xref: /freebsd/cddl/lib/libdtrace/tcp.d (revision 2dbc59317660f194d1b3ef0a72e1cdb273ec30b9)
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 */
105342af4d5SGeorge V. Neville-Neil 	uint32_t tcps_irs;		/* Initial sequence # received */
10657f60867SMark Johnston 	uint32_t tcps_suna;		/* sequence # sent but unacked */
1075d06879aSGeorge V. Neville-Neil 	uint32_t tcps_smax;		/* highest sequence number sent */
10857f60867SMark Johnston 	uint32_t tcps_snxt;		/* next sequence # to send */
10957f60867SMark Johnston 	uint32_t tcps_rack;		/* sequence # we have acked */
11057f60867SMark Johnston 	uint32_t tcps_rnxt;		/* next sequence # expected */
111*2dbc5931SHiren Panchasara 	u_long tcps_swnd;		/* send window size */
11257f60867SMark Johnston 	int32_t tcps_snd_ws;		/* send window scaling */
1135d06879aSGeorge V. Neville-Neil 	uint32_t tcps_swl1;		/* window update seg seq number */
1145d06879aSGeorge V. Neville-Neil 	uint32_t tcps_swl2;		/* window update seg ack number */
1155d06879aSGeorge V. Neville-Neil 	uint32_t tcps_rup;		/* receive urgent pointer */
116342af4d5SGeorge V. Neville-Neil 	uint32_t tcps_radv;		/* advertised window */
117*2dbc5931SHiren Panchasara 	u_long tcps_rwnd;		/* receive window size */
11857f60867SMark Johnston 	int32_t tcps_rcv_ws;		/* receive window scaling */
119*2dbc5931SHiren Panchasara 	u_long tcps_cwnd;		/* congestion window */
120*2dbc5931SHiren Panchasara 	u_long tcps_cwnd_ssthresh;	/* threshold for congestion avoidance */
121342af4d5SGeorge V. Neville-Neil 	uint32_t tcps_srecover;	/* for use in NewReno Fast Recovery */
12257f60867SMark Johnston 	uint32_t tcps_sack_fack;	/* SACK sequence # we have acked */
12357f60867SMark Johnston 	uint32_t tcps_sack_snxt;	/* next SACK seq # for retransmission */
12457f60867SMark Johnston 	uint32_t tcps_rto;		/* round-trip timeout, msec */
12557f60867SMark Johnston 	uint32_t tcps_mss;		/* max segment size */
12657f60867SMark Johnston 	int tcps_retransmit;		/* retransmit send event, boolean */
127bd537a28SGeorge V. Neville-Neil 	int tcps_srtt;			/* smoothed RTT in units of (TCP_RTT_SCALE*hz) */
1285d06879aSGeorge V. Neville-Neil 	int tcps_debug;		/* socket has SO_DEBUG set */
129342af4d5SGeorge V. Neville-Neil 	int32_t tcps_dupacks;	/* consecutive dup acks received */
130342af4d5SGeorge V. Neville-Neil 	uint32_t tcps_rtttime;	/* RTT measurement start time */
131342af4d5SGeorge V. Neville-Neil 	uint32_t tcps_rtseq;	/* sequence # being timed */
132342af4d5SGeorge V. Neville-Neil 	uint32_t tcps_ts_recent;	/* timestamp echo data */
13357f60867SMark Johnston } tcpsinfo_t;
13457f60867SMark Johnston 
13557f60867SMark Johnston /*
13657f60867SMark Johnston  * tcplsinfo provides the old tcp state for state changes.
13757f60867SMark Johnston  */
13857f60867SMark Johnston typedef struct tcplsinfo {
13957f60867SMark Johnston 	int32_t tcps_state;		/* previous TCP state */
14057f60867SMark Johnston } tcplsinfo_t;
14157f60867SMark Johnston 
14257f60867SMark Johnston /*
14357f60867SMark Johnston  * tcpinfo is the TCP header fields.
14457f60867SMark Johnston  */
14557f60867SMark Johnston typedef struct tcpinfo {
14657f60867SMark Johnston 	uint16_t tcp_sport;		/* source port */
14757f60867SMark Johnston 	uint16_t tcp_dport;		/* destination port */
14857f60867SMark Johnston 	uint32_t tcp_seq;		/* sequence number */
14957f60867SMark Johnston 	uint32_t tcp_ack;		/* acknowledgment number */
15057f60867SMark Johnston 	uint8_t tcp_offset;		/* data offset, in bytes */
15157f60867SMark Johnston 	uint8_t tcp_flags;		/* flags */
15257f60867SMark Johnston 	uint16_t tcp_window;		/* window size */
15357f60867SMark Johnston 	uint16_t tcp_checksum;		/* checksum */
15457f60867SMark Johnston 	uint16_t tcp_urgent;		/* urgent data pointer */
15557f60867SMark Johnston 	struct tcphdr *tcp_hdr;		/* raw TCP header */
15657f60867SMark Johnston } tcpinfo_t;
15757f60867SMark Johnston 
1588298c17cSMark Johnston /*
1598298c17cSMark Johnston  * A clone of tcpinfo_t used to handle the fact that the TCP input path
1608298c17cSMark Johnston  * overwrites some fields of the TCP header with their host-order equivalents.
1618298c17cSMark Johnston  * Unfortunately, DTrace doesn't let us simply typedef a new name for struct
1628298c17cSMark Johnston  * tcpinfo and define a separate translator for it.
1638298c17cSMark Johnston  */
1648298c17cSMark Johnston typedef struct tcpinfoh {
1658298c17cSMark Johnston 	uint16_t tcp_sport;		/* source port */
1668298c17cSMark Johnston 	uint16_t tcp_dport;		/* destination port */
1678298c17cSMark Johnston 	uint32_t tcp_seq;		/* sequence number */
1688298c17cSMark Johnston 	uint32_t tcp_ack;		/* acknowledgment number */
1698298c17cSMark Johnston 	uint8_t tcp_offset;		/* data offset, in bytes */
1708298c17cSMark Johnston 	uint8_t tcp_flags;		/* flags */
1718298c17cSMark Johnston 	uint16_t tcp_window;		/* window size */
1728298c17cSMark Johnston 	uint16_t tcp_checksum;		/* checksum */
1738298c17cSMark Johnston 	uint16_t tcp_urgent;		/* urgent data pointer */
1748298c17cSMark Johnston 	struct tcphdr *tcp_hdr;		/* raw TCP header */
1758298c17cSMark Johnston } tcpinfoh_t;
1768298c17cSMark Johnston 
1772f28ceebSMark Johnston #pragma D binding "1.6.3" translator
17857f60867SMark Johnston translator csinfo_t < struct tcpcb *p > {
17957f60867SMark Johnston 	cs_addr =	NULL;
1809feec372SMark Johnston 	cs_cid =	(uint64_t)(p == NULL ? 0 : p->t_inpcb);
18157f60867SMark Johnston 	cs_pid =	0;
18257f60867SMark Johnston 	cs_zoneid =	0;
18357f60867SMark Johnston };
18457f60867SMark Johnston 
1852f28ceebSMark Johnston #pragma D binding "1.6.3" translator
18657f60867SMark Johnston translator tcpsinfo_t < struct tcpcb *p > {
18757f60867SMark Johnston 	tcps_addr =		(uintptr_t)p;
18857f60867SMark Johnston 	tcps_local =		-1; /* XXX */
18957f60867SMark Johnston 	tcps_active =		-1; /* XXX */
19057f60867SMark Johnston 	tcps_lport =		p == NULL ? 0 : ntohs(p->t_inpcb->inp_inc.inc_ie.ie_lport);
19157f60867SMark Johnston 	tcps_rport =		p == NULL ? 0 : ntohs(p->t_inpcb->inp_inc.inc_ie.ie_fport);
19257f60867SMark Johnston 	tcps_laddr =		p == NULL ? 0 :
19357f60867SMark Johnston 	    p->t_inpcb->inp_vflag == INP_IPV4 ?
19457f60867SMark Johnston 	    inet_ntoa(&p->t_inpcb->inp_inc.inc_ie.ie_dependladdr.ie46_local.ia46_addr4.s_addr) :
19557f60867SMark Johnston 	    inet_ntoa6(&p->t_inpcb->inp_inc.inc_ie.ie_dependladdr.ie6_local);
19657f60867SMark Johnston 	tcps_raddr =		p == NULL ? 0 :
19757f60867SMark Johnston 	    p->t_inpcb->inp_vflag == INP_IPV4 ?
19857f60867SMark Johnston 	    inet_ntoa(&p->t_inpcb->inp_inc.inc_ie.ie_dependfaddr.ie46_foreign.ia46_addr4.s_addr) :
19957f60867SMark Johnston 	    inet_ntoa6(&p->t_inpcb->inp_inc.inc_ie.ie_dependfaddr.ie6_foreign);
20057f60867SMark Johnston 	tcps_state =		p == NULL ? -1 : p->t_state;
20157f60867SMark Johnston 	tcps_iss =		p == NULL ? 0  : p->iss;
202342af4d5SGeorge V. Neville-Neil 	tcps_irs =		p == NULL ? 0  : p->irs;
20357f60867SMark Johnston 	tcps_suna =		p == NULL ? 0  : p->snd_una;
2045d06879aSGeorge V. Neville-Neil 	tcps_smax =		p == NULL ? 0  : p->snd_max;
20557f60867SMark Johnston 	tcps_snxt =		p == NULL ? 0  : p->snd_nxt;
20657f60867SMark Johnston 	tcps_rack =		p == NULL ? 0  : p->last_ack_sent;
20757f60867SMark Johnston 	tcps_rnxt =		p == NULL ? 0  : p->rcv_nxt;
20857f60867SMark Johnston 	tcps_swnd =		p == NULL ? -1  : p->snd_wnd;
20957f60867SMark Johnston 	tcps_snd_ws =		p == NULL ? -1  : p->snd_scale;
2105d06879aSGeorge V. Neville-Neil 	tcps_swl1 =		p == NULL ? -1  : p->snd_wl1;
2115d06879aSGeorge V. Neville-Neil 	tcps_swl2 = 		p == NULL ? -1  : p->snd_wl2;
212342af4d5SGeorge V. Neville-Neil 	tcps_radv =		p == NULL ? -1  : p->rcv_adv;
21357f60867SMark Johnston 	tcps_rwnd =		p == NULL ? -1  : p->rcv_wnd;
2145d06879aSGeorge V. Neville-Neil 	tcps_rup =		p == NULL ? -1  : p->rcv_up;
21557f60867SMark Johnston 	tcps_rcv_ws =		p == NULL ? -1  : p->rcv_scale;
21657f60867SMark Johnston 	tcps_cwnd =		p == NULL ? -1  : p->snd_cwnd;
21757f60867SMark Johnston 	tcps_cwnd_ssthresh =	p == NULL ? -1  : p->snd_ssthresh;
218342af4d5SGeorge V. Neville-Neil 	tcps_srecover =		p == NULL ? -1  : p->snd_recover;
21957f60867SMark Johnston 	tcps_sack_fack =	p == NULL ? 0  : p->snd_fack;
22057f60867SMark Johnston 	tcps_sack_snxt =	p == NULL ? 0  : p->sack_newdata;
221fd8b318aSMark Johnston 	tcps_rto =		p == NULL ? -1 : (p->t_rxtcur * 1000) / `hz;
22257f60867SMark Johnston 	tcps_mss =		p == NULL ? -1  : p->t_maxseg;
2238298c17cSMark Johnston 	tcps_retransmit =	p == NULL ? -1 : p->t_rxtshift > 0 ? 1 : 0;
224bd537a28SGeorge V. Neville-Neil 	tcps_srtt =             p == NULL ? -1  : p->t_srtt;   /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */
2255d06879aSGeorge V. Neville-Neil 	tcps_debug =		p == NULL ? 0 :
2265d06879aSGeorge V. Neville-Neil 	    p->t_inpcb->inp_socket->so_options & 1;
227342af4d5SGeorge V. Neville-Neil 	tcps_dupacks =		p == NULL ? -1  : p->t_dupacks;
228342af4d5SGeorge V. Neville-Neil 	tcps_rtttime =		p == NULL ? -1  : p->t_rtttime;
229342af4d5SGeorge V. Neville-Neil 	tcps_rtseq =		p == NULL ? -1  : p->t_rtseq;
230342af4d5SGeorge V. Neville-Neil 	tcps_ts_recent =	p == NULL ? -1  : p->ts_recent;
23157f60867SMark Johnston };
23257f60867SMark Johnston 
2332f28ceebSMark Johnston #pragma D binding "1.6.3" translator
23457f60867SMark Johnston translator tcpinfo_t < struct tcphdr *p > {
23557f60867SMark Johnston 	tcp_sport =	p == NULL ? 0  : ntohs(p->th_sport);
23657f60867SMark Johnston 	tcp_dport =	p == NULL ? 0  : ntohs(p->th_dport);
23757f60867SMark Johnston 	tcp_seq =	p == NULL ? -1 : ntohl(p->th_seq);
23857f60867SMark Johnston 	tcp_ack =	p == NULL ? -1 : ntohl(p->th_ack);
23957f60867SMark Johnston 	tcp_offset =	p == NULL ? -1 : (p->th_off >> 2);
24057f60867SMark Johnston 	tcp_flags =	p == NULL ? 0  : p->th_flags;
24157f60867SMark Johnston 	tcp_window =	p == NULL ? 0  : ntohs(p->th_win);
24257f60867SMark Johnston 	tcp_checksum =	p == NULL ? 0  : ntohs(p->th_sum);
24357f60867SMark Johnston 	tcp_urgent =	p == NULL ? 0  : ntohs(p->th_urp);
24457f60867SMark Johnston 	tcp_hdr =	(struct tcphdr *)p;
24557f60867SMark Johnston };
24657f60867SMark Johnston 
2478298c17cSMark Johnston /*
2488298c17cSMark Johnston  * This translator differs from the one for tcpinfo_t in that the sequence
2498298c17cSMark Johnston  * number, acknowledgement number, window size and urgent pointer are already
2508298c17cSMark Johnston  * in host order and thus don't need to be converted.
2518298c17cSMark Johnston  */
2522f28ceebSMark Johnston #pragma D binding "1.6.3" translator
2538298c17cSMark Johnston translator tcpinfoh_t < struct tcphdr *p > {
2548298c17cSMark Johnston 	tcp_sport =	p == NULL ? 0  : ntohs(p->th_sport);
2558298c17cSMark Johnston 	tcp_dport =	p == NULL ? 0  : ntohs(p->th_dport);
2568298c17cSMark Johnston 	tcp_seq =	p == NULL ? -1 : p->th_seq;
2578298c17cSMark Johnston 	tcp_ack =	p == NULL ? -1 : p->th_ack;
2588298c17cSMark Johnston 	tcp_offset =	p == NULL ? -1 : (p->th_off >> 2);
2598298c17cSMark Johnston 	tcp_flags =	p == NULL ? 0  : p->th_flags;
2608298c17cSMark Johnston 	tcp_window =	p == NULL ? 0  : (p->th_win);
2618298c17cSMark Johnston 	tcp_checksum =	p == NULL ? 0  : ntohs(p->th_sum);
2628298c17cSMark Johnston 	tcp_urgent =	p == NULL ? 0  : p->th_urp;
2638298c17cSMark Johnston 	tcp_hdr =	(struct tcphdr *)p;
2648298c17cSMark Johnston };
2658298c17cSMark Johnston 
2662f28ceebSMark Johnston #pragma D binding "1.6.3" translator
26757f60867SMark Johnston translator tcplsinfo_t < int s > {
26857f60867SMark Johnston 	tcps_state =	s;
26957f60867SMark Johnston };
2705d06879aSGeorge V. Neville-Neil 
2715d06879aSGeorge V. Neville-Neil 
2725d06879aSGeorge V. Neville-Neil /* Support for TCP debug */
2735d06879aSGeorge V. Neville-Neil 
2745d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_INPUT
2755d06879aSGeorge V. Neville-Neil inline int TA_INPUT =	0;
2765d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_OUTPUT
2775d06879aSGeorge V. Neville-Neil inline int TA_OUTPUT =	1;
2785d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_USER
2795d06879aSGeorge V. Neville-Neil inline int TA_USER =	2;
2805d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_RESPOND
2815d06879aSGeorge V. Neville-Neil inline int TA_RESPOND =	3;
2825d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" TA_DROP
2835d06879aSGeorge V. Neville-Neil inline int TA_DROP =	4;
2845d06879aSGeorge V. Neville-Neil 
2855d06879aSGeorge V. Neville-Neil /* direction strings. */
2865d06879aSGeorge V. Neville-Neil 
2875d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" tcpdebug_dir_string
2885d06879aSGeorge V. Neville-Neil inline string tcpdebug_dir_string[uint8_t direction] =
2895d06879aSGeorge V. Neville-Neil 	direction == TA_INPUT ?	"input" :
2905d06879aSGeorge V. Neville-Neil 	direction == TA_OUTPUT ? "output" :
2915d06879aSGeorge V. Neville-Neil 	direction == TA_USER ? "user" :
2925d06879aSGeorge V. Neville-Neil 	direction == TA_RESPOND ? "respond" :
2935d06879aSGeorge V. Neville-Neil 	direction == TA_OUTPUT ? "drop" :
2945d06879aSGeorge V. Neville-Neil 	"unknown" ;
2955d06879aSGeorge V. Neville-Neil 
2965d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" tcpflag_string
2975d06879aSGeorge V. Neville-Neil inline string tcpflag_string[uint8_t flags] =
2985d06879aSGeorge V. Neville-Neil 	flags & TH_FIN ?	"FIN" :
2995d06879aSGeorge V. Neville-Neil 	flags & TH_SYN ?	"SYN" :
3005d06879aSGeorge V. Neville-Neil 	flags & TH_RST ?	"RST" :
3015d06879aSGeorge V. Neville-Neil 	flags & TH_PUSH ?	"PUSH" :
3025d06879aSGeorge V. Neville-Neil 	flags & TH_ACK ?	"ACK" :
3035d06879aSGeorge V. Neville-Neil 	flags & TH_URG ?	"URG" :
3045d06879aSGeorge V. Neville-Neil 	flags & TH_ECE ?	"ECE" :
3055d06879aSGeorge V. Neville-Neil 	flags & TH_CWR ?	"CWR" :
3065d06879aSGeorge V. Neville-Neil 	"unknown" ;
3075d06879aSGeorge V. Neville-Neil 
3085d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_ATTACH
3095d06879aSGeorge V. Neville-Neil inline int PRU_ATTACH		= 0;
3105d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_DETACH
3115d06879aSGeorge V. Neville-Neil inline int PRU_DETACH		= 1;
3125d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_BIND
3135d06879aSGeorge V. Neville-Neil inline int PRU_BIND		= 2;
3145d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_LISTEN
3155d06879aSGeorge V. Neville-Neil inline int PRU_LISTEN		= 3;
3165d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CONNECT
3175d06879aSGeorge V. Neville-Neil inline int PRU_CONNECT		= 4;
3185d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_ACCEPT
3195d06879aSGeorge V. Neville-Neil inline int PRU_ACCEPT	 = 5 ;
3205d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_DISCONNECT
3215d06879aSGeorge V. Neville-Neil inline int PRU_DISCONNECT=  6;
3225d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SHUTDOWN
3235d06879aSGeorge V. Neville-Neil inline int PRU_SHUTDOWN	 =  7;
3245d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_RCVD
3255d06879aSGeorge V. Neville-Neil inline int PRU_RCVD	 =  8;
3265d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SEND
3275d06879aSGeorge V. Neville-Neil inline int PRU_SEND	 =  9;
3285d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_ABORT
3295d06879aSGeorge V. Neville-Neil inline int PRU_ABORT	  = 10;
3305d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CONTROL
3315d06879aSGeorge V. Neville-Neil inline int PRU_CONTROL	  = 11;
3325d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SENSE
3335d06879aSGeorge V. Neville-Neil inline int PRU_SENSE	  = 12;
3345d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_RCVOOB
3355d06879aSGeorge V. Neville-Neil inline int PRU_RCVOOB	  = 13;
3365d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SENDOOB
3375d06879aSGeorge V. Neville-Neil inline int PRU_SENDOOB	  = 14;
3385d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SOCKADDR
3395d06879aSGeorge V. Neville-Neil inline int PRU_SOCKADDR	  = 15;
3405d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_PEERADDR
3415d06879aSGeorge V. Neville-Neil inline int PRU_PEERADDR	  = 16;
3425d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CONNECT2
3435d06879aSGeorge V. Neville-Neil inline int PRU_CONNECT2	  = 17;
3445d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_FASTTIMO
3455d06879aSGeorge V. Neville-Neil inline int PRU_FASTTIMO	  = 18;
3465d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SLOWTIMO
3475d06879aSGeorge V. Neville-Neil inline int PRU_SLOWTIMO	  = 19;
3485d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_PROTORCV
3495d06879aSGeorge V. Neville-Neil inline int PRU_PROTORCV	  = 20;
3505d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_PROTOSEND
3515d06879aSGeorge V. Neville-Neil inline int PRU_PROTOSEND  = 21;
3525d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SEND_EOF
3535d06879aSGeorge V. Neville-Neil inline int PRU_SEND_EOF	  = 22;
3545d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_SOSETLABEL
3555d06879aSGeorge V. Neville-Neil inline int PRU_SOSETLABEL = 23;
3565d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_CLOSE
3575d06879aSGeorge V. Neville-Neil inline int PRU_CLOSE	  = 24;
3585d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" PRU_FLUSH
3595d06879aSGeorge V. Neville-Neil inline int PRU_FLUSH	  = 25;
3605d06879aSGeorge V. Neville-Neil 
3615d06879aSGeorge V. Neville-Neil #pragma D binding "1.12.1" prureq_string
3625d06879aSGeorge V. Neville-Neil inline string prureq_string[uint8_t req] =
3635d06879aSGeorge V. Neville-Neil 	req == PRU_ATTACH ? "ATTACH" :
3645d06879aSGeorge V. Neville-Neil 	req == PRU_DETACH ? "DETACH" :
3655d06879aSGeorge V. Neville-Neil 	req == PRU_BIND ? "BIND" :
3665d06879aSGeorge V. Neville-Neil 	req == PRU_LISTEN ? "LISTEN" :
3675d06879aSGeorge V. Neville-Neil 	req == PRU_CONNECT ? "CONNECT" :
3685d06879aSGeorge V. Neville-Neil 	req == PRU_ACCEPT ? "ACCEPT" :
3695d06879aSGeorge V. Neville-Neil 	req == PRU_DISCONNECT ? "DISCONNECT" :
3705d06879aSGeorge V. Neville-Neil 	req == PRU_SHUTDOWN ? "SHUTDOWN" :
3715d06879aSGeorge V. Neville-Neil 	req == PRU_RCVD ? "RCVD" :
3725d06879aSGeorge V. Neville-Neil 	req == PRU_SEND ? "SEND" :
3735d06879aSGeorge V. Neville-Neil 	req == PRU_ABORT ? "ABORT" :
3745d06879aSGeorge V. Neville-Neil 	req == PRU_CONTROL ? "CONTROL" :
3755d06879aSGeorge V. Neville-Neil 	req == PRU_SENSE ? "SENSE" :
3765d06879aSGeorge V. Neville-Neil 	req == PRU_RCVOOB ? "RCVOOB" :
3775d06879aSGeorge V. Neville-Neil 	req == PRU_SENDOOB ? "SENDOOB" :
3785d06879aSGeorge V. Neville-Neil 	req == PRU_SOCKADDR ? "SOCKADDR" :
3795d06879aSGeorge V. Neville-Neil 	req == PRU_PEERADDR ? "PEERADDR" :
3805d06879aSGeorge V. Neville-Neil 	req == PRU_CONNECT2 ? "CONNECT2" :
3815d06879aSGeorge V. Neville-Neil 	req == PRU_FASTTIMO ? "FASTTIMO" :
3825d06879aSGeorge V. Neville-Neil 	req == PRU_SLOWTIMO ? "SLOWTIMO" :
3835d06879aSGeorge V. Neville-Neil 	req == PRU_PROTORCV ? "PROTORCV" :
3845d06879aSGeorge V. Neville-Neil 	req == PRU_PROTOSEND ? "PROTOSEND" :
3855d06879aSGeorge V. Neville-Neil 	req == PRU_SEND ? "SEND_EOF" :
3865d06879aSGeorge V. Neville-Neil 	req == PRU_SOSETLABEL ? "SOSETLABEL" :
3875d06879aSGeorge V. Neville-Neil 	req == PRU_CLOSE ? "CLOSE" :
3885d06879aSGeorge V. Neville-Neil 	req == PRU_FLUSH ? "FLUSE" :
3895d06879aSGeorge V. Neville-Neil 	"unknown" ;
390