174fd40c9SRandall Stewart /*- 274fd40c9SRandall Stewart * Copyright (c) 2001-2007, by Weongyo Jeong. All rights reserved. 32e34c19bSMichael Tuexen * Copyright (c) 2011, by Michael Tuexen. All rights reserved. 474fd40c9SRandall Stewart * 574fd40c9SRandall Stewart * Redistribution and use in source and binary forms, with or without 674fd40c9SRandall Stewart * modification, are permitted provided that the following conditions are met: 774fd40c9SRandall Stewart * 874fd40c9SRandall Stewart * a) Redistributions of source code must retain the above copyright notice, 974fd40c9SRandall Stewart * this list of conditions and the following disclaimer. 1074fd40c9SRandall Stewart * 1174fd40c9SRandall Stewart * b) Redistributions in binary form must reproduce the above copyright 1274fd40c9SRandall Stewart * notice, this list of conditions and the following disclaimer in 1374fd40c9SRandall Stewart * the documentation and/or other materials provided with the distribution. 1474fd40c9SRandall Stewart * 1574fd40c9SRandall Stewart * c) Neither the name of Cisco Systems, Inc. nor the names of its 1674fd40c9SRandall Stewart * contributors may be used to endorse or promote products derived 1774fd40c9SRandall Stewart * from this software without specific prior written permission. 1874fd40c9SRandall Stewart * 1974fd40c9SRandall Stewart * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2074fd40c9SRandall Stewart * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 2174fd40c9SRandall Stewart * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2274fd40c9SRandall Stewart * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2374fd40c9SRandall Stewart * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2474fd40c9SRandall Stewart * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2574fd40c9SRandall Stewart * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2674fd40c9SRandall Stewart * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2774fd40c9SRandall Stewart * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2874fd40c9SRandall Stewart * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 2974fd40c9SRandall Stewart * THE POSSIBILITY OF SUCH DAMAGE. 3074fd40c9SRandall Stewart */ 3174fd40c9SRandall Stewart 3274fd40c9SRandall Stewart #if 0 3374fd40c9SRandall Stewart #ifndef lint 3474fd40c9SRandall Stewart static char sccsid[] = "@(#)sctp.c 0.1 (Berkeley) 4/18/2007"; 3574fd40c9SRandall Stewart #endif /* not lint */ 3674fd40c9SRandall Stewart #endif 3774fd40c9SRandall Stewart 3874fd40c9SRandall Stewart #include <sys/cdefs.h> 3974fd40c9SRandall Stewart __FBSDID("$FreeBSD$"); 4074fd40c9SRandall Stewart 4174fd40c9SRandall Stewart #include <sys/param.h> 4274fd40c9SRandall Stewart #include <sys/queue.h> 4374fd40c9SRandall Stewart #include <sys/types.h> 4474fd40c9SRandall Stewart #include <sys/socket.h> 4574fd40c9SRandall Stewart #include <sys/socketvar.h> 4674fd40c9SRandall Stewart #include <sys/sysctl.h> 4774fd40c9SRandall Stewart #include <sys/protosw.h> 4874fd40c9SRandall Stewart 4974fd40c9SRandall Stewart #include <netinet/in.h> 5074fd40c9SRandall Stewart #include <netinet/sctp.h> 5174fd40c9SRandall Stewart #include <netinet/sctp_constants.h> 5274fd40c9SRandall Stewart #include <arpa/inet.h> 5374fd40c9SRandall Stewart 5474fd40c9SRandall Stewart #include <err.h> 5574fd40c9SRandall Stewart #include <errno.h> 56821df508SXin LI #include <libutil.h> 57821df508SXin LI #include <netdb.h> 5874fd40c9SRandall Stewart #include <stdint.h> 5974fd40c9SRandall Stewart #include <stdio.h> 6074fd40c9SRandall Stewart #include <stdlib.h> 6174fd40c9SRandall Stewart #include <string.h> 62821df508SXin LI #include <unistd.h> 6374fd40c9SRandall Stewart #include "netstat.h" 6474fd40c9SRandall Stewart 6574fd40c9SRandall Stewart #ifdef SCTP 6674fd40c9SRandall Stewart 6774fd40c9SRandall Stewart static void sctp_statesprint(uint32_t state); 6874fd40c9SRandall Stewart 6974fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_CLOSED 0x0 7074fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_BOUND 0x1 7174fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_LISTEN 0x2 7274fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_COOKIE_WAIT 0x3 7374fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_COOKIE_ECHOED 0x4 7474fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_ESTABLISHED 0x5 7574fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_SHUTDOWN_SENT 0x6 7674fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_SHUTDOWN_RECEIVED 0x7 7774fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT 0x8 7874fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_SHUTDOWN_PENDING 0x9 7974fd40c9SRandall Stewart 80*321ae07fSPhilippe Charnier const char *sctpstates[] = { 8174fd40c9SRandall Stewart "CLOSED", 8274fd40c9SRandall Stewart "BOUND", 8374fd40c9SRandall Stewart "LISTEN", 8474fd40c9SRandall Stewart "COOKIE_WAIT", 8574fd40c9SRandall Stewart "COOKIE_ECHOED", 8674fd40c9SRandall Stewart "ESTABLISHED", 8774fd40c9SRandall Stewart "SHUTDOWN_SENT", 8874fd40c9SRandall Stewart "SHUTDOWN_RECEIVED", 8974fd40c9SRandall Stewart "SHUTDOWN_ACK_SENT", 9074fd40c9SRandall Stewart "SHUTDOWN_PENDING" 9174fd40c9SRandall Stewart }; 9274fd40c9SRandall Stewart 9374fd40c9SRandall Stewart LIST_HEAD(xladdr_list, xladdr_entry) xladdr_head; 9474fd40c9SRandall Stewart struct xladdr_entry { 9574fd40c9SRandall Stewart struct xsctp_laddr *xladdr; 9674fd40c9SRandall Stewart LIST_ENTRY(xladdr_entry) xladdr_entries; 9774fd40c9SRandall Stewart }; 9874fd40c9SRandall Stewart 9974fd40c9SRandall Stewart LIST_HEAD(xraddr_list, xraddr_entry) xraddr_head; 10074fd40c9SRandall Stewart struct xraddr_entry { 10174fd40c9SRandall Stewart struct xsctp_raddr *xraddr; 10274fd40c9SRandall Stewart LIST_ENTRY(xraddr_entry) xraddr_entries; 10374fd40c9SRandall Stewart }; 10474fd40c9SRandall Stewart 1052e34c19bSMichael Tuexen /* 1062e34c19bSMichael Tuexen * Construct an Internet address representation. 1072e34c19bSMichael Tuexen * If numeric_addr has been supplied, give 1082e34c19bSMichael Tuexen * numeric value, otherwise try for symbolic name. 1092e34c19bSMichael Tuexen */ 1103dcc856bSMichael Tuexen #ifdef INET 1112e34c19bSMichael Tuexen static char * 1122e34c19bSMichael Tuexen inetname(struct in_addr *inp) 1132e34c19bSMichael Tuexen { 1142e34c19bSMichael Tuexen char *cp; 1152e34c19bSMichael Tuexen static char line[MAXHOSTNAMELEN]; 1162e34c19bSMichael Tuexen struct hostent *hp; 1172e34c19bSMichael Tuexen struct netent *np; 1182e34c19bSMichael Tuexen 1192e34c19bSMichael Tuexen cp = 0; 1202e34c19bSMichael Tuexen if (!numeric_addr && inp->s_addr != INADDR_ANY) { 1212e34c19bSMichael Tuexen int net = inet_netof(*inp); 1222e34c19bSMichael Tuexen int lna = inet_lnaof(*inp); 1232e34c19bSMichael Tuexen 1242e34c19bSMichael Tuexen if (lna == INADDR_ANY) { 1252e34c19bSMichael Tuexen np = getnetbyaddr(net, AF_INET); 1262e34c19bSMichael Tuexen if (np) 1272e34c19bSMichael Tuexen cp = np->n_name; 1282e34c19bSMichael Tuexen } 1292e34c19bSMichael Tuexen if (cp == 0) { 1302e34c19bSMichael Tuexen hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET); 1312e34c19bSMichael Tuexen if (hp) { 1322e34c19bSMichael Tuexen cp = hp->h_name; 1332e34c19bSMichael Tuexen trimdomain(cp, strlen(cp)); 1342e34c19bSMichael Tuexen } 1352e34c19bSMichael Tuexen } 1362e34c19bSMichael Tuexen } 1372e34c19bSMichael Tuexen if (inp->s_addr == INADDR_ANY) 1382e34c19bSMichael Tuexen strcpy(line, "*"); 1392e34c19bSMichael Tuexen else if (cp) { 1402e34c19bSMichael Tuexen strlcpy(line, cp, sizeof(line)); 1412e34c19bSMichael Tuexen } else { 1422e34c19bSMichael Tuexen inp->s_addr = ntohl(inp->s_addr); 1432e34c19bSMichael Tuexen #define C(x) ((u_int)((x) & 0xff)) 1442e34c19bSMichael Tuexen sprintf(line, "%u.%u.%u.%u", C(inp->s_addr >> 24), 1452e34c19bSMichael Tuexen C(inp->s_addr >> 16), C(inp->s_addr >> 8), C(inp->s_addr)); 1462e34c19bSMichael Tuexen inp->s_addr = htonl(inp->s_addr); 1472e34c19bSMichael Tuexen } 1482e34c19bSMichael Tuexen return (line); 1492e34c19bSMichael Tuexen } 1503dcc856bSMichael Tuexen #endif 1512e34c19bSMichael Tuexen 1522e34c19bSMichael Tuexen #ifdef INET6 1532e34c19bSMichael Tuexen static char ntop_buf[INET6_ADDRSTRLEN]; 1542e34c19bSMichael Tuexen 1552e34c19bSMichael Tuexen static char * 1562e34c19bSMichael Tuexen inet6name(struct in6_addr *in6p) 1572e34c19bSMichael Tuexen { 1582e34c19bSMichael Tuexen char *cp; 1592e34c19bSMichael Tuexen static char line[50]; 1602e34c19bSMichael Tuexen struct hostent *hp; 1612e34c19bSMichael Tuexen static char domain[MAXHOSTNAMELEN]; 1622e34c19bSMichael Tuexen static int first = 1; 1632e34c19bSMichael Tuexen 1642e34c19bSMichael Tuexen if (first && !numeric_addr) { 1652e34c19bSMichael Tuexen first = 0; 1662e34c19bSMichael Tuexen if (gethostname(domain, MAXHOSTNAMELEN) == 0 && 167b3608ae1SEd Schouten (cp = strchr(domain, '.'))) 1682e34c19bSMichael Tuexen (void) strcpy(domain, cp + 1); 1692e34c19bSMichael Tuexen else 1702e34c19bSMichael Tuexen domain[0] = 0; 1712e34c19bSMichael Tuexen } 1722e34c19bSMichael Tuexen cp = 0; 1732e34c19bSMichael Tuexen if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) { 1742e34c19bSMichael Tuexen hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6); 1752e34c19bSMichael Tuexen if (hp) { 176b3608ae1SEd Schouten if ((cp = strchr(hp->h_name, '.')) && 1772e34c19bSMichael Tuexen !strcmp(cp + 1, domain)) 1782e34c19bSMichael Tuexen *cp = 0; 1792e34c19bSMichael Tuexen cp = hp->h_name; 1802e34c19bSMichael Tuexen } 1812e34c19bSMichael Tuexen } 1822e34c19bSMichael Tuexen if (IN6_IS_ADDR_UNSPECIFIED(in6p)) 1832e34c19bSMichael Tuexen strcpy(line, "*"); 1842e34c19bSMichael Tuexen else if (cp) 1852e34c19bSMichael Tuexen strcpy(line, cp); 1862e34c19bSMichael Tuexen else 1872e34c19bSMichael Tuexen sprintf(line, "%s", 1882e34c19bSMichael Tuexen inet_ntop(AF_INET6, (void *)in6p, ntop_buf, 1892e34c19bSMichael Tuexen sizeof(ntop_buf))); 1902e34c19bSMichael Tuexen return (line); 1912e34c19bSMichael Tuexen } 1922e34c19bSMichael Tuexen #endif 1932e34c19bSMichael Tuexen 1942e34c19bSMichael Tuexen static void 1952e34c19bSMichael Tuexen sctp_print_address(union sctp_sockstore *address, int port, int num_port) 1962e34c19bSMichael Tuexen { 1972e34c19bSMichael Tuexen struct servent *sp = 0; 1982e34c19bSMichael Tuexen char line[80], *cp; 1992e34c19bSMichael Tuexen int width; 2002e34c19bSMichael Tuexen 2012e34c19bSMichael Tuexen switch (address->sa.sa_family) { 2023dcc856bSMichael Tuexen #ifdef INET 2032e34c19bSMichael Tuexen case AF_INET: 2042e34c19bSMichael Tuexen sprintf(line, "%.*s.", Wflag ? 39 : 16, inetname(&address->sin.sin_addr)); 2052e34c19bSMichael Tuexen break; 2063dcc856bSMichael Tuexen #endif 2072e34c19bSMichael Tuexen #ifdef INET6 2082e34c19bSMichael Tuexen case AF_INET6: 2092e34c19bSMichael Tuexen sprintf(line, "%.*s.", Wflag ? 39 : 16, inet6name(&address->sin6.sin6_addr)); 2102e34c19bSMichael Tuexen break; 2112e34c19bSMichael Tuexen #endif 2122e34c19bSMichael Tuexen default: 2132e34c19bSMichael Tuexen sprintf(line, "%.*s.", Wflag ? 39 : 16, ""); 2142e34c19bSMichael Tuexen break; 2152e34c19bSMichael Tuexen } 216b3608ae1SEd Schouten cp = strchr(line, '\0'); 2172e34c19bSMichael Tuexen if (!num_port && port) 2182e34c19bSMichael Tuexen sp = getservbyport((int)port, "sctp"); 2192e34c19bSMichael Tuexen if (sp || port == 0) 2202e34c19bSMichael Tuexen sprintf(cp, "%.15s ", sp ? sp->s_name : "*"); 2212e34c19bSMichael Tuexen else 2222e34c19bSMichael Tuexen sprintf(cp, "%d ", ntohs((u_short)port)); 2232e34c19bSMichael Tuexen width = Wflag ? 45 : 22; 2242e34c19bSMichael Tuexen printf("%-*.*s ", width, width, line); 2252e34c19bSMichael Tuexen } 2262e34c19bSMichael Tuexen 22774fd40c9SRandall Stewart static int 22874fd40c9SRandall Stewart sctp_skip_xinpcb_ifneed(char *buf, const size_t buflen, size_t *offset) 22974fd40c9SRandall Stewart { 23074fd40c9SRandall Stewart int exist_tcb = 0; 23174fd40c9SRandall Stewart struct xsctp_tcb *xstcb; 23274fd40c9SRandall Stewart struct xsctp_raddr *xraddr; 23374fd40c9SRandall Stewart struct xsctp_laddr *xladdr; 23474fd40c9SRandall Stewart 23574fd40c9SRandall Stewart while (*offset < buflen) { 23674fd40c9SRandall Stewart xladdr = (struct xsctp_laddr *)(buf + *offset); 23774fd40c9SRandall Stewart *offset += sizeof(struct xsctp_laddr); 23874fd40c9SRandall Stewart if (xladdr->last == 1) 23974fd40c9SRandall Stewart break; 24074fd40c9SRandall Stewart } 24174fd40c9SRandall Stewart 24274fd40c9SRandall Stewart while (*offset < buflen) { 24374fd40c9SRandall Stewart xstcb = (struct xsctp_tcb *)(buf + *offset); 24474fd40c9SRandall Stewart *offset += sizeof(struct xsctp_tcb); 24574fd40c9SRandall Stewart if (xstcb->last == 1) 24674fd40c9SRandall Stewart break; 24774fd40c9SRandall Stewart 24874fd40c9SRandall Stewart exist_tcb = 1; 24974fd40c9SRandall Stewart 25074fd40c9SRandall Stewart while (*offset < buflen) { 25174fd40c9SRandall Stewart xladdr = (struct xsctp_laddr *)(buf + *offset); 25274fd40c9SRandall Stewart *offset += sizeof(struct xsctp_laddr); 25374fd40c9SRandall Stewart if (xladdr->last == 1) 25474fd40c9SRandall Stewart break; 25574fd40c9SRandall Stewart } 25674fd40c9SRandall Stewart 25774fd40c9SRandall Stewart while (*offset < buflen) { 25874fd40c9SRandall Stewart xraddr = (struct xsctp_raddr *)(buf + *offset); 25974fd40c9SRandall Stewart *offset += sizeof(struct xsctp_raddr); 26074fd40c9SRandall Stewart if (xraddr->last == 1) 26174fd40c9SRandall Stewart break; 26274fd40c9SRandall Stewart } 26374fd40c9SRandall Stewart } 26474fd40c9SRandall Stewart 26574fd40c9SRandall Stewart /* 26674fd40c9SRandall Stewart * If Lflag is set, we don't care about the return value. 26774fd40c9SRandall Stewart */ 26874fd40c9SRandall Stewart if (Lflag) 26974fd40c9SRandall Stewart return 0; 27074fd40c9SRandall Stewart 27174fd40c9SRandall Stewart return exist_tcb; 27274fd40c9SRandall Stewart } 27374fd40c9SRandall Stewart 27474fd40c9SRandall Stewart static void 2752e34c19bSMichael Tuexen sctp_process_tcb(struct xsctp_tcb *xstcb, 27674fd40c9SRandall Stewart char *buf, const size_t buflen, size_t *offset, int *indent) 27774fd40c9SRandall Stewart { 27874fd40c9SRandall Stewart int i, xl_total = 0, xr_total = 0, x_max; 27974fd40c9SRandall Stewart struct xsctp_raddr *xraddr; 28074fd40c9SRandall Stewart struct xsctp_laddr *xladdr; 28174fd40c9SRandall Stewart struct xladdr_entry *prev_xl = NULL, *xl = NULL, *xl_tmp; 28274fd40c9SRandall Stewart struct xraddr_entry *prev_xr = NULL, *xr = NULL, *xr_tmp; 28374fd40c9SRandall Stewart 28474fd40c9SRandall Stewart LIST_INIT(&xladdr_head); 28574fd40c9SRandall Stewart LIST_INIT(&xraddr_head); 28674fd40c9SRandall Stewart 28774fd40c9SRandall Stewart /* 28874fd40c9SRandall Stewart * Make `struct xladdr_list' list and `struct xraddr_list' list 28974fd40c9SRandall Stewart * to handle the address flexibly. 29074fd40c9SRandall Stewart */ 29174fd40c9SRandall Stewart while (*offset < buflen) { 29274fd40c9SRandall Stewart xladdr = (struct xsctp_laddr *)(buf + *offset); 29374fd40c9SRandall Stewart *offset += sizeof(struct xsctp_laddr); 29474fd40c9SRandall Stewart if (xladdr->last == 1) 29574fd40c9SRandall Stewart break; 29674fd40c9SRandall Stewart 29774fd40c9SRandall Stewart prev_xl = xl; 29874fd40c9SRandall Stewart xl = malloc(sizeof(struct xladdr_entry)); 29974fd40c9SRandall Stewart if (xl == NULL) { 30074fd40c9SRandall Stewart warnx("malloc %lu bytes", 30174fd40c9SRandall Stewart (u_long)sizeof(struct xladdr_entry)); 30274fd40c9SRandall Stewart goto out; 30374fd40c9SRandall Stewart } 30474fd40c9SRandall Stewart xl->xladdr = xladdr; 30574fd40c9SRandall Stewart if (prev_xl == NULL) 30674fd40c9SRandall Stewart LIST_INSERT_HEAD(&xladdr_head, xl, xladdr_entries); 30774fd40c9SRandall Stewart else 30874fd40c9SRandall Stewart LIST_INSERT_AFTER(prev_xl, xl, xladdr_entries); 30974fd40c9SRandall Stewart xl_total++; 31074fd40c9SRandall Stewart } 31174fd40c9SRandall Stewart 31274fd40c9SRandall Stewart while (*offset < buflen) { 31374fd40c9SRandall Stewart xraddr = (struct xsctp_raddr *)(buf + *offset); 31474fd40c9SRandall Stewart *offset += sizeof(struct xsctp_raddr); 31574fd40c9SRandall Stewart if (xraddr->last == 1) 31674fd40c9SRandall Stewart break; 31774fd40c9SRandall Stewart 31874fd40c9SRandall Stewart prev_xr = xr; 31974fd40c9SRandall Stewart xr = malloc(sizeof(struct xraddr_entry)); 32074fd40c9SRandall Stewart if (xr == NULL) { 32174fd40c9SRandall Stewart warnx("malloc %lu bytes", 32274fd40c9SRandall Stewart (u_long)sizeof(struct xraddr_entry)); 32374fd40c9SRandall Stewart goto out; 32474fd40c9SRandall Stewart } 32574fd40c9SRandall Stewart xr->xraddr = xraddr; 32674fd40c9SRandall Stewart if (prev_xr == NULL) 32774fd40c9SRandall Stewart LIST_INSERT_HEAD(&xraddr_head, xr, xraddr_entries); 32874fd40c9SRandall Stewart else 32974fd40c9SRandall Stewart LIST_INSERT_AFTER(prev_xr, xr, xraddr_entries); 33074fd40c9SRandall Stewart xr_total++; 33174fd40c9SRandall Stewart } 33274fd40c9SRandall Stewart 33374fd40c9SRandall Stewart /* 33474fd40c9SRandall Stewart * Let's print the address infos. 33574fd40c9SRandall Stewart */ 33674fd40c9SRandall Stewart xl = LIST_FIRST(&xladdr_head); 33774fd40c9SRandall Stewart xr = LIST_FIRST(&xraddr_head); 33874fd40c9SRandall Stewart x_max = (xl_total > xr_total) ? xl_total : xr_total; 33974fd40c9SRandall Stewart for (i = 0; i < x_max; i++) { 34074fd40c9SRandall Stewart if (((*indent == 0) && i > 0) || *indent > 0) 3412e34c19bSMichael Tuexen printf("%-12s ", " "); 34274fd40c9SRandall Stewart 34374fd40c9SRandall Stewart if (xl != NULL) { 3442e34c19bSMichael Tuexen sctp_print_address(&(xl->xladdr->address), 3452e34c19bSMichael Tuexen htons(xstcb->local_port), numeric_port); 3462e34c19bSMichael Tuexen } else { 3472e34c19bSMichael Tuexen if (Wflag) { 3482e34c19bSMichael Tuexen printf("%-45s ", " "); 3492e34c19bSMichael Tuexen } else { 3502e34c19bSMichael Tuexen printf("%-22s ", " "); 35174fd40c9SRandall Stewart } 35274fd40c9SRandall Stewart } 35374fd40c9SRandall Stewart 35474fd40c9SRandall Stewart if (xr != NULL && !Lflag) { 3552e34c19bSMichael Tuexen sctp_print_address(&(xr->xraddr->address), 3562e34c19bSMichael Tuexen htons(xstcb->remote_port), numeric_port); 35774fd40c9SRandall Stewart } 35874fd40c9SRandall Stewart 35974fd40c9SRandall Stewart if (xl != NULL) 36074fd40c9SRandall Stewart xl = LIST_NEXT(xl, xladdr_entries); 36174fd40c9SRandall Stewart if (xr != NULL) 36274fd40c9SRandall Stewart xr = LIST_NEXT(xr, xraddr_entries); 36374fd40c9SRandall Stewart 36474fd40c9SRandall Stewart if (i == 0 && !Lflag) 36574fd40c9SRandall Stewart sctp_statesprint(xstcb->state); 36674fd40c9SRandall Stewart 36774fd40c9SRandall Stewart if (i < x_max) 36874fd40c9SRandall Stewart putchar('\n'); 36974fd40c9SRandall Stewart } 37074fd40c9SRandall Stewart 37174fd40c9SRandall Stewart out: 37274fd40c9SRandall Stewart /* 37374fd40c9SRandall Stewart * Free the list which be used to handle the address. 37474fd40c9SRandall Stewart */ 37574fd40c9SRandall Stewart xl = LIST_FIRST(&xladdr_head); 37674fd40c9SRandall Stewart while (xl != NULL) { 37774fd40c9SRandall Stewart xl_tmp = LIST_NEXT(xl, xladdr_entries); 37874fd40c9SRandall Stewart free(xl); 37974fd40c9SRandall Stewart xl = xl_tmp; 38074fd40c9SRandall Stewart } 38174fd40c9SRandall Stewart 38274fd40c9SRandall Stewart xr = LIST_FIRST(&xraddr_head); 38374fd40c9SRandall Stewart while (xr != NULL) { 38474fd40c9SRandall Stewart xr_tmp = LIST_NEXT(xr, xraddr_entries); 38574fd40c9SRandall Stewart free(xr); 38674fd40c9SRandall Stewart xr = xr_tmp; 38774fd40c9SRandall Stewart } 38874fd40c9SRandall Stewart } 38974fd40c9SRandall Stewart 39074fd40c9SRandall Stewart static void 3912e34c19bSMichael Tuexen sctp_process_inpcb(struct xsctp_inpcb *xinpcb, 39274fd40c9SRandall Stewart char *buf, const size_t buflen, size_t *offset) 39374fd40c9SRandall Stewart { 3942e34c19bSMichael Tuexen int indent = 0, xladdr_total = 0, is_listening = 0; 39574fd40c9SRandall Stewart static int first = 1; 396*321ae07fSPhilippe Charnier const char *tname, *pname; 39774fd40c9SRandall Stewart struct xsctp_tcb *xstcb; 39874fd40c9SRandall Stewart struct xsctp_laddr *xladdr; 3992e34c19bSMichael Tuexen size_t offset_laddr; 4002e34c19bSMichael Tuexen int process_closed; 40174fd40c9SRandall Stewart 4022e34c19bSMichael Tuexen if (xinpcb->maxqlen > 0) 40374fd40c9SRandall Stewart is_listening = 1; 40474fd40c9SRandall Stewart 40574fd40c9SRandall Stewart if (first) { 40674fd40c9SRandall Stewart if (!Lflag) { 40774fd40c9SRandall Stewart printf("Active SCTP associations"); 40874fd40c9SRandall Stewart if (aflag) 40974fd40c9SRandall Stewart printf(" (including servers)"); 41074fd40c9SRandall Stewart } else 41174fd40c9SRandall Stewart printf("Current listen queue sizes (qlen/maxqlen)"); 41274fd40c9SRandall Stewart putchar('\n'); 41374fd40c9SRandall Stewart if (Lflag) 4142e34c19bSMichael Tuexen printf("%-6.6s %-5.5s %-8.8s %-22.22s\n", 41574fd40c9SRandall Stewart "Proto", "Type", "Listen", "Local Address"); 41674fd40c9SRandall Stewart else 4172e34c19bSMichael Tuexen if (Wflag) 4182e34c19bSMichael Tuexen printf("%-6.6s %-5.5s %-45.45s %-45.45s %s\n", 4192e34c19bSMichael Tuexen "Proto", "Type", 4202e34c19bSMichael Tuexen "Local Address", "Foreign Address", 4212e34c19bSMichael Tuexen "(state)"); 4222e34c19bSMichael Tuexen else 4232e34c19bSMichael Tuexen printf("%-6.6s %-5.5s %-22.22s %-22.22s %s\n", 42474fd40c9SRandall Stewart "Proto", "Type", 42574fd40c9SRandall Stewart "Local Address", "Foreign Address", 42674fd40c9SRandall Stewart "(state)"); 42774fd40c9SRandall Stewart first = 0; 42874fd40c9SRandall Stewart } 4292e34c19bSMichael Tuexen xladdr = (struct xsctp_laddr *)(buf + *offset); 4302e34c19bSMichael Tuexen if (Lflag && !is_listening) { 43193f8854cSDimitry Andric sctp_skip_xinpcb_ifneed(buf, buflen, offset); 43274fd40c9SRandall Stewart return; 43374fd40c9SRandall Stewart } 43474fd40c9SRandall Stewart 4352e34c19bSMichael Tuexen if (xinpcb->flags & SCTP_PCB_FLAGS_BOUND_V6) { 4362e34c19bSMichael Tuexen /* Can't distinguish between sctp46 and sctp6 */ 4372e34c19bSMichael Tuexen pname = "sctp46"; 4382e34c19bSMichael Tuexen } else { 4392e34c19bSMichael Tuexen pname = "sctp4"; 4402e34c19bSMichael Tuexen } 44174fd40c9SRandall Stewart 44274fd40c9SRandall Stewart if (xinpcb->flags & SCTP_PCB_FLAGS_TCPTYPE) 44374fd40c9SRandall Stewart tname = "1to1"; 44474fd40c9SRandall Stewart else if (xinpcb->flags & SCTP_PCB_FLAGS_UDPTYPE) 44574fd40c9SRandall Stewart tname = "1toN"; 44674fd40c9SRandall Stewart else 4472e34c19bSMichael Tuexen tname = "????"; 44874fd40c9SRandall Stewart 44974fd40c9SRandall Stewart if (Lflag) { 45074fd40c9SRandall Stewart char buf1[9]; 45174fd40c9SRandall Stewart 45274fd40c9SRandall Stewart snprintf(buf1, 9, "%hu/%hu", xinpcb->qlen, xinpcb->maxqlen); 4532e34c19bSMichael Tuexen printf("%-6.6s %-5.5s ", pname, tname); 45474fd40c9SRandall Stewart printf("%-8.8s ", buf1); 45574fd40c9SRandall Stewart } 4562e34c19bSMichael Tuexen 4572e34c19bSMichael Tuexen offset_laddr = *offset; 4582e34c19bSMichael Tuexen process_closed = 0; 4592e34c19bSMichael Tuexen retry: 46074fd40c9SRandall Stewart while (*offset < buflen) { 46174fd40c9SRandall Stewart xladdr = (struct xsctp_laddr *)(buf + *offset); 46274fd40c9SRandall Stewart *offset += sizeof(struct xsctp_laddr); 4632e34c19bSMichael Tuexen if (xladdr->last) { 4642e34c19bSMichael Tuexen if (aflag && !Lflag && (xladdr_total == 0) && process_closed) { 4652e34c19bSMichael Tuexen printf("%-6.6s %-5.5s ", pname, tname); 4662e34c19bSMichael Tuexen if (Wflag) { 4672e34c19bSMichael Tuexen printf("%-91.91s CLOSED", " "); 4682e34c19bSMichael Tuexen } else { 4692e34c19bSMichael Tuexen printf("%-45.45s CLOSED", " "); 4702e34c19bSMichael Tuexen } 4712e34c19bSMichael Tuexen } 4722e34c19bSMichael Tuexen if (process_closed || is_listening) { 4732e34c19bSMichael Tuexen putchar('\n'); 4742e34c19bSMichael Tuexen } 47574fd40c9SRandall Stewart break; 4762e34c19bSMichael Tuexen } 47774fd40c9SRandall Stewart 4782e34c19bSMichael Tuexen if (!Lflag && !is_listening && !process_closed) 47974fd40c9SRandall Stewart continue; 48074fd40c9SRandall Stewart 4812e34c19bSMichael Tuexen if (xladdr_total == 0) { 4822e34c19bSMichael Tuexen printf("%-6.6s %-5.5s ", pname, tname); 4832e34c19bSMichael Tuexen } else { 48474fd40c9SRandall Stewart putchar('\n'); 48574fd40c9SRandall Stewart printf((Lflag) ? 4862e34c19bSMichael Tuexen "%-21.21s " : "%-12.12s ", " "); 48774fd40c9SRandall Stewart } 4882e34c19bSMichael Tuexen sctp_print_address(&(xladdr->address), 4892e34c19bSMichael Tuexen htons(xinpcb->local_port), numeric_port); 4902e34c19bSMichael Tuexen if (aflag && !Lflag && xladdr_total == 0) { 4912e34c19bSMichael Tuexen if (Wflag) { 4922e34c19bSMichael Tuexen if (process_closed) { 4932e34c19bSMichael Tuexen printf("%-45.45s CLOSED", " "); 4942e34c19bSMichael Tuexen } else { 4952e34c19bSMichael Tuexen printf("%-45.45s LISTEN", " "); 4962e34c19bSMichael Tuexen } 4972e34c19bSMichael Tuexen } else { 4982e34c19bSMichael Tuexen if (process_closed) { 4992e34c19bSMichael Tuexen printf("%-22.22s CLOSED", " "); 5002e34c19bSMichael Tuexen } else { 50174fd40c9SRandall Stewart printf("%-22.22s LISTEN", " "); 5022e34c19bSMichael Tuexen } 5032e34c19bSMichael Tuexen } 5042e34c19bSMichael Tuexen } 50574fd40c9SRandall Stewart xladdr_total++; 50674fd40c9SRandall Stewart } 50774fd40c9SRandall Stewart 50874fd40c9SRandall Stewart xstcb = (struct xsctp_tcb *)(buf + *offset); 50974fd40c9SRandall Stewart *offset += sizeof(struct xsctp_tcb); 5102e34c19bSMichael Tuexen if (aflag && (xladdr_total == 0) && xstcb->last && !process_closed) { 5112e34c19bSMichael Tuexen process_closed = 1; 5122e34c19bSMichael Tuexen *offset = offset_laddr; 5132e34c19bSMichael Tuexen goto retry; 5142e34c19bSMichael Tuexen } 51574fd40c9SRandall Stewart while (xstcb->last == 0 && *offset < buflen) { 5162e34c19bSMichael Tuexen printf("%-6.6s %-5.5s ", pname, tname); 5172e34c19bSMichael Tuexen sctp_process_tcb(xstcb, buf, buflen, offset, &indent); 51874fd40c9SRandall Stewart indent++; 51974fd40c9SRandall Stewart xstcb = (struct xsctp_tcb *)(buf + *offset); 52074fd40c9SRandall Stewart *offset += sizeof(struct xsctp_tcb); 52174fd40c9SRandall Stewart } 52274fd40c9SRandall Stewart } 52374fd40c9SRandall Stewart 52474fd40c9SRandall Stewart /* 52574fd40c9SRandall Stewart * Print a summary of SCTP connections related to an Internet 52674fd40c9SRandall Stewart * protocol. 52774fd40c9SRandall Stewart */ 52874fd40c9SRandall Stewart void 529feda1a43SJohn Baldwin sctp_protopr(u_long off __unused, 530*321ae07fSPhilippe Charnier const char *name __unused, int af1 __unused, int proto) 53174fd40c9SRandall Stewart { 53274fd40c9SRandall Stewart char *buf; 53374fd40c9SRandall Stewart const char *mibvar = "net.inet.sctp.assoclist"; 53404b764d8SXin LI size_t offset = 0; 53574fd40c9SRandall Stewart size_t len = 0; 53674fd40c9SRandall Stewart struct xsctp_inpcb *xinpcb; 53774fd40c9SRandall Stewart 53874fd40c9SRandall Stewart if (proto != IPPROTO_SCTP) 53974fd40c9SRandall Stewart return; 54074fd40c9SRandall Stewart 54174fd40c9SRandall Stewart if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) { 54274fd40c9SRandall Stewart if (errno != ENOENT) 54374fd40c9SRandall Stewart warn("sysctl: %s", mibvar); 54474fd40c9SRandall Stewart return; 54574fd40c9SRandall Stewart } 54674fd40c9SRandall Stewart if ((buf = malloc(len)) == 0) { 54774fd40c9SRandall Stewart warnx("malloc %lu bytes", (u_long)len); 54874fd40c9SRandall Stewart return; 54974fd40c9SRandall Stewart } 55074fd40c9SRandall Stewart if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) { 55174fd40c9SRandall Stewart warn("sysctl: %s", mibvar); 55274fd40c9SRandall Stewart free(buf); 55374fd40c9SRandall Stewart return; 55474fd40c9SRandall Stewart } 55574fd40c9SRandall Stewart 55674fd40c9SRandall Stewart xinpcb = (struct xsctp_inpcb *)(buf + offset); 55774fd40c9SRandall Stewart offset += sizeof(struct xsctp_inpcb); 55874fd40c9SRandall Stewart while (xinpcb->last == 0 && offset < len) { 5592e34c19bSMichael Tuexen sctp_process_inpcb(xinpcb, buf, (const size_t)len, 56074fd40c9SRandall Stewart &offset); 56174fd40c9SRandall Stewart 56274fd40c9SRandall Stewart xinpcb = (struct xsctp_inpcb *)(buf + offset); 56374fd40c9SRandall Stewart offset += sizeof(struct xsctp_inpcb); 56474fd40c9SRandall Stewart } 56574fd40c9SRandall Stewart 56674fd40c9SRandall Stewart free(buf); 56774fd40c9SRandall Stewart } 56874fd40c9SRandall Stewart 56974fd40c9SRandall Stewart static void 57074fd40c9SRandall Stewart sctp_statesprint(uint32_t state) 57174fd40c9SRandall Stewart { 57274fd40c9SRandall Stewart int idx; 57374fd40c9SRandall Stewart 57474fd40c9SRandall Stewart switch (state) { 57574fd40c9SRandall Stewart case SCTP_STATE_COOKIE_WAIT: 57674fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_COOKIE_WAIT; 57774fd40c9SRandall Stewart break; 57874fd40c9SRandall Stewart case SCTP_STATE_COOKIE_ECHOED: 57974fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_COOKIE_ECHOED; 58074fd40c9SRandall Stewart break; 58174fd40c9SRandall Stewart case SCTP_STATE_OPEN: 58274fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_ESTABLISHED; 58374fd40c9SRandall Stewart break; 58474fd40c9SRandall Stewart case SCTP_STATE_SHUTDOWN_SENT: 58574fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_SHUTDOWN_SENT; 58674fd40c9SRandall Stewart break; 58774fd40c9SRandall Stewart case SCTP_STATE_SHUTDOWN_RECEIVED: 58874fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_SHUTDOWN_RECEIVED; 58974fd40c9SRandall Stewart break; 59074fd40c9SRandall Stewart case SCTP_STATE_SHUTDOWN_ACK_SENT: 59174fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT; 59274fd40c9SRandall Stewart break; 59374fd40c9SRandall Stewart case SCTP_STATE_SHUTDOWN_PENDING: 59474fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_SHUTDOWN_PENDING; 59574fd40c9SRandall Stewart break; 59674fd40c9SRandall Stewart default: 59774fd40c9SRandall Stewart printf("UNKNOWN 0x%08x", state); 59874fd40c9SRandall Stewart return; 59974fd40c9SRandall Stewart } 60074fd40c9SRandall Stewart 60174fd40c9SRandall Stewart printf("%s", sctpstates[idx]); 60274fd40c9SRandall Stewart } 60374fd40c9SRandall Stewart 60474fd40c9SRandall Stewart /* 60574fd40c9SRandall Stewart * Dump SCTP statistics structure. 60674fd40c9SRandall Stewart */ 60774fd40c9SRandall Stewart void 608feda1a43SJohn Baldwin sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) 60974fd40c9SRandall Stewart { 61074fd40c9SRandall Stewart struct sctpstat sctpstat, zerostat; 61174fd40c9SRandall Stewart size_t len = sizeof(sctpstat); 61274fd40c9SRandall Stewart 613feda1a43SJohn Baldwin if (live) { 61474fd40c9SRandall Stewart if (zflag) 61574fd40c9SRandall Stewart memset(&zerostat, 0, len); 61674fd40c9SRandall Stewart if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len, 61774fd40c9SRandall Stewart zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { 61823a0e422SMichael Tuexen if (errno != ENOENT) 61974fd40c9SRandall Stewart warn("sysctl: net.inet.sctp.stats"); 62074fd40c9SRandall Stewart return; 62174fd40c9SRandall Stewart } 622feda1a43SJohn Baldwin } else 623feda1a43SJohn Baldwin kread(off, &sctpstat, len); 62474fd40c9SRandall Stewart 62574fd40c9SRandall Stewart printf ("%s:\n", name); 62674fd40c9SRandall Stewart 62774fd40c9SRandall Stewart #define p(f, m) if (sctpstat.f || sflag <= 1) \ 628a3a60860SRandall Stewart printf(m, (uintmax_t)sctpstat.f, plural(sctpstat.f)) 62974fd40c9SRandall Stewart #define p1a(f, m) if (sctpstat.f || sflag <= 1) \ 630a3a60860SRandall Stewart printf(m, (uintmax_t)sctpstat.f) 63174fd40c9SRandall Stewart 63274fd40c9SRandall Stewart /* 63374fd40c9SRandall Stewart * input statistics 63474fd40c9SRandall Stewart */ 635a3a60860SRandall Stewart p(sctps_recvpackets, "\t%ju input packet%s\n"); 636a3a60860SRandall Stewart p(sctps_recvdatagrams, "\t\t%ju datagram%s\n"); 637a3a60860SRandall Stewart p(sctps_recvpktwithdata, "\t\t%ju packet%s that had data\n"); 638a3a60860SRandall Stewart p(sctps_recvsacks, "\t\t%ju input SACK chunk%s\n"); 639a3a60860SRandall Stewart p(sctps_recvdata, "\t\t%ju input DATA chunk%s\n"); 640a3a60860SRandall Stewart p(sctps_recvdupdata, "\t\t%ju duplicate DATA chunk%s\n"); 641a3a60860SRandall Stewart p(sctps_recvheartbeat, "\t\t%ju input HB chunk%s\n"); 642a3a60860SRandall Stewart p(sctps_recvheartbeatack, "\t\t%ju HB-ACK chunk%s\n"); 643a3a60860SRandall Stewart p(sctps_recvecne, "\t\t%ju input ECNE chunk%s\n"); 644a3a60860SRandall Stewart p(sctps_recvauth, "\t\t%ju input AUTH chunk%s\n"); 645a3a60860SRandall Stewart p(sctps_recvauthmissing, "\t\t%ju chunk%s missing AUTH\n"); 646a3a60860SRandall Stewart p(sctps_recvivalhmacid, "\t\t%ju invalid HMAC id%s received\n"); 647e5221e8bSRandall Stewart p(sctps_recvivalkeyid, "\t\t%ju invalid secret id%s received\n"); 648a3a60860SRandall Stewart p1a(sctps_recvauthfailed, "\t\t%ju auth failed\n"); 649e5221e8bSRandall Stewart p1a(sctps_recvexpress, "\t\t%ju fast path receives all one chunk\n"); 650e5221e8bSRandall Stewart p1a(sctps_recvexpressm, "\t\t%ju fast path multi-part data\n"); 65174fd40c9SRandall Stewart 65274fd40c9SRandall Stewart /* 65374fd40c9SRandall Stewart * output statistics 65474fd40c9SRandall Stewart */ 655a3a60860SRandall Stewart p(sctps_sendpackets, "\t%ju output packet%s\n"); 656a3a60860SRandall Stewart p(sctps_sendsacks, "\t\t%ju output SACK%s\n"); 657a3a60860SRandall Stewart p(sctps_senddata, "\t\t%ju output DATA chunk%s\n"); 658e5221e8bSRandall Stewart p(sctps_sendretransdata, "\t\t%ju retransmitted DATA chunk%s\n"); 659e5221e8bSRandall Stewart p(sctps_sendfastretrans, "\t\t%ju fast retransmitted DATA chunk%s\n"); 660a3a60860SRandall Stewart p(sctps_sendmultfastretrans, "\t\t%ju FR'%s that happened more " 6614db051c8SRandall Stewart "than once to same chunk\n"); 662e17c4d4eSRebecca Cran p(sctps_sendheartbeat, "\t\t%ju output HB chunk%s\n"); 663a3a60860SRandall Stewart p(sctps_sendecne, "\t\t%ju output ECNE chunk%s\n"); 664a3a60860SRandall Stewart p(sctps_sendauth, "\t\t%ju output AUTH chunk%s\n"); 665a3a60860SRandall Stewart p1a(sctps_senderrors, "\t\t%ju ip_output error counter\n"); 66674fd40c9SRandall Stewart 66774fd40c9SRandall Stewart /* 66874fd40c9SRandall Stewart * PCKDROPREP statistics 66974fd40c9SRandall Stewart */ 670b8a1761eSRandall Stewart printf("\tPacket drop statistics:\n"); 671a3a60860SRandall Stewart p1a(sctps_pdrpfmbox, "\t\t%ju from middle box\n"); 672e5221e8bSRandall Stewart p1a(sctps_pdrpfehos, "\t\t%ju from end host\n"); 673a3a60860SRandall Stewart p1a(sctps_pdrpmbda, "\t\t%ju with data\n"); 674a3a60860SRandall Stewart p1a(sctps_pdrpmbct, "\t\t%ju non-data, non-endhost\n"); 675e5221e8bSRandall Stewart p1a(sctps_pdrpbwrpt, "\t\t%ju non-endhost, bandwidth rep only\n"); 676a3a60860SRandall Stewart p1a(sctps_pdrpcrupt, "\t\t%ju not enough for chunk header\n"); 677a3a60860SRandall Stewart p1a(sctps_pdrpnedat, "\t\t%ju not enough data to confirm\n"); 678e5221e8bSRandall Stewart p1a(sctps_pdrppdbrk, "\t\t%ju where process_chunk_drop said break\n"); 679a3a60860SRandall Stewart p1a(sctps_pdrptsnnf, "\t\t%ju failed to find TSN\n"); 680e5221e8bSRandall Stewart p1a(sctps_pdrpdnfnd, "\t\t%ju attempt reverse TSN lookup\n"); 681e5221e8bSRandall Stewart p1a(sctps_pdrpdiwnp, "\t\t%ju e-host confirms zero-rwnd\n"); 682e5221e8bSRandall Stewart p1a(sctps_pdrpdizrw, "\t\t%ju midbox confirms no space\n"); 683a3a60860SRandall Stewart p1a(sctps_pdrpbadd, "\t\t%ju data did not match TSN\n"); 684a3a60860SRandall Stewart p(sctps_pdrpmark, "\t\t%ju TSN'%s marked for Fast Retran\n"); 68574fd40c9SRandall Stewart 68674fd40c9SRandall Stewart /* 68774fd40c9SRandall Stewart * Timeouts 68874fd40c9SRandall Stewart */ 689b8a1761eSRandall Stewart printf("\tTimeouts:\n"); 690a3a60860SRandall Stewart p(sctps_timoiterator, "\t\t%ju iterator timer%s fired\n"); 691a3a60860SRandall Stewart p(sctps_timodata, "\t\t%ju T3 data time out%s\n"); 692a3a60860SRandall Stewart p(sctps_timowindowprobe, "\t\t%ju window probe (T3) timer%s fired\n"); 693a3a60860SRandall Stewart p(sctps_timoinit, "\t\t%ju INIT timer%s fired\n"); 694e5221e8bSRandall Stewart p(sctps_timosack, "\t\t%ju sack timer%s fired\n"); 695e5221e8bSRandall Stewart p(sctps_timoshutdown, "\t\t%ju shutdown timer%s fired\n"); 696a3a60860SRandall Stewart p(sctps_timoheartbeat, "\t\t%ju heartbeat timer%s fired\n"); 697a3a60860SRandall Stewart p1a(sctps_timocookie, "\t\t%ju a cookie timeout fired\n"); 698a3a60860SRandall Stewart p1a(sctps_timosecret, "\t\t%ju an endpoint changed its cookie" 699b8a1761eSRandall Stewart "secret\n"); 700a3a60860SRandall Stewart p(sctps_timopathmtu, "\t\t%ju PMTU timer%s fired\n"); 701e5221e8bSRandall Stewart p(sctps_timoshutdownack, "\t\t%ju shutdown ack timer%s fired\n"); 702e5221e8bSRandall Stewart p(sctps_timoshutdownguard, "\t\t%ju shutdown guard timer%s fired\n"); 703e5221e8bSRandall Stewart p(sctps_timostrmrst, "\t\t%ju stream reset timer%s fired\n"); 704a3a60860SRandall Stewart p(sctps_timoearlyfr, "\t\t%ju early FR timer%s fired\n"); 705a3a60860SRandall Stewart p1a(sctps_timoasconf, "\t\t%ju an asconf timer fired\n"); 706a3a60860SRandall Stewart p1a(sctps_timoautoclose, "\t\t%ju auto close timer fired\n"); 707e5221e8bSRandall Stewart p(sctps_timoassockill, "\t\t%ju asoc free timer%s expired\n"); 708a3a60860SRandall Stewart p(sctps_timoinpkill, "\t\t%ju inp free timer%s expired\n"); 70974fd40c9SRandall Stewart 71074fd40c9SRandall Stewart #if 0 71174fd40c9SRandall Stewart /* 71274fd40c9SRandall Stewart * Early fast retransmission counters 71374fd40c9SRandall Stewart */ 714e5221e8bSRandall Stewart p(sctps_earlyfrstart, "\t%ju TODO:sctps_earlyfrstart\n"); 715e5221e8bSRandall Stewart p(sctps_earlyfrstop, "\t%ju TODO:sctps_earlyfrstop\n"); 716e5221e8bSRandall Stewart p(sctps_earlyfrmrkretrans, "\t%ju TODO:sctps_earlyfrmrkretrans\n"); 717e5221e8bSRandall Stewart p(sctps_earlyfrstpout, "\t%ju TODO:sctps_earlyfrstpout\n"); 718e5221e8bSRandall Stewart p(sctps_earlyfrstpidsck1, "\t%ju TODO:sctps_earlyfrstpidsck1\n"); 719e5221e8bSRandall Stewart p(sctps_earlyfrstpidsck2, "\t%ju TODO:sctps_earlyfrstpidsck2\n"); 720e5221e8bSRandall Stewart p(sctps_earlyfrstpidsck3, "\t%ju TODO:sctps_earlyfrstpidsck3\n"); 721e5221e8bSRandall Stewart p(sctps_earlyfrstpidsck4, "\t%ju TODO:sctps_earlyfrstpidsck4\n"); 722e5221e8bSRandall Stewart p(sctps_earlyfrstrid, "\t%ju TODO:sctps_earlyfrstrid\n"); 723e5221e8bSRandall Stewart p(sctps_earlyfrstrout, "\t%ju TODO:sctps_earlyfrstrout\n"); 724e5221e8bSRandall Stewart p(sctps_earlyfrstrtmr, "\t%ju TODO:sctps_earlyfrstrtmr\n"); 72574fd40c9SRandall Stewart #endif 72674fd40c9SRandall Stewart 72774fd40c9SRandall Stewart /* 72874fd40c9SRandall Stewart * Others 72974fd40c9SRandall Stewart */ 730e5221e8bSRandall Stewart p1a(sctps_hdrops, "\t%ju packet shorter than header\n"); 731e5221e8bSRandall Stewart p1a(sctps_badsum, "\t%ju checksum error\n"); 732a3a60860SRandall Stewart p1a(sctps_noport, "\t%ju no endpoint for port\n"); 733a3a60860SRandall Stewart p1a(sctps_badvtag, "\t%ju bad v-tag\n"); 734a3a60860SRandall Stewart p1a(sctps_badsid, "\t%ju bad SID\n"); 735a3a60860SRandall Stewart p1a(sctps_nomem, "\t%ju no memory\n"); 736a3a60860SRandall Stewart p1a(sctps_fastretransinrtt, "\t%ju number of multiple FR in a RTT " 73774fd40c9SRandall Stewart "window\n"); 73874fd40c9SRandall Stewart #if 0 739e5221e8bSRandall Stewart p(sctps_markedretrans, "\t%ju TODO:sctps_markedretrans\n"); 74074fd40c9SRandall Stewart #endif 741e5221e8bSRandall Stewart p1a(sctps_naglesent, "\t%ju RFC813 allowed sending\n"); 742e5221e8bSRandall Stewart p1a(sctps_naglequeued, "\t%ju RFC813 does not allow sending\n"); 7434db051c8SRandall Stewart p1a(sctps_maxburstqueued, "\t%ju times max burst prohibited sending\n"); 744e5221e8bSRandall Stewart p1a(sctps_ifnomemqueued, "\t%ju look ahead tells us no memory in " 745b8a1761eSRandall Stewart "interface\n"); 746e5221e8bSRandall Stewart p(sctps_windowprobed, "\t%ju number%s of window probes sent\n"); 747a3a60860SRandall Stewart p(sctps_lowlevelerr, "\t%ju time%s an output error to clamp " 7484db051c8SRandall Stewart "down on next user send\n"); 749a3a60860SRandall Stewart p(sctps_lowlevelerrusr, "\t%ju time%s sctp_senderrors were " 750b8a1761eSRandall Stewart "caused from a user\n"); 751a3a60860SRandall Stewart p(sctps_datadropchklmt, "\t%ju number of in data drop%s due to " 75274fd40c9SRandall Stewart "chunk limit reached\n"); 753a3a60860SRandall Stewart p(sctps_datadroprwnd, "\t%ju number of in data drop%s due to rwnd " 75474fd40c9SRandall Stewart "limit reached\n"); 755a3a60860SRandall Stewart p(sctps_ecnereducedcwnd, "\t%ju time%s a ECN reduced " 75674fd40c9SRandall Stewart "the cwnd\n"); 757e5221e8bSRandall Stewart p1a(sctps_vtagexpress, "\t%ju used express lookup via vtag\n"); 7584db051c8SRandall Stewart p1a(sctps_vtagbogus, "\t%ju collision in express lookup\n"); 759a3a60860SRandall Stewart p(sctps_primary_randry, "\t%ju time%s the sender ran dry " 76074fd40c9SRandall Stewart "of user data on primary\n"); 761a3a60860SRandall Stewart p1a(sctps_cmt_randry, "\t%ju same for above\n"); 762a3a60860SRandall Stewart p(sctps_slowpath_sack, "\t%ju sack%s the slow way\n"); 763e5221e8bSRandall Stewart p(sctps_wu_sacks_sent, "\t%ju window update only sack%s sent\n"); 764e5221e8bSRandall Stewart p(sctps_sends_with_flags, "\t%ju send%s with sinfo_flags !=0\n"); 765e5221e8bSRandall Stewart p(sctps_sends_with_unord, "\t%ju unordered send%s\n"); 766e5221e8bSRandall Stewart p(sctps_sends_with_eof, "\t%ju send%s with EOF flag set\n"); 767e5221e8bSRandall Stewart p(sctps_sends_with_abort, "\t%ju send%s with ABORT flag set\n"); 768a3a60860SRandall Stewart p(sctps_protocol_drain_calls, "\t%ju time%s protocol drain called\n"); 769a3a60860SRandall Stewart p(sctps_protocol_drains_done, "\t%ju time%s we did a protocol " 770b8a1761eSRandall Stewart "drain\n"); 771a3a60860SRandall Stewart p(sctps_read_peeks, "\t%ju time%s recv was called with peek\n"); 772a3a60860SRandall Stewart p(sctps_cached_chk, "\t%ju cached chunk%s used\n"); 773e5221e8bSRandall Stewart p1a(sctps_cached_strmoq, "\t%ju cached stream oq's used\n"); 774e5221e8bSRandall Stewart p(sctps_left_abandon, "\t%ju unread message%s abandonded by close\n"); 775e5221e8bSRandall Stewart p1a(sctps_send_burst_avoid, "\t%ju send burst avoidance, already " 77674fd40c9SRandall Stewart "max burst inflight to net\n"); 777e5221e8bSRandall Stewart p1a(sctps_send_cwnd_avoid, "\t%ju send cwnd full avoidance, already " 778e5221e8bSRandall Stewart "max burst inflight to net\n"); 779a3a60860SRandall Stewart p(sctps_fwdtsn_map_over, "\t%ju number of map array over-run%s via " 78074fd40c9SRandall Stewart "fwd-tsn's\n"); 781b8a1761eSRandall Stewart 782b8a1761eSRandall Stewart #undef p 783b8a1761eSRandall Stewart #undef p1a 78474fd40c9SRandall Stewart } 78574fd40c9SRandall Stewart 78674fd40c9SRandall Stewart #endif /* SCTP */ 787