]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-pgm.c
Regenerate config files.
[tcpdump] / print-pgm.c
index d4c3b6106b999cf5b174b6be28337f48ff0ad9bd..6d5c01ce11a8306bd57dee57983b16521d843931 100644 (file)
  * Original code by Andy Heffernan ([email protected])
  */
 
-#define NETDISSECT_REWORKED
+/* \summary: Pragmatic General Multicast (PGM) printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
 
-#include "interface.h"
+#include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
+#include "addrtostr.h"
 
 #include "ip.h"
-#ifdef INET6
 #include "ip6.h"
-#endif
 #include "ipproto.h"
 #include "af.h"
 
  * PGM header (RFC 3208)
  */
 struct pgm_header {
-    u_int16_t  pgm_sport;
-    u_int16_t  pgm_dport;
-    u_int8_t   pgm_type;
-    u_int8_t   pgm_options;
-    u_int16_t  pgm_sum;
-    u_int8_t   pgm_gsid[6];
-    u_int16_t  pgm_length;
+    uint16_t   pgm_sport;
+    uint16_t   pgm_dport;
+    uint8_t    pgm_type;
+    uint8_t    pgm_options;
+    uint16_t   pgm_sum;
+    uint8_t    pgm_gsid[6];
+    uint16_t   pgm_length;
 };
 
 struct pgm_spm {
-    u_int32_t  pgms_seq;
-    u_int32_t  pgms_trailseq;
-    u_int32_t  pgms_leadseq;
-    u_int16_t  pgms_nla_afi;
-    u_int16_t  pgms_reserved;
-    /* ... u_int8_t    pgms_nla[0]; */
+    uint32_t   pgms_seq;
+    uint32_t   pgms_trailseq;
+    uint32_t   pgms_leadseq;
+    uint16_t   pgms_nla_afi;
+    uint16_t   pgms_reserved;
+    /* ... uint8_t     pgms_nla[0]; */
     /* ... options */
 };
 
 struct pgm_nak {
-    u_int32_t  pgmn_seq;
-    u_int16_t  pgmn_source_afi;
-    u_int16_t  pgmn_reserved;
-    /* ... u_int8_t    pgmn_source[0]; */
-    /* ... u_int16_t   pgmn_group_afi */
-    /* ... u_int16_t   pgmn_reserved2; */
-    /* ... u_int8_t    pgmn_group[0]; */
+    uint32_t   pgmn_seq;
+    uint16_t   pgmn_source_afi;
+    uint16_t   pgmn_reserved;
+    /* ... uint8_t     pgmn_source[0]; */
+    /* ... uint16_t    pgmn_group_afi */
+    /* ... uint16_t    pgmn_reserved2; */
+    /* ... uint8_t     pgmn_group[0]; */
     /* ... options */
 };
 
 struct pgm_ack {
-    u_int32_t  pgma_rx_max_seq;
-    u_int32_t  pgma_bitmap;
+    uint32_t   pgma_rx_max_seq;
+    uint32_t   pgma_bitmap;
     /* ... options */
 };
 
 struct pgm_poll {
-    u_int32_t  pgmp_seq;
-    u_int16_t  pgmp_round;
-    u_int16_t  pgmp_reserved;
+    uint32_t   pgmp_seq;
+    uint16_t   pgmp_round;
+    uint16_t   pgmp_reserved;
     /* ... options */
 };
 
 struct pgm_polr {
-    u_int32_t  pgmp_seq;
-    u_int16_t  pgmp_round;
-    u_int16_t  pgmp_subtype;
-    u_int16_t  pgmp_nla_afi;
-    u_int16_t  pgmp_reserved;
-    /* ... u_int8_t    pgmp_nla[0]; */
+    uint32_t   pgmp_seq;
+    uint16_t   pgmp_round;
+    uint16_t   pgmp_subtype;
+    uint16_t   pgmp_nla_afi;
+    uint16_t   pgmp_reserved;
+    /* ... uint8_t     pgmp_nla[0]; */
     /* ... options */
 };
 
 struct pgm_data {
-    u_int32_t  pgmd_seq;
-    u_int32_t  pgmd_trailseq;
+    uint32_t   pgmd_seq;
+    uint32_t   pgmd_trailseq;
     /* ... options */
 };
 
@@ -150,43 +150,27 @@ pgm_print(netdissect_options *ndo,
        register const struct pgm_header *pgm;
        register const struct ip *ip;
        register char ch;
-       u_int16_t sport, dport;
-       int addr_size;
-       const void *nla;
-       int nla_af;
-#ifdef INET6
+       uint16_t sport, dport;
+       u_int nla_afnum;
        char nla_buf[INET6_ADDRSTRLEN];
        register const struct ip6_hdr *ip6;
-#else
-       char nla_buf[INET_ADDRSTRLEN];
-#endif
-       u_int8_t opt_type, opt_len;
-       u_int32_t seq, opts_len, len, offset;
+       uint8_t opt_type, opt_len;
+       uint32_t seq, opts_len, len, offset;
 
-       pgm = (struct pgm_header *)bp;
-       ip = (struct ip *)bp2;
-#ifdef INET6
+       pgm = (const struct pgm_header *)bp;
+       ip = (const struct ip *)bp2;
        if (IP_V(ip) == 6)
-               ip6 = (struct ip6_hdr *)bp2;
+               ip6 = (const struct ip6_hdr *)bp2;
        else
                ip6 = NULL;
-#else /* INET6 */
-       if (IP_V(ip) == 6) {
-               ND_PRINT((ndo, "Can't handle IPv6"));
-               return;
-       }
-#endif /* INET6 */
        ch = '\0';
        if (!ND_TTEST(pgm->pgm_dport)) {
-#ifdef INET6
                if (ip6) {
                        ND_PRINT((ndo, "%s > %s: [|pgm]",
                                ip6addr_string(ndo, &ip6->ip6_src),
                                ip6addr_string(ndo, &ip6->ip6_dst)));
                        return;
-               } else
-#endif /* INET6 */
-               {
+               } else {
                        ND_PRINT((ndo, "%s > %s: [|pgm]",
                                ipaddr_string(ndo, &ip->ip_src),
                                ipaddr_string(ndo, &ip->ip_dst)));
@@ -197,30 +181,27 @@ pgm_print(netdissect_options *ndo,
        sport = EXTRACT_16BITS(&pgm->pgm_sport);
        dport = EXTRACT_16BITS(&pgm->pgm_dport);
 
-#ifdef INET6
        if (ip6) {
                if (ip6->ip6_nxt == IPPROTO_PGM) {
                        ND_PRINT((ndo, "%s.%s > %s.%s: ",
                                ip6addr_string(ndo, &ip6->ip6_src),
-                               tcpport_string(sport),
+                               tcpport_string(ndo, sport),
                                ip6addr_string(ndo, &ip6->ip6_dst),
-                               tcpport_string(dport)));
+                               tcpport_string(ndo, dport)));
                } else {
                        ND_PRINT((ndo, "%s > %s: ",
-                               tcpport_string(sport), tcpport_string(dport)));
+                               tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
                }
-       } else
-#endif /*INET6*/
-       {
+       } else {
                if (ip->ip_p == IPPROTO_PGM) {
                        ND_PRINT((ndo, "%s.%s > %s.%s: ",
                                ipaddr_string(ndo, &ip->ip_src),
-                               tcpport_string(sport),
+                               tcpport_string(ndo, sport),
                                ipaddr_string(ndo, &ip->ip_dst),
-                               tcpport_string(dport)));
+                               tcpport_string(ndo, dport)));
                } else {
                        ND_PRINT((ndo, "%s > %s: ",
-                               tcpport_string(sport), tcpport_string(dport)));
+                               tcpport_string(ndo, sport), tcpport_string(ndo, dport)));
                }
        }
 
@@ -240,32 +221,28 @@ pgm_print(netdissect_options *ndo,
                      pgm->pgm_gsid[5]));
        switch (pgm->pgm_type) {
        case PGM_SPM: {
-           struct pgm_spm *spm;
+           const struct pgm_spm *spm;
 
-           spm = (struct pgm_spm *)(pgm + 1);
+           spm = (const struct pgm_spm *)(pgm + 1);
            ND_TCHECK(*spm);
+           bp = (const u_char *) (spm + 1);
 
            switch (EXTRACT_16BITS(&spm->pgms_nla_afi)) {
            case AFNUM_INET:
-               addr_size = sizeof(struct in_addr);
-               nla_af = AF_INET;
+               ND_TCHECK2(*bp, sizeof(struct in_addr));
+               addrtostr(bp, nla_buf, sizeof(nla_buf));
+               bp += sizeof(struct in_addr);
                break;
-#ifdef INET6
            case AFNUM_INET6:
-               addr_size = sizeof(struct in6_addr);
-               nla_af = AF_INET6;
+               ND_TCHECK2(*bp, sizeof(struct in6_addr));
+               addrtostr6(bp, nla_buf, sizeof(nla_buf));
+               bp += sizeof(struct in6_addr);
                break;
-#endif
            default:
                goto trunc;
                break;
            }
-           bp = (u_char *) (spm + 1);
-           ND_TCHECK2(*bp, addr_size);
-           nla = bp;
-           bp += addr_size;
 
-           inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
            ND_PRINT((ndo, "SPM seq %u trail %u lead %u nla %s",
                         EXTRACT_32BITS(&spm->pgms_seq),
                          EXTRACT_32BITS(&spm->pgms_trailseq),
@@ -275,56 +252,51 @@ pgm_print(netdissect_options *ndo,
        }
 
        case PGM_POLL: {
-           struct pgm_poll *poll;
+           const struct pgm_poll *poll_msg;
 
-           poll = (struct pgm_poll *)(pgm + 1);
-           ND_TCHECK(*poll);
+           poll_msg = (const struct pgm_poll *)(pgm + 1);
+           ND_TCHECK(*poll_msg);
            ND_PRINT((ndo, "POLL seq %u round %u",
-                        EXTRACT_32BITS(&poll->pgmp_seq),
-                         EXTRACT_16BITS(&poll->pgmp_round)));
-           bp = (u_char *) (poll + 1);
+                        EXTRACT_32BITS(&poll_msg->pgmp_seq),
+                         EXTRACT_16BITS(&poll_msg->pgmp_round)));
+           bp = (const u_char *) (poll_msg + 1);
            break;
        }
        case PGM_POLR: {
-           struct pgm_polr *polr;
-           u_int32_t ivl, rnd, mask;
+           const struct pgm_polr *polr;
+           uint32_t ivl, rnd, mask;
 
-           polr = (struct pgm_polr *)(pgm + 1);
+           polr = (const struct pgm_polr *)(pgm + 1);
            ND_TCHECK(*polr);
+           bp = (const u_char *) (polr + 1);
 
            switch (EXTRACT_16BITS(&polr->pgmp_nla_afi)) {
            case AFNUM_INET:
-               addr_size = sizeof(struct in_addr);
-               nla_af = AF_INET;
+               ND_TCHECK2(*bp, sizeof(struct in_addr));
+               addrtostr(bp, nla_buf, sizeof(nla_buf));
+               bp += sizeof(struct in_addr);
                break;
-#ifdef INET6
            case AFNUM_INET6:
-               addr_size = sizeof(struct in6_addr);
-               nla_af = AF_INET6;
+               ND_TCHECK2(*bp, sizeof(struct in6_addr));
+               addrtostr6(bp, nla_buf, sizeof(nla_buf));
+               bp += sizeof(struct in6_addr);
                break;
-#endif
            default:
                goto trunc;
                break;
            }
-           bp = (u_char *) (polr + 1);
-           ND_TCHECK2(*bp, addr_size);
-           nla = bp;
-           bp += addr_size;
-
-           inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
 
-           ND_TCHECK2(*bp, sizeof(u_int32_t));
+           ND_TCHECK2(*bp, sizeof(uint32_t));
            ivl = EXTRACT_32BITS(bp);
-           bp += sizeof(u_int32_t);
+           bp += sizeof(uint32_t);
 
-           ND_TCHECK2(*bp, sizeof(u_int32_t));
+           ND_TCHECK2(*bp, sizeof(uint32_t));
            rnd = EXTRACT_32BITS(bp);
-           bp += sizeof(u_int32_t);
+           bp += sizeof(uint32_t);
 
-           ND_TCHECK2(*bp, sizeof(u_int32_t));
+           ND_TCHECK2(*bp, sizeof(uint32_t));
            mask = EXTRACT_32BITS(bp);
-           bp += sizeof(u_int32_t);
+           bp += sizeof(uint32_t);
 
            ND_PRINT((ndo, "POLR seq %u round %u nla %s ivl %u rnd 0x%08x "
                         "mask 0x%08x", EXTRACT_32BITS(&polr->pgmp_seq),
@@ -332,43 +304,38 @@ pgm_print(netdissect_options *ndo,
            break;
        }
        case PGM_ODATA: {
-           struct pgm_data *odata;
+           const struct pgm_data *odata;
 
-           odata = (struct pgm_data *)(pgm + 1);
+           odata = (const struct pgm_data *)(pgm + 1);
            ND_TCHECK(*odata);
            ND_PRINT((ndo, "ODATA trail %u seq %u",
                         EXTRACT_32BITS(&odata->pgmd_trailseq),
                         EXTRACT_32BITS(&odata->pgmd_seq)));
-           bp = (u_char *) (odata + 1);
+           bp = (const u_char *) (odata + 1);
            break;
        }
 
        case PGM_RDATA: {
-           struct pgm_data *rdata;
+           const struct pgm_data *rdata;
 
-           rdata = (struct pgm_data *)(pgm + 1);
+           rdata = (const struct pgm_data *)(pgm + 1);
            ND_TCHECK(*rdata);
            ND_PRINT((ndo, "RDATA trail %u seq %u",
                         EXTRACT_32BITS(&rdata->pgmd_trailseq),
                         EXTRACT_32BITS(&rdata->pgmd_seq)));
-           bp = (u_char *) (rdata + 1);
+           bp = (const u_char *) (rdata + 1);
            break;
        }
 
        case PGM_NAK:
        case PGM_NULLNAK:
        case PGM_NCF: {
-           struct pgm_nak *nak;
-           const void *source, *group;
-           int source_af, group_af;
-#ifdef INET6
+           const struct pgm_nak *nak;
            char source_buf[INET6_ADDRSTRLEN], group_buf[INET6_ADDRSTRLEN];
-#else
-           char source_buf[INET_ADDRSTRLEN], group_buf[INET_ADDRSTRLEN];
-#endif
 
-           nak = (struct pgm_nak *)(pgm + 1);
+           nak = (const struct pgm_nak *)(pgm + 1);
            ND_TCHECK(*nak);
+           bp = (const u_char *) (nak + 1);
 
            /*
             * Skip past the source, saving info along the way
@@ -376,53 +343,44 @@ pgm_print(netdissect_options *ndo,
             */
            switch (EXTRACT_16BITS(&nak->pgmn_source_afi)) {
            case AFNUM_INET:
-               addr_size = sizeof(struct in_addr);
-               source_af = AF_INET;
+               ND_TCHECK2(*bp, sizeof(struct in_addr));
+               addrtostr(bp, source_buf, sizeof(source_buf));
+               bp += sizeof(struct in_addr);
                break;
-#ifdef INET6
            case AFNUM_INET6:
-               addr_size = sizeof(struct in6_addr);
-               source_af = AF_INET6;
+               ND_TCHECK2(*bp, sizeof(struct in6_addr));
+               addrtostr6(bp, source_buf, sizeof(source_buf));
+               bp += sizeof(struct in6_addr);
                break;
-#endif
            default:
                goto trunc;
                break;
            }
-           bp = (u_char *) (nak + 1);
-           ND_TCHECK2(*bp, addr_size);
-           source = bp;
-           bp += addr_size;
 
            /*
             * Skip past the group, saving info along the way
             * and stopping if we don't have enough.
             */
+           bp += (2 * sizeof(uint16_t));
            switch (EXTRACT_16BITS(bp)) {
            case AFNUM_INET:
-               addr_size = sizeof(struct in_addr);
-               group_af = AF_INET;
+               ND_TCHECK2(*bp, sizeof(struct in_addr));
+               addrtostr(bp, group_buf, sizeof(group_buf));
+               bp += sizeof(struct in_addr);
                break;
-#ifdef INET6
            case AFNUM_INET6:
-               addr_size = sizeof(struct in6_addr);
-               group_af = AF_INET6;
+               ND_TCHECK2(*bp, sizeof(struct in6_addr));
+               addrtostr6(bp, group_buf, sizeof(group_buf));
+               bp += sizeof(struct in6_addr);
                break;
-#endif
            default:
                goto trunc;
                break;
            }
-           bp += (2 * sizeof(u_int16_t));
-           ND_TCHECK2(*bp, addr_size);
-           group = bp;
-           bp += addr_size;
 
            /*
             * Options decoding can go here.
             */
-           inet_ntop(source_af, source, source_buf, sizeof(source_buf));
-           inet_ntop(group_af, group, group_buf, sizeof(group_buf));
            switch (pgm->pgm_type) {
                case PGM_NAK:
                    ND_PRINT((ndo, "NAK "));
@@ -442,13 +400,13 @@ pgm_print(netdissect_options *ndo,
        }
 
        case PGM_ACK: {
-           struct pgm_ack *ack;
+           const struct pgm_ack *ack;
 
-           ack = (struct pgm_ack *)(pgm + 1);
+           ack = (const struct pgm_ack *)(pgm + 1);
            ND_TCHECK(*ack);
            ND_PRINT((ndo, "ACK seq %u",
                         EXTRACT_32BITS(&ack->pgma_rx_max_seq)));
-           bp = (u_char *) (ack + 1);
+           bp = (const u_char *) (ack + 1);
            break;
        }
 
@@ -490,7 +448,7 @@ pgm_print(netdissect_options *ndo,
                ND_PRINT((ndo, "[Bad total option length %u < 4]", opts_len));
                return;
            }
-           bp += sizeof(u_int16_t);
+           bp += sizeof(uint16_t);
            ND_PRINT((ndo, " OPTS LEN %d", opts_len));
            opts_len -= 4;
 
@@ -522,7 +480,7 @@ pgm_print(netdissect_options *ndo,
                        return;
                    }
                    ND_PRINT((ndo, " OPTS LEN (extra?) %d", EXTRACT_16BITS(bp)));
-                   bp += sizeof(u_int16_t);
+                   bp += sizeof(uint16_t);
                    opts_len -= 4;
                    break;
 
@@ -533,29 +491,29 @@ pgm_print(netdissect_options *ndo,
                    }
                    bp += 2;
                    seq = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    offset = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    len = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    ND_PRINT((ndo, " FRAG seq %u off %u len %u", seq, offset, len));
                    opts_len -= 16;
                    break;
 
                case PGM_OPT_NAK_LIST:
                    bp += 2;
-                   opt_len -= sizeof(u_int32_t);       /* option header */
+                   opt_len -= sizeof(uint32_t);        /* option header */
                    ND_PRINT((ndo, " NAK LIST"));
                    while (opt_len) {
-                       if (opt_len < sizeof(u_int32_t)) {
+                       if (opt_len < sizeof(uint32_t)) {
                            ND_PRINT((ndo, "[Option length not a multiple of 4]"));
                            return;
                        }
-                       ND_TCHECK2(*bp, sizeof(u_int32_t));
+                       ND_TCHECK2(*bp, sizeof(uint32_t));
                        ND_PRINT((ndo, " %u", EXTRACT_32BITS(bp)));
-                       bp += sizeof(u_int32_t);
-                       opt_len -= sizeof(u_int32_t);
-                       opts_len -= sizeof(u_int32_t);
+                       bp += sizeof(uint32_t);
+                       opt_len -= sizeof(uint32_t);
+                       opts_len -= sizeof(uint32_t);
                    }
                    break;
 
@@ -566,7 +524,7 @@ pgm_print(netdissect_options *ndo,
                    }
                    bp += 2;
                    seq = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    ND_PRINT((ndo, " JOIN %u", seq));
                    opts_len -= 8;
                    break;
@@ -578,9 +536,9 @@ pgm_print(netdissect_options *ndo,
                    }
                    bp += 2;
                    offset = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    seq = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    ND_PRINT((ndo, " BACKOFF ivl %u ivlseq %u", offset, seq));
                    opts_len -= 12;
                    break;
@@ -592,42 +550,44 @@ pgm_print(netdissect_options *ndo,
                    }
                    bp += 2;
                    offset = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    seq = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    ND_PRINT((ndo, " BACKOFF max %u min %u", offset, seq));
                    opts_len -= 12;
                    break;
 
                case PGM_OPT_REDIRECT:
                    bp += 2;
-                   switch (EXTRACT_16BITS(bp)) {
+                   nla_afnum = EXTRACT_16BITS(bp);
+                   bp += (2 * sizeof(uint16_t));
+                   switch (nla_afnum) {
                    case AFNUM_INET:
-                       addr_size = sizeof(struct in_addr);
-                       nla_af = AF_INET;
+                       if (opt_len != 4 + sizeof(struct in_addr)) {
+                           ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
+                           return;
+                       }
+                       ND_TCHECK2(*bp, sizeof(struct in_addr));
+                       addrtostr(bp, nla_buf, sizeof(nla_buf));
+                       bp += sizeof(struct in_addr);
+                       opts_len -= 4 + sizeof(struct in_addr);
                        break;
-#ifdef INET6
                    case AFNUM_INET6:
-                       addr_size = sizeof(struct in6_addr);
-                       nla_af = AF_INET6;
+                       if (opt_len != 4 + sizeof(struct in6_addr)) {
+                           ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
+                           return;
+                       }
+                       ND_TCHECK2(*bp, sizeof(struct in6_addr));
+                       addrtostr6(bp, nla_buf, sizeof(nla_buf));
+                       bp += sizeof(struct in6_addr);
+                       opts_len -= 4 + sizeof(struct in6_addr);
                        break;
-#endif
                    default:
                        goto trunc;
                        break;
                    }
-                   bp += (2 * sizeof(u_int16_t));
-                   if (opt_len != 4 + addr_size) {
-                       ND_PRINT((ndo, "[Bad OPT_REDIRECT option, length %u != 4 + address size]", opt_len));
-                       return;
-                   }
-                   ND_TCHECK2(*bp, addr_size);
-                   nla = bp;
-                   bp += addr_size;
 
-                   inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
-                   ND_PRINT((ndo, " REDIRECT %s",  (char *)nla));
-                   opts_len -= 4 + addr_size;
+                   ND_PRINT((ndo, " REDIRECT %s",  nla_buf));
                    break;
 
                case PGM_OPT_PARITY_PRM:
@@ -637,7 +597,7 @@ pgm_print(netdissect_options *ndo,
                    }
                    bp += 2;
                    len = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    ND_PRINT((ndo, " PARITY MAXTGS %u", len));
                    opts_len -= 8;
                    break;
@@ -649,7 +609,7 @@ pgm_print(netdissect_options *ndo,
                    }
                    bp += 2;
                    seq = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    ND_PRINT((ndo, " PARITY GROUP %u", seq));
                    opts_len -= 8;
                    break;
@@ -661,7 +621,7 @@ pgm_print(netdissect_options *ndo,
                    }
                    bp += 2;
                    len = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
+                   bp += sizeof(uint32_t);
                    ND_PRINT((ndo, " PARITY ATGS %u", len));
                    opts_len -= 8;
                    break;
@@ -731,67 +691,71 @@ pgm_print(netdissect_options *ndo,
                case PGM_OPT_PGMCC_DATA:
                    bp += 2;
                    offset = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
-                   switch (EXTRACT_16BITS(bp)) {
+                   bp += sizeof(uint32_t);
+                   nla_afnum = EXTRACT_16BITS(bp);
+                   bp += (2 * sizeof(uint16_t));
+                   switch (nla_afnum) {
                    case AFNUM_INET:
-                       addr_size = sizeof(struct in_addr);
-                       nla_af = AF_INET;
+                       if (opt_len != 12 + sizeof(struct in_addr)) {
+                           ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+                           return;
+                       }
+                       ND_TCHECK2(*bp, sizeof(struct in_addr));
+                       addrtostr(bp, nla_buf, sizeof(nla_buf));
+                       bp += sizeof(struct in_addr);
+                       opts_len -= 12 + sizeof(struct in_addr);
                        break;
-#ifdef INET6
                    case AFNUM_INET6:
-                       addr_size = sizeof(struct in6_addr);
-                       nla_af = AF_INET6;
+                       if (opt_len != 12 + sizeof(struct in6_addr)) {
+                           ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+                           return;
+                       }
+                       ND_TCHECK2(*bp, sizeof(struct in6_addr));
+                       addrtostr6(bp, nla_buf, sizeof(nla_buf));
+                       bp += sizeof(struct in6_addr);
+                       opts_len -= 12 + sizeof(struct in6_addr);
                        break;
-#endif
                    default:
                        goto trunc;
                        break;
                    }
-                   bp += (2 * sizeof(u_int16_t));
-                   if (opt_len != 12 + addr_size) {
-                       ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
-                       return;
-                   }
-                   ND_TCHECK2(*bp, addr_size);
-                   nla = bp;
-                   bp += addr_size;
 
-                   inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
-                   ND_PRINT((ndo, " PGMCC DATA %u %s", offset, (char*)nla));
-                   opts_len -= 16;
+                   ND_PRINT((ndo, " PGMCC DATA %u %s", offset, nla_buf));
                    break;
 
                case PGM_OPT_PGMCC_FEEDBACK:
                    bp += 2;
                    offset = EXTRACT_32BITS(bp);
-                   bp += sizeof(u_int32_t);
-                   switch (EXTRACT_16BITS(bp)) {
+                   bp += sizeof(uint32_t);
+                   nla_afnum = EXTRACT_16BITS(bp);
+                   bp += (2 * sizeof(uint16_t));
+                   switch (nla_afnum) {
                    case AFNUM_INET:
-                       addr_size = sizeof(struct in_addr);
-                       nla_af = AF_INET;
+                       if (opt_len != 12 + sizeof(struct in_addr)) {
+                           ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+                           return;
+                       }
+                       ND_TCHECK2(*bp, sizeof(struct in_addr));
+                       addrtostr(bp, nla_buf, sizeof(nla_buf));
+                       bp += sizeof(struct in_addr);
+                       opts_len -= 12 + sizeof(struct in_addr);
                        break;
-#ifdef INET6
                    case AFNUM_INET6:
-                       addr_size = sizeof(struct in6_addr);
-                       nla_af = AF_INET6;
+                       if (opt_len != 12 + sizeof(struct in6_addr)) {
+                           ND_PRINT((ndo, "[Bad OPT_PGMCC_DATA option, length %u != 12 + address size]", opt_len));
+                           return;
+                       }
+                       ND_TCHECK2(*bp, sizeof(struct in6_addr));
+                       addrtostr6(bp, nla_buf, sizeof(nla_buf));
+                       bp += sizeof(struct in6_addr);
+                       opts_len -= 12 + sizeof(struct in6_addr);
                        break;
-#endif
                    default:
                        goto trunc;
                        break;
                    }
-                   bp += (2 * sizeof(u_int16_t));
-                   if (opt_len != 12 + addr_size) {
-                       ND_PRINT((ndo, "[Bad OPT_PGMCC_FEEDBACK option, length %u != 12 + address size]", opt_len));
-                       return;
-                   }
-                   ND_TCHECK2(*bp, addr_size);
-                   nla = bp;
-                   bp += addr_size;
 
-                   inet_ntop(nla_af, nla, nla_buf, sizeof(nla_buf));
-                   ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, (char*)nla));
-                   opts_len -= 16;
+                   ND_PRINT((ndo, " PGMCC FEEDBACK %u %s", offset, nla_buf));
                    break;
 
                default: