mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-01 12:54:07 +00:00
Log ICMP addresses
This commit is contained in:
parent
36b41a298f
commit
bd4e1ff0c0
1 changed files with 12 additions and 12 deletions
|
@ -157,9 +157,19 @@ jboolean handle_icmp(const struct arguments *args,
|
|||
struct icmp *icmp = (struct icmp *) payload;
|
||||
size_t icmplen = length - (payload - pkt);
|
||||
|
||||
char source[INET6_ADDRSTRLEN + 1];
|
||||
char dest[INET6_ADDRSTRLEN + 1];
|
||||
if (version == 4) {
|
||||
inet_ntop(AF_INET, &ip4->saddr, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &ip4->daddr, dest, sizeof(dest));
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &ip6->ip6_src, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &ip6->ip6_dst, dest, sizeof(dest));
|
||||
}
|
||||
|
||||
if (icmp->icmp_type != ICMP_ECHO) {
|
||||
log_android(ANDROID_LOG_WARN, "ICMP type %d code %d not supported",
|
||||
icmp->icmp_type, icmp->icmp_code);
|
||||
log_android(ANDROID_LOG_WARN, "ICMP type %d code %d from %s to %s not supported",
|
||||
icmp->icmp_type, icmp->icmp_code, source, dest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -174,16 +184,6 @@ jboolean handle_icmp(const struct arguments *args,
|
|||
memcmp(&cur->icmp.daddr.ip6, &ip6->ip6_dst, 16) == 0)))
|
||||
cur = cur->next;
|
||||
|
||||
char source[INET6_ADDRSTRLEN + 1];
|
||||
char dest[INET6_ADDRSTRLEN + 1];
|
||||
if (version == 4) {
|
||||
inet_ntop(AF_INET, &ip4->saddr, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &ip4->daddr, dest, sizeof(dest));
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &ip6->ip6_src, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &ip6->ip6_dst, dest, sizeof(dest));
|
||||
}
|
||||
|
||||
// Create new session if needed
|
||||
if (cur == NULL) {
|
||||
log_android(ANDROID_LOG_INFO, "ICMP new session from %s to %s", source, dest);
|
||||
|
|
Loading…
Reference in a new issue