X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/9d046ee0503d4c8cbfcb200c88986de876f6cae7..0023eaa78f123676bfa9c5fba72ea4b8a59aaa70:/print-igmp.c diff --git a/print-igmp.c b/print-igmp.c index 4bdcba5d..68bb5d77 100644 --- a/print-igmp.c +++ b/print-igmp.c @@ -29,9 +29,7 @@ * draft-asaeda-mboned-mtrace-v2 for the mtrace message */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" @@ -109,46 +107,22 @@ static const struct tok igmpv3report2str[] = { static void print_mtrace(netdissect_options *ndo, + const char *typename, const u_char *bp, u_int len) { const struct tr_query *tr = (const struct tr_query *)(bp + 8); - ND_TCHECK_SIZE(tr); - if (len < 8 + sizeof (struct tr_query)) { - ND_PRINT(" [invalid len %u]", len); - return; - } - ND_PRINT("mtrace %u: %s to %s reply-to %s", - GET_BE_U_3(tr->tr_qid), - GET_IPADDR_STRING(tr->tr_src), GET_IPADDR_STRING(tr->tr_dst), - GET_IPADDR_STRING(tr->tr_raddr)); - if (IN_CLASSD(GET_BE_U_4(tr->tr_raddr))) - ND_PRINT(" with-ttl %u", GET_U_1(tr->tr_rttl)); - return; -trunc: - nd_print_trunc(ndo); -} - -static void -print_mresp(netdissect_options *ndo, - const u_char *bp, u_int len) -{ - const struct tr_query *tr = (const struct tr_query *)(bp + 8); - - ND_TCHECK_SIZE(tr); if (len < 8 + sizeof (struct tr_query)) { ND_PRINT(" [invalid len %u]", len); return; } - ND_PRINT("mresp %u: %s to %s reply-to %s", + ND_PRINT("%s %u: %s to %s reply-to %s", + typename, GET_BE_U_3(tr->tr_qid), GET_IPADDR_STRING(tr->tr_src), GET_IPADDR_STRING(tr->tr_dst), GET_IPADDR_STRING(tr->tr_raddr)); if (IN_CLASSD(GET_BE_U_4(tr->tr_raddr))) ND_PRINT(" with-ttl %u", GET_U_1(tr->tr_rttl)); - return; -trunc: - nd_print_trunc(ndo); } static void @@ -163,7 +137,6 @@ print_igmpv3_report(netdissect_options *ndo, ND_PRINT(" [invalid len %u]", len); return; } - ND_TCHECK_2(bp + 6); ngroups = GET_BE_U_2(bp + 6); ND_PRINT(", %u group record(s)", ngroups); if (ndo->ndo_vflag > 0) { @@ -174,7 +147,6 @@ print_igmpv3_report(netdissect_options *ndo, ND_PRINT(" [invalid number of groups]"); return; } - ND_TCHECK_4(bp + (group + 4)); ND_PRINT(" [gaddr %s", GET_IPADDR_STRING(bp + group + 4)); ND_PRINT(" %s", tok2str(igmpv3report2str, " [v3-report-#%u]", GET_U_1(bp + group))); @@ -190,7 +162,6 @@ print_igmpv3_report(netdissect_options *ndo, /* Print the sources */ ND_PRINT(" {"); for (j=0; j 0) { if (len < 12 + (nsrcs << 2)) @@ -248,7 +213,6 @@ print_igmpv3_query(netdissect_options *ndo, else if (ndo->ndo_vflag > 1) { ND_PRINT(" {"); for (i=0; i= 12) print_igmpv3_query(ndo, bp, len); else { - ND_TCHECK_1(bp + 1); if (GET_U_1(bp + 1)) { ND_PRINT(" v2"); if (GET_U_1(bp + 1) != 100) ND_PRINT(" [max resp time %u]", GET_U_1(bp + 1)); } else ND_PRINT(" v1"); - ND_TCHECK_4(bp + 4); if (GET_BE_U_4(bp + 4)) ND_PRINT(" [gaddr %s]", GET_IPADDR_STRING(bp + 4)); if (len != 8) @@ -295,13 +253,11 @@ igmp_print(netdissect_options *ndo, } break; case 0x12: - ND_TCHECK_4(bp + 4); ND_PRINT("igmp v1 report %s", GET_IPADDR_STRING(bp + 4)); if (len != 8) ND_PRINT(" [len %u]", len); break; case 0x16: - ND_TCHECK_4(bp + 4); ND_PRINT("igmp v2 report %s", GET_IPADDR_STRING(bp + 4)); break; case 0x22: @@ -309,7 +265,6 @@ igmp_print(netdissect_options *ndo, print_igmpv3_report(ndo, bp, len); break; case 0x17: - ND_TCHECK_4(bp + 4); ND_PRINT("igmp leave %s", GET_IPADDR_STRING(bp + 4)); break; case 0x13: @@ -324,10 +279,10 @@ igmp_print(netdissect_options *ndo, pimv1_print(ndo, bp, len); break; case 0x1e: - print_mresp(ndo, bp, len); + print_mtrace(ndo, "mresp", bp, len); break; case 0x1f: - print_mtrace(ndo, bp, len); + print_mtrace(ndo, "mtrace", bp, len); break; default: ND_PRINT("igmp-%u", GET_U_1(bp)); @@ -341,7 +296,4 @@ igmp_print(netdissect_options *ndo, if (in_cksum(vec, 1)) ND_PRINT(" bad igmp cksum %x!", GET_BE_U_2(bp + 2)); } - return; -trunc: - nd_print_trunc(ndo); }