xref: /freebsd/cddl/lib/libdtrace/udplite.d (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
1*7bda9663SMichael Tuexen /*
2*7bda9663SMichael Tuexen  * CDDL HEADER START
3*7bda9663SMichael Tuexen  *
4*7bda9663SMichael Tuexen  * The contents of this file are subject to the terms of the
5*7bda9663SMichael Tuexen  * Common Development and Distribution License (the "License").
6*7bda9663SMichael Tuexen  * You may not use this file except in compliance with the License.
7*7bda9663SMichael Tuexen  *
8*7bda9663SMichael Tuexen  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7bda9663SMichael Tuexen  * or http://www.opensolaris.org/os/licensing.
10*7bda9663SMichael Tuexen  * See the License for the specific language governing permissions
11*7bda9663SMichael Tuexen  * and limitations under the License.
12*7bda9663SMichael Tuexen  *
13*7bda9663SMichael Tuexen  * When distributing Covered Code, include this CDDL HEADER in each
14*7bda9663SMichael Tuexen  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7bda9663SMichael Tuexen  * If applicable, add the following below this CDDL HEADER, with the
16*7bda9663SMichael Tuexen  * fields enclosed by brackets "[]" replaced with your own identifying
17*7bda9663SMichael Tuexen  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7bda9663SMichael Tuexen  *
19*7bda9663SMichael Tuexen  * CDDL HEADER END
20*7bda9663SMichael Tuexen  */
21*7bda9663SMichael Tuexen /*
22*7bda9663SMichael Tuexen  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23*7bda9663SMichael Tuexen  * Copyright (c) 2013 Mark Johnston <markj@FreeBSD.org>
24*7bda9663SMichael Tuexen  * Copyright (c) 2018 Michael Tuexen <tuexen@FreeBSD.org>
25*7bda9663SMichael Tuexen  */
26*7bda9663SMichael Tuexen 
27*7bda9663SMichael Tuexen #pragma D depends_on library ip.d
28*7bda9663SMichael Tuexen #pragma D depends_on module kernel
29*7bda9663SMichael Tuexen #pragma D depends_on provider udplite
30*7bda9663SMichael Tuexen 
31*7bda9663SMichael Tuexen /*
32*7bda9663SMichael Tuexen  * udplitesinfo contains stable UDPLite details.
33*7bda9663SMichael Tuexen  */
34*7bda9663SMichael Tuexen typedef struct udplitesinfo {
35*7bda9663SMichael Tuexen 	uintptr_t udplites_addr;
36*7bda9663SMichael Tuexen 	uint16_t udplites_lport;	/* local port */
37*7bda9663SMichael Tuexen 	uint16_t udplites_rport;	/* remote port */
38*7bda9663SMichael Tuexen 	string udplites_laddr;		/* local address, as a string */
39*7bda9663SMichael Tuexen 	string udplites_raddr;		/* remote address, as a string */
40*7bda9663SMichael Tuexen } udplitesinfo_t;
41*7bda9663SMichael Tuexen 
42*7bda9663SMichael Tuexen /*
43*7bda9663SMichael Tuexen  * udpliteinfo is the UDPLite header fields.
44*7bda9663SMichael Tuexen  */
45*7bda9663SMichael Tuexen typedef struct udpliteinfo {
46*7bda9663SMichael Tuexen 	uint16_t udplite_sport;		/* source port */
47*7bda9663SMichael Tuexen 	uint16_t udplite_dport;		/* destination port */
48*7bda9663SMichael Tuexen 	uint16_t udplite_coverage;	/* checksum coverage */
49*7bda9663SMichael Tuexen 	uint16_t udplite_checksum;	/* headers + data checksum */
50*7bda9663SMichael Tuexen 	struct udplitehdr *udplite_hdr;	/* raw UDPLite header */
51*7bda9663SMichael Tuexen } udpliteinfo_t;
52*7bda9663SMichael Tuexen 
53*7bda9663SMichael Tuexen #pragma D binding "1.13" translator
54*7bda9663SMichael Tuexen translator udplitesinfo_t < struct inpcb *p > {
55*7bda9663SMichael Tuexen 	udplites_addr =	(uintptr_t)p;
56*7bda9663SMichael Tuexen 	udplites_lport =	p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_lport);
57*7bda9663SMichael Tuexen 	udplites_rport =	p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_fport);
58*7bda9663SMichael Tuexen 	udplites_laddr =	p == NULL ? "<unknown>" :
59*7bda9663SMichael Tuexen 	    p->inp_vflag == INP_IPV4 ?
60*7bda9663SMichael Tuexen 	    inet_ntoa(&p->inp_inc.inc_ie.ie_dependladdr.id46_addr.ia46_addr4.s_addr) :
61*7bda9663SMichael Tuexen 	    inet_ntoa6(&p->inp_inc.inc_ie.ie_dependladdr.id6_addr);
62*7bda9663SMichael Tuexen 	udplites_raddr =	p == NULL ? "<unknown>" :
63*7bda9663SMichael Tuexen 	    p->inp_vflag == INP_IPV4 ?
64*7bda9663SMichael Tuexen 	    inet_ntoa(&p->inp_inc.inc_ie.ie_dependfaddr.id46_addr.ia46_addr4.s_addr) :
65*7bda9663SMichael Tuexen 	    inet_ntoa6(&p->inp_inc.inc_ie.ie_dependfaddr.id6_addr);
66*7bda9663SMichael Tuexen };
67*7bda9663SMichael Tuexen 
68*7bda9663SMichael Tuexen #pragma D binding "1.13" translator
69*7bda9663SMichael Tuexen translator udpliteinfo_t < struct udphdr *p > {
70*7bda9663SMichael Tuexen 	udplite_sport =		p == NULL ? 0 : ntohs(p->uh_sport);
71*7bda9663SMichael Tuexen 	udplite_dport =		p == NULL ? 0 : ntohs(p->uh_dport);
72*7bda9663SMichael Tuexen 	udplite_coverage =	p == NULL ? 0 : ntohs(p->uh_ulen);
73*7bda9663SMichael Tuexen 	udplite_checksum =	p == NULL ? 0 : ntohs(p->uh_sum);
74*7bda9663SMichael Tuexen 	udplite_hdr =		(struct udplitehdr *)p;
75*7bda9663SMichael Tuexen };
76