mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-04 06:23:04 +00:00
Disable ICMP unreachable
This commit is contained in:
parent
90d743c7e3
commit
3cb9b79bf9
1 changed files with 24 additions and 23 deletions
|
@ -264,31 +264,32 @@ void check_tcp_socket(const struct arguments *args,
|
||||||
write_rst(args, &s->tcp);
|
write_rst(args, &s->tcp);
|
||||||
|
|
||||||
// Connection refused
|
// Connection refused
|
||||||
if (err >= 0 && (serr == ECONNREFUSED || serr == EHOSTUNREACH)) {
|
if (0)
|
||||||
struct icmp icmp;
|
if (err >= 0 && (serr == ECONNREFUSED || serr == EHOSTUNREACH)) {
|
||||||
memset(&icmp, 0, sizeof(struct icmp));
|
struct icmp icmp;
|
||||||
icmp.icmp_type = ICMP_UNREACH;
|
memset(&icmp, 0, sizeof(struct icmp));
|
||||||
if (serr == ECONNREFUSED)
|
icmp.icmp_type = ICMP_UNREACH;
|
||||||
icmp.icmp_code = ICMP_UNREACH_PORT;
|
if (serr == ECONNREFUSED)
|
||||||
else
|
icmp.icmp_code = ICMP_UNREACH_PORT;
|
||||||
icmp.icmp_code = ICMP_UNREACH_HOST;
|
else
|
||||||
icmp.icmp_cksum = 0;
|
icmp.icmp_code = ICMP_UNREACH_HOST;
|
||||||
icmp.icmp_cksum = ~calc_checksum(0, &icmp, 4);
|
icmp.icmp_cksum = 0;
|
||||||
|
icmp.icmp_cksum = ~calc_checksum(0, &icmp, 4);
|
||||||
|
|
||||||
struct icmp_session sicmp;
|
struct icmp_session sicmp;
|
||||||
memset(&sicmp, 0, sizeof(struct icmp_session));
|
memset(&sicmp, 0, sizeof(struct icmp_session));
|
||||||
sicmp.version = s->tcp.version;
|
sicmp.version = s->tcp.version;
|
||||||
if (s->tcp.version == 4) {
|
if (s->tcp.version == 4) {
|
||||||
sicmp.saddr.ip4 = (__be32) s->tcp.saddr.ip4;
|
sicmp.saddr.ip4 = (__be32) s->tcp.saddr.ip4;
|
||||||
sicmp.daddr.ip4 = (__be32) s->tcp.daddr.ip4;
|
sicmp.daddr.ip4 = (__be32) s->tcp.daddr.ip4;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
memcpy(&sicmp.saddr.ip6, &s->tcp.saddr.ip6, 16);
|
memcpy(&sicmp.saddr.ip6, &s->tcp.saddr.ip6, 16);
|
||||||
memcpy(&sicmp.daddr.ip6, &s->tcp.daddr.ip6, 16);
|
memcpy(&sicmp.daddr.ip6, &s->tcp.daddr.ip6, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_icmp(args, &sicmp, &icmp, 8);
|
write_icmp(args, &sicmp, &icmp, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Assume socket okay
|
// Assume socket okay
|
||||||
|
|
Loading…
Reference in a new issue