174fd40c9SRandall Stewart /*- 274fd40c9SRandall Stewart * Copyright (c) 2001-2007, by Weongyo Jeong. All rights reserved. 3*2e34c19bSMichael 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 8074fd40c9SRandall Stewart 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 105*2e34c19bSMichael Tuexen /* 106*2e34c19bSMichael Tuexen * Construct an Internet address representation. 107*2e34c19bSMichael Tuexen * If numeric_addr has been supplied, give 108*2e34c19bSMichael Tuexen * numeric value, otherwise try for symbolic name. 109*2e34c19bSMichael Tuexen */ 110*2e34c19bSMichael Tuexen static char * 111*2e34c19bSMichael Tuexen inetname(struct in_addr *inp) 112*2e34c19bSMichael Tuexen { 113*2e34c19bSMichael Tuexen char *cp; 114*2e34c19bSMichael Tuexen static char line[MAXHOSTNAMELEN]; 115*2e34c19bSMichael Tuexen struct hostent *hp; 116*2e34c19bSMichael Tuexen struct netent *np; 117*2e34c19bSMichael Tuexen 118*2e34c19bSMichael Tuexen cp = 0; 119*2e34c19bSMichael Tuexen if (!numeric_addr && inp->s_addr != INADDR_ANY) { 120*2e34c19bSMichael Tuexen int net = inet_netof(*inp); 121*2e34c19bSMichael Tuexen int lna = inet_lnaof(*inp); 122*2e34c19bSMichael Tuexen 123*2e34c19bSMichael Tuexen if (lna == INADDR_ANY) { 124*2e34c19bSMichael Tuexen np = getnetbyaddr(net, AF_INET); 125*2e34c19bSMichael Tuexen if (np) 126*2e34c19bSMichael Tuexen cp = np->n_name; 127*2e34c19bSMichael Tuexen } 128*2e34c19bSMichael Tuexen if (cp == 0) { 129*2e34c19bSMichael Tuexen hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET); 130*2e34c19bSMichael Tuexen if (hp) { 131*2e34c19bSMichael Tuexen cp = hp->h_name; 132*2e34c19bSMichael Tuexen trimdomain(cp, strlen(cp)); 133*2e34c19bSMichael Tuexen } 134*2e34c19bSMichael Tuexen } 135*2e34c19bSMichael Tuexen } 136*2e34c19bSMichael Tuexen if (inp->s_addr == INADDR_ANY) 137*2e34c19bSMichael Tuexen strcpy(line, "*"); 138*2e34c19bSMichael Tuexen else if (cp) { 139*2e34c19bSMichael Tuexen strlcpy(line, cp, sizeof(line)); 140*2e34c19bSMichael Tuexen } else { 141*2e34c19bSMichael Tuexen inp->s_addr = ntohl(inp->s_addr); 142*2e34c19bSMichael Tuexen #define C(x) ((u_int)((x) & 0xff)) 143*2e34c19bSMichael Tuexen sprintf(line, "%u.%u.%u.%u", C(inp->s_addr >> 24), 144*2e34c19bSMichael Tuexen C(inp->s_addr >> 16), C(inp->s_addr >> 8), C(inp->s_addr)); 145*2e34c19bSMichael Tuexen inp->s_addr = htonl(inp->s_addr); 146*2e34c19bSMichael Tuexen } 147*2e34c19bSMichael Tuexen return (line); 148*2e34c19bSMichael Tuexen } 149*2e34c19bSMichael Tuexen 150*2e34c19bSMichael Tuexen #ifdef INET6 151*2e34c19bSMichael Tuexen static char ntop_buf[INET6_ADDRSTRLEN]; 152*2e34c19bSMichael Tuexen 153*2e34c19bSMichael Tuexen static char * 154*2e34c19bSMichael Tuexen inet6name(struct in6_addr *in6p) 155*2e34c19bSMichael Tuexen { 156*2e34c19bSMichael Tuexen char *cp; 157*2e34c19bSMichael Tuexen static char line[50]; 158*2e34c19bSMichael Tuexen struct hostent *hp; 159*2e34c19bSMichael Tuexen static char domain[MAXHOSTNAMELEN]; 160*2e34c19bSMichael Tuexen static int first = 1; 161*2e34c19bSMichael Tuexen 162*2e34c19bSMichael Tuexen if (first && !numeric_addr) { 163*2e34c19bSMichael Tuexen first = 0; 164*2e34c19bSMichael Tuexen if (gethostname(domain, MAXHOSTNAMELEN) == 0 && 165*2e34c19bSMichael Tuexen (cp = index(domain, '.'))) 166*2e34c19bSMichael Tuexen (void) strcpy(domain, cp + 1); 167*2e34c19bSMichael Tuexen else 168*2e34c19bSMichael Tuexen domain[0] = 0; 169*2e34c19bSMichael Tuexen } 170*2e34c19bSMichael Tuexen cp = 0; 171*2e34c19bSMichael Tuexen if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) { 172*2e34c19bSMichael Tuexen hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6); 173*2e34c19bSMichael Tuexen if (hp) { 174*2e34c19bSMichael Tuexen if ((cp = index(hp->h_name, '.')) && 175*2e34c19bSMichael Tuexen !strcmp(cp + 1, domain)) 176*2e34c19bSMichael Tuexen *cp = 0; 177*2e34c19bSMichael Tuexen cp = hp->h_name; 178*2e34c19bSMichael Tuexen } 179*2e34c19bSMichael Tuexen } 180*2e34c19bSMichael Tuexen if (IN6_IS_ADDR_UNSPECIFIED(in6p)) 181*2e34c19bSMichael Tuexen strcpy(line, "*"); 182*2e34c19bSMichael Tuexen else if (cp) 183*2e34c19bSMichael Tuexen strcpy(line, cp); 184*2e34c19bSMichael Tuexen else 185*2e34c19bSMichael Tuexen sprintf(line, "%s", 186*2e34c19bSMichael Tuexen inet_ntop(AF_INET6, (void *)in6p, ntop_buf, 187*2e34c19bSMichael Tuexen sizeof(ntop_buf))); 188*2e34c19bSMichael Tuexen return (line); 189*2e34c19bSMichael Tuexen } 190*2e34c19bSMichael Tuexen #endif 191*2e34c19bSMichael Tuexen 192*2e34c19bSMichael Tuexen static void 193*2e34c19bSMichael Tuexen sctp_print_address(union sctp_sockstore *address, int port, int num_port) 194*2e34c19bSMichael Tuexen { 195*2e34c19bSMichael Tuexen struct servent *sp = 0; 196*2e34c19bSMichael Tuexen char line[80], *cp; 197*2e34c19bSMichael Tuexen int width; 198*2e34c19bSMichael Tuexen 199*2e34c19bSMichael Tuexen switch (address->sa.sa_family) { 200*2e34c19bSMichael Tuexen case AF_INET: 201*2e34c19bSMichael Tuexen sprintf(line, "%.*s.", Wflag ? 39 : 16, inetname(&address->sin.sin_addr)); 202*2e34c19bSMichael Tuexen break; 203*2e34c19bSMichael Tuexen #ifdef INET6 204*2e34c19bSMichael Tuexen case AF_INET6: 205*2e34c19bSMichael Tuexen sprintf(line, "%.*s.", Wflag ? 39 : 16, inet6name(&address->sin6.sin6_addr)); 206*2e34c19bSMichael Tuexen break; 207*2e34c19bSMichael Tuexen #endif 208*2e34c19bSMichael Tuexen default: 209*2e34c19bSMichael Tuexen sprintf(line, "%.*s.", Wflag ? 39 : 16, ""); 210*2e34c19bSMichael Tuexen break; 211*2e34c19bSMichael Tuexen } 212*2e34c19bSMichael Tuexen cp = index(line, '\0'); 213*2e34c19bSMichael Tuexen if (!num_port && port) 214*2e34c19bSMichael Tuexen sp = getservbyport((int)port, "sctp"); 215*2e34c19bSMichael Tuexen if (sp || port == 0) 216*2e34c19bSMichael Tuexen sprintf(cp, "%.15s ", sp ? sp->s_name : "*"); 217*2e34c19bSMichael Tuexen else 218*2e34c19bSMichael Tuexen sprintf(cp, "%d ", ntohs((u_short)port)); 219*2e34c19bSMichael Tuexen width = Wflag ? 45 : 22; 220*2e34c19bSMichael Tuexen printf("%-*.*s ", width, width, line); 221*2e34c19bSMichael Tuexen } 222*2e34c19bSMichael Tuexen 22374fd40c9SRandall Stewart static int 22474fd40c9SRandall Stewart sctp_skip_xinpcb_ifneed(char *buf, const size_t buflen, size_t *offset) 22574fd40c9SRandall Stewart { 22674fd40c9SRandall Stewart int exist_tcb = 0; 22774fd40c9SRandall Stewart struct xsctp_tcb *xstcb; 22874fd40c9SRandall Stewart struct xsctp_raddr *xraddr; 22974fd40c9SRandall Stewart struct xsctp_laddr *xladdr; 23074fd40c9SRandall Stewart 23174fd40c9SRandall Stewart while (*offset < buflen) { 23274fd40c9SRandall Stewart xladdr = (struct xsctp_laddr *)(buf + *offset); 23374fd40c9SRandall Stewart *offset += sizeof(struct xsctp_laddr); 23474fd40c9SRandall Stewart if (xladdr->last == 1) 23574fd40c9SRandall Stewart break; 23674fd40c9SRandall Stewart } 23774fd40c9SRandall Stewart 23874fd40c9SRandall Stewart while (*offset < buflen) { 23974fd40c9SRandall Stewart xstcb = (struct xsctp_tcb *)(buf + *offset); 24074fd40c9SRandall Stewart *offset += sizeof(struct xsctp_tcb); 24174fd40c9SRandall Stewart if (xstcb->last == 1) 24274fd40c9SRandall Stewart break; 24374fd40c9SRandall Stewart 24474fd40c9SRandall Stewart exist_tcb = 1; 24574fd40c9SRandall Stewart 24674fd40c9SRandall Stewart while (*offset < buflen) { 24774fd40c9SRandall Stewart xladdr = (struct xsctp_laddr *)(buf + *offset); 24874fd40c9SRandall Stewart *offset += sizeof(struct xsctp_laddr); 24974fd40c9SRandall Stewart if (xladdr->last == 1) 25074fd40c9SRandall Stewart break; 25174fd40c9SRandall Stewart } 25274fd40c9SRandall Stewart 25374fd40c9SRandall Stewart while (*offset < buflen) { 25474fd40c9SRandall Stewart xraddr = (struct xsctp_raddr *)(buf + *offset); 25574fd40c9SRandall Stewart *offset += sizeof(struct xsctp_raddr); 25674fd40c9SRandall Stewart if (xraddr->last == 1) 25774fd40c9SRandall Stewart break; 25874fd40c9SRandall Stewart } 25974fd40c9SRandall Stewart } 26074fd40c9SRandall Stewart 26174fd40c9SRandall Stewart /* 26274fd40c9SRandall Stewart * If Lflag is set, we don't care about the return value. 26374fd40c9SRandall Stewart */ 26474fd40c9SRandall Stewart if (Lflag) 26574fd40c9SRandall Stewart return 0; 26674fd40c9SRandall Stewart 26774fd40c9SRandall Stewart return exist_tcb; 26874fd40c9SRandall Stewart } 26974fd40c9SRandall Stewart 27074fd40c9SRandall Stewart static void 271*2e34c19bSMichael Tuexen sctp_process_tcb(struct xsctp_tcb *xstcb, 27274fd40c9SRandall Stewart char *buf, const size_t buflen, size_t *offset, int *indent) 27374fd40c9SRandall Stewart { 27474fd40c9SRandall Stewart int i, xl_total = 0, xr_total = 0, x_max; 27574fd40c9SRandall Stewart struct xsctp_raddr *xraddr; 27674fd40c9SRandall Stewart struct xsctp_laddr *xladdr; 27774fd40c9SRandall Stewart struct xladdr_entry *prev_xl = NULL, *xl = NULL, *xl_tmp; 27874fd40c9SRandall Stewart struct xraddr_entry *prev_xr = NULL, *xr = NULL, *xr_tmp; 27974fd40c9SRandall Stewart 28074fd40c9SRandall Stewart LIST_INIT(&xladdr_head); 28174fd40c9SRandall Stewart LIST_INIT(&xraddr_head); 28274fd40c9SRandall Stewart 28374fd40c9SRandall Stewart /* 28474fd40c9SRandall Stewart * Make `struct xladdr_list' list and `struct xraddr_list' list 28574fd40c9SRandall Stewart * to handle the address flexibly. 28674fd40c9SRandall Stewart */ 28774fd40c9SRandall Stewart while (*offset < buflen) { 28874fd40c9SRandall Stewart xladdr = (struct xsctp_laddr *)(buf + *offset); 28974fd40c9SRandall Stewart *offset += sizeof(struct xsctp_laddr); 29074fd40c9SRandall Stewart if (xladdr->last == 1) 29174fd40c9SRandall Stewart break; 29274fd40c9SRandall Stewart 29374fd40c9SRandall Stewart prev_xl = xl; 29474fd40c9SRandall Stewart xl = malloc(sizeof(struct xladdr_entry)); 29574fd40c9SRandall Stewart if (xl == NULL) { 29674fd40c9SRandall Stewart warnx("malloc %lu bytes", 29774fd40c9SRandall Stewart (u_long)sizeof(struct xladdr_entry)); 29874fd40c9SRandall Stewart goto out; 29974fd40c9SRandall Stewart } 30074fd40c9SRandall Stewart xl->xladdr = xladdr; 30174fd40c9SRandall Stewart if (prev_xl == NULL) 30274fd40c9SRandall Stewart LIST_INSERT_HEAD(&xladdr_head, xl, xladdr_entries); 30374fd40c9SRandall Stewart else 30474fd40c9SRandall Stewart LIST_INSERT_AFTER(prev_xl, xl, xladdr_entries); 30574fd40c9SRandall Stewart xl_total++; 30674fd40c9SRandall Stewart } 30774fd40c9SRandall Stewart 30874fd40c9SRandall Stewart while (*offset < buflen) { 30974fd40c9SRandall Stewart xraddr = (struct xsctp_raddr *)(buf + *offset); 31074fd40c9SRandall Stewart *offset += sizeof(struct xsctp_raddr); 31174fd40c9SRandall Stewart if (xraddr->last == 1) 31274fd40c9SRandall Stewart break; 31374fd40c9SRandall Stewart 31474fd40c9SRandall Stewart prev_xr = xr; 31574fd40c9SRandall Stewart xr = malloc(sizeof(struct xraddr_entry)); 31674fd40c9SRandall Stewart if (xr == NULL) { 31774fd40c9SRandall Stewart warnx("malloc %lu bytes", 31874fd40c9SRandall Stewart (u_long)sizeof(struct xraddr_entry)); 31974fd40c9SRandall Stewart goto out; 32074fd40c9SRandall Stewart } 32174fd40c9SRandall Stewart xr->xraddr = xraddr; 32274fd40c9SRandall Stewart if (prev_xr == NULL) 32374fd40c9SRandall Stewart LIST_INSERT_HEAD(&xraddr_head, xr, xraddr_entries); 32474fd40c9SRandall Stewart else 32574fd40c9SRandall Stewart LIST_INSERT_AFTER(prev_xr, xr, xraddr_entries); 32674fd40c9SRandall Stewart xr_total++; 32774fd40c9SRandall Stewart } 32874fd40c9SRandall Stewart 32974fd40c9SRandall Stewart /* 33074fd40c9SRandall Stewart * Let's print the address infos. 33174fd40c9SRandall Stewart */ 33274fd40c9SRandall Stewart xl = LIST_FIRST(&xladdr_head); 33374fd40c9SRandall Stewart xr = LIST_FIRST(&xraddr_head); 33474fd40c9SRandall Stewart x_max = (xl_total > xr_total) ? xl_total : xr_total; 33574fd40c9SRandall Stewart for (i = 0; i < x_max; i++) { 33674fd40c9SRandall Stewart if (((*indent == 0) && i > 0) || *indent > 0) 337*2e34c19bSMichael Tuexen printf("%-12s ", " "); 33874fd40c9SRandall Stewart 33974fd40c9SRandall Stewart if (xl != NULL) { 340*2e34c19bSMichael Tuexen sctp_print_address(&(xl->xladdr->address), 341*2e34c19bSMichael Tuexen htons(xstcb->local_port), numeric_port); 342*2e34c19bSMichael Tuexen } else { 343*2e34c19bSMichael Tuexen if (Wflag) { 344*2e34c19bSMichael Tuexen printf("%-45s ", " "); 345*2e34c19bSMichael Tuexen } else { 346*2e34c19bSMichael Tuexen printf("%-22s ", " "); 34774fd40c9SRandall Stewart } 34874fd40c9SRandall Stewart } 34974fd40c9SRandall Stewart 35074fd40c9SRandall Stewart if (xr != NULL && !Lflag) { 351*2e34c19bSMichael Tuexen sctp_print_address(&(xr->xraddr->address), 352*2e34c19bSMichael Tuexen htons(xstcb->remote_port), numeric_port); 35374fd40c9SRandall Stewart } 35474fd40c9SRandall Stewart 35574fd40c9SRandall Stewart if (xl != NULL) 35674fd40c9SRandall Stewart xl = LIST_NEXT(xl, xladdr_entries); 35774fd40c9SRandall Stewart if (xr != NULL) 35874fd40c9SRandall Stewart xr = LIST_NEXT(xr, xraddr_entries); 35974fd40c9SRandall Stewart 36074fd40c9SRandall Stewart if (i == 0 && !Lflag) 36174fd40c9SRandall Stewart sctp_statesprint(xstcb->state); 36274fd40c9SRandall Stewart 36374fd40c9SRandall Stewart if (i < x_max) 36474fd40c9SRandall Stewart putchar('\n'); 36574fd40c9SRandall Stewart } 36674fd40c9SRandall Stewart 36774fd40c9SRandall Stewart out: 36874fd40c9SRandall Stewart /* 36974fd40c9SRandall Stewart * Free the list which be used to handle the address. 37074fd40c9SRandall Stewart */ 37174fd40c9SRandall Stewart xl = LIST_FIRST(&xladdr_head); 37274fd40c9SRandall Stewart while (xl != NULL) { 37374fd40c9SRandall Stewart xl_tmp = LIST_NEXT(xl, xladdr_entries); 37474fd40c9SRandall Stewart free(xl); 37574fd40c9SRandall Stewart xl = xl_tmp; 37674fd40c9SRandall Stewart } 37774fd40c9SRandall Stewart 37874fd40c9SRandall Stewart xr = LIST_FIRST(&xraddr_head); 37974fd40c9SRandall Stewart while (xr != NULL) { 38074fd40c9SRandall Stewart xr_tmp = LIST_NEXT(xr, xraddr_entries); 38174fd40c9SRandall Stewart free(xr); 38274fd40c9SRandall Stewart xr = xr_tmp; 38374fd40c9SRandall Stewart } 38474fd40c9SRandall Stewart } 38574fd40c9SRandall Stewart 38674fd40c9SRandall Stewart static void 387*2e34c19bSMichael Tuexen sctp_process_inpcb(struct xsctp_inpcb *xinpcb, 38874fd40c9SRandall Stewart char *buf, const size_t buflen, size_t *offset) 38974fd40c9SRandall Stewart { 390*2e34c19bSMichael Tuexen int indent = 0, xladdr_total = 0, is_listening = 0; 39174fd40c9SRandall Stewart static int first = 1; 392*2e34c19bSMichael Tuexen char *tname, *pname; 39374fd40c9SRandall Stewart struct xsctp_tcb *xstcb; 39474fd40c9SRandall Stewart struct xsctp_laddr *xladdr; 395*2e34c19bSMichael Tuexen size_t offset_laddr; 396*2e34c19bSMichael Tuexen int process_closed; 39774fd40c9SRandall Stewart 398*2e34c19bSMichael Tuexen if (xinpcb->maxqlen > 0) 39974fd40c9SRandall Stewart is_listening = 1; 40074fd40c9SRandall Stewart 40174fd40c9SRandall Stewart if (first) { 40274fd40c9SRandall Stewart if (!Lflag) { 40374fd40c9SRandall Stewart printf("Active SCTP associations"); 40474fd40c9SRandall Stewart if (aflag) 40574fd40c9SRandall Stewart printf(" (including servers)"); 40674fd40c9SRandall Stewart } else 40774fd40c9SRandall Stewart printf("Current listen queue sizes (qlen/maxqlen)"); 40874fd40c9SRandall Stewart putchar('\n'); 40974fd40c9SRandall Stewart if (Lflag) 410*2e34c19bSMichael Tuexen printf("%-6.6s %-5.5s %-8.8s %-22.22s\n", 41174fd40c9SRandall Stewart "Proto", "Type", "Listen", "Local Address"); 41274fd40c9SRandall Stewart else 413*2e34c19bSMichael Tuexen if (Wflag) 414*2e34c19bSMichael Tuexen printf("%-6.6s %-5.5s %-45.45s %-45.45s %s\n", 415*2e34c19bSMichael Tuexen "Proto", "Type", 416*2e34c19bSMichael Tuexen "Local Address", "Foreign Address", 417*2e34c19bSMichael Tuexen "(state)"); 418*2e34c19bSMichael Tuexen else 419*2e34c19bSMichael Tuexen printf("%-6.6s %-5.5s %-22.22s %-22.22s %s\n", 42074fd40c9SRandall Stewart "Proto", "Type", 42174fd40c9SRandall Stewart "Local Address", "Foreign Address", 42274fd40c9SRandall Stewart "(state)"); 42374fd40c9SRandall Stewart first = 0; 42474fd40c9SRandall Stewart } 425*2e34c19bSMichael Tuexen xladdr = (struct xsctp_laddr *)(buf + *offset); 426*2e34c19bSMichael Tuexen if (Lflag && !is_listening) { 42793f8854cSDimitry Andric sctp_skip_xinpcb_ifneed(buf, buflen, offset); 42874fd40c9SRandall Stewart return; 42974fd40c9SRandall Stewart } 43074fd40c9SRandall Stewart 431*2e34c19bSMichael Tuexen if (xinpcb->flags & SCTP_PCB_FLAGS_BOUND_V6) { 432*2e34c19bSMichael Tuexen /* Can't distinguish between sctp46 and sctp6 */ 433*2e34c19bSMichael Tuexen pname = "sctp46"; 434*2e34c19bSMichael Tuexen } else { 435*2e34c19bSMichael Tuexen pname = "sctp4"; 436*2e34c19bSMichael Tuexen } 43774fd40c9SRandall Stewart 43874fd40c9SRandall Stewart if (xinpcb->flags & SCTP_PCB_FLAGS_TCPTYPE) 43974fd40c9SRandall Stewart tname = "1to1"; 44074fd40c9SRandall Stewart else if (xinpcb->flags & SCTP_PCB_FLAGS_UDPTYPE) 44174fd40c9SRandall Stewart tname = "1toN"; 44274fd40c9SRandall Stewart else 443*2e34c19bSMichael Tuexen tname = "????"; 44474fd40c9SRandall Stewart 44574fd40c9SRandall Stewart if (Lflag) { 44674fd40c9SRandall Stewart char buf1[9]; 44774fd40c9SRandall Stewart 44874fd40c9SRandall Stewart snprintf(buf1, 9, "%hu/%hu", xinpcb->qlen, xinpcb->maxqlen); 449*2e34c19bSMichael Tuexen printf("%-6.6s %-5.5s ", pname, tname); 45074fd40c9SRandall Stewart printf("%-8.8s ", buf1); 45174fd40c9SRandall Stewart } 452*2e34c19bSMichael Tuexen 453*2e34c19bSMichael Tuexen offset_laddr = *offset; 454*2e34c19bSMichael Tuexen process_closed = 0; 455*2e34c19bSMichael Tuexen retry: 45674fd40c9SRandall Stewart while (*offset < buflen) { 45774fd40c9SRandall Stewart xladdr = (struct xsctp_laddr *)(buf + *offset); 45874fd40c9SRandall Stewart *offset += sizeof(struct xsctp_laddr); 459*2e34c19bSMichael Tuexen if (xladdr->last) { 460*2e34c19bSMichael Tuexen if (aflag && !Lflag && (xladdr_total == 0) && process_closed) { 461*2e34c19bSMichael Tuexen printf("%-6.6s %-5.5s ", pname, tname); 462*2e34c19bSMichael Tuexen if (Wflag) { 463*2e34c19bSMichael Tuexen printf("%-91.91s CLOSED", " "); 464*2e34c19bSMichael Tuexen } else { 465*2e34c19bSMichael Tuexen printf("%-45.45s CLOSED", " "); 466*2e34c19bSMichael Tuexen } 467*2e34c19bSMichael Tuexen } 468*2e34c19bSMichael Tuexen if (process_closed || is_listening) { 469*2e34c19bSMichael Tuexen putchar('\n'); 470*2e34c19bSMichael Tuexen } 47174fd40c9SRandall Stewart break; 472*2e34c19bSMichael Tuexen } 47374fd40c9SRandall Stewart 474*2e34c19bSMichael Tuexen if (!Lflag && !is_listening && !process_closed) 47574fd40c9SRandall Stewart continue; 47674fd40c9SRandall Stewart 477*2e34c19bSMichael Tuexen if (xladdr_total == 0) { 478*2e34c19bSMichael Tuexen printf("%-6.6s %-5.5s ", pname, tname); 479*2e34c19bSMichael Tuexen } else { 48074fd40c9SRandall Stewart putchar('\n'); 48174fd40c9SRandall Stewart printf((Lflag) ? 482*2e34c19bSMichael Tuexen "%-21.21s " : "%-12.12s ", " "); 48374fd40c9SRandall Stewart } 484*2e34c19bSMichael Tuexen sctp_print_address(&(xladdr->address), 485*2e34c19bSMichael Tuexen htons(xinpcb->local_port), numeric_port); 486*2e34c19bSMichael Tuexen if (aflag && !Lflag && xladdr_total == 0) { 487*2e34c19bSMichael Tuexen if (Wflag) { 488*2e34c19bSMichael Tuexen if (process_closed) { 489*2e34c19bSMichael Tuexen printf("%-45.45s CLOSED", " "); 490*2e34c19bSMichael Tuexen } else { 491*2e34c19bSMichael Tuexen printf("%-45.45s LISTEN", " "); 492*2e34c19bSMichael Tuexen } 493*2e34c19bSMichael Tuexen } else { 494*2e34c19bSMichael Tuexen if (process_closed) { 495*2e34c19bSMichael Tuexen printf("%-22.22s CLOSED", " "); 496*2e34c19bSMichael Tuexen } else { 49774fd40c9SRandall Stewart printf("%-22.22s LISTEN", " "); 498*2e34c19bSMichael Tuexen } 499*2e34c19bSMichael Tuexen } 500*2e34c19bSMichael Tuexen } 50174fd40c9SRandall Stewart xladdr_total++; 50274fd40c9SRandall Stewart } 50374fd40c9SRandall Stewart 50474fd40c9SRandall Stewart xstcb = (struct xsctp_tcb *)(buf + *offset); 50574fd40c9SRandall Stewart *offset += sizeof(struct xsctp_tcb); 506*2e34c19bSMichael Tuexen if (aflag && (xladdr_total == 0) && xstcb->last && !process_closed) { 507*2e34c19bSMichael Tuexen process_closed = 1; 508*2e34c19bSMichael Tuexen *offset = offset_laddr; 509*2e34c19bSMichael Tuexen goto retry; 510*2e34c19bSMichael Tuexen } 51174fd40c9SRandall Stewart while (xstcb->last == 0 && *offset < buflen) { 512*2e34c19bSMichael Tuexen printf("%-6.6s %-5.5s ", pname, tname); 513*2e34c19bSMichael Tuexen sctp_process_tcb(xstcb, buf, buflen, offset, &indent); 51474fd40c9SRandall Stewart indent++; 51574fd40c9SRandall Stewart xstcb = (struct xsctp_tcb *)(buf + *offset); 51674fd40c9SRandall Stewart *offset += sizeof(struct xsctp_tcb); 51774fd40c9SRandall Stewart } 51874fd40c9SRandall Stewart } 51974fd40c9SRandall Stewart 52074fd40c9SRandall Stewart /* 52174fd40c9SRandall Stewart * Print a summary of SCTP connections related to an Internet 52274fd40c9SRandall Stewart * protocol. 52374fd40c9SRandall Stewart */ 52474fd40c9SRandall Stewart void 525feda1a43SJohn Baldwin sctp_protopr(u_long off __unused, 526feda1a43SJohn Baldwin const char *name, int af1, int proto) 52774fd40c9SRandall Stewart { 52874fd40c9SRandall Stewart char *buf; 52974fd40c9SRandall Stewart const char *mibvar = "net.inet.sctp.assoclist"; 53004b764d8SXin LI size_t offset = 0; 53174fd40c9SRandall Stewart size_t len = 0; 53274fd40c9SRandall Stewart struct xsctp_inpcb *xinpcb; 53374fd40c9SRandall Stewart 53474fd40c9SRandall Stewart if (proto != IPPROTO_SCTP) 53574fd40c9SRandall Stewart return; 53674fd40c9SRandall Stewart 53774fd40c9SRandall Stewart if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) { 53874fd40c9SRandall Stewart if (errno != ENOENT) 53974fd40c9SRandall Stewart warn("sysctl: %s", mibvar); 54074fd40c9SRandall Stewart return; 54174fd40c9SRandall Stewart } 54274fd40c9SRandall Stewart if ((buf = malloc(len)) == 0) { 54374fd40c9SRandall Stewart warnx("malloc %lu bytes", (u_long)len); 54474fd40c9SRandall Stewart return; 54574fd40c9SRandall Stewart } 54674fd40c9SRandall Stewart if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) { 54774fd40c9SRandall Stewart warn("sysctl: %s", mibvar); 54874fd40c9SRandall Stewart free(buf); 54974fd40c9SRandall Stewart return; 55074fd40c9SRandall Stewart } 55174fd40c9SRandall Stewart 55274fd40c9SRandall Stewart xinpcb = (struct xsctp_inpcb *)(buf + offset); 55374fd40c9SRandall Stewart offset += sizeof(struct xsctp_inpcb); 55474fd40c9SRandall Stewart while (xinpcb->last == 0 && offset < len) { 555*2e34c19bSMichael Tuexen sctp_process_inpcb(xinpcb, buf, (const size_t)len, 55674fd40c9SRandall Stewart &offset); 55774fd40c9SRandall Stewart 55874fd40c9SRandall Stewart xinpcb = (struct xsctp_inpcb *)(buf + offset); 55974fd40c9SRandall Stewart offset += sizeof(struct xsctp_inpcb); 56074fd40c9SRandall Stewart } 56174fd40c9SRandall Stewart 56274fd40c9SRandall Stewart free(buf); 56374fd40c9SRandall Stewart } 56474fd40c9SRandall Stewart 56574fd40c9SRandall Stewart static void 56674fd40c9SRandall Stewart sctp_statesprint(uint32_t state) 56774fd40c9SRandall Stewart { 56874fd40c9SRandall Stewart int idx; 56974fd40c9SRandall Stewart 57074fd40c9SRandall Stewart switch (state) { 57174fd40c9SRandall Stewart case SCTP_STATE_COOKIE_WAIT: 57274fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_COOKIE_WAIT; 57374fd40c9SRandall Stewart break; 57474fd40c9SRandall Stewart case SCTP_STATE_COOKIE_ECHOED: 57574fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_COOKIE_ECHOED; 57674fd40c9SRandall Stewart break; 57774fd40c9SRandall Stewart case SCTP_STATE_OPEN: 57874fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_ESTABLISHED; 57974fd40c9SRandall Stewart break; 58074fd40c9SRandall Stewart case SCTP_STATE_SHUTDOWN_SENT: 58174fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_SHUTDOWN_SENT; 58274fd40c9SRandall Stewart break; 58374fd40c9SRandall Stewart case SCTP_STATE_SHUTDOWN_RECEIVED: 58474fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_SHUTDOWN_RECEIVED; 58574fd40c9SRandall Stewart break; 58674fd40c9SRandall Stewart case SCTP_STATE_SHUTDOWN_ACK_SENT: 58774fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT; 58874fd40c9SRandall Stewart break; 58974fd40c9SRandall Stewart case SCTP_STATE_SHUTDOWN_PENDING: 59074fd40c9SRandall Stewart idx = NETSTAT_SCTP_STATES_SHUTDOWN_PENDING; 59174fd40c9SRandall Stewart break; 59274fd40c9SRandall Stewart default: 59374fd40c9SRandall Stewart printf("UNKNOWN 0x%08x", state); 59474fd40c9SRandall Stewart return; 59574fd40c9SRandall Stewart } 59674fd40c9SRandall Stewart 59774fd40c9SRandall Stewart printf("%s", sctpstates[idx]); 59874fd40c9SRandall Stewart } 59974fd40c9SRandall Stewart 60074fd40c9SRandall Stewart /* 60174fd40c9SRandall Stewart * Dump SCTP statistics structure. 60274fd40c9SRandall Stewart */ 60374fd40c9SRandall Stewart void 604feda1a43SJohn Baldwin sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) 60574fd40c9SRandall Stewart { 60674fd40c9SRandall Stewart struct sctpstat sctpstat, zerostat; 60774fd40c9SRandall Stewart size_t len = sizeof(sctpstat); 60874fd40c9SRandall Stewart 609feda1a43SJohn Baldwin if (live) { 61074fd40c9SRandall Stewart if (zflag) 61174fd40c9SRandall Stewart memset(&zerostat, 0, len); 61274fd40c9SRandall Stewart if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len, 61374fd40c9SRandall Stewart zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { 61474fd40c9SRandall Stewart warn("sysctl: net.inet.sctp.stats"); 61574fd40c9SRandall Stewart return; 61674fd40c9SRandall Stewart } 617feda1a43SJohn Baldwin } else 618feda1a43SJohn Baldwin kread(off, &sctpstat, len); 61974fd40c9SRandall Stewart 62074fd40c9SRandall Stewart printf ("%s:\n", name); 62174fd40c9SRandall Stewart 62274fd40c9SRandall Stewart #define p(f, m) if (sctpstat.f || sflag <= 1) \ 623a3a60860SRandall Stewart printf(m, (uintmax_t)sctpstat.f, plural(sctpstat.f)) 62474fd40c9SRandall Stewart #define p1a(f, m) if (sctpstat.f || sflag <= 1) \ 625a3a60860SRandall Stewart printf(m, (uintmax_t)sctpstat.f) 62674fd40c9SRandall Stewart 62774fd40c9SRandall Stewart /* 62874fd40c9SRandall Stewart * input statistics 62974fd40c9SRandall Stewart */ 630a3a60860SRandall Stewart p(sctps_recvpackets, "\t%ju input packet%s\n"); 631a3a60860SRandall Stewart p(sctps_recvdatagrams, "\t\t%ju datagram%s\n"); 632a3a60860SRandall Stewart p(sctps_recvpktwithdata, "\t\t%ju packet%s that had data\n"); 633a3a60860SRandall Stewart p(sctps_recvsacks, "\t\t%ju input SACK chunk%s\n"); 634a3a60860SRandall Stewart p(sctps_recvdata, "\t\t%ju input DATA chunk%s\n"); 635a3a60860SRandall Stewart p(sctps_recvdupdata, "\t\t%ju duplicate DATA chunk%s\n"); 636a3a60860SRandall Stewart p(sctps_recvheartbeat, "\t\t%ju input HB chunk%s\n"); 637a3a60860SRandall Stewart p(sctps_recvheartbeatack, "\t\t%ju HB-ACK chunk%s\n"); 638a3a60860SRandall Stewart p(sctps_recvecne, "\t\t%ju input ECNE chunk%s\n"); 639a3a60860SRandall Stewart p(sctps_recvauth, "\t\t%ju input AUTH chunk%s\n"); 640a3a60860SRandall Stewart p(sctps_recvauthmissing, "\t\t%ju chunk%s missing AUTH\n"); 641a3a60860SRandall Stewart p(sctps_recvivalhmacid, "\t\t%ju invalid HMAC id%s received\n"); 642e5221e8bSRandall Stewart p(sctps_recvivalkeyid, "\t\t%ju invalid secret id%s received\n"); 643a3a60860SRandall Stewart p1a(sctps_recvauthfailed, "\t\t%ju auth failed\n"); 644e5221e8bSRandall Stewart p1a(sctps_recvexpress, "\t\t%ju fast path receives all one chunk\n"); 645e5221e8bSRandall Stewart p1a(sctps_recvexpressm, "\t\t%ju fast path multi-part data\n"); 64674fd40c9SRandall Stewart 64774fd40c9SRandall Stewart /* 64874fd40c9SRandall Stewart * output statistics 64974fd40c9SRandall Stewart */ 650a3a60860SRandall Stewart p(sctps_sendpackets, "\t%ju output packet%s\n"); 651a3a60860SRandall Stewart p(sctps_sendsacks, "\t\t%ju output SACK%s\n"); 652a3a60860SRandall Stewart p(sctps_senddata, "\t\t%ju output DATA chunk%s\n"); 653e5221e8bSRandall Stewart p(sctps_sendretransdata, "\t\t%ju retransmitted DATA chunk%s\n"); 654e5221e8bSRandall Stewart p(sctps_sendfastretrans, "\t\t%ju fast retransmitted DATA chunk%s\n"); 655a3a60860SRandall Stewart p(sctps_sendmultfastretrans, "\t\t%ju FR'%s that happened more " 6564db051c8SRandall Stewart "than once to same chunk\n"); 657e17c4d4eSRebecca Cran p(sctps_sendheartbeat, "\t\t%ju output HB chunk%s\n"); 658a3a60860SRandall Stewart p(sctps_sendecne, "\t\t%ju output ECNE chunk%s\n"); 659a3a60860SRandall Stewart p(sctps_sendauth, "\t\t%ju output AUTH chunk%s\n"); 660a3a60860SRandall Stewart p1a(sctps_senderrors, "\t\t%ju ip_output error counter\n"); 66174fd40c9SRandall Stewart 66274fd40c9SRandall Stewart /* 66374fd40c9SRandall Stewart * PCKDROPREP statistics 66474fd40c9SRandall Stewart */ 665b8a1761eSRandall Stewart printf("\tPacket drop statistics:\n"); 666a3a60860SRandall Stewart p1a(sctps_pdrpfmbox, "\t\t%ju from middle box\n"); 667e5221e8bSRandall Stewart p1a(sctps_pdrpfehos, "\t\t%ju from end host\n"); 668a3a60860SRandall Stewart p1a(sctps_pdrpmbda, "\t\t%ju with data\n"); 669a3a60860SRandall Stewart p1a(sctps_pdrpmbct, "\t\t%ju non-data, non-endhost\n"); 670e5221e8bSRandall Stewart p1a(sctps_pdrpbwrpt, "\t\t%ju non-endhost, bandwidth rep only\n"); 671a3a60860SRandall Stewart p1a(sctps_pdrpcrupt, "\t\t%ju not enough for chunk header\n"); 672a3a60860SRandall Stewart p1a(sctps_pdrpnedat, "\t\t%ju not enough data to confirm\n"); 673e5221e8bSRandall Stewart p1a(sctps_pdrppdbrk, "\t\t%ju where process_chunk_drop said break\n"); 674a3a60860SRandall Stewart p1a(sctps_pdrptsnnf, "\t\t%ju failed to find TSN\n"); 675e5221e8bSRandall Stewart p1a(sctps_pdrpdnfnd, "\t\t%ju attempt reverse TSN lookup\n"); 676e5221e8bSRandall Stewart p1a(sctps_pdrpdiwnp, "\t\t%ju e-host confirms zero-rwnd\n"); 677e5221e8bSRandall Stewart p1a(sctps_pdrpdizrw, "\t\t%ju midbox confirms no space\n"); 678a3a60860SRandall Stewart p1a(sctps_pdrpbadd, "\t\t%ju data did not match TSN\n"); 679a3a60860SRandall Stewart p(sctps_pdrpmark, "\t\t%ju TSN'%s marked for Fast Retran\n"); 68074fd40c9SRandall Stewart 68174fd40c9SRandall Stewart /* 68274fd40c9SRandall Stewart * Timeouts 68374fd40c9SRandall Stewart */ 684b8a1761eSRandall Stewart printf("\tTimeouts:\n"); 685a3a60860SRandall Stewart p(sctps_timoiterator, "\t\t%ju iterator timer%s fired\n"); 686a3a60860SRandall Stewart p(sctps_timodata, "\t\t%ju T3 data time out%s\n"); 687a3a60860SRandall Stewart p(sctps_timowindowprobe, "\t\t%ju window probe (T3) timer%s fired\n"); 688a3a60860SRandall Stewart p(sctps_timoinit, "\t\t%ju INIT timer%s fired\n"); 689e5221e8bSRandall Stewart p(sctps_timosack, "\t\t%ju sack timer%s fired\n"); 690e5221e8bSRandall Stewart p(sctps_timoshutdown, "\t\t%ju shutdown timer%s fired\n"); 691a3a60860SRandall Stewart p(sctps_timoheartbeat, "\t\t%ju heartbeat timer%s fired\n"); 692a3a60860SRandall Stewart p1a(sctps_timocookie, "\t\t%ju a cookie timeout fired\n"); 693a3a60860SRandall Stewart p1a(sctps_timosecret, "\t\t%ju an endpoint changed its cookie" 694b8a1761eSRandall Stewart "secret\n"); 695a3a60860SRandall Stewart p(sctps_timopathmtu, "\t\t%ju PMTU timer%s fired\n"); 696e5221e8bSRandall Stewart p(sctps_timoshutdownack, "\t\t%ju shutdown ack timer%s fired\n"); 697e5221e8bSRandall Stewart p(sctps_timoshutdownguard, "\t\t%ju shutdown guard timer%s fired\n"); 698e5221e8bSRandall Stewart p(sctps_timostrmrst, "\t\t%ju stream reset timer%s fired\n"); 699a3a60860SRandall Stewart p(sctps_timoearlyfr, "\t\t%ju early FR timer%s fired\n"); 700a3a60860SRandall Stewart p1a(sctps_timoasconf, "\t\t%ju an asconf timer fired\n"); 701a3a60860SRandall Stewart p1a(sctps_timoautoclose, "\t\t%ju auto close timer fired\n"); 702e5221e8bSRandall Stewart p(sctps_timoassockill, "\t\t%ju asoc free timer%s expired\n"); 703a3a60860SRandall Stewart p(sctps_timoinpkill, "\t\t%ju inp free timer%s expired\n"); 70474fd40c9SRandall Stewart 70574fd40c9SRandall Stewart #if 0 70674fd40c9SRandall Stewart /* 70774fd40c9SRandall Stewart * Early fast retransmission counters 70874fd40c9SRandall Stewart */ 709e5221e8bSRandall Stewart p(sctps_earlyfrstart, "\t%ju TODO:sctps_earlyfrstart\n"); 710e5221e8bSRandall Stewart p(sctps_earlyfrstop, "\t%ju TODO:sctps_earlyfrstop\n"); 711e5221e8bSRandall Stewart p(sctps_earlyfrmrkretrans, "\t%ju TODO:sctps_earlyfrmrkretrans\n"); 712e5221e8bSRandall Stewart p(sctps_earlyfrstpout, "\t%ju TODO:sctps_earlyfrstpout\n"); 713e5221e8bSRandall Stewart p(sctps_earlyfrstpidsck1, "\t%ju TODO:sctps_earlyfrstpidsck1\n"); 714e5221e8bSRandall Stewart p(sctps_earlyfrstpidsck2, "\t%ju TODO:sctps_earlyfrstpidsck2\n"); 715e5221e8bSRandall Stewart p(sctps_earlyfrstpidsck3, "\t%ju TODO:sctps_earlyfrstpidsck3\n"); 716e5221e8bSRandall Stewart p(sctps_earlyfrstpidsck4, "\t%ju TODO:sctps_earlyfrstpidsck4\n"); 717e5221e8bSRandall Stewart p(sctps_earlyfrstrid, "\t%ju TODO:sctps_earlyfrstrid\n"); 718e5221e8bSRandall Stewart p(sctps_earlyfrstrout, "\t%ju TODO:sctps_earlyfrstrout\n"); 719e5221e8bSRandall Stewart p(sctps_earlyfrstrtmr, "\t%ju TODO:sctps_earlyfrstrtmr\n"); 72074fd40c9SRandall Stewart #endif 72174fd40c9SRandall Stewart 72274fd40c9SRandall Stewart /* 72374fd40c9SRandall Stewart * Others 72474fd40c9SRandall Stewart */ 725e5221e8bSRandall Stewart p1a(sctps_hdrops, "\t%ju packet shorter than header\n"); 726e5221e8bSRandall Stewart p1a(sctps_badsum, "\t%ju checksum error\n"); 727a3a60860SRandall Stewart p1a(sctps_noport, "\t%ju no endpoint for port\n"); 728a3a60860SRandall Stewart p1a(sctps_badvtag, "\t%ju bad v-tag\n"); 729a3a60860SRandall Stewart p1a(sctps_badsid, "\t%ju bad SID\n"); 730a3a60860SRandall Stewart p1a(sctps_nomem, "\t%ju no memory\n"); 731a3a60860SRandall Stewart p1a(sctps_fastretransinrtt, "\t%ju number of multiple FR in a RTT " 73274fd40c9SRandall Stewart "window\n"); 73374fd40c9SRandall Stewart #if 0 734e5221e8bSRandall Stewart p(sctps_markedretrans, "\t%ju TODO:sctps_markedretrans\n"); 73574fd40c9SRandall Stewart #endif 736e5221e8bSRandall Stewart p1a(sctps_naglesent, "\t%ju RFC813 allowed sending\n"); 737e5221e8bSRandall Stewart p1a(sctps_naglequeued, "\t%ju RFC813 does not allow sending\n"); 7384db051c8SRandall Stewart p1a(sctps_maxburstqueued, "\t%ju times max burst prohibited sending\n"); 739e5221e8bSRandall Stewart p1a(sctps_ifnomemqueued, "\t%ju look ahead tells us no memory in " 740b8a1761eSRandall Stewart "interface\n"); 741e5221e8bSRandall Stewart p(sctps_windowprobed, "\t%ju number%s of window probes sent\n"); 742a3a60860SRandall Stewart p(sctps_lowlevelerr, "\t%ju time%s an output error to clamp " 7434db051c8SRandall Stewart "down on next user send\n"); 744a3a60860SRandall Stewart p(sctps_lowlevelerrusr, "\t%ju time%s sctp_senderrors were " 745b8a1761eSRandall Stewart "caused from a user\n"); 746a3a60860SRandall Stewart p(sctps_datadropchklmt, "\t%ju number of in data drop%s due to " 74774fd40c9SRandall Stewart "chunk limit reached\n"); 748a3a60860SRandall Stewart p(sctps_datadroprwnd, "\t%ju number of in data drop%s due to rwnd " 74974fd40c9SRandall Stewart "limit reached\n"); 750a3a60860SRandall Stewart p(sctps_ecnereducedcwnd, "\t%ju time%s a ECN reduced " 75174fd40c9SRandall Stewart "the cwnd\n"); 752e5221e8bSRandall Stewart p1a(sctps_vtagexpress, "\t%ju used express lookup via vtag\n"); 7534db051c8SRandall Stewart p1a(sctps_vtagbogus, "\t%ju collision in express lookup\n"); 754a3a60860SRandall Stewart p(sctps_primary_randry, "\t%ju time%s the sender ran dry " 75574fd40c9SRandall Stewart "of user data on primary\n"); 756a3a60860SRandall Stewart p1a(sctps_cmt_randry, "\t%ju same for above\n"); 757a3a60860SRandall Stewart p(sctps_slowpath_sack, "\t%ju sack%s the slow way\n"); 758e5221e8bSRandall Stewart p(sctps_wu_sacks_sent, "\t%ju window update only sack%s sent\n"); 759e5221e8bSRandall Stewart p(sctps_sends_with_flags, "\t%ju send%s with sinfo_flags !=0\n"); 760e5221e8bSRandall Stewart p(sctps_sends_with_unord, "\t%ju unordered send%s\n"); 761e5221e8bSRandall Stewart p(sctps_sends_with_eof, "\t%ju send%s with EOF flag set\n"); 762e5221e8bSRandall Stewart p(sctps_sends_with_abort, "\t%ju send%s with ABORT flag set\n"); 763a3a60860SRandall Stewart p(sctps_protocol_drain_calls, "\t%ju time%s protocol drain called\n"); 764a3a60860SRandall Stewart p(sctps_protocol_drains_done, "\t%ju time%s we did a protocol " 765b8a1761eSRandall Stewart "drain\n"); 766a3a60860SRandall Stewart p(sctps_read_peeks, "\t%ju time%s recv was called with peek\n"); 767a3a60860SRandall Stewart p(sctps_cached_chk, "\t%ju cached chunk%s used\n"); 768e5221e8bSRandall Stewart p1a(sctps_cached_strmoq, "\t%ju cached stream oq's used\n"); 769e5221e8bSRandall Stewart p(sctps_left_abandon, "\t%ju unread message%s abandonded by close\n"); 770e5221e8bSRandall Stewart p1a(sctps_send_burst_avoid, "\t%ju send burst avoidance, already " 77174fd40c9SRandall Stewart "max burst inflight to net\n"); 772e5221e8bSRandall Stewart p1a(sctps_send_cwnd_avoid, "\t%ju send cwnd full avoidance, already " 773e5221e8bSRandall Stewart "max burst inflight to net\n"); 774a3a60860SRandall Stewart p(sctps_fwdtsn_map_over, "\t%ju number of map array over-run%s via " 77574fd40c9SRandall Stewart "fwd-tsn's\n"); 776b8a1761eSRandall Stewart 777b8a1761eSRandall Stewart #undef p 778b8a1761eSRandall Stewart #undef p1a 77974fd40c9SRandall Stewart } 78074fd40c9SRandall Stewart 78174fd40c9SRandall Stewart #endif /* SCTP */ 782