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 * $FreeBSD$ 22 */ 23 /* 24 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 25 * Copyright (c) 2013 Mark Johnston <markj@FreeBSD.org> 26 */ 27 28 #pragma D depends_on library ip.d 29 #pragma D depends_on provider udp 30 31 /* 32 * udpsinfo contains stable UDP details. 33 */ 34 typedef struct udpsinfo { 35 uintptr_t udps_addr; 36 uint16_t udps_lport; /* local port */ 37 uint16_t udps_rport; /* remote port */ 38 string udps_laddr; /* local address, as a string */ 39 string udps_raddr; /* remote address, as a string */ 40 } udpsinfo_t; 41 42 /* 43 * udpinfo is the UDP header fields. 44 */ 45 typedef struct udpinfo { 46 uint16_t udp_sport; /* source port */ 47 uint16_t udp_dport; /* destination port */ 48 uint16_t udp_length; /* total length */ 49 uint16_t udp_checksum; /* headers + data checksum */ 50 struct udphdr *udp_hdr; /* raw UDP header */ 51 } udpinfo_t; 52 53 #pragma D binding "1.6.3" translator 54 translator udpsinfo_t < struct inpcb *p > { 55 udps_addr = (uintptr_t)p; 56 udps_lport = p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_lport); 57 udps_rport = p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_fport); 58 udps_laddr = p == NULL ? "" : 59 p->inp_vflag == INP_IPV4 ? 60 inet_ntoa(&p->inp_inc.inc_ie.ie_dependladdr.ie46_local.ia46_addr4.s_addr) : 61 inet_ntoa6(&p->inp_inc.inc_ie.ie_dependladdr.ie6_local); 62 udps_raddr = p == NULL ? "" : 63 p->inp_vflag == INP_IPV4 ? 64 inet_ntoa(&p->inp_inc.inc_ie.ie_dependfaddr.ie46_foreign.ia46_addr4.s_addr) : 65 inet_ntoa6(&p->inp_inc.inc_ie.ie_dependfaddr.ie6_foreign); 66 }; 67 68 #pragma D binding "1.6.3" translator 69 translator udpinfo_t < struct udphdr *p > { 70 udp_sport = p == NULL ? 0 : ntohs(p->uh_sport); 71 udp_dport = p == NULL ? 0 : ntohs(p->uh_dport); 72 udp_length = p == NULL ? 0 : ntohs(p->uh_ulen); 73 udp_checksum = p == NULL ? 0 : ntohs(p->uh_sum); 74 udp_hdr = p; 75 }; 76