diff options
author | Bill Fenner <fenner@FreeBSD.org> | 2002-06-21 00:49:02 +0000 |
---|---|---|
committer | Bill Fenner <fenner@FreeBSD.org> | 2002-06-21 00:49:02 +0000 |
commit | a1c2090e60772b130de11c58c5587e56ca741565 (patch) | |
tree | cf4df09e1e89ebd11358792543230083e577ad0f /contrib/tcpdump/print-pim.c | |
parent | 1c6248dba05782c255d12a9a0bfdc2d72e5843f6 (diff) | |
download | src-a1c2090e60772b130de11c58c5587e56ca741565.tar.gz src-a1c2090e60772b130de11c58c5587e56ca741565.zip |
Merge tcpdump 3.7.1
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=98527
Diffstat (limited to 'contrib/tcpdump/print-pim.c')
-rw-r--r-- | contrib/tcpdump/print-pim.c | 569 |
1 files changed, 286 insertions, 283 deletions
diff --git a/contrib/tcpdump/print-pim.c b/contrib/tcpdump/print-pim.c index 2e6ff7266991..209c552f76b6 100644 --- a/contrib/tcpdump/print-pim.c +++ b/contrib/tcpdump/print-pim.c @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.23 2000/10/03 02:55:00 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-pim.c,v 1.29 2001/07/04 21:36:15 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -71,280 +71,287 @@ static void pimv2_print(register const u_char *bp, register u_int len); static void pimv1_join_prune_print(register const u_char *bp, register u_int len) { - int maddrlen, addrlen, ngroups, njoin, nprune; - int njp; - - /* If it's a single group and a single source, use 1-line output. */ - if (TTEST2(bp[0], 30) && bp[11] == 1 && - ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) { - int hold; - - (void)printf(" RPF %s ", ipaddr_string(bp)); - hold = EXTRACT_16BITS(&bp[6]); - if (hold != 180) { - (void)printf("Hold "); - relts_print(hold); - } - (void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune", - ipaddr_string(&bp[26]), bp[25] & 0x3f, - ipaddr_string(&bp[12])); - if (EXTRACT_32BITS(&bp[16]) != 0xffffffff) - (void)printf("/%s", ipaddr_string(&bp[16])); - (void)printf(") %s%s %s", + int maddrlen, addrlen, ngroups, njoin, nprune; + int njp; + + /* If it's a single group and a single source, use 1-line output. */ + if (TTEST2(bp[0], 30) && bp[11] == 1 && + ((njoin = EXTRACT_16BITS(&bp[20])) + EXTRACT_16BITS(&bp[22])) == 1) { + int hold; + + (void)printf(" RPF %s ", ipaddr_string(bp)); + hold = EXTRACT_16BITS(&bp[6]); + if (hold != 180) { + (void)printf("Hold "); + relts_print(hold); + } + (void)printf("%s (%s/%d, %s", njoin ? "Join" : "Prune", + ipaddr_string(&bp[26]), bp[25] & 0x3f, + ipaddr_string(&bp[12])); + if (EXTRACT_32BITS(&bp[16]) != 0xffffffff) + (void)printf("/%s", ipaddr_string(&bp[16])); + (void)printf(") %s%s %s", (bp[24] & 0x01) ? "Sparse" : "Dense", (bp[25] & 0x80) ? " WC" : "", (bp[25] & 0x40) ? "RP" : "SPT"); - return; - } - - TCHECK2(bp[0], 4); - (void)printf("\n Upstream Nbr: %s", ipaddr_string(bp)); - TCHECK2(bp[6], 2); - (void)printf("\n Hold time: "); - relts_print(EXTRACT_16BITS(&bp[6])); - bp += 8; len -= 8; - - TCHECK2(bp[0], 4); - maddrlen = bp[1]; - addrlen = bp[2]; - ngroups = bp[3]; - bp += 4; len -= 4; - while (ngroups--) { + return; + } + TCHECK2(bp[0], 4); - (void)printf("\n\tGroup: %s", ipaddr_string(bp)); - if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) - (void)printf("/%s", ipaddr_string(&bp[4])); - TCHECK2(bp[8], 4); - njoin = EXTRACT_16BITS(&bp[8]); - nprune = EXTRACT_16BITS(&bp[10]); - (void)printf(" joined: %d pruned: %d", njoin, nprune); - bp += 12; len -= 12; - for (njp = 0; njp < (njoin + nprune); njp++) { - char *type; - - if (njp < njoin) { - type = "Join "; - } else { - type = "Prune"; - } - TCHECK2(bp[0], 6); - (void)printf("\n\t%s %s%s%s%s/%d", type, + if (vflag > 1) + (void)printf("\n"); + (void)printf(" Upstream Nbr: %s", ipaddr_string(bp)); + TCHECK2(bp[6], 2); + if (vflag > 1) + (void)printf("\n"); + (void)printf(" Hold time: "); + relts_print(EXTRACT_16BITS(&bp[6])); + if (vflag < 2) + return; + bp += 8; + len -= 8; + + TCHECK2(bp[0], 4); + maddrlen = bp[1]; + addrlen = bp[2]; + ngroups = bp[3]; + bp += 4; + len -= 4; + while (ngroups--) { + TCHECK2(bp[0], 4); + (void)printf("\n\tGroup: %s", ipaddr_string(bp)); + if (EXTRACT_32BITS(&bp[4]) != 0xffffffff) + (void)printf("/%s", ipaddr_string(&bp[4])); + TCHECK2(bp[8], 4); + njoin = EXTRACT_16BITS(&bp[8]); + nprune = EXTRACT_16BITS(&bp[10]); + (void)printf(" joined: %d pruned: %d", njoin, nprune); + bp += 12; + len -= 12; + for (njp = 0; njp < (njoin + nprune); njp++) { + char *type; + + if (njp < njoin) + type = "Join "; + else + type = "Prune"; + TCHECK2(bp[0], 6); + (void)printf("\n\t%s %s%s%s%s/%d", type, (bp[0] & 0x01) ? "Sparse " : "Dense ", (bp[1] & 0x80) ? "WC " : "", (bp[1] & 0x40) ? "RP " : "SPT ", - ipaddr_string(&bp[2]), bp[1] & 0x3f); - bp += 6; len -= 6; + ipaddr_string(&bp[2]), bp[1] & 0x3f); + bp += 6; + len -= 6; + } } - } - return; + return; trunc: - (void)printf("[|pim]"); - return; + (void)printf("[|pim]"); + return; } void pimv1_print(register const u_char *bp, register u_int len) { - register const u_char *ep; - register u_char type; + register const u_char *ep; + register u_char type; - ep = (const u_char *)snapend; - if (bp >= ep) - return; + ep = (const u_char *)snapend; + if (bp >= ep) + return; - type = bp[1]; + type = bp[1]; - switch (type) { - case 0: - (void)printf(" Query"); - if (TTEST(bp[8])) { - switch (bp[8] >> 4) { - case 0: (void)printf(" Dense-mode"); + switch (type) { + case 0: + (void)printf(" Query"); + if (TTEST(bp[8])) { + switch (bp[8] >> 4) { + case 0: + (void)printf(" Dense-mode"); break; - case 1: (void)printf(" Sparse-mode"); + case 1: + (void)printf(" Sparse-mode"); break; - case 2: (void)printf(" Sparse-Dense-mode"); + case 2: + (void)printf(" Sparse-Dense-mode"); break; - default: (void)printf(" mode-%d", bp[8] >> 4); + default: + (void)printf(" mode-%d", bp[8] >> 4); break; + } } - } - if (vflag) { - TCHECK2(bp[10],2); - (void)printf(" (Hold-time "); - relts_print(EXTRACT_16BITS(&bp[10])); - (void)printf(")"); - } - break; - - case 1: - (void)printf(" Register"); - TCHECK2(bp[8], 20); /* ip header */ - (void)printf(" for %s > %s", ipaddr_string(&bp[20]), - ipaddr_string(&bp[24])); - break; - - case 2: - (void)printf(" Register-Stop"); - TCHECK2(bp[12], 4); - (void)printf(" for %s > %s", ipaddr_string(&bp[8]), - ipaddr_string(&bp[12])); - break; - - case 3: - (void)printf(" Join/Prune"); - if (vflag) { - pimv1_join_prune_print(&bp[8], len - 8); - } - break; + if (vflag) { + TCHECK2(bp[10],2); + (void)printf(" (Hold-time "); + relts_print(EXTRACT_16BITS(&bp[10])); + (void)printf(")"); + } + break; - case 4: - (void)printf(" RP-reachable"); - if (vflag) { - TCHECK2(bp[22], 2); - (void)printf(" group %s", + case 1: + (void)printf(" Register"); + TCHECK2(bp[8], 20); /* ip header */ + (void)printf(" for %s > %s", ipaddr_string(&bp[20]), + ipaddr_string(&bp[24])); + break; + case 2: + (void)printf(" Register-Stop"); + TCHECK2(bp[12], 4); + (void)printf(" for %s > %s", ipaddr_string(&bp[8]), + ipaddr_string(&bp[12])); + break; + case 3: + (void)printf(" Join/Prune"); + if (vflag) + pimv1_join_prune_print(&bp[8], len - 8); + break; + case 4: + (void)printf(" RP-reachable"); + if (vflag) { + TCHECK2(bp[22], 2); + (void)printf(" group %s", ipaddr_string(&bp[8])); + if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) + (void)printf("/%s", ipaddr_string(&bp[12])); + (void)printf(" RP %s hold ", ipaddr_string(&bp[16])); + relts_print(EXTRACT_16BITS(&bp[22])); + } + break; + case 5: + (void)printf(" Assert"); + TCHECK2(bp[16], 4); + (void)printf(" for %s > %s", ipaddr_string(&bp[16]), + ipaddr_string(&bp[8])); if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) (void)printf("/%s", ipaddr_string(&bp[12])); - (void)printf(" RP %s hold ", - ipaddr_string(&bp[16])); - relts_print(EXTRACT_16BITS(&bp[22])); - } - break; - - case 5: - (void)printf(" Assert"); - TCHECK2(bp[16], 4); - (void)printf(" for %s > %s", ipaddr_string(&bp[16]), - ipaddr_string(&bp[8])); - if (EXTRACT_32BITS(&bp[12]) != 0xffffffff) - (void)printf("/%s", ipaddr_string(&bp[12])); - TCHECK2(bp[24], 4); - (void)printf(" %s pref %d metric %d", - (bp[20] & 0x80) ? "RP-tree" : "SPT", + TCHECK2(bp[24], 4); + (void)printf(" %s pref %d metric %d", + (bp[20] & 0x80) ? "RP-tree" : "SPT", EXTRACT_32BITS(&bp[20]) & 0x7fffffff, EXTRACT_32BITS(&bp[24])); - break; - - case 6: - (void)printf(" Graft"); - if (vflag) { - pimv1_join_prune_print(&bp[8], len - 8); - } - break; - - case 7: - (void)printf(" Graft-ACK"); - if (vflag) { - pimv1_join_prune_print(&bp[8], len - 8); + break; + case 6: + (void)printf(" Graft"); + if (vflag) + pimv1_join_prune_print(&bp[8], len - 8); + break; + case 7: + (void)printf(" Graft-ACK"); + if (vflag) + pimv1_join_prune_print(&bp[8], len - 8); + break; + case 8: + (void)printf(" Mode"); + break; + default: + (void)printf(" [type %d]", type); + break; } - break; - - case 8: - (void)printf(" Mode"); - break; - - default: - (void)printf(" [type %d]", type); - break; - } - if ((bp[4] >> 4) != 1) - (void)printf(" [v%d]", bp[4] >> 4); - return; + if ((bp[4] >> 4) != 1) + (void)printf(" [v%d]", bp[4] >> 4); + return; trunc: - (void)printf("[|pim]"); - return; + (void)printf("[|pim]"); + return; } /* * auto-RP is a cisco protocol, documented at - * ftp://ftpeng.cisco.com/ipmulticast/pim-autorp-spec01.txt + * ftp://ftpeng.cisco.com/ipmulticast/specs/pim-autorp-spec01.txt + * + * This implements version 1+, dated Sept 9, 1998. */ void cisco_autorp_print(register const u_char *bp, register u_int len) { - int type; - int numrps; - int hold; - - TCHECK(bp[0]); - (void)printf(" auto-rp "); - type = bp[0]; - switch (type) { - case 0x11: - (void)printf("candidate-advert"); - break; - case 0x12: - (void)printf("mapping"); - break; - default: - (void)printf("type-0x%02x", type); - break; - } - - TCHECK(bp[1]); - numrps = bp[1]; - - TCHECK2(bp[2], 2); - (void)printf(" Hold "); - hold = EXTRACT_16BITS(&bp[2]); - if (hold) - relts_print(EXTRACT_16BITS(&bp[2])); - else - printf("FOREVER"); - - /* Next 4 bytes are reserved. */ - - bp += 8; len -= 8; - - /*XXX skip unless -v? */ - - /* - * Rest of packet: - * numrps entries of the form: - * 32 bits: RP - * 6 bits: reserved - * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2". - * 8 bits: # of entries for this RP - * each entry: 7 bits: reserved, 1 bit: negative, - * 8 bits: mask 32 bits: source - * lather, rinse, repeat. - */ - while (numrps--) { - int nentries; - char s; + int type; + int numrps; + int hold; - TCHECK2(bp[0], 4); - (void)printf(" RP %s", ipaddr_string(bp)); - TCHECK(bp[4]); - switch (bp[4] & 0x3) { - case 0: printf(" PIMv?"); - break; - case 1: printf(" PIMv1"); + TCHECK(bp[0]); + (void)printf(" auto-rp "); + type = bp[0]; + switch (type) { + case 0x11: + (void)printf("candidate-advert"); break; - case 2: printf(" PIMv2"); + case 0x12: + (void)printf("mapping"); break; - case 3: printf(" PIMv1+2"); + default: + (void)printf("type-0x%02x", type); break; } - TCHECK(bp[5]); - nentries = bp[5]; - bp += 6; len -= 6; - s = ' '; - for (; nentries; nentries--) { - TCHECK2(bp[0], 6); - (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "", - ipaddr_string(&bp[2]), bp[1]); - s = ','; - bp += 6; len -= 6; + + TCHECK(bp[1]); + numrps = bp[1]; + + TCHECK2(bp[2], 2); + (void)printf(" Hold "); + hold = EXTRACT_16BITS(&bp[2]); + if (hold) + relts_print(EXTRACT_16BITS(&bp[2])); + else + printf("FOREVER"); + + /* Next 4 bytes are reserved. */ + + bp += 8; len -= 8; + + /*XXX skip unless -v? */ + + /* + * Rest of packet: + * numrps entries of the form: + * 32 bits: RP + * 6 bits: reserved + * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2". + * 8 bits: # of entries for this RP + * each entry: 7 bits: reserved, 1 bit: negative, + * 8 bits: mask 32 bits: source + * lather, rinse, repeat. + */ + while (numrps--) { + int nentries; + char s; + + TCHECK2(bp[0], 4); + (void)printf(" RP %s", ipaddr_string(bp)); + TCHECK(bp[4]); + switch (bp[4] & 0x3) { + case 0: printf(" PIMv?"); + break; + case 1: printf(" PIMv1"); + break; + case 2: printf(" PIMv2"); + break; + case 3: printf(" PIMv1+2"); + break; + } + if (bp[4] & 0xfc) + (void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc); + TCHECK(bp[5]); + nentries = bp[5]; + bp += 6; len -= 6; + s = ' '; + for (; nentries; nentries--) { + TCHECK2(bp[0], 6); + (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "", + ipaddr_string(&bp[2]), bp[1]); + if (bp[0] & 0xfe) + (void)printf("[rsvd=0x%02x]", bp[0] & 0xfe); + s = ','; + bp += 6; len -= 6; + } } - } - return; + return; trunc: - (void)printf("[|autorp]"); - return; + (void)printf("[|autorp]"); + return; } void @@ -361,11 +368,11 @@ pim_print(register const u_char *bp, register u_int len) #endif switch (PIM_VER(pim->pim_typever)) { - case 2: /* avoid hardcoding? */ + case 2: /* avoid hardcoding? */ (void)printf("pim v2"); pimv2_print(bp, len); break; - default: + default: (void)printf("pim v%d", PIM_VER(pim->pim_typever)); break; } @@ -417,11 +424,6 @@ static int pimv2_addr_len; enum pimv2_addrtype { pimv2_unicast, pimv2_group, pimv2_source }; -#if 0 -static char *addrtypestr[] = { - "unicast", "group", "source" -}; -#endif /* 0 1 2 3 * 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 @@ -455,19 +457,19 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent) if (pimv2_addr_len == 0) { TCHECK(bp[1]); switch (bp[0]) { - case 1: + case 1: af = AF_INET; afstr = "IPv4"; len = 4; break; #ifdef INET6 - case 2: + case 2: af = AF_INET6; afstr = "IPv6"; len = 16; break; #endif - default: + default: return -1; } if (bp[1] != 0) @@ -475,17 +477,17 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent) hdrlen = 2; } else { switch (pimv2_addr_len) { - case 4: + case 4: af = AF_INET; afstr = "IPv4"; break; #ifdef INET6 - case 16: + case 16: af = AF_INET6; afstr = "IPv6"; break; #endif - default: + default: return -1; break; } @@ -495,7 +497,7 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent) bp += hdrlen; switch (at) { - case pimv2_unicast: + case pimv2_unicast: TCHECK2(bp[0], len); if (af == AF_INET) { if (!silent) @@ -508,8 +510,8 @@ pimv2_addr_print(const u_char *bp, enum pimv2_addrtype at, int silent) } #endif return hdrlen + len; - case pimv2_group: - case pimv2_source: + case pimv2_group: + case pimv2_source: TCHECK2(bp[0], len + 2); if (af == AF_INET) { if (!silent) { @@ -567,7 +569,7 @@ pimv2_print(register const u_char *bp, register u_int len) (void)printf("[RFC2117-encoding] "); switch (PIM_TYPE(pim->pim_typever)) { - case 0: + case 0: { u_int16_t otype, olen; (void)printf(" Hello"); @@ -584,20 +586,13 @@ pimv2_print(register const u_char *bp, register u_int len) (void)printf(")"); break; - /* XXX - * draft-ietf-idmr-pimv2-dr-priority-00.txt - * says that DR-Priority is option 19. - * draft-ietf-pim-v2-sm-00.txt says it's 18. - */ - case 18: /* DR-Priority */ - (void)printf(" (DR-Priority: %d)", EXTRACT_32BITS(&bp[4])); - break; - - case 19: /* Bidir-Capable */ - if (olen == 4) - (void)printf(" (OLD-DR-Priority: %d)", EXTRACT_32BITS(&bp[4])); - else - (void)printf(" (bidir-capable)"); + case 19: /* DR-Priority */ + (void)printf(" (DR-Priority: "); + if (olen != 4) { + (void)printf("!olen=%d!)", olen); + } else { + (void)printf("%d)", EXTRACT_32BITS(&bp[4])); + } break; case 20: @@ -605,13 +600,21 @@ pimv2_print(register const u_char *bp, register u_int len) break; case 21: - (void)printf(" (State Refresh Capable"); - if (EXTRACT_32BITS(&bp[4]) != 1) { - (void)printf(" ?0x%x?", EXTRACT_32BITS(&bp[4])); + (void)printf(" (State Refresh Capable; v%d", bp[4]); + if (bp[5] != 0) { + (void)printf(" interval "); + relts_print(bp[5]); + } + if (EXTRACT_16BITS(&bp[6]) != 0) { + (void)printf(" ?0x%04x?", EXTRACT_16BITS(&bp[6])); } (void)printf(")"); break; + case 22: /* Bidir-Capable */ + (void)printf(" (bidir-capable)"); + break; + default: if (vflag) (void)printf(" [Hello option %d]", otype); @@ -621,8 +624,8 @@ pimv2_print(register const u_char *bp, register u_int len) break; } - case 1: - { + case 1: + { struct ip *ip; (void)printf(" Register"); @@ -637,24 +640,24 @@ pimv2_print(register const u_char *bp, register u_int len) break; ip = (struct ip *)bp; switch (IP_V(ip)) { - case 4: /* IPv4 */ + case 4: /* IPv4 */ printf(" "); ip_print(bp, len); break; #ifdef INET6 - case 6: /* IPv6 */ + case 6: /* IPv6 */ printf(" "); ip6_print(bp, len); break; #endif - default: + default: (void)printf(" IP ver %d", IP_V(ip)); break; } break; - } + } - case 2: + case 2: (void)printf(" Register-Stop"); bp += 4; len -= 4; if (bp >= ep) @@ -675,9 +678,9 @@ pimv2_print(register const u_char *bp, register u_int len) bp += advance; len -= advance; break; - case 3: - case 6: - case 7: + case 3: + case 6: + case 7: { u_int8_t ngroup; u_int16_t holdtime; @@ -686,13 +689,13 @@ pimv2_print(register const u_char *bp, register u_int len) int i, j; switch (PIM_TYPE(pim->pim_typever)) { - case 3: + case 3: (void)printf(" Join/Prune"); break; - case 6: + case 6: (void)printf(" Graft"); break; - case 7: + case 7: (void)printf(" Graft-ACK"); break; } @@ -760,8 +763,8 @@ pimv2_print(register const u_char *bp, register u_int len) break; } - case 4: - { + case 4: + { int i, j, frpcnt; (void)printf(" Bootstrap"); @@ -837,8 +840,8 @@ pimv2_print(register const u_char *bp, register u_int len) } bs_done: break; - } - case 5: + } + case 5: (void)printf(" Assert"); bp += 4; len -= 4; if (bp >= ep) @@ -865,8 +868,8 @@ pimv2_print(register const u_char *bp, register u_int len) (void)printf(" metric=%u", EXTRACT_32BITS(&bp[4])); break; - case 8: - { + case 8: + { int i, pfxcnt; (void)printf(" Candidate-RP-Advertisement"); @@ -903,9 +906,9 @@ pimv2_print(register const u_char *bp, register u_int len) bp += advance; } break; - } + } - case 9: + case 9: (void)printf(" Prune-Refresh"); (void)printf(" src="); if ((advance = pimv2_addr_print(bp, pimv2_unicast, 0)) < 0) { |