/**
* Object oriented C module to send ICMP and ICMPv6 `echo's.
- * Copyright (C) 2006-2011 Florian octo Forster <ff at octo.it>
+ * Copyright (C) 2006-2016 Florian octo Forster <ff at octo.it>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
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);