Deleted Added
full compact
inet6.c (55533) inet6.c (62584)
1/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
2/*
3 * Copyright (c) 1983, 1988, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
1/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
2/*
3 * Copyright (c) 1983, 1988, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * $FreeBSD: head/usr.bin/netstat/inet6.c 55533 2000-01-07 05:17:09Z shin $
34 * $FreeBSD: head/usr.bin/netstat/inet6.c 62584 2000-07-04 16:26:46Z itojun $
35 */
36
37#ifndef lint
38/*
39static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94";
40*/
41#endif /* not lint */
42

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

159 "#81",
160 "#82",
161 "#83",
162 "#84",
163 "#85",
164 "#86",
165 "#87",
166 "#88",
35 */
36
37#ifndef lint
38/*
39static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94";
40*/
41#endif /* not lint */
42

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

159 "#81",
160 "#82",
161 "#83",
162 "#84",
163 "#85",
164 "#86",
165 "#87",
166 "#88",
167 "#89",
167 "OSPF",
168 "#80",
169 "#91",
170 "#92",
171 "#93",
172 "#94",
173 "#95",
174 "#96",
175 "Ethernet",

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

346
347 if (off == 0)
348 return;
349
350 kread(off, (char *)&ip6stat, sizeof (ip6stat));
351 printf("%s:\n", name);
352
353#define p(f, m) if (ip6stat.f || sflag <= 1) \
168 "#80",
169 "#91",
170 "#92",
171 "#93",
172 "#94",
173 "#95",
174 "#96",
175 "Ethernet",

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

346
347 if (off == 0)
348 return;
349
350 kread(off, (char *)&ip6stat, sizeof (ip6stat));
351 printf("%s:\n", name);
352
353#define p(f, m) if (ip6stat.f || sflag <= 1) \
354 printf(m, ip6stat.f, plural(ip6stat.f))
354 printf(m, (unsigned long long)ip6stat.f, plural(ip6stat.f))
355#define p1a(f, m) if (ip6stat.f || sflag <= 1) \
355#define p1a(f, m) if (ip6stat.f || sflag <= 1) \
356 printf(m, ip6stat.f)
356 printf(m, (unsigned long long)ip6stat.f)
357
357
358 p(ip6s_total, "\t%lu total packet%s received\n");
359 p1a(ip6s_toosmall, "\t%lu with size smaller than minimum\n");
360 p1a(ip6s_tooshort, "\t%lu with data size < data length\n");
361 p1a(ip6s_badoptions, "\t%lu with bad options\n");
362 p1a(ip6s_badvers, "\t%lu with incorrect version number\n");
363 p(ip6s_fragments, "\t%lu fragment%s received\n");
364 p(ip6s_fragdropped, "\t%lu fragment%s dropped (dup or out of space)\n");
365 p(ip6s_fragtimeout, "\t%lu fragment%s dropped after timeout\n");
366 p(ip6s_fragoverflow, "\t%lu fragment%s that exceeded limit\n");
367 p(ip6s_reassembled, "\t%lu packet%s reassembled ok\n");
368 p(ip6s_delivered, "\t%lu packet%s for this host\n");
369 p(ip6s_forward, "\t%lu packet%s forwarded\n");
370 p(ip6s_cantforward, "\t%lu packet%s not forwardable\n");
371 p(ip6s_redirectsent, "\t%lu redirect%s sent\n");
372 p(ip6s_localout, "\t%lu packet%s sent from this host\n");
373 p(ip6s_rawout, "\t%lu packet%s sent with fabricated ip header\n");
374 p(ip6s_odropped, "\t%lu output packet%s dropped due to no bufs, etc.\n");
375 p(ip6s_noroute, "\t%lu output packet%s discarded due to no route\n");
376 p(ip6s_fragmented, "\t%lu output datagram%s fragmented\n");
377 p(ip6s_ofragments, "\t%lu fragment%s created\n");
378 p(ip6s_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
379 p(ip6s_badscope, "\t%lu packet%s that violated scope rules\n");
380 p(ip6s_notmember, "\t%lu multicast packet%s which we don't join\n");
358 p(ip6s_total, "\t%llu total packet%s received\n");
359 p1a(ip6s_toosmall, "\t%llu with size smaller than minimum\n");
360 p1a(ip6s_tooshort, "\t%llu with data size < data length\n");
361 p1a(ip6s_badoptions, "\t%llu with bad options\n");
362 p1a(ip6s_badvers, "\t%llu with incorrect version number\n");
363 p(ip6s_fragments, "\t%llu fragment%s received\n");
364 p(ip6s_fragdropped, "\t%llu fragment%s dropped (dup or out of space)\n");
365 p(ip6s_fragtimeout, "\t%llu fragment%s dropped after timeout\n");
366 p(ip6s_fragoverflow, "\t%llu fragment%s that exceeded limit\n");
367 p(ip6s_reassembled, "\t%llu packet%s reassembled ok\n");
368 p(ip6s_delivered, "\t%llu packet%s for this host\n");
369 p(ip6s_forward, "\t%llu packet%s forwarded\n");
370 p(ip6s_cantforward, "\t%llu packet%s not forwardable\n");
371 p(ip6s_redirectsent, "\t%llu redirect%s sent\n");
372 p(ip6s_localout, "\t%llu packet%s sent from this host\n");
373 p(ip6s_rawout, "\t%llu packet%s sent with fabricated ip header\n");
374 p(ip6s_odropped, "\t%llu output packet%s dropped due to no bufs, etc.\n");
375 p(ip6s_noroute, "\t%llu output packet%s discarded due to no route\n");
376 p(ip6s_fragmented, "\t%llu output datagram%s fragmented\n");
377 p(ip6s_ofragments, "\t%llu fragment%s created\n");
378 p(ip6s_cantfrag, "\t%llu datagram%s that can't be fragmented\n");
379 p(ip6s_badscope, "\t%llu packet%s that violated scope rules\n");
380 p(ip6s_notmember, "\t%llu multicast packet%s which we don't join\n");
381 for (first = 1, i = 0; i < 256; i++)
382 if (ip6stat.ip6s_nxthist[i] != 0) {
383 if (first) {
384 printf("\tInput histogram:\n");
385 first = 0;
386 }
381 for (first = 1, i = 0; i < 256; i++)
382 if (ip6stat.ip6s_nxthist[i] != 0) {
383 if (first) {
384 printf("\tInput histogram:\n");
385 first = 0;
386 }
387 printf("\t\t%s: %lu\n", ip6nh[i],
388 ip6stat.ip6s_nxthist[i]);
387 printf("\t\t%s: %llu\n", ip6nh[i],
388 (unsigned long long)ip6stat.ip6s_nxthist[i]);
389 }
390 printf("\tMbuf statistics:\n");
389 }
390 printf("\tMbuf statistics:\n");
391 printf("\t\t%lu one mbuf\n", ip6stat.ip6s_m1);
391 printf("\t\t%llu one mbuf\n", (unsigned long long)ip6stat.ip6s_m1);
392 for (first = 1, i = 0; i < 32; i++) {
393 char ifbuf[IFNAMSIZ];
394 if (ip6stat.ip6s_m2m[i] != 0) {
395 if (first) {
396 printf("\t\ttwo or more mbuf:\n");
397 first = 0;
398 }
392 for (first = 1, i = 0; i < 32; i++) {
393 char ifbuf[IFNAMSIZ];
394 if (ip6stat.ip6s_m2m[i] != 0) {
395 if (first) {
396 printf("\t\ttwo or more mbuf:\n");
397 first = 0;
398 }
399 printf("\t\t\t%s= %ld\n",
400 if_indextoname(i, ifbuf),
401 ip6stat.ip6s_m2m[i]);
399 printf("\t\t\t%s= %llu\n",
400 if_indextoname(i, ifbuf),
401 (unsigned long long)ip6stat.ip6s_m2m[i]);
402 }
403 }
402 }
403 }
404 printf("\t\t%lu one ext mbuf\n", ip6stat.ip6s_mext1);
405 printf("\t\t%lu two or more ext mbuf\n", ip6stat.ip6s_mext2m);
406 p(ip6s_exthdrtoolong, "\t%lu packet%s whose headers are not continuous\n");
407 p(ip6s_nogif, "\t%lu tunneling packet%s that can't find gif\n");
408 p(ip6s_toomanyhdr, "\t%lu packet%s discarded due to too may headers\n");
404 printf("\t\t%llu one ext mbuf\n",
405 (unsigned long long)ip6stat.ip6s_mext1);
406 printf("\t\t%llu two or more ext mbuf\n",
407 (unsigned long long)ip6stat.ip6s_mext2m);
408 p(ip6s_exthdrtoolong,
409 "\t%llu packet%s whose headers are not continuous\n");
410 p(ip6s_nogif, "\t%llu tunneling packet%s that can't find gif\n");
411 p(ip6s_toomanyhdr,
412 "\t%llu packet%s discarded due to too may headers\n");
413
414 if (ip6stat.ip6s_exthdrget || ip6stat.ip6s_exthdrget0) {
415 p(ip6s_exthdrget, "\t%llu use%s of IP6_EXTHDR_GET\n");
416 p(ip6s_exthdrget0, "\t%llu use%s of IP6_EXTHDR_GET0\n");
417 p(ip6s_pulldown, "\t%llu call%s to m_pulldown\n");
418 p(ip6s_pulldown_alloc,
419 "\t%llu mbuf allocation%s in m_pulldown\n");
420 if (ip6stat.ip6s_pulldown_copy != 1) {
421 p1a(ip6s_pulldown_copy,
422 "\t%llu mbuf copies in m_pulldown\n");
423 } else {
424 p1a(ip6s_pulldown_copy,
425 "\t%llu mbuf copy in m_pulldown\n");
426 }
427 p(ip6s_pullup, "\t%llu call%s to m_pullup\n");
428 p(ip6s_pullup_alloc, "\t%llu mbuf allocation%s in m_pullup\n");
429 if (ip6stat.ip6s_pullup_copy != 1) {
430 p1a(ip6s_pullup_copy, "\t%llu mbuf copies in m_pullup\n");
431 } else {
432 p1a(ip6s_pullup_copy, "\t%llu mbuf copy in m_pullup\n");
433 }
434 p(ip6s_pullup_fail, "\t%llu failure%s in m_pullup\n");
435 p(ip6s_pullup2, "\t%llu call%s to m_pullup2\n");
436 p(ip6s_pullup2_alloc, "\t%llu mbuf allocation%s in m_pullup2\n");
437 if (ip6stat.ip6s_pullup2_copy != 1) {
438 p1a(ip6s_pullup2_copy,
439 "\t%llu mbuf copies in m_pullup2\n");
440 } else {
441 p1a(ip6s_pullup2_copy, "\t%llu mbuf copy in m_pullup2\n");
442 }
443 p(ip6s_pullup2_fail, "\t%llu failure%s in m_pullup2\n");
444 }
445
446 /* for debugging source address selection */
447#define PRINT_SCOPESTAT(s,i) do {\
448 switch(i) { /* XXX hardcoding in each case */\
449 case 1:\
450 p(s, "\t\t%llu node-local%s\n");\
451 break;\
452 case 2:\
453 p(s,"\t\t%llu link-local%s\n");\
454 break;\
455 case 5:\
456 p(s,"\t\t%llu site-local%s\n");\
457 break;\
458 case 14:\
459 p(s,"\t\t%llu global%s\n");\
460 break;\
461 default:\
462 printf("\t\t%llu addresses scope=%x\n",\
463 (unsigned long long)ip6stat.s, i);\
464 }\
465 } while (0);
466
467 p(ip6s_sources_none,
468 "\t%llu failure%s of source address selection\n");
469 for (first = 1, i = 0; i < 16; i++) {
470 if (ip6stat.ip6s_sources_sameif[i]) {
471 if (first) {
472 printf("\tsource addresses on an outgoing I/F\n");
473 first = 0;
474 }
475 PRINT_SCOPESTAT(ip6s_sources_sameif[i], i);
476 }
477 }
478 for (first = 1, i = 0; i < 16; i++) {
479 if (ip6stat.ip6s_sources_otherif[i]) {
480 if (first) {
481 printf("\tsource addresses on a non-outgoing I/F\n");
482 first = 0;
483 }
484 PRINT_SCOPESTAT(ip6s_sources_otherif[i], i);
485 }
486 }
487 for (first = 1, i = 0; i < 16; i++) {
488 if (ip6stat.ip6s_sources_samescope[i]) {
489 if (first) {
490 printf("\tsource addresses of same scope\n");
491 first = 0;
492 }
493 PRINT_SCOPESTAT(ip6s_sources_samescope[i], i);
494 }
495 }
496 for (first = 1, i = 0; i < 16; i++) {
497 if (ip6stat.ip6s_sources_otherscope[i]) {
498 if (first) {
499 printf("\tsource addresses of a different scope\n");
500 first = 0;
501 }
502 PRINT_SCOPESTAT(ip6s_sources_otherscope[i], i);
503 }
504 }
505 for (first = 1, i = 0; i < 16; i++) {
506 if (ip6stat.ip6s_sources_deprecated[i]) {
507 if (first) {
508 printf("\tdeprecated source addresses\n");
509 first = 0;
510 }
511 PRINT_SCOPESTAT(ip6s_sources_deprecated[i], i);
512 }
513 }
514
515 p1a(ip6s_forward_cachehit, "\t%llu forward cache hit\n");
516 p1a(ip6s_forward_cachemiss, "\t%llu forward cache miss\n");
409#undef p
517#undef p
518#undef p1a
410}
411
412/*
413 * Dump IPv6 per-interface statistics based on RFC 2465.
414 */
415void
416ip6_ifstats(ifname)
417 char *ifname;
418{
419 struct in6_ifreq ifr;
420 int s;
421#define p(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \
519}
520
521/*
522 * Dump IPv6 per-interface statistics based on RFC 2465.
523 */
524void
525ip6_ifstats(ifname)
526 char *ifname;
527{
528 struct in6_ifreq ifr;
529 int s;
530#define p(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \
422 printf(m, ifr.ifr_ifru.ifru_stat.f, plural(ifr.ifr_ifru.ifru_stat.f))
531 printf(m, (unsigned long long)ifr.ifr_ifru.ifru_stat.f, plural(ifr.ifr_ifru.ifru_stat.f))
423#define p_5(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \
532#define p_5(f, m) if (ifr.ifr_ifru.ifru_stat.f || sflag <= 1) \
424 printf(m, ip6stat.f)
533 printf(m, (unsigned long long)ip6stat.f)
425
426 if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
427 perror("Warning: socket(AF_INET6)");
428 return;
429 }
430
431 strcpy(ifr.ifr_name, ifname);
432 printf("ip6 on %s:\n", ifr.ifr_name);
433
434 if (ioctl(s, SIOCGIFSTAT_IN6, (char *)&ifr) < 0) {
435 perror("Warning: ioctl(SIOCGIFSTAT_IN6)");
436 goto end;
437 }
438
534
535 if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
536 perror("Warning: socket(AF_INET6)");
537 return;
538 }
539
540 strcpy(ifr.ifr_name, ifname);
541 printf("ip6 on %s:\n", ifr.ifr_name);
542
543 if (ioctl(s, SIOCGIFSTAT_IN6, (char *)&ifr) < 0) {
544 perror("Warning: ioctl(SIOCGIFSTAT_IN6)");
545 goto end;
546 }
547
439 p(ifs6_in_receive, "\t%qu total input datagram%s\n");
440 p(ifs6_in_hdrerr, "\t%qu datagram%s with invalid header received\n");
441 p(ifs6_in_toobig, "\t%qu datagram%s exceeded MTU received\n");
442 p(ifs6_in_noroute, "\t%qu datagram%s with no route received\n");
443 p(ifs6_in_addrerr, "\t%qu datagram%s with invalid dst received\n");
444 p(ifs6_in_protounknown, "\t%qu datagram%s with unknown proto received\n");
445 p(ifs6_in_truncated, "\t%qu truncated datagram%s received\n");
446 p(ifs6_in_discard, "\t%qu input datagram%s discarded\n");
548 p(ifs6_in_receive, "\t%llu total input datagram%s\n");
549 p(ifs6_in_hdrerr, "\t%llu datagram%s with invalid header received\n");
550 p(ifs6_in_toobig, "\t%llu datagram%s exceeded MTU received\n");
551 p(ifs6_in_noroute, "\t%llu datagram%s with no route received\n");
552 p(ifs6_in_addrerr, "\t%llu datagram%s with invalid dst received\n");
553 p(ifs6_in_protounknown, "\t%llu datagram%s with unknown proto received\n");
554 p(ifs6_in_truncated, "\t%llu truncated datagram%s received\n");
555 p(ifs6_in_discard, "\t%llu input datagram%s discarded\n");
447 p(ifs6_in_deliver,
556 p(ifs6_in_deliver,
448 "\t%qu datagram%s delivered to an upper layer protocol\n");
449 p(ifs6_out_forward, "\t%qu datagram%s forwarded to this interface\n");
557 "\t%llu datagram%s delivered to an upper layer protocol\n");
558 p(ifs6_out_forward, "\t%llu datagram%s forwarded to this interface\n");
450 p(ifs6_out_request,
559 p(ifs6_out_request,
451 "\t%qu datagram%s sent from an upper layer protocol\n");
452 p(ifs6_out_discard, "\t%qu total discarded output datagram%s\n");
453 p(ifs6_out_fragok, "\t%qu output datagram%s fragmented\n");
454 p(ifs6_out_fragfail, "\t%qu output datagram%s failed on fragment\n");
455 p(ifs6_out_fragcreat, "\t%qu output datagram%s succeeded on fragment\n");
456 p(ifs6_reass_reqd, "\t%qu incoming datagram%s fragmented\n");
457 p(ifs6_reass_ok, "\t%qu datagram%s reassembled\n");
458 p(ifs6_reass_fail, "\t%qu datagram%s failed on reassembling\n");
459 p(ifs6_in_mcast, "\t%qu multicast datagram%s received\n");
460 p(ifs6_out_mcast, "\t%qu multicast datagram%s sent\n");
560 "\t%llu datagram%s sent from an upper layer protocol\n");
561 p(ifs6_out_discard, "\t%llu total discarded output datagram%s\n");
562 p(ifs6_out_fragok, "\t%llu output datagram%s fragmented\n");
563 p(ifs6_out_fragfail, "\t%llu output datagram%s failed on fragment\n");
564 p(ifs6_out_fragcreat, "\t%llu output datagram%s succeeded on fragment\n");
565 p(ifs6_reass_reqd, "\t%llu incoming datagram%s fragmented\n");
566 p(ifs6_reass_ok, "\t%llu datagram%s reassembled\n");
567 p(ifs6_reass_fail, "\t%llu datagram%s failed on reassembling\n");
568 p(ifs6_in_mcast, "\t%llu multicast datagram%s received\n");
569 p(ifs6_out_mcast, "\t%llu multicast datagram%s sent\n");
461
462 end:
463 close(s);
464
465#undef p
466#undef p_5
467}
468

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

737 register int i, first;
738
739 if (off == 0)
740 return;
741 kread(off, (char *)&icmp6stat, sizeof (icmp6stat));
742 printf("%s:\n", name);
743
744#define p(f, m) if (icmp6stat.f || sflag <= 1) \
570
571 end:
572 close(s);
573
574#undef p
575#undef p_5
576}
577

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

846 register int i, first;
847
848 if (off == 0)
849 return;
850 kread(off, (char *)&icmp6stat, sizeof (icmp6stat));
851 printf("%s:\n", name);
852
853#define p(f, m) if (icmp6stat.f || sflag <= 1) \
745 printf(m, icmp6stat.f, plural(icmp6stat.f))
854 printf(m, (unsigned long long)icmp6stat.f, plural(icmp6stat.f))
855#define p_5(f, m) printf(m, (unsigned long long)icmp6stat.f)
746
856
747 p(icp6s_error, "\t%lu call%s to icmp_error\n");
857 p(icp6s_error, "\t%llu call%s to icmp_error\n");
748 p(icp6s_canterror,
858 p(icp6s_canterror,
749 "\t%lu error%s not generated because old message was icmp error or so\n");
859 "\t%llu error%s not generated because old message was icmp error or so\n");
750 p(icp6s_toofreq,
860 p(icp6s_toofreq,
751 "\t%lu error%s not generated because rate limitation\n");
861 "\t%llu error%s not generated because rate limitation\n");
752 for (first = 1, i = 0; i < 256; i++)
753 if (icmp6stat.icp6s_outhist[i] != 0) {
754 if (first) {
755 printf("\tOutput histogram:\n");
756 first = 0;
757 }
862 for (first = 1, i = 0; i < 256; i++)
863 if (icmp6stat.icp6s_outhist[i] != 0) {
864 if (first) {
865 printf("\tOutput histogram:\n");
866 first = 0;
867 }
758 printf("\t\t%s: %lu\n", icmp6names[i],
759 icmp6stat.icp6s_outhist[i]);
868 printf("\t\t%s: %llu\n", icmp6names[i],
869 (unsigned long long)icmp6stat.icp6s_outhist[i]);
760 }
870 }
761 p(icp6s_badcode, "\t%lu message%s with bad code fields\n");
762 p(icp6s_tooshort, "\t%lu message%s < minimum length\n");
763 p(icp6s_checksum, "\t%lu bad checksum%s\n");
764 p(icp6s_badlen, "\t%lu message%s with bad length\n");
871 p(icp6s_badcode, "\t%llu message%s with bad code fields\n");
872 p(icp6s_tooshort, "\t%llu message%s < minimum length\n");
873 p(icp6s_checksum, "\t%llu bad checksum%s\n");
874 p(icp6s_badlen, "\t%llu message%s with bad length\n");
765 for (first = 1, i = 0; i < ICMP6_MAXTYPE; i++)
766 if (icmp6stat.icp6s_inhist[i] != 0) {
767 if (first) {
768 printf("\tInput histogram:\n");
769 first = 0;
770 }
875 for (first = 1, i = 0; i < ICMP6_MAXTYPE; i++)
876 if (icmp6stat.icp6s_inhist[i] != 0) {
877 if (first) {
878 printf("\tInput histogram:\n");
879 first = 0;
880 }
771 printf("\t\t%s: %lu\n", icmp6names[i],
772 icmp6stat.icp6s_inhist[i]);
881 printf("\t\t%s: %llu\n", icmp6names[i],
882 (unsigned long long)icmp6stat.icp6s_inhist[i]);
773 }
883 }
774 p(icp6s_reflect, "\t%lu message response%s generated\n");
884 printf("\tHistgram of error messages to be generated:\n");
885 p_5(icp6s_odst_unreach_noroute, "\t\t%llu no route\n");
886 p_5(icp6s_odst_unreach_admin, "\t\t%llu administratively prohibited\n");
887 p_5(icp6s_odst_unreach_beyondscope, "\t\t%llu beyond scope\n");
888 p_5(icp6s_odst_unreach_addr, "\t\t%llu address unreachable\n");
889 p_5(icp6s_odst_unreach_noport, "\t\t%llu port unreachable\n");
890 p_5(icp6s_opacket_too_big, "\t\t%llu packet too big\n");
891 p_5(icp6s_otime_exceed_transit, "\t\t%llu time exceed transit\n");
892 p_5(icp6s_otime_exceed_reassembly, "\t\t%llu time exceed reassembly\n");
893 p_5(icp6s_oparamprob_header, "\t\t%llu erroneous header field\n");
894 p_5(icp6s_oparamprob_nextheader, "\t\t%llu unrecognized next header\n");
895 p_5(icp6s_oparamprob_option, "\t\t%llu unrecognized option\n");
896 p_5(icp6s_oredirect, "\t\t%llu redirect\n");
897 p_5(icp6s_ounknown, "\t\t%llu unknown\n");
898
899 p(icp6s_reflect, "\t%llu message response%s generated\n");
900 p(icp6s_nd_toomanyopt, "\t%llu message%s with too many ND options\n");
775#undef p
776#undef p_5
777}
778
779/*
780 * Dump ICMPv6 per-interface statistics based on RFC 2466.
781 */
782void
783icmp6_ifstats(ifname)
784 char *ifname;
785{
786 struct in6_ifreq ifr;
787 int s;
788#define p(f, m) if (ifr.ifr_ifru.ifru_icmp6stat.f || sflag <= 1) \
901#undef p
902#undef p_5
903}
904
905/*
906 * Dump ICMPv6 per-interface statistics based on RFC 2466.
907 */
908void
909icmp6_ifstats(ifname)
910 char *ifname;
911{
912 struct in6_ifreq ifr;
913 int s;
914#define p(f, m) if (ifr.ifr_ifru.ifru_icmp6stat.f || sflag <= 1) \
789 printf(m, (u_quad_t)ifr.ifr_ifru.ifru_icmp6stat.f, plural(ifr.ifr_ifru.ifru_icmp6stat.f))
915 printf(m, (unsigned long long)ifr.ifr_ifru.ifru_icmp6stat.f, plural(ifr.ifr_ifru.ifru_icmp6stat.f))
790
791 if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
792 perror("Warning: socket(AF_INET6)");
793 return;
794 }
795
796 strcpy(ifr.ifr_name, ifname);
797 printf("icmp6 on %s:\n", ifr.ifr_name);
798
799 if (ioctl(s, SIOCGIFSTAT_ICMP6, (char *)&ifr) < 0) {
800 perror("Warning: ioctl(SIOCGIFSTAT_ICMP6)");
801 goto end;
802 }
803
916
917 if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
918 perror("Warning: socket(AF_INET6)");
919 return;
920 }
921
922 strcpy(ifr.ifr_name, ifname);
923 printf("icmp6 on %s:\n", ifr.ifr_name);
924
925 if (ioctl(s, SIOCGIFSTAT_ICMP6, (char *)&ifr) < 0) {
926 perror("Warning: ioctl(SIOCGIFSTAT_ICMP6)");
927 goto end;
928 }
929
804 p(ifs6_in_msg, "\t%qu total input message%s\n");
805 p(ifs6_in_error, "\t%qu total input error message%s\n");
806 p(ifs6_in_dstunreach, "\t%qu input destination unreachable error%s\n");
807 p(ifs6_in_adminprohib, "\t%qu input administratively prohibited error%s\n");
808 p(ifs6_in_timeexceed, "\t%qu input time exceeded error%s\n");
809 p(ifs6_in_paramprob, "\t%qu input parameter problem error%s\n");
810 p(ifs6_in_pkttoobig, "\t%qu input packet too big error%s\n");
811 p(ifs6_in_echo, "\t%qu input echo request%s\n");
812 p(ifs6_in_echoreply, "\t%qu input echo reply%s\n");
813 p(ifs6_in_routersolicit, "\t%qu input router solicitation%s\n");
814 p(ifs6_in_routeradvert, "\t%qu input router advertisement%s\n");
815 p(ifs6_in_neighborsolicit, "\t%qu input neighbor solicitation%s\n");
816 p(ifs6_in_neighboradvert, "\t%qu input neighbor advertisement%s\n");
817 p(ifs6_in_redirect, "\t%qu input redirect%s\n");
818 p(ifs6_in_mldquery, "\t%qu input MLD query%s\n");
819 p(ifs6_in_mldreport, "\t%qu input MLD report%s\n");
820 p(ifs6_in_mlddone, "\t%qu input MLD done%s\n");
930 p(ifs6_in_msg, "\t%llu total input message%s\n");
931 p(ifs6_in_error, "\t%llu total input error message%s\n");
932 p(ifs6_in_dstunreach, "\t%llu input destination unreachable error%s\n");
933 p(ifs6_in_adminprohib, "\t%llu input administratively prohibited error%s\n");
934 p(ifs6_in_timeexceed, "\t%llu input time exceeded error%s\n");
935 p(ifs6_in_paramprob, "\t%llu input parameter problem error%s\n");
936 p(ifs6_in_pkttoobig, "\t%llu input packet too big error%s\n");
937 p(ifs6_in_echo, "\t%llu input echo request%s\n");
938 p(ifs6_in_echoreply, "\t%llu input echo reply%s\n");
939 p(ifs6_in_routersolicit, "\t%llu input router solicitation%s\n");
940 p(ifs6_in_routeradvert, "\t%llu input router advertisement%s\n");
941 p(ifs6_in_neighborsolicit, "\t%llu input neighbor solicitation%s\n");
942 p(ifs6_in_neighboradvert, "\t%llu input neighbor advertisement%s\n");
943 p(ifs6_in_redirect, "\t%llu input redirect%s\n");
944 p(ifs6_in_mldquery, "\t%llu input MLD query%s\n");
945 p(ifs6_in_mldreport, "\t%llu input MLD report%s\n");
946 p(ifs6_in_mlddone, "\t%llu input MLD done%s\n");
821
947
822 p(ifs6_out_msg, "\t%qu total output message%s\n");
823 p(ifs6_out_error, "\t%qu total output error message%s\n");
824 p(ifs6_out_dstunreach, "\t%qu output destination unreachable error%s\n");
825 p(ifs6_out_adminprohib, "\t%qu output administratively prohibited error%s\n");
826 p(ifs6_out_timeexceed, "\t%qu output time exceeded error%s\n");
827 p(ifs6_out_paramprob, "\t%qu output parameter problem error%s\n");
828 p(ifs6_out_pkttoobig, "\t%qu output packet too big error%s\n");
829 p(ifs6_out_echo, "\t%qu output echo request%s\n");
830 p(ifs6_out_echoreply, "\t%qu output echo reply%s\n");
831 p(ifs6_out_routersolicit, "\t%qu output router solicitation%s\n");
832 p(ifs6_out_routeradvert, "\t%qu output router advertisement%s\n");
833 p(ifs6_out_neighborsolicit, "\t%qu output neighbor solicitation%s\n");
834 p(ifs6_out_neighboradvert, "\t%qu output neighbor advertisement%s\n");
835 p(ifs6_out_redirect, "\t%qu output redirect%s\n");
836 p(ifs6_out_mldquery, "\t%qu output MLD query%s\n");
837 p(ifs6_out_mldreport, "\t%qu output MLD report%s\n");
838 p(ifs6_out_mlddone, "\t%qu output MLD done%s\n");
948 p(ifs6_out_msg, "\t%llu total output message%s\n");
949 p(ifs6_out_error, "\t%llu total output error message%s\n");
950 p(ifs6_out_dstunreach, "\t%llu output destination unreachable error%s\n");
951 p(ifs6_out_adminprohib, "\t%llu output administratively prohibited error%s\n");
952 p(ifs6_out_timeexceed, "\t%llu output time exceeded error%s\n");
953 p(ifs6_out_paramprob, "\t%llu output parameter problem error%s\n");
954 p(ifs6_out_pkttoobig, "\t%llu output packet too big error%s\n");
955 p(ifs6_out_echo, "\t%llu output echo request%s\n");
956 p(ifs6_out_echoreply, "\t%llu output echo reply%s\n");
957 p(ifs6_out_routersolicit, "\t%llu output router solicitation%s\n");
958 p(ifs6_out_routeradvert, "\t%llu output router advertisement%s\n");
959 p(ifs6_out_neighborsolicit, "\t%llu output neighbor solicitation%s\n");
960 p(ifs6_out_neighboradvert, "\t%llu output neighbor advertisement%s\n");
961 p(ifs6_out_redirect, "\t%llu output redirect%s\n");
962 p(ifs6_out_mldquery, "\t%llu output MLD query%s\n");
963 p(ifs6_out_mldreport, "\t%llu output MLD report%s\n");
964 p(ifs6_out_mlddone, "\t%llu output MLD done%s\n");
839
840 end:
841 close(s);
842#undef p
843}
844
845/*
846 * Dump PIM statistics structure.

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

853 struct pim6stat pim6stat;
854
855 if (off == 0)
856 return;
857 kread(off, (char *)&pim6stat, sizeof(pim6stat));
858 printf("%s:\n", name);
859
860#define p(f, m) if (pim6stat.f || sflag <= 1) \
965
966 end:
967 close(s);
968#undef p
969}
970
971/*
972 * Dump PIM statistics structure.

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

979 struct pim6stat pim6stat;
980
981 if (off == 0)
982 return;
983 kread(off, (char *)&pim6stat, sizeof(pim6stat));
984 printf("%s:\n", name);
985
986#define p(f, m) if (pim6stat.f || sflag <= 1) \
861 printf(m, pim6stat.f, plural(pim6stat.f))
862 p(pim6s_rcv_total, "\t%u message%s received\n");
863 p(pim6s_rcv_tooshort, "\t%u message%s received with too few bytes\n");
864 p(pim6s_rcv_badsum, "\t%u message%s received with bad checksum\n");
865 p(pim6s_rcv_badversion, "\t%u message%s received with bad version\n");
866 p(pim6s_rcv_registers, "\t%u register%s received\n");
867 p(pim6s_rcv_badregisters, "\t%u bad register%s received\n");
868 p(pim6s_snd_registers, "\t%u register%s sent\n");
987 printf(m, (unsigned long long)pim6stat.f, plural(pim6stat.f))
988 p(pim6s_rcv_total, "\t%llu message%s received\n");
989 p(pim6s_rcv_tooshort, "\t%llu message%s received with too few bytes\n");
990 p(pim6s_rcv_badsum, "\t%llu message%s received with bad checksum\n");
991 p(pim6s_rcv_badversion, "\t%llu message%s received with bad version\n");
992 p(pim6s_rcv_registers, "\t%llu register%s received\n");
993 p(pim6s_rcv_badregisters, "\t%llu bad register%s received\n");
994 p(pim6s_snd_registers, "\t%llu register%s sent\n");
869#undef p
870}
871
872/*
873 * Pretty print an Internet address (net address + port).
874 * If the nflag was specified, use numbers instead of names.
875 */
876#define GETSERVBYPORT6(port, proto, ret)\

--- 77 unchanged lines hidden ---
995#undef p
996}
997
998/*
999 * Pretty print an Internet address (net address + port).
1000 * If the nflag was specified, use numbers instead of names.
1001 */
1002#define GETSERVBYPORT6(port, proto, ret)\

--- 77 unchanged lines hidden ---