MCPcopy Create free account
hub / github.com/F-Stack/f-stack / udp_stats

Function udp_stats

tools/netstat/inet.c:887–947  ·  view source on GitHub ↗

* Dump UDP statistics structure. */

Source from the content-addressed store, hash-verified

885 * Dump UDP statistics structure.
886 */
887void
888udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
889{
890 struct udpstat udpstat;
891 uint64_t delivered;
892
893#ifdef INET6
894 if (udp_done != 0)
895 return;
896 else
897 udp_done = 1;
898#endif
899
900 if (fetch_stats("net.inet.udp.stats", off, &udpstat,
901 sizeof(udpstat), kread_counters) != 0)
902 return;
903
904 xo_open_container("udp");
905 xo_emit("{T:/%s}:\n", name);
906
907#define p(f, m) if (udpstat.f || sflag <= 1) \
908 xo_emit("\t" m, (uintmax_t)udpstat.f, plural(udpstat.f))
909#define p1a(f, m) if (udpstat.f || sflag <= 1) \
910 xo_emit("\t" m, (uintmax_t)udpstat.f)
911
912 p(udps_ipackets, "{:received-datagrams/%ju} "
913 "{N:/datagram%s received}\n");
914 p1a(udps_hdrops, "{:dropped-incomplete-headers/%ju} "
915 "{N:/with incomplete header}\n");
916 p1a(udps_badlen, "{:dropped-bad-data-length/%ju} "
917 "{N:/with bad data length field}\n");
918 p1a(udps_badsum, "{:dropped-bad-checksum/%ju} "
919 "{N:/with bad checksum}\n");
920 p1a(udps_nosum, "{:dropped-no-checksum/%ju} "
921 "{N:/with no checksum}\n");
922 p1a(udps_noport, "{:dropped-no-socket/%ju} "
923 "{N:/dropped due to no socket}\n");
924 p(udps_noportbcast, "{:dropped-broadcast-multicast/%ju} "
925 "{N:/broadcast\\/multicast datagram%s undelivered}\n");
926 p1a(udps_fullsock, "{:dropped-full-socket-buffer/%ju} "
927 "{N:/dropped due to full socket buffers}\n");
928 p1a(udpps_pcbhashmiss, "{:not-for-hashed-pcb/%ju} "
929 "{N:/not for hashed pcb}\n");
930 delivered = udpstat.udps_ipackets -
931 udpstat.udps_hdrops -
932 udpstat.udps_badlen -
933 udpstat.udps_badsum -
934 udpstat.udps_noport -
935 udpstat.udps_noportbcast -
936 udpstat.udps_fullsock;
937 if (delivered || sflag <= 1)
938 xo_emit("\t{:delivered-packets/%ju} {N:/delivered}\n",
939 (uint64_t)delivered);
940 p(udps_opackets, "{:output-packets/%ju} {N:/datagram%s output}\n");
941 /* the next statistic is cumulative in udps_noportbcast */
942 p(udps_filtermcast, "{:multicast-source-filter-matches/%ju} "
943 "{N:/time%s multicast source filter matched}\n");
944#undef p

Callers

nothing calls this directly

Calls 4

fetch_statsFunction · 0.85
xo_open_containerFunction · 0.85
xo_emitFunction · 0.85
xo_close_containerFunction · 0.85

Tested by

no test coverage detected