Deleted Added
full compact
inet.c (249345) inet.c (253081)
1/*-
2 * Copyright (c) 1983, 1988, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

29
30#if 0
31#ifndef lint
32static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
33#endif /* not lint */
34#endif
35
36#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1983, 1988, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

29
30#if 0
31#ifndef lint
32static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
33#endif /* not lint */
34#endif
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/usr.bin/netstat/inet.c 249345 2013-04-10 20:29:23Z glebius $");
37__FBSDID("$FreeBSD: head/usr.bin/netstat/inet.c 253081 2013-07-09 09:32:06Z ae $");
38
39#include <sys/param.h>
40#include <sys/queue.h>
41#include <sys/domain.h>
42#include <sys/protosw.h>
43#include <sys/socket.h>
44#include <sys/socketvar.h>
45#include <sys/sysctl.h>

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

738/*
739 * Dump UDP statistics structure.
740 */
741void
742udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
743{
744 struct udpstat udpstat, zerostat;
745 size_t len = sizeof udpstat;
38
39#include <sys/param.h>
40#include <sys/queue.h>
41#include <sys/domain.h>
42#include <sys/protosw.h>
43#include <sys/socket.h>
44#include <sys/socketvar.h>
45#include <sys/sysctl.h>

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

738/*
739 * Dump UDP statistics structure.
740 */
741void
742udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
743{
744 struct udpstat udpstat, zerostat;
745 size_t len = sizeof udpstat;
746 u_long delivered;
746 uint64_t delivered;
747
748#ifdef INET6
749 if (udp_done != 0)
750 return;
751 else
752 udp_done = 1;
753#endif
754

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

760 warn("sysctl: net.inet.udp.stats");
761 return;
762 }
763 } else
764 kread(off, &udpstat, len);
765
766 printf("%s:\n", name);
767#define p(f, m) if (udpstat.f || sflag <= 1) \
747
748#ifdef INET6
749 if (udp_done != 0)
750 return;
751 else
752 udp_done = 1;
753#endif
754

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

760 warn("sysctl: net.inet.udp.stats");
761 return;
762 }
763 } else
764 kread(off, &udpstat, len);
765
766 printf("%s:\n", name);
767#define p(f, m) if (udpstat.f || sflag <= 1) \
768 printf(m, udpstat.f, plural(udpstat.f))
768 printf("\t%ju " m, (uintmax_t)udpstat.f, plural(udpstat.f))
769#define p1a(f, m) if (udpstat.f || sflag <= 1) \
769#define p1a(f, m) if (udpstat.f || sflag <= 1) \
770 printf(m, udpstat.f)
771 p(udps_ipackets, "\t%lu datagram%s received\n");
772 p1a(udps_hdrops, "\t%lu with incomplete header\n");
773 p1a(udps_badlen, "\t%lu with bad data length field\n");
774 p1a(udps_badsum, "\t%lu with bad checksum\n");
775 p1a(udps_nosum, "\t%lu with no checksum\n");
776 p1a(udps_noport, "\t%lu dropped due to no socket\n");
770 printf("\t%ju " m, (uintmax_t)udpstat.f)
771 p(udps_ipackets, "datagram%s received\n");
772 p1a(udps_hdrops, "with incomplete header\n");
773 p1a(udps_badlen, "with bad data length field\n");
774 p1a(udps_badsum, "with bad checksum\n");
775 p1a(udps_nosum, "with no checksum\n");
776 p1a(udps_noport, "dropped due to no socket\n");
777 p(udps_noportbcast,
777 p(udps_noportbcast,
778 "\t%lu broadcast/multicast datagram%s undelivered\n");
779 p1a(udps_fullsock, "\t%lu dropped due to full socket buffers\n");
780 p1a(udpps_pcbhashmiss, "\t%lu not for hashed pcb\n");
778 "broadcast/multicast datagram%s undelivered\n");
779 p1a(udps_fullsock, "dropped due to full socket buffers\n");
780 p1a(udpps_pcbhashmiss, "not for hashed pcb\n");
781 delivered = udpstat.udps_ipackets -
782 udpstat.udps_hdrops -
783 udpstat.udps_badlen -
784 udpstat.udps_badsum -
785 udpstat.udps_noport -
786 udpstat.udps_noportbcast -
787 udpstat.udps_fullsock;
788 if (delivered || sflag <= 1)
781 delivered = udpstat.udps_ipackets -
782 udpstat.udps_hdrops -
783 udpstat.udps_badlen -
784 udpstat.udps_badsum -
785 udpstat.udps_noport -
786 udpstat.udps_noportbcast -
787 udpstat.udps_fullsock;
788 if (delivered || sflag <= 1)
789 printf("\t%lu delivered\n", delivered);
790 p(udps_opackets, "\t%lu datagram%s output\n");
789 printf("\t%ju delivered\n", (uint64_t)delivered);
790 p(udps_opackets, "datagram%s output\n");
791 /* the next statistic is cumulative in udps_noportbcast */
792 p(udps_filtermcast,
791 /* the next statistic is cumulative in udps_noportbcast */
792 p(udps_filtermcast,
793 "\t%lu time%s multicast source filter matched\n");
793 "time%s multicast source filter matched\n");
794#undef p
795#undef p1a
796}
797
798/*
799 * Dump CARP statistics structure.
800 */
801void

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

933 return;
934 }
935 } else
936 kread(off, &arpstat, len);
937
938 printf("%s:\n", name);
939
940#define p(f, m) if (arpstat.f || sflag <= 1) \
794#undef p
795#undef p1a
796}
797
798/*
799 * Dump CARP statistics structure.
800 */
801void

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

933 return;
934 }
935 } else
936 kread(off, &arpstat, len);
937
938 printf("%s:\n", name);
939
940#define p(f, m) if (arpstat.f || sflag <= 1) \
941 printf(m, arpstat.f, plural(arpstat.f))
941 printf("\t%ju " m, (uintmax_t)arpstat.f, plural(arpstat.f))
942#define p2(f, m) if (arpstat.f || sflag <= 1) \
942#define p2(f, m) if (arpstat.f || sflag <= 1) \
943 printf(m, arpstat.f, pluralies(arpstat.f))
943 printf("\t%ju " m, (uintmax_t)arpstat.f, pluralies(arpstat.f))
944
944
945 p(txrequests, "\t%lu ARP request%s sent\n");
946 p2(txreplies, "\t%lu ARP repl%s sent\n");
947 p(rxrequests, "\t%lu ARP request%s received\n");
948 p2(rxreplies, "\t%lu ARP repl%s received\n");
949 p(received, "\t%lu ARP packet%s received\n");
950 p(dropped, "\t%lu total packet%s dropped due to no ARP entry\n");
951 p(timeouts, "\t%lu ARP entry%s timed out\n");
952 p(dupips, "\t%lu Duplicate IP%s seen\n");
945 p(txrequests, "ARP request%s sent\n");
946 p2(txreplies, "ARP repl%s sent\n");
947 p(rxrequests, "ARP request%s received\n");
948 p2(rxreplies, "ARP repl%s received\n");
949 p(received, "ARP packet%s received\n");
950 p(dropped, "total packet%s dropped due to no ARP entry\n");
951 p(timeouts, "ARP entry%s timed out\n");
952 p(dupips, "Duplicate IP%s seen\n");
953#undef p
954#undef p2
955}
956
957
958
959static const char *icmpnames[ICMP_MAXTYPE + 1] = {
960 "echo reply", /* RFC 792 */

--- 365 unchanged lines hidden ---
953#undef p
954#undef p2
955}
956
957
958
959static const char *icmpnames[ICMP_MAXTYPE + 1] = {
960 "echo reply", /* RFC 792 */

--- 365 unchanged lines hidden ---