xref: /freebsd/cddl/lib/libdtrace/siftr.d (revision d39bd2c1388b520fcba9abed1932acacead60fba)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 #pragma D depends_on library ip.d
23 #pragma D depends_on module kernel
24 #pragma D depends_on module siftr
25 #pragma D depends_on provider tcp
26 
27 /*
28  * Convert a SIFTR direction value to a string
29  */
30 #pragma D binding "1.12.1" SIFTR_IN
31 inline int SIFTR_IN =	0;
32 #pragma D binding "1.12.1" SIFTR_OUT
33 inline int SIFTR_OUT =	1;
34 
35 /* SIFTR direction strings. */
36 #pragma D binding "1.12.1" siftr_dir_string
37 inline string siftr_dir_string[uint8_t direction] =
38 	direction == SIFTR_IN ?	"in" :
39 	direction == SIFTR_OUT ? "out" :
40 	"unknown" ;
41 
42 typedef struct siftrinfo {
43 	struct timeval		tval;
44 	uint8_t			direction;
45 	uint8_t			ipver;
46 	uint16_t		lport;
47 	uint16_t		rport;
48 	string 			laddr;
49 	string 			raddr;
50 	uint32_t		snd_cwnd;
51 	uint32_t		snd_wnd;
52 	uint32_t		rcv_wnd;
53 	uint32_t		t_flags2;
54 	uint32_t		snd_ssthresh;
55 	int			conn_state;
56 	uint32_t		mss;
57 	uint32_t		srtt;
58 	u_char			sack_enabled;
59 	u_char			snd_scale;
60 	u_char			rcv_scale;
61 	u_int			t_flags;
62 	uint32_t		rto;
63 	u_int			snd_buf_hiwater;
64 	u_int			snd_buf_cc;
65 	u_int			rcv_buf_hiwater;
66 	u_int			rcv_buf_cc;
67 	u_int			sent_inflight_bytes;
68 	int			t_segqlen;
69 	u_int			flowid;
70 	u_int			flowtype;
71 } siftrinfo_t;
72 
73 #pragma D binding "1.12.1" translator
74 translator siftrinfo_t < struct pkt_node *p > {
75 	direction = 		p == NULL ? 0 : p->direction;
76 	ipver =			p == NULL ? 0 : p->ipver;
77 	lport =			p == NULL ? 0 : ntohs(p->lport);
78 	rport =			p == NULL ? 0 : ntohs(p->fport);
79 	laddr =			p == NULL ? "<unknown>" :
80 	    p->ipver == INP_IPV4 ?
81 	    inet_ntoa(&p->laddr.id46_addr.ia46_addr4.s_addr) :
82 	    inet_ntoa6(&p->laddr.id6_addr);
83 	raddr =			p == NULL ? "<unknown>" :
84 	    p->ipver == INP_IPV4 ?
85 	    inet_ntoa(&p->faddr.id46_addr.ia46_addr4.s_addr) :
86 	    inet_ntoa6(&p->faddr.id6_addr);
87 	snd_cwnd =		p == NULL ? 0 : p->snd_cwnd;
88 	snd_wnd =		p == NULL ? 0 : p->snd_wnd;
89 	rcv_wnd =		p == NULL ? 0 : p->rcv_wnd;
90 	t_flags2 =		p == NULL ? 0 : p->t_flags2;
91 	snd_ssthresh =		p == NULL ? 0 : p->snd_ssthresh;
92 	conn_state =		p == NULL ? 0 : p->conn_state;
93 	mss = 			p == NULL ? 0 : p->mss;
94 	srtt =			p == NULL ? 0 : p->srtt;
95 	sack_enabled = 		p == NULL ? 0 : p->sack_enabled;
96 	snd_scale =		p == NULL ? 0 : p->snd_scale;
97 	rcv_scale =		p == NULL ? 0 : p->rcv_scale;
98 	t_flags =		p == NULL ? 0 : p->t_flags;
99 	rto =			p == NULL ? 0 : p->rto;
100 	snd_buf_hiwater =	p == NULL ? 0 : p->snd_buf_hiwater;
101 	snd_buf_cc = 		p == NULL ? 0 : p->snd_buf_cc;
102 	rcv_buf_hiwater = 	p == NULL ? 0 : p->rcv_buf_hiwater;
103 	rcv_buf_cc = 		p == NULL ? 0 : p->rcv_buf_cc;
104 	sent_inflight_bytes = 	p == NULL ? 0 : p->sent_inflight_bytes;
105 	t_segqlen =		p == NULL ? 0 : p->t_segqlen;
106 	flowid = 		p == NULL ? 0 : p->flowid;
107 	flowtype = 		p == NULL ? 0 : p->flowtype;
108 };
109