print-pim.c (75118) | print-pim.c (98527) |
---|---|
1/* 2 * Copyright (c) 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 --- 4 unchanged lines hidden (view full) --- 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 * | 1/* 2 * Copyright (c) 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 --- 4 unchanged lines hidden (view full) --- 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 * $FreeBSD: head/contrib/tcpdump/print-pim.c 75118 2001-04-03 07:50:46Z fenner $ | 21 * $FreeBSD: head/contrib/tcpdump/print-pim.c 98527 2002-06-21 00:49:02Z fenner $ |
22 */ 23 24#ifndef lint 25static const char rcsid[] = | 22 */ 23 24#ifndef lint 25static const char rcsid[] = |
26 "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.23 2000/10/03 02:55:00 itojun Exp $ (LBL)"; | 26 "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.29 2001/07/04 21:36:15 fenner Exp $ (LBL)"; |
27#endif 28 29#ifdef HAVE_CONFIG_H 30#include "config.h" 31#endif 32 33#include <sys/param.h> 34#include <sys/time.h> --- 31 unchanged lines hidden (view full) --- 66 67#include "ip.h" 68 69static void pimv2_print(register const u_char *bp, register u_int len); 70 71static void 72pimv1_join_prune_print(register const u_char *bp, register u_int len) 73{ | 27#endif 28 29#ifdef HAVE_CONFIG_H 30#include "config.h" 31#endif 32 33#include <sys/param.h> 34#include <sys/time.h> --- 31 unchanged lines hidden (view full) --- 66 67#include "ip.h" 68 69static void pimv2_print(register const u_char *bp, register u_int len); 70 71static void 72pimv1_join_prune_print(register const u_char *bp, register u_int len) 73{ |
74 int maddrlen, addrlen, ngroups, njoin, nprune; 75 int njp; | 74 int maddrlen, addrlen, ngroups, njoin, nprune; 75 int njp; |
76 | 76 |
77 /* If it's a single group and a single source, use 1-line output. */ 78 if (TTEST2(bp[0], 30) && bp[11] == 1 && 79 ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) { 80 int hold; | 77 /* If it's a single group and a single source, use 1-line output. */ 78 if (TTEST2(bp[0], 30) && bp[11] == 1 && 79 ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) { 80 int hold; |
81 | 81 |
82 (void)printf(" RPF %s ", ipaddr_string(bp)); 83 hold = EXTRACT_16BITS(&bp[6]); 84 if (hold != 180) { 85 (void)printf("Hold "); 86 relts_print(hold); 87 } 88 (void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune", 89 ipaddr_string(&bp[26]), bp[25] & 0x3f, 90 ipaddr_string(&bp[12])); 91 if (EXTRACT_32BITS(&bp[16]) != 0xffffffff) 92 (void)printf("/%s", ipaddr_string(&bp[16])); 93 (void)printf(") %s%s %s", | 82 (void)printf(" RPF %s ", ipaddr_string(bp)); 83 hold = EXTRACT_16BITS(&bp[6]); 84 if (hold != 180) { 85 (void)printf("Hold "); 86 relts_print(hold); 87 } 88 (void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune", 89 ipaddr_string(&bp[26]), bp[25] & 0x3f, 90 ipaddr_string(&bp[12])); 91 if (EXTRACT_32BITS(&bp[16]) != 0xffffffff) 92 (void)printf("/%s", ipaddr_string(&bp[16])); 93 (void)printf(") %s%s %s", |
94 (bp[24] & 0x01) ? "Sparse" : "Dense", 95 (bp[25] & 0x80) ? " WC" : "", 96 (bp[25] & 0x40) ? "RP" : "SPT"); | 94 (bp[24] & 0x01) ? "Sparse" : "Dense", 95 (bp[25] & 0x80) ? " WC" : "", 96 (bp[25] & 0x40) ? "RP" : "SPT"); |
97 return; 98 } 99 100 TCHECK2(bp[0], 4); 101 (void)printf("\n Upstream Nbr: %s", ipaddr_string(bp)); 102 TCHECK2(bp[6], 2); 103 (void)printf("\n Hold time: "); 104 relts_print(EXTRACT_16BITS(&bp[6])); 105 bp += 8; len -= 8; | 97 return; 98 } |
106 | 99 |
107 TCHECK2(bp[0], 4); 108 maddrlen = bp[1]; 109 addrlen = bp[2]; 110 ngroups = bp[3]; 111 bp += 4; len -= 4; 112 while (ngroups--) { | |
113 TCHECK2(bp[0], 4); | 100 TCHECK2(bp[0], 4); |
114 (void)printf("\n\tGroup: %s", ipaddr_string(bp)); 115 if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) 116 (void)printf("/%s", ipaddr_string(&bp[4])); 117 TCHECK2(bp[8], 4); 118 njoin = EXTRACT_16BITS(&bp[8]); 119 nprune = EXTRACT_16BITS(&bp[10]); 120 (void)printf(" joined: %d pruned: %d", njoin, nprune); 121 bp += 12; len -= 12; 122 for (njp = 0; njp < (njoin + nprune); njp++) { 123 char *type; | 101 if (vflag > 1) 102 (void)printf("\n"); 103 (void)printf(" Upstream Nbr: %s", ipaddr_string(bp)); 104 TCHECK2(bp[6], 2); 105 if (vflag > 1) 106 (void)printf("\n"); 107 (void)printf(" Hold time: "); 108 relts_print(EXTRACT_16BITS(&bp[6])); 109 if (vflag < 2) 110 return; 111 bp += 8; 112 len -= 8; |
124 | 113 |
125 if (njp < njoin) { 126 type = "Join "; 127 } else { 128 type = "Prune"; 129 } 130 TCHECK2(bp[0], 6); 131 (void)printf("\n\t%s %s%s%s%s/%d", type, | 114 TCHECK2(bp[0], 4); 115 maddrlen = bp[1]; 116 addrlen = bp[2]; 117 ngroups = bp[3]; 118 bp += 4; 119 len -= 4; 120 while (ngroups--) { 121 TCHECK2(bp[0], 4); 122 (void)printf("\n\tGroup: %s", ipaddr_string(bp)); 123 if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) 124 (void)printf("/%s", ipaddr_string(&bp[4])); 125 TCHECK2(bp[8], 4); 126 njoin = EXTRACT_16BITS(&bp[8]); 127 nprune = EXTRACT_16BITS(&bp[10]); 128 (void)printf(" joined: %d pruned: %d", njoin, nprune); 129 bp += 12; 130 len -= 12; 131 for (njp = 0; njp < (njoin + nprune); njp++) { 132 char *type; 133 134 if (njp < njoin) 135 type = "Join "; 136 else 137 type = "Prune"; 138 TCHECK2(bp[0], 6); 139 (void)printf("\n\t%s %s%s%s%s/%d", type, |
132 (bp[0] & 0x01) ? "Sparse " : "Dense ", 133 (bp[1] & 0x80) ? "WC " : "", 134 (bp[1] & 0x40) ? "RP " : "SPT ", | 140 (bp[0] & 0x01) ? "Sparse " : "Dense ", 141 (bp[1] & 0x80) ? "WC " : "", 142 (bp[1] & 0x40) ? "RP " : "SPT ", |
135 ipaddr_string(&bp[2]), bp[1] & 0x3f); 136 bp += 6; len -= 6; | 143 ipaddr_string(&bp[2]), bp[1] & 0x3f); 144 bp += 6; 145 len -= 6; 146 } |
137 } | 147 } |
138 } 139 return; | 148 return; |
140trunc: | 149trunc: |
141 (void)printf("[|pim]"); 142 return; | 150 (void)printf("[|pim]"); 151 return; |
143} 144 145void 146pimv1_print(register const u_char *bp, register u_int len) 147{ | 152} 153 154void 155pimv1_print(register const u_char *bp, register u_int len) 156{ |
148 register const u_char *ep; 149 register u_char type; | 157 register const u_char *ep; 158 register u_char type; |
150 | 159 |
151 ep = (const u_char *)snapend; 152 if (bp >= ep) 153 return; | 160 ep = (const u_char *)snapend; 161 if (bp >= ep) 162 return; |
154 | 163 |
155 type = bp[1]; | 164 type = bp[1]; |
156 | 165 |
157 switch (type) { 158 case 0: 159 (void)printf(" Query"); 160 if (TTEST(bp[8])) { 161 switch (bp[8] >> 4) { 162 case 0: (void)printf(" Dense-mode"); | 166 switch (type) { 167 case 0: 168 (void)printf(" Query"); 169 if (TTEST(bp[8])) { 170 switch (bp[8] >> 4) { 171 case 0: 172 (void)printf(" Dense-mode"); |
163 break; | 173 break; |
164 case 1: (void)printf(" Sparse-mode"); | 174 case 1: 175 (void)printf(" Sparse-mode"); |
165 break; | 176 break; |
166 case 2: (void)printf(" Sparse-Dense-mode"); | 177 case 2: 178 (void)printf(" Sparse-Dense-mode"); |
167 break; | 179 break; |
168 default: (void)printf(" mode-%d", bp[8] >> 4); | 180 default: 181 (void)printf(" mode-%d", bp[8] >> 4); |
169 break; | 182 break; |
183 } |
|
170 } | 184 } |
171 } 172 if (vflag) { 173 TCHECK2(bp[10],2); 174 (void)printf(" (Hold-time "); 175 relts_print(EXTRACT_16BITS(&bp[10])); 176 (void)printf(")"); 177 } 178 break; | 185 if (vflag) { 186 TCHECK2(bp[10],2); 187 (void)printf(" (Hold-time "); 188 relts_print(EXTRACT_16BITS(&bp[10])); 189 (void)printf(")"); 190 } 191 break; |
179 | 192 |
180 case 1: 181 (void)printf(" Register"); 182 TCHECK2(bp[8], 20); /* ip header */ 183 (void)printf(" for %s > %s", ipaddr_string(&bp[20]), 184 ipaddr_string(&bp[24])); 185 break; 186 187 case 2: 188 (void)printf(" Register-Stop"); 189 TCHECK2(bp[12], 4); 190 (void)printf(" for %s > %s", ipaddr_string(&bp[8]), 191 ipaddr_string(&bp[12])); 192 break; 193 194 case 3: 195 (void)printf(" Join/Prune"); 196 if (vflag) { 197 pimv1_join_prune_print(&bp[8], len - 8); 198 } 199 break; 200 201 case 4: 202 (void)printf(" RP-reachable"); 203 if (vflag) { 204 TCHECK2(bp[22], 2); 205 (void)printf(" group %s", | 193 case 1: 194 (void)printf(" Register"); 195 TCHECK2(bp[8], 20); /* ip header */ 196 (void)printf(" for %s > %s", ipaddr_string(&bp[20]), 197 ipaddr_string(&bp[24])); 198 break; 199 case 2: 200 (void)printf(" Register-Stop"); 201 TCHECK2(bp[12], 4); 202 (void)printf(" for %s > %s", ipaddr_string(&bp[8]), 203 ipaddr_string(&bp[12])); 204 break; 205 case 3: 206 (void)printf(" Join/Prune"); 207 if (vflag) 208 pimv1_join_prune_print(&bp[8], len - 8); 209 break; 210 case 4: 211 (void)printf(" RP-reachable"); 212 if (vflag) { 213 TCHECK2(bp[22], 2); 214 (void)printf(" group %s", |
206 ipaddr_string(&bp[8])); | 215 ipaddr_string(&bp[8])); |
216 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) 217 (void)printf("/%s", ipaddr_string(&bp[12])); 218 (void)printf(" RP %s hold ", ipaddr_string(&bp[16])); 219 relts_print(EXTRACT_16BITS(&bp[22])); 220 } 221 break; 222 case 5: 223 (void)printf(" Assert"); 224 TCHECK2(bp[16], 4); 225 (void)printf(" for %s > %s", ipaddr_string(&bp[16]), 226 ipaddr_string(&bp[8])); |
|
207 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) 208 (void)printf("/%s", ipaddr_string(&bp[12])); | 227 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) 228 (void)printf("/%s", ipaddr_string(&bp[12])); |
209 (void)printf(" RP %s hold ", 210 ipaddr_string(&bp[16])); 211 relts_print(EXTRACT_16BITS(&bp[22])); 212 } 213 break; 214 215 case 5: 216 (void)printf(" Assert"); 217 TCHECK2(bp[16], 4); 218 (void)printf(" for %s > %s", ipaddr_string(&bp[16]), 219 ipaddr_string(&bp[8])); 220 if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) 221 (void)printf("/%s", ipaddr_string(&bp[12])); 222 TCHECK2(bp[24], 4); 223 (void)printf(" %s pref %d metric %d", 224 (bp[20] & 0x80) ? "RP-tree" : "SPT", | 229 TCHECK2(bp[24], 4); 230 (void)printf(" %s pref %d metric %d", 231 (bp[20] & 0x80) ? "RP-tree" : "SPT", |
225 EXTRACT_32BITS(&bp[20]) & 0x7fffffff, 226 EXTRACT_32BITS(&bp[24])); | 232 EXTRACT_32BITS(&bp[20]) & 0x7fffffff, 233 EXTRACT_32BITS(&bp[24])); |
227 break; 228 229 case 6: 230 (void)printf(" Graft"); 231 if (vflag) { 232 pimv1_join_prune_print(&bp[8], len - 8); | 234 break; 235 case 6: 236 (void)printf(" Graft"); 237 if (vflag) 238 pimv1_join_prune_print(&bp[8], len - 8); 239 break; 240 case 7: 241 (void)printf(" Graft-ACK"); 242 if (vflag) 243 pimv1_join_prune_print(&bp[8], len - 8); 244 break; 245 case 8: 246 (void)printf(" Mode"); 247 break; 248 default: 249 (void)printf(" [type %d]", type); 250 break; |
233 } | 251 } |
234 break; | 252 if ((bp[4] >> 4) != 1) 253 (void)printf(" [v%d]", bp[4] >> 4); 254 return; |
235 | 255 |
236 case 7: 237 (void)printf(" Graft-ACK"); 238 if (vflag) { 239 pimv1_join_prune_print(&bp[8], len - 8); 240 } 241 break; 242 243 case 8: 244 (void)printf(" Mode"); 245 break; 246 247 default: 248 (void)printf(" [type %d]", type); 249 break; 250 } 251 if ((bp[4] >> 4) != 1) 252 (void)printf(" [v%d]", bp[4] >> 4); 253 return; 254 | |
255trunc: | 256trunc: |
256 (void)printf("[|pim]"); 257 return; | 257 (void)printf("[|pim]"); 258 return; |
258} 259 260/* 261 * auto-RP is a cisco protocol, documented at | 259} 260 261/* 262 * auto-RP is a cisco protocol, documented at |
262 * ftp://ftpeng.cisco.com/ipmulticast/pim-autorp-spec01.txt | 263 * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt 264 * 265 * This implements version 1+, dated Sept 9, 1998. |
263 */ 264void 265cisco_autorp_print(register const u_char *bp, register u_int len) 266{ | 266 */ 267void 268cisco_autorp_print(register const u_char *bp, register u_int len) 269{ |
267 int type; 268 int numrps; 269 int hold; | 270 int type; 271 int numrps; 272 int hold; |
270 | 273 |
271 TCHECK(bp[0]); 272 (void)printf(" auto-rp "); 273 type = bp[0]; 274 switch (type) { 275 case 0x11: 276 (void)printf("candidate-advert"); 277 break; 278 case 0x12: 279 (void)printf("mapping"); 280 break; 281 default: 282 (void)printf("type-0x%02x", type); 283 break; 284 } | 274 TCHECK(bp[0]); 275 (void)printf(" auto-rp "); 276 type = bp[0]; 277 switch (type) { 278 case 0x11: 279 (void)printf("candidate-advert"); 280 break; 281 case 0x12: 282 (void)printf("mapping"); 283 break; 284 default: 285 (void)printf("type-0x%02x", type); 286 break; 287 } |
285 | 288 |
286 TCHECK(bp[1]); 287 numrps = bp[1]; | 289 TCHECK(bp[1]); 290 numrps = bp[1]; |
288 | 291 |
289 TCHECK2(bp[2], 2); 290 (void)printf(" Hold "); 291 hold = EXTRACT_16BITS(&bp[2]); 292 if (hold) 293 relts_print(EXTRACT_16BITS(&bp[2])); 294 else 295 printf("FOREVER"); | 292 TCHECK2(bp[2], 2); 293 (void)printf(" Hold "); 294 hold = EXTRACT_16BITS(&bp[2]); 295 if (hold) 296 relts_print(EXTRACT_16BITS(&bp[2])); 297 else 298 printf("FOREVER"); |
296 | 299 |
297 /* Next 4 bytes are reserved. */ | 300 /* Next 4 bytes are reserved. */ |
298 | 301 |
299 bp += 8; len -= 8; | 302 bp += 8; len -= 8; |
300 | 303 |
301 /*XXX skip unless -v? */ | 304 /*XXX skip unless -v? */ |
302 | 305 |
303 /* 304 * Rest of packet: 305 * numrps entries of the form: 306 * 32 bits: RP 307 * 6 bits: reserved 308 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2". 309 * 8 bits: # of entries for this RP 310 * each entry: 7 bits: reserved, 1 bit: negative, 311 * 8 bits: mask 32 bits: source 312 * lather, rinse, repeat. 313 */ 314 while (numrps--) { 315 int nentries; 316 char s; | 306 /* 307 * Rest of packet: 308 * numrps entries of the form: 309 * 32 bits: RP 310 * 6 bits: reserved 311 * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2". 312 * 8 bits: # of entries for this RP 313 * each entry: 7 bits: reserved, 1 bit: negative, 314 * 8 bits: mask 32 bits: source 315 * lather, rinse, repeat. 316 */ 317 while (numrps--) { 318 int nentries; 319 char s; |
317 | 320 |
318 TCHECK2(bp[0], 4); 319 (void)printf(" RP %s", ipaddr_string(bp)); 320 TCHECK(bp[4]); 321 switch (bp[4] & 0x3) { 322 case 0: printf(" PIMv?"); 323 break; 324 case 1: printf(" PIMv1"); 325 break; 326 case 2: printf(" PIMv2"); 327 break; 328 case 3: printf(" PIMv1+2"); 329 break; | 321 TCHECK2(bp[0], 4); 322 (void)printf(" RP %s", ipaddr_string(bp)); 323 TCHECK(bp[4]); 324 switch (bp[4] & 0x3) { 325 case 0: printf(" PIMv?"); 326 break; 327 case 1: printf(" PIMv1"); 328 break; 329 case 2: printf(" PIMv2"); 330 break; 331 case 3: printf(" PIMv1+2"); 332 break; 333 } 334 if (bp[4] & 0xfc) 335 (void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc); 336 TCHECK(bp[5]); 337 nentries = bp[5]; 338 bp += 6; len -= 6; 339 s = ' '; 340 for (; nentries; nentries--) { 341 TCHECK2(bp[0], 6); 342 (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "", 343 ipaddr_string(&bp[2]), bp[1]); 344 if (bp[0] & 0xfe) 345 (void)printf("[rsvd=0x%02x]", bp[0] & 0xfe); 346 s = ','; 347 bp += 6; len -= 6; 348 } |
330 } | 349 } |
331 TCHECK(bp[5]); 332 nentries = bp[5]; 333 bp += 6; len -= 6; 334 s = ' '; 335 for (; nentries; nentries--) { 336 TCHECK2(bp[0], 6); 337 (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "", 338 ipaddr_string(&bp[2]), bp[1]); 339 s = ','; 340 bp += 6; len -= 6; 341 } 342 } 343 return; | 350 return; |
344 345trunc: | 351 352trunc: |
346 (void)printf("[|autorp]"); 347 return; | 353 (void)printf("[|autorp]"); 354 return; |
348} 349 350void 351pim_print(register const u_char *bp, register u_int len) 352{ 353 register const u_char *ep; 354 register struct pim *pim = (struct pim *)bp; 355 356 ep = (const u_char *)snapend; 357 if (bp >= ep) 358 return; 359#ifdef notyet /* currently we see only version and type */ 360 TCHECK(pim->pim_rsv); 361#endif 362 363 switch (PIM_VER(pim->pim_typever)) { | 355} 356 357void 358pim_print(register const u_char *bp, register u_int len) 359{ 360 register const u_char *ep; 361 register struct pim *pim = (struct pim *)bp; 362 363 ep = (const u_char *)snapend; 364 if (bp >= ep) 365 return; 366#ifdef notyet /* currently we see only version and type */ 367 TCHECK(pim->pim_rsv); 368#endif 369 370 switch (PIM_VER(pim->pim_typever)) { |
364 case 2: /* avoid hardcoding? */ | 371 case 2: /* avoid hardcoding? */ |
365 (void)printf("pim v2"); 366 pimv2_print(bp, len); 367 break; | 372 (void)printf("pim v2"); 373 pimv2_print(bp, len); 374 break; |
368 default: | 375 default: |
369 (void)printf("pim v%d", PIM_VER(pim->pim_typever)); 370 break; 371 } 372 return; 373} 374 375/* 376 * PIMv2 uses encoded address representations. --- 35 unchanged lines hidden (view full) --- 412 * 413 */ 414 415static int pimv2_addr_len; 416 417enum pimv2_addrtype { 418 pimv2_unicast, pimv2_group, pimv2_source 419}; | 376 (void)printf("pim v%d", PIM_VER(pim->pim_typever)); 377 break; 378 } 379 return; 380} 381 382/* 383 * PIMv2 uses encoded address representations. --- 35 unchanged lines hidden (view full) --- 419 * 420 */ 421 422static int pimv2_addr_len; 423 424enum pimv2_addrtype { 425 pimv2_unicast, pimv2_group, pimv2_source 426}; |
420#if 0 421static char *addrtypestr[] = { 422 "unicast", "group", "source" 423}; 424#endif | |
425 426/* 0 1 2 3 427 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 428 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 429 * | Addr Family | Encoding Type | Unicast Address | 430 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++ 431 * 0 1 2 3 432 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 --- 17 unchanged lines hidden (view full) --- 450 char *afstr; 451 int len, hdrlen; 452 453 TCHECK(bp[0]); 454 455 if (pimv2_addr_len == 0) { 456 TCHECK(bp[1]); 457 switch (bp[0]) { | 427 428/* 0 1 2 3 429 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 430 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 431 * | Addr Family | Encoding Type | Unicast Address | 432 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+++++++ 433 * 0 1 2 3 434 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 --- 17 unchanged lines hidden (view full) --- 452 char *afstr; 453 int len, hdrlen; 454 455 TCHECK(bp[0]); 456 457 if (pimv2_addr_len == 0) { 458 TCHECK(bp[1]); 459 switch (bp[0]) { |
458 case 1: | 460 case 1: |
459 af = AF_INET; 460 afstr = "IPv4"; 461 len = 4; 462 break; 463#ifdef INET6 | 461 af = AF_INET; 462 afstr = "IPv4"; 463 len = 4; 464 break; 465#ifdef INET6 |
464 case 2: | 466 case 2: |
465 af = AF_INET6; 466 afstr = "IPv6"; 467 len = 16; 468 break; 469#endif | 467 af = AF_INET6; 468 afstr = "IPv6"; 469 len = 16; 470 break; 471#endif |
470 default: | 472 default: |
471 return -1; 472 } 473 if (bp[1] != 0) 474 return -1; 475 hdrlen = 2; 476 } else { 477 switch (pimv2_addr_len) { | 473 return -1; 474 } 475 if (bp[1] != 0) 476 return -1; 477 hdrlen = 2; 478 } else { 479 switch (pimv2_addr_len) { |
478 case 4: | 480 case 4: |
479 af = AF_INET; 480 afstr = "IPv4"; 481 break; 482#ifdef INET6 | 481 af = AF_INET; 482 afstr = "IPv4"; 483 break; 484#ifdef INET6 |
483 case 16: | 485 case 16: |
484 af = AF_INET6; 485 afstr = "IPv6"; 486 break; 487#endif | 486 af = AF_INET6; 487 afstr = "IPv6"; 488 break; 489#endif |
488 default: | 490 default: |
489 return -1; 490 break; 491 } 492 len = pimv2_addr_len; 493 hdrlen = 0; 494 } 495 496 bp += hdrlen; 497 switch (at) { | 491 return -1; 492 break; 493 } 494 len = pimv2_addr_len; 495 hdrlen = 0; 496 } 497 498 bp += hdrlen; 499 switch (at) { |
498 case pimv2_unicast: | 500 case pimv2_unicast: |
499 TCHECK2(bp[0], len); 500 if (af == AF_INET) { 501 if (!silent) 502 (void)printf("%s", ipaddr_string(bp)); 503 } 504#ifdef INET6 505 else if (af == AF_INET6) { 506 if (!silent) 507 (void)printf("%s", ip6addr_string(bp)); 508 } 509#endif 510 return hdrlen + len; | 501 TCHECK2(bp[0], len); 502 if (af == AF_INET) { 503 if (!silent) 504 (void)printf("%s", ipaddr_string(bp)); 505 } 506#ifdef INET6 507 else if (af == AF_INET6) { 508 if (!silent) 509 (void)printf("%s", ip6addr_string(bp)); 510 } 511#endif 512 return hdrlen + len; |
511 case pimv2_group: 512 case pimv2_source: | 513 case pimv2_group: 514 case pimv2_source: |
513 TCHECK2(bp[0], len + 2); 514 if (af == AF_INET) { 515 if (!silent) { 516 (void)printf("%s", ipaddr_string(bp + 2)); 517 if (bp[1] != 32) 518 (void)printf("/%u", bp[1]); 519 } 520 } --- 41 unchanged lines hidden (view full) --- 562 if (ep > bp + len) 563 ep = bp + len; 564 TCHECK(pim->pim_rsv); 565 pimv2_addr_len = pim->pim_rsv; 566 if (pimv2_addr_len != 0) 567 (void)printf("[RFC2117-encoding] "); 568 569 switch (PIM_TYPE(pim->pim_typever)) { | 515 TCHECK2(bp[0], len + 2); 516 if (af == AF_INET) { 517 if (!silent) { 518 (void)printf("%s", ipaddr_string(bp + 2)); 519 if (bp[1] != 32) 520 (void)printf("/%u", bp[1]); 521 } 522 } --- 41 unchanged lines hidden (view full) --- 564 if (ep > bp + len) 565 ep = bp + len; 566 TCHECK(pim->pim_rsv); 567 pimv2_addr_len = pim->pim_rsv; 568 if (pimv2_addr_len != 0) 569 (void)printf("[RFC2117-encoding] "); 570 571 switch (PIM_TYPE(pim->pim_typever)) { |
570 case 0: | 572 case 0: |
571 { 572 u_int16_t otype, olen; 573 (void)printf(" Hello"); 574 bp += 4; 575 while (bp < ep) { 576 TCHECK2(bp[0], 4); 577 otype = EXTRACT_16BITS(&bp[0]); 578 olen = EXTRACT_16BITS(&bp[2]); 579 TCHECK2(bp[0], 4 + olen); 580 switch (otype) { 581 case 1: /* Hold time */ 582 (void)printf(" (Hold-time "); 583 relts_print(EXTRACT_16BITS(&bp[4])); 584 (void)printf(")"); 585 break; 586 | 573 { 574 u_int16_t otype, olen; 575 (void)printf(" Hello"); 576 bp += 4; 577 while (bp < ep) { 578 TCHECK2(bp[0], 4); 579 otype = EXTRACT_16BITS(&bp[0]); 580 olen = EXTRACT_16BITS(&bp[2]); 581 TCHECK2(bp[0], 4 + olen); 582 switch (otype) { 583 case 1: /* Hold time */ 584 (void)printf(" (Hold-time "); 585 relts_print(EXTRACT_16BITS(&bp[4])); 586 (void)printf(")"); 587 break; 588 |
587 /* XXX 588 * draft-ietf-idmr-pimv2-dr-priority-00.txt 589 * says that DR-Priority is option 19. 590 * draft-ietf-pim-v2-sm-00.txt says it's 18. 591 */ 592 case 18: /* DR-Priority */ 593 (void)printf(" (DR-Priority: %d)", EXTRACT_32BITS(&bp[4])); | 589 case 19: /* DR-Priority */ 590 (void)printf(" (DR-Priority: "); 591 if (olen != 4) { 592 (void)printf("!olen=%d!)", olen); 593 } else { 594 (void)printf("%d)", EXTRACT_32BITS(&bp[4])); 595 } |
594 break; 595 | 596 break; 597 |
596 case 19: /* Bidir-Capable */ 597 if (olen == 4) 598 (void)printf(" (OLD-DR-Priority: %d)", EXTRACT_32BITS(&bp[4])); 599 else 600 (void)printf(" (bidir-capable)"); 601 break; 602 | |
603 case 20: 604 (void)printf(" (Genid: 0x%08x)", EXTRACT_32BITS(&bp[4])); 605 break; 606 607 case 21: | 598 case 20: 599 (void)printf(" (Genid: 0x%08x)", EXTRACT_32BITS(&bp[4])); 600 break; 601 602 case 21: |
608 (void)printf(" (State Refresh Capable"); 609 if (EXTRACT_32BITS(&bp[4]) != 1) { 610 (void)printf(" ?0x%x?", EXTRACT_32BITS(&bp[4])); | 603 (void)printf(" (State Refresh Capable; v%d", bp[4]); 604 if (bp[5] != 0) { 605 (void)printf(" interval "); 606 relts_print(bp[5]); |
611 } | 607 } |
608 if (EXTRACT_16BITS(&bp[6]) != 0) { 609 (void)printf(" ?0x%04x?", EXTRACT_16BITS(&bp[6])); 610 } |
|
612 (void)printf(")"); 613 break; 614 | 611 (void)printf(")"); 612 break; 613 |
614 case 22: /* Bidir-Capable */ 615 (void)printf(" (bidir-capable)"); 616 break; 617 |
|
615 default: 616 if (vflag) 617 (void)printf(" [Hello option %d]", otype); 618 } 619 bp += 4 + olen; 620 } 621 break; 622 } 623 | 618 default: 619 if (vflag) 620 (void)printf(" [Hello option %d]", otype); 621 } 622 bp += 4 + olen; 623 } 624 break; 625 } 626 |
624 case 1: 625 { | 627 case 1: 628 { |
626 struct ip *ip; 627 628 (void)printf(" Register"); 629 if (vflag && bp + 8 <= ep) { 630 (void)printf(" %s%s", bp[4] & 0x80 ? "B" : "", 631 bp[4] & 0x40 ? "N" : ""); 632 } 633 bp += 8; len -= 8; 634 635 /* encapsulated multicast packet */ 636 if (bp >= ep) 637 break; 638 ip = (struct ip *)bp; 639 switch (IP_V(ip)) { | 629 struct ip *ip; 630 631 (void)printf(" Register"); 632 if (vflag && bp + 8 <= ep) { 633 (void)printf(" %s%s", bp[4] & 0x80 ? "B" : "", 634 bp[4] & 0x40 ? "N" : ""); 635 } 636 bp += 8; len -= 8; 637 638 /* encapsulated multicast packet */ 639 if (bp >= ep) 640 break; 641 ip = (struct ip *)bp; 642 switch (IP_V(ip)) { |
640 case 4: /* IPv4 */ | 643 case 4: /* IPv4 */ |
641 printf(" "); 642 ip_print(bp, len); 643 break; 644#ifdef INET6 | 644 printf(" "); 645 ip_print(bp, len); 646 break; 647#ifdef INET6 |
645 case 6: /* IPv6 */ | 648 case 6: /* IPv6 */ |
646 printf(" "); 647 ip6_print(bp, len); 648 break; 649#endif | 649 printf(" "); 650 ip6_print(bp, len); 651 break; 652#endif |
650 default: | 653 default: |
651 (void)printf(" IP ver %d", IP_V(ip)); 652 break; 653 } 654 break; | 654 (void)printf(" IP ver %d", IP_V(ip)); 655 break; 656 } 657 break; |
655 } | 658 } |
656 | 659 |
657 case 2: | 660 case 2: |
658 (void)printf(" Register-Stop"); 659 bp += 4; len -= 4; 660 if (bp >= ep) 661 break; 662 (void)printf(" group="); 663 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { 664 (void)printf("..."); 665 break; --- 4 unchanged lines hidden (view full) --- 670 (void)printf(" source="); 671 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { 672 (void)printf("..."); 673 break; 674 } 675 bp += advance; len -= advance; 676 break; 677 | 661 (void)printf(" Register-Stop"); 662 bp += 4; len -= 4; 663 if (bp >= ep) 664 break; 665 (void)printf(" group="); 666 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { 667 (void)printf("..."); 668 break; --- 4 unchanged lines hidden (view full) --- 673 (void)printf(" source="); 674 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { 675 (void)printf("..."); 676 break; 677 } 678 bp += advance; len -= advance; 679 break; 680 |
678 case 3: 679 case 6: 680 case 7: | 681 case 3: 682 case 6: 683 case 7: |
681 { 682 u_int8_t ngroup; 683 u_int16_t holdtime; 684 u_int16_t njoin; 685 u_int16_t nprune; 686 int i, j; 687 688 switch (PIM_TYPE(pim->pim_typever)) { | 684 { 685 u_int8_t ngroup; 686 u_int16_t holdtime; 687 u_int16_t njoin; 688 u_int16_t nprune; 689 int i, j; 690 691 switch (PIM_TYPE(pim->pim_typever)) { |
689 case 3: | 692 case 3: |
690 (void)printf(" Join/Prune"); 691 break; | 693 (void)printf(" Join/Prune"); 694 break; |
692 case 6: | 695 case 6: |
693 (void)printf(" Graft"); 694 break; | 696 (void)printf(" Graft"); 697 break; |
695 case 7: | 698 case 7: |
696 (void)printf(" Graft-ACK"); 697 break; 698 } 699 bp += 4; len -= 4; 700 if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/ 701 if (bp >= ep) 702 break; 703 (void)printf(" upstream-neighbor="); --- 51 unchanged lines hidden (view full) --- 755 bp += advance; len -= advance; 756 } 757 (void)printf(")"); 758 } 759 jp_done: 760 break; 761 } 762 | 699 (void)printf(" Graft-ACK"); 700 break; 701 } 702 bp += 4; len -= 4; 703 if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/ 704 if (bp >= ep) 705 break; 706 (void)printf(" upstream-neighbor="); --- 51 unchanged lines hidden (view full) --- 758 bp += advance; len -= advance; 759 } 760 (void)printf(")"); 761 } 762 jp_done: 763 break; 764 } 765 |
763 case 4: 764 { | 766 case 4: 767 { |
765 int i, j, frpcnt; 766 767 (void)printf(" Bootstrap"); 768 bp += 4; 769 770 /* Fragment Tag, Hash Mask len, and BSR-priority */ 771 if (bp + sizeof(u_int16_t) >= ep) break; 772 (void)printf(" tag=%x", EXTRACT_16BITS(bp)); --- 59 unchanged lines hidden (view full) --- 832 } 833 (void)printf(",prio=%d", bp[2]); 834 bp += 4; 835 } 836 (void)printf(")"); 837 } 838 bs_done: 839 break; | 768 int i, j, frpcnt; 769 770 (void)printf(" Bootstrap"); 771 bp += 4; 772 773 /* Fragment Tag, Hash Mask len, and BSR-priority */ 774 if (bp + sizeof(u_int16_t) >= ep) break; 775 (void)printf(" tag=%x", EXTRACT_16BITS(bp)); --- 59 unchanged lines hidden (view full) --- 835 } 836 (void)printf(",prio=%d", bp[2]); 837 bp += 4; 838 } 839 (void)printf(")"); 840 } 841 bs_done: 842 break; |
840 } 841 case 5: | 843 } 844 case 5: |
842 (void)printf(" Assert"); 843 bp += 4; len -= 4; 844 if (bp >= ep) 845 break; 846 (void)printf(" group="); 847 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { 848 (void)printf("..."); 849 break; --- 10 unchanged lines hidden (view full) --- 860 if (bp + 8 > ep) 861 break; 862 if (bp[0] & 0x80) 863 (void)printf(" RPT"); 864 (void)printf(" pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff); 865 (void)printf(" metric=%u", EXTRACT_32BITS(&bp[4])); 866 break; 867 | 845 (void)printf(" Assert"); 846 bp += 4; len -= 4; 847 if (bp >= ep) 848 break; 849 (void)printf(" group="); 850 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) < 0) { 851 (void)printf("..."); 852 break; --- 10 unchanged lines hidden (view full) --- 863 if (bp + 8 > ep) 864 break; 865 if (bp[0] & 0x80) 866 (void)printf(" RPT"); 867 (void)printf(" pref=%u", EXTRACT_32BITS(&bp[0]) & 0x7fffffff); 868 (void)printf(" metric=%u", EXTRACT_32BITS(&bp[4])); 869 break; 870 |
868 case 8: 869 { | 871 case 8: 872 { |
870 int i, pfxcnt; 871 872 (void)printf(" Candidate-RP-Advertisement"); 873 bp += 4; 874 875 /* Prefix-Cnt, Priority, and Holdtime */ 876 if (bp >= ep) break; 877 (void)printf(" prefix-cnt=%d", bp[0]); --- 20 unchanged lines hidden (view full) --- 898 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) 899 < 0) { 900 (void)printf("..."); 901 break; 902 } 903 bp += advance; 904 } 905 break; | 873 int i, pfxcnt; 874 875 (void)printf(" Candidate-RP-Advertisement"); 876 bp += 4; 877 878 /* Prefix-Cnt, Priority, and Holdtime */ 879 if (bp >= ep) break; 880 (void)printf(" prefix-cnt=%d", bp[0]); --- 20 unchanged lines hidden (view full) --- 901 if ((advance = pimv2_addr_print(bp, pimv2_group, 0)) 902 < 0) { 903 (void)printf("..."); 904 break; 905 } 906 bp += advance; 907 } 908 break; |
906 } | 909 } |
907 | 910 |
908 case 9: | 911 case 9: |
909 (void)printf(" Prune-Refresh"); 910 (void)printf(" src="); 911 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { 912 (void)printf("..."); 913 break; 914 } 915 bp += advance; 916 (void)printf(" grp="); --- 27 unchanged lines hidden --- | 912 (void)printf(" Prune-Refresh"); 913 (void)printf(" src="); 914 if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { 915 (void)printf("..."); 916 break; 917 } 918 bp += advance; 919 (void)printf(" grp="); --- 27 unchanged lines hidden --- |