#define ND_TTEST_SIZE(p) ND_TTEST_LEN(p, sizeof(*(p)))
/* Bail out if "l" bytes from "p" were not captured */
+#ifdef ND_LONGJMP_FROM_TCHECK
+#define ND_TCHECK_LEN(p, l) if (!ND_TTEST_LEN(p, l)) nd_trunc(ndo)
+#else
#define ND_TCHECK_LEN(p, l) if (!ND_TTEST_LEN(p, l)) goto trunc
+#endif
/* Bail out if "*(p)" was not captured */
#define ND_TCHECK_SIZE(p) ND_TCHECK_LEN(p, sizeof(*(p)))
* The convention is that a printer function returns iff the given structure is
* completely within the packet buffer; otherwise it processes the part that is
* within the buffer, sooner of later takes the "truncated packet" shortcut via
- * nd_trunc() and never returns. With that in mind, the function may return
+ * longjmp() and never returns. With that in mind, the function may return
* without printing the structure completely if it is invalid or the ndo_vflag
* value is not high enough. This way the calling function can try to decode
* the next data item.
#include "netdissect-stdinc.h"
+#define ND_LONGJMP_FROM_TCHECK
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
hex_and_ascii_print(ndo, "\n\t ", cp, len);
else
ND_TCHECK_LEN(cp, len);
- return;
-
-trunc:
- nd_trunc(ndo);
}
static void
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
static void
invalid:
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
static void
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
static void
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* Vendor ID is mandatory, data is optional. */
invalid: /* skip the undersized data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
static void
ND_PRINT(", frame decoding below\n");
ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL);
ndo->ndo_vflag += 3;
- return;
-
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.2.1 */
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.2.2 */
invalid: /* skip the rest of queue properties */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* ibid */
invalid: /* skip the rest of queues */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.2.3 */
}
else
ND_TCHECK_2(cp);
- return;
-
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.2.4 */
invalid: /* skip the rest of actions */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.3.1 */
/* pad */
/* Always the last field, check bounds. */
ND_TCHECK_4(cp);
- return;
-
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.3.5 */
invalid: /* skip the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* ibid */
invalid: /* skip the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* ibid */
invalid: /* skip the rest of flow statistics entries */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* ibid */
invalid: /* skip the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* ibid */
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* ibid */
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* ibid */
invalid: /* skip the undersized trailing data */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* ibid */
}
}
ND_TCHECK_LEN(cp, len);
- return;
-
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.3.6 */
invalid: /* skip the rest of the message body */
nd_print_invalid(ndo);
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.4.1 */
OF_CHK_FWD(1);
/* data */
of10_packet_data_print(ndo, cp, len);
- return;
-
-trunc:
- nd_trunc(ndo);
}
/* [OF10] Section 5.4.2 */
nd_print_invalid(ndo);
next_message:
ND_TCHECK_LEN(cp, len);
- return;
-trunc:
- nd_trunc(ndo);
}