* Print a summary of SCTP connections related to an Internet * protocol. */
| 493 | * protocol. |
| 494 | */ |
| 495 | void |
| 496 | sctp_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 | |
| 536 | static void |
| 537 | sctp_statesprint(uint32_t state) |
nothing calls this directly
no test coverage detected