mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-16 06:52:27 +00:00
- simplify option flags
- do not print header when using -c - linklocal address are not cleared when using -c Obtained from: KAME
This commit is contained in:
parent
4336716b84
commit
02647224e9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=66865
|
@ -1,5 +1,5 @@
|
||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
/* $KAME: ndp.c,v 1.41 2000/07/04 12:54:11 jinmei Exp $ */
|
/* $KAME: ndp.c,v 1.46 2000/10/09 09:17:10 sumikawa Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
|
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
|
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
|
||||||
|
|
||||||
static int pid;
|
static int pid;
|
||||||
static int fflag;
|
static int cflag;
|
||||||
static int nflag;
|
static int nflag;
|
||||||
static int tflag;
|
static int tflag;
|
||||||
static int32_t thiszone; /* time difference with gmt */
|
static int32_t thiszone; /* time difference with gmt */
|
||||||
|
@ -168,7 +168,7 @@ main(argc, argv)
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
int aflag = 0, cflag = 0, dflag = 0, sflag = 0, Hflag = 0,
|
int aflag = 0, dflag = 0, sflag = 0, Hflag = 0,
|
||||||
pflag = 0, rflag = 0, Pflag = 0, Rflag = 0;
|
pflag = 0, rflag = 0, Pflag = 0, Rflag = 0;
|
||||||
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
|
@ -179,7 +179,6 @@ main(argc, argv)
|
||||||
aflag = 1;
|
aflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
fflag = 1;
|
|
||||||
cflag = 1;
|
cflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
|
@ -562,7 +561,7 @@ dump(addr)
|
||||||
char flgbuf[8];
|
char flgbuf[8];
|
||||||
|
|
||||||
/* Print header */
|
/* Print header */
|
||||||
if (!tflag)
|
if (!tflag && !cflag)
|
||||||
printf("%-31.31s %-17.17s %6.6s %-9.9s %2s %4s %4s\n",
|
printf("%-31.31s %-17.17s %6.6s %-9.9s %2s %4s %4s\n",
|
||||||
"Neighbor", "Linklayer Address", "Netif", "Expire",
|
"Neighbor", "Linklayer Address", "Netif", "Expire",
|
||||||
"St", "Flgs", "Prbs");
|
"St", "Flgs", "Prbs");
|
||||||
|
@ -597,24 +596,23 @@ again:;
|
||||||
found_entry = 1;
|
found_entry = 1;
|
||||||
} else if (IN6_IS_ADDR_MULTICAST(&sin->sin6_addr))
|
} else if (IN6_IS_ADDR_MULTICAST(&sin->sin6_addr))
|
||||||
continue;
|
continue;
|
||||||
if (fflag == 1) {
|
|
||||||
delete((char *)inet_ntop(AF_INET6, &sin->sin6_addr,
|
|
||||||
ntop_buf, sizeof(ntop_buf)));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr) ||
|
if (IN6_IS_ADDR_LINKLOCAL(&sin->sin6_addr) ||
|
||||||
IN6_IS_ADDR_MC_LINKLOCAL(&sin->sin6_addr)) {
|
IN6_IS_ADDR_MC_LINKLOCAL(&sin->sin6_addr)) {
|
||||||
/* XXX: should scope id be filled in the kernel? */
|
/* XXX: should scope id be filled in the kernel? */
|
||||||
if (sin->sin6_scope_id == 0)
|
if (sin->sin6_scope_id == 0)
|
||||||
sin->sin6_scope_id = sdl->sdl_index;
|
sin->sin6_scope_id = sdl->sdl_index;
|
||||||
|
#ifdef __KAME__
|
||||||
/* XXX: KAME specific hack; removed the embedded id */
|
/* KAME specific hack; removed the embedded id */
|
||||||
*(u_int16_t *)&sin->sin6_addr.s6_addr[2] = 0;
|
*(u_int16_t *)&sin->sin6_addr.s6_addr[2] = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf,
|
getnameinfo((struct sockaddr *)sin, sin->sin6_len, host_buf,
|
||||||
sizeof(host_buf), NULL, 0,
|
sizeof(host_buf), NULL, 0,
|
||||||
NI_WITHSCOPEID | (nflag ? NI_NUMERICHOST : 0));
|
NI_WITHSCOPEID | (nflag ? NI_NUMERICHOST : 0));
|
||||||
|
if (cflag == 1) {
|
||||||
|
delete(host_buf);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
gettimeofday(&time, 0);
|
gettimeofday(&time, 0);
|
||||||
if (tflag)
|
if (tflag)
|
||||||
ts_print(&time);
|
ts_print(&time);
|
||||||
|
|
Loading…
Reference in a new issue