/* specification: RFC 1058, RFC 2453, RFC 4822 */
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include "netdissect-stdinc.h"
const struct rip_netinfo_v1 *ni = (const struct rip_netinfo_v1 *)p;
/* RFC 1058 */
- if (remaining < RIP_ROUTELEN)
- goto invalid;
+ 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);
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));
u_short family;
const struct rip_netinfo_v2 *ni;
- if (remaining < sizeof(*eh))
- goto invalid;
+ 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 */
const struct rip_auth_crypto_v2 *ch;
ch = (const struct rip_auth_crypto_v2 *)p;
- if (remaining < sizeof(*ch))
- goto invalid;
+ 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));
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;
- if (remaining < sizeof(*ni))
- goto invalid;
+ 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),
unsigned entry_size;
ndo->ndo_protocol = "rip";
- if (len < sizeof(*rp)) {
- ND_PRINT(" (packet length %u)", len);
- goto invalid;
- }
+ 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);
/* Error */
goto invalid;
}
- if (len < entry_size) {
- ND_PRINT(" [remaining entries length %u < %u]",
- len, entry_size);
- goto invalid;
- }
+ ND_ICHECKMSG_U("remaining entries length",
+ len, <, entry_size);
p += entry_size;
len -= entry_size;
}
/* Error */
goto invalid;
}
- if (len < entry_size) {
- ND_PRINT(" [remaining entries length %u < %u]",
- len, entry_size);
- goto invalid;
- }
+ ND_ICHECKMSG_U("remaining entries length",
+ len, <, entry_size);
p += entry_size;
len -= entry_size;
}
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;
}