X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/fb2479d733dbe8a991d11909b319341f7db62ab1..0023eaa78f123676bfa9c5fba72ea4b8a59aaa70:/print-telnet.c diff --git a/print-telnet.c b/print-telnet.c index f23d8a56..97be4b91 100644 --- a/print-telnet.c +++ b/print-telnet.c @@ -1,4 +1,4 @@ -/* $NetBSD: print-telnet.c,v 1.2 1999/10/11 12:40:12 sjg Exp $ */ +/* $NetBSD: print-telnet.c,v 1.2 1999/10/11 12:40:12 sjg Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -47,9 +47,7 @@ /* \summary: Telnet option printer */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" @@ -58,12 +56,8 @@ #include "netdissect.h" #include "extract.h" -static const char tstr[] = " [|telnet]"; - -#define TELCMDS -#define TELOPTS -/* NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp */ +/* NetBSD: telnet.h,v 1.9 2001/06/11 01:50:50 wiz Exp */ /* * Definitions for the TELNET protocol. @@ -91,15 +85,11 @@ static const char tstr[] = " [|telnet]"; #define SYNCH 242 /* for telfunc calls */ -#ifdef 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, }; -#else -extern char *telcmds[]; -#endif #define TELCMD_FIRST xEOF #define TELCMD_LAST IAC @@ -116,8 +106,8 @@ extern char *telcmds[]; #define TELOPT_STATUS 5 /* give status */ #define TELOPT_TM 6 /* timing mark */ #define TELOPT_RCTE 7 /* remote controlled transmission and echo */ -#define TELOPT_NAOL 8 /* negotiate about output line width */ -#define TELOPT_NAOP 9 /* negotiate about output page size */ +#define TELOPT_NAOL 8 /* negotiate about output line width */ +#define TELOPT_NAOP 9 /* negotiate about output page size */ #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ #define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ @@ -125,7 +115,7 @@ extern char *telcmds[]; #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ -#define TELOPT_XASCII 17 /* extended ascic character set */ +#define TELOPT_XASCII 17 /* extended ascii character set */ #define TELOPT_LOGOUT 18 /* force logout */ #define TELOPT_BM 19 /* byte macro */ #define TELOPT_DET 20 /* data entry terminal */ @@ -152,7 +142,6 @@ extern char *telcmds[]; #define NTELOPTS (1+TELOPT_NEW_ENVIRON) -#ifdef TELOPTS static const char *telopts[NTELOPTS+1] = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", @@ -170,7 +159,6 @@ static const char *telopts[NTELOPTS+1] = { #define TELOPT_LAST TELOPT_NEW_ENVIRON #define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) #define TELOPT(x) telopts[(x)-TELOPT_FIRST] -#endif /* sub-option qualifiers */ #define TELQUAL_IS 0 /* option is... */ @@ -397,8 +385,7 @@ telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print) do { \ if (length < 1) \ goto pktend; \ - ND_TCHECK_1(sp); \ - c = EXTRACT_U_1(sp); \ + c = GET_U_1(sp); \ sp++; \ length--; \ } while (0) @@ -439,13 +426,11 @@ telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print) /* IAC SB .... IAC SE */ 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 +483,8 @@ 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); pktend: return -1; #undef FETCH @@ -514,10 +497,10 @@ 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 +515,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 @@ -545,7 +528,6 @@ telnet_print(netdissect_options *ndo, const u_char *sp, u_int length) sp += l; length -= l; - ND_TCHECK_1(sp); } if (!first) { if (ndo->ndo_Xflag && 2 < ndo->ndo_vflag) @@ -553,7 +535,4 @@ telnet_print(netdissect_options *ndo, const u_char *sp, u_int length) else ND_PRINT("]"); } - return; -trunc: - ND_PRINT("%s", tstr); }