xref: /freebsd/usr.bin/netstat/sctp.c (revision feda1a4372d5e340da97042375dfb783dea52eda)
174fd40c9SRandall Stewart /*-
274fd40c9SRandall Stewart  * Copyright (c) 2001-2007, by Weongyo Jeong. All rights reserved.
374fd40c9SRandall Stewart  *
474fd40c9SRandall Stewart  * Redistribution and use in source and binary forms, with or without
574fd40c9SRandall Stewart  * modification, are permitted provided that the following conditions are met:
674fd40c9SRandall Stewart  *
774fd40c9SRandall Stewart  * a) Redistributions of source code must retain the above copyright notice,
874fd40c9SRandall Stewart  *   this list of conditions and the following disclaimer.
974fd40c9SRandall Stewart  *
1074fd40c9SRandall Stewart  * b) Redistributions in binary form must reproduce the above copyright
1174fd40c9SRandall Stewart  *    notice, this list of conditions and the following disclaimer in
1274fd40c9SRandall Stewart  *   the documentation and/or other materials provided with the distribution.
1374fd40c9SRandall Stewart  *
1474fd40c9SRandall Stewart  * c) Neither the name of Cisco Systems, Inc. nor the names of its
1574fd40c9SRandall Stewart  *    contributors may be used to endorse or promote products derived
1674fd40c9SRandall Stewart  *    from this software without specific prior written permission.
1774fd40c9SRandall Stewart  *
1874fd40c9SRandall Stewart  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1974fd40c9SRandall Stewart  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2074fd40c9SRandall Stewart  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2174fd40c9SRandall Stewart  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2274fd40c9SRandall Stewart  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2374fd40c9SRandall Stewart  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2474fd40c9SRandall Stewart  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2574fd40c9SRandall Stewart  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2674fd40c9SRandall Stewart  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2774fd40c9SRandall Stewart  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2874fd40c9SRandall Stewart  * THE POSSIBILITY OF SUCH DAMAGE.
2974fd40c9SRandall Stewart  */
3074fd40c9SRandall Stewart 
313f8d71d5SRandall 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>
5674fd40c9SRandall Stewart #include <libutil.h>
5774fd40c9SRandall Stewart #include <netdb.h>
5874fd40c9SRandall Stewart #include <stdint.h>
5974fd40c9SRandall Stewart #include <stdio.h>
6074fd40c9SRandall Stewart #include <stdlib.h>
6174fd40c9SRandall Stewart #include <string.h>
6274fd40c9SRandall Stewart #include <unistd.h>
6374fd40c9SRandall Stewart #include "netstat.h"
6474fd40c9SRandall Stewart 
6574fd40c9SRandall Stewart #ifdef SCTP
6674fd40c9SRandall Stewart 
6774fd40c9SRandall Stewart void	inetprint (struct in_addr *, int, const char *, int);
6874fd40c9SRandall Stewart static void sctp_statesprint(uint32_t state);
6974fd40c9SRandall Stewart 
7074fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_CLOSED		0x0
7174fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_BOUND		0x1
7274fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_LISTEN		0x2
7374fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_COOKIE_WAIT		0x3
7474fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_COOKIE_ECHOED	0x4
7574fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_ESTABLISHED		0x5
7674fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_SHUTDOWN_SENT	0x6
7774fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_SHUTDOWN_RECEIVED	0x7
7874fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT	0x8
7974fd40c9SRandall Stewart #define NETSTAT_SCTP_STATES_SHUTDOWN_PENDING	0x9
8074fd40c9SRandall Stewart 
8174fd40c9SRandall Stewart char *sctpstates[] = {
8274fd40c9SRandall Stewart 	"CLOSED",
8374fd40c9SRandall Stewart 	"BOUND",
8474fd40c9SRandall Stewart 	"LISTEN",
8574fd40c9SRandall Stewart 	"COOKIE_WAIT",
8674fd40c9SRandall Stewart 	"COOKIE_ECHOED",
8774fd40c9SRandall Stewart 	"ESTABLISHED",
8874fd40c9SRandall Stewart 	"SHUTDOWN_SENT",
8974fd40c9SRandall Stewart 	"SHUTDOWN_RECEIVED",
9074fd40c9SRandall Stewart 	"SHUTDOWN_ACK_SENT",
9174fd40c9SRandall Stewart 	"SHUTDOWN_PENDING"
9274fd40c9SRandall Stewart };
9374fd40c9SRandall Stewart 
9474fd40c9SRandall Stewart LIST_HEAD(xladdr_list, xladdr_entry) xladdr_head;
9574fd40c9SRandall Stewart struct xladdr_entry {
9674fd40c9SRandall Stewart 	struct xsctp_laddr *xladdr;
9774fd40c9SRandall Stewart 	LIST_ENTRY(xladdr_entry) xladdr_entries;
9874fd40c9SRandall Stewart };
9974fd40c9SRandall Stewart 
10074fd40c9SRandall Stewart LIST_HEAD(xraddr_list, xraddr_entry) xraddr_head;
10174fd40c9SRandall Stewart struct xraddr_entry {
10274fd40c9SRandall Stewart         struct xsctp_raddr *xraddr;
10374fd40c9SRandall Stewart         LIST_ENTRY(xraddr_entry) xraddr_entries;
10474fd40c9SRandall Stewart };
10574fd40c9SRandall Stewart 
10674fd40c9SRandall Stewart static int
10774fd40c9SRandall Stewart sctp_skip_xinpcb_ifneed(char *buf, const size_t buflen, size_t *offset)
10874fd40c9SRandall Stewart {
10974fd40c9SRandall Stewart 	int exist_tcb = 0;
11074fd40c9SRandall Stewart 	struct xsctp_tcb *xstcb;
11174fd40c9SRandall Stewart 	struct xsctp_raddr *xraddr;
11274fd40c9SRandall Stewart 	struct xsctp_laddr *xladdr;
11374fd40c9SRandall Stewart 
11474fd40c9SRandall Stewart 	while (*offset < buflen) {
11574fd40c9SRandall Stewart 		xladdr = (struct xsctp_laddr *)(buf + *offset);
11674fd40c9SRandall Stewart 		*offset += sizeof(struct xsctp_laddr);
11774fd40c9SRandall Stewart 		if (xladdr->last == 1)
11874fd40c9SRandall Stewart 			break;
11974fd40c9SRandall Stewart 	}
12074fd40c9SRandall Stewart 
12174fd40c9SRandall Stewart 	while (*offset < buflen) {
12274fd40c9SRandall Stewart 		xstcb = (struct xsctp_tcb *)(buf + *offset);
12374fd40c9SRandall Stewart 		*offset += sizeof(struct xsctp_tcb);
12474fd40c9SRandall Stewart 		if (xstcb->last == 1)
12574fd40c9SRandall Stewart 			break;
12674fd40c9SRandall Stewart 
12774fd40c9SRandall Stewart 		exist_tcb = 1;
12874fd40c9SRandall Stewart 
12974fd40c9SRandall Stewart 		while (*offset < buflen) {
13074fd40c9SRandall Stewart 			xladdr = (struct xsctp_laddr *)(buf + *offset);
13174fd40c9SRandall Stewart 			*offset += sizeof(struct xsctp_laddr);
13274fd40c9SRandall Stewart 			if (xladdr->last == 1)
13374fd40c9SRandall Stewart 				break;
13474fd40c9SRandall Stewart 		}
13574fd40c9SRandall Stewart 
13674fd40c9SRandall Stewart 		while (*offset < buflen) {
13774fd40c9SRandall Stewart 			xraddr = (struct xsctp_raddr *)(buf + *offset);
13874fd40c9SRandall Stewart 			*offset += sizeof(struct xsctp_raddr);
13974fd40c9SRandall Stewart 			if (xraddr->last == 1)
14074fd40c9SRandall Stewart 				break;
14174fd40c9SRandall Stewart 		}
14274fd40c9SRandall Stewart 	}
14374fd40c9SRandall Stewart 
14474fd40c9SRandall Stewart 	/*
14574fd40c9SRandall Stewart 	 * If Lflag is set, we don't care about the return value.
14674fd40c9SRandall Stewart 	 */
14774fd40c9SRandall Stewart 	if (Lflag)
14874fd40c9SRandall Stewart 		return 0;
14974fd40c9SRandall Stewart 
15074fd40c9SRandall Stewart 	return exist_tcb;
15174fd40c9SRandall Stewart }
15274fd40c9SRandall Stewart 
15374fd40c9SRandall Stewart static void
15474fd40c9SRandall Stewart sctp_process_tcb(struct xsctp_tcb *xstcb, const char *name,
15574fd40c9SRandall Stewart     char *buf, const size_t buflen, size_t *offset, int *indent)
15674fd40c9SRandall Stewart {
15774fd40c9SRandall Stewart 	int i, xl_total = 0, xr_total = 0, x_max;
15874fd40c9SRandall Stewart 	struct sockaddr *sa;
15974fd40c9SRandall Stewart 	struct xsctp_raddr *xraddr;
16074fd40c9SRandall Stewart 	struct xsctp_laddr *xladdr;
16174fd40c9SRandall Stewart 	struct xladdr_entry *prev_xl = NULL, *xl = NULL, *xl_tmp;
16274fd40c9SRandall Stewart 	struct xraddr_entry *prev_xr = NULL, *xr = NULL, *xr_tmp;
16374fd40c9SRandall Stewart #ifdef INET6
16474fd40c9SRandall Stewart 	struct sockaddr_in6 *in6;
16574fd40c9SRandall Stewart #endif
16674fd40c9SRandall Stewart 
16774fd40c9SRandall Stewart 	LIST_INIT(&xladdr_head);
16874fd40c9SRandall Stewart 	LIST_INIT(&xraddr_head);
16974fd40c9SRandall Stewart 
17074fd40c9SRandall Stewart 	/*
17174fd40c9SRandall Stewart 	 * Make `struct xladdr_list' list and `struct xraddr_list' list
17274fd40c9SRandall Stewart 	 * to handle the address flexibly.
17374fd40c9SRandall Stewart 	 */
17474fd40c9SRandall Stewart 	while (*offset < buflen) {
17574fd40c9SRandall Stewart 		xladdr = (struct xsctp_laddr *)(buf + *offset);
17674fd40c9SRandall Stewart 		*offset += sizeof(struct xsctp_laddr);
17774fd40c9SRandall Stewart 		if (xladdr->last == 1)
17874fd40c9SRandall Stewart 			break;
17974fd40c9SRandall Stewart 
18074fd40c9SRandall Stewart 		prev_xl = xl;
18174fd40c9SRandall Stewart 		xl = malloc(sizeof(struct xladdr_entry));
18274fd40c9SRandall Stewart 		if (xl == NULL) {
18374fd40c9SRandall Stewart 			warnx("malloc %lu bytes",
18474fd40c9SRandall Stewart 			    (u_long)sizeof(struct xladdr_entry));
18574fd40c9SRandall Stewart 			goto out;
18674fd40c9SRandall Stewart 		}
18774fd40c9SRandall Stewart 		xl->xladdr = xladdr;
18874fd40c9SRandall Stewart 		if (prev_xl == NULL)
18974fd40c9SRandall Stewart 			LIST_INSERT_HEAD(&xladdr_head, xl, xladdr_entries);
19074fd40c9SRandall Stewart 		else
19174fd40c9SRandall Stewart 			LIST_INSERT_AFTER(prev_xl, xl, xladdr_entries);
19274fd40c9SRandall Stewart 		xl_total++;
19374fd40c9SRandall Stewart 	}
19474fd40c9SRandall Stewart 
19574fd40c9SRandall Stewart 	while (*offset < buflen) {
19674fd40c9SRandall Stewart 		xraddr = (struct xsctp_raddr *)(buf + *offset);
19774fd40c9SRandall Stewart 		*offset += sizeof(struct xsctp_raddr);
19874fd40c9SRandall Stewart 		if (xraddr->last == 1)
19974fd40c9SRandall Stewart 			break;
20074fd40c9SRandall Stewart 
20174fd40c9SRandall Stewart 		prev_xr = xr;
20274fd40c9SRandall Stewart 		xr = malloc(sizeof(struct xraddr_entry));
20374fd40c9SRandall Stewart 		if (xr == NULL) {
20474fd40c9SRandall Stewart 			warnx("malloc %lu bytes",
20574fd40c9SRandall Stewart 			    (u_long)sizeof(struct xraddr_entry));
20674fd40c9SRandall Stewart 			goto out;
20774fd40c9SRandall Stewart 		}
20874fd40c9SRandall Stewart 		xr->xraddr = xraddr;
20974fd40c9SRandall Stewart 		if (prev_xr == NULL)
21074fd40c9SRandall Stewart 			LIST_INSERT_HEAD(&xraddr_head, xr, xraddr_entries);
21174fd40c9SRandall Stewart 		else
21274fd40c9SRandall Stewart 			LIST_INSERT_AFTER(prev_xr, xr, xraddr_entries);
21374fd40c9SRandall Stewart 		xr_total++;
21474fd40c9SRandall Stewart 	}
21574fd40c9SRandall Stewart 
21674fd40c9SRandall Stewart 	/*
21774fd40c9SRandall Stewart 	 * Let's print the address infos.
21874fd40c9SRandall Stewart 	 */
21974fd40c9SRandall Stewart 	xl = LIST_FIRST(&xladdr_head);
22074fd40c9SRandall Stewart 	xr = LIST_FIRST(&xraddr_head);
22174fd40c9SRandall Stewart 	x_max = (xl_total > xr_total) ? xl_total : xr_total;
22274fd40c9SRandall Stewart 	for (i = 0; i < x_max; i++) {
22374fd40c9SRandall Stewart 		if (((*indent == 0) && i > 0) || *indent > 0)
22474fd40c9SRandall Stewart 			printf("%-11s ", " ");
22574fd40c9SRandall Stewart 
22674fd40c9SRandall Stewart 		if (xl != NULL) {
22774fd40c9SRandall Stewart 			sa = &(xl->xladdr->address.sa);
22874fd40c9SRandall Stewart 			if ((sa->sa_family) == AF_INET)
22974fd40c9SRandall Stewart 				inetprint(&((struct sockaddr_in *)sa)->sin_addr,
23074fd40c9SRandall Stewart 				    htons(xstcb->local_port),
23174fd40c9SRandall Stewart 				    name, numeric_port);
23274fd40c9SRandall Stewart #ifdef INET6
23374fd40c9SRandall Stewart 			else {
23474fd40c9SRandall Stewart 				in6 = (struct sockaddr_in6 *)sa;
23574fd40c9SRandall Stewart 				inet6print(&in6->sin6_addr,
23674fd40c9SRandall Stewart 				    htons(xstcb->local_port),
23774fd40c9SRandall Stewart 				    name, numeric_port);
23874fd40c9SRandall Stewart 			}
23974fd40c9SRandall Stewart #endif
24074fd40c9SRandall Stewart 		}
24174fd40c9SRandall Stewart 
24274fd40c9SRandall Stewart 		if (xr != NULL && !Lflag) {
24374fd40c9SRandall Stewart 			sa = &(xr->xraddr->address.sa);
24474fd40c9SRandall Stewart 			if ((sa->sa_family) == AF_INET)
24574fd40c9SRandall Stewart 				inetprint(&((struct sockaddr_in *)sa)->sin_addr,
24674fd40c9SRandall Stewart 				    htons(xstcb->remote_port),
24774fd40c9SRandall Stewart 				    name, numeric_port);
24874fd40c9SRandall Stewart #ifdef INET6
24974fd40c9SRandall Stewart 			else {
25074fd40c9SRandall Stewart 				in6 = (struct sockaddr_in6 *)sa;
25174fd40c9SRandall Stewart 				inet6print(&in6->sin6_addr,
25274fd40c9SRandall Stewart 				    htons(xstcb->remote_port),
25374fd40c9SRandall Stewart 				    name, numeric_port);
25474fd40c9SRandall Stewart 			}
25574fd40c9SRandall Stewart #endif
25674fd40c9SRandall Stewart 		}
25774fd40c9SRandall Stewart 
25874fd40c9SRandall Stewart 		if (xl != NULL)
25974fd40c9SRandall Stewart 			xl = LIST_NEXT(xl, xladdr_entries);
26074fd40c9SRandall Stewart 		if (xr != NULL)
26174fd40c9SRandall Stewart 			xr = LIST_NEXT(xr, xraddr_entries);
26274fd40c9SRandall Stewart 
26374fd40c9SRandall Stewart 		if (i == 0 && !Lflag)
26474fd40c9SRandall Stewart 			sctp_statesprint(xstcb->state);
26574fd40c9SRandall Stewart 
26674fd40c9SRandall Stewart 		if (i < x_max)
26774fd40c9SRandall Stewart 			putchar('\n');
26874fd40c9SRandall Stewart 	}
26974fd40c9SRandall Stewart 
27074fd40c9SRandall Stewart out:
27174fd40c9SRandall Stewart 	/*
27274fd40c9SRandall Stewart 	 * Free the list which be used to handle the address.
27374fd40c9SRandall Stewart 	 */
27474fd40c9SRandall Stewart 	xl = LIST_FIRST(&xladdr_head);
27574fd40c9SRandall Stewart 	while (xl != NULL) {
27674fd40c9SRandall Stewart 		xl_tmp = LIST_NEXT(xl, xladdr_entries);
27774fd40c9SRandall Stewart 		free(xl);
27874fd40c9SRandall Stewart 		xl = xl_tmp;
27974fd40c9SRandall Stewart 	}
28074fd40c9SRandall Stewart 
28174fd40c9SRandall Stewart 	xr = LIST_FIRST(&xraddr_head);
28274fd40c9SRandall Stewart 	while (xr != NULL) {
28374fd40c9SRandall Stewart 		xr_tmp = LIST_NEXT(xr, xraddr_entries);
28474fd40c9SRandall Stewart 		free(xr);
28574fd40c9SRandall Stewart 		xr = xr_tmp;
28674fd40c9SRandall Stewart 	}
28774fd40c9SRandall Stewart }
28874fd40c9SRandall Stewart 
28974fd40c9SRandall Stewart #ifdef SCTP_DEBUG
29074fd40c9SRandall Stewart uint32_t sctp_pdup[64];
29174fd40c9SRandall Stewart int sctp_pcnt = 0;
29274fd40c9SRandall Stewart #endif
29374fd40c9SRandall Stewart 
29474fd40c9SRandall Stewart static void
29574fd40c9SRandall Stewart sctp_process_inpcb(struct xsctp_inpcb *xinpcb, const char *name,
29674fd40c9SRandall Stewart     char *buf, const size_t buflen, size_t *offset)
29774fd40c9SRandall Stewart {
29874fd40c9SRandall Stewart 	int offset_backup, indent = 0, xladdr_total = 0, is_listening = 0;
29974fd40c9SRandall Stewart 	static int first = 1;
30074fd40c9SRandall Stewart 	char *tname;
30174fd40c9SRandall Stewart 	struct xsctp_tcb *xstcb;
30274fd40c9SRandall Stewart 	struct xsctp_laddr *xladdr;
30374fd40c9SRandall Stewart 	struct sockaddr *sa;
30474fd40c9SRandall Stewart #ifdef INET6
30574fd40c9SRandall Stewart 	struct sockaddr_in6 *in6;
30674fd40c9SRandall Stewart #endif
30774fd40c9SRandall Stewart 
30874fd40c9SRandall Stewart 	if ((xinpcb->flags & SCTP_PCB_FLAGS_TCPTYPE) ==
30974fd40c9SRandall Stewart 	    SCTP_PCB_FLAGS_TCPTYPE && xinpcb->maxqlen > 0)
31074fd40c9SRandall Stewart 		is_listening = 1;
31174fd40c9SRandall Stewart 
31274fd40c9SRandall Stewart 	if (!Lflag && !is_listening &&
31374fd40c9SRandall Stewart 	    !(xinpcb->flags & SCTP_PCB_FLAGS_CONNECTED)) {
31474fd40c9SRandall Stewart #ifdef SCTP_DEBUG
31574fd40c9SRandall Stewart 		int i, found = 0;
31674fd40c9SRandall Stewart 
31774fd40c9SRandall Stewart 		for (i = 0; i < sctp_pcnt; i++) {
31874fd40c9SRandall Stewart 			if (sctp_pdup[i] == xinpcb->flags) {
31974fd40c9SRandall Stewart 				found = 1;
32074fd40c9SRandall Stewart 				break;
32174fd40c9SRandall Stewart 			}
32274fd40c9SRandall Stewart 		}
32374fd40c9SRandall Stewart 		if (!found) {
32474fd40c9SRandall Stewart 			sctp_pdup[sctp_pcnt++] = xinpcb->flags;
32574fd40c9SRandall Stewart 			if (sctp_pcnt >= 64)
32674fd40c9SRandall Stewart 				sctp_pcnt = 0;
32774fd40c9SRandall Stewart 			printf("[0x%08x]", xinpcb->flags);
32874fd40c9SRandall Stewart 		}
32974fd40c9SRandall Stewart #endif
33074fd40c9SRandall Stewart 		offset_backup = *offset;
33174fd40c9SRandall Stewart 		if (!sctp_skip_xinpcb_ifneed(buf, buflen, offset))
33274fd40c9SRandall Stewart 			return;
33374fd40c9SRandall Stewart 		*offset = offset_backup;
33474fd40c9SRandall Stewart 	}
33574fd40c9SRandall Stewart 
33674fd40c9SRandall Stewart 	if (first) {
33774fd40c9SRandall Stewart 		if (!Lflag) {
33874fd40c9SRandall Stewart 			printf("Active SCTP associations");
33974fd40c9SRandall Stewart 			if (aflag)
34074fd40c9SRandall Stewart 				printf(" (including servers)");
34174fd40c9SRandall Stewart 		} else
34274fd40c9SRandall Stewart 			printf("Current listen queue sizes (qlen/maxqlen)");
34374fd40c9SRandall Stewart 		putchar('\n');
34474fd40c9SRandall Stewart 		if (Aflag)
34574fd40c9SRandall Stewart 			printf("%-8.8s ", "Socket");
34674fd40c9SRandall Stewart 		if (Lflag)
34774fd40c9SRandall Stewart 			printf("%-5.5s %-5.5s %-8.8s %-22.22s\n",
34874fd40c9SRandall Stewart 			    "Proto", "Type", "Listen", "Local Address");
34974fd40c9SRandall Stewart 		else
35074fd40c9SRandall Stewart 			printf((Aflag && !Wflag) ?
35174fd40c9SRandall Stewart 			    "%-5.5s %-5.5s %-18.18s %-18.18s %s\n" :
35274fd40c9SRandall Stewart 			    "%-5.5s %-5.5s %-22.22s %-22.22s %s\n",
35374fd40c9SRandall Stewart 			    "Proto", "Type",
35474fd40c9SRandall Stewart 			    "Local Address", "Foreign Address",
35574fd40c9SRandall Stewart 			    "(state)");
35674fd40c9SRandall Stewart 		first = 0;
35774fd40c9SRandall Stewart 	}
35874fd40c9SRandall Stewart 	if (Lflag && xinpcb->maxqlen == 0) {
35974fd40c9SRandall Stewart 		(int)sctp_skip_xinpcb_ifneed(buf, buflen, offset);
36074fd40c9SRandall Stewart 		return;
36174fd40c9SRandall Stewart 	}
36274fd40c9SRandall Stewart 	if (Aflag)
36374fd40c9SRandall Stewart 		printf("%8lx ", (u_long)xinpcb);
36474fd40c9SRandall Stewart 
36574fd40c9SRandall Stewart 	printf("%-5.5s ", name);
36674fd40c9SRandall Stewart 
36774fd40c9SRandall Stewart 	if (xinpcb->flags & SCTP_PCB_FLAGS_TCPTYPE)
36874fd40c9SRandall Stewart 		tname = "1to1";
36974fd40c9SRandall Stewart 	else if (xinpcb->flags & SCTP_PCB_FLAGS_UDPTYPE)
37074fd40c9SRandall Stewart 		tname = "1toN";
37174fd40c9SRandall Stewart 	else
37274fd40c9SRandall Stewart 		return;
37374fd40c9SRandall Stewart 
37474fd40c9SRandall Stewart 	printf("%-5.5s ", tname);
37574fd40c9SRandall Stewart 
37674fd40c9SRandall Stewart 	if (Lflag) {
37774fd40c9SRandall Stewart 		char buf1[9];
37874fd40c9SRandall Stewart 
37974fd40c9SRandall Stewart 		snprintf(buf1, 9, "%hu/%hu", xinpcb->qlen, xinpcb->maxqlen);
38074fd40c9SRandall Stewart 		printf("%-8.8s ", buf1);
38174fd40c9SRandall Stewart 	}
38274fd40c9SRandall Stewart 	/*
38374fd40c9SRandall Stewart 	 * process the local address.  This routine are used for Lflag.
38474fd40c9SRandall Stewart 	 */
38574fd40c9SRandall Stewart 	while (*offset < buflen) {
38674fd40c9SRandall Stewart 		xladdr = (struct xsctp_laddr *)(buf + *offset);
38774fd40c9SRandall Stewart 		*offset += sizeof(struct xsctp_laddr);
38874fd40c9SRandall Stewart 		if (xladdr->last == 1)
38974fd40c9SRandall Stewart 			break;
39074fd40c9SRandall Stewart 
39174fd40c9SRandall Stewart 		if (!Lflag && !is_listening)
39274fd40c9SRandall Stewart 			continue;
39374fd40c9SRandall Stewart 
39474fd40c9SRandall Stewart 		if (xladdr_total != 0)
39574fd40c9SRandall Stewart 			putchar('\n');
39674fd40c9SRandall Stewart 		if (xladdr_total > 0)
39774fd40c9SRandall Stewart 			printf((Lflag) ?
39874fd40c9SRandall Stewart 			    "%-20.20s " : "%-11.11s ", " ");
39974fd40c9SRandall Stewart 
40074fd40c9SRandall Stewart 		sa = &(xladdr->address.sa);
40174fd40c9SRandall Stewart 		if ((sa->sa_family) == AF_INET)
40274fd40c9SRandall Stewart 			inetprint(&((struct sockaddr_in *)sa)->sin_addr,
40374fd40c9SRandall Stewart 			    htons(xinpcb->local_port), name, numeric_port);
40474fd40c9SRandall Stewart #ifdef INET6
40574fd40c9SRandall Stewart 		else {
40674fd40c9SRandall Stewart 			in6 = (struct sockaddr_in6 *)sa;
40774fd40c9SRandall Stewart 			inet6print(&in6->sin6_addr,
40874fd40c9SRandall Stewart 			    htons(xinpcb->local_port), name, numeric_port);
40974fd40c9SRandall Stewart 		}
41074fd40c9SRandall Stewart #endif
41174fd40c9SRandall Stewart 
41274fd40c9SRandall Stewart 		if (!Lflag && xladdr_total == 0 && is_listening == 1)
41374fd40c9SRandall Stewart 			printf("%-22.22s LISTEN", " ");
41474fd40c9SRandall Stewart 
41574fd40c9SRandall Stewart 		xladdr_total++;
41674fd40c9SRandall Stewart 	}
41774fd40c9SRandall Stewart 
41874fd40c9SRandall Stewart 	xstcb = (struct xsctp_tcb *)(buf + *offset);
41974fd40c9SRandall Stewart 	*offset += sizeof(struct xsctp_tcb);
42074fd40c9SRandall Stewart 	while (xstcb->last == 0 && *offset < buflen) {
42174fd40c9SRandall Stewart 		sctp_process_tcb(xstcb, name, buf, buflen, offset, &indent);
42274fd40c9SRandall Stewart 		indent++;
42374fd40c9SRandall Stewart 		xstcb = (struct xsctp_tcb *)(buf + *offset);
42474fd40c9SRandall Stewart 		*offset += sizeof(struct xsctp_tcb);
42574fd40c9SRandall Stewart 	}
42674fd40c9SRandall Stewart 
42774fd40c9SRandall Stewart 	putchar('\n');
42874fd40c9SRandall Stewart }
42974fd40c9SRandall Stewart 
43074fd40c9SRandall Stewart /*
43174fd40c9SRandall Stewart  * Print a summary of SCTP connections related to an Internet
43274fd40c9SRandall Stewart  * protocol.
43374fd40c9SRandall Stewart  */
43474fd40c9SRandall Stewart void
435feda1a43SJohn Baldwin sctp_protopr(u_long off __unused,
436feda1a43SJohn Baldwin     const char *name, int af1, int proto)
43774fd40c9SRandall Stewart {
43874fd40c9SRandall Stewart 	char *buf;
43974fd40c9SRandall Stewart 	const char *mibvar = "net.inet.sctp.assoclist";
44004b764d8SXin LI 	size_t offset = 0;
44174fd40c9SRandall Stewart 	size_t len = 0;
44274fd40c9SRandall Stewart 	struct xsctp_inpcb *xinpcb;
44374fd40c9SRandall Stewart 
44474fd40c9SRandall Stewart 	if (proto != IPPROTO_SCTP)
44574fd40c9SRandall Stewart 		return;
44674fd40c9SRandall Stewart 
44774fd40c9SRandall Stewart 	if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
44874fd40c9SRandall Stewart 		if (errno != ENOENT)
44974fd40c9SRandall Stewart 			warn("sysctl: %s", mibvar);
45074fd40c9SRandall Stewart 		return;
45174fd40c9SRandall Stewart 	}
45274fd40c9SRandall Stewart 	if ((buf = malloc(len)) == 0) {
45374fd40c9SRandall Stewart 		warnx("malloc %lu bytes", (u_long)len);
45474fd40c9SRandall Stewart 		return;
45574fd40c9SRandall Stewart 	}
45674fd40c9SRandall Stewart 	if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
45774fd40c9SRandall Stewart 		warn("sysctl: %s", mibvar);
45874fd40c9SRandall Stewart 		free(buf);
45974fd40c9SRandall Stewart 		return;
46074fd40c9SRandall Stewart 	}
46174fd40c9SRandall Stewart 
46274fd40c9SRandall Stewart 	xinpcb = (struct xsctp_inpcb *)(buf + offset);
46374fd40c9SRandall Stewart 	offset += sizeof(struct xsctp_inpcb);
46474fd40c9SRandall Stewart 	while (xinpcb->last == 0 && offset < len) {
46574fd40c9SRandall Stewart 		sctp_process_inpcb(xinpcb, name, buf, (const size_t)len,
46674fd40c9SRandall Stewart 		    &offset);
46774fd40c9SRandall Stewart 
46874fd40c9SRandall Stewart 		xinpcb = (struct xsctp_inpcb *)(buf + offset);
46974fd40c9SRandall Stewart 		offset += sizeof(struct xsctp_inpcb);
47074fd40c9SRandall Stewart 	}
47174fd40c9SRandall Stewart 
47274fd40c9SRandall Stewart 	free(buf);
47374fd40c9SRandall Stewart }
47474fd40c9SRandall Stewart 
47574fd40c9SRandall Stewart static void
47674fd40c9SRandall Stewart sctp_statesprint(uint32_t state)
47774fd40c9SRandall Stewart {
47874fd40c9SRandall Stewart 	int idx;
47974fd40c9SRandall Stewart 
48074fd40c9SRandall Stewart 	switch (state) {
48174fd40c9SRandall Stewart 	case SCTP_STATE_COOKIE_WAIT:
48274fd40c9SRandall Stewart 		idx = NETSTAT_SCTP_STATES_COOKIE_WAIT;
48374fd40c9SRandall Stewart 		break;
48474fd40c9SRandall Stewart 	case SCTP_STATE_COOKIE_ECHOED:
48574fd40c9SRandall Stewart 		idx = NETSTAT_SCTP_STATES_COOKIE_ECHOED;
48674fd40c9SRandall Stewart 		break;
48774fd40c9SRandall Stewart 	case SCTP_STATE_OPEN:
48874fd40c9SRandall Stewart 		idx = NETSTAT_SCTP_STATES_ESTABLISHED;
48974fd40c9SRandall Stewart 		break;
49074fd40c9SRandall Stewart 	case SCTP_STATE_SHUTDOWN_SENT:
49174fd40c9SRandall Stewart 		idx = NETSTAT_SCTP_STATES_SHUTDOWN_SENT;
49274fd40c9SRandall Stewart 		break;
49374fd40c9SRandall Stewart 	case SCTP_STATE_SHUTDOWN_RECEIVED:
49474fd40c9SRandall Stewart 		idx = NETSTAT_SCTP_STATES_SHUTDOWN_RECEIVED;
49574fd40c9SRandall Stewart 		break;
49674fd40c9SRandall Stewart 	case SCTP_STATE_SHUTDOWN_ACK_SENT:
49774fd40c9SRandall Stewart 		idx = NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT;
49874fd40c9SRandall Stewart 		break;
49974fd40c9SRandall Stewart 	case SCTP_STATE_SHUTDOWN_PENDING:
50074fd40c9SRandall Stewart 		idx = NETSTAT_SCTP_STATES_SHUTDOWN_PENDING;
50174fd40c9SRandall Stewart 		break;
50274fd40c9SRandall Stewart 	default:
50374fd40c9SRandall Stewart 		printf("UNKNOWN 0x%08x", state);
50474fd40c9SRandall Stewart 		return;
50574fd40c9SRandall Stewart 	}
50674fd40c9SRandall Stewart 
50774fd40c9SRandall Stewart 	printf("%s", sctpstates[idx]);
50874fd40c9SRandall Stewart }
50974fd40c9SRandall Stewart 
51074fd40c9SRandall Stewart /*
51174fd40c9SRandall Stewart  * Dump SCTP statistics structure.
51274fd40c9SRandall Stewart  */
51374fd40c9SRandall Stewart void
514feda1a43SJohn Baldwin sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
51574fd40c9SRandall Stewart {
51674fd40c9SRandall Stewart 	struct sctpstat sctpstat, zerostat;
51774fd40c9SRandall Stewart 	size_t len = sizeof(sctpstat);
51874fd40c9SRandall Stewart 
519feda1a43SJohn Baldwin 	if (live) {
52074fd40c9SRandall Stewart 		if (zflag)
52174fd40c9SRandall Stewart 			memset(&zerostat, 0, len);
52274fd40c9SRandall Stewart 		if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len,
52374fd40c9SRandall Stewart 		    zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
52474fd40c9SRandall Stewart 			warn("sysctl: net.inet.sctp.stats");
52574fd40c9SRandall Stewart 			return;
52674fd40c9SRandall Stewart 		}
527feda1a43SJohn Baldwin 	} else
528feda1a43SJohn Baldwin 		kread(off, &sctpstat, len);
52974fd40c9SRandall Stewart 
53074fd40c9SRandall Stewart 	printf ("%s:\n", name);
53174fd40c9SRandall Stewart 
53274fd40c9SRandall Stewart #define	p(f, m) if (sctpstat.f || sflag <= 1) \
53374fd40c9SRandall Stewart     printf(m, sctpstat.f, plural(sctpstat.f))
53474fd40c9SRandall Stewart #define	p1a(f, m) if (sctpstat.f || sflag <= 1) \
53574fd40c9SRandall Stewart     printf(m, sctpstat.f)
53674fd40c9SRandall Stewart #define	p2(f1, f2, m) if (sctpstat.f1 || sctpstat.f2 || sflag <= 1) \
53774fd40c9SRandall Stewart     printf(m, sctpstat.f1, plural(sctpstat.f1), sctpstat.f2, plural(sctpstat.f2))
53874fd40c9SRandall Stewart #define	p2a(f1, f2, m) if (sctpstat.f1 || sctpstat.f2 || sflag <= 1) \
53974fd40c9SRandall Stewart     printf(m, sctpstat.f1, plural(sctpstat.f1), sctpstat.f2)
54074fd40c9SRandall Stewart #define	p3(f, m) if (sctpstat.f || sflag <= 1) \
54174fd40c9SRandall Stewart     printf(m, sctpstat.f, plurales(sctpstat.f))
54274fd40c9SRandall Stewart 
54374fd40c9SRandall Stewart 	/*
54474fd40c9SRandall Stewart 	 * input statistics
54574fd40c9SRandall Stewart 	 */
546b8a1761eSRandall Stewart 	p(sctps_recvpackets, "\t%lu input packet%s\n");
547b8a1761eSRandall Stewart 	p(sctps_recvdatagrams, "\t\t%lu datagram%s\n");
548b8a1761eSRandall Stewart 	p(sctps_recvpktwithdata, "\t\t%lu packet%s that had data\n");
549b8a1761eSRandall Stewart 	p(sctps_recvsacks, "\t\t%lu input SACK chunk%s\n");
550b8a1761eSRandall Stewart 	p(sctps_recvdata, "\t\t%lu input DATA chunk%s\n");
551b8a1761eSRandall Stewart 	p(sctps_recvdupdata, "\t\t%lu duplicate DATA chunk%s\n");
552b8a1761eSRandall Stewart 	p(sctps_recvheartbeat, "\t\t%lu input HB chunk%s\n");
553b8a1761eSRandall Stewart 	p(sctps_recvheartbeatack, "\t\t%lu HB-ACK chunk%s\n");
554b8a1761eSRandall Stewart 	p(sctps_recvecne, "\t\t%lu input ECNE chunk%s\n");
555b8a1761eSRandall Stewart 	p(sctps_recvauth, "\t\t%lu input AUTH chunk%s\n");
556b8a1761eSRandall Stewart 	p(sctps_recvauthmissing, "\t\t%lu chunk%s missing AUTH\n");
557b8a1761eSRandall Stewart 	p(sctps_recvivalhmacid, "\t\t%lu invalid HMAC id%s received\n");
558b8a1761eSRandall Stewart 	p(sctps_recvivalkeyid, "\t\t%lu invalid %secret ids received\n");
559b8a1761eSRandall Stewart 	p1a(sctps_recvauthfailed, "\t\t%lu auth failed\n");
560b8a1761eSRandall Stewart 	p(sctps_recvexpress, "\t\t%lu fa%st path receives all one chunk\n");
561b8a1761eSRandall Stewart 	p(sctps_recvexpressm, "\t\t%lu fa%st path multi-part data\n");
56274fd40c9SRandall Stewart 
56374fd40c9SRandall Stewart 	/*
56474fd40c9SRandall Stewart 	 * output statistics
56574fd40c9SRandall Stewart 	 */
566b8a1761eSRandall Stewart 	p(sctps_sendpackets, "\t%lu output packet%s\n");
567b8a1761eSRandall Stewart 	p(sctps_sendsacks, "\t\t%lu output SACK%s\n");
568b8a1761eSRandall Stewart 	p(sctps_senddata, "\t\t%lu output DATA chunk%s\n");
569b8a1761eSRandall Stewart 	p(sctps_sendretransdata, "\t\t%lu retran%smitted DATA chunks\n");
570b8a1761eSRandall Stewart 	p(sctps_sendfastretrans, "\t\t%lu fa%st retransmitted DATA chunks\n");
571b8a1761eSRandall Stewart 	p(sctps_sendmultfastretrans, "\t\t%lu FR'%s that happened more "
572b8a1761eSRandall Stewart 	    "than once to same chunk.\n");
573b8a1761eSRandall Stewart 	p(sctps_sendheartbeat, "\t\t%lu intput HB chunk%s\n");
574b8a1761eSRandall Stewart 	p(sctps_sendecne, "\t\t%lu output ECNE chunk%s\n");
575b8a1761eSRandall Stewart 	p(sctps_sendauth, "\t\t%lu output AUTH chunk%s\n");
576b8a1761eSRandall Stewart 	p1a(sctps_senderrors, "\t\t%lu ip_output error counter\n");
57774fd40c9SRandall Stewart 
57874fd40c9SRandall Stewart 	/*
57974fd40c9SRandall Stewart 	 * PCKDROPREP statistics
58074fd40c9SRandall Stewart 	 */
581b8a1761eSRandall Stewart 	printf("\tPacket drop statistics:\n");
582b8a1761eSRandall Stewart 	p1a(sctps_pdrpfmbox, "\t\t%lu from middle box\n");
583b8a1761eSRandall Stewart 	p(sctps_pdrpfehos, "\t\t%lu from end ho%st\n");
584b8a1761eSRandall Stewart 	p1a(sctps_pdrpmbda, "\t\t%lu with data\n");
585b8a1761eSRandall Stewart 	p1a(sctps_pdrpmbct, "\t\t%lu non-data, non-endhost\n");
586b8a1761eSRandall Stewart 	p(sctps_pdrpbwrpt, "\t\t%lu non-endho%st, bandwidth rep only\n");
587b8a1761eSRandall Stewart 	p1a(sctps_pdrpcrupt, "\t\t%lu not enough for chunk header\n");
588b8a1761eSRandall Stewart 	p1a(sctps_pdrpnedat, "\t\t%lu not enough data to confirm\n");
589b8a1761eSRandall Stewart 	p(sctps_pdrppdbrk, "\t\t%lu where proce%ss_chunk_drop said break\n");
590b8a1761eSRandall Stewart 	p1a(sctps_pdrptsnnf, "\t\t%lu failed to find TSN\n");
591b8a1761eSRandall Stewart 	p(sctps_pdrpdnfnd, "\t\t%lu attempt rever%se TSN lookup\n");
592b8a1761eSRandall Stewart 	p(sctps_pdrpdiwnp, "\t\t%lu e-ho%st confirms zero-rwnd\n");
593b8a1761eSRandall Stewart 	p(sctps_pdrpdizrw, "\t\t%lu midbox confirm%s no space\n");
594b8a1761eSRandall Stewart 	p1a(sctps_pdrpbadd, "\t\t%lu data did not match TSN\n");
595b8a1761eSRandall Stewart 	p(sctps_pdrpmark, "\t\t%lu TSN'%s marked for Fast Retran\n");
59674fd40c9SRandall Stewart 
59774fd40c9SRandall Stewart 	/*
59874fd40c9SRandall Stewart 	 * Timeouts
59974fd40c9SRandall Stewart 	 */
600b8a1761eSRandall Stewart 	printf("\tTimeouts:\n");
601b8a1761eSRandall Stewart 	p(sctps_timoiterator, "\t\t%lu iterator timer%s fired\n");
602b8a1761eSRandall Stewart 	p(sctps_timodata, "\t\t%lu T3 data time out%s\n");
603b8a1761eSRandall Stewart 	p(sctps_timowindowprobe, "\t\t%lu window probe (T3) timer%s fired\n");
604b8a1761eSRandall Stewart 	p(sctps_timoinit, "\t\t%lu INIT timer%s fired\n");
605b8a1761eSRandall Stewart 	p(sctps_timosack, "\t\t%lu %sack timers fired\n");
606b8a1761eSRandall Stewart 	p(sctps_timoshutdown, "\t\t%lu %shutdown timers fired\n");
607b8a1761eSRandall Stewart 	p(sctps_timoheartbeat, "\t\t%lu heartbeat timer%s fired\n");
608b8a1761eSRandall Stewart 	p1a(sctps_timocookie, "\t\t%lu a cookie timeout fired\n");
609b8a1761eSRandall Stewart 	p1a(sctps_timosecret, "\t\t%lu an endpoint changed its cookie"
610b8a1761eSRandall Stewart 	    "secret\n");
611b8a1761eSRandall Stewart 	p(sctps_timopathmtu, "\t\t%lu PMTU timer%s fired\n");
612b8a1761eSRandall Stewart 	p(sctps_timoshutdownack, "\t\t%lu %shutdown ack timers fired\n");
613b8a1761eSRandall Stewart 	p(sctps_timoshutdownguard, "\t\t%lu %shutdown guard timers fired\n");
614b8a1761eSRandall Stewart 	p(sctps_timostrmrst, "\t\t%lu %stream reset timers fired\n");
615b8a1761eSRandall Stewart 	p(sctps_timoearlyfr, "\t\t%lu early FR timer%s fired\n");
616b8a1761eSRandall Stewart 	p1a(sctps_timoasconf, "\t\t%lu an asconf timer fired\n");
617b8a1761eSRandall Stewart 	p1a(sctps_timoautoclose, "\t\t%lu auto close timer fired\n");
618b8a1761eSRandall Stewart 	p(sctps_timoassockill, "\t\t%lu a%soc free timers expired\n");
619b8a1761eSRandall Stewart 	p(sctps_timoinpkill, "\t\t%lu inp free timer%s expired\n");
62074fd40c9SRandall Stewart 
62174fd40c9SRandall Stewart #if 0
62274fd40c9SRandall Stewart 	/*
62374fd40c9SRandall Stewart 	 * Early fast retransmission counters
62474fd40c9SRandall Stewart 	 */
62574fd40c9SRandall Stewart 	p(sctps_earlyfrstart, "\t%lu TODO:%sctps_earlyfrstart\n");
62674fd40c9SRandall Stewart 	p(sctps_earlyfrstop, "\t%lu TODO:sctp%s_earlyfrstop\n");
62774fd40c9SRandall Stewart 	p(sctps_earlyfrmrkretrans, "\t%lu TODO:%sctps_earlyfrmrkretrans\n");
62874fd40c9SRandall Stewart 	p(sctps_earlyfrstpout, "\t%lu TODO:%sctps_earlyfrstpout\n");
62974fd40c9SRandall Stewart 	p(sctps_earlyfrstpidsck1, "\t%lu TODO:%sctps_earlyfrstpidsck1\n");
63074fd40c9SRandall Stewart 	p(sctps_earlyfrstpidsck2, "\t%lu TODO:%sctps_earlyfrstpidsck2\n");
63174fd40c9SRandall Stewart 	p(sctps_earlyfrstpidsck3, "\t%lu TODO:%sctps_earlyfrstpidsck3\n");
63274fd40c9SRandall Stewart 	p(sctps_earlyfrstpidsck4, "\t%lu TODO:%sctps_earlyfrstpidsck4\n");
63374fd40c9SRandall Stewart 	p(sctps_earlyfrstrid, "\t%lu TODO:%sctps_earlyfrstrid\n");
63474fd40c9SRandall Stewart 	p(sctps_earlyfrstrout, "\t%lu TODO:%sctps_earlyfrstrout\n");
63574fd40c9SRandall Stewart 	p(sctps_earlyfrstrtmr, "\t%lu TODO:%sctps_earlyfrstrtmr\n");
63674fd40c9SRandall Stewart #endif
63774fd40c9SRandall Stewart 
63874fd40c9SRandall Stewart 	/*
63974fd40c9SRandall Stewart 	 * Others
64074fd40c9SRandall Stewart 	 */
64174fd40c9SRandall Stewart 	p(sctps_hdrops, "\t%lu packet %shorter than header\n");
64274fd40c9SRandall Stewart 	p(sctps_badsum, "\t%lu check%sum error\n");
64374fd40c9SRandall Stewart 	p1a(sctps_noport, "\t%lu no endpoint for port\n");
64474fd40c9SRandall Stewart 	p1a(sctps_badvtag, "\t%lu bad v-tag\n");
64574fd40c9SRandall Stewart 	p1a(sctps_badsid, "\t%lu bad SID\n");
64674fd40c9SRandall Stewart 	p1a(sctps_nomem, "\t%lu no memory\n");
64774fd40c9SRandall Stewart 	p1a(sctps_fastretransinrtt, "\t%lu number of multiple FR in a RTT "
64874fd40c9SRandall Stewart 	    "window\n");
64974fd40c9SRandall Stewart #if 0
65074fd40c9SRandall Stewart 	p(sctps_markedretrans, "\t%lu TODO:%sctps_markedretrans\n");
65174fd40c9SRandall Stewart #endif
65274fd40c9SRandall Stewart 	p(sctps_naglesent, "\t%lu nagle allowed %sending\n");
65374fd40c9SRandall Stewart 	p(sctps_naglequeued, "\t%lu nagle doe%s't allow sending\n");
65474fd40c9SRandall Stewart 	p(sctps_maxburstqueued, "\t%lu max bur%st dosn't allow sending\n");
65574fd40c9SRandall Stewart 	p(sctps_ifnomemqueued, "\t%lu look ahead tell%s us no memory in "
656b8a1761eSRandall Stewart 	    "interface\n");
657b8a1761eSRandall Stewart 	p(sctps_windowprobed, "\t%lu numbers of window probe%s sent\n");
658b8a1761eSRandall Stewart 	p(sctps_lowlevelerr, "\t%lu time%s an output error to clamp "
659b8a1761eSRandall Stewart 	    "down on next user send.\n");
660b8a1761eSRandall Stewart 	p(sctps_lowlevelerrusr, "\t%lu time%s sctp_senderrors were "
661b8a1761eSRandall Stewart 	    "caused from a user\n");
66274fd40c9SRandall Stewart 	p(sctps_datadropchklmt, "\t%lu number of in data drop%s due to "
66374fd40c9SRandall Stewart 	    "chunk limit reached\n");
66474fd40c9SRandall Stewart 	p(sctps_datadroprwnd, "\t%lu number of in data drop%s due to rwnd "
66574fd40c9SRandall Stewart 	    "limit reached\n");
666b8a1761eSRandall Stewart 	p(sctps_ecnereducedcwnd, "\t%lu time%s a ECN reduced "
66774fd40c9SRandall Stewart 	    "the cwnd\n");
66874fd40c9SRandall Stewart 	p(sctps_vtagexpress, "\t%lu u%sed express lookup via vtag\n");
66974fd40c9SRandall Stewart 	p(sctps_vtagbogus, "\t%lu colli%sion in express lookup.\n");
670b8a1761eSRandall Stewart 	p(sctps_primary_randry, "\t%lu time%s the sender ran dry "
67174fd40c9SRandall Stewart 	    "of user data on primary\n");
67274fd40c9SRandall Stewart 	p1a(sctps_cmt_randry, "\t%lu same for above\n");
67374fd40c9SRandall Stewart 	p(sctps_slowpath_sack, "\t%lu sack%s the slow way\n");
67474fd40c9SRandall Stewart 	p(sctps_wu_sacks_sent, "\t%lu window update only %sacks sent\n");
675b8a1761eSRandall Stewart 	p(sctps_sends_with_flags, "\t%lu %sends with sinfo_flags !=0\n");
676b8a1761eSRandall Stewart 	p(sctps_sends_with_unord, "\t%lu unordered %sends\n");
677b8a1761eSRandall Stewart 	p(sctps_sends_with_eof, "\t%lu %sends with EOF flag set\n");
678b8a1761eSRandall Stewart 	p(sctps_sends_with_abort, "\t%lu %sends with ABORT flag set\n");
679b8a1761eSRandall Stewart 	p(sctps_protocol_drain_calls, "\t%lu time%s protocol drain called\n");
680b8a1761eSRandall Stewart 	p(sctps_protocol_drains_done, "\t%lu time%s we did a protocol "
681b8a1761eSRandall Stewart 	    "drain\n");
682b8a1761eSRandall Stewart 	p(sctps_read_peeks, "\t%lu time%s recv was called with peek\n");
683b8a1761eSRandall Stewart 	p(sctps_cached_chk, "\t%lu cached chunk%s used\n");
684b8a1761eSRandall Stewart 	p(sctps_cached_strmoq, "\t%lu cached %stream oq's used\n");
685b8a1761eSRandall Stewart 	p(sctps_left_abandon, "\t%lu unread me%ssage abandonded by close\n");
68674fd40c9SRandall Stewart 	p(sctps_send_burst_avoid, "\t%lu send bur%st avoidance, already "
68774fd40c9SRandall Stewart 	    "max burst inflight to net\n");
68874fd40c9SRandall Stewart 	p(sctps_send_cwnd_avoid, "\t%lu send cwnd full avoidance, already "
68974fd40c9SRandall Stewart 	    "max bur%st inflight to net\n");
69074fd40c9SRandall Stewart 	p(sctps_fwdtsn_map_over, "\t%lu number of map array over-run%s via "
69174fd40c9SRandall Stewart 	    "fwd-tsn's\n");
692b8a1761eSRandall Stewart 
693b8a1761eSRandall Stewart #undef p
694b8a1761eSRandall Stewart #undef p1a
695b8a1761eSRandall Stewart #undef p2
696b8a1761eSRandall Stewart #undef p2a
697b8a1761eSRandall Stewart #undef p3
69874fd40c9SRandall Stewart }
69974fd40c9SRandall Stewart 
70074fd40c9SRandall Stewart #endif /* SCTP */
701