- TCHECK(*pdtlv);
- type = EXTRACT_16BITS(&pdtlv->type);
- tll = EXTRACT_16BITS(&pdtlv->length) - TLV_HDRL;
- invtlv = tlv_valid(pdtlv, len);
- printf("genoptlvprint - %s TLV type 0x%x len %d\n",
- tok2str(ForCES_TLV, NULL, type), type, EXTRACT_16BITS(&pdtlv->length));
- if (!invtlv) {
- /*
- * At this point, tlv_valid() has ensured that the TLV
- * length is large enough but not too large (it doesn't
- * go past the end of the containing TLV).
- */
- register const u_char *dp = (u_char *) TLV_DATA(pdtlv);
- if (!ttlv_valid(type)) {
- printf("%s TLV type 0x%x len %d\n",
- tok2str(ForCES_TLV_err, NULL, invtlv), type,
- EXTRACT_16BITS(&pdtlv->length));
- return -1;
- }
- if (vflag >= 3)
- printf("%s%s, length %d (data length %d Bytes)",
- ib, tok2str(ForCES_TLV, NULL, type),
- EXTRACT_16BITS(&pdtlv->length), tll);
+ type = GET_BE_U_2(pdtlv->type);
+ tlvl = GET_BE_U_2(pdtlv->length);
+ invtlv = tlv_valid(tlvl, len);
+ ND_PRINT("genoptlvprint - %s TLV type 0x%x len %u\n",
+ tok2str(ForCES_TLV, NULL, type), type, tlvl);
+ if (invtlv) {
+ ND_PRINT("\t\t\tInvalid ForCES TLV type=%x", type);
+ goto invalid;
+ }
+ /*
+ * At this point, tlv_valid() has ensured that the TLV
+ * length is large enough but not too large (it doesn't
+ * go past the end of the containing TLV).
+ */
+ const u_char *dp = TLV_DATA(pdtlv);