1 /* \summary: Solaris DLT_IPNET printer */
7 #include <netdissect-stdinc.h>
9 #include "netdissect.h"
11 typedef struct ipnet_hdr
{
17 uint32_t iph_grifindex
;
22 #define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
23 #define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
27 static const struct tok ipnet_values
[] = {
28 { IPH_AF_INET
, "IPv4" },
29 { IPH_AF_INET6
, "IPv6" },
34 ipnet_hdr_print(netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
36 const ipnet_hdr_t
*hdr
;
37 hdr
= (const ipnet_hdr_t
*)bp
;
39 ND_PRINT((ndo
, "%d > %d", hdr
->iph_zsrc
, hdr
->iph_zdst
));
41 if (!ndo
->ndo_qflag
) {
42 ND_PRINT((ndo
,", family %s (%d)",
43 tok2str(ipnet_values
, "Unknown",
49 "Unknown Ethertype (0x%04x)",
53 ND_PRINT((ndo
, ", length %u: ", length
));
57 ipnet_print(netdissect_options
*ndo
, const u_char
*p
, u_int length
, u_int caplen
)
59 const ipnet_hdr_t
*hdr
;
61 if (caplen
< sizeof(ipnet_hdr_t
)) {
62 ND_PRINT((ndo
, "[|ipnet]"));
67 ipnet_hdr_print(ndo
, p
, length
);
69 length
-= sizeof(ipnet_hdr_t
);
70 caplen
-= sizeof(ipnet_hdr_t
);
71 hdr
= (const ipnet_hdr_t
*)p
;
72 p
+= sizeof(ipnet_hdr_t
);
74 switch (hdr
->iph_family
) {
77 ip_print(ndo
, p
, length
);
81 ip6_print(ndo
, p
, length
);
86 ipnet_hdr_print(ndo
, (const u_char
*)hdr
,
87 length
+ sizeof(ipnet_hdr_t
));
89 if (!ndo
->ndo_suppress_default_print
)
90 ND_DEFAULTPRINT(p
, caplen
);
96 * This is the top level routine of the printer. 'p' points
97 * to the ether header of the packet, 'h->ts' is the timestamp,
98 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
99 * is the number of bytes actually captured.
102 ipnet_if_print(netdissect_options
*ndo
,
103 const struct pcap_pkthdr
*h
, const u_char
*p
)
105 ipnet_print(ndo
, p
, h
->len
, h
->caplen
);
107 return (sizeof(ipnet_hdr_t
));
112 * c-style: whitesmith
117 #endif /* DLT_IPNET */