5 #include <tcpdump-stdinc.h>
10 #include "netdissect.h"
11 #include "interface.h"
13 typedef struct ipnet_hdr
{
19 uint32_t iph_grifindex
;
24 #define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
25 #define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
29 static const struct tok ipnet_values
[] = {
30 { IPH_AF_INET
, "IPv4" },
31 { IPH_AF_INET6
, "IPv6" },
36 ipnet_hdr_print(struct netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
38 const ipnet_hdr_t
*hdr
;
39 hdr
= (const ipnet_hdr_t
*)bp
;
41 ND_PRINT((ndo
, "%d > %d", hdr
->iph_zsrc
, hdr
->iph_zdst
));
43 if (!ndo
->ndo_qflag
) {
44 ND_PRINT((ndo
,", family %s (%d)",
45 tok2str(ipnet_values
, "Unknown",
51 "Unknown Ethertype (0x%04x)",
55 ND_PRINT((ndo
, ", length %u: ", length
));
59 ipnet_print(struct netdissect_options
*ndo
, const u_char
*p
, u_int length
, u_int caplen
)
63 if (caplen
< sizeof(ipnet_hdr_t
)) {
64 ND_PRINT((ndo
, "[|ipnet]"));
69 ipnet_hdr_print(ndo
, p
, length
);
71 length
-= sizeof(ipnet_hdr_t
);
72 caplen
-= sizeof(ipnet_hdr_t
);
73 hdr
= (ipnet_hdr_t
*)p
;
74 p
+= sizeof(ipnet_hdr_t
);
76 switch (hdr
->iph_family
) {
79 ip_print(ndo
, p
, length
);
84 ip6_print(ndo
, p
, length
);
90 ipnet_hdr_print(ndo
, (u_char
*)hdr
,
91 length
+ sizeof(ipnet_hdr_t
));
93 if (!ndo
->ndo_suppress_default_print
)
94 ndo
->ndo_default_print(ndo
, p
, caplen
);
100 * This is the top level routine of the printer. 'p' points
101 * to the ether header of the packet, 'h->ts' is the timestamp,
102 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
103 * is the number of bytes actually captured.
106 ipnet_if_print(struct netdissect_options
*ndo
,
107 const struct pcap_pkthdr
*h
, const u_char
*p
)
109 ipnet_print(ndo
, p
, h
->len
, h
->caplen
);
111 return (sizeof(ipnet_hdr_t
));
116 * c-style: whitesmith
121 #endif /* DLT_IPNET */