123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #ifdef HAVE_CONFIG_H
- #include "config.h"
- #endif
- #include <netdissect-stdinc.h>
- #include <string.h>
- #include "netdissect.h"
- #include "af.h"
- #define NULL_HDRLEN 4
- #define SWAPLONG(y) \
- ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
- static inline void
- null_hdr_print(netdissect_options *ndo, u_int family, u_int length)
- {
- if (!ndo->ndo_qflag) {
- ND_PRINT((ndo, "AF %s (%u)",
- tok2str(bsd_af_values,"Unknown",family),family));
- } else {
- ND_PRINT((ndo, "%s",
- tok2str(bsd_af_values,"Unknown AF %u",family)));
- }
- ND_PRINT((ndo, ", length %u: ", length));
- }
- u_int
- null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
- {
- u_int length = h->len;
- u_int caplen = h->caplen;
- u_int family;
- if (caplen < NULL_HDRLEN) {
- ND_PRINT((ndo, "[|null]"));
- return (NULL_HDRLEN);
- }
- memcpy((char *)&family, (const char *)p, sizeof(family));
-
- if ((family & 0xFFFF0000) != 0)
- family = SWAPLONG(family);
- if (ndo->ndo_eflag)
- null_hdr_print(ndo, family, length);
- length -= NULL_HDRLEN;
- caplen -= NULL_HDRLEN;
- p += NULL_HDRLEN;
- switch (family) {
- case BSD_AFNUM_INET:
- ip_print(ndo, p, length);
- break;
- case BSD_AFNUM_INET6_BSD:
- case BSD_AFNUM_INET6_FREEBSD:
- case BSD_AFNUM_INET6_DARWIN:
- ip6_print(ndo, p, length);
- break;
- case BSD_AFNUM_ISO:
- isoclns_print(ndo, p, length);
- break;
- case BSD_AFNUM_APPLETALK:
- atalk_print(ndo, p, length);
- break;
- case BSD_AFNUM_IPX:
- ipx_print(ndo, p, length);
- break;
- default:
-
- if (!ndo->ndo_eflag)
- null_hdr_print(ndo, family, length + NULL_HDRLEN);
- if (!ndo->ndo_suppress_default_print)
- ND_DEFAULTPRINT(p, caplen);
- }
- return (NULL_HDRLEN);
- }
|