2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-09-01 14:55:30 +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 #ifndef lint
static char copyright[] = 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 */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -63,6 +63,7 @@ void icmp_startup (routep, handler)
int protocol = 1; int protocol = 1;
struct sockaddr_in from; struct sockaddr_in from;
int fd; int fd;
int state;
/* Only initialize icmp once. */ /* Only initialize icmp once. */
if (icmp_protocol_initialized) if (icmp_protocol_initialized)
@@ -76,12 +77,14 @@ void icmp_startup (routep, handler)
/* Get a raw socket for the ICMP protocol. */ /* Get a raw socket for the ICMP protocol. */
icmp_protocol_fd = socket (AF_INET, SOCK_RAW, 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"); error ("unable to create icmp socket: %m");
if (setsockopt (icmp_protocol_fd, SOL_SOCKET, SO_DONTROUTE, /* Make sure it does routing... */
(char *)&routep, sizeof routep)) state = 0;
error ("Can't set SO_DONTROUTE on ICMP socket: %m"); 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); add_protocol ("icmp", icmp_protocol_fd, icmp_echoreply, handler);
} }
@@ -108,7 +111,7 @@ int icmp_echorequest (addr)
icmp.icmp_cksum = 0; icmp.icmp_cksum = 0;
icmp.icmp_seq = 0; icmp.icmp_seq = 0;
#ifdef PTRSIZE_64BIT #ifdef PTRSIZE_64BIT
icmp.icmp_id = (((u_int32_t)addr) ^ icmp.icmp_id = (((u_int32_t)(u_int64_t)addr) ^
(u_int32_t)(((u_int64_t)addr) >> 32)); (u_int32_t)(((u_int64_t)addr) >> 32));
#else #else
icmp.icmp_id = (u_int32_t)addr; icmp.icmp_id = (u_int32_t)addr;
@@ -121,7 +124,7 @@ int icmp_echorequest (addr)
status = sendto (icmp_protocol_fd, (char *)&icmp, sizeof icmp, 0, status = sendto (icmp_protocol_fd, (char *)&icmp, sizeof icmp, 0,
(struct sockaddr *)&to, sizeof to); (struct sockaddr *)&to, sizeof to);
if (status < 0) if (status < 0)
warn ("icmp_echorequest: %m"); warn ("icmp_echorequest %s: %m", inet_ntoa(to.sin_addr));
if (status != sizeof icmp) if (status != sizeof icmp)
return 0; return 0;