const struct in_addr *other)
{
struct ip_header ip_pkt;
- struct icmp_ttl_exceeded_header icmp_pkt;
+ struct icmp_ttl_exceeded_header icmp_ttl;
struct icmp_echo_header icmp_echo;
struct sockaddr_in dst;
char packet[sizeof (struct ip_header) * 2 +
off = sizeof (ip_pkt);
/* icmp reply: time exceeded */
- icmp_pkt.type = ICMP_TIME_EXCEEDED;
- icmp_pkt.code = 0;
- icmp_pkt.checksum = 0;
- icmp_pkt.unused = 0;
+ icmp_ttl.type = ICMP_TIME_EXCEEDED;
+ icmp_ttl.code = 0;
+ icmp_ttl.checksum = 0;
+ icmp_ttl.unused = 0;
memcpy (&packet[off],
- &icmp_pkt,
+ &icmp_ttl,
sizeof (struct icmp_ttl_exceeded_header));
off += sizeof (struct icmp_ttl_exceeded_header);
/* no go back to calculate ICMP packet checksum */
off = sizeof (struct ip_header);
- icmp_pkt.checksum = htons(calc_checksum((uint16_t*) &packet[off],
+ icmp_ttl.checksum = htons(calc_checksum((uint16_t*) &packet[off],
sizeof (struct icmp_ttl_exceeded_header) +
sizeof(struct ip_header) +
sizeof(struct icmp_echo_header)));
memcpy (&packet[off],
- &icmp_pkt,
+ &icmp_ttl,
sizeof (struct icmp_ttl_exceeded_header));
/* prepare for transmission */
ssize_t have;
struct in_addr source_ip;
struct ip_header ip_pkt;
- struct icmp_ttl_exceeded_header icmp_pkt;
- struct icmp_echo_header icmp_echo_pkt;
+ struct icmp_ttl_exceeded_header icmp_ttl;
+ struct icmp_echo_header icmp_echo;
struct udp_header udp_pkt;
size_t off;
uint32_t port;
"Received message of %u bytes\n",
(unsigned int) have);
#endif
- if (have < sizeof (struct ip_header) + sizeof (struct icmp_ttl_exceeded_header) + sizeof (struct ip_header) )
+ if (have < (ssize_t) (sizeof (struct ip_header) + sizeof (struct icmp_ttl_exceeded_header) + sizeof (struct ip_header)))
{
/* malformed */
return;
memcpy(&source_ip,
&ip_pkt.src_ip,
sizeof (source_ip));
- memcpy (&icmp_pkt,
+ memcpy (&icmp_ttl,
&buf[off],
sizeof (struct icmp_ttl_exceeded_header));
off += sizeof (struct icmp_ttl_exceeded_header);
- if ( (ICMP_TIME_EXCEEDED != icmp_pkt.type) ||
- (0 != icmp_pkt.code) )
+ if ( (ICMP_TIME_EXCEEDED != icmp_ttl.type) ||
+ (0 != icmp_ttl.code) )
{
/* different type than what we want */
return;
return;
}
/* grab ICMP ECHO content */
- memcpy (&icmp_echo_pkt,
+ memcpy (&icmp_echo,
&buf[off],
sizeof (struct icmp_echo_header));
- port = (uint16_t) ntohl (icmp_echo_pkt.reserved);
+ port = (uint16_t) ntohl (icmp_echo.reserved);
break;
case IPPROTO_UDP:
if (have != (sizeof (struct ip_header) * 2 +