5 #include <tcpdump-stdinc.h>
10 #include "netdissect.h"
11 #include "interface.h"
12 #include "addrtoname.h"
17 const struct tok ipnet_values[] = {
18 { IPH_AF_INET, "IPv4" },
19 { IPH_AF_INET6, "IPv6" },
24 ipnet_hdr_print(struct netdissect_options *ndo, const u_char *bp, u_int length)
26 const ipnet_hdr_t *hdr;
27 hdr = (const ipnet_hdr_t *)bp;
29 ND_PRINT((ndo, "%d > %d", hdr->iph_zsrc, hdr->iph_zdst));
31 if (!ndo->ndo_qflag) {
32 ND_PRINT((ndo,", family %s (%d)",
33 tok2str(ipnet_values, "Unknown",
39 "Unknown Ethertype (0x%04x)",
43 ND_PRINT((ndo, ", length %u: ", length));
47 ipnet_print(struct netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
51 if (caplen < sizeof(ipnet_hdr_t)) {
52 ND_PRINT((ndo, "[|ipnet]"));
57 ipnet_hdr_print(ndo, p, length);
59 length -= sizeof(ipnet_hdr_t);
60 caplen -= sizeof(ipnet_hdr_t);
61 hdr = (ipnet_hdr_t *)p;
62 p += sizeof(ipnet_hdr_t);
64 switch (hdr->iph_family) {
67 ip_print(ndo, p, length);
72 ip6_print(ndo, p, length);
78 ipnet_hdr_print(ndo, (u_char *)hdr,
79 length + sizeof(ipnet_hdr_t));
81 if (!ndo->ndo_suppress_default_print)
82 ndo->ndo_default_print(ndo, p, caplen);
88 * This is the top level routine of the printer. 'p' points
89 * to the ether header of the packet, 'h->ts' is the timestamp,
90 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
91 * is the number of bytes actually captured.
94 ipnet_if_print(struct netdissect_options *ndo,
95 const struct pcap_pkthdr *h, const u_char *p)
97 ipnet_print(ndo, p, h->len, h->caplen);
99 return (sizeof(ipnet_hdr_t));
104 * c-style: whitesmith
109 #endif /* DLT_IPNET */