X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/19021b87db9b28427f0b6191d65c3b08422fe24a..1ee09c1510704191a14df4eb914dba3d5dc9ab58:/print-ppp.c diff --git a/print-ppp.c b/print-ppp.c index 410614e4..603dd6c4 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -31,7 +31,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.105 2004-10-28 11:21:23 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.109 2005-04-20 22:15:17 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -101,6 +101,9 @@ struct tok ppptype2str[] = { { PPP_PAP, "PAP" }, { PPP_LQM, "LQM" }, { PPP_CHAP, "CHAP" }, + { PPP_EAP, "EAP" }, + { PPP_SPAP, "SPAP" }, + { PPP_SPAP_OLD, "Old-SPAP" }, { PPP_BACP, "BACP" }, { PPP_BAP, "BAP" }, { PPP_MPCP, "MLPPP-CP" }, @@ -324,6 +327,13 @@ struct tok ip6cpopt_values[] = { #define AUTHALG_MSCHAP1 128 /* RFC2433 */ #define AUTHALG_MSCHAP2 129 /* RFC2795 */ +struct tok authalg_values[] = { + { AUTHALG_CHAPMD5, "MD5" }, + { AUTHALG_MSCHAP1, "MS-CHAPv1" }, + { AUTHALG_MSCHAP2, "MS-CHAPv2" }, + { 0, NULL } +}; + /* FCS Alternatives - to be supported */ /* Multilink Endpoint Discriminator (RFC1717) */ @@ -588,39 +598,20 @@ print_lcp_config_options(const u_char *p, int length) case LCPOPT_AP: if (len >= 4) { TCHECK2(*(p + 2), 2); + printf(" %s", tok2str(ppptype2str,"Unknown Auth Proto (0x04x)",EXTRACT_16BITS(p+2))); + switch (EXTRACT_16BITS(p+2)) { - case PPP_PAP: - printf(" PAP"); - break; case PPP_CHAP: - printf(" CHAP"); TCHECK(p[4]); - switch (p[4]) { - default: - printf(", unknown-algorithm-%u", p[4]); - break; - case AUTHALG_CHAPMD5: - printf(", MD5"); - break; - case AUTHALG_MSCHAP1: - printf(", MSCHAPv1"); - break; - case AUTHALG_MSCHAP2: - printf(", MSCHAPv2"); - break; - } + printf(", %s",tok2str(authalg_values,"Unknown Auth Alg %u",p[4])); break; + case PPP_PAP: /* fall through */ case PPP_EAP: - printf(" EAP"); - break; case PPP_SPAP: - printf(" SPAP"); - break; case PPP_SPAP_OLD: - printf(" Old-SPAP"); - break; + break; default: - printf("unknown"); + print_unknown_data(p,"\n\t",len); } } break; @@ -881,6 +872,16 @@ handle_pap(const u_char *p, int length) len = EXTRACT_16BITS(p); p += 2; + if ((int)len > length) { + printf(", length %u > packet size", len); + return; + } + length = len; + if (length < (p - p0)) { + printf(", length %u < PAP header length", length); + return; + } + switch (code) { case PAP_AREQ: if (length - (p - p0) < 1) @@ -1158,8 +1159,8 @@ ppp_hdlc(const u_char *p, int length) switch (proto) { case PPP_IP: - ip_print(b+1, t - b - 1); - goto cleanup; + ip_print(gndo, b+1, t - b - 1); + goto cleanup; #ifdef INET6 case PPP_IPV6: ip6_print(b+1, t - b - 1); @@ -1172,7 +1173,7 @@ ppp_hdlc(const u_char *p, int length) proto = EXTRACT_16BITS(b); /* next guess - load two octets */ switch (proto) { - case 0xff03: /* looks like a PPP frame */ + case (PPP_ADDRESS << 8 | PPP_CONTROL): /* looks like a PPP frame */ proto = EXTRACT_16BITS(b+2); /* load the PPP proto-id */ handle_ppp(proto, b+4, t - b - 4); break; @@ -1222,7 +1223,7 @@ handle_ppp(u_int proto, const u_char *p, int length) case ETHERTYPE_IP: /*XXX*/ case PPP_VJNC: case PPP_IP: - ip_print(p, length); + ip_print(gndo, p, length); break; #ifdef INET6 case ETHERTYPE_IPV6: /*XXX*/ @@ -1606,3 +1607,11 @@ printx: #endif /* __bsdi__ */ return (hdrlength); } + + +/* + * Local Variables: + * c-style: whitesmith + * c-basic-offset: 8 + * End: + */