+static void pimv2_print(register const u_char *bp, register u_int len, u_int cksum);
+
+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",
+ (bp[24] & 0x01) ? "Sparse" : "Dense",
+ (bp[25] & 0x80) ? " WC" : "",
+ (bp[25] & 0x40) ? "RP" : "SPT");
+ return;
+ }
+
+ TCHECK2(bp[0], sizeof(struct in_addr));
+ 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--) {
+ /*
+ * XXX - does the address have length "addrlen" and the
+ * mask length "maddrlen"?
+ */
+ TCHECK2(bp[0], sizeof(struct in_addr));
+ (void)printf("\n\tGroup: %s", ipaddr_string(bp));
+ TCHECK2(bp[4], sizeof(struct in_addr));
+ 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++) {
+ const 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;
+ }
+ }
+ return;
+trunc:
+ (void)printf("[|pim]");
+ return;
+}