diff options
author | Hajimu UMEMOTO <ume@FreeBSD.org> | 2003-08-08 16:56:01 +0000 |
---|---|---|
committer | Hajimu UMEMOTO <ume@FreeBSD.org> | 2003-08-08 16:56:01 +0000 |
commit | fa19f9be0400bf0b77b89ad6940eb0675235db1c (patch) | |
tree | 178f6af642cf6aacbd3415e4286f66d0b9bd3bba /usr.sbin/rtsold/probe.c | |
parent | 5ed8c16b882bf0cd10fa24e3dd8aacbe1b60d8bb (diff) | |
download | src-fa19f9be0400bf0b77b89ad6940eb0675235db1c.tar.gz src-fa19f9be0400bf0b77b89ad6940eb0675235db1c.zip |
KNF, correct typos and cleanup spaces.
Obtained from: KAME
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=118664
Diffstat (limited to 'usr.sbin/rtsold/probe.c')
-rw-r--r-- | usr.sbin/rtsold/probe.c | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/usr.sbin/rtsold/probe.c b/usr.sbin/rtsold/probe.c index c7b07e23fb03..33f33f9cb3d3 100644 --- a/usr.sbin/rtsold/probe.c +++ b/usr.sbin/rtsold/probe.c @@ -61,16 +61,15 @@ static struct msghdr sndmhdr; static struct iovec sndiov[2]; static int probesock; -static void sendprobe __P((struct in6_addr *addr, int ifindex)); - +static void sendprobe __P((struct in6_addr *, int)); int probe_init() { int scmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + - CMSG_SPACE(sizeof(int)); + CMSG_SPACE(sizeof(int)); static u_char *sndcmsgbuf = NULL; - + if (sndcmsgbuf == NULL && (sndcmsgbuf = (u_char *)malloc(scmsglen)) == NULL) { warnmsg(LOG_ERR, __func__, "malloc failed"); @@ -94,12 +93,11 @@ probe_init() sndmhdr.msg_iovlen = 1; sndmhdr.msg_control = (caddr_t)sndcmsgbuf; sndmhdr.msg_controllen = scmsglen; - return(0); } /* - * Probe if each router in the default router list is still alive. + * Probe if each router in the default router list is still alive. */ void defrouter_probe(int ifindex) @@ -116,30 +114,29 @@ defrouter_probe(int ifindex) strcpy(dr.ifname, "lo0"); /* dummy interface */ if (ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) { warnmsg(LOG_ERR, __func__, "ioctl(SIOCGDRLST_IN6): %s", - strerror(errno)); + strerror(errno)); goto closeandend; } - for(i = 0; dr.defrouter[i].if_index && i < PRLSTSIZ; i++) { + for (i = 0; dr.defrouter[i].if_index && i < PRLSTSIZ; i++) { if (ifindex && dr.defrouter[i].if_index == ifindex) { /* sanity check */ if (!IN6_IS_ADDR_LINKLOCAL(&dr.defrouter[i].rtaddr)) { warnmsg(LOG_ERR, __func__, - "default router list contains a " - "non-linklocal address(%s)", - inet_ntop(AF_INET6, - &dr.defrouter[i].rtaddr, - ntopbuf, INET6_ADDRSTRLEN)); + "default router list contains a " + "non-link-local address(%s)", + inet_ntop(AF_INET6, + &dr.defrouter[i].rtaddr, + ntopbuf, INET6_ADDRSTRLEN)); continue; /* ignore the address */ } sendprobe(&dr.defrouter[i].rtaddr, - dr.defrouter[i].if_index); + dr.defrouter[i].if_index); } } - closeandend: +closeandend: close(s); - return; } static void @@ -148,7 +145,8 @@ sendprobe(struct in6_addr *addr, int ifindex) struct sockaddr_in6 sa6_probe; struct in6_pktinfo *pi; struct cmsghdr *cm; - u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ];; + u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; + int hoplimit = 1; bzero(&sa6_probe, sizeof(sa6_probe)); sa6_probe.sin6_family = AF_INET6; @@ -169,23 +167,17 @@ sendprobe(struct in6_addr *addr, int ifindex) pi->ipi6_ifindex = ifindex; /* specify the hop limit of the packet for safety */ - { - int hoplimit = 1; - - cm = CMSG_NXTHDR(&sndmhdr, cm); - cm->cmsg_level = IPPROTO_IPV6; - cm->cmsg_type = IPV6_HOPLIMIT; - cm->cmsg_len = CMSG_LEN(sizeof(int)); - memcpy(CMSG_DATA(cm), &hoplimit, sizeof(int)); - } + cm = CMSG_NXTHDR(&sndmhdr, cm); + cm->cmsg_level = IPPROTO_IPV6; + cm->cmsg_type = IPV6_HOPLIMIT; + cm->cmsg_len = CMSG_LEN(sizeof(int)); + memcpy(CMSG_DATA(cm), &hoplimit, sizeof(int)); warnmsg(LOG_DEBUG, __func__, "probe a router %s on %s", - inet_ntop(AF_INET6, addr, ntopbuf, INET6_ADDRSTRLEN), - if_indextoname(ifindex, ifnamebuf)); + inet_ntop(AF_INET6, addr, ntopbuf, INET6_ADDRSTRLEN), + if_indextoname(ifindex, ifnamebuf)); if (sendmsg(probesock, &sndmhdr, 0)) warnmsg(LOG_ERR, __func__, "sendmsg on %s: %s", - if_indextoname(ifindex, ifnamebuf), strerror(errno)); - - return; + if_indextoname(ifindex, ifnamebuf), strerror(errno)); } |