1254889Smarkj/* 2254889Smarkj * CDDL HEADER START 3254889Smarkj * 4254889Smarkj * The contents of this file are subject to the terms of the 5254889Smarkj * Common Development and Distribution License (the "License"). 6254889Smarkj * You may not use this file except in compliance with the License. 7254889Smarkj * 8254889Smarkj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9254889Smarkj * or http://www.opensolaris.org/os/licensing. 10254889Smarkj * See the License for the specific language governing permissions 11254889Smarkj * and limitations under the License. 12254889Smarkj * 13254889Smarkj * When distributing Covered Code, include this CDDL HEADER in each 14254889Smarkj * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15254889Smarkj * If applicable, add the following below this CDDL HEADER, with the 16254889Smarkj * fields enclosed by brackets "[]" replaced with your own identifying 17254889Smarkj * information: Portions Copyright [yyyy] [name of copyright owner] 18254889Smarkj * 19254889Smarkj * CDDL HEADER END 20254889Smarkj * 21254889Smarkj * $FreeBSD$ 22254889Smarkj */ 23254889Smarkj/* 24254889Smarkj * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 25254889Smarkj * Copyright (c) 2013 Mark Johnston <markj@FreeBSD.org> 26254889Smarkj */ 27254889Smarkj 28254889Smarkj#pragma D depends_on library ip.d 29254889Smarkj#pragma D depends_on provider udp 30254889Smarkj 31254889Smarkj/* 32254889Smarkj * udpsinfo contains stable UDP details. 33254889Smarkj */ 34254889Smarkjtypedef struct udpsinfo { 35254889Smarkj uintptr_t udps_addr; 36254889Smarkj uint16_t udps_lport; /* local port */ 37254889Smarkj uint16_t udps_rport; /* remote port */ 38254889Smarkj string udps_laddr; /* local address, as a string */ 39254889Smarkj string udps_raddr; /* remote address, as a string */ 40254889Smarkj} udpsinfo_t; 41254889Smarkj 42254889Smarkj/* 43254889Smarkj * udpinfo is the UDP header fields. 44254889Smarkj */ 45254889Smarkjtypedef struct udpinfo { 46254889Smarkj uint16_t udp_sport; /* source port */ 47254889Smarkj uint16_t udp_dport; /* destination port */ 48254889Smarkj uint16_t udp_length; /* total length */ 49254889Smarkj uint16_t udp_checksum; /* headers + data checksum */ 50254889Smarkj struct udphdr *udp_hdr; /* raw UDP header */ 51254889Smarkj} udpinfo_t; 52254889Smarkj 53254889Smarkj#pragma D binding "1.0" translator 54254889Smarkjtranslator udpsinfo_t < struct inpcb *p > { 55254889Smarkj udps_addr = (uintptr_t)p; 56254889Smarkj udps_lport = p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_lport); 57254889Smarkj udps_rport = p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_fport); 58254889Smarkj udps_laddr = p == NULL ? "" : 59254889Smarkj p->inp_vflag == INP_IPV4 ? 60254889Smarkj inet_ntoa(&p->inp_inc.inc_ie.ie_dependladdr.ie46_local.ia46_addr4.s_addr) : 61254889Smarkj inet_ntoa6(&p->inp_inc.inc_ie.ie_dependladdr.ie6_local); 62254889Smarkj udps_raddr = p == NULL ? "" : 63254889Smarkj p->inp_vflag == INP_IPV4 ? 64254889Smarkj inet_ntoa(&p->inp_inc.inc_ie.ie_dependfaddr.ie46_foreign.ia46_addr4.s_addr) : 65254889Smarkj inet_ntoa6(&p->inp_inc.inc_ie.ie_dependfaddr.ie6_foreign); 66254889Smarkj}; 67254889Smarkj 68254889Smarkj#pragma D binding "1.0" translator 69254889Smarkjtranslator udpinfo_t < struct udphdr *p > { 70254889Smarkj udp_sport = p == NULL ? 0 : ntohs(p->uh_sport); 71254889Smarkj udp_dport = p == NULL ? 0 : ntohs(p->uh_dport); 72254889Smarkj udp_length = p == NULL ? 0 : ntohs(p->uh_ulen); 73254889Smarkj udp_checksum = p == NULL ? 0 : ntohs(p->uh_sum); 74254889Smarkj udp_hdr = p; 75254889Smarkj}; 76