xref: /freebsd/cddl/lib/libdtrace/tcp.d (revision 5d06879adb95ac922703072a28fc11048d809a4b)
157f60867SMark Johnston /*
257f60867SMark Johnston  * CDDL HEADER START
357f60867SMark Johnston  *
457f60867SMark Johnston  * The contents of this file are subject to the terms of the
557f60867SMark Johnston  * Common Development and Distribution License (the "License").
657f60867SMark Johnston  * You may not use this file except in compliance with the License.
757f60867SMark Johnston  *
857f60867SMark Johnston  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
957f60867SMark Johnston  * or http://www.opensolaris.org/os/licensing.
1057f60867SMark Johnston  * See the License for the specific language governing permissions
1157f60867SMark Johnston  * and limitations under the License.
1257f60867SMark Johnston  *
1357f60867SMark Johnston  * When distributing Covered Code, include this CDDL HEADER in each
1457f60867SMark Johnston  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1557f60867SMark Johnston  * If applicable, add the following below this CDDL HEADER, with the
1657f60867SMark Johnston  * fields enclosed by brackets "[]" replaced with your own identifying
1757f60867SMark Johnston  * information: Portions Copyright [yyyy] [name of copyright owner]
1857f60867SMark Johnston  *
1957f60867SMark Johnston  * CDDL HEADER END
2057f60867SMark Johnston  *
2157f60867SMark Johnston  * $FreeBSD$
2257f60867SMark Johnston  */
2357f60867SMark Johnston /*
2457f60867SMark Johnston  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2557f60867SMark Johnston  * Copyright (c) 2013 Mark Johnston <markj@freebsd.org>
2657f60867SMark Johnston  */
2757f60867SMark Johnston 
2857f60867SMark Johnston #pragma D depends_on library ip.d
297e518a66SMark Johnston #pragma D depends_on module kernel
3057f60867SMark Johnston #pragma D depends_on provider tcp
3157f60867SMark Johnston 
3257f60867SMark Johnston /*
3357f60867SMark Johnston  * Convert a TCP state value to a string.
3457f60867SMark Johnston  */
352f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_CLOSED
3657f60867SMark Johnston inline int TCPS_CLOSED =	0;
372f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_LISTEN
3857f60867SMark Johnston inline int TCPS_LISTEN =	1;
392f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_SYN_SENT
4057f60867SMark Johnston inline int TCPS_SYN_SENT =	2;
412f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_SYN_RECEIVED
4257f60867SMark Johnston inline int TCPS_SYN_RECEIVED =	3;
432f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_ESTABLISHED
4457f60867SMark Johnston inline int TCPS_ESTABLISHED =	4;
452f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_CLOSE_WAIT
4657f60867SMark Johnston inline int TCPS_CLOSE_WAIT =	5;
472f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_FIN_WAIT_1
4857f60867SMark Johnston inline int TCPS_FIN_WAIT_1 =	6;
492f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_CLOSING
5057f60867SMark Johnston inline int TCPS_CLOSING =	7;
512f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_LAST_ACK
5257f60867SMark Johnston inline int TCPS_LAST_ACK =	8;
532f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_FIN_WAIT_2
5457f60867SMark Johnston inline int TCPS_FIN_WAIT_2 =	9;
552f28ceebSMark Johnston #pragma D binding "1.6.3" TCPS_TIME_WAIT
5657f60867SMark Johnston inline int TCPS_TIME_WAIT =	10;
5757f60867SMark Johnston 
5857f60867SMark Johnston /* TCP segment flags. */
592f28ceebSMark Johnston #pragma D binding "1.6.3" TH_FIN
6057f60867SMark Johnston inline uint8_t TH_FIN =		0x01;
612f28ceebSMark Johnston #pragma D binding "1.6.3" TH_SYN
6257f60867SMark Johnston inline uint8_t TH_SYN =		0x02;
632f28ceebSMark Johnston #pragma D binding "1.6.3" TH_RST
6457f60867SMark Johnston inline uint8_t TH_RST =		0x04;
652f28ceebSMark Johnston #pragma D binding "1.6.3" TH_PUSH
6657f60867SMark Johnston inline uint8_t TH_PUSH =	0x08;
672f28ceebSMark Johnston #pragma D binding "1.6.3" TH_ACK
6857f60867SMark Johnston inline uint8_t TH_ACK =		0x10;
692f28ceebSMark Johnston #pragma D binding "1.6.3" TH_URG
7057f60867SMark Johnston inline uint8_t TH_URG =		0x20;
712f28ceebSMark Johnston #pragma D binding "1.6.3" TH_ECE
7257f60867SMark Johnston inline uint8_t TH_ECE =		0x40;
732f28ceebSMark Johnston #pragma D binding "1.6.3" TH_CWR
7457f60867SMark Johnston inline uint8_t TH_CWR =		0x80;
7557f60867SMark Johnston 
7657f60867SMark Johnston /* TCP connection state strings. */
772f28ceebSMark Johnston #pragma D binding "1.6.3" tcp_state_string
7857f60867SMark Johnston inline string tcp_state_string[int32_t state] =
7957f60867SMark Johnston 	state == TCPS_CLOSED ?		"state-closed" :
8057f60867SMark Johnston 	state == TCPS_LISTEN ?		"state-listen" :
8157f60867SMark Johnston 	state == TCPS_SYN_SENT ?	"state-syn-sent" :
8257f60867SMark Johnston 	state == TCPS_SYN_RECEIVED ?	"state-syn-received" :
8357f60867SMark Johnston 	state == TCPS_ESTABLISHED ?	"state-established" :
8457f60867SMark Johnston 	state == TCPS_CLOSE_WAIT ?	"state-close-wait" :
8557f60867SMark Johnston 	state == TCPS_FIN_WAIT_1 ?	"state-fin-wait-1" :
8657f60867SMark Johnston 	state == TCPS_CLOSING ?		"state-closing" :
8757f60867SMark Johnston 	state == TCPS_LAST_ACK ?	"state-last-ack" :
8857f60867SMark Johnston 	state == TCPS_FIN_WAIT_2 ?	"state-fin-wait-2" :
8957f60867SMark Johnston 	state == TCPS_TIME_WAIT ?	"state-time-wait" :
9057f60867SMark Johnston 	"<unknown>";
9157f60867SMark Johnston 
9257f60867SMark Johnston /*
9357f60867SMark Johnston  * tcpsinfo contains stable TCP details from tcp_t.
9457f60867SMark Johnston  */
9557f60867SMark Johnston typedef struct tcpsinfo {
9657f60867SMark Johnston 	uintptr_t tcps_addr;
9757f60867SMark Johnston 	int tcps_local;			/* is delivered locally, boolean */
9857f60867SMark Johnston 	int tcps_active;		/* active open (from here), boolean */
9957f60867SMark Johnston 	uint16_t tcps_lport;		/* local port */
10057f60867SMark Johnston 	uint16_t tcps_rport;		/* remote port */
10157f60867SMark Johnston 	string tcps_laddr;		/* local address, as a string */
10257f60867SMark Johnston 	string tcps_raddr;		/* remote address, as a string */
10357f60867SMark Johnston 	int32_t tcps_state;		/* TCP state */
10457f60867SMark Johnston 	uint32_t tcps_iss;		/* Initial sequence # sent */
10557f60867SMark Johnston 	uint32_t tcps_suna;		/* sequence # sent but unacked */
106*5d06879aSGeorge V. Neville-Neil 	uint32_t tcps_smax;		/* highest sequence number sent */
10757f60867SMark Johnston 	uint32_t tcps_snxt;		/* next sequence # to send */
10857f60867SMark Johnston 	uint32_t tcps_rack;		/* sequence # we have acked */
10957f60867SMark Johnston 	uint32_t tcps_rnxt;		/* next sequence # expected */
11057f60867SMark Johnston 	uint32_t tcps_swnd;		/* send window size */
11157f60867SMark Johnston 	int32_t tcps_snd_ws;		/* send window scaling */
112*5d06879aSGeorge V. Neville-Neil 	uint32_t tcps_swl1;		/* window update seg seq number */
113*5d06879aSGeorge V. Neville-Neil 	uint32_t tcps_swl2;		/* window update seg ack number */
114*5d06879aSGeorge V. Neville-Neil 	uint32_t tcps_rup;		/* receive urgent pointer */
11557f60867SMark Johnston 	uint32_t tcps_rwnd;		/* receive window size */
11657f60867SMark Johnston 	int32_t tcps_rcv_ws;		/* receive window scaling */
11757f60867SMark Johnston 	uint32_t tcps_cwnd;		/* congestion window */
11857f60867SMark Johnston 	uint32_t tcps_cwnd_ssthresh;	/* threshold for congestion avoidance */
11957f60867SMark Johnston 	uint32_t tcps_sack_fack;	/* SACK sequence # we have acked */
12057f60867SMark Johnston 	uint32_t tcps_sack_snxt;	/* next SACK seq # for retransmission */
12157f60867SMark Johnston 	uint32_t tcps_rto;		/* round-trip timeout, msec */
12257f60867SMark Johnston 	uint32_t tcps_mss;		/* max segment size */
12357f60867SMark Johnston 	int tcps_retransmit;		/* retransmit send event, boolean */
124bd537a28SGeorge V. Neville-Neil 	int tcps_srtt;			/* smoothed RTT in units of (TCP_RTT_SCALE*hz) */
125*5d06879aSGeorge V. Neville-Neil 	int tcps_debug;		/* socket has SO_DEBUG set */
12657f60867SMark Johnston } tcpsinfo_t;
12757f60867SMark Johnston 
12857f60867SMark Johnston /*
12957f60867SMark Johnston  * tcplsinfo provides the old tcp state for state changes.
13057f60867SMark Johnston  */
13157f60867SMark Johnston typedef struct tcplsinfo {
13257f60867SMark Johnston 	int32_t tcps_state;		/* previous TCP state */
13357f60867SMark Johnston } tcplsinfo_t;
13457f60867SMark Johnston 
13557f60867SMark Johnston /*
13657f60867SMark Johnston  * tcpinfo is the TCP header fields.
13757f60867SMark Johnston  */
13857f60867SMark Johnston typedef struct tcpinfo {
13957f60867SMark Johnston 	uint16_t tcp_sport;		/* source port */
14057f60867SMark Johnston 	uint16_t tcp_dport;		/* destination port */
14157f60867SMark Johnston 	uint32_t tcp_seq;		/* sequence number */
14257f60867SMark Johnston 	uint32_t tcp_ack;		/* acknowledgment number */
14357f60867SMark Johnston 	uint8_t tcp_offset;		/* data offset, in bytes */
14457f60867SMark Johnston 	uint8_t tcp_flags;		/* flags */
14557f60867SMark Johnston 	uint16_t tcp_window;		/* window size */
14657f60867SMark Johnston 	uint16_t tcp_checksum;		/* checksum */
14757f60867SMark Johnston 	uint16_t tcp_urgent;		/* urgent data pointer */
14857f60867SMark Johnston 	struct tcphdr *tcp_hdr;		/* raw TCP header */
14957f60867SMark Johnston } tcpinfo_t;
15057f60867SMark Johnston 
1518298c17cSMark Johnston /*
1528298c17cSMark Johnston  * A clone of tcpinfo_t used to handle the fact that the TCP input path
1538298c17cSMark Johnston  * overwrites some fields of the TCP header with their host-order equivalents.
1548298c17cSMark Johnston  * Unfortunately, DTrace doesn't let us simply typedef a new name for struct
1558298c17cSMark Johnston  * tcpinfo and define a separate translator for it.
1568298c17cSMark Johnston  */
1578298c17cSMark Johnston typedef struct tcpinfoh {
1588298c17cSMark Johnston 	uint16_t tcp_sport;		/* source port */
1598298c17cSMark Johnston 	uint16_t tcp_dport;		/* destination port */
1608298c17cSMark Johnston 	uint32_t tcp_seq;		/* sequence number */
1618298c17cSMark Johnston 	uint32_t tcp_ack;		/* acknowledgment number */
1628298c17cSMark Johnston 	uint8_t tcp_offset;		/* data offset, in bytes */
1638298c17cSMark Johnston 	uint8_t tcp_flags;		/* flags */
1648298c17cSMark Johnston 	uint16_t tcp_window;		/* window size */
1658298c17cSMark Johnston 	uint16_t tcp_checksum;		/* checksum */
1668298c17cSMark Johnston 	uint16_t tcp_urgent;		/* urgent data pointer */
1678298c17cSMark Johnston 	struct tcphdr *tcp_hdr;		/* raw TCP header */
1688298c17cSMark Johnston } tcpinfoh_t;
1698298c17cSMark Johnston 
1702f28ceebSMark Johnston #pragma D binding "1.6.3" translator
17157f60867SMark Johnston translator csinfo_t < struct tcpcb *p > {
17257f60867SMark Johnston 	cs_addr =	NULL;
1739feec372SMark Johnston 	cs_cid =	(uint64_t)(p == NULL ? 0 : p->t_inpcb);
17457f60867SMark Johnston 	cs_pid =	0;
17557f60867SMark Johnston 	cs_zoneid =	0;
17657f60867SMark Johnston };
17757f60867SMark Johnston 
1782f28ceebSMark Johnston #pragma D binding "1.6.3" translator
17957f60867SMark Johnston translator tcpsinfo_t < struct tcpcb *p > {
18057f60867SMark Johnston 	tcps_addr =		(uintptr_t)p;
18157f60867SMark Johnston 	tcps_local =		-1; /* XXX */
18257f60867SMark Johnston 	tcps_active =		-1; /* XXX */
18357f60867SMark Johnston 	tcps_lport =		p == NULL ? 0 : ntohs(p->t_inpcb->inp_inc.inc_ie.ie_lport);
18457f60867SMark Johnston 	tcps_rport =		p == NULL ? 0 : ntohs(p->t_inpcb->inp_inc.inc_ie.ie_fport);
18557f60867SMark Johnston 	tcps_laddr =		p == NULL ? 0 :
18657f60867SMark Johnston 	    p->t_inpcb->inp_vflag == INP_IPV4 ?
18757f60867SMark Johnston 	    inet_ntoa(&p->t_inpcb->inp_inc.inc_ie.ie_dependladdr.ie46_local.ia46_addr4.s_addr) :
18857f60867SMark Johnston 	    inet_ntoa6(&p->t_inpcb->inp_inc.inc_ie.ie_dependladdr.ie6_local);
18957f60867SMark Johnston 	tcps_raddr =		p == NULL ? 0 :
19057f60867SMark Johnston 	    p->t_inpcb->inp_vflag == INP_IPV4 ?
19157f60867SMark Johnston 	    inet_ntoa(&p->t_inpcb->inp_inc.inc_ie.ie_dependfaddr.ie46_foreign.ia46_addr4.s_addr) :
19257f60867SMark Johnston 	    inet_ntoa6(&p->t_inpcb->inp_inc.inc_ie.ie_dependfaddr.ie6_foreign);
19357f60867SMark Johnston 	tcps_state =		p == NULL ? -1 : p->t_state;
19457f60867SMark Johnston 	tcps_iss =		p == NULL ? 0  : p->iss;
19557f60867SMark Johnston 	tcps_suna =		p == NULL ? 0  : p->snd_una;
196*5d06879aSGeorge V. Neville-Neil 	tcps_smax =		p == NULL ? 0  : p->snd_max;
19757f60867SMark Johnston 	tcps_snxt =		p == NULL ? 0  : p->snd_nxt;
19857f60867SMark Johnston 	tcps_rack =		p == NULL ? 0  : p->last_ack_sent;
19957f60867SMark Johnston 	tcps_rnxt =		p == NULL ? 0  : p->rcv_nxt;
20057f60867SMark Johnston 	tcps_swnd =		p == NULL ? -1  : p->snd_wnd;
20157f60867SMark Johnston 	tcps_snd_ws =		p == NULL ? -1  : p->snd_scale;
202*5d06879aSGeorge V. Neville-Neil 	tcps_swl1 =		p == NULL ? -1  : p->snd_wl1;
203*5d06879aSGeorge V. Neville-Neil 	tcps_swl2 = 		p == NULL ? -1  : p->snd_wl2;
20457f60867SMark Johnston 	tcps_rwnd =		p == NULL ? -1  : p->rcv_wnd;
205*5d06879aSGeorge V. Neville-Neil 	tcps_rup =		p == NULL ? -1  : p->rcv_up;
20657f60867SMark Johnston 	tcps_rcv_ws =		p == NULL ? -1  : p->rcv_scale;
20757f60867SMark Johnston 	tcps_cwnd =		p == NULL ? -1  : p->snd_cwnd;
20857f60867SMark Johnston 	tcps_cwnd_ssthresh =	p == NULL ? -1  : p->snd_ssthresh;
20957f60867SMark Johnston 	tcps_sack_fack =	p == NULL ? 0  : p->snd_fack;
21057f60867SMark Johnston 	tcps_sack_snxt =	p == NULL ? 0  : p->sack_newdata;
211fd8b318aSMark Johnston 	tcps_rto =		p == NULL ? -1 : (p->t_rxtcur * 1000) / `hz;
21257f60867SMark Johnston 	tcps_mss =		p == NULL ? -1  : p->t_maxseg;
2138298c17cSMark Johnston 	tcps_retransmit =	p == NULL ? -1 : p->t_rxtshift > 0 ? 1 : 0;
214bd537a28SGeorge V. Neville-Neil 	tcps_srtt =             p == NULL ? -1  : p->t_srtt;   /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */
215*5d06879aSGeorge V. Neville-Neil 	tcps_debug =		p == NULL ? 0 :
216*5d06879aSGeorge V. Neville-Neil 	    p->t_inpcb->inp_socket->so_options & 1;
21757f60867SMark Johnston };
21857f60867SMark Johnston 
2192f28ceebSMark Johnston #pragma D binding "1.6.3" translator
22057f60867SMark Johnston translator tcpinfo_t < struct tcphdr *p > {
22157f60867SMark Johnston 	tcp_sport =	p == NULL ? 0  : ntohs(p->th_sport);
22257f60867SMark Johnston 	tcp_dport =	p == NULL ? 0  : ntohs(p->th_dport);
22357f60867SMark Johnston 	tcp_seq =	p == NULL ? -1 : ntohl(p->th_seq);
22457f60867SMark Johnston 	tcp_ack =	p == NULL ? -1 : ntohl(p->th_ack);
22557f60867SMark Johnston 	tcp_offset =	p == NULL ? -1 : (p->th_off >> 2);
22657f60867SMark Johnston 	tcp_flags =	p == NULL ? 0  : p->th_flags;
22757f60867SMark Johnston 	tcp_window =	p == NULL ? 0  : ntohs(p->th_win);
22857f60867SMark Johnston 	tcp_checksum =	p == NULL ? 0  : ntohs(p->th_sum);
22957f60867SMark Johnston 	tcp_urgent =	p == NULL ? 0  : ntohs(p->th_urp);
23057f60867SMark Johnston 	tcp_hdr =	(struct tcphdr *)p;
23157f60867SMark Johnston };
23257f60867SMark Johnston 
2338298c17cSMark Johnston /*
2348298c17cSMark Johnston  * This translator differs from the one for tcpinfo_t in that the sequence
2358298c17cSMark Johnston  * number, acknowledgement number, window size and urgent pointer are already
2368298c17cSMark Johnston  * in host order and thus don't need to be converted.
2378298c17cSMark Johnston  */
2382f28ceebSMark Johnston #pragma D binding "1.6.3" translator
2398298c17cSMark Johnston translator tcpinfoh_t < struct tcphdr *p > {
2408298c17cSMark Johnston 	tcp_sport =	p == NULL ? 0  : ntohs(p->th_sport);
2418298c17cSMark Johnston 	tcp_dport =	p == NULL ? 0  : ntohs(p->th_dport);
2428298c17cSMark Johnston 	tcp_seq =	p == NULL ? -1 : p->th_seq;
2438298c17cSMark Johnston 	tcp_ack =	p == NULL ? -1 : p->th_ack;
2448298c17cSMark Johnston 	tcp_offset =	p == NULL ? -1 : (p->th_off >> 2);
2458298c17cSMark Johnston 	tcp_flags =	p == NULL ? 0  : p->th_flags;
2468298c17cSMark Johnston 	tcp_window =	p == NULL ? 0  : (p->th_win);
2478298c17cSMark Johnston 	tcp_checksum =	p == NULL ? 0  : ntohs(p->th_sum);
2488298c17cSMark Johnston 	tcp_urgent =	p == NULL ? 0  : p->th_urp;
2498298c17cSMark Johnston 	tcp_hdr =	(struct tcphdr *)p;
2508298c17cSMark Johnston };
2518298c17cSMark Johnston 
2522f28ceebSMark Johnston #pragma D binding "1.6.3" translator
25357f60867SMark Johnston translator tcplsinfo_t < int s > {
25457f60867SMark Johnston 	tcps_state =	s;
25557f60867SMark Johnston };
256*5d06879aSGeorge V. Neville-Neil 
257*5d06879aSGeorge V. Neville-Neil 
258*5d06879aSGeorge V. Neville-Neil /* Support for TCP debug */
259*5d06879aSGeorge V. Neville-Neil 
260*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_INPUT
261*5d06879aSGeorge V. Neville-Neil inline int TA_INPUT =	0;
262*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_OUTPUT
263*5d06879aSGeorge V. Neville-Neil inline int TA_OUTPUT =	1;
264*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_USER
265*5d06879aSGeorge V. Neville-Neil inline int TA_USER =	2;
266*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_RESPOND
267*5d06879aSGeorge V. Neville-Neil inline int TA_RESPOND =	3;
268*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_DROP
269*5d06879aSGeorge V. Neville-Neil inline int TA_DROP =	4;
270*5d06879aSGeorge V. Neville-Neil 
271*5d06879aSGeorge V. Neville-Neil /* direction strings. */
272*5d06879aSGeorge V. Neville-Neil 
273*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" tcpdebug_dir_string
274*5d06879aSGeorge V. Neville-Neil inline string tcpdebug_dir_string[uint8_t direction] =
275*5d06879aSGeorge V. Neville-Neil 	direction == TA_INPUT ?	"input" :
276*5d06879aSGeorge V. Neville-Neil 	direction == TA_OUTPUT ? "output" :
277*5d06879aSGeorge V. Neville-Neil 	direction == TA_USER ? "user" :
278*5d06879aSGeorge V. Neville-Neil 	direction == TA_RESPOND ? "respond" :
279*5d06879aSGeorge V. Neville-Neil 	direction == TA_OUTPUT ? "drop" :
280*5d06879aSGeorge V. Neville-Neil 	"unknown" ;
281*5d06879aSGeorge V. Neville-Neil 
282*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" tcpflag_string
283*5d06879aSGeorge V. Neville-Neil inline string tcpflag_string[uint8_t flags] =
284*5d06879aSGeorge V. Neville-Neil 	flags & TH_FIN ?	"FIN" :
285*5d06879aSGeorge V. Neville-Neil 	flags & TH_SYN ?	"SYN" :
286*5d06879aSGeorge V. Neville-Neil 	flags & TH_RST ?	"RST" :
287*5d06879aSGeorge V. Neville-Neil 	flags & TH_PUSH ?	"PUSH" :
288*5d06879aSGeorge V. Neville-Neil 	flags & TH_ACK ?	"ACK" :
289*5d06879aSGeorge V. Neville-Neil 	flags & TH_URG ?	"URG" :
290*5d06879aSGeorge V. Neville-Neil 	flags & TH_ECE ?	"ECE" :
291*5d06879aSGeorge V. Neville-Neil 	flags & TH_CWR ?	"CWR" :
292*5d06879aSGeorge V. Neville-Neil 	"unknown" ;
293*5d06879aSGeorge V. Neville-Neil 
294*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_ATTACH
295*5d06879aSGeorge V. Neville-Neil inline int PRU_ATTACH		= 0;
296*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_DETACH
297*5d06879aSGeorge V. Neville-Neil inline int PRU_DETACH		= 1;
298*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_BIND
299*5d06879aSGeorge V. Neville-Neil inline int PRU_BIND		= 2;
300*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_LISTEN
301*5d06879aSGeorge V. Neville-Neil inline int PRU_LISTEN		= 3;
302*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CONNECT
303*5d06879aSGeorge V. Neville-Neil inline int PRU_CONNECT		= 4;
304*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_ACCEPT
305*5d06879aSGeorge V. Neville-Neil inline int PRU_ACCEPT	 = 5 ;
306*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_DISCONNECT
307*5d06879aSGeorge V. Neville-Neil inline int PRU_DISCONNECT=  6;
308*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SHUTDOWN
309*5d06879aSGeorge V. Neville-Neil inline int PRU_SHUTDOWN	 =  7;
310*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_RCVD
311*5d06879aSGeorge V. Neville-Neil inline int PRU_RCVD	 =  8;
312*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SEND
313*5d06879aSGeorge V. Neville-Neil inline int PRU_SEND	 =  9;
314*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_ABORT
315*5d06879aSGeorge V. Neville-Neil inline int PRU_ABORT	  = 10;
316*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CONTROL
317*5d06879aSGeorge V. Neville-Neil inline int PRU_CONTROL	  = 11;
318*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SENSE
319*5d06879aSGeorge V. Neville-Neil inline int PRU_SENSE	  = 12;
320*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_RCVOOB
321*5d06879aSGeorge V. Neville-Neil inline int PRU_RCVOOB	  = 13;
322*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SENDOOB
323*5d06879aSGeorge V. Neville-Neil inline int PRU_SENDOOB	  = 14;
324*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SOCKADDR
325*5d06879aSGeorge V. Neville-Neil inline int PRU_SOCKADDR	  = 15;
326*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_PEERADDR
327*5d06879aSGeorge V. Neville-Neil inline int PRU_PEERADDR	  = 16;
328*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CONNECT2
329*5d06879aSGeorge V. Neville-Neil inline int PRU_CONNECT2	  = 17;
330*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_FASTTIMO
331*5d06879aSGeorge V. Neville-Neil inline int PRU_FASTTIMO	  = 18;
332*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SLOWTIMO
333*5d06879aSGeorge V. Neville-Neil inline int PRU_SLOWTIMO	  = 19;
334*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_PROTORCV
335*5d06879aSGeorge V. Neville-Neil inline int PRU_PROTORCV	  = 20;
336*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_PROTOSEND
337*5d06879aSGeorge V. Neville-Neil inline int PRU_PROTOSEND  = 21;
338*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SEND_EOF
339*5d06879aSGeorge V. Neville-Neil inline int PRU_SEND_EOF	  = 22;
340*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SOSETLABEL
341*5d06879aSGeorge V. Neville-Neil inline int PRU_SOSETLABEL = 23;
342*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CLOSE
343*5d06879aSGeorge V. Neville-Neil inline int PRU_CLOSE	  = 24;
344*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_FLUSH
345*5d06879aSGeorge V. Neville-Neil inline int PRU_FLUSH	  = 25;
346*5d06879aSGeorge V. Neville-Neil 
347*5d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" prureq_string
348*5d06879aSGeorge V. Neville-Neil inline string prureq_string[uint8_t req] =
349*5d06879aSGeorge V. Neville-Neil 	req == PRU_ATTACH ? "ATTACH" :
350*5d06879aSGeorge V. Neville-Neil 	req == PRU_DETACH ? "DETACH" :
351*5d06879aSGeorge V. Neville-Neil 	req == PRU_BIND ? "BIND" :
352*5d06879aSGeorge V. Neville-Neil 	req == PRU_LISTEN ? "LISTEN" :
353*5d06879aSGeorge V. Neville-Neil 	req == PRU_CONNECT ? "CONNECT" :
354*5d06879aSGeorge V. Neville-Neil 	req == PRU_ACCEPT ? "ACCEPT" :
355*5d06879aSGeorge V. Neville-Neil 	req == PRU_DISCONNECT ? "DISCONNECT" :
356*5d06879aSGeorge V. Neville-Neil 	req == PRU_SHUTDOWN ? "SHUTDOWN" :
357*5d06879aSGeorge V. Neville-Neil 	req == PRU_RCVD ? "RCVD" :
358*5d06879aSGeorge V. Neville-Neil 	req == PRU_SEND ? "SEND" :
359*5d06879aSGeorge V. Neville-Neil 	req == PRU_ABORT ? "ABORT" :
360*5d06879aSGeorge V. Neville-Neil 	req == PRU_CONTROL ? "CONTROL" :
361*5d06879aSGeorge V. Neville-Neil 	req == PRU_SENSE ? "SENSE" :
362*5d06879aSGeorge V. Neville-Neil 	req == PRU_RCVOOB ? "RCVOOB" :
363*5d06879aSGeorge V. Neville-Neil 	req == PRU_SENDOOB ? "SENDOOB" :
364*5d06879aSGeorge V. Neville-Neil 	req == PRU_SOCKADDR ? "SOCKADDR" :
365*5d06879aSGeorge V. Neville-Neil 	req == PRU_PEERADDR ? "PEERADDR" :
366*5d06879aSGeorge V. Neville-Neil 	req == PRU_CONNECT2 ? "CONNECT2" :
367*5d06879aSGeorge V. Neville-Neil 	req == PRU_FASTTIMO ? "FASTTIMO" :
368*5d06879aSGeorge V. Neville-Neil 	req == PRU_SLOWTIMO ? "SLOWTIMO" :
369*5d06879aSGeorge V. Neville-Neil 	req == PRU_PROTORCV ? "PROTORCV" :
370*5d06879aSGeorge V. Neville-Neil 	req == PRU_PROTOSEND ? "PROTOSEND" :
371*5d06879aSGeorge V. Neville-Neil 	req == PRU_SEND ? "SEND_EOF" :
372*5d06879aSGeorge V. Neville-Neil 	req == PRU_SOSETLABEL ? "SOSETLABEL" :
373*5d06879aSGeorge V. Neville-Neil 	req == PRU_CLOSE ? "CLOSE" :
374*5d06879aSGeorge V. Neville-Neil 	req == PRU_FLUSH ? "FLUSE" :
375*5d06879aSGeorge V. Neville-Neil 	"unknown" ;
376