diff options
author | ume <ume@FreeBSD.org> | 2003-08-17 11:11:32 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2003-08-17 11:11:32 +0000 |
commit | e63e485957ca75728d14f0f841a255c547024105 (patch) | |
tree | 71f0ce4c364fa35219a41194d4e21717734ebb58 /usr.sbin/rtsold/probe.c | |
parent | d21c6d5071dfec3042de4b42f1f7754eeb80247b (diff) | |
download | FreeBSD-src-e63e485957ca75728d14f0f841a255c547024105.zip FreeBSD-src-e63e485957ca75728d14f0f841a255c547024105.tar.gz |
- improved the -a option. it can probe a interface automatically when
the interface wake up. it can be started anytime even when there is
no network interface on the list of intarfaces in the kernel.
- get a correct link ID for each interface at initialization
(using scope libraries if HAVE_SCOPELIB is defined).
- fill in sin6_scope_id correctly before sendmsg().
Obtained from: KAME
MFC after: 1 week
Diffstat (limited to 'usr.sbin/rtsold/probe.c')
-rw-r--r-- | usr.sbin/rtsold/probe.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/usr.sbin/rtsold/probe.c b/usr.sbin/rtsold/probe.c index 9b86c63..b7e7cc6 100644 --- a/usr.sbin/rtsold/probe.c +++ b/usr.sbin/rtsold/probe.c @@ -1,4 +1,4 @@ -/* $KAME: probe.c,v 1.10 2000/08/13 06:14:59 itojun Exp $ */ +/* $KAME: probe.c,v 1.16 2002/06/10 20:00:36 itojun Exp $ */ /* * Copyright (C) 1998 WIDE Project. @@ -40,6 +40,7 @@ #include <net/if.h> #include <net/if_var.h> +#include <net/if_dl.h> #include <netinet/in.h> #include <netinet6/in6_var.h> @@ -59,7 +60,7 @@ static struct msghdr sndmhdr; static struct iovec sndiov[2]; static int probesock; -static void sendprobe __P((struct in6_addr *, int)); +static void sendprobe __P((struct in6_addr *, struct ifinfo *)); int probe_init() @@ -98,11 +99,12 @@ probe_init() * Probe if each router in the default router list is still alive. */ void -defrouter_probe(int ifindex) +defrouter_probe(struct ifinfo *ifinfo) { + u_char ntopbuf[INET6_ADDRSTRLEN]; struct in6_drlist dr; int s, i; - u_char ntopbuf[INET6_ADDRSTRLEN]; + int ifindex = ifinfo->sdl->sdl_index; if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { warnmsg(LOG_ERR, __func__, "socket: %s", strerror(errno)); @@ -128,8 +130,7 @@ defrouter_probe(int ifindex) ntopbuf, INET6_ADDRSTRLEN)); continue; /* ignore the address */ } - sendprobe(&dr.defrouter[i].rtaddr, - dr.defrouter[i].if_index); + sendprobe(&dr.defrouter[i].rtaddr, ifinfo); } } @@ -138,18 +139,20 @@ closeandend: } static void -sendprobe(struct in6_addr *addr, int ifindex) +sendprobe(struct in6_addr *addr, struct ifinfo *ifinfo) { + u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; struct sockaddr_in6 sa6_probe; struct in6_pktinfo *pi; struct cmsghdr *cm; - u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; + u_int32_t ifindex = ifinfo->sdl->sdl_index; int hoplimit = 1; memset(&sa6_probe, 0, sizeof(sa6_probe)); sa6_probe.sin6_family = AF_INET6; sa6_probe.sin6_len = sizeof(sa6_probe); sa6_probe.sin6_addr = *addr; + sa6_probe.sin6_scope_id = ifinfo->linkid; sndmhdr.msg_name = (caddr_t)&sa6_probe; sndmhdr.msg_iov[0].iov_base = NULL; |