Add a function to check if a packet is ours
This allows the ping socket codepaths to be simpler.
Bug: 9469682
Change-Id: I05174cafd74ad5de5e867af8a3a3ac19439034b4
diff --git a/ping6.c b/ping6.c
index c39864d..019d9e4 100644
--- a/ping6.c
+++ b/ping6.c
@@ -1305,7 +1305,7 @@
if (res < sizeof(icmph) ||
memcmp(&target.sin6_addr, &whereto.sin6_addr, 16) ||
icmph.icmp6_type != ICMP6_ECHO_REQUEST ||
- icmph.icmp6_id != ident) {
+ !is_ours(icmph.icmp6_id)) {
/* Not our error, not an error at all. Clear. */
saved_errno = 0;
goto out;
@@ -1602,7 +1602,7 @@
}
if (icmph->icmp6_type == ICMP6_ECHO_REPLY) {
- if (icmph->icmp6_id != ident)
+ if (!is_ours(icmph->icmp6_id))
return 1;
if (gather_statistics((__u8*)icmph, sizeof(*icmph), cc,
ntohs(icmph->icmp6_seq),
@@ -1645,7 +1645,7 @@
}
if (nexthdr == IPPROTO_ICMPV6) {
if (icmph1->icmp6_type != ICMP6_ECHO_REQUEST ||
- icmph1->icmp6_id != ident)
+ !is_ours(icmph1->icmp6_id))
return 1;
acknowledge(ntohs(icmph1->icmp6_seq));
if (working_recverr)