diff options
-rw-r--r-- | src/pinger.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/pinger.c b/src/pinger.c index 80d4dc0..4ab54f3 100644 --- a/src/pinger.c +++ b/src/pinger.c @@ -1085,10 +1085,11 @@ icmp_generic_decode(unsigned char * buffer, size_t bufsize, cksum = icmp->icmp_cksum; icmp->icmp_cksum = 0; icmp->icmp_cksum = icmp_cksum((unsigned char *) icmp, bufsize - hlen); - if (icmp->icmp_cksum != cksum) - return 1; icmp->icmp_seq = ntohs(icmp->icmp_seq); icmp->icmp_id = ntohs(icmp->icmp_id); + + if (icmp->icmp_cksum != cksum) + return 1; return 0; } @@ -1123,21 +1124,21 @@ send_echo(HOSTPING *host, unsigned char *ping_buffer) seqno); icmp_generic_encode(ping_buffer, buflen, ICMP_ECHO, ping_ident, seqno); + hostping_lock(host); n = sendto(ping_fd, (char *) ping_buffer, buflen, 0, host->addr, host->addrlen); if (n < 0) { error("%s: sendto: %s", host->name, strerror(errno)); } else { - hostping_lock(host); if (host->xmit_count == 0) host->start_tv = host->xmit_tv; host->xmit_count++; - hostping_unlock(host); xmit_total++; if (n != buflen) error("ping: wrote %s %zu chars, ret=%ld\n", host->name, buflen, n); } + hostping_unlock(host); } static void hostping_commit(HOSTPING *host); |