xref: /titanic_50/usr/src/lib/libdtrace/common/udp.d.in (revision 356f72340a69936724c69f2f87fffa6f5887f885)
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 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25#pragma D depends_on module unix
26#pragma D depends_on provider udp
27
28inline int UDPH_SIZE = @UDPH_SIZE@;
29#pragma D binding "1.6.3" UDPH_SIZE
30
31/*
32 * udpinfo is the UDP header fields.
33 */
34typedef struct udpinfo {
35	uint16_t udp_sport;		/* source port */
36	uint16_t udp_dport;		/* destination port */
37	uint16_t udp_length;		/* total length */
38	uint16_t udp_checksum;          /* headers + data checksum */
39	udpha_t *udp_hdr;		/* raw UDP header */
40} udpinfo_t;
41
42/*
43 * udpsinfo contains stable UDP details from udp_t.
44 */
45typedef struct udpsinfo {
46	uintptr_t udps_addr;
47	uint16_t udps_lport;		/* local port */
48	uint16_t udps_rport;		/* remote port */
49	string udps_laddr;		/* local address, as a string */
50	string udps_raddr;		/* remote address, as a string */
51} udpsinfo_t;
52
53#pragma D binding "1.6.3" translator
54translator udpinfo_t < udpha_t *U > {
55	udp_sport = ntohs(U->uha_src_port);
56	udp_dport = ntohs(U->uha_dst_port);
57	udp_length = ntohs(U->uha_length);
58	udp_checksum = ntohs(U->uha_checksum);
59	udp_hdr = U;
60};
61
62#pragma D binding "1.6.3" translator
63translator udpsinfo_t < udp_t *U > {
64	udps_addr = (uintptr_t)U;
65	udps_lport = U ?
66	    ntohs(U->udp_connp->u_port.connu_ports.connu_lport) : 0;
67	udps_rport = U ?
68	    ntohs(U->udp_connp->u_port.connu_ports.connu_fport) : 0;
69	udps_laddr = U ?
70	    inet_ntoa6(&U->udp_connp->connua_v6addr.connua_laddr) : "<unknown>";
71	udps_raddr = U ?
72	    inet_ntoa6(&U->udp_connp->connua_v6addr.connua_faddr) : "<unknown>";
73};
74