diff options
author | suz <suz@FreeBSD.org> | 2005-10-19 15:05:42 +0000 |
---|---|---|
committer | suz <suz@FreeBSD.org> | 2005-10-19 15:05:42 +0000 |
commit | 7cb7aed97b0e1c3253828f94db5e8b65429fded3 (patch) | |
tree | 3dc9168e29ff177252961d6c77b2be13d7b389e2 /usr.sbin/ndp/ndp.c | |
parent | e0f0e9f59a385855edfc18a8090a03938fea36b2 (diff) | |
download | FreeBSD-src-7cb7aed97b0e1c3253828f94db5e8b65429fded3.zip FreeBSD-src-7cb7aed97b0e1c3253828f94db5e8b65429fded3.tar.gz |
added an ioctl option in kernel so that ndp/rtadvd can change some NDP-related kernel variables based on their configurations (RFC2461 p.43 6.2.1 mandates this for IPv6 routers)
Obtained from: KAME
Reviewd by: ume, gnn
MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/ndp/ndp.c')
-rw-r--r-- | usr.sbin/ndp/ndp.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index de3a80a..31ed677 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -965,6 +965,27 @@ ifinfo(ifname, argc, argv) newflags |= (f);\ }\ } while (0) +/* + * XXX: this macro is not 100% correct, in that it matches "nud" against + * "nudbogus". But we just let it go since this is minor. + */ +#define SETVALUE(f, v) \ + do { \ + char *valptr; \ + unsigned long newval; \ + v = 0; /* unspecified */ \ + if (strncmp(cp, f, strlen(f)) == 0) { \ + valptr = strchr(cp, '='); \ + if (valptr == NULL) \ + err(1, "syntax error in %s field", (f)); \ + errno = 0; \ + newval = strtoul(++valptr, NULL, 0); \ + if (errno) \ + err(1, "syntax error in %s's value", (f)); \ + v = newval; \ + } \ + } while (0) + SETFLAG("nud", ND6_IFF_PERFORMNUD); #ifdef ND6_IFF_ACCEPT_RTADV SETFLAG("accept_rtadv", ND6_IFF_ACCEPT_RTADV); @@ -972,13 +993,17 @@ ifinfo(ifname, argc, argv) #ifdef ND6_IFF_PREFER_SOURCE SETFLAG("prefer_source", ND6_IFF_PREFER_SOURCE); #endif + SETVALUE("basereachable", ND.basereachable); + SETVALUE("retrans", ND.retrans); + SETVALUE("curhlim", ND.chlim); ND.flags = newflags; - if (ioctl(s, SIOCSIFINFO_FLAGS, (caddr_t)&nd) < 0) { - err(1, "ioctl(SIOCSIFINFO_FLAGS)"); + if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&nd) < 0) { + err(1, "ioctl(SIOCSIFINFO_IN6)"); /* NOTREACHED */ } #undef SETFLAG +#undef SETVALUE } if (!ND.initialized) { @@ -986,6 +1011,10 @@ ifinfo(ifname, argc, argv) /* NOTREACHED */ } + if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) { + err(1, "ioctl(SIOCGIFINFO_IN6)"); + /* NOTREACHED */ + } printf("linkmtu=%d", ND.linkmtu); printf(", maxmtu=%d", ND.maxmtu); printf(", curhlim=%d", ND.chlim); |