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