The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996 |
| 3 | * The Regents of the University of California. All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that: (1) source code distributions |
| 7 | * retain the above copyright notice and this paragraph in its entirety, (2) |
| 8 | * distributions including binary code include the above copyright notice and |
| 9 | * this paragraph in its entirety in the documentation or other materials |
| 10 | * provided with the distribution, and (3) all advertising materials mentioning |
| 11 | * features or use of this software display the following acknowledgement: |
| 12 | * ``This product includes software developed by the University of California, |
| 13 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of |
| 14 | * the University nor the names of its contributors may be used to endorse |
| 15 | * or promote products derived from this software without specific prior |
| 16 | * written permission. |
| 17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 20 | */ |
| 21 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 22 | /* \summary: Internet Group Management Protocol (IGMP) printer */ |
| 23 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 24 | #ifdef HAVE_CONFIG_H |
| 25 | #include "config.h" |
| 26 | #endif |
| 27 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 28 | #include <netdissect-stdinc.h> |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 29 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 30 | #include "netdissect.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 31 | #include "addrtoname.h" |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 32 | #include "extract.h" |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 33 | |
| 34 | #ifndef IN_CLASSD |
| 35 | #define IN_CLASSD(i) (((int32_t)(i) & 0xf0000000) == 0xe0000000) |
| 36 | #endif |
| 37 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 38 | static const char tstr[] = "[|igmp]"; |
| 39 | |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 40 | /* (following from ipmulti/mrouted/prune.h) */ |
| 41 | |
| 42 | /* |
| 43 | * The packet format for a traceroute request. |
| 44 | */ |
| 45 | struct tr_query { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 46 | uint32_t tr_src; /* traceroute source */ |
| 47 | uint32_t tr_dst; /* traceroute destination */ |
| 48 | uint32_t tr_raddr; /* traceroute response address */ |
| 49 | uint32_t tr_rttlqid; /* response ttl and qid */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | #define TR_GETTTL(x) (int)(((x) >> 24) & 0xff) |
| 53 | #define TR_GETQID(x) ((x) & 0x00ffffff) |
| 54 | |
| 55 | /* |
| 56 | * Traceroute response format. A traceroute response has a tr_query at the |
| 57 | * beginning, followed by one tr_resp for each hop taken. |
| 58 | */ |
| 59 | struct tr_resp { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 60 | uint32_t tr_qarr; /* query arrival time */ |
| 61 | uint32_t tr_inaddr; /* incoming interface address */ |
| 62 | uint32_t tr_outaddr; /* outgoing interface address */ |
| 63 | uint32_t tr_rmtaddr; /* parent address in source tree */ |
| 64 | uint32_t tr_vifin; /* input packet count on interface */ |
| 65 | uint32_t tr_vifout; /* output packet count on interface */ |
| 66 | uint32_t tr_pktcnt; /* total incoming packets for src-grp */ |
| 67 | uint8_t tr_rproto; /* routing proto deployed on router */ |
| 68 | uint8_t tr_fttl; /* ttl required to forward on outvif */ |
| 69 | uint8_t tr_smask; /* subnet mask for src addr */ |
| 70 | uint8_t tr_rflags; /* forwarding error codes */ |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | /* defs within mtrace */ |
| 74 | #define TR_QUERY 1 |
| 75 | #define TR_RESP 2 |
| 76 | |
| 77 | /* fields for tr_rflags (forwarding error codes) */ |
| 78 | #define TR_NO_ERR 0 |
| 79 | #define TR_WRONG_IF 1 |
| 80 | #define TR_PRUNED 2 |
| 81 | #define TR_OPRUNED 3 |
| 82 | #define TR_SCOPED 4 |
| 83 | #define TR_NO_RTE 5 |
| 84 | #define TR_NO_FWD 7 |
| 85 | #define TR_NO_SPACE 0x81 |
| 86 | #define TR_OLD_ROUTER 0x82 |
| 87 | |
| 88 | /* fields for tr_rproto (routing protocol) */ |
| 89 | #define TR_PROTO_DVMRP 1 |
| 90 | #define TR_PROTO_MOSPF 2 |
| 91 | #define TR_PROTO_PIM 3 |
| 92 | #define TR_PROTO_CBT 4 |
| 93 | |
| 94 | /* igmpv3 report types */ |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 95 | static const struct tok igmpv3report2str[] = { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 96 | { 1, "is_in" }, |
| 97 | { 2, "is_ex" }, |
| 98 | { 3, "to_in" }, |
| 99 | { 4, "to_ex" }, |
| 100 | { 5, "allow" }, |
| 101 | { 6, "block" }, |
| 102 | { 0, NULL } |
| 103 | }; |
| 104 | |
| 105 | static void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 106 | print_mtrace(netdissect_options *ndo, |
| 107 | register const u_char *bp, register u_int len) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 108 | { |
| 109 | register const struct tr_query *tr = (const struct tr_query *)(bp + 8); |
| 110 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 111 | ND_TCHECK(*tr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 112 | if (len < 8 + sizeof (struct tr_query)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 113 | ND_PRINT((ndo, " [invalid len %d]", len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 114 | return; |
| 115 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 116 | ND_PRINT((ndo, "mtrace %u: %s to %s reply-to %s", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 117 | TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 118 | ipaddr_string(ndo, &tr->tr_src), ipaddr_string(ndo, &tr->tr_dst), |
| 119 | ipaddr_string(ndo, &tr->tr_raddr))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 120 | if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr))) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 121 | ND_PRINT((ndo, " with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 122 | return; |
| 123 | trunc: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 124 | ND_PRINT((ndo, "%s", tstr)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | static void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 128 | print_mresp(netdissect_options *ndo, |
| 129 | register const u_char *bp, register u_int len) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 130 | { |
| 131 | register const struct tr_query *tr = (const struct tr_query *)(bp + 8); |
| 132 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 133 | ND_TCHECK(*tr); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 134 | if (len < 8 + sizeof (struct tr_query)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 135 | ND_PRINT((ndo, " [invalid len %d]", len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 136 | return; |
| 137 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 138 | ND_PRINT((ndo, "mresp %lu: %s to %s reply-to %s", |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 139 | (u_long)TR_GETQID(EXTRACT_32BITS(&tr->tr_rttlqid)), |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 140 | ipaddr_string(ndo, &tr->tr_src), ipaddr_string(ndo, &tr->tr_dst), |
| 141 | ipaddr_string(ndo, &tr->tr_raddr))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 142 | if (IN_CLASSD(EXTRACT_32BITS(&tr->tr_raddr))) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 143 | ND_PRINT((ndo, " with-ttl %d", TR_GETTTL(EXTRACT_32BITS(&tr->tr_rttlqid)))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 144 | return; |
| 145 | trunc: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 146 | ND_PRINT((ndo, "%s", tstr)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | static void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 150 | print_igmpv3_report(netdissect_options *ndo, |
| 151 | register const u_char *bp, register u_int len) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 152 | { |
| 153 | u_int group, nsrcs, ngroups; |
| 154 | register u_int i, j; |
| 155 | |
| 156 | /* Minimum len is 16, and should be a multiple of 4 */ |
| 157 | if (len < 16 || len & 0x03) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 158 | ND_PRINT((ndo, " [invalid len %d]", len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 159 | return; |
| 160 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 161 | ND_TCHECK2(bp[6], 2); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 162 | ngroups = EXTRACT_16BITS(&bp[6]); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 163 | ND_PRINT((ndo, ", %d group record(s)", ngroups)); |
| 164 | if (ndo->ndo_vflag > 0) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 165 | /* Print the group records */ |
| 166 | group = 8; |
| 167 | for (i=0; i<ngroups; i++) { |
| 168 | if (len < group+8) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 169 | ND_PRINT((ndo, " [invalid number of groups]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 170 | return; |
| 171 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 172 | ND_TCHECK2(bp[group+4], 4); |
| 173 | ND_PRINT((ndo, " [gaddr %s", ipaddr_string(ndo, &bp[group+4]))); |
| 174 | ND_PRINT((ndo, " %s", tok2str(igmpv3report2str, " [v3-report-#%d]", |
| 175 | bp[group]))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 176 | nsrcs = EXTRACT_16BITS(&bp[group+2]); |
| 177 | /* Check the number of sources and print them */ |
| 178 | if (len < group+8+(nsrcs<<2)) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 179 | ND_PRINT((ndo, " [invalid number of sources %d]", nsrcs)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 180 | return; |
| 181 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 182 | if (ndo->ndo_vflag == 1) |
| 183 | ND_PRINT((ndo, ", %d source(s)", nsrcs)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 184 | else { |
| 185 | /* Print the sources */ |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 186 | ND_PRINT((ndo, " {")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 187 | for (j=0; j<nsrcs; j++) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 188 | ND_TCHECK2(bp[group+8+(j<<2)], 4); |
| 189 | ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[group+8+(j<<2)]))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 190 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 191 | ND_PRINT((ndo, " }")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 192 | } |
| 193 | /* Next group record */ |
| 194 | group += 8 + (nsrcs << 2); |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 195 | ND_PRINT((ndo, "]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | return; |
| 199 | trunc: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 200 | ND_PRINT((ndo, "%s", tstr)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | static void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 204 | print_igmpv3_query(netdissect_options *ndo, |
| 205 | register const u_char *bp, register u_int len) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 206 | { |
| 207 | u_int mrc; |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 208 | u_int mrt; |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 209 | u_int nsrcs; |
| 210 | register u_int i; |
| 211 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 212 | ND_PRINT((ndo, " v3")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 213 | /* Minimum len is 12, and should be a multiple of 4 */ |
| 214 | if (len < 12 || len & 0x03) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 215 | ND_PRINT((ndo, " [invalid len %d]", len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 216 | return; |
| 217 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 218 | ND_TCHECK(bp[1]); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 219 | mrc = bp[1]; |
| 220 | if (mrc < 128) { |
| 221 | mrt = mrc; |
| 222 | } else { |
| 223 | mrt = ((mrc & 0x0f) | 0x10) << (((mrc & 0x70) >> 4) + 3); |
| 224 | } |
| 225 | if (mrc != 100) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 226 | ND_PRINT((ndo, " [max resp time ")); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 227 | if (mrt < 600) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 228 | ND_PRINT((ndo, "%.1fs", mrt * 0.1)); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 229 | } else { |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 230 | unsigned_relts_print(ndo, mrt / 10); |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 231 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 232 | ND_PRINT((ndo, "]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 233 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 234 | ND_TCHECK2(bp[4], 4); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 235 | if (EXTRACT_32BITS(&bp[4]) == 0) |
| 236 | return; |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 237 | ND_PRINT((ndo, " [gaddr %s", ipaddr_string(ndo, &bp[4]))); |
| 238 | ND_TCHECK2(bp[10], 2); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 239 | nsrcs = EXTRACT_16BITS(&bp[10]); |
| 240 | if (nsrcs > 0) { |
| 241 | if (len < 12 + (nsrcs << 2)) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 242 | ND_PRINT((ndo, " [invalid number of sources]")); |
| 243 | else if (ndo->ndo_vflag > 1) { |
| 244 | ND_PRINT((ndo, " {")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 245 | for (i=0; i<nsrcs; i++) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 246 | ND_TCHECK2(bp[12+(i<<2)], 4); |
| 247 | ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[12+(i<<2)]))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 248 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 249 | ND_PRINT((ndo, " }")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 250 | } else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 251 | ND_PRINT((ndo, ", %d source(s)", nsrcs)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 252 | } |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 253 | ND_PRINT((ndo, "]")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 254 | return; |
| 255 | trunc: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 256 | ND_PRINT((ndo, "%s", tstr)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | void |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 260 | igmp_print(netdissect_options *ndo, |
| 261 | register const u_char *bp, register u_int len) |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 262 | { |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 263 | struct cksum_vec vec[1]; |
| 264 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 265 | if (ndo->ndo_qflag) { |
| 266 | ND_PRINT((ndo, "igmp")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 267 | return; |
| 268 | } |
| 269 | |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 270 | ND_TCHECK(bp[0]); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 271 | switch (bp[0]) { |
| 272 | case 0x11: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 273 | ND_PRINT((ndo, "igmp query")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 274 | if (len >= 12) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 275 | print_igmpv3_query(ndo, bp, len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 276 | else { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 277 | ND_TCHECK(bp[1]); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 278 | if (bp[1]) { |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 279 | ND_PRINT((ndo, " v2")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 280 | if (bp[1] != 100) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 281 | ND_PRINT((ndo, " [max resp time %d]", bp[1])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 282 | } else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 283 | ND_PRINT((ndo, " v1")); |
| 284 | ND_TCHECK2(bp[4], 4); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 285 | if (EXTRACT_32BITS(&bp[4])) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 286 | ND_PRINT((ndo, " [gaddr %s]", ipaddr_string(ndo, &bp[4]))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 287 | if (len != 8) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 288 | ND_PRINT((ndo, " [len %d]", len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 289 | } |
| 290 | break; |
| 291 | case 0x12: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 292 | ND_TCHECK2(bp[4], 4); |
| 293 | ND_PRINT((ndo, "igmp v1 report %s", ipaddr_string(ndo, &bp[4]))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 294 | if (len != 8) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 295 | ND_PRINT((ndo, " [len %d]", len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 296 | break; |
| 297 | case 0x16: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 298 | ND_TCHECK2(bp[4], 4); |
| 299 | ND_PRINT((ndo, "igmp v2 report %s", ipaddr_string(ndo, &bp[4]))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 300 | break; |
| 301 | case 0x22: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 302 | ND_PRINT((ndo, "igmp v3 report")); |
| 303 | print_igmpv3_report(ndo, bp, len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 304 | break; |
| 305 | case 0x17: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 306 | ND_TCHECK2(bp[4], 4); |
| 307 | ND_PRINT((ndo, "igmp leave %s", ipaddr_string(ndo, &bp[4]))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 308 | break; |
| 309 | case 0x13: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 310 | ND_PRINT((ndo, "igmp dvmrp")); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 311 | if (len < 8) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 312 | ND_PRINT((ndo, " [len %d]", len)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 313 | else |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 314 | dvmrp_print(ndo, bp, len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 315 | break; |
| 316 | case 0x14: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 317 | ND_PRINT((ndo, "igmp pimv1")); |
| 318 | pimv1_print(ndo, bp, len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 319 | break; |
| 320 | case 0x1e: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 321 | print_mresp(ndo, bp, len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 322 | break; |
| 323 | case 0x1f: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 324 | print_mtrace(ndo, bp, len); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 325 | break; |
| 326 | default: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 327 | ND_PRINT((ndo, "igmp-%d", bp[0])); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 328 | break; |
| 329 | } |
| 330 | |
Elliott Hughes | e2e3bd1 | 2017-05-15 10:59:29 -0700 | [diff] [blame] | 331 | if (ndo->ndo_vflag && len >= 4 && ND_TTEST2(bp[0], len)) { |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 332 | /* Check the IGMP checksum */ |
JP Abgrall | 53f17a9 | 2014-02-12 14:02:41 -0800 | [diff] [blame] | 333 | vec[0].ptr = bp; |
| 334 | vec[0].len = len; |
| 335 | if (in_cksum(vec, 1)) |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 336 | ND_PRINT((ndo, " bad igmp cksum %x!", EXTRACT_16BITS(&bp[2]))); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 337 | } |
| 338 | return; |
| 339 | trunc: |
Elliott Hughes | 892a68b | 2015-10-19 14:43:53 -0700 | [diff] [blame] | 340 | ND_PRINT((ndo, "%s", tstr)); |
The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame] | 341 | } |