]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-dtp.c
NDOize AH, BEEP and DTP decoders
[tcpdump] / print-dtp.c
index 90ce6cc377c13fb56f76291390e3c5f0de94251c..e502ad54ce1f394b6112124c0365dd751c1b5a76 100644 (file)
 
 #include <tcpdump-stdinc.h>
 
-#include <stdio.h>
-#include <string.h>
-
-#include "interface.h"
+#include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"
-#include "nlpid.h"
 
 #define DTP_HEADER_LEN                 1
 #define DTP_DOMAIN_TLV                 0x0001
@@ -46,7 +42,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 +52,17 @@ dtp_print (const u_char *pptr, u_int length)
 
     tptr = pptr;
 
-    if (!TTEST2(*tptr, DTP_HEADER_LEN))
+    if (!ND_TTEST2(*tptr, DTP_HEADER_LEN))
        goto trunc;
 
-    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,7 +70,7 @@ dtp_print (const u_char *pptr, u_int length)
 
     while (tptr < (pptr+length)) {
 
-        if (!TTEST2(*tptr, 4))
+        if (!ND_TTEST2(*tptr, 4))
             goto trunc;
 
        type = EXTRACT_16BITS(tptr);
@@ -85,22 +81,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(tptr+4)));
                 break;
 
         default:
@@ -112,7 +108,7 @@ dtp_print (const u_char *pptr, u_int length)
     return;
 
  trunc:
-    printf("[|dtp]");
+    ND_PRINT((ndo, "[|dtp]"));
 }
 
 /*