]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-dtp.c
Add CAP_FCNTL and use cap_fcntls_limit().
[tcpdump] / print-dtp.c
index 90ce6cc377c13fb56f76291390e3c5f0de94251c..5d84a770eecaa78ca44424869b441711dadd8d36 100644 (file)
  * Original code by Carles Kishimoto <[email protected]>
  */
 
+#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
 #include "interface.h"
 #include "addrtoname.h"
 #include "extract.h"
-#include "nlpid.h"
 
 #define DTP_HEADER_LEN                 1
 #define DTP_DOMAIN_TLV                 0x0001
@@ -46,7 +43,7 @@ static const struct tok dtp_tlv_values[] = {
 };
 
 void
-dtp_print (const u_char *pptr, u_int length)
+dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
 {
     int type, len;
     const u_char *tptr;
@@ -56,17 +53,16 @@ dtp_print (const u_char *pptr, u_int length)
 
     tptr = pptr;
 
-    if (!TTEST2(*tptr, DTP_HEADER_LEN))
-       goto trunc;
+    ND_TCHECK2(*tptr, DTP_HEADER_LEN);
 
-    printf("DTPv%u, length %u",
+    ND_PRINT((ndo, "DTPv%u, length %u",
            (*tptr),
-           length);
+           length));
 
     /*
      * In non-verbose mode, just print version.
      */
-    if (vflag < 1) {
+    if (ndo->ndo_vflag < 1) {
        return;
     }
 
@@ -74,8 +70,7 @@ dtp_print (const u_char *pptr, u_int length)
 
     while (tptr < (pptr+length)) {
 
-        if (!TTEST2(*tptr, 4))
-            goto trunc;
+        ND_TCHECK2(*tptr, 4);
 
        type = EXTRACT_16BITS(tptr);
         len  = EXTRACT_16BITS(tptr+2);
@@ -85,22 +80,22 @@ dtp_print (const u_char *pptr, u_int length)
             return;
         }
 
-        printf("\n\t%s (0x%04x) TLV, length %u",
+        ND_PRINT((ndo, "\n\t%s (0x%04x) TLV, length %u",
                tok2str(dtp_tlv_values, "Unknown", type),
-               type, len);
+               type, len));
 
         switch (type) {
        case DTP_DOMAIN_TLV:
-               printf(", %s", tptr+4);
+               ND_PRINT((ndo, ", %s", tptr+4));
                break;
 
        case DTP_STATUS_TLV:
        case DTP_DTP_TYPE_TLV:
-                printf(", 0x%x", *(tptr+4));
+                ND_PRINT((ndo, ", 0x%x", *(tptr+4)));
                 break;
 
        case DTP_NEIGHBOR_TLV:
-                printf(", %s", etheraddr_string(tptr+4));
+                ND_PRINT((ndo, ", %s", etheraddr_string(ndo, tptr+4)));
                 break;
 
         default:
@@ -112,7 +107,7 @@ dtp_print (const u_char *pptr, u_int length)
     return;
 
  trunc:
-    printf("[|dtp]");
+    ND_PRINT((ndo, "[|dtp]"));
 }
 
 /*