diff options
author | itojun <itojun> | 2001-06-26 03:01:10 +0000 |
---|---|---|
committer | itojun <itojun> | 2001-06-26 03:01:10 +0000 |
commit | b34c8fc6f8e76e3e9d295b42af751c5f31ff99a0 (patch) | |
tree | c2c2eb4bd076a65b5720e3b1aaac5c53141161fe /print-telnet.c | |
parent | 003d0035f4db84d00b1b76802869c3563335612d (diff) | |
download | tcpdump-b34c8fc6f8e76e3e9d295b42af751c5f31ff99a0.tar.gz |
improve ENCRYPT and AUTHENTICATION telnet negotiation printing.
Diffstat (limited to 'print-telnet.c')
-rw-r--r-- | print-telnet.c | 90 |
1 files changed, 73 insertions, 17 deletions
diff --git a/print-telnet.c b/print-telnet.c index df5370c8..af1218f6 100644 --- a/print-telnet.c +++ b/print-telnet.c @@ -51,7 +51,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.15 2001-06-25 23:03:57 itojun Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.16 2001-06-26 03:01:10 itojun Exp $"; #endif #include <sys/param.h> @@ -77,6 +77,44 @@ static const char rcsid[] = # define TELCMD_FIRST SE #endif +/* normal */ +static const char *cmds[] = { + "IS", "SEND", "INFO", +}; + +/* 37: Authentication */ +static const char *authcmd[] = { + "IS", "SEND", "REPLY", "NAME", +}; +static const char *authtype[] = { + "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", + "SRP", "RSA", "SSL", NULL, NULL, + "LOKI", "SSA", "KEA_SJ", "KEA_SJ_INTEG", "DSS", + "NTLM", +}; + +/* 38: Encryption */ +static const char *enccmd[] = { + "IS", "SUPPORT", "REPLY", "START", "END", + "REQUEST-START", "REQUEST-END", "END_KEYID", "DEC_KEYID", +}; +static const char *enctype[] = { + "NULL", "DES_CFB64", "DES_OFB64", "DES3_CFB64", "DES3_OFB64", + NULL, "CAST5_40_CFB64", "CAST5_40_OFB64", "CAST128_CFB64", "CAST128_OFB64", +}; + +#define STR_OR_ID(x, tab) \ + (((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x)) + +static char * +numstr(int x) +{ + static char buf[20]; + + snprintf(buf, sizeof(buf), "%#x", x); + return buf; +} + /* sp points to IAB byte */ static int telnet_parse(const u_char *sp, u_int length, int print) @@ -139,25 +177,43 @@ telnet_parse(const u_char *sp, u_int length, int print) if (*p != IAC) goto trunc; - PEEK(c, sp, length); - if (c) { - while (p > sp) { - FETCH(x, sp, length); - if (print) - (void)printf(" %#x", x); - } - } else { + switch (x) { + case TELOPT_AUTHENTICATION: + if (p <= sp) + break; + FETCH(c, sp, length); + if (print) + (void)printf(" %s", STR_OR_ID(c, authcmd)); + if (p <= sp) + break; FETCH(c, sp, length); if (print) - (void)printf(" IS '"); - while (p > sp) { - FETCH(x, sp, length); - if (print) - safeputchar(x); - } - /* terminating IAC SE */ + (void)printf(" %s", STR_OR_ID(c, authtype)); + break; + case TELOPT_ENCRYPT: + if (p <= sp) + break; + FETCH(c, sp, length); + if (print) + (void)printf(" %s", STR_OR_ID(c, enccmd)); + if (p <= sp) + break; + FETCH(c, sp, length); + if (print) + (void)printf(" %s", STR_OR_ID(c, enctype)); + break; + default: + if (p <= sp) + break; + FETCH(c, sp, length); + if (print) + (void)printf(" %s", STR_OR_ID(c, cmds)); + break; + } + while (p > sp) { + FETCH(x, sp, length); if (print) - (void)printf("'"); + (void)printf(" %#x", x); } /* terminating IAC SE */ if (print) |