summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6e83f8b)
raw | patch | inline | side by side (parent: 6e83f8b)
author | Kyle Zhou <kyle.zhou@live.com> | |
Tue, 2 Aug 2016 12:33:03 +0000 (22:33 +1000) | ||
committer | Kyle Zhou <kyle.zhou@live.com> | |
Tue, 2 Aug 2016 12:33:03 +0000 (22:33 +1000) |
src/liboping.c | patch | blob | history |
diff --git a/src/liboping.c b/src/liboping.c
index d99129ccc3c186d8ba7b8e6b5eec75ed2e0673bc..396f489f3d0b1d0d2f9ef382dbfc266f2ea0c189 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
buffer += ip_hdr_len;
buffer_len -= ip_hdr_len;
- if (buffer_len < sizeof (struct icmp))
+ if (buffer_len < sizeof (struct icmphdr))
return (NULL);
icmp_hdr = (struct icmp *) buffer;
- buffer += sizeof (struct icmp);
- buffer_len -= sizeof (struct icmp);
+ buffer += sizeof (struct icmphdr);
+ buffer_len -= sizeof (struct icmphdr);
if (icmp_hdr->icmp_type != ICMP_ECHOREPLY)
{
recv_checksum = icmp_hdr->icmp_cksum;
icmp_hdr->icmp_cksum = 0;
calc_checksum = ping_icmp4_checksum ((char *) icmp_hdr,
- sizeof (struct icmp) + buffer_len);
+ sizeof (struct icmphdr) + buffer_len);
if (recv_checksum != calc_checksum)
{
memset (buf, '\0', sizeof (buf));
icmp4 = (struct icmp *) buf;
- data = (char *) (icmp4 + 1);
+ data = buf + sizeof (struct icmphdr);
icmp4->icmp_type = ICMP_ECHO;
icmp4->icmp_code = 0;
icmp4->icmp_id = htons (ph->ident);
icmp4->icmp_seq = htons (ph->sequence);
- buflen = 4096 - sizeof (struct icmp);
+ buflen = sizeof(buf) - sizeof (struct icmphdr);
strncpy (data, ph->data, buflen);
datalen = strlen (data);
- buflen = datalen + sizeof (struct icmp);
+ buflen = datalen + sizeof (struct icmphdr);
icmp4->icmp_cksum = ping_icmp4_checksum (buf, buflen);