5 #include <tcpdump-stdinc.h>
10 #include "netdissect.h"
11 #include "addrtoname.h"
16 int ipnet_encap_print(netdissect_options
*,u_short
, const u_char
*, u_int
, u_int
);
18 const struct tok ipnet_values
[] = {
19 { IPH_AF_INET
, "IPv4" },
20 { IPH_AF_INET6
, "IPv6" },
25 ipnet_hdr_print(struct netdissect_options
*ndo
, const u_char
*bp
, u_int length
)
27 const ipnet_hdr_t
*hdr
;
28 hdr
= (const ipnet_hdr_t
*)bp
;
30 ND_PRINT((ndo
, "%d > %d", hdr
->iph_zsrc
, hdr
->iph_zdst
));
32 if (!ndo
->ndo_qflag
) {
33 ND_PRINT((ndo
,", family %s (%d)",
34 tok2str(ipnet_values
, "Unknown",
40 "Unknown Ethertype (0x%04x)",
44 ND_PRINT((ndo
, ", length %u: ", length
));
48 ipnet_print(struct netdissect_options
*ndo
, const u_char
*p
, u_int length
, u_int caplen
)
52 if (caplen
< sizeof(ipnet_hdr_t
)) {
53 ND_PRINT((ndo
, "[|ipnet]"));
58 ipnet_hdr_print(ndo
, p
, length
);
60 length
-= sizeof(ipnet_hdr_t
);
61 caplen
-= sizeof(ipnet_hdr_t
);
62 hdr
= (ipnet_hdr_t
*)p
;
63 p
+= sizeof(ipnet_hdr_t
);
65 if (ipnet_encap_print(ndo
, hdr
->iph_family
, p
, length
, caplen
) == 0) {
67 ipnet_hdr_print(ndo
, (u_char
*)hdr
,
68 length
+ sizeof(ipnet_hdr_t
));
70 if (!ndo
->ndo_suppress_default_print
)
71 ndo
->ndo_default_print(ndo
, p
, caplen
);
76 * This is the top level routine of the printer. 'p' points
77 * to the ether header of the packet, 'h->ts' is the timestamp,
78 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
79 * is the number of bytes actually captured.
82 ipnet_if_print(struct netdissect_options
*ndo
, const struct pcap_pkthdr
*h
, const u_char
*p
)
84 ipnet_print(ndo
, p
, h
->len
, h
->caplen
);
86 return (sizeof(ipnet_hdr_t
));
90 * Prints the packet encapsulated in an Ethernet data segment
91 * (or an equivalent encapsulation), given the Ethernet type code.
93 * Returns non-zero if it can do so, zero if the ethertype is unknown.
95 * The Ethernet type code is passed through a pointer; if it was
96 * ETHERTYPE_8021Q, it gets updated to be the Ethernet type of
97 * the 802.1Q payload, for the benefit of lower layers that might
98 * want to know what it is.
102 ipnet_encap_print(struct netdissect_options
*ndo
, u_short family
, const u_char
*p
,
103 u_int length
, u_int caplen
)
110 ip_print(ndo
, p
, length
);
115 ip6_print(p
, length
);
127 * c-style: whitesmith
132 #endif /* DLT_IPNET */