]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-pgm.c
bgp: Parse BGP extended message support capability
[tcpdump] / print-pgm.c
index a7ac64a8379d767067abba4593fb1c2279cf0a6e..39597e7f57e41bc69a278921d73c7a6b5bfd3756 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "netdissect-stdinc.h"
 
+#define ND_LONGJMP_FROM_TCHECK
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -167,15 +168,14 @@ pgm_print(netdissect_options *ndo,
        if (!ND_TTEST_2(pgm->pgm_dport)) {
                if (ip6) {
                        ND_PRINT("%s > %s:",
-                               ip6addr_string(ndo, ip6->ip6_src),
-                               ip6addr_string(ndo, ip6->ip6_dst));
+                               GET_IP6ADDR_STRING(ip6->ip6_src),
+                               GET_IP6ADDR_STRING(ip6->ip6_dst));
                } else {
                        ND_PRINT("%s > %s:",
-                               ipaddr_string(ndo, ip->ip_src),
-                               ipaddr_string(ndo, ip->ip_dst));
+                               GET_IPADDR_STRING(ip->ip_src),
+                               GET_IPADDR_STRING(ip->ip_dst));
                }
-               nd_print_trunc(ndo);
-               return;
+               nd_trunc_longjmp(ndo);
        }
 
        sport = GET_BE_U_2(pgm->pgm_sport);
@@ -184,9 +184,9 @@ pgm_print(netdissect_options *ndo,
        if (ip6) {
                if (GET_U_1(ip6->ip6_nxt) == IPPROTO_PGM) {
                        ND_PRINT("%s.%s > %s.%s: ",
-                               ip6addr_string(ndo, ip6->ip6_src),
+                               GET_IP6ADDR_STRING(ip6->ip6_src),
                                tcpport_string(ndo, sport),
-                               ip6addr_string(ndo, ip6->ip6_dst),
+                               GET_IP6ADDR_STRING(ip6->ip6_dst),
                                tcpport_string(ndo, dport));
                } else {
                        ND_PRINT("%s > %s: ",
@@ -195,9 +195,9 @@ pgm_print(netdissect_options *ndo,
        } else {
                if (GET_U_1(ip->ip_p) == IPPROTO_PGM) {
                        ND_PRINT("%s.%s > %s.%s: ",
-                               ipaddr_string(ndo, ip->ip_src),
+                               GET_IPADDR_STRING(ip->ip_src),
                                tcpport_string(ndo, sport),
-                               ipaddr_string(ndo, ip->ip_dst),
+                               GET_IPADDR_STRING(ip->ip_dst),
                                tcpport_string(ndo, dport));
                } else {
                        ND_PRINT("%s > %s: ",
@@ -240,7 +240,7 @@ pgm_print(netdissect_options *ndo,
                bp += sizeof(nd_ipv6);
                break;
            default:
-               goto trunc;
+               goto invalid;
                break;
            }
 
@@ -253,14 +253,14 @@ pgm_print(netdissect_options *ndo,
        }
 
        case PGM_POLL: {
-           const struct pgm_poll *poll;
+           const struct pgm_poll *pgm_poll;
            uint32_t ivl, rnd, mask;
 
-           poll = (const struct pgm_poll *)(pgm + 1);
-           ND_TCHECK_SIZE(poll);
-           bp = (const u_char *) (poll + 1);
+           pgm_poll = (const struct pgm_poll *)(pgm + 1);
+           ND_TCHECK_SIZE(pgm_poll);
+           bp = (const u_char *) (pgm_poll + 1);
 
-           switch (GET_BE_U_2(poll->pgmp_nla_afi)) {
+           switch (GET_BE_U_2(pgm_poll->pgmp_nla_afi)) {
            case AFNUM_INET:
                ND_TCHECK_LEN(bp, sizeof(nd_ipv4));
                addrtostr(bp, nla_buf, sizeof(nla_buf));
@@ -272,25 +272,22 @@ pgm_print(netdissect_options *ndo,
                bp += sizeof(nd_ipv6);
                break;
            default:
-               goto trunc;
+               goto invalid;
                break;
            }
 
-           ND_TCHECK_LEN(bp, sizeof(uint32_t));
            ivl = GET_BE_U_4(bp);
            bp += sizeof(uint32_t);
 
-           ND_TCHECK_LEN(bp, sizeof(uint32_t));
            rnd = GET_BE_U_4(bp);
            bp += sizeof(uint32_t);
 
-           ND_TCHECK_LEN(bp, sizeof(uint32_t));
            mask = GET_BE_U_4(bp);
            bp += sizeof(uint32_t);
 
            ND_PRINT("POLL seq %u round %u nla %s ivl %u rnd 0x%08x "
-                        "mask 0x%08x", GET_BE_U_4(poll->pgmp_seq),
-                        GET_BE_U_2(poll->pgmp_round), nla_buf, ivl, rnd,
+                        "mask 0x%08x", GET_BE_U_4(pgm_poll->pgmp_seq),
+                        GET_BE_U_2(pgm_poll->pgmp_round), nla_buf, ivl, rnd,
                         mask);
            break;
        }
@@ -309,7 +306,6 @@ pgm_print(netdissect_options *ndo,
            const struct pgm_data *odata;
 
            odata = (const struct pgm_data *)(pgm + 1);
-           ND_TCHECK_SIZE(odata);
            ND_PRINT("ODATA trail %u seq %u",
                         GET_BE_U_4(odata->pgmd_trailseq),
                         GET_BE_U_4(odata->pgmd_seq));
@@ -321,7 +317,6 @@ pgm_print(netdissect_options *ndo,
            const struct pgm_data *rdata;
 
            rdata = (const struct pgm_data *)(pgm + 1);
-           ND_TCHECK_SIZE(rdata);
            ND_PRINT("RDATA trail %u seq %u",
                         GET_BE_U_4(rdata->pgmd_trailseq),
                         GET_BE_U_4(rdata->pgmd_seq));
@@ -355,7 +350,7 @@ pgm_print(netdissect_options *ndo,
                bp += sizeof(nd_ipv6);
                break;
            default:
-               goto trunc;
+               goto invalid;
                break;
            }
 
@@ -364,7 +359,6 @@ pgm_print(netdissect_options *ndo,
             * and stopping if we don't have enough.
             */
            bp += (2 * sizeof(uint16_t));
-           ND_TCHECK_2(bp);
            switch (GET_BE_U_2(bp)) {
            case AFNUM_INET:
                ND_TCHECK_LEN(bp, sizeof(nd_ipv4));
@@ -377,7 +371,7 @@ pgm_print(netdissect_options *ndo,
                bp += sizeof(nd_ipv6);
                break;
            default:
-               goto trunc;
+               goto invalid;
                break;
            }
 
@@ -459,7 +453,6 @@ pgm_print(netdissect_options *ndo,
                    ND_PRINT("[Total option length leaves no room for final option]");
                    return;
                }
-               ND_TCHECK_2(bp);
                opt_type = GET_U_1(bp);
                bp++;
                opt_len = GET_U_1(bp);
@@ -515,7 +508,6 @@ pgm_print(netdissect_options *ndo,
                            ND_PRINT("[Option length not a multiple of 4]");
                            return;
                        }
-                       ND_TCHECK_4(bp);
                        ND_PRINT(" %u", GET_BE_U_4(bp));
                        bp += 4;
                        opt_len -= 4;
@@ -594,7 +586,7 @@ pgm_print(netdissect_options *ndo,
                    case AFNUM_INET6:
                        if (opt_len != PGM_OPT_REDIRECT_FIXED_LEN + sizeof(nd_ipv6)) {
                            ND_PRINT("[Bad OPT_REDIRECT option, length %u != %u + address size]",
-                               PGM_OPT_REDIRECT_FIXED_LEN, opt_len);
+                               opt_len, PGM_OPT_REDIRECT_FIXED_LEN);
                            return;
                        }
                        ND_TCHECK_LEN(bp, sizeof(nd_ipv6));
@@ -603,7 +595,7 @@ pgm_print(netdissect_options *ndo,
                        opts_len -= PGM_OPT_REDIRECT_FIXED_LEN + sizeof(nd_ipv6);
                        break;
                    default:
-                       goto trunc;
+                       goto invalid;
                        break;
                    }
 
@@ -760,7 +752,7 @@ pgm_print(netdissect_options *ndo,
                        opts_len -= PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof(nd_ipv6);
                        break;
                    default:
-                       goto trunc;
+                       goto invalid;
                        break;
                    }
 
@@ -803,7 +795,7 @@ pgm_print(netdissect_options *ndo,
                        opts_len -= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof(nd_ipv6);
                        break;
                    default:
-                       goto trunc;
+                       goto invalid;
                        break;
                    }
 
@@ -829,7 +821,6 @@ pgm_print(netdissect_options *ndo,
                                     GET_BE_U_2(pgm->pgm_length));
 
        return;
-
-trunc:
-       nd_print_trunc(ndo);
+invalid:
+       nd_print_invalid(ndo);
 }