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

Function unixdomainpr

tools/netstat/unix.c:280–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280static void
281unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
282{
283 struct sockaddr_un *sa;
284 static int first = 1;
285 char buf1[33];
286 static const char *titles[2] = {
287 "{T:/%-8.8s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%8.8s} "
288 "{T:/%8.8s} {T:/%8.8s} {T:/%8.8s} {T:Addr}\n",
289 "{T:/%-16.16s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%16.16s} "
290 "{T:/%16.16s} {T:/%16.16s} {T:/%16.16s} {T:Addr}\n"
291 };
292 static const char *format[2] = {
293 "{q:address/%8lx} {t:type/%-6.6s} "
294 "{:receive-bytes-waiting/%6u} "
295 "{:send-bytes-waiting/%6u} "
296 "{q:vnode/%8lx} {q:connection/%8lx} "
297 "{q:first-reference/%8lx} {q:next-reference/%8lx}",
298 "{q:address/%16lx} {t:type/%-6.6s} "
299 "{:receive-bytes-waiting/%6u} "
300 "{:send-bytes-waiting/%6u} "
301 "{q:vnode/%16lx} {q:connection/%16lx} "
302 "{q:first-reference/%16lx} {q:next-reference/%16lx}"
303 };
304 int fmt = (sizeof(void *) == 8) ? 1 : 0;
305
306 sa = (xunp->xu_addr.sun_family == AF_UNIX) ? &xunp->xu_addr : NULL;
307
308 if (first && !Lflag) {
309 xo_emit("{T:Active UNIX domain sockets}\n");
310 xo_emit(titles[fmt],
311 "Address", "Type", "Recv-Q", "Send-Q",
312 "Inode", "Conn", "Refs", "Nextref");
313 first = 0;
314 }
315
316 if (Lflag && so->so_qlimit == 0)
317 return;
318
319 if (Lflag) {
320 snprintf(buf1, sizeof buf1, "%u/%u/%u", so->so_qlen,
321 so->so_incqlen, so->so_qlimit);
322 xo_emit("unix {d:socket/%-32.32s}{e:queue-length/%u}"
323 "{e:incomplete-queue-length/%u}{e:queue-limit/%u}",
324 buf1, so->so_qlen, so->so_incqlen, so->so_qlimit);
325 } else {
326 xo_emit(format[fmt],
327 (long)so->so_pcb, socktype[so->so_type], so->so_rcv.sb_cc,
328 so->so_snd.sb_cc, (long)xunp->unp_vnode,
329 (long)xunp->unp_conn, (long)xunp->xu_firstref,
330 (long)xunp->xu_nextref);
331 }
332 if (sa)
333 xo_emit(" {:path/%.*s}",
334 (int)(sa->sun_len - offsetof(struct sockaddr_un, sun_path)),
335 sa->sun_path);
336 xo_emit("\n");
337}

Callers 1

unixprFunction · 0.85

Calls 2

xo_emitFunction · 0.85
snprintfFunction · 0.85

Tested by

no test coverage detected