1 /* \summary: Solaris DLT_IPNET printer */
7 #include <netdissect-stdinc.h>
9 #include "netdissect.h"
12 static const char tstr
[] = "[|ipnet]";
14 typedef struct ipnet_hdr
{
15 nd_uint8_t iph_version
;
16 nd_uint8_t iph_family
;
17 nd_uint16_t iph_htype
;
18 nd_uint32_t iph_pktlen
;
19 nd_uint32_t iph_ifindex
;
20 nd_uint32_t iph_grifindex
;
25 #define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
26 #define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
30 static const struct tok ipnet_values
[] = {
31 { IPH_AF_INET
, "IPv4" },
32 { IPH_AF_INET6
, "IPv6" },
37 ipnet_hdr_print(netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
39 const ipnet_hdr_t
*hdr
;
40 hdr
= (const ipnet_hdr_t
*)bp
;
43 ND_PRINT("%u > %u", EXTRACT_BE_U_4(hdr
->iph_zsrc
),
44 EXTRACT_BE_U_4(hdr
->iph_zdst
));
46 if (!ndo
->ndo_qflag
) {
47 ND_PRINT(", family %s (%u)",
48 tok2str(ipnet_values
, "Unknown",
49 EXTRACT_U_1(hdr
->iph_family
)),
50 EXTRACT_U_1(hdr
->iph_family
));
54 "Unknown Ethertype (0x%04x)",
55 EXTRACT_U_1(hdr
->iph_family
)));
58 ND_PRINT(", length %u: ", length
);
61 ND_PRINT(" %s", tstr
);
65 ipnet_print(netdissect_options
*ndo
, const u_char
*p
, u_int length
, u_int caplen
)
67 const ipnet_hdr_t
*hdr
;
69 if (caplen
< sizeof(ipnet_hdr_t
))
73 ipnet_hdr_print(ndo
, p
, length
);
75 length
-= sizeof(ipnet_hdr_t
);
76 caplen
-= sizeof(ipnet_hdr_t
);
77 hdr
= (const ipnet_hdr_t
*)p
;
78 p
+= sizeof(ipnet_hdr_t
);
80 ND_TCHECK_1(hdr
->iph_family
);
81 switch (EXTRACT_U_1(hdr
->iph_family
)) {
84 ip_print(ndo
, p
, length
);
88 ip6_print(ndo
, p
, length
);
93 ipnet_hdr_print(ndo
, (const u_char
*)hdr
,
94 length
+ sizeof(ipnet_hdr_t
));
96 if (!ndo
->ndo_suppress_default_print
)
97 ND_DEFAULTPRINT(p
, caplen
);
102 ND_PRINT(" %s", tstr
);
106 * This is the top level routine of the printer. 'p' points
107 * to the ether header of the packet, 'h->ts' is the timestamp,
108 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
109 * is the number of bytes actually captured.
112 ipnet_if_print(netdissect_options
*ndo
,
113 const struct pcap_pkthdr
*h
, const u_char
*p
)
115 ipnet_print(ndo
, p
, h
->len
, h
->caplen
);
117 return (sizeof(ipnet_hdr_t
));
122 * c-style: whitesmith
127 #endif /* DLT_IPNET */