#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
-/* network endian */
-#define NI_SUPTYPE_FLAG_COMPRESS ((uint16_t)htons(0x1))
-#define NI_FQDN_FLAG_VALIDTTL ((uint16_t)htons(0x1))
-
-/* network endian */
-#define NI_NODEADDR_FLAG_TRUNCATE ((uint16_t)htons(0x1))
-#define NI_NODEADDR_FLAG_ALL ((uint16_t)htons(0x2))
-#define NI_NODEADDR_FLAG_COMPAT ((uint16_t)htons(0x4))
-#define NI_NODEADDR_FLAG_LINKLOCAL ((uint16_t)htons(0x8))
-#define NI_NODEADDR_FLAG_SITELOCAL ((uint16_t)htons(0x10))
-#define NI_NODEADDR_FLAG_GLOBAL ((uint16_t)htons(0x20))
-#define NI_NODEADDR_FLAG_ANYCAST ((uint16_t)htons(0x40)) /* just experimental. not in spec */
+#define NI_NODEADDR_FLAG_TRUNCATE 0x0001
+#define NI_NODEADDR_FLAG_ALL 0x0002
+#define NI_NODEADDR_FLAG_COMPAT 0x0004
+#define NI_NODEADDR_FLAG_LINKLOCAL 0x0008
+#define NI_NODEADDR_FLAG_SITELOCAL 0x0010
+#define NI_NODEADDR_FLAG_GLOBAL 0x0020
+#define NI_NODEADDR_FLAG_ANYCAST 0x0040 /* just experimental. not in spec */
struct ni_reply_fqdn {
nd_uint32_t ni_fqdn_ttl; /* TTL */
static void icmp6_nodeinfo_print(netdissect_options *ndo, u_int, const u_char *, const u_char *);
static void icmp6_rrenum_print(netdissect_options *ndo, const u_char *, const u_char *);
-#ifndef abs
-#define abs(a) ((0 < (a)) ? (a) : -(a))
-#endif
-
/*
* DIO: Updated to RFC6550, as published in 2012: section 6. (page 30)
*/
{ 0, NULL }
};
-
static const struct tok icmp6_opt_values[] = {
{ ND_OPT_SOURCE_LINKADDR, "source link-address"},
{ ND_OPT_TARGET_LINKADDR, "destination link-address"},
return;
trunc:
nd_print_trunc(ndo);
- return;
}
static void
const u_char *bp, u_int length)
{
const struct nd_rpl_dio *dio = (const struct nd_rpl_dio *)bp;
- const char *dagid_str;
-
- ND_TCHECK_SIZE(dio);
- dagid_str = ip6addr_string (ndo, dio->rpl_dagid);
+ ND_LCHECK_ZU(length, sizeof(struct nd_rpl_dio));
ND_PRINT(" [dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]",
- dagid_str,
+ GET_IP6ADDR_STRING(dio->rpl_dagid),
GET_U_1(dio->rpl_dtsn),
GET_U_1(dio->rpl_instanceid),
GET_BE_U_2(dio->rpl_dagrank),
RPL_DIO_GROUNDED(GET_U_1(dio->rpl_mopprf)) ? "grounded,":"",
- tok2str(rpl_mop_values, "mop%u", RPL_DIO_MOP(GET_U_1(dio->rpl_mopprf))),
+ tok2str(rpl_mop_values, "mop%u",
+ RPL_DIO_MOP(GET_U_1(dio->rpl_mopprf))),
RPL_DIO_PRF(GET_U_1(dio->rpl_mopprf)));
if(ndo->ndo_vflag > 1) {
rpl_printopts(ndo, bp + sizeof(struct nd_rpl_dio),
length - sizeof(struct nd_rpl_dio));
}
- return;
-trunc:
- nd_print_trunc(ndo);
- return;
+ return;
+invalid:
+ nd_print_invalid(ndo);
}
static void
tooshort:
ND_PRINT(" [|length too short]");
- return;
}
static void
tooshort:
ND_PRINT(" [|dao-length too short]");
- return;
}
static void
}
-
void
icmp6_print(netdissect_options *ndo,
const u_char *bp, u_int length, const u_char *bp2, int fragmented)
break;
case ICMP6_ECHO_REQUEST:
case ICMP6_ECHO_REPLY:
- /* The check below covers both icmp6_id and icmp6_seq. */
ND_PRINT(", id %u, seq %u", GET_BE_U_2(dp->icmp6_id),
GET_BE_U_2(dp->icmp6_seq));
break;
case 1:
break;
case 2:
- ND_TCHECK_8(opri + 1);
- memcpy(&in6, opri + 1, 8);
+ GET_CPY_BYTES(&in6, opri + 1, 8);
break;
case 3:
- ND_TCHECK_16(opri + 1);
- memcpy(&in6, opri + 1, 16);
+ GET_CPY_BYTES(&in6, opri + 1, 16);
break;
default:
goto trunc;
}
- ND_PRINT(" %s/%u", ip6addr_string(ndo, (const u_char *)&in6),
+ ND_PRINT(" %s/%u", ip6addr_string(ndo, (const u_char *)&in6), /* local buffer, not packet data; don't use GET_IP6ADDR_STRING() */
GET_U_1(opri->nd_opt_rti_prefixlen));
ND_PRINT(", pref=%s",
get_rtpref(GET_U_1(opri->nd_opt_rti_flags)));
ND_PRINT(" [invalid number of groups]");
return;
}
- ND_TCHECK_LEN(bp + 4 + group, sizeof(nd_ipv6));
ND_PRINT(" [gaddr %s", GET_IP6ADDR_STRING(bp + group + 4));
ND_PRINT(" %s", tok2str(mldv2report2str, " [v2-report-#%u]",
GET_U_1(bp + group)));
/* Print the sources */
ND_PRINT(" {");
for (j = 0; j < nsrcs; j++) {
- ND_TCHECK_LEN(bp + group + 20 + (j * sizeof(nd_ipv6)),
- sizeof(nd_ipv6));
ND_PRINT(" %s", GET_IP6ADDR_STRING(bp + group + 20 + (j * sizeof(nd_ipv6))));
}
ND_PRINT(" }");
ND_PRINT("]");
}
}
- return;
-trunc:
- nd_print_trunc(ndo);
- return;
}
static void
if (ndo->ndo_vflag) {
ND_PRINT(" [max resp delay=%u]", mrt);
}
- ND_TCHECK_LEN(bp + 8, sizeof(nd_ipv6));
ND_PRINT(" [gaddr %s", GET_IP6ADDR_STRING(bp + 8));
if (ndo->ndo_vflag) {
- ND_TCHECK_1(bp + 25);
if (GET_U_1(bp + 24) & 0x08) {
ND_PRINT(" sflag");
}
else if (ndo->ndo_vflag > 1) {
ND_PRINT(" {");
for (i = 0; i < nsrcs; i++) {
- ND_TCHECK_LEN(bp + 28 + (i * sizeof(nd_ipv6)),
- sizeof(nd_ipv6));
ND_PRINT(" %s", GET_IP6ADDR_STRING(bp + 28 + (i * sizeof(nd_ipv6))));
}
ND_PRINT(" }");
ND_PRINT(", %u source(s)", nsrcs);
}
ND_PRINT("]");
- return;
-trunc:
- nd_print_trunc(ndo);
- return;
}
static void
break;
}
-
/* XXX backward compat, icmp-name-lookup-03 */
if (siz == sizeof(*ni6)) {
ND_PRINT(", 03 draft");
ND_TCHECK_4(rr6->rr_reserved);
switch (GET_U_1(rr6->rr_code)) {
case ICMP6_ROUTER_RENUMBERING_COMMAND:
- ND_PRINT("router renum: command");
+ ND_PRINT(", command");
break;
case ICMP6_ROUTER_RENUMBERING_RESULT:
- ND_PRINT("router renum: result");
+ ND_PRINT(", result");
break;
case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET:
- ND_PRINT("router renum: sequence number reset");
+ ND_PRINT(", sequence number reset");
break;
default:
- ND_PRINT("router renum: code-#%u", GET_U_1(rr6->rr_code));
+ ND_PRINT(", code-#%u", GET_U_1(rr6->rr_code));
break;
}