- } else if (ether_encap_print(ether_type, p, length, caplen,
- &extracted_ether_type) == 0) {
- /* ether_type not known, print raw packet */
- if (!eflag)
- ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN);
-
- if (!suppress_default_print)
- default_print(p, caplen);
- }
+ if (length < 2) {
+ ND_PRINT("[|arista]");
+ return hdrlen + length;
+ }
+ ether_type_print(ndo, length_type);
+ ND_PRINT(", length %u: ", orig_length);
+ int bytesConsumed = arista_ethertype_print(ndo, p, length);
+ if (bytesConsumed > 0) {
+ p += bytesConsumed;
+ length -= bytesConsumed;
+ caplen -= bytesConsumed;
+ hdrlen += bytesConsumed;
+ goto recurse;
+ } else {
+ /* subtype/version not known, print raw packet */
+ if (!ndo->ndo_eflag && length_type > MAX_ETHERNET_LENGTH_VAL) {
+ ether_addresses_print(ndo, src.addr, dst.addr);
+ ether_type_print(ndo, length_type);
+ ND_PRINT(", length %u: ", orig_length);
+ }
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ }
+ } else {
+ /*
+ * It's a type field with some other value.
+ */
+ if (ndo->ndo_eflag) {
+ ether_type_print(ndo, length_type);
+ if (!printed_length)
+ ND_PRINT(", length %u: ", orig_length);
+ else
+ ND_PRINT(", ");
+ }
+ if (ethertype_print(ndo, length_type, p, length, caplen, &src, &dst) == 0) {
+ /* type not known, print raw packet */
+ if (!ndo->ndo_eflag) {
+ /*
+ * We didn't print the full link-layer
+ * header, as -e wasn't specified, so
+ * print only the source and destination
+ * MAC addresses and the final Ethernet
+ * type.
+ */
+ ether_addresses_print(ndo, src.addr, dst.addr);
+ ether_type_print(ndo, length_type);
+ ND_PRINT(", length %u: ", orig_length);
+ }
+
+ if (!ndo->ndo_suppress_default_print)
+ ND_DEFAULTPRINT(p, caplen);
+ }
+ }
+ return hdrlen;