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

Function sctp_protopr

tools/netstat/sctp.c:495–534  ·  view source on GitHub ↗

* Print a summary of SCTP connections related to an Internet * protocol. */

Source from the content-addressed store, hash-verified

493 * protocol.
494 */
495void
496sctp_protopr(u_long off __unused,
497 const char *name __unused, int af1 __unused, int proto)
498{
499 char *buf;
500 const char *mibvar = "net.inet.sctp.assoclist";
501 size_t offset = 0;
502 size_t len = 0;
503 struct xsctp_inpcb *xinpcb;
504
505 if (proto != IPPROTO_SCTP)
506 return;
507
508 if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
509 if (errno != ENOENT)
510 xo_warn("sysctl: %s", mibvar);
511 return;
512 }
513 if ((buf = malloc(len)) == NULL) {
514 xo_warnx("malloc %lu bytes", (u_long)len);
515 return;
516 }
517 if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
518 xo_warn("sysctl: %s", mibvar);
519 free(buf);
520 return;
521 }
522
523 xinpcb = (struct xsctp_inpcb *)(buf + offset);
524 offset += sizeof(struct xsctp_inpcb);
525 while (xinpcb->last == 0 && offset < len) {
526 sctp_process_inpcb(xinpcb, buf, (const size_t)len,
527 &offset);
528
529 xinpcb = (struct xsctp_inpcb *)(buf + offset);
530 offset += sizeof(struct xsctp_inpcb);
531 }
532
533 free(buf);
534}
535
536static void
537sctp_statesprint(uint32_t state)

Callers

nothing calls this directly

Calls 6

sysctlbynameFunction · 0.85
xo_warnFunction · 0.85
mallocFunction · 0.85
xo_warnxFunction · 0.85
sctp_process_inpcbFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected