xref: /onnv-gate/usr/src/lib/libdtrace/common/udp.d.in (revision 12507:501806a754d2)
1*12507SAlan.Maguire@Sun.COM/*
2*12507SAlan.Maguire@Sun.COM * CDDL HEADER START
3*12507SAlan.Maguire@Sun.COM *
4*12507SAlan.Maguire@Sun.COM * The contents of this file are subject to the terms of the
5*12507SAlan.Maguire@Sun.COM * Common Development and Distribution License (the "License").
6*12507SAlan.Maguire@Sun.COM * You may not use this file except in compliance with the License.
7*12507SAlan.Maguire@Sun.COM *
8*12507SAlan.Maguire@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12507SAlan.Maguire@Sun.COM * or http://www.opensolaris.org/os/licensing.
10*12507SAlan.Maguire@Sun.COM * See the License for the specific language governing permissions
11*12507SAlan.Maguire@Sun.COM * and limitations under the License.
12*12507SAlan.Maguire@Sun.COM *
13*12507SAlan.Maguire@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
14*12507SAlan.Maguire@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12507SAlan.Maguire@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
16*12507SAlan.Maguire@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
17*12507SAlan.Maguire@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
18*12507SAlan.Maguire@Sun.COM *
19*12507SAlan.Maguire@Sun.COM * CDDL HEADER END
20*12507SAlan.Maguire@Sun.COM */
21*12507SAlan.Maguire@Sun.COM/*
22*12507SAlan.Maguire@Sun.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23*12507SAlan.Maguire@Sun.COM */
24*12507SAlan.Maguire@Sun.COM
25*12507SAlan.Maguire@Sun.COM#pragma D depends_on module unix
26*12507SAlan.Maguire@Sun.COM#pragma D depends_on provider udp
27*12507SAlan.Maguire@Sun.COM
28*12507SAlan.Maguire@Sun.COMinline int UDPH_SIZE = @UDPH_SIZE@;
29*12507SAlan.Maguire@Sun.COM#pragma D binding "1.6.3" UDPH_SIZE
30*12507SAlan.Maguire@Sun.COM
31*12507SAlan.Maguire@Sun.COM/*
32*12507SAlan.Maguire@Sun.COM * udpinfo is the UDP header fields.
33*12507SAlan.Maguire@Sun.COM */
34*12507SAlan.Maguire@Sun.COMtypedef struct udpinfo {
35*12507SAlan.Maguire@Sun.COM	uint16_t udp_sport;		/* source port */
36*12507SAlan.Maguire@Sun.COM	uint16_t udp_dport;		/* destination port */
37*12507SAlan.Maguire@Sun.COM	uint16_t udp_length;		/* total length */
38*12507SAlan.Maguire@Sun.COM	uint16_t udp_checksum;          /* headers + data checksum */
39*12507SAlan.Maguire@Sun.COM	udpha_t *udp_hdr;		/* raw UDP header */
40*12507SAlan.Maguire@Sun.COM} udpinfo_t;
41*12507SAlan.Maguire@Sun.COM
42*12507SAlan.Maguire@Sun.COM/*
43*12507SAlan.Maguire@Sun.COM * udpsinfo contains stable UDP details from udp_t.
44*12507SAlan.Maguire@Sun.COM */
45*12507SAlan.Maguire@Sun.COMtypedef struct udpsinfo {
46*12507SAlan.Maguire@Sun.COM	uintptr_t udps_addr;
47*12507SAlan.Maguire@Sun.COM	uint16_t udps_lport;		/* local port */
48*12507SAlan.Maguire@Sun.COM	uint16_t udps_rport;		/* remote port */
49*12507SAlan.Maguire@Sun.COM	string udps_laddr;		/* local address, as a string */
50*12507SAlan.Maguire@Sun.COM	string udps_raddr;		/* remote address, as a string */
51*12507SAlan.Maguire@Sun.COM} udpsinfo_t;
52*12507SAlan.Maguire@Sun.COM
53*12507SAlan.Maguire@Sun.COM#pragma D binding "1.6.3" translator
54*12507SAlan.Maguire@Sun.COMtranslator udpinfo_t < udpha_t *U > {
55*12507SAlan.Maguire@Sun.COM	udp_sport = ntohs(U->uha_src_port);
56*12507SAlan.Maguire@Sun.COM	udp_dport = ntohs(U->uha_dst_port);
57*12507SAlan.Maguire@Sun.COM	udp_length = ntohs(U->uha_length);
58*12507SAlan.Maguire@Sun.COM	udp_checksum = ntohs(U->uha_checksum);
59*12507SAlan.Maguire@Sun.COM	udp_hdr = U;
60*12507SAlan.Maguire@Sun.COM};
61*12507SAlan.Maguire@Sun.COM
62*12507SAlan.Maguire@Sun.COM#pragma D binding "1.6.3" translator
63*12507SAlan.Maguire@Sun.COMtranslator udpsinfo_t < udp_t *U > {
64*12507SAlan.Maguire@Sun.COM	udps_addr = (uintptr_t)U;
65*12507SAlan.Maguire@Sun.COM	udps_lport = U ?
66*12507SAlan.Maguire@Sun.COM	    ntohs(U->udp_connp->u_port.connu_ports.connu_lport) : 0;
67*12507SAlan.Maguire@Sun.COM	udps_rport = U ?
68*12507SAlan.Maguire@Sun.COM	    ntohs(U->udp_connp->u_port.connu_ports.connu_fport) : 0;
69*12507SAlan.Maguire@Sun.COM	udps_laddr = U ?
70*12507SAlan.Maguire@Sun.COM	    inet_ntoa6(&U->udp_connp->connua_v6addr.connua_laddr) : "<unknown>";
71*12507SAlan.Maguire@Sun.COM	udps_raddr = U ?
72*12507SAlan.Maguire@Sun.COM	    inet_ntoa6(&U->udp_connp->connua_v6addr.connua_faddr) : "<unknown>";
73*12507SAlan.Maguire@Sun.COM};
74