]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-rip.c
gre: add support for MikroTik Ethernet-over-IP hack.
[tcpdump] / print-rip.c
index 8aea1f8aaba44f88fccf9785df9e9d871e6f3f12..57e7e481121e051af0ac09b38aa228d4a8d9b1da 100644 (file)
@@ -195,10 +195,10 @@ rip_entry_print_v1(netdissect_options *ndo, const u_char *p,
        const struct rip_netinfo_v1 *ni = (const struct rip_netinfo_v1 *)p;
 
        /* RFC 1058 */
-       ND_LCHECKMSG_U(remaining, RIP_ROUTELEN, "remaining data length");
+       ND_ICHECKMSG_U("remaining data length", remaining, <, RIP_ROUTELEN);
        ND_TCHECK_SIZE(ni);
        family = GET_BE_U_2(ni->rip_family);
-       if (family != BSD_AFNUM_INET && family != 0) {
+       if (family != BSD_AF_INET && family != 0) {
                ND_PRINT("\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family));
                print_unknown_data(ndo, p + sizeof(*eh), "\n\t  ", RIP_ROUTELEN - sizeof(*eh));
                return (RIP_ROUTELEN);
@@ -215,7 +215,7 @@ rip_entry_print_v1(netdissect_options *ndo, const u_char *p,
                         GET_IPADDR_STRING(ni->rip_dest),
                         GET_BE_U_4(ni->rip_metric));
                return (RIP_ROUTELEN);
-       } /* BSD_AFNUM_INET */
+       } /* BSD_AF_INET */
        ND_PRINT("\n\t  %s, metric: %u",
                 GET_IPADDR_STRING(ni->rip_dest),
                 GET_BE_U_4(ni->rip_metric));
@@ -232,7 +232,7 @@ rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
        u_short family;
        const struct rip_netinfo_v2 *ni;
 
-       ND_LCHECKMSG_ZU(remaining, sizeof(*eh), "remaining data length");
+       ND_ICHECKMSG_ZU("remaining data length", remaining, <, sizeof(*eh));
        ND_TCHECK_SIZE(eh);
        family = GET_BE_U_2(eh->rip_family);
        if (family == 0xFFFF) { /* variable-sized authentication structures */
@@ -247,7 +247,8 @@ rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
                        const struct rip_auth_crypto_v2 *ch;
 
                        ch = (const struct rip_auth_crypto_v2 *)p;
-                       ND_LCHECKMSG_ZU(remaining, sizeof(*ch), "remaining data length");
+                       ND_ICHECKMSG_ZU("remaining data length", remaining,
+                                       <, sizeof(*ch));
                        ND_PRINT("\n\t  Auth header:");
                        ND_PRINT(" Packet Len %u,",
                                 GET_BE_U_2(ch->rip_packet_len));
@@ -267,12 +268,13 @@ rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
                        print_unknown_data(ndo, p, "\n\t  ", remaining);
                        return (sizeof(*eh) + remaining); /* we don't know how long this is, so we go to the packet end */
                }
-       } else if (family != BSD_AFNUM_INET && family != 0) {
+       } else if (family != BSD_AF_INET && family != 0) {
                ND_PRINT("\n\t  AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family));
                print_unknown_data(ndo, p + sizeof(*eh), "\n\t  ", RIP_ROUTELEN - sizeof(*eh));
-       } else { /* BSD_AFNUM_INET or AFI 0 */
+       } else { /* BSD_AF_INET or AFI 0 */
                ni = (const struct rip_netinfo_v2 *)p;
-               ND_LCHECKMSG_ZU(remaining, sizeof(*ni), "remaining data length");
+               ND_ICHECKMSG_ZU("remaining data length", remaining, <,
+                               sizeof(*ni));
                ND_PRINT("\n\t  AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
                         tok2str(bsd_af_values, "%u", family),
                         GET_IPADDR_STRING(ni->rip_dest),
@@ -298,14 +300,18 @@ rip_print(netdissect_options *ndo,
        unsigned entry_size;
 
        ndo->ndo_protocol = "rip";
-       ND_LCHECKMSG_ZU(len, sizeof(*rp), "packet length");
+       ND_PRINT("%s", (ndo->ndo_vflag >= 1) ? "\n\t" : "");
+       nd_print_protocol_caps(ndo);
+       ND_ICHECKMSG_ZU("packet length", len, <, sizeof(*rp));
 
        rp = (const struct rip *)p;
 
        vers = GET_U_1(rp->rip_vers);
-       ND_PRINT("%sRIPv%u",
-                (ndo->ndo_vflag >= 1) ? "\n\t" : "",
-                vers);
+       ND_PRINT("v%u", vers);
+       if (vers != 1 && vers != 2) {
+               ND_PRINT(" [version != 1 && version != 2]");
+               goto invalid;
+       }
 
        /* dump version and lets see if we know the commands name*/
        cmd = GET_U_1(rp->rip_cmd);
@@ -333,7 +339,8 @@ rip_print(netdissect_options *ndo,
                                        /* Error */
                                        goto invalid;
                                }
-                               ND_LCHECKMSG_U(len, entry_size, "remaining entries length");
+                               ND_ICHECKMSG_U("remaining entries length",
+                                              len, <, entry_size);
                                p += entry_size;
                                len -= entry_size;
                        }
@@ -347,7 +354,8 @@ rip_print(netdissect_options *ndo,
                                        /* Error */
                                        goto invalid;
                                }
-                               ND_LCHECKMSG_U(len, entry_size, "remaining entries length");
+                               ND_ICHECKMSG_U("remaining entries length",
+                                              len, <, entry_size);
                                p += entry_size;
                                len -= entry_size;
                        }
@@ -377,7 +385,7 @@ rip_print(netdissect_options *ndo,
                break;
        }
        /* do we want to see an additionally hexdump ? */
-       if (ndo->ndo_vflag> 1) {
+       if (ndo->ndo_vflag > 1 && ND_TTEST_LEN(p, len)) {
                if (!print_unknown_data(ndo, p, "\n\t", len))
                        return;
        }