X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3b8ff4bf0d8f389e00c19d6c094bce2bbf00deca..refs/heads/master:/print-pim.c diff --git a/print-pim.c b/print-pim.c index 4c67f1e7..9241db32 100644 --- a/print-pim.c +++ b/print-pim.c @@ -21,9 +21,7 @@ /* \summary: Protocol Independent Multicast (PIM) printer */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" @@ -34,6 +32,7 @@ #include "ip.h" #include "ip6.h" #include "ipproto.h" +#include "af.h" #define PIMV1_TYPE_QUERY 0 #define PIMV1_TYPE_REGISTER 1 @@ -137,7 +136,7 @@ static const struct tok pimv2_df_election_flag_values[] = { /* * XXX: We consider a case where IPv6 is not ready yet for portability, - * but PIM dependent defintions should be independent of IPv6... + * but PIM dependent definitions should be independent of IPv6... */ struct pim { @@ -256,7 +255,6 @@ pimv1_join_prune_print(netdissect_options *ndo, return; trunc: nd_print_trunc(ndo); - return; } void @@ -305,7 +303,6 @@ pimv1_print(netdissect_options *ndo, break; case PIMV1_TYPE_RP_REACHABILITY: if (ndo->ndo_vflag) { - ND_TCHECK_2(bp + 22); ND_PRINT(" group %s", GET_IPADDR_STRING(bp + 8)); if (GET_BE_U_4(bp + 12) != 0xffffffff) ND_PRINT("/%s", GET_IPADDR_STRING(bp + 12)); @@ -339,7 +336,6 @@ pimv1_print(netdissect_options *ndo, trunc: nd_print_trunc(ndo); - return; } /* @@ -451,7 +447,6 @@ cisco_autorp_print(netdissect_options *ndo, trunc: nd_print_trunc(ndo); - return; } void @@ -462,9 +457,6 @@ pim_print(netdissect_options *ndo, uint8_t pim_typever; ndo->ndo_protocol = "pim"; -#ifdef notyet /* currently we see only version and type */ - ND_TCHECK_1(pim->pim_rsv); -#endif pim_typever = GET_U_1(pim->pim_typever); switch (PIM_VER(pim_typever)) { @@ -566,13 +558,12 @@ pimv2_addr_print(netdissect_options *ndo, if (addr_len == 0) { if (len < 2) goto trunc; - switch (GET_U_1(bp)) { - case 1: - af = AF_INET; + af = GET_U_1(bp); + switch (af) { + case AFNUM_IP: addr_len = (u_int)sizeof(nd_ipv4); break; - case 2: - af = AF_INET6; + case AFNUM_IP6: addr_len = (u_int)sizeof(nd_ipv6); break; default: @@ -584,14 +575,13 @@ pimv2_addr_print(netdissect_options *ndo, } else { switch (addr_len) { case sizeof(nd_ipv4): - af = AF_INET; + af = AFNUM_IP; break; case sizeof(nd_ipv6): - af = AF_INET6; + af = AFNUM_IP6; break; default: return -1; - break; } hdrlen = 0; } @@ -603,11 +593,10 @@ pimv2_addr_print(netdissect_options *ndo, if (len < addr_len) goto trunc; ND_TCHECK_LEN(bp, addr_len); - if (af == AF_INET) { + if (af == AFNUM_IP) { if (!silent) ND_PRINT("%s", GET_IPADDR_STRING(bp)); - } - else if (af == AF_INET6) { + } else if (af == AFNUM_IP6) { if (!silent) ND_PRINT("%s", GET_IP6ADDR_STRING(bp)); } @@ -617,14 +606,13 @@ pimv2_addr_print(netdissect_options *ndo, if (len < addr_len + 2) goto trunc; ND_TCHECK_LEN(bp, addr_len + 2); - if (af == AF_INET) { + if (af == AFNUM_IP) { if (!silent) { ND_PRINT("%s", GET_IPADDR_STRING(bp + 2)); if (GET_U_1(bp + 1) != 32) ND_PRINT("/%u", GET_U_1(bp + 1)); } - } - else if (af == AF_INET6) { + } else if (af == AFNUM_IP6) { if (!silent) { ND_PRINT("%s", GET_IP6ADDR_STRING(bp + 2)); if (GET_U_1(bp + 1) != 128) @@ -765,7 +753,7 @@ pimv2_print(netdissect_options *ndo, case PIMV2_TYPE_HELLO: { uint16_t otype, olen; - while (len > 0) { + while (len != 0) { if (len < 4) goto trunc; otype = GET_BE_U_2(bp); @@ -822,7 +810,6 @@ pimv2_print(netdissect_options *ndo, ND_PRINT("[option length %u != 4]", olen); nd_print_invalid(ndo); return; - break; } break; @@ -1094,7 +1081,6 @@ pimv2_print(netdissect_options *ndo, if (len < 2) goto trunc; - ND_TCHECK_2(bp); ND_PRINT(",holdtime="); unsigned_relts_print(ndo, GET_BE_U_2(bp));