5 #include <tcpdump-stdinc.h>
9 #include "netdissect.h"
10 #include "interface.h"
12 typedef struct ipnet_hdr
{
18 uint32_t iph_grifindex
;
23 #define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
24 #define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
28 static const struct tok ipnet_values
[] = {
29 { IPH_AF_INET
, "IPv4" },
30 { IPH_AF_INET6
, "IPv6" },
35 ipnet_hdr_print(struct netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
37 const ipnet_hdr_t
*hdr
;
38 hdr
= (const ipnet_hdr_t
*)bp
;
40 ND_PRINT((ndo
, "%d > %d", hdr
->iph_zsrc
, hdr
->iph_zdst
));
42 if (!ndo
->ndo_qflag
) {
43 ND_PRINT((ndo
,", family %s (%d)",
44 tok2str(ipnet_values
, "Unknown",
50 "Unknown Ethertype (0x%04x)",
54 ND_PRINT((ndo
, ", length %u: ", length
));
58 ipnet_print(struct netdissect_options
*ndo
, const u_char
*p
, u_int length
, u_int caplen
)
62 if (caplen
< sizeof(ipnet_hdr_t
)) {
63 ND_PRINT((ndo
, "[|ipnet]"));
68 ipnet_hdr_print(ndo
, p
, length
);
70 length
-= sizeof(ipnet_hdr_t
);
71 caplen
-= sizeof(ipnet_hdr_t
);
72 hdr
= (ipnet_hdr_t
*)p
;
73 p
+= sizeof(ipnet_hdr_t
);
75 switch (hdr
->iph_family
) {
78 ip_print(ndo
, p
, length
);
83 ip6_print(ndo
, p
, length
);
89 ipnet_hdr_print(ndo
, (u_char
*)hdr
,
90 length
+ sizeof(ipnet_hdr_t
));
92 if (!ndo
->ndo_suppress_default_print
)
93 ndo
->ndo_default_print(ndo
, p
, caplen
);
99 * This is the top level routine of the printer. 'p' points
100 * to the ether header of the packet, 'h->ts' is the timestamp,
101 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
102 * is the number of bytes actually captured.
105 ipnet_if_print(struct netdissect_options
*ndo
,
106 const struct pcap_pkthdr
*h
, const u_char
*p
)
108 ipnet_print(ndo
, p
, h
->len
, h
->caplen
);
110 return (sizeof(ipnet_hdr_t
));
115 * c-style: whitesmith
120 #endif /* DLT_IPNET */