]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-telnet.c
IPoIB: Add the output with -e for a capture test
[tcpdump] / print-telnet.c
index a9a517a0c299316c736a28c1c0e8b29f23d092a1..f2ff1389f17d4b0a6e326cf16050655502caa481 100644 (file)
 /* \summary: Telnet option printer */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
 
 #include <stdio.h>
 
 #include "netdissect.h"
 #include "extract.h"
 
-static const char tstr[] = " [|telnet]";
 
 #define TELCMDS
 #define TELOPTS
@@ -382,7 +381,7 @@ numstr(int x)
 {
        static char buf[20];
 
-       snprintf(buf, sizeof(buf), "%#x", x);
+       nd_snprintf(buf, sizeof(buf), "%#x", x);
        return buf;
 }
 
@@ -398,7 +397,7 @@ telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
                if (length < 1) \
                        goto pktend; \
                ND_TCHECK_1(sp); \
-               c = EXTRACT_U_1(sp); \
+               c = GET_U_1(sp); \
                sp++; \
                length--; \
        } while (0)
@@ -440,12 +439,12 @@ telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
                p = sp;
                while (length > (u_int)(p + 1 - sp)) {
                        ND_TCHECK_2(p);
-                       if (EXTRACT_U_1(p) == IAC && EXTRACT_U_1(p + 1) == SE)
+                       if (GET_U_1(p) == IAC && GET_U_1(p + 1) == SE)
                                break;
                        p++;
                }
                ND_TCHECK_1(p);
-               if (EXTRACT_U_1(p) != IAC)
+               if (GET_U_1(p) != IAC)
                        goto pktend;
 
                switch (x) {
@@ -498,10 +497,10 @@ telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
        }
 
 done:
-       return sp - osp;
+       return (int)(sp - osp);
 
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
 pktend:
        return -1;
 #undef FETCH
@@ -514,10 +513,11 @@ telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
        const u_char *osp;
        int l;
 
+       ndo->ndo_protocol = "telnet";
        osp = sp;
 
        ND_TCHECK_1(sp);
-       while (length > 0 && EXTRACT_U_1(sp) == IAC) {
+       while (length > 0 && GET_U_1(sp) == IAC) {
                /*
                 * Parse the Telnet command without printing it,
                 * to determine its length.
@@ -532,7 +532,7 @@ telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
                if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag) {
                        if (first)
                                ND_PRINT("\nTelnet:");
-                       hex_print_with_offset(ndo, "\n", sp, l, sp - osp);
+                       hex_print_with_offset(ndo, "\n", sp, l, (u_int)(sp - osp));
                        if (l > 8)
                                ND_PRINT("\n\t\t\t\t");
                        else
@@ -555,5 +555,5 @@ telnet_print(netdissect_options *ndo, const u_char *sp, u_int length)
        }
        return;
 trunc:
-       ND_PRINT("%s", tstr);
+       nd_print_trunc(ndo);
 }