X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/886fcf669f13779c8d25370c95b47993f5e3c7dd..refs/pull/1034/head:/print-ssh.c diff --git a/print-ssh.c b/print-ssh.c index 0126bd0e..5207c52e 100644 --- a/print-ssh.c +++ b/print-ssh.c @@ -18,9 +18,7 @@ #endif #include "netdissect-stdinc.h" - -#include -#include +#include "netdissect-ctype.h" #include "netdissect.h" #include "extract.h" @@ -29,7 +27,6 @@ static int ssh_print_version(netdissect_options *ndo, const u_char *pptr, u_int len) { u_int idx = 0; - const char *pnp; if ( GET_U_1(pptr+idx) != 'S' ) return 0; @@ -45,14 +42,17 @@ ssh_print_version(netdissect_options *ndo, const u_char *pptr, u_int len) idx++; while (idx < len) { - if (GET_U_1(pptr + idx) == '\n') { + u_char c; + + c = GET_U_1(pptr + idx); + if (c == '\n') { /* * LF without CR; end of line. * Skip the LF and print the line, with the * exception of the LF. */ goto print; - } else if (GET_U_1(pptr + idx) == '\r') { + } else if (c == '\r') { /* CR - any LF? */ if ((idx+1) >= len) { /* not in this packet */ @@ -72,8 +72,7 @@ ssh_print_version(netdissect_options *ndo, const u_char *pptr, u_int len) * if it were binary data and don't print it. */ goto trunc; - } else if (!isascii(GET_U_1(pptr + idx)) || - !isprint(GET_U_1(pptr + idx)) ) { + } else if (!ND_ASCII_ISPRINT(c) ) { /* * Not a printable ASCII character; treat this * as if it were binary data and don't print it. @@ -86,9 +85,7 @@ trunc: return -1; print: ND_PRINT(": "); - /* Capitalize the protocol name */ - for (pnp = ndo->ndo_protocol; *pnp != '\0'; pnp++) - ND_PRINT("%c", ND_TOUPPER((u_char)*pnp)); + nd_print_protocol_caps(ndo); ND_PRINT(": %.*s", (int)idx, pptr); return idx; }