make use of tok2str() in the CHAP and PAP printers, misc. display cosmetics

This commit is contained in:
hannes 2004-09-09 16:36:23 +00:00
parent 9092c485b3
commit bf4f8908d2

View File

@ -31,7 +31,7 @@
#ifndef lint #ifndef lint
static const char rcsid[] _U_ = static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.101 2004-08-18 14:56:28 hannes Exp $ (LBL)"; "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.102 2004-09-09 16:36:23 hannes Exp $ (LBL)";
#endif #endif
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -328,14 +328,12 @@ static const char *ccpconfopts[] = {
#define CHAP_SUCC 3 #define CHAP_SUCC 3
#define CHAP_FAIL 4 #define CHAP_FAIL 4
#define CHAP_CODEMIN CHAP_CHAL struct tok chapcode_values[] = {
#define CHAP_CODEMAX CHAP_FAIL { CHAP_CHAL, "Challenge" },
{ CHAP_RESP, "Response" },
static const char *chapcode[] = { { CHAP_SUCC, "Success" },
"Chal", /* (1) */ { CHAP_FAIL, "Fail" },
"Resp", /* (2) */ { 0, NULL}
"Succ", /* (3) */
"Fail", /* (4) */
}; };
/* PAP */ /* PAP */
@ -344,13 +342,11 @@ static const char *chapcode[] = {
#define PAP_AACK 2 #define PAP_AACK 2
#define PAP_ANAK 3 #define PAP_ANAK 3
#define PAP_CODEMIN PAP_AREQ struct tok papcode_values[] = {
#define PAP_CODEMAX PAP_ANAK { PAP_AREQ, "Auth-Req" },
{ PAP_AACK, "Auth-ACK" },
static const char *papcode[] = { { PAP_ANAK, "Auth-NACK" },
"Auth-Req", /* (1) */ { 0, NULL }
"Auth-Ack", /* (2) */
"Auth-Nak", /* (3) */
}; };
/* BAP */ /* BAP */
@ -744,16 +740,13 @@ handle_chap(const u_char *p, int length)
TCHECK(*p); TCHECK(*p);
code = *p; code = *p;
if ((code >= CHAP_CODEMIN) && (code <= CHAP_CODEMAX)) printf("CHAP, %s (0x%02x)",
printf("%s", chapcode[code - 1]); tok2str(chapcode_values,"unknown",code),
else { code);
printf("0x%02x", code);
return;
}
p++; p++;
TCHECK(*p); TCHECK(*p);
printf("(%u)", *p); /* ID */ printf(", id %u", *p); /* ID */
p++; p++;
TCHECK2(*p, 2); TCHECK2(*p, 2);
@ -826,16 +819,13 @@ handle_pap(const u_char *p, int length)
TCHECK(*p); TCHECK(*p);
code = *p; code = *p;
if ((code >= PAP_CODEMIN) && (code <= PAP_CODEMAX)) printf("PAP, %s (0x%02x)",
printf("%s", papcode[code - 1]); tok2str(papcode_values,"unknown",code),
else { code);
printf("0x%02x", code);
return;
}
p++; p++;
TCHECK(*p); TCHECK(*p);
printf("(%u)", *p); /* ID */ printf(", id %u", *p); /* ID */
p++; p++;
TCHECK2(*p, 2); TCHECK2(*p, 2);