#include <stdio.h>
#include "netdissect.h"
+#include "extract.h"
+
+static const char tstr[] = " [|telnet]";
#define TELCMDS
#define TELOPTS
#define SYNCH 242 /* for telfunc calls */
#ifdef TELCMDS
-const char *telcmds[] = {
+static const char *telcmds[] = {
"EOF", "SUSP", "ABORT", "EOR",
"SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
"EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0,
#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
#ifdef TELOPTS
-const char *telopts[NTELOPTS+1] = {
+static const char *telopts[NTELOPTS+1] = {
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
"STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
"NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
/* IAC SB .... IAC SE */
p = sp;
while (length > (u_int)(p + 1 - sp)) {
+ ND_TCHECK_2(p);
if (p[0] == IAC && p[1] == SE)
break;
p++;
}
+ ND_TCHECK(*p);
if (*p != IAC)
goto pktend;
return sp - osp;
trunc:
- ND_PRINT((ndo, "[|telnet]"));
+ ND_PRINT((ndo, "%s", tstr));
pktend:
return -1;
#undef FETCH
osp = sp;
- while (length > 0 && *sp == IAC) {
+ ND_TCHECK(*sp);
+ while (length > 0 && EXTRACT_U_1(sp) == IAC) {
/*
* Parse the Telnet command without printing it,
* to determine its length.
sp += l;
length -= l;
+ ND_TCHECK(*sp);
}
if (!first) {
if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag)
else
ND_PRINT((ndo, "]"));
}
+ return;
+trunc:
+ ND_PRINT((ndo, "%s", tstr));
}