hncp_print(netdissect_options *ndo,
const u_char *cp, u_int length)
{
+ ndo->ndo_protocol = "hncp";
ND_PRINT("hncp (%u)", length);
hncp_print_rec(ndo, cp, length, 1);
}
/*
* Is an IPv6 address an IPv4-mapped address?
*/
-static inline int
+static int
is_ipv4_mapped_address(const u_char *addr)
{
/* The value of the prefix */
static char buf[4][sizeof("01:01:01:01")];
static int i = 0;
i = (i + 1) % 4;
- snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x",
+ nd_snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x",
EXTRACT_U_1(data), EXTRACT_U_1(data + 1), EXTRACT_U_1(data + 2),
EXTRACT_U_1(data + 3));
return buf[i];
static char buf[4][sizeof("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")];
static int i = 0;
i = (i + 1) % 4;
- snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
+ nd_snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
EXTRACT_BE_U_8(data),
EXTRACT_BE_U_8(data + 8),
EXTRACT_BE_U_8(data + 16),
static char buf[4][sizeof("0000000.000s")];
static int i = 0;
i = (i + 1) % 4;
- snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000);
+ nd_snprintf(buf[i], sizeof(buf[i]), "%u.%03us", n / 1000, n % 1000);
return buf[i];
}
((u_char *)&addr)[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
- snprintf(buf, sizeof(buf), "%s/%u", ipaddr_string(ndo, &addr), plen);
+ nd_snprintf(buf, sizeof(buf), "%s/%u", ipaddr_string(ndo, (const u_char *)&addr), plen);
plenbytes += 1 + IPV4_MAPPED_HEADING_LEN;
} else {
plenbytes = decode_prefix6(ndo, prefix, max_length, buf, sizeof(buf));
if (lab_length == 0)
return (int)length;
if (length > 1 && print)
- safeputchar(ndo, '.');
+ ND_PRINT(".");
if (length+lab_length > max_length) {
if (print)
- safeputs(ndo, cp+length, max_length-length);
+ (void)nd_printzp(ndo, cp+length, max_length-length, NULL);
break;
}
if (print)
- safeputs(ndo, cp+length, lab_length);
+ (void)nd_printzp(ndo, cp+length, lab_length, NULL);
length += lab_length;
}
if (print)
case DH6OPT_DNS_SERVERS:
case DH6OPT_SNTP_SERVERS: {
if (optlen % 16 != 0) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
return -1;
}
for (t = 0; t < optlen; t += 16)
case DNCP_REQUEST_NETWORK_STATE: {
if (bodylen != 0)
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
}
break;
case DNCP_REQUEST_NODE_STATE: {
const char *node_identifier;
if (bodylen != 4) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
node_identifier = format_nid(value);
const char *node_identifier;
uint32_t endpoint_identifier;
if (bodylen != 8) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
node_identifier = format_nid(value);
case DNCP_NETWORK_STATE: {
uint64_t hash;
if (bodylen != 8) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
hash = EXTRACT_BE_U_8(value);
uint32_t sequence_number;
uint64_t hash;
if (bodylen < 20) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
node_identifier = format_nid(value);
const char *peer_node_identifier;
uint32_t peer_endpoint_identifier, endpoint_identifier;
if (bodylen != 12) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
peer_node_identifier = format_nid(value);
uint32_t endpoint_identifier;
const char *interval;
if (bodylen < 8) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
endpoint_identifier = EXTRACT_BE_U_4(value);
case DNCP_TRUST_VERDICT: {
if (bodylen <= 36) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
ND_PRINT(" Verdict: %u Fingerprint: %s Common Name: ",
EXTRACT_U_1(value),
format_256(value + 4));
- safeputs(ndo, value + 36, bodylen - 36);
+ (void)nd_printzp(ndo, value + 36, bodylen - 36, NULL);
}
break;
uint16_t capabilities;
uint8_t M, P, H, L;
if (bodylen < 5) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
capabilities = EXTRACT_BE_U_2(value + 2);
ND_PRINT(" M: %u P: %u H: %u L: %u User-agent: ",
M, P, H, L
);
- safeputs(ndo, value + 4, bodylen - 4);
+ (void)nd_printzp(ndo, value + 4, bodylen - 4, NULL);
}
break;
case HNCP_DELEGATED_PREFIX: {
int l;
if (bodylen < 9 || bodylen < 9 + (EXTRACT_U_1(value + 8) + 7) / 8) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
ND_PRINT(" VLSO: %s PLSO: %s Prefix: ",
* IPv6", or -3, meaning "the prefix runs past
* the end of the TLV".
*/
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
l += 8 + (-l & 3);
uint8_t policy;
int l;
if (bodylen < 1) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
policy = EXTRACT_U_1(value);
ND_PRINT(" type: ");
if (policy == 0) {
if (bodylen != 1) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
ND_PRINT("Internet connectivity");
* IPv6", or -3, meaning "the prefix runs past
* the end of the TLV".
*/
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
} else if (policy == 129) {
print_dns_label(ndo, value+1, bodylen-1, 1);
} else if (policy == 130) {
ND_PRINT("Opaque UTF-8: ");
- safeputs(ndo, value + 1, bodylen - 1);
+ (void)nd_printzp(ndo, value + 1, bodylen - 1, NULL);
} else if (policy == 131) {
if (bodylen != 1) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
ND_PRINT("Restrictive assignment");
case HNCP_DHCPV4_DATA: {
if (bodylen == 0) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
if (dhcpv4_print(ndo, value, bodylen, indent+1) != 0)
case HNCP_DHCPV6_DATA: {
if (bodylen == 0) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
if (dhcpv6_print(ndo, value, bodylen, indent+1) != 0) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
}
uint8_t prty;
int l;
if (bodylen < 6 || bodylen < 6 + (EXTRACT_U_1(value + 5) + 7) / 8) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
prty = EXTRACT_U_1(value + 4) & 0xf;
);
ND_PRINT(" Prefix: ");
if ((l = print_prefix(ndo, value + 5, bodylen - 5)) < 0) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
l += 5;
uint32_t endpoint_identifier;
const char *ip_address;
if (bodylen < 20) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
endpoint_identifier = EXTRACT_BE_U_4(value);
const char *ip_address;
int len;
if (bodylen < 17) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
ip_address = format_ip6addr(ndo, value);
);
len = print_dns_label(ndo, value+17, bodylen-17, 1);
if (len < 0) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
len += 17;
case HNCP_DOMAIN_NAME: {
if (bodylen == 0) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
ND_PRINT(" Domain: ");
case HNCP_NODE_NAME: {
u_int l;
if (bodylen < 17) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
l = EXTRACT_U_1(value + 16);
if (bodylen < 17 + l) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
ND_PRINT(" IP-Address: %s Name: ",
format_ip6addr(ndo, value)
);
if (l < 64) {
- safeputchar(ndo, '"');
- safeputs(ndo, value + 17, l);
- safeputchar(ndo, '"');
+ ND_PRINT("\"");
+ (void)nd_printzp(ndo, value + 17, l, NULL);
+ ND_PRINT("\"");
} else {
- ND_PRINT("%s", istr);
+ nd_print_invalid(ndo);
}
l += 17;
l += -l & 3;
case HNCP_MANAGED_PSK: {
if (bodylen < 32) {
- ND_PRINT(" %s", istr);
+ nd_print_invalid(ndo);
break;
}
ND_PRINT(" PSK: %s", format_256(value));
return;
trunc:
- ND_PRINT("%s", "[|hncp]");
+ nd_print_trunc(ndo);
return;
invalid:
- ND_PRINT("%s", istr);
+ nd_print_invalid(ndo);
return;
}