]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-nsh.c
Use nd_ types, add EXTRACT_ calls.
[tcpdump] / print-nsh.c
index 82976a03a029fa4e3fe84c1009454ec1676b9b03..2734382ce1a95af5d33e535e6cbe6d8c8f579252 100644 (file)
@@ -66,20 +66,20 @@ nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
     if (len < NSH_BASE_HDR_LEN + NSH_SERVICE_PATH_HDR_LEN)
         goto trunc;
 
-    ND_TCHECK2(*bp, NSH_BASE_HDR_LEN + NSH_SERVICE_PATH_HDR_LEN);
+    ND_TCHECK_LEN(bp, NSH_BASE_HDR_LEN + NSH_SERVICE_PATH_HDR_LEN);
 
-    ver = (uint8_t)(*bp >> 6);
-    flags = *bp;
+    ver = (uint8_t)(EXTRACT_U_1(bp) >> 6);
+    flags = EXTRACT_U_1(bp);
     bp += 1;
-    length = *bp;
+    length = EXTRACT_U_1(bp);
     bp += 1;
-    md_type = *bp;
+    md_type = EXTRACT_U_1(bp);
     bp += 1;
-    next_protocol = *bp;
+    next_protocol = EXTRACT_U_1(bp);
     bp += 1;
-    service_path_id = EXTRACT_24BITS(bp);
+    service_path_id = EXTRACT_BE_U_3(bp);
     bp += 3;
-    service_index = *bp;
+    service_index = EXTRACT_U_1(bp);
     bp += 1;
 
     ND_PRINT((ndo, "NSH, "));
@@ -101,7 +101,7 @@ nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
     if (len < length * NSH_HDR_WORD_SIZE)
         goto trunc;
 
-    ND_TCHECK2(*bp, length * NSH_HDR_WORD_SIZE);
+    ND_TCHECK_LEN(bp, length * NSH_HDR_WORD_SIZE);
 
     /*
      * length includes the lengths of the Base and Service Path headers.
@@ -117,7 +117,7 @@ nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
     if (ndo->ndo_vflag > 2) {
         if (md_type == 0x01) {
             for (n = 0; n < length - 2; n++) {
-                ctx = EXTRACT_32BITS(bp);
+                ctx = EXTRACT_BE_U_4(bp);
                 bp += NSH_HDR_WORD_SIZE;
                 ND_PRINT((ndo, "\n        Context[%02d]: 0x%08x", n, ctx));
             }
@@ -125,11 +125,11 @@ nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
         else if (md_type == 0x02) {
             n = 0;
             while (n < length - 2) {
-                tlv_class = EXTRACT_16BITS(bp);
+                tlv_class = EXTRACT_BE_U_2(bp);
                 bp += 2;
-                tlv_type  = *bp;
+                tlv_type  = EXTRACT_U_1(bp);
                 bp += 1;
-                tlv_len   = *bp;
+                tlv_len   = EXTRACT_U_1(bp);
                 bp += 1;
 
                 ND_PRINT((ndo, "\n        TLV Class %d, Type %d, Len %d",
@@ -143,7 +143,7 @@ nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
                 }
 
                 for (vn = 0; vn < tlv_len; vn++) {
-                    ctx = EXTRACT_32BITS(bp);
+                    ctx = EXTRACT_BE_U_4(bp);
                     bp += NSH_HDR_WORD_SIZE;
                     ND_PRINT((ndo, "\n            Value[%02d]: 0x%08x", vn, ctx));
                 }
@@ -170,7 +170,7 @@ nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
         ip6_print(ndo, bp, next_len);
         break;
     case 0x3:
-        ether_print(ndo, bp, next_len, next_len, NULL, NULL);
+        ether_print(ndo, bp, next_len, ndo->ndo_snapend - bp, NULL, NULL);
         break;
     default:
         ND_PRINT((ndo, "ERROR: unknown-next-protocol"));