xref: /onnv-gate/usr/src/lib/libdtrace/common/ip.d.in (revision 12507:501806a754d2)
14291Sbrendan/*
24291Sbrendan * CDDL HEADER START
34291Sbrendan *
44291Sbrendan * The contents of this file are subject to the terms of the
54291Sbrendan * Common Development and Distribution License (the "License").
64291Sbrendan * You may not use this file except in compliance with the License.
74291Sbrendan *
84291Sbrendan * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
94291Sbrendan * or http://www.opensolaris.org/os/licensing.
104291Sbrendan * See the License for the specific language governing permissions
114291Sbrendan * and limitations under the License.
124291Sbrendan *
134291Sbrendan * When distributing Covered Code, include this CDDL HEADER in each
144291Sbrendan * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
154291Sbrendan * If applicable, add the following below this CDDL HEADER, with the
164291Sbrendan * fields enclosed by brackets "[]" replaced with your own identifying
174291Sbrendan * information: Portions Copyright [yyyy] [name of copyright owner]
184291Sbrendan *
194291Sbrendan * CDDL HEADER END
204291Sbrendan */
214291Sbrendan/*
22*12507SAlan.Maguire@Sun.COM * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
234291Sbrendan */
244291Sbrendan
256878Sbrendan#pragma D depends_on module ip
266878Sbrendan#pragma D depends_on provider ip
276878Sbrendan
286878Sbrendaninline int IPH_DF = @IPH_DF@;
2911237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPH_DF
306878Sbrendaninline int IPH_MF = @IPH_MF@;
3111237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPH_MF
326878Sbrendan
3311237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_IP
346878Sbrendaninline int IPPROTO_IP = @IPPROTO_IP@;
3511237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_HOPOPTS
366878Sbrendaninline int IPPROTO_HOPOPTS = @IPPROTO_HOPOPTS@;
3711237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_ICMP
386878Sbrendaninline int IPPROTO_ICMP = @IPPROTO_ICMP@;
3911237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_IGMP
406878Sbrendaninline int IPPROTO_IGMP = @IPPROTO_IGMP@;
4111237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_GGP
426878Sbrendaninline int IPPROTO_GGP = @IPPROTO_GGP@;
4311237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_ENCAP
446878Sbrendaninline int IPPROTO_ENCAP = @IPPROTO_ENCAP@;
4511237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_TCP
466878Sbrendaninline int IPPROTO_TCP = @IPPROTO_TCP@;
4711237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_EGP
486878Sbrendaninline int IPPROTO_EGP = @IPPROTO_EGP@;
4911237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_PUP
506878Sbrendaninline int IPPROTO_PUP = @IPPROTO_PUP@;
5111237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_UDP
526878Sbrendaninline int IPPROTO_UDP = @IPPROTO_UDP@;
5311237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_IDP
546878Sbrendaninline int IPPROTO_IDP = @IPPROTO_IDP@;
5511237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_IPV6
566878Sbrendaninline int IPPROTO_IPV6 = @IPPROTO_IPV6@;
5711237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_ROUTING
586878Sbrendaninline int IPPROTO_ROUTING = @IPPROTO_ROUTING@;
5911237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_FRAGMENT
606878Sbrendaninline int IPPROTO_FRAGMENT = @IPPROTO_FRAGMENT@;
6111237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_RSVP
626878Sbrendaninline int IPPROTO_RSVP = @IPPROTO_RSVP@;
6311237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_ESP
646878Sbrendaninline int IPPROTO_ESP = @IPPROTO_ESP@;
6511237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_AH
666878Sbrendaninline int IPPROTO_AH = @IPPROTO_AH@;
6711237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_ICMPV6
686878Sbrendaninline int IPPROTO_ICMPV6 = @IPPROTO_ICMPV6@;
6911237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_NONE
706878Sbrendaninline int IPPROTO_NONE = @IPPROTO_NONE@;
7111237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_DSTOPTS
726878Sbrendaninline int IPPROTO_DSTOPTS = @IPPROTO_DSTOPTS@;
7311237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_HELLO
746878Sbrendaninline int IPPROTO_HELLO = @IPPROTO_HELLO@;
7511237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_ND
766878Sbrendaninline int IPPROTO_ND = @IPPROTO_ND@;
7711237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_EON
786878Sbrendaninline int IPPROTO_EON = @IPPROTO_EON@;
7911237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_OSPF
806878Sbrendaninline int IPPROTO_OSPF = @IPPROTO_OSPF@;
8111237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_PIM
826878Sbrendaninline int IPPROTO_PIM = @IPPROTO_PIM@;
8311237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_SCTP
846878Sbrendaninline int IPPROTO_SCTP = @IPPROTO_SCTP@;
8511237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_RAW
866878Sbrendaninline int IPPROTO_RAW = @IPPROTO_RAW@;
8711237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" IPPROTO_MAX
886878Sbrendaninline int IPPROTO_MAX = @IPPROTO_MAX@;
896878Sbrendan
906878Sbrendan/*
916878Sbrendan * pktinfo is where packet ID info can be made available for deeper
926878Sbrendan * analysis if packet IDs become supported by the kernel in the future.
936878Sbrendan * The pkt_addr member is currently always NULL.
946878Sbrendan */
956878Sbrendantypedef struct pktinfo {
966878Sbrendan	uintptr_t pkt_addr;
976878Sbrendan} pktinfo_t;
986878Sbrendan
996878Sbrendan/*
100*12507SAlan.Maguire@Sun.COM * csinfo is where connection state info is made available.
1016878Sbrendan */
1026878Sbrendantypedef struct csinfo {
1036878Sbrendan	uintptr_t cs_addr;
104*12507SAlan.Maguire@Sun.COM	uint64_t cs_cid;
105*12507SAlan.Maguire@Sun.COM	pid_t cs_pid;
106*12507SAlan.Maguire@Sun.COM	zoneid_t cs_zoneid;
1076878Sbrendan} csinfo_t;
1086878Sbrendan
1096878Sbrendan/*
1106878Sbrendan * ipinfo contains common IP info for both IPv4 and IPv6.
1116878Sbrendan */
1126878Sbrendantypedef struct ipinfo {
1136878Sbrendan	uint8_t ip_ver;			/* IP version (4, 6) */
1146878Sbrendan	uint32_t ip_plength;		/* payload length */
1156878Sbrendan	string ip_saddr;		/* source address */
1166878Sbrendan	string ip_daddr;		/* destination address */
1176878Sbrendan} ipinfo_t;
1186878Sbrendan
1196878Sbrendan/*
1206878Sbrendan * ifinfo contains network interface info.
1216878Sbrendan */
1226878Sbrendantypedef struct ifinfo {
1236878Sbrendan	string if_name;			/* interface name */
1246878Sbrendan	int8_t if_local;		/* is delivered locally */
1256878Sbrendan	netstackid_t if_ipstack;	/* ipstack ID */
1266878Sbrendan	uintptr_t if_addr;		/* pointer to raw ill_t */
1276878Sbrendan} ifinfo_t;
1286878Sbrendan
1296878Sbrendan/*
1306878Sbrendan * ipv4info is a translated version of the IPv4 header (with raw pointer).
1316878Sbrendan * These values are NULL if the packet is not IPv4.
1326878Sbrendan */
1336878Sbrendantypedef struct ipv4info {
1346878Sbrendan	uint8_t ipv4_ver;		/* IP version (4) */
1356878Sbrendan	uint8_t ipv4_ihl;		/* header length, bytes */
1366878Sbrendan	uint8_t ipv4_tos;		/* type of service field */
1376878Sbrendan	uint16_t ipv4_length;		/* length (header + payload) */
1386878Sbrendan	uint16_t ipv4_ident;		/* identification */
1396878Sbrendan	uint8_t ipv4_flags;		/* IP flags */
1406878Sbrendan	uint16_t ipv4_offset;		/* fragment offset */
1416878Sbrendan	uint8_t ipv4_ttl;		/* time to live */
1426878Sbrendan	uint8_t ipv4_protocol;		/* next level protocol */
1436878Sbrendan	string ipv4_protostr;		/* next level protocol, as a string */
1446878Sbrendan	uint16_t ipv4_checksum;		/* header checksum */
1456878Sbrendan	ipaddr_t ipv4_src;		/* source address */
1466878Sbrendan	ipaddr_t ipv4_dst;		/* destination address */
1476878Sbrendan	string ipv4_saddr;		/* source address, string */
1486878Sbrendan	string ipv4_daddr;		/* destination address, string */
1496878Sbrendan	ipha_t *ipv4_hdr;		/* pointer to raw header */
1506878Sbrendan} ipv4info_t;
1516878Sbrendan
1526878Sbrendan/*
1536878Sbrendan * ipv6info is a translated version of the IPv6 header (with raw pointer).
1546878Sbrendan * These values are NULL if the packet is not IPv6.
1556878Sbrendan */
1566878Sbrendantypedef struct ipv6info {
1576878Sbrendan	uint8_t ipv6_ver;		/* IP version (6) */
1586878Sbrendan	uint8_t ipv6_tclass;		/* traffic class */
1596878Sbrendan	uint32_t ipv6_flow;		/* flow label */
1606878Sbrendan	uint16_t ipv6_plen;		/* payload length */
1616878Sbrendan	uint8_t ipv6_nexthdr;		/* next header protocol */
1626878Sbrendan	string ipv6_nextstr;		/* next header protocol, as a string */
1636878Sbrendan	uint8_t ipv6_hlim;		/* hop limit */
1646878Sbrendan	in6_addr_t *ipv6_src;		/* source address */
1656878Sbrendan	in6_addr_t *ipv6_dst;		/* destination address */
1666878Sbrendan	string ipv6_saddr;		/* source address, string */
1676878Sbrendan	string ipv6_daddr;		/* destination address, string */
1686878Sbrendan	ip6_t *ipv6_hdr;		/* pointer to raw header */
1696878Sbrendan} ipv6info_t;
1706878Sbrendan
1716878Sbrendan/*
1726878Sbrendan * void_ip_t is a void pointer to either an IPv4 or IPv6 header.  It has
1736878Sbrendan * its own type name so that a translator can be determined.
1746878Sbrendan */
1756878Sbrendantypedef uintptr_t void_ip_t;
1766878Sbrendan
1776878Sbrendan/*
1786878Sbrendan * __dtrace_ipsr_ill_t is used by the translator to take an ill_t plus an
1796878Sbrendan * additional arg6 from the ip:::send and ip:::recieve probes, and translate
1806878Sbrendan * them to an ifinfo_t.
1816878Sbrendan */
1826878Sbrendantypedef ill_t __dtrace_ipsr_ill_t;
1836878Sbrendan
184*12507SAlan.Maguire@Sun.COM/*
185*12507SAlan.Maguire@Sun.COM * __dtrace_tcp_void_ip_t is used by the translator to take either the
186*12507SAlan.Maguire@Sun.COM * non-NULL void_ip_t * passed in or, if it is NULL, uses arg3 (tcp_t *)
187*12507SAlan.Maguire@Sun.COM * from the tcp:::send and tcp:::recieve probes to translate to an ipinfo_t.
188*12507SAlan.Maguire@Sun.COM * When no headers are available in the TCP fusion case for tcp:::send
189*12507SAlan.Maguire@Sun.COM * and tcp:::receive case, this allows us to present the consumer with header
190*12507SAlan.Maguire@Sun.COM * data based on the tcp_t * content in order to hide the implementation
191*12507SAlan.Maguire@Sun.COM * details of TCP fusion.
192*12507SAlan.Maguire@Sun.COM */
193*12507SAlan.Maguire@Sun.COMtypedef void * __dtrace_tcp_void_ip_t;
194*12507SAlan.Maguire@Sun.COM
19511237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" translator
1966878Sbrendantranslator pktinfo_t < mblk_t *M > {
1976878Sbrendan	pkt_addr = NULL;
1986878Sbrendan};
1996878Sbrendan
20011237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" translator
2016878Sbrendantranslator csinfo_t < conn_t *C > {
2026878Sbrendan	cs_addr = NULL;
2036878Sbrendan};
2046878Sbrendan
205*12507SAlan.Maguire@Sun.COM#pragma D binding "1.6.3" translator
206*12507SAlan.Maguire@Sun.COMtranslator csinfo_t < ip_xmit_attr_t *C > {
207*12507SAlan.Maguire@Sun.COM	cs_addr = (uintptr_t)C;
208*12507SAlan.Maguire@Sun.COM	cs_cid = C ? C->ixa_conn_id : NULL;
209*12507SAlan.Maguire@Sun.COM	cs_pid = C ? C->ixa_cpid : -1;
210*12507SAlan.Maguire@Sun.COM	cs_zoneid = C ?
211*12507SAlan.Maguire@Sun.COM	    (C->ixa_ipst == NULL || C->ixa_ipst->ips_netstack == NULL ||
212*12507SAlan.Maguire@Sun.COM	    C->ixa_ipst->ips_netstack->netstack_stackid ==
213*12507SAlan.Maguire@Sun.COM	    @GLOBAL_NETSTACKID@ ||
214*12507SAlan.Maguire@Sun.COM	    C->ixa_cred == NULL ||
215*12507SAlan.Maguire@Sun.COM	    C->ixa_cred->cr_zone == NULL ||
216*12507SAlan.Maguire@Sun.COM	    C->ixa_cred->cr_uid == -1 ?
217*12507SAlan.Maguire@Sun.COM	    C->ixa_zoneid : C->ixa_cred->cr_zone->zone_id) : -1;
218*12507SAlan.Maguire@Sun.COM};
219*12507SAlan.Maguire@Sun.COM
22011237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" translator
2216878Sbrendantranslator ipinfo_t < ipha_t *I > {
2226878Sbrendan	ip_ver = I->ipha_version_and_hdr_length >> 4;
2236878Sbrendan	ip_plength = ntohs(I->ipha_length) -
2246878Sbrendan	    ((I->ipha_version_and_hdr_length & 0xf) << 2);
2256878Sbrendan	ip_saddr = inet_ntoa(&I->ipha_src);
2266878Sbrendan	ip_daddr = inet_ntoa(&I->ipha_dst);
2276878Sbrendan};
2286878Sbrendan
22911237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" translator
2306878Sbrendantranslator ipinfo_t < ip6_t *I > {
2316878Sbrendan	ip_ver = *(uint8_t *)I >> 4;
2326878Sbrendan	ip_plength = ntohs(I->ip6_ctlun.ip6_un1.ip6_un1_plen);
2336878Sbrendan	ip_saddr = inet_ntoa6(&I->ip6_src);
2346878Sbrendan	ip_daddr = inet_ntoa6(&I->ip6_dst);
2356878Sbrendan};
2366878Sbrendan
23711237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" translator
2386878Sbrendantranslator ipinfo_t < void_ip_t *I > {
2396878Sbrendan	ip_ver = I != NULL ? *(uint8_t *)I >> 4 : 0;
2406878Sbrendan	ip_plength = I != NULL ? (*(uint8_t *)I >> 4 == 4 ?
2416878Sbrendan	    ntohs(((ipha_t *)I)->ipha_length) -
2426878Sbrendan	    ((((ipha_t *)I)->ipha_version_and_hdr_length & 0xf) << 2) :
2436878Sbrendan	    *(uint8_t *)I >> 4 == 6 ?
2446878Sbrendan	    ntohs(((ip6_t *)I)->ip6_ctlun.ip6_un1.ip6_un1_plen) : 0) : 0;
2456878Sbrendan	ip_saddr = I != NULL ? (*(uint8_t *)I >> 4 == 4 ?
2466878Sbrendan	    inet_ntoa(&((ipha_t *)I)->ipha_src) : *(uint8_t *)I >> 4 == 6 ?
2476878Sbrendan	    inet_ntoa6(&((ip6_t *)I)->ip6_src) : "<unknown>") : "<unknown>";
2486878Sbrendan	ip_daddr = I != NULL ? (*(uint8_t *)I >> 4 == 4 ?
2496878Sbrendan	    inet_ntoa(&((ipha_t *)I)->ipha_dst) : *(uint8_t *)I >> 4 == 6 ?
2506878Sbrendan	    inet_ntoa6(&((ip6_t *)I)->ip6_dst) : "<unknown>") : "<unknown>";
2516878Sbrendan};
2526878Sbrendan
25311237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" translator
2546878Sbrendantranslator ifinfo_t < __dtrace_ipsr_ill_t *I > {
2556878Sbrendan	if_name = I != NULL ? stringof(I->ill_name) : "<null>";
2566878Sbrendan	if_ipstack = I != NULL ? I->ill_ipst->ips_netstack->netstack_stackid
2576878Sbrendan	    : 0;
2586878Sbrendan	if_local = arg6;		/* probe dependent */
2596878Sbrendan	if_addr = (uintptr_t)I;
2606878Sbrendan};
2616878Sbrendan
262*12507SAlan.Maguire@Sun.COM/*
263*12507SAlan.Maguire@Sun.COM * Translate to an ipinfo_t * from either the non-NULL void_ip_t * passed in,
264*12507SAlan.Maguire@Sun.COM * or use arg3 (tcp_t *) to fabricate ip header info.
265*12507SAlan.Maguire@Sun.COM */
266*12507SAlan.Maguire@Sun.COM#pragma D binding "1.6.3" translator
267*12507SAlan.Maguire@Sun.COMtranslator ipinfo_t < __dtrace_tcp_void_ip_t *I > {
268*12507SAlan.Maguire@Sun.COM	ip_ver = I != NULL ? *(uint8_t *)I >> 4 :
269*12507SAlan.Maguire@Sun.COM	    arg3 != NULL ? ((tcp_t *)arg3)->tcp_connp->conn_ipversion : 0;
270*12507SAlan.Maguire@Sun.COM	ip_plength =
271*12507SAlan.Maguire@Sun.COM	    I != NULL && *(uint8_t *)I >> 4 == 4 ?
272*12507SAlan.Maguire@Sun.COM	    ntohs(((ipha_t *)I)->ipha_length) -
273*12507SAlan.Maguire@Sun.COM	    ((((ipha_t *)I)->ipha_version_and_hdr_length & 0xf) << 2) :
274*12507SAlan.Maguire@Sun.COM	    I != NULL && *(uint8_t *)I >> 4 == 6 ?
275*12507SAlan.Maguire@Sun.COM	    ntohs(((ip6_t *)I)->ip6_ctlun.ip6_un1.ip6_un1_plen) :
276*12507SAlan.Maguire@Sun.COM	    I != NULL ? 0 :
277*12507SAlan.Maguire@Sun.COM	    arg3 != NULL && probename == "send" ?
278*12507SAlan.Maguire@Sun.COM	    ((tcp_t *)arg3)->tcp_last_sent_len + @TCP_MIN_HEADER_LENGTH@ :
279*12507SAlan.Maguire@Sun.COM	    arg3 != NULL && probename == "receive" ?
280*12507SAlan.Maguire@Sun.COM	    ((tcp_t *)arg3)->tcp_last_recv_len + @TCP_MIN_HEADER_LENGTH@ :
281*12507SAlan.Maguire@Sun.COM	    0;
282*12507SAlan.Maguire@Sun.COM	ip_saddr =
283*12507SAlan.Maguire@Sun.COM	    I != NULL && *(uint8_t *)I >> 4 == 4 ?
284*12507SAlan.Maguire@Sun.COM	    inet_ntoa(&((ipha_t *)I)->ipha_src) :
285*12507SAlan.Maguire@Sun.COM	    I != NULL && *(uint8_t *)I >> 4 == 6 ?
286*12507SAlan.Maguire@Sun.COM	    inet_ntoa6(&((ip6_t *)I)->ip6_src) :
287*12507SAlan.Maguire@Sun.COM	    I != NULL ? "<unknown>" :
288*12507SAlan.Maguire@Sun.COM	    arg3 != NULL && probename == "send" ?
289*12507SAlan.Maguire@Sun.COM	    inet_ntoa6(&((tcp_t *)arg3)->tcp_connp->connua_v6addr.connua_laddr):
290*12507SAlan.Maguire@Sun.COM	    arg3 != NULL && probename == "receive" ?
291*12507SAlan.Maguire@Sun.COM	    inet_ntoa6(&((tcp_t *)arg3)->tcp_connp->connua_v6addr.connua_faddr):
292*12507SAlan.Maguire@Sun.COM	    "<unknown>";
293*12507SAlan.Maguire@Sun.COM	ip_daddr =
294*12507SAlan.Maguire@Sun.COM	    I != NULL && *(uint8_t *)I >> 4 == 4 ?
295*12507SAlan.Maguire@Sun.COM	    inet_ntoa(&((ipha_t *)I)->ipha_dst) :
296*12507SAlan.Maguire@Sun.COM	    I != NULL && *(uint8_t *)I >> 4 == 6 ?
297*12507SAlan.Maguire@Sun.COM	    inet_ntoa6(&((ip6_t *)I)->ip6_dst) :
298*12507SAlan.Maguire@Sun.COM	    I != NULL ? "<unknown>" :
299*12507SAlan.Maguire@Sun.COM	    arg3 != NULL && probename == "send" ?
300*12507SAlan.Maguire@Sun.COM	    inet_ntoa6(&((tcp_t *)arg3)->tcp_connp->connua_v6addr.connua_faddr):
301*12507SAlan.Maguire@Sun.COM	    arg3 != NULL && probename == "receive" ?
302*12507SAlan.Maguire@Sun.COM	    inet_ntoa6(&((tcp_t *)arg3)->tcp_connp->connua_v6addr.connua_laddr):
303*12507SAlan.Maguire@Sun.COM	    "<unknown>";
304*12507SAlan.Maguire@Sun.COM};
305*12507SAlan.Maguire@Sun.COM
30611237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" translator
3076878Sbrendantranslator ipv4info_t < ipha_t *I > {
3086878Sbrendan	ipv4_ver = I != NULL ? I->ipha_version_and_hdr_length >> 4 : 0;
3096878Sbrendan	ipv4_ihl = I != NULL ? (I->ipha_version_and_hdr_length & 0xf) << 2 : 0;
3106878Sbrendan	ipv4_tos = I != NULL ? I->ipha_type_of_service : 0;
3116878Sbrendan	ipv4_length = I != NULL ? ntohs(I->ipha_length) : 0;
3126878Sbrendan	ipv4_ident = I != NULL ? ntohs(I->ipha_ident) : 0;
3136878Sbrendan	ipv4_flags = I != NULL ? ntohs(I->ipha_fragment_offset_and_flags) >>
3146878Sbrendan	    12 : 0;
3156878Sbrendan	ipv4_offset = I != NULL ? ntohs(I->ipha_fragment_offset_and_flags) &
3166878Sbrendan	    0x0fff : 0;
3176878Sbrendan	ipv4_ttl = I != NULL ? I->ipha_ttl : 0;
3186878Sbrendan	ipv4_protocol = I != NULL ? I->ipha_protocol : 0;
3196878Sbrendan	ipv4_protostr = I == NULL ? "<null>" :
3206878Sbrendan	    I->ipha_protocol == IPPROTO_TCP     ? "TCP"    :
3216878Sbrendan	    I->ipha_protocol == IPPROTO_UDP     ? "UDP"    :
3226878Sbrendan	    I->ipha_protocol == IPPROTO_IP      ? "IP"     :
3236878Sbrendan	    I->ipha_protocol == IPPROTO_ICMP    ? "ICMP"   :
3246878Sbrendan	    I->ipha_protocol == IPPROTO_IGMP    ? "IGMP"   :
3256878Sbrendan	    I->ipha_protocol == IPPROTO_EGP     ? "EGP"    :
3266878Sbrendan	    I->ipha_protocol == IPPROTO_IPV6    ? "IPv6"   :
3276878Sbrendan	    I->ipha_protocol == IPPROTO_ROUTING ? "ROUTE"  :
3286878Sbrendan	    I->ipha_protocol == IPPROTO_ESP     ? "ESP"    :
3296878Sbrendan	    I->ipha_protocol == IPPROTO_AH      ? "AH"     :
3306878Sbrendan	    I->ipha_protocol == IPPROTO_ICMPV6  ? "ICMPv6" :
3316878Sbrendan	    I->ipha_protocol == IPPROTO_OSPF    ? "OSPF"   :
3326878Sbrendan	    I->ipha_protocol == IPPROTO_SCTP    ? "SCTP"   :
3336878Sbrendan	    I->ipha_protocol == IPPROTO_RAW     ? "RAW"    :
3346878Sbrendan	    lltostr((uint64_t)I->ipha_protocol);
3356878Sbrendan	ipv4_checksum = I != NULL ? ntohs(I->ipha_hdr_checksum) : 0;
3366878Sbrendan	ipv4_src = I != NULL ? I->ipha_src : 0;
3376878Sbrendan	ipv4_dst = I != NULL ? I->ipha_dst : 0;
3386878Sbrendan	ipv4_saddr = I != NULL ? inet_ntoa(&I->ipha_src) : "<null>";
3396878Sbrendan	ipv4_daddr = I != NULL ? inet_ntoa(&I->ipha_dst) : "<null>";
3406878Sbrendan	ipv4_hdr = I;
3416878Sbrendan};
3426878Sbrendan
34311237SJonathan.Haslam@Sun.COM#pragma D binding "1.5" translator
3446878Sbrendantranslator ipv6info_t < ip6_t *I > {
3456878Sbrendan	ipv6_ver = I != NULL ? I->ip6_ctlun.ip6_un2_vfc >> 4 : 0;
3466878Sbrendan	ipv6_tclass = I != NULL ? ((I->ip6_ctlun.ip6_un1.ip6_un1_flow &&
3476878Sbrendan	    0x0fffffff) >> 20) : 0;
3486878Sbrendan	ipv6_flow = I != NULL ? I->ip6_ctlun.ip6_un1.ip6_un1_flow &&
3496878Sbrendan	    0x000fffff : 0;
3506878Sbrendan	ipv6_plen = I != NULL ? ntohs(I->ip6_ctlun.ip6_un1.ip6_un1_plen) : 0;
3516878Sbrendan	ipv6_nexthdr = I != NULL ? I->ip6_ctlun.ip6_un1.ip6_un1_nxt : 0;
3526878Sbrendan	ipv6_nextstr = I == NULL ? "<null>" :
3536878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_TCP     ? "TCP"    :
3546878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_UDP     ? "UDP"    :
3556878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_IP      ? "IP"     :
3566878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_ICMP    ? "ICMP"   :
3576878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_IGMP    ? "IGMP"   :
3586878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_EGP     ? "EGP"    :
3596878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_IPV6    ? "IPv6"   :
3606878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_ROUTING ? "ROUTE"  :
3616878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_ESP     ? "ESP"    :
3626878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_AH      ? "AH"     :
3636878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_ICMPV6  ? "ICMPv6" :
3646878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_OSPF    ? "OSPF"   :
3656878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_SCTP    ? "SCTP"   :
3666878Sbrendan	    I->ip6_ctlun.ip6_un1.ip6_un1_nxt == IPPROTO_RAW     ? "RAW"    :
3676878Sbrendan	    lltostr((uint64_t)I->ip6_ctlun.ip6_un1.ip6_un1_nxt);
3686878Sbrendan	ipv6_hlim = I != NULL ? I->ip6_ctlun.ip6_un1.ip6_un1_hlim : 0;
3696878Sbrendan	ipv6_src = I != NULL ? &I->ip6_src : 0;
3706878Sbrendan	ipv6_dst = I != NULL ? &I->ip6_dst : 0;
3716878Sbrendan	ipv6_saddr = I != NULL ? inet_ntoa6(&I->ip6_src) : "<null>";
3726878Sbrendan	ipv6_daddr = I != NULL ? inet_ntoa6(&I->ip6_dst) : "<null>";
3736878Sbrendan	ipv6_hdr = I;
3746878Sbrendan};
375