sync with more recent kame code.
accept scoped address notation.
This commit is contained in:
parent
4696f48761
commit
f42e218016
@ -1,6 +1,9 @@
|
||||
.\" $NetBSD: ndp.8,v 1.8 2000/06/20 22:23:01 itojun Exp $
|
||||
.\" $KAME: ndp.8,v 1.12 2000/06/20 21:50:17 itojun Exp $
|
||||
.\"
|
||||
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
@ -12,7 +15,7 @@
|
||||
.\" 3. Neither the name of the project nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@ -25,16 +28,13 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $NetBSD: ndp.8,v 1.7 2000/04/16 15:28:01 itojun Exp $
|
||||
.\" KAME Id: ndp.8,v 1.9 2000/04/16 15:17:33 itojun Exp
|
||||
.\"
|
||||
.Dd May 17, 1998
|
||||
.Dt NDP 8
|
||||
.Os
|
||||
.\"
|
||||
.Sh NAME
|
||||
.Nm ndp
|
||||
.Nd control/diagnose IPv6 neighbor discovery protocol
|
||||
.Nd control/diagnose IPv6 neighbor discovery protocol
|
||||
.\"
|
||||
.Sh SYNOPSIS
|
||||
.Nm ndp
|
||||
@ -80,6 +80,7 @@
|
||||
.Op Li proxy
|
||||
.\"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
command manipulates the address mapping table
|
||||
used by Neighbor Discovery Protocol (NDP).
|
||||
@ -148,11 +149,11 @@ Flush all the entries in the default router list.
|
||||
Register a NDP entry for a node.
|
||||
The entry will be permanent unless the word
|
||||
.Li temp
|
||||
is given in the command.
|
||||
is given in the command.
|
||||
If the word
|
||||
.Li proxy
|
||||
is given, this system will act as an proxy NDP server,
|
||||
responding to requests for
|
||||
responding to requests for
|
||||
.Ar hostname
|
||||
even though the host address is not its own.
|
||||
.It Fl t
|
||||
@ -164,8 +165,9 @@ Most useful when used with
|
||||
.El
|
||||
.\"
|
||||
.Sh RETURN VALUES
|
||||
.Nm Ndp
|
||||
will exit with 0 on success, and non-zero on errors.
|
||||
The
|
||||
.Nm
|
||||
command will exit with 0 on success, and non-zero on errors.
|
||||
.\"
|
||||
.Sh SEE ALSO
|
||||
.Xr arp 8
|
||||
|
@ -1,7 +1,10 @@
|
||||
/* $NetBSD: ndp.c,v 1.9 2000/06/20 22:23:02 itojun Exp $ */
|
||||
/* $KAME: ndp.c,v 1.40 2000/06/20 21:50:17 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -13,7 +16,7 @@
|
||||
* 3. Neither the name of the project nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
@ -152,6 +155,7 @@ void ifinfo __P((int, char **));
|
||||
void rtrlist __P((void));
|
||||
void plist __P((void));
|
||||
void pfx_flush __P((void));
|
||||
void rtrlist __P((void));
|
||||
void rtr_flush __P((void));
|
||||
void harmonize_rtr __P((void));
|
||||
#ifdef SIOCSDEFIFACE_IN6 /* XXX: check SIOCGDEFIFACE_IN6 as well? */
|
||||
@ -255,6 +259,7 @@ main(argc, argv)
|
||||
if (argc != 1)
|
||||
usage();
|
||||
delete(argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
if (pflag) {
|
||||
plist();
|
||||
@ -376,6 +381,12 @@ set(argc, argv)
|
||||
return 1;
|
||||
}
|
||||
sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
|
||||
#ifdef __KAME__
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)) {
|
||||
*(u_int16_t *)&sin->sin6_addr.s6_addr[2] =
|
||||
htons(((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id);
|
||||
}
|
||||
#endif
|
||||
ea = (u_char *)LLADDR(&sdl_m);
|
||||
if (ndp_ether_aton(eaddr, ea) == 0)
|
||||
sdl_m.sdl_alen = 6;
|
||||
@ -389,7 +400,6 @@ set(argc, argv)
|
||||
flags |= RTF_ANNOUNCE;
|
||||
argv++;
|
||||
}
|
||||
tryagain:
|
||||
if (rtmsg(RTM_GET) < 0) {
|
||||
perror(host);
|
||||
return (1);
|
||||
@ -404,8 +414,13 @@ tryagain:
|
||||
case IFT_ISO88024: case IFT_ISO88025:
|
||||
goto overwrite;
|
||||
}
|
||||
goto tryagain;
|
||||
/*
|
||||
* IPv4 arp command retries with sin_other = SIN_PROXY here.
|
||||
*/
|
||||
fprintf(stderr, "set: cannot configure a new entry\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
overwrite:
|
||||
if (sdl->sdl_family != AF_LINK) {
|
||||
printf("cannot intuit interface index and type for %s\n", host);
|
||||
@ -437,6 +452,12 @@ get(host)
|
||||
return;
|
||||
}
|
||||
sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
|
||||
#ifdef __KAME__
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)) {
|
||||
*(u_int16_t *)&sin->sin6_addr.s6_addr[2] =
|
||||
htons(((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id);
|
||||
}
|
||||
#endif
|
||||
dump(&sin->sin6_addr);
|
||||
if (found_entry == 0) {
|
||||
getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf,
|
||||
@ -472,7 +493,12 @@ delete(host)
|
||||
return 1;
|
||||
}
|
||||
sin->sin6_addr = ((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
|
||||
/*tryagain:*/
|
||||
#ifdef __KAME__
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr)) {
|
||||
*(u_int16_t *)&sin->sin6_addr.s6_addr[2] =
|
||||
htons(((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id);
|
||||
}
|
||||
#endif
|
||||
if (rtmsg(RTM_GET) < 0) {
|
||||
perror(host);
|
||||
return (1);
|
||||
@ -489,8 +515,12 @@ delete(host)
|
||||
goto delete;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* IPv4 arp command retries with sin_other = SIN_PROXY here.
|
||||
*/
|
||||
fprintf(stderr, "delete: cannot delete non-NDP entry\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
delete:
|
||||
if (sdl->sdl_family != AF_LINK) {
|
||||
@ -498,7 +528,7 @@ delete:
|
||||
return (1);
|
||||
}
|
||||
if (rtmsg(RTM_DELETE) == 0) {
|
||||
getnameinfo((struct sockaddr *)sin,
|
||||
getnameinfo((struct sockaddr *)sin,
|
||||
sin->sin6_len, host_buf,
|
||||
sizeof(host_buf), NULL, 0,
|
||||
NI_WITHSCOPEID | (nflag ? NI_NUMERICHOST : 0));
|
||||
@ -521,6 +551,7 @@ dump(addr)
|
||||
struct rt_msghdr *rtm;
|
||||
struct sockaddr_in6 *sin;
|
||||
struct sockaddr_dl *sdl;
|
||||
extern int h_errno;
|
||||
struct in6_nbrinfo *nbi;
|
||||
struct timeval time;
|
||||
int addrwidth;
|
||||
@ -1038,7 +1069,7 @@ plist()
|
||||
printf(" (reachable)\n");
|
||||
break;
|
||||
default:
|
||||
printf(" (unreachable)\n");
|
||||
printf(" (unreachable)\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1112,7 +1143,7 @@ setdefif(ifname)
|
||||
err(1, "failed to resolve i/f index for %s", ifname);
|
||||
}
|
||||
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
err(1, "socket");
|
||||
|
||||
strcpy(ndifreq.ifname, "lo0"); /* dummy */
|
||||
@ -1130,7 +1161,7 @@ getdefif()
|
||||
struct in6_ndifreq ndifreq;
|
||||
char ifname[IFNAMSIZ+8];
|
||||
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
||||
err(1, "socket");
|
||||
|
||||
memset(&ndifreq, 0, sizeof(ndifreq));
|
||||
|
Loading…
Reference in New Issue
Block a user