X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/f085c93f59fb2332e09f3da20eef5fb2bbd04431..195a4cfd9de46b47ac6794930e19e38ed263b05f:/print-pim.c diff --git a/print-pim.c b/print-pim.c index ac248450..fa6a345a 100644 --- a/print-pim.c +++ b/print-pim.c @@ -137,17 +137,17 @@ struct pim { u_short pim_cksum; /* IP style check sum */ }; -static void pimv2_print(netdissect_options *, register const u_char *bp, register u_int len, const u_char *); +static void pimv2_print(netdissect_options *, const u_char *bp, u_int len, const u_char *); static void pimv1_join_prune_print(netdissect_options *ndo, - register const u_char *bp, register u_int len) + const u_char *bp, u_int len) { int ngroups, njoin, nprune; int njp; /* If it's a single group and a single source, use 1-line output. */ - if (ND_TTEST2(bp[0], 30) && bp[11] == 1 && + if (ND_TTEST_LEN(bp, 30) && EXTRACT_U_1(bp + 11) == 1 && ((njoin = EXTRACT_BE_U_2(bp + 20)) + EXTRACT_BE_U_2(bp + 22)) == 1) { int hold; @@ -171,7 +171,7 @@ pimv1_join_prune_print(netdissect_options *ndo, if (len < sizeof(struct in_addr)) goto trunc; - ND_TCHECK2(bp[0], sizeof(struct in_addr)); + ND_TCHECK_LEN(bp, sizeof(struct in_addr)); if (ndo->ndo_vflag > 1) ND_PRINT((ndo, "\n")); ND_PRINT((ndo, " Upstream Nbr: %s", ipaddr_string(ndo, bp))); @@ -192,7 +192,7 @@ pimv1_join_prune_print(netdissect_options *ndo, if (len < 4) goto trunc; ND_TCHECK_4(bp); - ngroups = bp[3]; + ngroups = EXTRACT_U_1(bp + 3); bp += 4; len -= 4; while (ngroups--) { @@ -202,13 +202,13 @@ pimv1_join_prune_print(netdissect_options *ndo, */ if (len < 4) goto trunc; - ND_TCHECK2(bp[0], sizeof(struct in_addr)); + ND_TCHECK_LEN(bp, sizeof(struct in_addr)); ND_PRINT((ndo, "\n\tGroup: %s", ipaddr_string(ndo, bp))); bp += 4; len -= 4; if (len < 4) goto trunc; - ND_TCHECK2(bp[0], sizeof(struct in_addr)); + ND_TCHECK_LEN(bp, sizeof(struct in_addr)); if (EXTRACT_BE_U_4(bp) != 0xffffffff) ND_PRINT((ndo, "/%s", ipaddr_string(ndo, bp))); bp += 4; @@ -249,18 +249,18 @@ trunc: void pimv1_print(netdissect_options *ndo, - register const u_char *bp, register u_int len) + const u_char *bp, u_int len) { - register u_char type; + u_char type; - ND_TCHECK(bp[1]); - type = bp[1]; + ND_TCHECK_1(bp + 1); + type = EXTRACT_U_1(bp + 1); ND_PRINT((ndo, " %s", tok2str(pimv1_type_str, "[type %u]", type))); switch (type) { case PIMV1_TYPE_QUERY: - if (ND_TTEST(bp[8])) { - switch (bp[8] >> 4) { + if (ND_TTEST_1(bp + 8)) { + switch (EXTRACT_U_1(bp + 8) >> 4) { case 0: ND_PRINT((ndo, " Dense-mode")); break; @@ -284,12 +284,12 @@ pimv1_print(netdissect_options *ndo, break; case PIMV1_TYPE_REGISTER: - ND_TCHECK2(bp[8], 20); /* ip header */ + ND_TCHECK_LEN(bp + 8, 20); /* ip header */ ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, bp + 20), ipaddr_string(ndo, bp + 24))); break; case PIMV1_TYPE_REGISTER_STOP: - ND_TCHECK2(bp[12], sizeof(struct in_addr)); + ND_TCHECK_LEN(bp + 12, sizeof(struct in_addr)); ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, bp + 8), ipaddr_string(ndo, bp + 12))); break; @@ -304,7 +304,7 @@ pimv1_print(netdissect_options *ndo, } break; case PIMV1_TYPE_ASSERT: - ND_TCHECK2(bp[16], sizeof(struct in_addr)); + ND_TCHECK_LEN(bp + 16, sizeof(struct in_addr)); ND_PRINT((ndo, " for %s > %s", ipaddr_string(ndo, bp + 16), ipaddr_string(ndo, bp + 8))); if (EXTRACT_BE_U_4(bp + 12) != 0xffffffff) @@ -321,12 +321,12 @@ pimv1_print(netdissect_options *ndo, if (ndo->ndo_vflag) { if (len < 8) goto trunc; - pimv1_join_prune_print(ndo, &bp[8], len - 8); + pimv1_join_prune_print(ndo, bp + 8, len - 8); } break; } - ND_TCHECK(bp[4]); - if ((bp[4] >> 4) != 1) + ND_TCHECK_1(bp + 4); + if ((EXTRACT_U_1(bp + 4) >> 4) != 1) ND_PRINT((ndo, " [v%d]", EXTRACT_U_1(bp + 4) >> 4)); return; @@ -343,7 +343,7 @@ trunc: */ void cisco_autorp_print(netdissect_options *ndo, - register const u_char *bp, register u_int len) + const u_char *bp, u_int len) { int type; int numrps; @@ -351,9 +351,9 @@ cisco_autorp_print(netdissect_options *ndo, if (len < 8) goto trunc; - ND_TCHECK(bp[0]); + ND_TCHECK_1(bp); ND_PRINT((ndo, " auto-rp ")); - type = bp[0]; + type = EXTRACT_U_1(bp); switch (type) { case 0x11: ND_PRINT((ndo, "candidate-advert")); @@ -366,8 +366,8 @@ cisco_autorp_print(netdissect_options *ndo, break; } - ND_TCHECK(bp[1]); - numrps = bp[1]; + ND_TCHECK_1(bp + 1); + numrps = EXTRACT_U_1(bp + 1); ND_TCHECK_2(bp + 2); ND_PRINT((ndo, " Hold ")); @@ -406,8 +406,8 @@ cisco_autorp_print(netdissect_options *ndo, len -= 4; if (len < 1) goto trunc; - ND_TCHECK(bp[0]); - switch (bp[0] & 0x3) { + ND_TCHECK_1(bp); + switch (EXTRACT_U_1(bp) & 0x3) { case 0: ND_PRINT((ndo, " PIMv?")); break; case 1: ND_PRINT((ndo, " PIMv1")); @@ -417,14 +417,14 @@ cisco_autorp_print(netdissect_options *ndo, case 3: ND_PRINT((ndo, " PIMv1+2")); break; } - if (bp[0] & 0xfc) + if (EXTRACT_U_1(bp) & 0xfc) ND_PRINT((ndo, " [rsvd=0x%02x]", EXTRACT_U_1(bp) & 0xfc)); bp += 1; len -= 1; if (len < 1) goto trunc; - ND_TCHECK(bp[0]); - nentries = bp[0]; + ND_TCHECK_1(bp); + nentries = EXTRACT_U_1(bp); bp += 1; len -= 1; s = ' '; @@ -434,10 +434,10 @@ cisco_autorp_print(netdissect_options *ndo, ND_TCHECK_6(bp); ND_PRINT((ndo, "%c%s%s/%d", s, EXTRACT_U_1(bp) & 1 ? "!" : "", ipaddr_string(ndo, bp + 2), EXTRACT_U_1(bp + 1))); - if (bp[0] & 0x02) { + if (EXTRACT_U_1(bp) & 0x02) { ND_PRINT((ndo, " bidir")); } - if (bp[0] & 0xfc) { + if (EXTRACT_U_1(bp) & 0xfc) { ND_PRINT((ndo, "[rsvd=0x%02x]", EXTRACT_U_1(bp) & 0xfc)); } s = ','; @@ -453,9 +453,9 @@ trunc: void pim_print(netdissect_options *ndo, - register const u_char *bp, register u_int len, const u_char *bp2) + const u_char *bp, u_int len, const u_char *bp2) { - register const struct pim *pim = (const struct pim *)bp; + const struct pim *pim = (const struct pim *)bp; #ifdef notyet /* currently we see only version and type */ ND_TCHECK(pim->pim_rsv); @@ -566,8 +566,8 @@ pimv2_addr_print(netdissect_options *ndo, if (addr_len == 0) { if (len < 2) goto trunc; - ND_TCHECK(bp[1]); - switch (bp[0]) { + ND_TCHECK_1(bp + 1); + switch (EXTRACT_U_1(bp)) { case 1: af = AF_INET; addr_len = (u_int)sizeof(struct in_addr); @@ -579,7 +579,7 @@ pimv2_addr_print(netdissect_options *ndo, default: return -1; } - if (bp[1] != 0) + if (EXTRACT_U_1(bp + 1) != 0) return -1; hdrlen = 2; } else { @@ -603,7 +603,7 @@ pimv2_addr_print(netdissect_options *ndo, case pimv2_unicast: if (len < addr_len) goto trunc; - ND_TCHECK2(bp[0], addr_len); + ND_TCHECK_LEN(bp, addr_len); if (af == AF_INET) { if (!silent) ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp))); @@ -617,22 +617,22 @@ pimv2_addr_print(netdissect_options *ndo, case pimv2_source: if (len < addr_len + 2) goto trunc; - ND_TCHECK2(bp[0], addr_len + 2); + ND_TCHECK_LEN(bp, addr_len + 2); if (af == AF_INET) { if (!silent) { ND_PRINT((ndo, "%s", ipaddr_string(ndo, bp + 2))); - if (bp[1] != 32) + if (EXTRACT_U_1(bp + 1) != 32) ND_PRINT((ndo, "/%u", EXTRACT_U_1(bp + 1))); } } else if (af == AF_INET6) { if (!silent) { ND_PRINT((ndo, "%s", ip6addr_string(ndo, bp + 2))); - if (bp[1] != 128) + if (EXTRACT_U_1(bp + 1) != 128) ND_PRINT((ndo, "/%u", EXTRACT_U_1(bp + 1))); } } - if (bp[0] && !silent) { + if (EXTRACT_U_1(bp) && !silent) { if (at == pimv2_group) { ND_PRINT((ndo, "(0x%02x)", EXTRACT_U_1(bp))); } else { @@ -640,7 +640,7 @@ pimv2_addr_print(netdissect_options *ndo, EXTRACT_U_1(bp) & 0x04 ? "S" : "", EXTRACT_U_1(bp) & 0x02 ? "W" : "", EXTRACT_U_1(bp) & 0x01 ? "R" : "")); - if (bp[0] & 0xf8) { + if (EXTRACT_U_1(bp) & 0xf8) { ND_PRINT((ndo, "+0x%02x", EXTRACT_U_1(bp) & 0xf8)); } ND_PRINT((ndo, ")")); @@ -667,7 +667,7 @@ pimv2_check_checksum(netdissect_options *ndo, const u_char *bp, const struct ip *ip; u_int cksum; - if (!ND_TTEST2(bp[0], len)) { + if (!ND_TTEST_LEN(bp, len)) { /* We don't have all the data. */ return (UNVERIFIED); } @@ -692,9 +692,9 @@ pimv2_check_checksum(netdissect_options *ndo, const u_char *bp, static void pimv2_print(netdissect_options *ndo, - register const u_char *bp, register u_int len, const u_char *bp2) + const u_char *bp, u_int len, const u_char *bp2) { - register const struct pim *pim = (const struct pim *)bp; + const struct pim *pim = (const struct pim *)bp; int advance; enum checksum_status cksum_status; int pimv2_addr_len; @@ -771,7 +771,7 @@ pimv2_print(netdissect_options *ndo, if (len < olen) goto trunc; - ND_TCHECK2(bp[0], olen); + ND_TCHECK_LEN(bp, olen); switch (otype) { case PIMV2_HELLO_OPTION_HOLDTIME: if (olen != 2) { @@ -825,9 +825,10 @@ pimv2_print(netdissect_options *ndo, ND_PRINT((ndo, "ERROR: Option Length != 4 Bytes (%u)", olen)); } else { ND_PRINT((ndo, "v%d", EXTRACT_U_1(bp))); - if (*(bp+1) != 0) { + if (EXTRACT_U_1(bp + 1) != 0) { ND_PRINT((ndo, ", interval ")); - unsigned_relts_print(ndo, *(bp+1)); + unsigned_relts_print(ndo, + EXTRACT_U_1(bp + 1)); } if (EXTRACT_BE_U_2(bp + 2) != 0) { ND_PRINT((ndo, " ?0x%04x?", EXTRACT_BE_U_2(bp + 2))); @@ -873,7 +874,7 @@ pimv2_print(netdissect_options *ndo, if (len < 4) goto trunc; - ND_TCHECK2(*bp, PIMV2_REGISTER_FLAG_LEN); + ND_TCHECK_LEN(bp, PIMV2_REGISTER_FLAG_LEN); ND_PRINT((ndo, ", Flags [ %s ]\n\t", tok2str(pimv2_register_flag_values, @@ -976,7 +977,7 @@ pimv2_print(netdissect_options *ndo, if (len < 4) goto trunc; ND_TCHECK_4(bp); - ngroup = bp[1]; + ngroup = EXTRACT_U_1(bp + 1); holdtime = EXTRACT_BE_U_2(bp + 2); ND_PRINT((ndo, "\n\t %u group(s)", ngroup)); if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/ @@ -1028,11 +1029,11 @@ pimv2_print(netdissect_options *ndo, len -= 2; if (len < 1) goto trunc; - ND_TCHECK(bp[0]); + ND_TCHECK_1(bp); ND_PRINT((ndo, " hashmlen=%d", EXTRACT_U_1(bp))); if (len < 2) goto trunc; - ND_TCHECK(bp[2]); + ND_TCHECK_1(bp + 2); ND_PRINT((ndo, " BSRprio=%d", EXTRACT_U_1(bp + 1))); bp += 2; len -= 2; @@ -1055,11 +1056,11 @@ pimv2_print(netdissect_options *ndo, /* RP-Count, Frag RP-Cnt, and rsvd */ if (len < 1) goto trunc; - ND_TCHECK(bp[0]); + ND_TCHECK_1(bp); ND_PRINT((ndo, " RPcnt=%d", EXTRACT_U_1(bp))); if (len < 2) goto trunc; - ND_TCHECK(bp[1]); + ND_TCHECK_1(bp + 1); ND_PRINT((ndo, " FRPcnt=%d", frpcnt = EXTRACT_U_1(bp + 1))); if (len < 4) goto trunc; @@ -1085,7 +1086,7 @@ pimv2_print(netdissect_options *ndo, EXTRACT_BE_U_2(bp)); if (len < 3) goto trunc; - ND_TCHECK(bp[2]); + ND_TCHECK_1(bp + 2); ND_PRINT((ndo, ",prio=%d", EXTRACT_U_1(bp + 2))); if (len < 4) goto trunc; @@ -1108,7 +1109,7 @@ pimv2_print(netdissect_options *ndo, if (len < 8) goto trunc; ND_TCHECK_8(bp); - if (bp[0] & 0x80) + if (EXTRACT_U_1(bp) & 0x80) ND_PRINT((ndo, " RPT")); ND_PRINT((ndo, " pref=%u", EXTRACT_BE_U_4(bp) & 0x7fffffff)); ND_PRINT((ndo, " metric=%u", EXTRACT_BE_U_4(bp + 4))); @@ -1121,12 +1122,12 @@ pimv2_print(netdissect_options *ndo, /* Prefix-Cnt, Priority, and Holdtime */ if (len < 1) goto trunc; - ND_TCHECK(bp[0]); + ND_TCHECK_1(bp); ND_PRINT((ndo, " prefix-cnt=%d", EXTRACT_U_1(bp))); - pfxcnt = bp[0]; + pfxcnt = EXTRACT_U_1(bp); if (len < 2) goto trunc; - ND_TCHECK(bp[1]); + ND_TCHECK_1(bp + 1); ND_PRINT((ndo, " prio=%d", EXTRACT_U_1(bp + 1))); if (len < 4) goto trunc;