Remove obsolete API (SIOCGDRLST_IN6 and SIOCGPRLST_IN6) support.
This commit is contained in:
parent
fb583bd228
commit
f34065a7fd
@ -150,14 +150,12 @@ static void setdefif(char *);
|
||||
static char *sec2str(time_t);
|
||||
static void ts_print(const struct timeval *);
|
||||
|
||||
#ifdef ICMPV6CTL_ND6_DRLIST
|
||||
static char *rtpref_str[] = {
|
||||
"medium", /* 00 */
|
||||
"high", /* 01 */
|
||||
"rsv", /* 10 */
|
||||
"low" /* 11 */
|
||||
};
|
||||
#endif
|
||||
|
||||
int mode = 0;
|
||||
char *arg = NULL;
|
||||
@ -1056,7 +1054,6 @@ ifinfo(char *ifname, int argc, char **argv)
|
||||
void
|
||||
rtrlist()
|
||||
{
|
||||
#ifdef ICMPV6CTL_ND6_DRLIST
|
||||
int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_DRLIST };
|
||||
char *buf;
|
||||
struct in6_defrouter *p, *ep;
|
||||
@ -1104,54 +1101,11 @@ rtrlist()
|
||||
sec2str(p->expire - now.tv_sec));
|
||||
}
|
||||
free(buf);
|
||||
#else
|
||||
struct in6_drlist dr;
|
||||
int s, i;
|
||||
struct timeval now;
|
||||
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
|
||||
err(1, "socket");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
bzero(&dr, sizeof(dr));
|
||||
strlcpy(dr.ifname, "lo0", sizeof(dr.ifname)); /* dummy */
|
||||
if (ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) {
|
||||
err(1, "ioctl(SIOCGDRLST_IN6)");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
#define DR dr.defrouter[i]
|
||||
for (i = 0 ; DR.if_index && i < DRLSTSIZ ; i++) {
|
||||
struct sockaddr_in6 sin6;
|
||||
|
||||
bzero(&sin6, sizeof(sin6));
|
||||
sin6.sin6_family = AF_INET6;
|
||||
sin6.sin6_len = sizeof(sin6);
|
||||
sin6.sin6_addr = DR.rtaddr;
|
||||
getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len, host_buf,
|
||||
sizeof(host_buf), NULL, 0,
|
||||
(nflag ? NI_NUMERICHOST : 0));
|
||||
|
||||
printf("%s if=%s", host_buf,
|
||||
if_indextoname(DR.if_index, ifix_buf));
|
||||
printf(", flags=%s%s",
|
||||
DR.flags & ND_RA_FLAG_MANAGED ? "M" : "",
|
||||
DR.flags & ND_RA_FLAG_OTHER ? "O" : "");
|
||||
gettimeofday(&now, 0);
|
||||
if (DR.expire == 0)
|
||||
printf(", expire=Never\n");
|
||||
else
|
||||
printf(", expire=%s\n",
|
||||
sec2str(DR.expire - now.tv_sec));
|
||||
}
|
||||
#undef DR
|
||||
close(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
plist()
|
||||
{
|
||||
#ifdef ICMPV6CTL_ND6_PRLIST
|
||||
int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_PRLIST };
|
||||
char *buf;
|
||||
struct in6_prefix *p, *ep, *n;
|
||||
@ -1261,161 +1215,6 @@ plist()
|
||||
printf(" No advertising router\n");
|
||||
}
|
||||
free(buf);
|
||||
#else
|
||||
struct in6_prlist pr;
|
||||
int s, i;
|
||||
struct timeval now;
|
||||
|
||||
gettimeofday(&now, 0);
|
||||
|
||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
|
||||
err(1, "socket");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
bzero(&pr, sizeof(pr));
|
||||
strlcpy(pr.ifname, "lo0", sizeof(pr.ifname)); /* dummy */
|
||||
if (ioctl(s, SIOCGPRLST_IN6, (caddr_t)&pr) < 0) {
|
||||
err(1, "ioctl(SIOCGPRLST_IN6)");
|
||||
/* NOTREACHED */
|
||||
}
|
||||
#define PR pr.prefix[i]
|
||||
for (i = 0; PR.if_index && i < PRLSTSIZ ; i++) {
|
||||
struct sockaddr_in6 p6;
|
||||
char namebuf[NI_MAXHOST];
|
||||
int niflags;
|
||||
|
||||
#ifdef NDPRF_ONLINK
|
||||
p6 = PR.prefix;
|
||||
#else
|
||||
memset(&p6, 0, sizeof(p6));
|
||||
p6.sin6_family = AF_INET6;
|
||||
p6.sin6_len = sizeof(p6);
|
||||
p6.sin6_addr = PR.prefix;
|
||||
#endif
|
||||
niflags = NI_NUMERICHOST;
|
||||
if (getnameinfo((struct sockaddr *)&p6,
|
||||
sizeof(p6), namebuf, sizeof(namebuf),
|
||||
NULL, 0, niflags)) {
|
||||
warnx("getnameinfo failed");
|
||||
continue;
|
||||
}
|
||||
printf("%s/%d if=%s\n", namebuf, PR.prefixlen,
|
||||
if_indextoname(PR.if_index, ifix_buf));
|
||||
|
||||
gettimeofday(&now, 0);
|
||||
/*
|
||||
* meaning of fields, especially flags, is very different
|
||||
* by origin. notify the difference to the users.
|
||||
*/
|
||||
#if 0
|
||||
printf(" %s",
|
||||
PR.origin == PR_ORIG_RA ? "" : "advertise: ");
|
||||
#endif
|
||||
#ifdef NDPRF_ONLINK
|
||||
printf("flags=%s%s%s%s%s",
|
||||
PR.raflags.onlink ? "L" : "",
|
||||
PR.raflags.autonomous ? "A" : "",
|
||||
(PR.flags & NDPRF_ONLINK) != 0 ? "O" : "",
|
||||
(PR.flags & NDPRF_DETACHED) != 0 ? "D" : "",
|
||||
#ifdef NDPRF_HOME
|
||||
(PR.flags & NDPRF_HOME) != 0 ? "H" : ""
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
);
|
||||
#else
|
||||
printf("flags=%s%s",
|
||||
PR.raflags.onlink ? "L" : "",
|
||||
PR.raflags.autonomous ? "A" : "");
|
||||
#endif
|
||||
if (PR.vltime == ND6_INFINITE_LIFETIME)
|
||||
printf(" vltime=infinity");
|
||||
else
|
||||
printf(" vltime=%lu", PR.vltime);
|
||||
if (PR.pltime == ND6_INFINITE_LIFETIME)
|
||||
printf(", pltime=infinity");
|
||||
else
|
||||
printf(", pltime=%lu", PR.pltime);
|
||||
if (PR.expire == 0)
|
||||
printf(", expire=Never");
|
||||
else if (PR.expire >= now.tv_sec)
|
||||
printf(", expire=%s",
|
||||
sec2str(PR.expire - now.tv_sec));
|
||||
else
|
||||
printf(", expired");
|
||||
#ifdef NDPRF_ONLINK
|
||||
printf(", ref=%d", PR.refcnt);
|
||||
#endif
|
||||
#if 0
|
||||
switch (PR.origin) {
|
||||
case PR_ORIG_RA:
|
||||
printf(", origin=RA");
|
||||
break;
|
||||
case PR_ORIG_RR:
|
||||
printf(", origin=RR");
|
||||
break;
|
||||
case PR_ORIG_STATIC:
|
||||
printf(", origin=static");
|
||||
break;
|
||||
case PR_ORIG_KERNEL:
|
||||
printf(", origin=kernel");
|
||||
break;
|
||||
default:
|
||||
printf(", origin=?");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
printf("\n");
|
||||
/*
|
||||
* "advertising router" list is meaningful only if the prefix
|
||||
* information is from RA.
|
||||
*/
|
||||
if (0 && /* prefix origin is almost obsolted */
|
||||
PR.origin != PR_ORIG_RA)
|
||||
;
|
||||
else if (PR.advrtrs) {
|
||||
int j;
|
||||
printf(" advertised by\n");
|
||||
for (j = 0; j < PR.advrtrs; j++) {
|
||||
struct sockaddr_in6 sin6;
|
||||
struct in6_nbrinfo *nbi;
|
||||
|
||||
bzero(&sin6, sizeof(sin6));
|
||||
sin6.sin6_family = AF_INET6;
|
||||
sin6.sin6_len = sizeof(sin6);
|
||||
sin6.sin6_addr = PR.advrtr[j];
|
||||
sin6.sin6_scope_id = PR.if_index; /* XXX */
|
||||
getnameinfo((struct sockaddr *)&sin6,
|
||||
sin6.sin6_len, host_buf,
|
||||
sizeof(host_buf), NULL, 0,
|
||||
(nflag ? NI_NUMERICHOST : 0));
|
||||
printf(" %s", host_buf);
|
||||
|
||||
nbi = getnbrinfo(&sin6.sin6_addr,
|
||||
PR.if_index, 0);
|
||||
if (nbi) {
|
||||
switch (nbi->state) {
|
||||
case ND6_LLINFO_REACHABLE:
|
||||
case ND6_LLINFO_STALE:
|
||||
case ND6_LLINFO_DELAY:
|
||||
case ND6_LLINFO_PROBE:
|
||||
printf(" (reachable)\n");
|
||||
break;
|
||||
default:
|
||||
printf(" (unreachable)\n");
|
||||
}
|
||||
} else
|
||||
printf(" (no neighbor state)\n");
|
||||
}
|
||||
if (PR.advrtrs > DRLSTSIZ)
|
||||
printf(" and %d routers\n",
|
||||
PR.advrtrs - DRLSTSIZ);
|
||||
} else
|
||||
printf(" No advertising router\n");
|
||||
}
|
||||
#undef PR
|
||||
close(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user