]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-nsh.c
Fix mkdep invocations.
[tcpdump] / print-nsh.c
index 0130e6dd1c96f9a1c88ea4b4ad5c4e4767f8ea59..6abf9f17c48aba545aee1c1a6324e05328ffbfd6 100644 (file)
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* \summary: Network Service Header (NSH) printer */
+
+/* specification: draft-ietf-sfc-nsh-01 */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -41,10 +45,6 @@ static const struct tok nsh_flags [] = {
 #define NSH_SERVICE_PATH_HDR_LEN 4
 #define NSH_HDR_WORD_SIZE 4U
 
-/*
- * NSH, draft-ietf-sfc-nsh-01 Network Service Header
- */
-
 void
 nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
 {
@@ -77,7 +77,7 @@ nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
     bp += 1;
     next_protocol = *bp;
     bp += 1;
-    service_path_id = EXTRACT_24BITS(bp);
+    service_path_id = EXTRACT_BE_U_3(bp);
     bp += 3;
     service_index = *bp;
     bp += 1;
@@ -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,7 +125,7 @@ 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;
                 bp += 1;
@@ -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"));