5 #include <tcpdump-stdinc.h>
10 #include "netdissect.h"
11 #include "interface.h"
12 #include "addrtoname.h"
14 typedef struct ipnet_hdr
{
20 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(struct netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
39 const ipnet_hdr_t
*hdr
;
40 hdr
= (const ipnet_hdr_t
*)bp
;
42 ND_PRINT((ndo
, "%d > %d", hdr
->iph_zsrc
, hdr
->iph_zdst
));
44 if (!ndo
->ndo_qflag
) {
45 ND_PRINT((ndo
,", family %s (%d)",
46 tok2str(ipnet_values
, "Unknown",
52 "Unknown Ethertype (0x%04x)",
56 ND_PRINT((ndo
, ", length %u: ", length
));
60 ipnet_print(struct netdissect_options
*ndo
, const u_char
*p
, u_int length
, u_int caplen
)
64 if (caplen
< sizeof(ipnet_hdr_t
)) {
65 ND_PRINT((ndo
, "[|ipnet]"));
70 ipnet_hdr_print(ndo
, p
, length
);
72 length
-= sizeof(ipnet_hdr_t
);
73 caplen
-= sizeof(ipnet_hdr_t
);
74 hdr
= (ipnet_hdr_t
*)p
;
75 p
+= sizeof(ipnet_hdr_t
);
77 switch (hdr
->iph_family
) {
80 ip_print(ndo
, p
, length
);
85 ip6_print(ndo
, p
, length
);
91 ipnet_hdr_print(ndo
, (u_char
*)hdr
,
92 length
+ sizeof(ipnet_hdr_t
));
94 if (!ndo
->ndo_suppress_default_print
)
95 ndo
->ndo_default_print(ndo
, p
, caplen
);
101 * This is the top level routine of the printer. 'p' points
102 * to the ether header of the packet, 'h->ts' is the timestamp,
103 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
104 * is the number of bytes actually captured.
107 ipnet_if_print(struct netdissect_options
*ndo
,
108 const struct pcap_pkthdr
*h
, const u_char
*p
)
110 ipnet_print(ndo
, p
, h
->len
, h
->caplen
);
112 return (sizeof(ipnet_hdr_t
));
117 * c-style: whitesmith
122 #endif /* DLT_IPNET */