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

Function netgraphprotopr

tools/netstat/netgraph.c:66–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64static int csock = -1;
65
66void
67netgraphprotopr(u_long off, const char *name, int af1 __unused,
68 int proto __unused)
69{
70 struct ngpcb *this, *next;
71 struct ngpcb ngpcb;
72 struct socket sockb;
73 int debug = 1;
74
75 /* If symbol not found, try looking in the KLD module */
76 if (off == 0) {
77 if (debug)
78 xo_warnx("Error reading symbols from ng_socket.ko");
79 return;
80 }
81
82 /* Get pointer to first socket */
83 kread(off, (char *)&this, sizeof(this));
84
85 /* Get my own socket node */
86 if (csock == -1)
87 NgMkSockNode(NULL, &csock, NULL);
88
89 for (; this != NULL; this = next) {
90 u_char rbuf[sizeof(struct ng_mesg) + sizeof(struct nodeinfo)];
91 struct ng_mesg *resp = (struct ng_mesg *) rbuf;
92 struct nodeinfo *ni = (struct nodeinfo *) resp->data;
93 char path[64];
94
95 /* Read in ngpcb structure */
96 kread((u_long)this, (char *)&ngpcb, sizeof(ngpcb));
97 next = LIST_NEXT(&ngpcb, socks);
98
99 /* Read in socket structure */
100 kread((u_long)ngpcb.ng_socket, (char *)&sockb, sizeof(sockb));
101
102 /* Check type of socket */
103 if (strcmp(name, "ctrl") == 0 && ngpcb.type != NG_CONTROL)
104 continue;
105 if (strcmp(name, "data") == 0 && ngpcb.type != NG_DATA)
106 continue;
107
108 /* Do headline */
109 if (first) {
110 xo_emit("{T:Netgraph sockets}\n");
111 if (Aflag)
112 xo_emit("{T:/%-8.8s} ", "PCB");
113 xo_emit("{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} "
114 "{T:/%-14.14s} {T:/%s}\n",
115 "Type", "Recv-Q", "Send-Q", "Node Address",
116 "#Hooks");
117 first = 0;
118 }
119
120 /* Show socket */
121 if (Aflag)
122 xo_emit("{:address/%8lx} ", (u_long) this);
123 xo_emit("{t:name/%-5.5s} {:receive-bytes-waiting/%6u} "

Callers

nothing calls this directly

Calls 8

xo_warnxFunction · 0.85
NgMkSockNodeFunction · 0.85
strcmpFunction · 0.85
xo_emitFunction · 0.85
snprintfFunction · 0.85
NgSendMsgFunction · 0.85
NgRecvMsgFunction · 0.85
kreadFunction · 0.70

Tested by

no test coverage detected