Deleted Added
full compact
ndp.c (246143) ndp.c (253970)
1/* $FreeBSD: head/usr.sbin/ndp/ndp.c 246143 2013-01-31 08:55:21Z glebius $ */
1/* $FreeBSD: head/usr.sbin/ndp/ndp.c 253970 2013-08-05 20:13:02Z hrs $ */
2/* $KAME: ndp.c,v 1.104 2003/06/27 07:48:39 itojun Exp $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

--- 64 unchanged lines hidden (view full) ---

74 */
75
76
77#include <sys/param.h>
78#include <sys/file.h>
79#include <sys/ioctl.h>
80#include <sys/socket.h>
81#include <sys/sysctl.h>
2/* $KAME: ndp.c,v 1.104 2003/06/27 07:48:39 itojun Exp $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

--- 64 unchanged lines hidden (view full) ---

74 */
75
76
77#include <sys/param.h>
78#include <sys/file.h>
79#include <sys/ioctl.h>
80#include <sys/socket.h>
81#include <sys/sysctl.h>
82#include <sys/time.h>
83#include <sys/queue.h>
84
85#include <net/if.h>
86#include <net/if_var.h>
87#include <net/if_dl.h>
88#include <net/if_types.h>
89#include <net/route.h>
90

--- 9 unchanged lines hidden (view full) ---

100#include <netdb.h>
101#include <errno.h>
102#include <nlist.h>
103#include <stdio.h>
104#include <string.h>
105#include <paths.h>
106#include <err.h>
107#include <stdlib.h>
82#include <sys/queue.h>
83
84#include <net/if.h>
85#include <net/if_var.h>
86#include <net/if_dl.h>
87#include <net/if_types.h>
88#include <net/route.h>
89

--- 9 unchanged lines hidden (view full) ---

99#include <netdb.h>
100#include <errno.h>
101#include <nlist.h>
102#include <stdio.h>
103#include <string.h>
104#include <paths.h>
105#include <err.h>
106#include <stdlib.h>
107#include <time.h>
108#include <fcntl.h>
109#include <unistd.h>
110#include "gmt2local.h"
111
112/* packing rule for routing socket */
113#define ROUNDUP(a) \
114 ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
115#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))

--- 4 unchanged lines hidden (view full) ---

120
121
122static pid_t pid;
123static int nflag;
124static int tflag;
125static int32_t thiszone; /* time difference with gmt */
126static int s = -1;
127static int repeat = 0;
108#include <fcntl.h>
109#include <unistd.h>
110#include "gmt2local.h"
111
112/* packing rule for routing socket */
113#define ROUNDUP(a) \
114 ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
115#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))

--- 4 unchanged lines hidden (view full) ---

120
121
122static pid_t pid;
123static int nflag;
124static int tflag;
125static int32_t thiszone; /* time difference with gmt */
126static int s = -1;
127static int repeat = 0;
128static struct timespec ts, ts0;
128
129char ntop_buf[INET6_ADDRSTRLEN]; /* inet_ntop() */
130char host_buf[NI_MAXHOST]; /* getnameinfo() */
131char ifix_buf[IFNAMSIZ]; /* if_indextoname() */
132
133int main(int, char **);
134int file(char *);
135void getsocket(void);

--- 12 unchanged lines hidden (view full) ---

148void pfx_flush(void);
149void rtr_flush(void);
150void harmonize_rtr(void);
151#ifdef SIOCSDEFIFACE_IN6 /* XXX: check SIOCGDEFIFACE_IN6 as well? */
152static void getdefif(void);
153static void setdefif(char *);
154#endif
155static char *sec2str(time_t);
129
130char ntop_buf[INET6_ADDRSTRLEN]; /* inet_ntop() */
131char host_buf[NI_MAXHOST]; /* getnameinfo() */
132char ifix_buf[IFNAMSIZ]; /* if_indextoname() */
133
134int main(int, char **);
135int file(char *);
136void getsocket(void);

--- 12 unchanged lines hidden (view full) ---

149void pfx_flush(void);
150void rtr_flush(void);
151void harmonize_rtr(void);
152#ifdef SIOCSDEFIFACE_IN6 /* XXX: check SIOCGDEFIFACE_IN6 as well? */
153static void getdefif(void);
154static void setdefif(char *);
155#endif
156static char *sec2str(time_t);
156static void ts_print(const struct timeval *);
157static void ts_print(const struct timespec *);
157
158#ifdef ICMPV6CTL_ND6_DRLIST
159static char *rtpref_str[] = {
160 "medium", /* 00 */
161 "high", /* 01 */
162 "rsv", /* 10 */
163 "low" /* 11 */
164};
165#endif
166
158
159#ifdef ICMPV6CTL_ND6_DRLIST
160static char *rtpref_str[] = {
161 "medium", /* 00 */
162 "high", /* 01 */
163 "rsv", /* 10 */
164 "low" /* 11 */
165};
166#endif
167
168#define TS_SUB(tsp, usp, vsp) \
169 do { \
170 (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
171 (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
172 if ((vsp)->tv_nsec < 0) { \
173 (vsp)->tv_sec--; \
174 (vsp)->tv_nsec += 1000000000L; \
175 } \
176 } while (0)
177
167int mode = 0;
168char *arg = NULL;
169
170int
171main(argc, argv)
172 int argc;
173 char **argv;
174{
178int mode = 0;
179char *arg = NULL;
180
181int
182main(argc, argv)
183 int argc;
184 char **argv;
185{
186 struct timespec now;
175 int ch;
176
177 pid = getpid();
178 thiszone = gmt2local(0);
187 int ch;
188
189 pid = getpid();
190 thiszone = gmt2local(0);
191 clock_gettime(CLOCK_REALTIME_FAST, &now);
192 clock_gettime(CLOCK_MONOTONIC_FAST, &ts);
193 TS_SUB(&now, &ts, &ts0);
179 while ((ch = getopt(argc, argv, "acd:f:Ii:nprstA:HPR")) != -1)
180 switch (ch) {
181 case 'a':
182 case 'c':
183 case 'p':
184 case 'r':
185 case 'H':
186 case 'P':

--- 175 unchanged lines hidden (view full) ---

362 /* NOTREACHED */
363 }
364 }
365}
366
367struct sockaddr_in6 so_mask = {sizeof(so_mask), AF_INET6 };
368struct sockaddr_in6 blank_sin = {sizeof(blank_sin), AF_INET6 }, sin_m;
369struct sockaddr_dl blank_sdl = {sizeof(blank_sdl), AF_LINK }, sdl_m;
194 while ((ch = getopt(argc, argv, "acd:f:Ii:nprstA:HPR")) != -1)
195 switch (ch) {
196 case 'a':
197 case 'c':
198 case 'p':
199 case 'r':
200 case 'H':
201 case 'P':

--- 175 unchanged lines hidden (view full) ---

377 /* NOTREACHED */
378 }
379 }
380}
381
382struct sockaddr_in6 so_mask = {sizeof(so_mask), AF_INET6 };
383struct sockaddr_in6 blank_sin = {sizeof(blank_sin), AF_INET6 }, sin_m;
384struct sockaddr_dl blank_sdl = {sizeof(blank_sdl), AF_LINK }, sdl_m;
370int expire_time, flags, found_entry;
385static time_t expire_time;
386static int flags, found_entry;
371struct {
372 struct rt_msghdr m_rtm;
373 char m_space[512];
374} m_rtmsg;
375
376/*
377 * Set an individual neighbor cache entry
378 */

--- 28 unchanged lines hidden (view full) ---

407 sin->sin6_scope_id =
408 ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
409 ea = (u_char *)LLADDR(&sdl_m);
410 if (ndp_ether_aton(eaddr, ea) == 0)
411 sdl_m.sdl_alen = 6;
412 flags = expire_time = 0;
413 while (argc-- > 0) {
414 if (strncmp(argv[0], "temp", 4) == 0) {
387struct {
388 struct rt_msghdr m_rtm;
389 char m_space[512];
390} m_rtmsg;
391
392/*
393 * Set an individual neighbor cache entry
394 */

--- 28 unchanged lines hidden (view full) ---

423 sin->sin6_scope_id =
424 ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id;
425 ea = (u_char *)LLADDR(&sdl_m);
426 if (ndp_ether_aton(eaddr, ea) == 0)
427 sdl_m.sdl_alen = 6;
428 flags = expire_time = 0;
429 while (argc-- > 0) {
430 if (strncmp(argv[0], "temp", 4) == 0) {
415 struct timeval time;
431 struct timespec now;
416
432
417 gettimeofday(&time, 0);
418 expire_time = time.tv_sec + 20 * 60;
433 clock_gettime(CLOCK_MONOTONIC_FAST, &now);
434 expire_time = now.tv_sec + 20 * 60;
419 } else if (strncmp(argv[0], "proxy", 5) == 0)
420 flags |= RTF_ANNOUNCE;
421 argv++;
422 }
423 if (rtmsg(RTM_GET) < 0) {
424 errx(1, "RTM_GET(%s) failed", host);
425 /* NOTREACHED */
426 }

--- 134 unchanged lines hidden (view full) ---

561 int mib[6];
562 size_t needed;
563 char *lim, *buf, *next;
564 struct rt_msghdr *rtm;
565 struct sockaddr_in6 *sin;
566 struct sockaddr_dl *sdl;
567 extern int h_errno;
568 struct in6_nbrinfo *nbi;
435 } else if (strncmp(argv[0], "proxy", 5) == 0)
436 flags |= RTF_ANNOUNCE;
437 argv++;
438 }
439 if (rtmsg(RTM_GET) < 0) {
440 errx(1, "RTM_GET(%s) failed", host);
441 /* NOTREACHED */
442 }

--- 134 unchanged lines hidden (view full) ---

577 int mib[6];
578 size_t needed;
579 char *lim, *buf, *next;
580 struct rt_msghdr *rtm;
581 struct sockaddr_in6 *sin;
582 struct sockaddr_dl *sdl;
583 extern int h_errno;
584 struct in6_nbrinfo *nbi;
569 struct timeval time;
585 struct timespec now;
570 int addrwidth;
571 int llwidth;
572 int ifwidth;
573 char flgbuf[8];
574 char *ifname;
575
576 /* Print header */
577 if (!tflag && !cflag)

--- 70 unchanged lines hidden (view full) ---

648#elif defined(RTF_CLONED)
649 if (rtm->rtm_flags & RTF_CLONED)
650 delete(host_buf);
651#else
652 delete(host_buf);
653#endif
654 continue;
655 }
586 int addrwidth;
587 int llwidth;
588 int ifwidth;
589 char flgbuf[8];
590 char *ifname;
591
592 /* Print header */
593 if (!tflag && !cflag)

--- 70 unchanged lines hidden (view full) ---

664#elif defined(RTF_CLONED)
665 if (rtm->rtm_flags & RTF_CLONED)
666 delete(host_buf);
667#else
668 delete(host_buf);
669#endif
670 continue;
671 }
656 gettimeofday(&time, 0);
672 clock_gettime(CLOCK_MONOTONIC_FAST, &now);
657 if (tflag)
673 if (tflag)
658 ts_print(&time);
674 ts_print(&now);
659
660 addrwidth = strlen(host_buf);
661 if (addrwidth < W_ADDR)
662 addrwidth = W_ADDR;
663 llwidth = strlen(ether_str(sdl));
664 if (W_ADDR + W_LL - addrwidth > llwidth)
665 llwidth = W_ADDR + W_LL - addrwidth;
666 ifname = if_indextoname(sdl->sdl_index, ifix_buf);

--- 4 unchanged lines hidden (view full) ---

671 ifwidth = W_ADDR + W_LL + W_IF - addrwidth - llwidth;
672
673 printf("%-*.*s %-*.*s %*.*s", addrwidth, addrwidth, host_buf,
674 llwidth, llwidth, ether_str(sdl), ifwidth, ifwidth, ifname);
675
676 /* Print neighbor discovery specific informations */
677 nbi = getnbrinfo(&sin->sin6_addr, sdl->sdl_index, 1);
678 if (nbi) {
675
676 addrwidth = strlen(host_buf);
677 if (addrwidth < W_ADDR)
678 addrwidth = W_ADDR;
679 llwidth = strlen(ether_str(sdl));
680 if (W_ADDR + W_LL - addrwidth > llwidth)
681 llwidth = W_ADDR + W_LL - addrwidth;
682 ifname = if_indextoname(sdl->sdl_index, ifix_buf);

--- 4 unchanged lines hidden (view full) ---

687 ifwidth = W_ADDR + W_LL + W_IF - addrwidth - llwidth;
688
689 printf("%-*.*s %-*.*s %*.*s", addrwidth, addrwidth, host_buf,
690 llwidth, llwidth, ether_str(sdl), ifwidth, ifwidth, ifname);
691
692 /* Print neighbor discovery specific informations */
693 nbi = getnbrinfo(&sin->sin6_addr, sdl->sdl_index, 1);
694 if (nbi) {
679 if (nbi->expire > time.tv_sec) {
695 if (nbi->expire > now.tv_sec) {
680 printf(" %-9.9s",
696 printf(" %-9.9s",
681 sec2str(nbi->expire - time.tv_sec));
697 sec2str(nbi->expire - now.tv_sec));
682 } else if (nbi->expire == 0)
683 printf(" %-9.9s", "permanent");
684 else
685 printf(" %-9.9s", "expired");
686
687 switch (nbi->state) {
688 case ND6_LLINFO_NOSTATE:
689 printf(" N");

--- 380 unchanged lines hidden (view full) ---

1070void
1071rtrlist()
1072{
1073#ifdef ICMPV6CTL_ND6_DRLIST
1074 int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_DRLIST };
1075 char *buf;
1076 struct in6_defrouter *p, *ep;
1077 size_t l;
698 } else if (nbi->expire == 0)
699 printf(" %-9.9s", "permanent");
700 else
701 printf(" %-9.9s", "expired");
702
703 switch (nbi->state) {
704 case ND6_LLINFO_NOSTATE:
705 printf(" N");

--- 380 unchanged lines hidden (view full) ---

1086void
1087rtrlist()
1088{
1089#ifdef ICMPV6CTL_ND6_DRLIST
1090 int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_DRLIST };
1091 char *buf;
1092 struct in6_defrouter *p, *ep;
1093 size_t l;
1078 struct timeval time;
1094 struct timespec now;
1079
1080 if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
1081 err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
1082 /*NOTREACHED*/
1083 }
1084 if (l == 0)
1085 return;
1086 buf = malloc(l);

--- 18 unchanged lines hidden (view full) ---

1105 printf("%s if=%s", host_buf,
1106 if_indextoname(p->if_index, ifix_buf));
1107 printf(", flags=%s%s",
1108 p->flags & ND_RA_FLAG_MANAGED ? "M" : "",
1109 p->flags & ND_RA_FLAG_OTHER ? "O" : "");
1110 rtpref = ((p->flags & ND_RA_FLAG_RTPREF_MASK) >> 3) & 0xff;
1111 printf(", pref=%s", rtpref_str[rtpref]);
1112
1095
1096 if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
1097 err(1, "sysctl(ICMPV6CTL_ND6_DRLIST)");
1098 /*NOTREACHED*/
1099 }
1100 if (l == 0)
1101 return;
1102 buf = malloc(l);

--- 18 unchanged lines hidden (view full) ---

1121 printf("%s if=%s", host_buf,
1122 if_indextoname(p->if_index, ifix_buf));
1123 printf(", flags=%s%s",
1124 p->flags & ND_RA_FLAG_MANAGED ? "M" : "",
1125 p->flags & ND_RA_FLAG_OTHER ? "O" : "");
1126 rtpref = ((p->flags & ND_RA_FLAG_RTPREF_MASK) >> 3) & 0xff;
1127 printf(", pref=%s", rtpref_str[rtpref]);
1128
1113 gettimeofday(&time, 0);
1129 clock_gettime(CLOCK_MONOTONIC_FAST, &now);
1114 if (p->expire == 0)
1115 printf(", expire=Never\n");
1116 else
1117 printf(", expire=%s\n",
1130 if (p->expire == 0)
1131 printf(", expire=Never\n");
1132 else
1133 printf(", expire=%s\n",
1118 sec2str(p->expire - time.tv_sec));
1134 sec2str(p->expire - now.tv_sec));
1119 }
1120 free(buf);
1121#else
1122 struct in6_drlist dr;
1123 int s, i;
1135 }
1136 free(buf);
1137#else
1138 struct in6_drlist dr;
1139 int s, i;
1124 struct timeval time;
1140 struct timespec now;
1125
1126 if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
1127 err(1, "socket");
1128 /* NOTREACHED */
1129 }
1130 bzero(&dr, sizeof(dr));
1131 strlcpy(dr.ifname, "lo0", sizeof(dr.ifname)); /* dummy */
1132 if (ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) {

--- 12 unchanged lines hidden (view full) ---

1145 sizeof(host_buf), NULL, 0,
1146 (nflag ? NI_NUMERICHOST : 0));
1147
1148 printf("%s if=%s", host_buf,
1149 if_indextoname(DR.if_index, ifix_buf));
1150 printf(", flags=%s%s",
1151 DR.flags & ND_RA_FLAG_MANAGED ? "M" : "",
1152 DR.flags & ND_RA_FLAG_OTHER ? "O" : "");
1141
1142 if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
1143 err(1, "socket");
1144 /* NOTREACHED */
1145 }
1146 bzero(&dr, sizeof(dr));
1147 strlcpy(dr.ifname, "lo0", sizeof(dr.ifname)); /* dummy */
1148 if (ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) {

--- 12 unchanged lines hidden (view full) ---

1161 sizeof(host_buf), NULL, 0,
1162 (nflag ? NI_NUMERICHOST : 0));
1163
1164 printf("%s if=%s", host_buf,
1165 if_indextoname(DR.if_index, ifix_buf));
1166 printf(", flags=%s%s",
1167 DR.flags & ND_RA_FLAG_MANAGED ? "M" : "",
1168 DR.flags & ND_RA_FLAG_OTHER ? "O" : "");
1153 gettimeofday(&time, 0);
1169 clock_gettime(CLOCK_MONOTONIC_FAST, &now);
1154 if (DR.expire == 0)
1155 printf(", expire=Never\n");
1156 else
1157 printf(", expire=%s\n",
1170 if (DR.expire == 0)
1171 printf(", expire=Never\n");
1172 else
1173 printf(", expire=%s\n",
1158 sec2str(DR.expire - time.tv_sec));
1174 sec2str(DR.expire - now.tv_sec));
1159 }
1160#undef DR
1161 close(s);
1162#endif
1163}
1164
1165void
1166plist()
1167{
1168#ifdef ICMPV6CTL_ND6_PRLIST
1169 int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_PRLIST };
1170 char *buf;
1171 struct in6_prefix *p, *ep, *n;
1172 struct sockaddr_in6 *advrtr;
1173 size_t l;
1175 }
1176#undef DR
1177 close(s);
1178#endif
1179}
1180
1181void
1182plist()
1183{
1184#ifdef ICMPV6CTL_ND6_PRLIST
1185 int mib[] = { CTL_NET, PF_INET6, IPPROTO_ICMPV6, ICMPV6CTL_ND6_PRLIST };
1186 char *buf;
1187 struct in6_prefix *p, *ep, *n;
1188 struct sockaddr_in6 *advrtr;
1189 size_t l;
1174 struct timeval time;
1190 struct timespec now;
1175 const int niflags = NI_NUMERICHOST;
1176 int ninflags = nflag ? NI_NUMERICHOST : 0;
1177 char namebuf[NI_MAXHOST];
1178
1179 if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
1180 err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
1181 /*NOTREACHED*/
1182 }

--- 14 unchanged lines hidden (view full) ---

1197
1198 if (getnameinfo((struct sockaddr *)&p->prefix,
1199 p->prefix.sin6_len, namebuf, sizeof(namebuf),
1200 NULL, 0, niflags) != 0)
1201 strlcpy(namebuf, "?", sizeof(namebuf));
1202 printf("%s/%d if=%s\n", namebuf, p->prefixlen,
1203 if_indextoname(p->if_index, ifix_buf));
1204
1191 const int niflags = NI_NUMERICHOST;
1192 int ninflags = nflag ? NI_NUMERICHOST : 0;
1193 char namebuf[NI_MAXHOST];
1194
1195 if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &l, NULL, 0) < 0) {
1196 err(1, "sysctl(ICMPV6CTL_ND6_PRLIST)");
1197 /*NOTREACHED*/
1198 }

--- 14 unchanged lines hidden (view full) ---

1213
1214 if (getnameinfo((struct sockaddr *)&p->prefix,
1215 p->prefix.sin6_len, namebuf, sizeof(namebuf),
1216 NULL, 0, niflags) != 0)
1217 strlcpy(namebuf, "?", sizeof(namebuf));
1218 printf("%s/%d if=%s\n", namebuf, p->prefixlen,
1219 if_indextoname(p->if_index, ifix_buf));
1220
1205 gettimeofday(&time, 0);
1221 clock_gettime(CLOCK_MONOTONIC_FAST, &now);
1206 /*
1207 * meaning of fields, especially flags, is very different
1208 * by origin. notify the difference to the users.
1209 */
1210 printf("flags=%s%s%s%s%s",
1211 p->raflags.onlink ? "L" : "",
1212 p->raflags.autonomous ? "A" : "",
1213 (p->flags & NDPRF_ONLINK) != 0 ? "O" : "",

--- 9 unchanged lines hidden (view full) ---

1223 else
1224 printf(" vltime=%lu", (unsigned long)p->vltime);
1225 if (p->pltime == ND6_INFINITE_LIFETIME)
1226 printf(", pltime=infinity");
1227 else
1228 printf(", pltime=%lu", (unsigned long)p->pltime);
1229 if (p->expire == 0)
1230 printf(", expire=Never");
1222 /*
1223 * meaning of fields, especially flags, is very different
1224 * by origin. notify the difference to the users.
1225 */
1226 printf("flags=%s%s%s%s%s",
1227 p->raflags.onlink ? "L" : "",
1228 p->raflags.autonomous ? "A" : "",
1229 (p->flags & NDPRF_ONLINK) != 0 ? "O" : "",

--- 9 unchanged lines hidden (view full) ---

1239 else
1240 printf(" vltime=%lu", (unsigned long)p->vltime);
1241 if (p->pltime == ND6_INFINITE_LIFETIME)
1242 printf(", pltime=infinity");
1243 else
1244 printf(", pltime=%lu", (unsigned long)p->pltime);
1245 if (p->expire == 0)
1246 printf(", expire=Never");
1231 else if (p->expire >= time.tv_sec)
1247 else if (p->expire >= now.tv_sec)
1232 printf(", expire=%s",
1248 printf(", expire=%s",
1233 sec2str(p->expire - time.tv_sec));
1249 sec2str(p->expire - now.tv_sec));
1234 else
1235 printf(", expired");
1236 printf(", ref=%d", p->refcnt);
1237 printf("\n");
1238 /*
1239 * "advertising router" list is meaningful only if the prefix
1240 * information is from RA.
1241 */

--- 31 unchanged lines hidden (view full) ---

1273 }
1274 } else
1275 printf(" No advertising router\n");
1276 }
1277 free(buf);
1278#else
1279 struct in6_prlist pr;
1280 int s, i;
1250 else
1251 printf(", expired");
1252 printf(", ref=%d", p->refcnt);
1253 printf("\n");
1254 /*
1255 * "advertising router" list is meaningful only if the prefix
1256 * information is from RA.
1257 */

--- 31 unchanged lines hidden (view full) ---

1289 }
1290 } else
1291 printf(" No advertising router\n");
1292 }
1293 free(buf);
1294#else
1295 struct in6_prlist pr;
1296 int s, i;
1281 struct timeval time;
1297 struct timespec now;
1282
1298
1283 gettimeofday(&time, 0);
1299 clock_gettime(CLOCK_MONOTONIC_FAST, &now);
1284
1285 if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
1286 err(1, "socket");
1287 /* NOTREACHED */
1288 }
1289 bzero(&pr, sizeof(pr));
1290 strlcpy(pr.ifname, "lo0", sizeof(pr.ifname)); /* dummy */
1291 if (ioctl(s, SIOCGPRLST_IN6, (caddr_t)&pr) < 0) {

--- 19 unchanged lines hidden (view full) ---

1311 sizeof(p6), namebuf, sizeof(namebuf),
1312 NULL, 0, niflags)) {
1313 warnx("getnameinfo failed");
1314 continue;
1315 }
1316 printf("%s/%d if=%s\n", namebuf, PR.prefixlen,
1317 if_indextoname(PR.if_index, ifix_buf));
1318
1300
1301 if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
1302 err(1, "socket");
1303 /* NOTREACHED */
1304 }
1305 bzero(&pr, sizeof(pr));
1306 strlcpy(pr.ifname, "lo0", sizeof(pr.ifname)); /* dummy */
1307 if (ioctl(s, SIOCGPRLST_IN6, (caddr_t)&pr) < 0) {

--- 19 unchanged lines hidden (view full) ---

1327 sizeof(p6), namebuf, sizeof(namebuf),
1328 NULL, 0, niflags)) {
1329 warnx("getnameinfo failed");
1330 continue;
1331 }
1332 printf("%s/%d if=%s\n", namebuf, PR.prefixlen,
1333 if_indextoname(PR.if_index, ifix_buf));
1334
1319 gettimeofday(&time, 0);
1335 clock_gettime(CLOCK_MONOTONIC_FAST, &now);
1320 /*
1321 * meaning of fields, especially flags, is very different
1322 * by origin. notify the difference to the users.
1323 */
1324#if 0
1325 printf(" %s",
1326 PR.origin == PR_ORIG_RA ? "" : "advertise: ");
1327#endif

--- 19 unchanged lines hidden (view full) ---

1347 else
1348 printf(" vltime=%lu", PR.vltime);
1349 if (PR.pltime == ND6_INFINITE_LIFETIME)
1350 printf(", pltime=infinity");
1351 else
1352 printf(", pltime=%lu", PR.pltime);
1353 if (PR.expire == 0)
1354 printf(", expire=Never");
1336 /*
1337 * meaning of fields, especially flags, is very different
1338 * by origin. notify the difference to the users.
1339 */
1340#if 0
1341 printf(" %s",
1342 PR.origin == PR_ORIG_RA ? "" : "advertise: ");
1343#endif

--- 19 unchanged lines hidden (view full) ---

1363 else
1364 printf(" vltime=%lu", PR.vltime);
1365 if (PR.pltime == ND6_INFINITE_LIFETIME)
1366 printf(", pltime=infinity");
1367 else
1368 printf(", pltime=%lu", PR.pltime);
1369 if (PR.expire == 0)
1370 printf(", expire=Never");
1355 else if (PR.expire >= time.tv_sec)
1371 else if (PR.expire >= now.tv_sec)
1356 printf(", expire=%s",
1372 printf(", expire=%s",
1357 sec2str(PR.expire - time.tv_sec));
1373 sec2str(PR.expire - now.tv_sec));
1358 else
1359 printf(", expired");
1360#ifdef NDPRF_ONLINK
1361 printf(", ref=%d", PR.refcnt);
1362#endif
1363#if 0
1364 switch (PR.origin) {
1365 case PR_ORIG_RA:

--- 206 unchanged lines hidden (view full) ---

1572 return(result);
1573}
1574
1575/*
1576 * Print the timestamp
1577 * from tcpdump/util.c
1578 */
1579static void
1374 else
1375 printf(", expired");
1376#ifdef NDPRF_ONLINK
1377 printf(", ref=%d", PR.refcnt);
1378#endif
1379#if 0
1380 switch (PR.origin) {
1381 case PR_ORIG_RA:

--- 206 unchanged lines hidden (view full) ---

1588 return(result);
1589}
1590
1591/*
1592 * Print the timestamp
1593 * from tcpdump/util.c
1594 */
1595static void
1580ts_print(tvp)
1581 const struct timeval *tvp;
1596ts_print(tsp)
1597 const struct timespec *tsp;
1582{
1583 int s;
1584
1585 /* Default */
1598{
1599 int s;
1600
1601 /* Default */
1586 s = (tvp->tv_sec + thiszone) % 86400;
1602 s = (tsp->tv_sec + thiszone + ts0.tv_sec) % 86400;
1587 (void)printf("%02d:%02d:%02d.%06u ",
1603 (void)printf("%02d:%02d:%02d.%06u ",
1588 s / 3600, (s % 3600) / 60, s % 60, (u_int32_t)tvp->tv_usec);
1604 s / 3600, (s % 3600) / 60, s % 60, (u_int32_t)tsp->tv_nsec / 1000);
1589}
1590
1591#undef NEXTADDR
1605}
1606
1607#undef NEXTADDR