Skip to content

Commit 4da3308

Browse files
committed
IPv6: Print the protocol name before any test
Use nd_print_protocol_caps(). IP6_VERSION() uses GET_U_1(), so there's no need for ND_TCHECK_*() beforehand.
1 parent b4b993c commit 4da3308

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

print-ip6.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,22 @@ ip6_print(netdissect_options *ndo, const u_char *bp, u_int length)
241241
ndo->ndo_protocol = "ip6";
242242
ip6 = (const struct ip6_hdr *)bp;
243243

244+
if (!ndo->ndo_eflag) {
245+
nd_print_protocol_caps(ndo);
246+
ND_PRINT(" ");
247+
}
248+
249+
if (IP6_VERSION(ip6) != 6) {
250+
ND_PRINT("version error: %u != 6", IP6_VERSION(ip6));
251+
return;
252+
}
253+
244254
ND_TCHECK_SIZE(ip6);
245255
if (length < sizeof (struct ip6_hdr)) {
246256
ND_PRINT("truncated-ip6 %u", length);
247257
return;
248258
}
249259

250-
if (!ndo->ndo_eflag)
251-
ND_PRINT("IP6 ");
252-
253-
if (IP6_VERSION(ip6) != 6) {
254-
ND_PRINT("version error: %u != 6", IP6_VERSION(ip6));
255-
return;
256-
}
257-
258260
payload_len = GET_BE_U_2(ip6->ip6_plen);
259261
/*
260262
* RFC 1883 says:

0 commit comments

Comments
 (0)