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 * Copyright (c) 2013 Mark Johnston <markj@FreeBSD.org> 24 * Copyright (c) 2018 Michael Tuexen <tuexen@FreeBSD.org> 25 */ 26 27 #pragma D depends_on library ip.d 28 #pragma D depends_on module kernel 29 #pragma D depends_on provider udplite 30 31 /* 32 * udplitesinfo contains stable UDPLite details. 33 */ 34 typedef struct udplitesinfo { 35 uintptr_t udplites_addr; 36 uint16_t udplites_lport; /* local port */ 37 uint16_t udplites_rport; /* remote port */ 38 string udplites_laddr; /* local address, as a string */ 39 string udplites_raddr; /* remote address, as a string */ 40 } udplitesinfo_t; 41 42 /* 43 * udpliteinfo is the UDPLite header fields. 44 */ 45 typedef struct udpliteinfo { 46 uint16_t udplite_sport; /* source port */ 47 uint16_t udplite_dport; /* destination port */ 48 uint16_t udplite_coverage; /* checksum coverage */ 49 uint16_t udplite_checksum; /* headers + data checksum */ 50 struct udplitehdr *udplite_hdr; /* raw UDPLite header */ 51 } udpliteinfo_t; 52 53 #pragma D binding "1.13" translator 54 translator udplitesinfo_t < struct inpcb *p > { 55 udplites_addr = (uintptr_t)p; 56 udplites_lport = p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_lport); 57 udplites_rport = p == NULL ? 0 : ntohs(p->inp_inc.inc_ie.ie_fport); 58 udplites_laddr = p == NULL ? "<unknown>" : 59 p->inp_vflag == INP_IPV4 ? 60 inet_ntoa(&p->inp_inc.inc_ie.ie_dependladdr.id46_addr.ia46_addr4.s_addr) : 61 inet_ntoa6(&p->inp_inc.inc_ie.ie_dependladdr.id6_addr); 62 udplites_raddr = p == NULL ? "<unknown>" : 63 p->inp_vflag == INP_IPV4 ? 64 inet_ntoa(&p->inp_inc.inc_ie.ie_dependfaddr.id46_addr.ia46_addr4.s_addr) : 65 inet_ntoa6(&p->inp_inc.inc_ie.ie_dependfaddr.id6_addr); 66 }; 67 68 #pragma D binding "1.13" translator 69 translator udpliteinfo_t < struct udphdr *p > { 70 udplite_sport = p == NULL ? 0 : ntohs(p->uh_sport); 71 udplite_dport = p == NULL ? 0 : ntohs(p->uh_dport); 72 udplite_coverage = p == NULL ? 0 : ntohs(p->uh_ulen); 73 udplite_checksum = p == NULL ? 0 : ntohs(p->uh_sum); 74 udplite_hdr = (struct udplitehdr *)p; 75 }; 76