Have llc_print() return the length of the LLC header, plus the length of
the SNAP header, if available - or, if it couldn't dissect the payload,
return the *negative* of that sum. Use that return value in link-layer
printers.
extern void loopback_print(netdissect_options *, const u_char *, const u_int);
extern void carp_print(netdissect_options *, const u_char *, u_int, int);
extern void loopback_print(netdissect_options *, const u_char *, const u_int);
extern void carp_print(netdissect_options *, const u_char *, u_int, int);
-extern void ether_print(netdissect_options *,
- const u_char *, u_int, u_int,
- void (*)(netdissect_options *, const u_char *),
- const u_char *);
+extern u_int ether_print(netdissect_options *,
+ const u_char *, u_int, u_int,
+ void (*)(netdissect_options *, const u_char *),
+ const u_char *);
extern u_int ether_if_print(netdissect_options *,
const struct pcap_pkthdr *,const u_char *);
extern u_int ether_if_print(netdissect_options *,
const struct pcap_pkthdr *,const u_char *);
extern u_int token_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
extern void zephyr_print(netdissect_options *, const u_char *, int);
extern u_int token_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
extern void zephyr_print(netdissect_options *, const u_char *, int);
-extern void fddi_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int fddi_print(netdissect_options *, const u_char *, u_int, u_int);
extern u_int fddi_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void mpcp_print(netdissect_options *, const u_char *, u_int);
extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
extern u_int fddi_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
extern void mpcp_print(netdissect_options *, const u_char *, u_int);
extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
uint16_t fc;
u_int caplen, hdrlen, meshdrlen;
const uint8_t *src, *dst;
uint16_t fc;
u_int caplen, hdrlen, meshdrlen;
const uint8_t *src, *dst;
caplen = orig_caplen;
/* Remove FCS, if present */
caplen = orig_caplen;
/* Remove FCS, if present */
}
} else {
get_data_src_dst_mac(fc, p - hdrlen, &src, &dst);
}
} else {
get_data_src_dst_mac(fc, p - hdrlen, &src, &dst);
- if (llc_print(ndo, p, length, caplen, dst, src) == 0) {
+ llc_hdrlen = llc_print(ndo, p, length, caplen, dst, src);
+ if (llc_hdrlen < 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
/*
* Print an RFC 1483 LLC-encapsulated ATM frame.
*/
/*
* Print an RFC 1483 LLC-encapsulated ATM frame.
*/
atm_llc_print(netdissect_options *ndo,
const u_char *p, int length, int caplen)
{
atm_llc_print(netdissect_options *ndo,
const u_char *p, int length, int caplen)
{
- if (!llc_print(ndo, p, length, caplen, NULL, NULL)) {
- /* ether_type not known, print raw packet */
+ int llc_hdrlen;
+
+ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+ if (llc_hdrlen < 0) {
+ /* packet not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
caplen -= 20;
hdrlen += 20;
}
caplen -= 20;
hdrlen += 20;
}
- atm_llc_print(ndo, p, length, caplen);
+ hdrlen += atm_llc_print(ndo, p, length, caplen);
{
u_int caplen = h->caplen;
u_int length = h->len;
{
u_int caplen = h->caplen;
u_int length = h->len;
if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
ND_PRINT((ndo, "[|cip]"));
if (memcmp(rfcllc, p, sizeof(rfcllc))==0 && caplen < RFC1483LLC_LEN) {
ND_PRINT((ndo, "[|cip]"));
/*
* LLC header is present. Try to print it & higher layers.
*/
/*
* LLC header is present. Try to print it & higher layers.
*/
- if (llc_print(ndo, p, length, caplen, NULL, NULL) == 0) {
+ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+ if (llc_hdrlen < 0) {
+ /* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
}
} else {
/*
* LLC header is absent; treat it as just IP.
*/
}
} else {
/*
* LLC header is absent; treat it as just IP.
*/
ip_print(ndo, p, length);
}
ip_print(ndo, p, length);
}
* a pointer to a function that can print header information for that
* frame's protocol, and an argument to pass to that function.
*/
* a pointer to a function that can print header information for that
* frame's protocol, and an argument to pass to that function.
*/
ether_print(netdissect_options *ndo,
const u_char *p, u_int length, u_int caplen,
void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
ether_print(netdissect_options *ndo,
const u_char *p, u_int length, u_int caplen,
void (*print_encap_header)(netdissect_options *ndo, const u_char *), const u_char *encap_header_arg)
struct ether_header *ep;
u_int orig_length;
u_short ether_type;
struct ether_header *ep;
u_int orig_length;
u_short ether_type;
+ u_int hdrlen;
+ int llc_hdrlen;
- if (caplen < ETHER_HDRLEN || length < ETHER_HDRLEN) {
+ if (caplen < ETHER_HDRLEN) {
+ ND_PRINT((ndo, "[|ether]"));
+ return (caplen);
+ }
+ if (length < ETHER_HDRLEN) {
ND_PRINT((ndo, "[|ether]"));
ND_PRINT((ndo, "[|ether]"));
caplen -= ETHER_HDRLEN;
ep = (struct ether_header *)p;
p += ETHER_HDRLEN;
caplen -= ETHER_HDRLEN;
ep = (struct ether_header *)p;
p += ETHER_HDRLEN;
ether_type = EXTRACT_16BITS(&ep->ether_type);
ether_type = EXTRACT_16BITS(&ep->ether_type);
*/
if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
*/
if (ether_type <= ETHERMTU) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep)) == 0) {
- /* ether_type not known, print raw packet */
+ llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep));
+ if (llc_hdrlen < 0) {
+ /* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
} else if (ether_type == ETHERTYPE_8021Q ||
ether_type == ETHERTYPE_8021Q9100 ||
ether_type == ETHERTYPE_8021Q9200 ||
} else if (ether_type == ETHERTYPE_8021Q ||
ether_type == ETHERTYPE_8021Q9100 ||
ether_type == ETHERTYPE_8021Q9200 ||
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
- if (caplen < 4 || length < 4) {
+ if (caplen < 4) {
+ ND_PRINT((ndo, "[|vlan]"));
+ return (hdrlen + caplen);
+ }
+ if (length < 4) {
ND_PRINT((ndo, "[|vlan]"));
ND_PRINT((ndo, "[|vlan]"));
+ return (hdrlen + length);
}
if (ndo->ndo_eflag) {
uint16_t tag = EXTRACT_16BITS(p);
}
if (ndo->ndo_eflag) {
uint16_t tag = EXTRACT_16BITS(p);
p += 4;
length -= 4;
caplen -= 4;
p += 4;
length -= 4;
caplen -= 4;
goto recurse;
} else if (ether_type == ETHERTYPE_JUMBO) {
/*
goto recurse;
} else if (ether_type == ETHERTYPE_JUMBO) {
/*
* there's an LLC header and payload.
*/
/* Try to print the LLC-layer header & higher layers */
* there's an LLC header and payload.
*/
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep)) == 0) {
- /* ether_type not known, print raw packet */
+ llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(ep), EDST(ep));
+ if (llc_hdrlen < 0) {
+ /* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
} else {
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
} else {
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
/* ether_type not known, print raw packet */
ND_DEFAULTPRINT(p, caplen);
}
}
ND_DEFAULTPRINT(p, caplen);
}
}
ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
const u_char *p)
{
ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
const u_char *p)
{
- ether_print(ndo, p, h->len, h->caplen, NULL, NULL);
-
- return (ETHER_HDRLEN);
+ return (ether_print(ndo, p, h->len, h->caplen, NULL, NULL));
}
/* Skip the pseudo-header. */
}
/* Skip the pseudo-header. */
- ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL);
-
- return (4 + ETHER_HDRLEN);
+ return (4 + ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL));
}
/* Skip the pseudo-header, preamble, and SOF. */
}
/* Skip the pseudo-header, preamble, and SOF. */
- ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL);
-
- return (12 + ETHER_HDRLEN);
+ return (12 + ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL));
ND_PRINT((ndo, "<SMT printer not yet implemented>"));
}
ND_PRINT((ndo, "<SMT printer not yet implemented>"));
}
fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct fddi_header *fddip = (const struct fddi_header *)p;
struct ether_header ehdr;
fddi_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct fddi_header *fddip = (const struct fddi_header *)p;
struct ether_header ehdr;
if (caplen < FDDI_HDRLEN) {
ND_PRINT((ndo, "[|fddi]"));
if (caplen < FDDI_HDRLEN) {
ND_PRINT((ndo, "[|fddi]"));
/* Frame Control field determines interpretation of packet */
if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
/* Try to print the LLC-layer header & higher layers */
/* Frame Control field determines interpretation of packet */
if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr)) == 0) {
+ llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr));
+ if (llc_hdrlen < 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
- } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT)
+ } else if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_SMT) {
fddi_smt_print(ndo, p, caplen);
fddi_smt_print(ndo, p, caplen);
+ llc_hdrlen = 0;
+ } else {
/* Some kinds of FDDI packet we cannot handle intelligently */
if (!ndo->ndo_eflag)
fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
EDST(&ehdr));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
/* Some kinds of FDDI packet we cannot handle intelligently */
if (!ndo->ndo_eflag)
fddi_hdr_print(ndo, fddip, length + FDDI_HDRLEN, ESRC(&ehdr),
EDST(&ehdr));
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ return (FDDI_HDRLEN + llc_hdrlen);
u_int
fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
u_int
fddi_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- fddi_print(ndo, p, h->len, h->caplen);
-
- return (FDDI_HDRLEN);
+ return (fddi_print(ndo, p, h->len, h->caplen));
ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
}
ND_PRINT((ndo, "%s %s %d: ", srcname, dstname, length));
}
ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct ipfc_header *ipfcp = (const struct ipfc_header *)p;
struct ether_header ehdr;
ipfc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct ipfc_header *ipfcp = (const struct ipfc_header *)p;
struct ether_header ehdr;
if (caplen < IPFC_HDRLEN) {
ND_PRINT((ndo, "[|ipfc]"));
if (caplen < IPFC_HDRLEN) {
ND_PRINT((ndo, "[|ipfc]"));
}
/*
* Get the network addresses into a canonical form
}
/*
* Get the network addresses into a canonical form
caplen -= IPFC_HDRLEN;
/* Try to print the LLC-layer header & higher layers */
caplen -= IPFC_HDRLEN;
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr)) == 0) {
+ llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr));
+ if (llc_hdrlen < 0) {
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
/*
* Some kinds of LLC packet we cannot
* handle intelligently
*/
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
+ return (IPFC_HDRLEN + llc_hdrlen);
u_int
ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
u_int
ipfc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register const u_char *p)
{
- ipfc_print(ndo, p, h->len, h->caplen);
-
- return (IPFC_HDRLEN);
+ return (ipfc_print(ndo, p, h->len, h->caplen));
juniper_atm1_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, register const u_char *p)
{
juniper_atm1_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM1;
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM1;
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
- if (llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL) != 0)
+ llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ if (llc_hdrlen > 0)
return l2info.header_len;
}
return l2info.header_len;
}
juniper_atm2_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, register const u_char *p)
{
juniper_atm2_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, register const u_char *p)
{
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM2;
struct juniper_l2info_t l2info;
l2info.pictype = DLT_JUNIPER_ATM2;
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
if (EXTRACT_24BITS(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_24BITS(p) == 0xaaaa03) { /* SNAP encaps ? */
- if (llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL) != 0)
+ llc_hdrlen = llc_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
+ if (llc_hdrlen > 0)
return l2info.header_len;
}
return l2info.header_len;
}
- * Returns zero if we have a payload but haven't printed it (for example,
- * because it has unknown SAPs or has a SNAP header with an unknown OUI/
- * PID combination).
+ * If we printed information about the payload, returns the length of the LLC
+ * header, plus the length of any SNAP header following it.
+ *
+ * Otherwise (for example, if the packet has unknown SAPs or has a SNAP
+ * header with an unknown OUI/PID combination), returns the *negative*
+ * of that value.
*/
int
llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
*/
int
llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
{
uint8_t dsap_field, dsap, ssap_field, ssap;
uint16_t control;
{
uint8_t dsap_field, dsap, ssap_field, ssap;
uint16_t control;
- if (caplen < 3 || length < 3) {
+ if (caplen < 3) {
+ ND_PRINT((ndo, "[|llc]"));
+ ND_DEFAULTPRINT((u_char *)p, caplen);
+ return (caplen);
+ }
+ if (length < 3) {
ND_PRINT((ndo, "[|llc]"));
ND_DEFAULTPRINT((u_char *)p, caplen);
ND_PRINT((ndo, "[|llc]"));
ND_DEFAULTPRINT((u_char *)p, caplen);
+ hdrlen = 3; /* DSAP, SSAP, 1-byte control field */
} else {
/*
* The control field in I and S frames is
* 2 bytes...
*/
} else {
/*
* The control field in I and S frames is
* 2 bytes...
*/
- if (caplen < 4 || length < 4) {
ND_PRINT((ndo, "[|llc]"));
ND_DEFAULTPRINT((u_char *)p, caplen);
ND_PRINT((ndo, "[|llc]"));
ND_DEFAULTPRINT((u_char *)p, caplen);
+ return (caplen);
+ }
+ if (length < 4) {
+ ND_PRINT((ndo, "[|llc]"));
+ ND_DEFAULTPRINT((u_char *)p, caplen);
+ return (length);
*/
control = EXTRACT_LE_16BITS(p + 2);
is_u = 0;
*/
control = EXTRACT_LE_16BITS(p + 2);
is_u = 0;
+ hdrlen = 4; /* DSAP, SSAP, 2-byte control field */
}
if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) {
}
if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) {
ND_PRINT((ndo, "IPX 802.3: "));
ipx_print(ndo, p, length);
ND_PRINT((ndo, "IPX 802.3: "));
ipx_print(ndo, p, length);
+ return (0); /* no LLC header */
}
dsap = dsap_field & ~LLC_IG;
ssap = ssap_field & ~LLC_GSAP;
}
dsap = dsap_field & ~LLC_IG;
ssap = ssap_field & ~LLC_GSAP;
+ /*
+ * Skip LLC header.
+ */
+ p += hdrlen;
+ length -= hdrlen;
+ caplen -= hdrlen;
+
/*
* Check for SNAP UI packets; if we have one, there's no point
* in printing the LLC header information, as we already know it -
/*
* Check for SNAP UI packets; if we have one, there's no point
* in printing the LLC header information, as we already know it -
* Does anybody ever bridge one form of LAN traffic
* over a networking type that uses 802.2 LLC?
*/
* Does anybody ever bridge one form of LAN traffic
* over a networking type that uses 802.2 LLC?
*/
- return (snap_print(ndo, p+3, length-3, caplen-3, esrc, edst, 2));
+ if (!snap_print(ndo, p, length, caplen, esrc, edst, 2)) {
+ /*
+ * Unknown packet type; tell our caller, by
+ * returning a negative value, so they
+ * can print the raw packet.
+ */
+ return (-(hdrlen + 5)); /* include LLC and SNAP header */
+ } else
+ return (hdrlen + 5); /* include LLC and SNAP header */
if (ssap == LLCSAP_8021D && dsap == LLCSAP_8021D &&
control == LLC_UI) {
if (ssap == LLCSAP_8021D && dsap == LLCSAP_8021D &&
control == LLC_UI) {
- stp_print(ndo, p+3, length-3);
- return (1);
+ stp_print(ndo, p, length);
+ return (hdrlen);
}
if (ssap == LLCSAP_IP && dsap == LLCSAP_IP &&
}
if (ssap == LLCSAP_IP && dsap == LLCSAP_IP &&
* with the source and destination SAPs being
* the IP SAP.
*/
* with the source and destination SAPs being
* the IP SAP.
*/
- ip_print(ndo, p+3, length-3);
- return (1);
+ ip_print(ndo, p, length);
+ return (hdrlen);
}
if (ssap == LLCSAP_IPX && dsap == LLCSAP_IPX &&
}
if (ssap == LLCSAP_IPX && dsap == LLCSAP_IPX &&
* This is an Ethernet_802.2 IPX frame, with an 802.3
* header and an 802.2 LLC header with the source and
* destination SAPs being the IPX SAP.
* This is an Ethernet_802.2 IPX frame, with an 802.3
* header and an 802.2 LLC header with the source and
* destination SAPs being the IPX SAP.
- *
- * Skip DSAP, LSAP, and control field.
*/
if (ndo->ndo_eflag)
ND_PRINT((ndo, "IPX 802.2: "));
*/
if (ndo->ndo_eflag)
ND_PRINT((ndo, "IPX 802.2: "));
- ipx_print(ndo, p+3, length-3);
- return (1);
+ ipx_print(ndo, p, length);
+ return (hdrlen);
* LLC_S_FMT, set in the first byte of the control field)
* and UI frames (whose control field is just 3, LLC_U_FMT).
*/
* LLC_S_FMT, set in the first byte of the control field)
* and UI frames (whose control field is just 3, LLC_U_FMT).
*/
-
- /*
- * Skip the LLC header.
- */
- if (is_u) {
- p += 3;
- length -= 3;
- } else {
- p += 4;
- length -= 4;
- }
netbeui_print(ndo, control, p, length);
netbeui_print(ndo, control, p, length);
}
#endif
if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
&& control == LLC_UI) {
}
#endif
if (ssap == LLCSAP_ISONS && dsap == LLCSAP_ISONS
&& control == LLC_UI) {
- isoclns_print(ndo, p + 3, length - 3, caplen - 3);
- return (1);
+ isoclns_print(ndo, p, length, caplen);
+ return (hdrlen);
ND_PRINT((ndo, "Unnumbered, %s, Flags [%s], length %u",
tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)),
ND_PRINT((ndo, "Unnumbered, %s, Flags [%s], length %u",
tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)),
if ((control & ~LLC_U_POLL) == LLC_XID) {
if (*p == LLC_XID_FI) {
ND_PRINT((ndo, ": %02x %02x", p[1], p[2]));
if ((control & ~LLC_U_POLL) == LLC_XID) {
if (*p == LLC_XID_FI) {
ND_PRINT((ndo, ": %02x %02x", p[1], p[2]));
tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)),
LLC_IS_NR(control),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)),
LLC_IS_NR(control),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
- length));
- return (1); /* no payload to print */
+ length + hdrlen));
+ return (hdrlen); /* no payload to print */
} else {
ND_PRINT((ndo, "Information, send seq %u, rcv seq %u, Flags [%s], length %u",
LLC_I_NS(control),
LLC_IS_NR(control),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
} else {
ND_PRINT((ndo, "Information, send seq %u, rcv seq %u, Flags [%s], length %u",
LLC_I_NS(control),
LLC_IS_NR(control),
tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)),
u_int length = h->len;
register const struct sll_header *sllp;
u_short ether_type;
u_int length = h->len;
register const struct sll_header *sllp;
u_short ether_type;
+ int llc_hdrlen;
+ u_int hdrlen;
if (caplen < SLL_HDR_LEN) {
/*
if (caplen < SLL_HDR_LEN) {
/*
length -= SLL_HDR_LEN;
caplen -= SLL_HDR_LEN;
p += SLL_HDR_LEN;
length -= SLL_HDR_LEN;
caplen -= SLL_HDR_LEN;
p += SLL_HDR_LEN;
ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
* 802.2.
* Try to print the LLC-layer header & higher layers.
*/
* 802.2.
* Try to print the LLC-layer header & higher layers.
*/
- if (llc_print(ndo, p, length, caplen, NULL, NULL) == 0)
+ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+ if (llc_hdrlen < 0)
goto unknown; /* unknown LLC type */
goto unknown; /* unknown LLC type */
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
- if (caplen < 4 || length < 4) {
ND_PRINT((ndo, "[|vlan]"));
ND_PRINT((ndo, "[|vlan]"));
+ return (hdrlen + caplen);
+ }
+ if (length < 4) {
+ ND_PRINT((ndo, "[|vlan]"));
+ return (hdrlen + length);
}
if (ndo->ndo_eflag) {
uint16_t tag = EXTRACT_16BITS(p);
}
if (ndo->ndo_eflag) {
uint16_t tag = EXTRACT_16BITS(p);
p += 4;
length -= 4;
caplen -= 4;
p += 4;
length -= 4;
caplen -= 4;
goto recurse;
} else {
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
goto recurse;
} else {
if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct token_header *trp;
token_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
{
const struct token_header *trp;
struct ether_header ehdr;
u_int route_len = 0, hdr_len = TOKEN_HDRLEN;
int seg;
struct ether_header ehdr;
u_int route_len = 0, hdr_len = TOKEN_HDRLEN;
int seg;
/* Frame Control field determines interpretation of packet */
if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
/* Try to print the LLC-layer header & higher layers */
/* Frame Control field determines interpretation of packet */
if (FRAME_TYPE(trp) == TOKEN_FC_LLC) {
/* Try to print the LLC-layer header & higher layers */
- if (llc_print(ndo, p, length, caplen, ESRC(&ehdr), EDST(&ehdr)) == 0) {
- /* ether_type not known, print raw packet */
+ llc_hdrlen = llc_print(ndo, p, length, caplen, ESRC(&ehdr),
+ EDST(&ehdr));
+ if (llc_hdrlen < 0) {
+ /* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
+ llc_hdrlen = -llc_hdrlen;
} else {
/* Some kinds of TR packet we cannot handle intelligently */
/* XXX - dissect MAC packets if frame type is 0 */
} else {
/* Some kinds of TR packet we cannot handle intelligently */
/* XXX - dissect MAC packets if frame type is 0 */