summaryrefslogtreecommitdiff
path: root/usr.sbin/ndp
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-04-17 04:44:52 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-04-17 04:44:52 +0000
commit21c2e6c965d401f6359663687069efbf69376e00 (patch)
tree324898ea862ad4e4badb4620d5d2e6159627b0f0 /usr.sbin/ndp
parentfe45f154d1f286c742242fe504ccad68e20378f9 (diff)
revisit in6_ifattach(). (1) make it more persistent about initializaing an
interface (2) cleanup interface id selection. run NUD on p2p interface (required by spec for bidir p2p interface). add "ndp -i interface" (can tweak per-interface ND flag). (sync with more recent kame)
Diffstat (limited to 'usr.sbin/ndp')
-rw-r--r--usr.sbin/ndp/ndp.832
-rw-r--r--usr.sbin/ndp/ndp.c73
2 files changed, 83 insertions, 22 deletions
diff --git a/usr.sbin/ndp/ndp.8 b/usr.sbin/ndp/ndp.8
index 70282196a97..3ffcf015ec4 100644
--- a/usr.sbin/ndp/ndp.8
+++ b/usr.sbin/ndp/ndp.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ndp.8,v 1.6 2000/04/12 21:47:55 aaron Exp $
+.\" $OpenBSD: ndp.8,v 1.7 2000/04/17 04:44:51 itojun Exp $
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" KAME Id: ndp.8,v 1.5 2000/02/17 05:35:56 itojun Exp
+.\" KAME Id: ndp.8,v 1.9 2000/04/16 15:17:33 itojun Exp
.\"
.Dd May 17, 1998
.Dt NDP 8
@@ -63,6 +63,7 @@
.Nm ndp
.Fl i
.Ar interface
+.Op Ar flags...
.Nm ndp
.Fl p
.Nm ndp
@@ -105,18 +106,33 @@ Harmonize consistency between the routing table and the default router
list; install the top entry of the list into the kernel routing table.
.It Fl I Op delete \(ba Ar interface
Shows or specifies the default interface used as the default route when
-there is no default router.
-If no argument is given to the option,
-the current deafult interface will be shown.
+there is no default router. If no argument is given to the option,
+the current default interface will be shown.
If an
.Ar interface
is specified, the interface will be used as the default.
If a special keyword
.Ic delete
is specified, the current default interface will be deleted from the kernel.
-.It Fl i
-.Ar interface
-view ND information for specified interface.
+.It Fl i Ar interface Op Ar flags...
+View ND information for the specified interface.
+If additional arguments
+.Ar flags
+are given,
+.Nm
+sets or clears the specified flags for the interface.
+Possible flags are as follows. All of the flags can begin with the
+special character
+.Ql - ,
+which means the flag should be cleared.
+.\"
+.Bl -tag -width Ds -compact
+.It Xo
+.Ic nud
+.Xc
+turn on or off NUD (Neighbor Unreachability Detection) on the
+interface. NUD is usually turned on by default.
+.El
.It Fl l
Do not truncate numeric IPv6 address.
.It Fl n
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index e02383d527a..cdf24ffc974 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ndp.c,v 1.4 2000/02/28 11:56:41 itojun Exp $ */
+/* $OpenBSD: ndp.c,v 1.5 2000/04/17 04:44:51 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
@@ -150,7 +150,7 @@ static char *ether_str __P((struct sockaddr_dl *));
int ndp_ether_aton __P((char *, u_char *));
void usage __P((void));
int rtmsg __P((int));
-void ifinfo __P((char *));
+void ifinfo __P((int, char **));
void rtrlist __P((void));
void plist __P((void));
void pfx_flush __P((void));
@@ -200,9 +200,11 @@ main(argc, argv)
/*NOTREACHED*/
#endif
case 'i' :
- if (argc != 3)
+ argc -= optind;
+ argv += optind;
+ if (argc < 1)
usage();
- ifinfo(argv[2]);
+ ifinfo(argc, argv);
exit(0);
case 'n':
nflag = 1;
@@ -484,12 +486,16 @@ delete(host)
if (IN6_ARE_ADDR_EQUAL(&sin->sin6_addr, &sin_m.sin6_addr)) {
if (sdl->sdl_family == AF_LINK &&
(rtm->rtm_flags & RTF_LLINFO) &&
- !(rtm->rtm_flags & RTF_GATEWAY)) switch (sdl->sdl_type) {
- case IFT_ETHER: case IFT_FDDI: case IFT_ISO88023:
- case IFT_ISO88024: case IFT_ISO88025:
- goto delete;
+ !(rtm->rtm_flags & RTF_GATEWAY)) {
+ switch (sdl->sdl_type) {
+ case IFT_ETHER: case IFT_FDDI: case IFT_ISO88023:
+ case IFT_ISO88024: case IFT_ISO88025:
+ goto delete;
+ }
}
}
+ return 0;
+
delete:
if (sdl->sdl_family != AF_LINK) {
printf("cannot locate %s\n", host);
@@ -692,7 +698,7 @@ getnbrinfo(addr, ifindex, warning)
nbi.addr = *addr;
if (ioctl(s, SIOCGNBRINFO_IN6, (caddr_t)&nbi) < 0) {
if (warning)
- warn("ioctl");
+ warn("ioctl(SIOCGNBRINFO_IN6)");
close(s);
return(NULL);
}
@@ -747,7 +753,7 @@ usage()
printf(" ndp -c[nt]\n");
printf(" ndp -d[nt] hostname\n");
printf(" ndp -f[nt] filename\n");
- printf(" ndp -i interface\n");
+ printf(" ndp -i interface [flags...]\n");
#ifdef SIOCSDEFIFACE_IN6
printf(" ndp -I [interface|delete]\n");
#endif
@@ -824,11 +830,14 @@ doit:
}
void
-ifinfo(ifname)
- char *ifname;
+ifinfo(argc, argv)
+ int argc;
+ char **argv;
{
struct in6_ndireq nd;
- int s;
+ int i, s;
+ char *ifname = argv[0];
+ u_int32_t newflags;
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
perror("ndp: socket");
@@ -841,13 +850,49 @@ ifinfo(ifname)
exit(1);
}
#define ND nd.ndi
+ newflags = ND.flags;
+ for (i = 1; i < argc; i++) {
+ int clear = 0;
+ char *cp = argv[i];
+
+ if (*cp == '-') {
+ clear = 1;
+ cp++;
+ }
+
+#define SETFLAG(s, f) \
+ do {\
+ if (strcmp(cp, (s)) == 0) {\
+ if (clear)\
+ newflags &= ~(f);\
+ else\
+ newflags |= (f);\
+ }\
+ } while (0)
+ SETFLAG("nud", ND6_IFF_PERFORMNUD);
+
+ ND.flags = newflags;
+ if (ioctl(s, SIOCSIFINFO_FLAGS, (caddr_t)&nd) < 0) {
+ perror("ioctl(SIOCSIFINFO_FLAGS)");
+ exit(1);
+ }
+#undef SETFLAG
+ }
+
printf("linkmtu=%d", ND.linkmtu);
printf(", curhlim=%d", ND.chlim);
printf(", basereachable=%ds%dms",
ND.basereachable / 1000, ND.basereachable % 1000);
printf(", reachable=%ds", ND.reachable);
- printf(", retrans=%ds%dms\n", ND.retrans / 1000, ND.retrans % 1000);
+ printf(", retrans=%ds%dms", ND.retrans / 1000, ND.retrans % 1000);
+ if (ND.flags) {
+ printf("\nFlags: ");
+ if ((ND.flags & ND6_IFF_PERFORMNUD) != 0)
+ printf("PERFORMNUD ");
+ }
+ putc('\n', stdout);
#undef ND
+
close(s);
}