+
+ return 0; /* OK */
+
+trunc:
+ return -1; /* packet truncated by capture process */
+
+invalid:
+ return -2; /* packet is invalid */
+}
+
+static void
+babel_print_v2(netdissect_options *ndo,
+ const u_char *cp, u_int length)
+{
+ u_short bodylen;
+ int ret;
+
+ ND_TCHECK_4(cp);
+ if (length < 4)
+ goto invalid;
+ bodylen = GET_BE_U_2(cp + 2);
+ ND_PRINT(" (%u)", bodylen);
+ length -= 4;
+ cp += 4;
+
+ /* Process the TLVs in the body */
+ if (length < bodylen)
+ goto invalid;
+ ret = babel_print_v2_tlvs(ndo, cp, bodylen, length);
+ if (ret == -1)
+ goto trunc;
+ if (ret == -2)
+ goto invalid;
+ length -= bodylen;
+ cp += bodylen;
+
+ /* If there's a trailer, process the TLVs in the trailer */
+ if (length != 0) {
+ if(ndo->ndo_vflag) ND_PRINT("\n\t----");
+ else ND_PRINT(" |");
+ ret = babel_print_v2_tlvs(ndo, cp, length, length);
+ if (ret == -1)
+ goto trunc;
+ if (ret == -2)
+ goto invalid;
+ }