Permalink
Browse files

Much fixes to work as inteded for MN.

  • Loading branch information...
1 parent 1194eed commit d8d7273b082b45602bc4f92274303123c22b7102 t-momose committed Feb 19, 2007
View
@@ -1,4 +1,4 @@
-/* $Id: babymdd.c,v 1.28 2007/02/10 04:30:56 t-momose Exp $ */
+/* $Id: babymdd.c,v 1.29 2007/02/19 08:13:03 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
@@ -293,9 +293,13 @@ main (argc, argv)
while (1) {
if (force_mdreg) {
- if (babyinfo.whereami == IAMFOREIGN)
- baby_md_reg((struct sockaddr *)&babyinfo.coaif->coa,
- babyinfo.coaif->ifindex, babyinfo.coaif->bid);
+ if (babyinfo.whereami == IAMFOREIGN) {
+ if (babyinfo.coaif == NULL)
+ syslog(LOG_ERR, "No CoA i/f available");
+ else
+ baby_md_reg((struct sockaddr *)&babyinfo.coaif->coa,
+ babyinfo.coaif->ifindex, babyinfo.coaif->bid);
+ }
force_mdreg = 0;
}
FD_ZERO(&fds);
View
@@ -1,4 +1,4 @@
-/* $KAME: callout.c,v 1.11 2007/02/18 18:09:57 t-momose Exp $ */
+/* $KAME: callout.c,v 1.12 2007/02/19 08:13:04 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project.
@@ -201,15 +201,15 @@ remove_callout_entry(ch)
/* There are no necessary to reschedule the expiration. */
}
-void
+int
update_callout_entry(ch, sec)
CALLOUT_HANDLE ch;
int sec;
{
struct callout_queue_t *cq;
if (sec == 0)
- return;
+ return (-1);
/* This is the very simplest way. there must be
more efficient ways */
@@ -218,12 +218,14 @@ update_callout_entry(ch, sec)
break;
}
if (cq == NULL)
- return;
+ return (0);
TAILQ_REMOVE(&callout_head, ch, callout_entry);
gettimeofday(&ch->exptime, NULL);
ch->exptime.tv_sec += sec;
insert_callout_queue(ch);
+
+ return (1);
}
int
@@ -255,35 +257,35 @@ show_callout_table(s, line)
{
struct timeval current_time, t;
struct callout_queue_t *cq;
- struct tm *ctm;
+ struct tm ctm;
gettimeofday(&current_time, NULL);
- ctm = localtime((time_t *)&current_time.tv_sec);
+ localtime_r((time_t *)&current_time.tv_sec, &ctm);
TAILQ_FOREACH(cq, &callout_head, callout_entry) {
- struct tm *etm;
+ struct tm etm;
int dispday = 0;
- etm = localtime((time_t *)&cq->exptime.tv_sec);
- if (ctm->tm_year != etm->tm_year) {
- command_printf(s, "%04d/", etm->tm_year + 1900);
+ localtime_r((time_t *)&cq->exptime.tv_sec, &etm);
+ if (ctm.tm_year != etm.tm_year) {
+ command_printf(s, "%04d/", etm.tm_year + 1900);
dispday = 1;
}
- if (dispday || (ctm->tm_mon != etm->tm_mon)) {
- command_printf(s, "%02d/", etm->tm_mon);
+ if (dispday || (ctm.tm_mon != etm.tm_mon)) {
+ command_printf(s, "%02d/", etm.tm_mon);
dispday = 1;
}
- if (dispday || (ctm->tm_mday != etm->tm_mday)) {
+ if (dispday || (ctm.tm_mday != etm.tm_mday)) {
if (!dispday)
- command_printf(s, "+%02d ", etm->tm_mday - ctm->tm_mday);
+ command_printf(s, "+%02d ", etm.tm_mday - ctm.tm_mday);
else
- command_printf(s, "%02d ", etm->tm_mday);
+ command_printf(s, "%02d ", etm.tm_mday);
}
timersub(&cq->exptime, &current_time, &t);
command_printf(s, "%02d:%02d:%02d(%ld.%06lds) %s() for %p\n",
- etm->tm_hour, etm->tm_min, etm->tm_sec,
- t.tv_sec, t.tv_usec,
- cq->funcname, cq->arg);
+ etm.tm_hour, etm.tm_min, etm.tm_sec,
+ t.tv_sec, t.tv_usec,
+ cq->funcname, cq->arg);
}
}
@@ -1,4 +1,4 @@
-/* $KAME: callout.h,v 1.6 2006/09/29 08:00:51 t-momose Exp $ */
+/* $KAME: callout.h,v 1.7 2007/02/19 08:13:04 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project.
@@ -51,7 +51,7 @@ void shisad_callout_init(void);
void callout_expire_check(void);
CALLOUT_HANDLE new_callout_entry(int, void (*)(void *), void *, char *);
void remove_callout_entry(CALLOUT_HANDLE ch);
-void update_callout_entry(CALLOUT_HANDLE ch, int);
+int update_callout_entry(CALLOUT_HANDLE ch, int);
int get_next_timeout(void);
void show_callout_table(int, char *);
@@ -1,4 +1,4 @@
-/* $KAME: common.c,v 1.36 2007/02/17 13:09:26 t-momose Exp $ */
+/* $KAME: common.c,v 1.37 2007/02/19 08:13:04 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
@@ -529,7 +529,8 @@ icmp6_input_common(fd)
* determin which BU is failed or not. so remove all
* BU entries anyway
*/
- syslog(LOG_ERR, "ICMP6 error: hoa=%s peer=%s",
+ syslog(LOG_ERR, "ICMP6 error: type:%02x cod:%02x hoa=%s peer=%s",
+ icp->icmp6_type, icp->icmp6_code,
ip6_sprintf(&dst), ip6_sprintf(peer));
bul = bul_get(&dst, peer);
if (bul == NULL)
View
@@ -1,4 +1,4 @@
-/* $KAME: fsm.c,v 1.44 2007/02/18 18:09:57 t-momose Exp $ */
+/* $KAME: fsm.c,v 1.45 2007/02/19 08:13:04 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
@@ -92,9 +92,21 @@ static void bul_stop_retrans_timer(struct binding_update_list *);
static void bul_stop_timers(struct binding_update_list *);
#define bul_set_retrans_timer(bul, tick) \
- update_callout_entry((bul)->bul_retrans, (tick))
+ do { \
+ if (update_callout_entry((bul)->bul_retrans, (tick)) == 0) { \
+ (bul)->bul_retrans = \
+ new_callout_entry((tick), bul_retrans_timer, \
+ (void *)(bul), "bul_retrans_timer"); \
+ } \
+ } while (/*CONTSTCOND*/0)
#define bul_set_expire_timer(bul, tick) \
- update_callout_entry((bul)->bul_expire, (tick))
+ do { \
+ if (update_callout_entry((bul)->bul_expire, (tick)) == 0) { \
+ (bul)->bul_expire = \
+ new_callout_entry((tick), bul_expire_timer, \
+ (void *)(bul), "bul_expire_timer"); \
+ } \
+ } while (/*CONTSTCOND*/0)
/*
* return value:
View
@@ -1,4 +1,4 @@
-/* $KAME: mh.c,v 1.60 2007/01/14 05:56:42 keiichi Exp $ */
+/* $KAME: mh.c,v 1.61 2007/02/19 08:13:04 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
*
@@ -1569,11 +1569,6 @@ send_bu(bul)
}
/* create tunnel */
-# if 0
-/* DON'T LEAVE SUCH ADHOC CODE ONLY FOR YOUR SPECIFIC DEBUGGING ENVIRONMENT SO LONG TIME */
-system("ifconfig nemo0 tunnel 203.178.128.64 203.178.128.50 up");
-#endif
-
error = v4_sendmessage((char *)bufp, buflen, 0,
&bul->bul_peeraddr, &bul->bul_coa,
&hal->hal_ip6addr,
@@ -1631,11 +1626,11 @@ send_ba(src, coa, acoa, hoa, flags, kbm_p, status, seqno, lifetime, refresh, bid
hoa = coa;
/* section 9.5.4 if hoa is not unicast global, BA should not be sent */
- if (hoa && (IN6_IS_ADDR_LINKLOCAL(hoa)
- || IN6_IS_ADDR_MULTICAST(hoa)
- || IN6_IS_ADDR_LOOPBACK(hoa)
- || IN6_IS_ADDR_V4MAPPED(hoa)
- || IN6_IS_ADDR_UNSPECIFIED(hoa)))
+ if (hoa && (IN6_IS_ADDR_LINKLOCAL(hoa)
+ || IN6_IS_ADDR_MULTICAST(hoa)
+ || IN6_IS_ADDR_LOOPBACK(hoa)
+ || IN6_IS_ADDR_V4MAPPED(hoa)
+ || IN6_IS_ADDR_UNSPECIFIED(hoa)))
return (EINVAL);
memset(buf, 0, sizeof(buf));
@@ -1675,7 +1670,7 @@ send_ba(src, coa, acoa, hoa, flags, kbm_p, status, seqno, lifetime, refresh, bid
buflen += pad;
memset(&bid_opt, 0, sizeof(bid_opt));
-
+
bid_opt.ip6mobid_type = IP6_MHOPT_BID;
bid_opt.ip6mobid_len = 4;
bid_opt.ip6mobid_bid = htons(bid);
@@ -1902,42 +1897,42 @@ checksum_p(src, dst, addr, len, nxt)
u_int16_t *src, *dst, *addr;
int len, nxt;
{
- int sum;
- u_int16_t s;
+ int sum;
+ u_int16_t s;
if (src == NULL || dst == NULL || addr == NULL)
return (-1);
- sum = 0;
+ sum = 0;
- /* add pseudo ip header */
- s = 8;
- while (s--) {
- sum += *src++;
- sum += *dst++;
- }
+ /* add pseudo ip header */
+ s = 8;
+ while (s--) {
+ sum += *src++;
+ sum += *dst++;
+ }
- sum += htons(len >> 16);
- sum += htons(len & 0xffff);
- sum += htons(nxt);
+ sum += htons(len >> 16);
+ sum += htons(len & 0xffff);
+ sum += htons(nxt);
- /* add payload data */
- while (len > 1) {
- sum += *addr++;
- len -= 2;
- }
+ /* add payload data */
+ while (len > 1) {
+ sum += *addr++;
+ len -= 2;
+ }
- if (len) {
- s = 0;
- *(unsigned char *)(&s) = *(unsigned char *)addr;
- sum += s;
- }
+ if (len) {
+ s = 0;
+ *(unsigned char *)(&s) = *(unsigned char *)addr;
+ sum += s;
+ }
- /* add overflow counts */
- while (sum >> 16)
- sum = (sum >> 16) + (sum & 0xffff);
+ /* add overflow counts */
+ while (sum >> 16)
+ sum = (sum >> 16) + (sum & 0xffff);
- return (~sum);
+ return (~sum);
}
@@ -1957,9 +1952,9 @@ sendmessage(mhdata, mhdatalen, ifindex, src, dst, haoaddr, rtaddr)
struct cmsghdr *cmsgptr = NULL;
register struct in6_pktinfo *pi;
struct ip6_opt_home_address *hoadst;
- struct ip6_rthdr2 *rtopt = NULL;
+ struct ip6_rthdr2 *rtopt = NULL;
struct ip6_dest *dest;
- char adata [1024];
+ char adata [1024];
#if defined(MIP_MN)
struct sockaddr_in6 *ar_sin6 = NULL, ar_sin6_orig;
#endif
@@ -1992,8 +1987,8 @@ sendmessage(mhdata, mhdatalen, ifindex, src, dst, haoaddr, rtaddr)
CMSG_SPACE(sizeof(struct sockaddr_in6));
}
#endif /* MIP_MN */
- iov.iov_base = mhdata;
- iov.iov_len = mhdatalen;
+ iov.iov_base = mhdata;
+ iov.iov_len = mhdatalen;
/* Packet Information i.e. Source Address */
cmsgptr = CMSG_FIRSTHDR(&msg);
@@ -2148,8 +2143,8 @@ v4_sendmessage(mhdata, mhdatalen, ifindex, v4dst, src, dst, hoa, rtaddr)
sizeof(struct ip6_dest) + MIP6_HOAOPT_PADLEN;
}
- /* Routing Header */
- if (rtaddr) {
+ /* Routing Header */
+ if (rtaddr) {
ip6->ip6_nxt = IPPROTO_ROUTING;
rtopt = (struct ip6_rthdr2 *)(ip6 + 1);
@@ -2160,7 +2155,7 @@ v4_sendmessage(mhdata, mhdatalen, ifindex, v4dst, src, dst, hoa, rtaddr)
rtopt->ip6r2_reserved = 0;
memcpy((rtopt + 1), rtaddr, sizeof(struct in6_addr));
buflen += sizeof(struct ip6_rthdr2) + sizeof(struct in6_addr);
- }
+ }
memcpy(buf+buflen, mhdata, mhdatalen);
buflen += mhdatalen;
@@ -2242,8 +2237,8 @@ v4_sendmessage(mhdata, mhdatalen, ifindex, v4dst, src, dst, hoa, rtaddr)
sizeof(struct ip6_dest) + MIP6_HOAOPT_PADLEN;
}
- /* Routing Header */
- if (rtaddr) {
+ /* Routing Header */
+ if (rtaddr) {
ip6->ip6_nxt = IPPROTO_ROUTING;
rtopt = (struct ip6_rthdr2 *)(ip6 + 1);
@@ -2254,7 +2249,7 @@ v4_sendmessage(mhdata, mhdatalen, ifindex, v4dst, src, dst, hoa, rtaddr)
rtopt->ip6r2_reserved = 0;
memcpy((rtopt + 1), rtaddr, sizeof(struct in6_addr));
buflen += sizeof(struct ip6_rthdr2) + sizeof(struct in6_addr);
- }
+ }
memcpy(buf+buflen, mhdata, mhdatalen);
buflen += mhdatalen;
View
@@ -1,4 +1,4 @@
-/* $KAME: mnd.c,v 1.50 2007/02/13 02:32:41 t-momose Exp $ */
+/* $KAME: mnd.c,v 1.51 2007/02/19 08:13:04 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project.
@@ -1348,6 +1348,9 @@ hpfxlist_set_expire_timer(hpfx, tick)
remove_callout_entry(hpfx->hpfx_retrans);
hpfx->hpfx_retrans = new_callout_entry(tick, hpfxlist_expire_timer,
(void *)hpfx, "hpfxlist_expire_timer");
+ if (hpfx->hpfx_retrans == NULL) {
+ syslog(LOG_ERR, "hpfxlist_set_expire_time() was failed (tick = %d)", tick);
+ }
}
void

0 comments on commit d8d7273

Please sign in to comment.