/* \summary: IPv6 Open Shortest Path First (OSPFv3) printer */
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
#include <string.h>
{
if ((const u_char *)(lshp + 1) > dataend)
goto trunc;
- ND_TCHECK(lshp->ls_type);
- ND_TCHECK(lshp->ls_seq);
+ ND_TCHECK_2(lshp->ls_type);
+ ND_TCHECK_4(lshp->ls_seq);
ND_PRINT("\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
ipaddr_string(ndo, &lshp->ls_router),
if (ospf6_print_lshdr(ndo, &lsap->ls_hdr, dataend))
return (1);
- ND_TCHECK(lsap->ls_hdr.ls_length);
+ ND_TCHECK_2(lsap->ls_hdr.ls_length);
length = EXTRACT_BE_U_2(lsap->ls_hdr.ls_length);
/*
if (lsa_length < sizeof (lsap->lsa_un.un_rla.rla_options))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_rla.rla_options);
- ND_TCHECK(lsap->lsa_un.un_rla.rla_options);
+ ND_TCHECK_4(lsap->lsa_un.un_rla.rla_options);
ND_PRINT("\n\t Options [%s]",
bittok2str(ospf6_option_values, "none",
EXTRACT_BE_U_4(lsap->lsa_un.un_rla.rla_options)));
if (lsa_length < sizeof (lsap->lsa_un.un_nla.nla_options))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_nla.nla_options);
- ND_TCHECK(lsap->lsa_un.un_nla.nla_options);
+ ND_TCHECK_4(lsap->lsa_un.un_nla.nla_options);
ND_PRINT("\n\t Options [%s]",
bittok2str(ospf6_option_values, "none",
EXTRACT_BE_U_4(lsap->lsa_un.un_nla.nla_options)));
if (lsa_length < sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_inter_ap.inter_ap_metric);
- ND_TCHECK(lsap->lsa_un.un_inter_ap.inter_ap_metric);
+ ND_TCHECK_4(lsap->lsa_un.un_inter_ap.inter_ap_metric);
ND_PRINT(", metric %u",
EXTRACT_BE_U_4(lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC);
if (lsa_length < sizeof (lsap->lsa_un.un_asla.asla_metric))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_asla.asla_metric);
- ND_TCHECK(lsap->lsa_un.un_asla.asla_metric);
+ ND_TCHECK_4(lsap->lsa_un.un_asla.asla_metric);
flags32 = EXTRACT_BE_U_4(lsap->lsa_un.un_asla.asla_metric);
ND_PRINT("\n\t Flags [%s]",
bittok2str(ospf6_asla_flag_values, "none", flags32));
if (lsa_length < sizeof (uint32_t))
return (1);
lsa_length -= sizeof (uint32_t);
- ND_TCHECK(*(const uint32_t *)tptr);
+ ND_TCHECK_4(tptr);
ND_PRINT(" tag %s",
ipaddr_string(ndo, (const uint32_t *)tptr));
tptr += sizeof(uint32_t);
if (lsa_length < sizeof (uint32_t))
return (1);
lsa_length -= sizeof (uint32_t);
- ND_TCHECK(*(const uint32_t *)tptr);
+ ND_TCHECK_4(tptr);
ND_PRINT(" RefLSID: %s",
ipaddr_string(ndo, (const uint32_t *)tptr));
tptr += sizeof(uint32_t);
if (lsa_length < sizeof (llsap->llsa_priandopt))
return (1);
lsa_length -= sizeof (llsap->llsa_priandopt);
- ND_TCHECK(llsap->llsa_priandopt);
+ ND_TCHECK_SIZE(&llsap->llsa_priandopt);
ND_PRINT("\n\t Options [%s]",
bittok2str(ospf6_option_values, "none",
EXTRACT_BE_U_4(llsap->llsa_options)));
if (lsa_length < sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix))
return (1);
lsa_length -= sizeof (llsap->llsa_lladdr) + sizeof (llsap->llsa_nprefix);
- ND_TCHECK(llsap->llsa_nprefix);
+ ND_TCHECK_4(llsap->llsa_nprefix);
prefixes = EXTRACT_BE_U_4(llsap->llsa_nprefix);
ND_PRINT("\n\t Priority %u, Link-local address %s, Prefixes %u:",
EXTRACT_U_1(llsap->llsa_priority),
if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_rtid);
- ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
+ ND_TCHECK_4(lsap->lsa_un.un_intra_ap.intra_ap_rtid);
ospf6_print_ls_type(ndo,
EXTRACT_BE_U_2(lsap->lsa_un.un_intra_ap.intra_ap_lstype),
&lsap->lsa_un.un_intra_ap.intra_ap_lsid);
if (lsa_length < sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix))
return (1);
lsa_length -= sizeof (lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
- ND_TCHECK(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
+ ND_TCHECK_2(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
prefixes = EXTRACT_BE_U_2(lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
ND_PRINT("\n\t Prefixes %u:", prefixes);
bittok2str(ospf6_option_values, "none",
EXTRACT_BE_U_4(hellop->hello_options)));
- ND_TCHECK(hellop->hello_deadint);
+ ND_TCHECK_2(hellop->hello_deadint);
ND_PRINT("\n\t Hello Timer %us, Dead Timer %us, Interface-ID %s, Priority %u",
EXTRACT_BE_U_2(hellop->hello_helloint),
EXTRACT_BE_U_2(hellop->hello_deadint),
ipaddr_string(ndo, &hellop->hello_ifid),
EXTRACT_U_1(hellop->hello_priority));
- ND_TCHECK(hellop->hello_dr);
+ ND_TCHECK_4(hellop->hello_dr);
if (EXTRACT_BE_U_4(hellop->hello_dr) != 0)
ND_PRINT("\n\t Designated Router %s",
ipaddr_string(ndo, &hellop->hello_dr));
- ND_TCHECK(hellop->hello_bdr);
+ ND_TCHECK_4(hellop->hello_bdr);
if (EXTRACT_BE_U_4(hellop->hello_bdr) != 0)
ND_PRINT(", Backup Designated Router %s",
ipaddr_string(ndo, &hellop->hello_bdr));
case OSPF_TYPE_DD: {
const struct dd6 *ddp = (const struct dd6 *)((const uint8_t *)op + OSPF6HDR_LEN);
- ND_TCHECK(ddp->db_options);
+ ND_TCHECK_4(ddp->db_options);
ND_PRINT("\n\tOptions [%s]",
bittok2str(ospf6_option_values, "none",
EXTRACT_BE_U_4(ddp->db_options)));
- ND_TCHECK(ddp->db_flags);
+ ND_TCHECK_1(ddp->db_flags);
ND_PRINT(", DD Flags [%s]",
bittok2str(ospf6_dd_flag_values,"none",EXTRACT_U_1(ddp->db_flags)));
- ND_TCHECK(ddp->db_seq);
+ ND_TCHECK_4(ddp->db_seq);
ND_PRINT(", MTU %u, DD-Sequence 0x%08x",
EXTRACT_BE_U_2(ddp->db_mtu),
EXTRACT_BE_U_4(ddp->db_seq));
if (ndo->ndo_vflag > 1) {
const struct lsu6 *lsup = (const struct lsu6 *)((const uint8_t *)op + OSPF6HDR_LEN);
- ND_TCHECK(lsup->lsu_count);
+ ND_TCHECK_4(lsup->lsu_count);
i = EXTRACT_BE_U_4(lsup->lsu_count);
lsap = lsup->lsu_lsa;
while ((const u_char *)lsap < dataend && i--) {
type = EXTRACT_U_1(op->ospf6_type);
if (type == OSPF_TYPE_HELLO) {
const struct hello6 *hellop = (const struct hello6 *)((const uint8_t *)op + OSPF6HDR_LEN);
- ND_TCHECK(hellop->hello_options);
+ ND_TCHECK_4(hellop->hello_options);
if (EXTRACT_BE_U_4(hellop->hello_options) & OSPF6_OPTION_L)
lls_hello = 1;
} else if (type == OSPF_TYPE_DD) {
const struct dd6 *ddp = (const struct dd6 *)((const uint8_t *)op + OSPF6HDR_LEN);
- ND_TCHECK(ddp->db_options);
+ ND_TCHECK_4(ddp->db_options);
if (EXTRACT_BE_U_4(ddp->db_options) & OSPF6_OPTION_L)
lls_dd = 1;
}
/* If the type is valid translate it, or just print the type */
/* value. If it's not valid, say so and return */
- ND_TCHECK(op->ospf6_type);
+ ND_TCHECK_1(op->ospf6_type);
cp = tok2str(ospf6_type_values, "unknown packet type (%u)", EXTRACT_U_1(op->ospf6_type));
ND_PRINT("OSPFv%u, %s, length %u", EXTRACT_U_1(op->ospf6_version), cp, length);
if (*cp == 'u') {
}
/* OSPFv3 data always comes first and optional trailing data may follow. */
- ND_TCHECK(op->ospf6_len);
+ ND_TCHECK_2(op->ospf6_len);
datalen = EXTRACT_BE_U_2(op->ospf6_len);
if (datalen > length) {
ND_PRINT(" [len %u]", datalen);
}
dataend = bp + datalen;
- ND_TCHECK(op->ospf6_routerid);
+ ND_TCHECK_4(op->ospf6_routerid);
ND_PRINT("\n\tRouter-ID %s", ipaddr_string(ndo, &op->ospf6_routerid));
- ND_TCHECK(op->ospf6_areaid);
+ ND_TCHECK_4(op->ospf6_areaid);
if (EXTRACT_BE_U_4(op->ospf6_areaid) != 0)
ND_PRINT(", Area %s", ipaddr_string(ndo, &op->ospf6_areaid));
else
ND_PRINT(", Backbone Area");
- ND_TCHECK(op->ospf6_instanceid);
+ ND_TCHECK_1(op->ospf6_instanceid);
if (EXTRACT_U_1(op->ospf6_instanceid))
ND_PRINT(", Instance %u", EXTRACT_U_1(op->ospf6_instanceid));