]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ether.c
Use more the EXTRACT_U_1() macro to fetch a one-byte value (26/n)
[tcpdump] / print-ether.c
index 59d15c24481a509f5c27fb9682fded67fca65a11..8d8341bae107b77352c88b3d79f7c655401dbea6 100644 (file)
@@ -72,6 +72,7 @@ const struct tok ethertype_values[] = {
     { ETHERTYPE_RRCP,           "RRCP" },
     { ETHERTYPE_MS_NLB_HB,      "MS NLB heartbeat" },
     { ETHERTYPE_JUMBO,          "Jumbo" },
+    { ETHERTYPE_NSH,            "NSH" },
     { ETHERTYPE_LOOPBACK,       "Loopback" },
     { ETHERTYPE_ISO,            "OSI" },
     { ETHERTYPE_GRE_ISO,        "GRE-OSI" },
@@ -101,7 +102,7 @@ ether_hdr_print(netdissect_options *ndo,
                     etheraddr_string(ndo, ESRC(ep)),
                     etheraddr_string(ndo, EDST(ep))));
 
-       length_type = EXTRACT_16BITS(&ep->ether_length_type);
+       length_type = EXTRACT_BE_U_2(&ep->ether_length_type);
        if (!ndo->ndo_qflag) {
                if (length_type <= ETHERMTU) {
                        ND_PRINT((ndo, ", 802.3"));
@@ -126,6 +127,8 @@ ether_hdr_print(netdissect_options *ndo,
  * This might be encapsulated within another frame; we might be passed
  * a pointer to a function that can print header information for that
  * frame's protocol, and an argument to pass to that function.
+ *
+ * FIXME: caplen can and should be derived from ndo->ndo_snapend and p.
  */
 u_int
 ether_print(netdissect_options *ndo,
@@ -165,7 +168,7 @@ ether_print(netdissect_options *ndo,
        src.addr_string = etheraddr_string;
        dst.addr = EDST(ep);
        dst.addr_string = etheraddr_string;
-       length_type = EXTRACT_16BITS(&ep->ether_length_type);
+       length_type = EXTRACT_BE_U_2(&ep->ether_length_type);
 
 recurse:
        /*
@@ -198,12 +201,12 @@ recurse:
                        return (hdrlen + length);
                }
                if (ndo->ndo_eflag) {
-                       uint16_t tag = EXTRACT_16BITS(p);
+                       uint16_t tag = EXTRACT_BE_U_2(p);
 
                        ND_PRINT((ndo, "%s, ", ieee8021q_tci_string(tag)));
                }
 
-               length_type = EXTRACT_16BITS(p + 2);
+               length_type = EXTRACT_BE_U_2(p + 2);
                if (ndo->ndo_eflag && length_type > ETHERMTU)
                        ND_PRINT((ndo, "ethertype %s, ", tok2str(ethertype_values,"0x%04x", length_type)));
                p += 4;
@@ -360,7 +363,11 @@ ethertype_print(netdissect_options *ndo,
                return (1);
 
        case ETHERTYPE_ISO:
-               isoclns_print(ndo, p + 1, length - 1, length - 1);
+               if (length == 0 || caplen == 0) {
+                       ND_PRINT((ndo, " [|osi]"));
+                       return (1);
+               }
+               isoclns_print(ndo, p + 1, length - 1);
                return(1);
 
        case ETHERTYPE_PPPOED:
@@ -402,6 +409,10 @@ ethertype_print(netdissect_options *ndo,
                lldp_print(ndo, p, length);
                return (1);
 
+        case ETHERTYPE_NSH:
+                nsh_print(ndo, p, length);
+                return (1);
+
         case ETHERTYPE_LOOPBACK:
                loopback_print(ndo, p, length);
                 return (1);
@@ -433,7 +444,7 @@ ethertype_print(netdissect_options *ndo,
                return (1);
 
        case ETHERTYPE_MEDSA:
-               medsa_print(ndo, p, length, caplen);
+               medsa_print(ndo, p, length, caplen, src, dst);
                return (1);
 
        case ETHERTYPE_LAT: