From a0c2ac4c3f26339df4b37177b9746aa5168cc344 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Wed, 27 May 2015 11:06:07 +0200 Subject: [PATCH] ping: cleanup code --- src/icmp-ping.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/icmp-ping.c b/src/icmp-ping.c index f203ef2a..55a45fe1 100644 --- a/src/icmp-ping.c +++ b/src/icmp-ping.c @@ -179,14 +179,13 @@ int icmp_ping4(main_server_st * s, struct sockaddr_in *addr1) char packet1[DEFDATALEN + MAXIPLEN + MAXICMPLEN]; char buf1[64]; time_t now; - uint16_t id1, id2; + uint16_t id1; unsigned gotreply = 0, unreachable = 0; if (s->config->ping_leases == 0) return 0; gnutls_rnd(GNUTLS_RND_NONCE, &id1, sizeof(id1)); - gnutls_rnd(GNUTLS_RND_NONCE, &id2, sizeof(id2)); pingsock = socket(AF_INET, SOCK_RAW, 1); if (pingsock == -1) { @@ -231,7 +230,7 @@ int icmp_ping4(main_server_st * s, struct sockaddr_in *addr1) #else pkt = (struct icmp *) (packet1 + ((packet1[0] & 0x0f) << 2)); /* skip ip hdr */ #endif - if (pkt->icmp_id == id1 || pkt->icmp_id == id2) { + if (pkt->icmp_id == id1) { if (pkt->icmp_type == ICMP_ECHOREPLY) gotreply++; else if (pkt->icmp_type == ICMP_DEST_UNREACH) @@ -268,7 +267,7 @@ int icmp_ping6(main_server_st * s, int pingsock, c, e; int sockopt; char packet1[DEFDATALEN + MAXIPLEN + MAXICMPLEN]; - uint16_t id1, id2; + uint16_t id1; unsigned gotreply = 0, unreachable = 0; time_t now; @@ -276,7 +275,6 @@ int icmp_ping6(main_server_st * s, return 0; gnutls_rnd(GNUTLS_RND_NONCE, &id1, sizeof(id1)); - gnutls_rnd(GNUTLS_RND_NONCE, &id2, sizeof(id2)); pingsock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6); if (pingsock == -1) { @@ -320,7 +318,7 @@ int icmp_ping6(main_server_st * s, SA_IN_SIZE(sizeof(*addr1))) == 0) { pkt = (struct icmp6_hdr *) packet1; - if (pkt->icmp6_id == id1 || pkt->icmp6_id == id2) { + if (pkt->icmp6_id == id1) { if (pkt->icmp6_type == ICMP6_ECHO_REPLY) gotreply++; else if (pkt->icmp6_type == ICMP_DEST_UNREACH)