-
- printf("%s (%u) v%u, len %u",
- tok2str(eap_frame_type_values, "unknown", eap->type),
- eap->type,
- eap->version,
- EXTRACT_16BITS(eap->length));
-
- tptr += sizeof(const struct eap_frame_t);
- tlen -= sizeof(const struct eap_frame_t);
-
- switch (eap->type) {
- case EAP_FRAME_TYPE_PACKET:
- type = *(tptr);
- len = EXTRACT_16BITS(tptr+2);
- printf(", %s (%u), id %u, len %u",
- tok2str(eap_code_values, "unknown", type),
- type,
- *(tptr+1),
- len);
-
- if (!TTEST2(*tptr, len))
- goto trunc;
-
- if (type <= 2) { /* For EAP_REQUEST and EAP_RESPONSE only */
- subtype = *(tptr+4);
- printf("\n\t\t Type %s (%u)",
- tok2str(eap_type_values, "unknown", *(tptr+4)),
- *(tptr+4));
-
- switch (subtype) {
+ ND_PRINT("%s (%u), id %u, len %u",
+ tok2str(eap_code_values, "unknown", type),
+ type,
+ GET_U_1((cp + 1)),
+ len);
+
+ ND_TCHECK_LEN(cp, len);
+
+ if (type == EAP_REQUEST || type == EAP_RESPONSE) {
+ /* RFC 3748 Section 4.1 */
+ ND_ICHECK_U(len, <, 5);
+ subtype = GET_U_1(cp + 4);
+ ND_PRINT("\n\t\t Type %s (%u)",
+ tok2str(eap_type_values, "unknown", subtype),
+ subtype);
+
+ switch (subtype) {