X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/f9dbcc9615275370677b7ae164417bf2f44f0c41..9f957a5883cb4c5c99cefa71b42fc9d2d27d73e1:/print-ppp.c diff --git a/print-ppp.c b/print-ppp.c index 3ab4c96d..31b87a24 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -179,9 +179,6 @@ static const struct tok cpcodes[] = { #define LCPOPT_SDLOS 29 #define LCPOPT_PPPMUX 30 -#define LCPOPT_MIN LCPOPT_VEXT -#define LCPOPT_MAX LCPOPT_PPPMUX - static const char *lcpconfopts[] = { "Vend-Ext", /* (0) */ "MRU", /* (1) */ @@ -216,6 +213,8 @@ static const char *lcpconfopts[] = { "PPP-Muxing", /* (30) */ }; +#define NUM_LCPOPTS (sizeof lcpconfopts / sizeof lcpconfopts[0]) + /* ECP - to be supported */ /* CCP Config Options */ @@ -427,7 +426,7 @@ handle_ctrl_proto(netdissect_options *ndo, if (length < 4) /* FIXME weak boundary checking */ goto trunc; - ND_TCHECK2(*tptr, 2); + ND_TCHECK_2(tptr); code = EXTRACT_U_1(tptr); tptr++; @@ -550,7 +549,7 @@ handle_ctrl_proto(netdissect_options *ndo, /* XXX: need to decode Data? - hexdump for now */ if (len > 8) { ND_PRINT((ndo, "\n\t -----trailing data-----")); - ND_TCHECK2(tptr[4], len - 8); + ND_TCHECK_LEN(tptr + 4, len - 8); print_unknown_data(ndo, tptr + 4, "\n\t ", len - 8); } break; @@ -598,20 +597,20 @@ print_lcp_config_options(netdissect_options *ndo, if (length < 2) return 0; - ND_TCHECK2(*p, 2); + ND_TCHECK_2(p); opt = EXTRACT_U_1(p); len = EXTRACT_U_1(p + 1); if (length < len) return 0; if (len < 2) { - if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX)) + if (opt < NUM_LCPOPTS) ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u (length bogus, should be >= 2)", lcpconfopts[opt], opt, len)); else ND_PRINT((ndo, "\n\tunknown LCP option 0x%02x", opt)); return 0; } - if ((opt >= LCPOPT_MIN) && (opt <= LCPOPT_MAX)) + if (opt < NUM_LCPOPTS) ND_PRINT((ndo, "\n\t %s Option (0x%02x), length %u", lcpconfopts[opt], opt, len)); else { ND_PRINT((ndo, "\n\tunknown LCP option 0x%02x", opt)); @@ -744,7 +743,7 @@ print_lcp_config_options(netdissect_options *ndo, ND_PRINT((ndo, " (length bogus, should be = 7)")); return 0; } - ND_TCHECK2(*(p + 3), 4); + ND_TCHECK_4(p + 3); ND_PRINT((ndo, ": IPv4 %s", ipaddr_string(ndo, p + 3))); break; case MEDCLASS_MAC: @@ -752,7 +751,7 @@ print_lcp_config_options(netdissect_options *ndo, ND_PRINT((ndo, " (length bogus, should be = 9)")); return 0; } - ND_TCHECK2(*(p + 3), 6); + ND_TCHECK_6(p + 3); ND_PRINT((ndo, ": MAC %s", etheraddr_string(ndo, p + 3))); break; case MEDCLASS_MNB: @@ -962,7 +961,7 @@ handle_pap(netdissect_options *ndo, return; } length = len; - if (length < (p - p0)) { + if (length < (size_t)(p - p0)) { ND_PRINT((ndo, ", length %u < PAP header length", length)); return; } @@ -1049,7 +1048,7 @@ print_ipcp_config_options(netdissect_options *ndo, if (length < 2) return 0; - ND_TCHECK2(*p, 2); + ND_TCHECK_2(p); opt = EXTRACT_U_1(p); len = EXTRACT_U_1(p + 1); if (length < len) @@ -1073,7 +1072,7 @@ print_ipcp_config_options(netdissect_options *ndo, ND_PRINT((ndo, " (length bogus, should be = 10)")); return len; } - ND_TCHECK2(*(p + 6), 4); + ND_TCHECK_4(p + 6); ND_PRINT((ndo, ": src %s, dst %s", ipaddr_string(ndo, p + 2), ipaddr_string(ndo, p + 6))); @@ -1101,7 +1100,7 @@ print_ipcp_config_options(netdissect_options *ndo, return 0; } - ND_TCHECK2(*(p + 2), IPCPOPT_IPCOMP_MINLEN); + ND_TCHECK_LEN(p + 2, IPCPOPT_IPCOMP_MINLEN); ND_PRINT((ndo, "\n\t TCP Space %u, non-TCP Space %u" \ ", maxPeriod %u, maxTime %u, maxHdr %u", EXTRACT_BE_U_2(p + 4), @@ -1118,7 +1117,7 @@ print_ipcp_config_options(netdissect_options *ndo, ND_PRINT((ndo, "\n\t Suboptions, length %u", ipcomp_subopttotallen)); while (ipcomp_subopttotallen >= 2) { - ND_TCHECK2(*p, 2); + ND_TCHECK_2(p); ipcomp_subopt = EXTRACT_U_1(p); ipcomp_suboptlen = EXTRACT_U_1(p + 1); @@ -1155,7 +1154,7 @@ print_ipcp_config_options(netdissect_options *ndo, ND_PRINT((ndo, " (length bogus, should be = 6)")); return 0; } - ND_TCHECK2(*(p + 2), 4); + ND_TCHECK_4(p + 2); ND_PRINT((ndo, ": %s", ipaddr_string(ndo, p + 2))); break; default: @@ -1185,7 +1184,7 @@ print_ip6cp_config_options(netdissect_options *ndo, if (length < 2) return 0; - ND_TCHECK2(*p, 2); + ND_TCHECK_2(p); opt = EXTRACT_U_1(p); len = EXTRACT_U_1(p + 1); if (length < len) @@ -1209,7 +1208,7 @@ print_ip6cp_config_options(netdissect_options *ndo, ND_PRINT((ndo, " (length bogus, should be = 10)")); return len; } - ND_TCHECK2(*(p + 2), 8); + ND_TCHECK_8(p + 2); ND_PRINT((ndo, ": %04x:%04x:%04x:%04x", EXTRACT_BE_U_2(p + 2), EXTRACT_BE_U_2(p + 4), @@ -1245,7 +1244,7 @@ print_ccp_config_options(netdissect_options *ndo, if (length < 2) return 0; - ND_TCHECK2(*p, 2); + ND_TCHECK_2(p); opt = EXTRACT_U_1(p); len = EXTRACT_U_1(p + 1); if (length < len) @@ -1344,7 +1343,7 @@ print_bacp_config_options(netdissect_options *ndo, if (length < 2) return 0; - ND_TCHECK2(*p, 2); + ND_TCHECK_2(p); opt = EXTRACT_U_1(p); len = EXTRACT_U_1(p + 1); if (length < len) @@ -1411,7 +1410,7 @@ ppp_hdlc(netdissect_options *ndo, * Do this so that we dont overwrite the original packet * contents. */ - for (s = p, t = b, i = length; i != 0 && ND_TTEST(*s); i--) { + for (s = p, t = b, i = length; i != 0 && ND_TTEST_1(s); i--) { c = EXTRACT_U_1(s); s++; if (c == 0x7d) { @@ -1540,7 +1539,7 @@ handle_ppp(netdissect_options *ndo, /* Standard PPP printer */ u_int ppp_print(netdissect_options *ndo, - register const u_char *p, u_int length) + const u_char *p, u_int length) { u_int proto,ppp_header; u_int olen = length; /* _o_riginal length */ @@ -1611,10 +1610,10 @@ trunc: /* PPP I/F printer */ u_int ppp_if_print(netdissect_options *ndo, - const struct pcap_pkthdr *h, register const u_char *p) + const struct pcap_pkthdr *h, const u_char *p) { - register u_int length = h->len; - register u_int caplen = h->caplen; + u_int length = h->len; + u_int caplen = h->caplen; if (caplen < PPP_HDRLEN) { ND_PRINT((ndo, "[|ppp]")); @@ -1679,10 +1678,10 @@ ppp_if_print(netdissect_options *ndo, */ u_int ppp_hdlc_if_print(netdissect_options *ndo, - const struct pcap_pkthdr *h, register const u_char *p) + const struct pcap_pkthdr *h, const u_char *p) { - register u_int length = h->len; - register u_int caplen = h->caplen; + u_int length = h->len; + u_int caplen = h->caplen; u_int proto; u_int hdrlen = 0; @@ -1749,12 +1748,12 @@ ppp_hdlc_if_print(netdissect_options *ndo, /* BSD/OS specific PPP printer */ u_int ppp_bsdos_if_print(netdissect_options *ndo _U_, - const struct pcap_pkthdr *h _U_, register const u_char *p _U_) + const struct pcap_pkthdr *h _U_, const u_char *p _U_) { - register u_int hdrlength; + u_int hdrlength; #ifdef __bsdi__ - register u_int length = h->len; - register u_int caplen = h->caplen; + u_int length = h->len; + u_int caplen = h->caplen; uint16_t ptype; uint8_t llhl; const u_char *q;