From f2aad86a770b08e9c5bea9e2875cd520c61b6b05 Mon Sep 17 00:00:00 2001 From: Ted Lemon Date: Fri, 9 May 1997 08:05:28 +0000 Subject: [PATCH] Fix alpha ptrsize botch. Try even harder to make sure ICMP Echo request packets are routed. Better error message. --- common/icmp.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/common/icmp.c b/common/icmp.c index 93e109e8..6c078cab 100644 --- a/common/icmp.c +++ b/common/icmp.c @@ -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;