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

Function protopr

tools/netstat/inet.c:200–599  ·  view source on GitHub ↗

* Print a summary of connections related to an Internet * protocol. For TCP, also give state of connection. * Listening processes (aflag) are suppressed unless the * -a (all) flag is specified. */

Source from the content-addressed store, hash-verified

198 * -a (all) flag is specified.
199 */
200void
201protopr(u_long off, const char *name, int af1, int proto)
202{
203 static int first = 1;
204 int istcp;
205 char *buf;
206 const char *vchar;
207 struct xtcpcb *tp;
208 struct xinpcb *inp;
209 struct xinpgen *xig, *oxig;
210 struct xsocket *so;
211 int fnamelen, cnamelen;
212
213 istcp = 0;
214 switch (proto) {
215 case IPPROTO_TCP:
216#ifdef INET6
217 if (strncmp(name, "sdp", 3) != 0) {
218 if (tcp_done != 0)
219 return;
220 else
221 tcp_done = 1;
222 } else {
223 if (sdp_done != 0)
224 return;
225 else
226 sdp_done = 1;
227 }
228#endif
229 istcp = 1;
230 break;
231 case IPPROTO_UDP:
232#ifdef INET6
233 if (udp_done != 0)
234 return;
235 else
236 udp_done = 1;
237#endif
238 break;
239 }
240
241 if (!pcblist_sysctl(proto, name, &buf))
242 return;
243
244 if (cflag || Cflag) {
245 fnamelen = strlen("Stack");
246 cnamelen = strlen("CC");
247 oxig = xig = (struct xinpgen *)buf;
248 for (xig = (struct xinpgen*)((char *)xig + xig->xig_len);
249 xig->xig_len > sizeof(struct xinpgen);
250 xig = (struct xinpgen *)((char *)xig + xig->xig_len)) {
251 if (istcp) {
252 tp = (struct xtcpcb *)xig;
253 inp = &tp->xt_inp;
254 } else {
255 continue;
256 }
257#ifndef FSTACK

Callers

nothing calls this directly

Calls 10

strncmpFunction · 0.85
maxFunction · 0.85
xo_emitFunction · 0.85
xo_open_instanceFunction · 0.85
snprintfFunction · 0.85
inetprintFunction · 0.85
inet6printFunction · 0.85
xo_close_instanceFunction · 0.85
pcblist_sysctlFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected