#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
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);
}
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);
}
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);
}
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);
}
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);
}
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))
c = EXTRACT_U_1(sp);
sp++;
fn_print_char(ndo, c);
- length--;
+ length--;
}
ND_PRINT("]");
}
* 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;
*/
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:
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];
}
/* 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) {
*/
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);
}
}
}