]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use the ndo->ndo_protocol field instead of the protoname parameter
authorFrancois-Xavier Le Bail <[email protected]>
Thu, 7 Mar 2019 21:20:34 +0000 (22:20 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 8 Mar 2019 09:12:21 +0000 (10:12 +0100)
Moreover:
Fix a truncated string: "[!" is not the prefix for a truncated string.
Add two comments.
Clean up a whitespace.

netdissect.h
print-ftp.c
print-http.c
print-rtsp.c
print-sip.c
print-smtp.c
print-tcp.c
util-print.c

index 9a6475e13a5ca25ecb5564576f4c3943e592971e..adc17175d3f91fc87d6938366c0e16d08edc1bfc 100644 (file)
@@ -346,7 +346,7 @@ extern int nd_printzp(netdissect_options *, const u_char *, u_int, const u_char
 #define RESP_CODE_SECOND_TOKEN 0x00000001      /* response code is second token in response line */
 
 extern void txtproto_print(netdissect_options *, const u_char *, u_int,
-    const char *, const char **, u_int);
+                          const char **, u_int);
 
 /*
  * Locale-independent macros for testing character properties and
index f56468740161b7bb51111807d1e31d046c060f71..98335ed5bb309276bb4b67de432deb9d11205a4d 100644 (file)
@@ -29,5 +29,5 @@ void
 ftp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
 {
        ndo->ndo_protocol = "ftp";
-       txtproto_print(ndo, pptr, len, "ftp", NULL, 0);
+       txtproto_print(ndo, pptr, len, NULL, 0);
 }
index c8b6be127bc462c6b19c4a99329be630bd808757..866f3827feb0e3f3ae65fe81750767a3d2d7e6f1 100644 (file)
@@ -74,5 +74,5 @@ void
 http_print(netdissect_options *ndo, const u_char *pptr, u_int len)
 {
        ndo->ndo_protocol = "http";
-       txtproto_print(ndo, pptr, len, "http", httpcmds, RESP_CODE_SECOND_TOKEN);
+       txtproto_print(ndo, pptr, len, httpcmds, RESP_CODE_SECOND_TOKEN);
 }
index 8c04e11acb064758e56b1c24a1a8ab665142952f..d607acd6bb3adca3d1ac1039df105fb247d5aff1 100644 (file)
@@ -44,5 +44,5 @@ void
 rtsp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
 {
        ndo->ndo_protocol = "rtsp";
-       txtproto_print(ndo, pptr, len, "rtsp", rtspcmds, RESP_CODE_SECOND_TOKEN);
+       txtproto_print(ndo, pptr, len, rtspcmds, RESP_CODE_SECOND_TOKEN);
 }
index 3be6a38379475191de6fb38b19905048c37bfc2e..14fe94e56d2b1145323fc618874e3176d59fcc07 100644 (file)
@@ -51,5 +51,5 @@ void
 sip_print(netdissect_options *ndo, const u_char *pptr, u_int len)
 {
        ndo->ndo_protocol = "sip";
-       txtproto_print(ndo, pptr, len, "sip", sipcmds, RESP_CODE_SECOND_TOKEN);
+       txtproto_print(ndo, pptr, len, sipcmds, RESP_CODE_SECOND_TOKEN);
 }
index a85ea8a9fc4c606ed1a47b8f503cd5f856139212..d14d8f35f549a49fb623d64febbfe9477e004949 100644 (file)
@@ -29,5 +29,5 @@ void
 smtp_print(netdissect_options *ndo, const u_char *pptr, u_int len)
 {
        ndo->ndo_protocol = "smtp";
-       txtproto_print(ndo, pptr, len, "smtp", NULL, 0);
+       txtproto_print(ndo, pptr, len, NULL, 0);
 }
index 55bff7663a0901db6d80c748da1f4433b85c4b01..66834e84fe7d2bdc2d620e7b8b63bba4bf96f978 100644 (file)
@@ -709,7 +709,8 @@ tcp_print(netdissect_options *ndo,
                 smtp_print(ndo, bp, length);
         } else if (IS_SRC_OR_DST_PORT(WHOIS_PORT)) {
                 ND_PRINT(": ");
-                txtproto_print(ndo, bp, length, "whois", NULL, 0); /* RFC 3912 */
+                ndo->ndo_protocol = "whois";   /* needed by txtproto_print() */
+                txtproto_print(ndo, bp, length, NULL, 0); /* RFC 3912 */
         } else if (IS_SRC_OR_DST_PORT(BGP_PORT))
                 bgp_print(ndo, bp, length);
         else if (IS_SRC_OR_DST_PORT(PPTP_PORT))
@@ -832,7 +833,7 @@ print_tcp_rst_data(netdissect_options *ndo,
                 c = EXTRACT_U_1(sp);
                 sp++;
                 fn_print_char(ndo, c);
-               length--;
+                length--;
         }
         ND_PRINT("]");
 }
index a982e86da4deb95ec4ca2e76ec632e1a4a085b1f..83bcca662f1c65b60924d3b2dab30ae2fe0443aa 100644 (file)
@@ -752,8 +752,8 @@ fetch_token(netdissect_options *ndo, const u_char *pptr, u_int idx, u_int len,
  * the line ending.
  */
 static u_int
-print_txt_line(netdissect_options *ndo, const char *protoname,
-    const char *prefix, const u_char *pptr, u_int idx, u_int len)
+print_txt_line(netdissect_options *ndo, const char *prefix,
+              const u_char *pptr, u_int idx, u_int len)
 {
        u_int startidx;
        u_int linelen;
@@ -813,8 +813,8 @@ print_txt_line(netdissect_options *ndo, const char *protoname,
         */
 trunc:
        linelen = idx - startidx;
-       ND_PRINT("%s%.*s[!%s]", prefix, (int)linelen, pptr + startidx,
-           protoname);
+       ND_PRINT("%s%.*s", prefix, (int)linelen, pptr + startidx);
+       nd_print_trunc(ndo);
        return (0);
 
 print:
@@ -822,9 +822,10 @@ print:
        return (idx);
 }
 
+/* Assign needed before calling txtproto_print(): ndo->ndo_protocol = "proto" */
 void
 txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
-    const char *protoname, const char **cmds, u_int flags)
+              const char **cmds, u_int flags)
 {
        u_int idx, eol;
        u_char token[MAX_TOKEN+1];
@@ -896,7 +897,7 @@ txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
        }
 
        /* Capitalize the protocol name */
-       for (pnp = protoname; *pnp != '\0'; pnp++)
+       for (pnp = ndo->ndo_protocol; *pnp != '\0'; pnp++)
                ND_PRINT("%c", ND_TOUPPER((u_char)*pnp));
 
        if (print_this) {
@@ -916,14 +917,14 @@ txtproto_print(netdissect_options *ndo, const u_char *pptr, u_int len,
                         */
                        ND_PRINT(", length: %u", len);
                        for (idx = 0;
-                           idx < len && (eol = print_txt_line(ndo, protoname, "\n\t", pptr, idx, len)) != 0;
+                           idx < len && (eol = print_txt_line(ndo, "\n\t", pptr, idx, len)) != 0;
                            idx = eol)
                                ;
                } else {
                        /*
                         * Just print the first text line.
                         */
-                       print_txt_line(ndo, protoname, ": ", pptr, 0, len);
+                       print_txt_line(ndo, ": ", pptr, 0, len);
                }
        }
 }