#include "llc.h"
#include "nlpid.h"
#include "extract.h"
-#include "oui.h"
static void frf15_print(netdissect_options *ndo, const u_char *, u_int);
static u_int dlci, addr_len;
static uint32_t flags;
- static char buffer[sizeof("DLCI xxxxxxxxxx")];
+ static char buffer[sizeof("parse_q922_header() returned XXXXXXXXXXX")];
+ int ret;
memset(buffer, 0, sizeof(buffer));
- if (parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length) == 1){
+ ret = parse_q922_header(ndo, p, &dlci, &addr_len, &flags, length);
+ if (ret == 1) {
snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
+ return buffer;
+ } else if (ret == 0) {
+ return "<Invalid DLCI>";
+ } else if (ret == -1) {
+ return "<Truncated>";
+ } else {
+ snprintf(buffer, sizeof(buffer), "parse_q922_header() returned %d", ret);
+ return buffer;
}
-
- return buffer;
}
}
}
-u_int
+/* Frame Relay */
+void
fr_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
- ndo->ndo_protocol = "fr_if";
- ND_TCHECK_4(p); /* minimum frame header length */
+ ndo->ndo_protocol = "fr";
+ if (caplen < 4) { /* minimum frame header length */
+ nd_print_trunc(ndo);
+ ndo->ndo_ll_hdr_len += caplen;
+ return;
+ }
- if ((length = fr_print(ndo, p, length)) == 0)
- return (0);
- else
- return length;
-trunc:
- nd_print_trunc(ndo);
- return caplen;
+ ndo->ndo_ll_hdr_len += fr_print(ndo, p, length);
}
u_int
}
-u_int
+/* Multi Link Frame Relay (FRF.16) */
+void
mfr_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
u_int length = h->len;
u_int caplen = h->caplen;
- ndo->ndo_protocol = "mfr_if";
- ND_TCHECK_2(p); /* minimum frame header length */
+ ndo->ndo_protocol = "mfr";
+ if (caplen < 2) { /* minimum frame header length */
+ nd_print_trunc(ndo);
+ ndo->ndo_ll_hdr_len += caplen;
+ return;
+ }
- if ((length = mfr_print(ndo, p, length)) == 0)
- return (0);
- else
- return length;
-trunc:
- nd_print_trunc(ndo);
- return caplen;
+ ndo->ndo_ll_hdr_len += mfr_print(ndo, p, length);
}
*/
ndo->ndo_protocol = "mfr";
- ND_TCHECK_4(p); /* minimum frame header length */
+
+ if (length < 4) { /* minimum frame header length */
+ ND_PRINT("[length %u < 4]", length);
+ nd_print_invalid(ndo);
+ return length;
+ }
+ ND_TCHECK_4(p);
if ((GET_U_1(p) & MFR_BEC_MASK) == MFR_CTRL_FRAME && GET_U_1(p + 1) == 0) {
ND_PRINT("FRF.16 Control, Flags [%s], %s, length %u",
switch (ie_type) {
case MFR_CTRL_IE_MAGIC_NUM:
+ /* FRF.16.1 Section 3.4.3 Magic Number Information Element */
+ if (ie_len != 4) {
+ ND_PRINT("[IE data length %d != 4]", ie_len);
+ nd_print_invalid(ndo);
+ break;
+ }
ND_PRINT("0x%08x", GET_BE_U_4(tptr));
break;
if (length < 2)
goto trunc;
- ND_TCHECK_2(p);
flags = GET_U_1(p)&MFR_BEC_MASK;
sequence_num = (GET_U_1(p)&0x1e)<<7 | GET_U_1(p + 1);
* dig as deep as we can - e.g. on the first (B) fragment
* there is enough payload to print the IP header
* on non (B) fragments it depends if the fragmentation
- * model is end-to-end or interface based wether we want to print
+ * model is end-to-end or interface based whether we want to print
* another Q.922 header
*/
return;
ND_PRINT("%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset);
if (call_ref_length != 0) {
- ND_TCHECK_1(p);
if (call_ref_length > 1 || GET_U_1(p) != 0) {
/*
* Not a dummy call reference.