2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-30 13:57:50 +00:00

Fix alpha ptrsize botch. Try even harder to make sure ICMP Echo request packets are routed. Better error message.

This commit is contained in:
Ted Lemon 1997-05-09 08:05:28 +00:00
parent 7c695fad45
commit f2aad86a77

View File

@ -43,7 +43,7 @@
#ifndef lint
static char copyright[] =
"$Id: icmp.c,v 1.4 1997/03/29 10:37:18 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
"$Id: icmp.c,v 1.5 1997/05/09 08:05:28 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@ -63,6 +63,7 @@ void icmp_startup (routep, handler)
int protocol = 1;
struct sockaddr_in from;
int fd;
int state;
/* Only initialize icmp once. */
if (icmp_protocol_initialized)
@ -76,12 +77,14 @@ void icmp_startup (routep, handler)
/* Get a raw socket for the ICMP protocol. */
icmp_protocol_fd = socket (AF_INET, SOCK_RAW, protocol);
if (!icmp_protocol_fd)
if (icmp_protocol_fd < 0)
error ("unable to create icmp socket: %m");
if (setsockopt (icmp_protocol_fd, SOL_SOCKET, SO_DONTROUTE,
(char *)&routep, sizeof routep))
error ("Can't set SO_DONTROUTE on ICMP socket: %m");
/* Make sure it does routing... */
state = 0;
if (setsockopt (icmp_protocol_fd,
SOL_SOCKET, SO_DONTROUTE, &state, sizeof state) < 0)
error ("Unable to disable SO_DONTROUTE on ICMP socket: %m");
add_protocol ("icmp", icmp_protocol_fd, icmp_echoreply, handler);
}
@ -108,8 +111,8 @@ int icmp_echorequest (addr)
icmp.icmp_cksum = 0;
icmp.icmp_seq = 0;
#ifdef PTRSIZE_64BIT
icmp.icmp_id = (((u_int32_t)addr) ^
(u_int32_t)(((u_int64_t)addr) >> 32));
icmp.icmp_id = (((u_int32_t)(u_int64_t)addr) ^
(u_int32_t)(((u_int64_t)addr) >> 32));
#else
icmp.icmp_id = (u_int32_t)addr;
#endif
@ -121,7 +124,7 @@ int icmp_echorequest (addr)
status = sendto (icmp_protocol_fd, (char *)&icmp, sizeof icmp, 0,
(struct sockaddr *)&to, sizeof to);
if (status < 0)
warn ("icmp_echorequest: %m");
warn ("icmp_echorequest %s: %m", inet_ntoa(to.sin_addr));
if (status != sizeof icmp)
return 0;