/*
- * $Id: icmp.cc,v 1.7 1996/09/20 06:28:51 wessels Exp $
+ * $Id: icmp.cc,v 1.8 1996/09/20 07:31:02 wessels Exp $
*
* DEBUG: section 37 ICMP Routines
* AUTHOR: Duane Wessels
int n;
int fromlen;
struct sockaddr_in from;
- int iphdrlen;
+ int iphdrlen = 20;
struct iphdr *ip = NULL;
register struct icmphdr *icmp = NULL;
char *pkt = get_free_8k_page();
debug(37, 9, "icmpRecv: %d bytes from %s\n", n, inet_ntoa(from.sin_addr));
ip = (struct iphdr *) (void *) pkt;
iphdrlen = ip->ip_hl << 2;
+#if HAVE_IP_HL
+ iphdrlen = ip->ip_hl << 2;
+#else
+#if BYTE_ORDER == BIG_ENDIAN
+ iphdrlen = (ip->ip_vhl >> 4) << 2;
+#endif
+#if BYTE_ORDER == LITTLE_ENDIAN
+ iphdrlen = (ip->ip_vhl & 0xF) << 2;
+#endif
+#endif
icmp = (struct icmphdr *) (void *) (pkt + iphdrlen);
if (icmp->icmp_type == ICMP_ECHOREPLY) {
if (icmp->icmp_id == icmp_ident) {
static void
icmpLog(struct icmphdr *icmp, struct in_addr addr, int rtt, int hops)
{
- debug(0, 0, "icmpLog: %9d.%06d %-16s %d %-15.15s %dms %d hops\n",
+ debug(37, 2, "icmpLog: %9d.%06d %-16s %d %-15.15s %dms %d hops\n",
(int) current_time.tv_sec,
(int) current_time.tv_usec,
inet_ntoa(addr),
addr = inaddrFromHostent(hp);
if ((n = netdbLookupHost(hostname)) == NULL)
n = netdbAdd(addr, hostname);
- debug(37, 0, "netdbSendPing: pinging %s\n", hostname);
+ debug(37, 3, "netdbSendPing: pinging %s\n", hostname);
icmpDomainPing(addr, hostname);
n->next_ping_time = squid_curtime + NET_DB_TTL;
xfree(hostname);
{
netdbEntry *n;
int N;
- debug(37, 0, "netdbHandlePingReply: from %s\n", inet_ntoa(from->sin_addr));
+ debug(37, 3, "netdbHandlePingReply: from %s\n", inet_ntoa(from->sin_addr));
if ((n = netdbLookupAddr(from->sin_addr)) == NULL)
return;
N = ++n->n;
N = 100;
n->hops = ((n->hops * (N - 1)) + hops) / N;
n->rtt = ((n->rtt * (N - 1)) + rtt) / N;
- debug(37, 0, "netdbHandlePingReply: %s; rtt=%5.1f hops=%4.1f\n",
+ debug(37, 3, "netdbHandlePingReply: %s; rtt=%5.1f hops=%4.1f\n",
n->network,
n->rtt,
n->hops);
{
struct in_addr b = a;
if (IN_CLASSC(b.s_addr))
- b.s_addr &= IN_CLASSC_NET;
+ b.s_addr &= htonl(IN_CLASSC_NET);
else if (IN_CLASSB(b.s_addr))
- b.s_addr &= IN_CLASSB_NET;
+ b.s_addr &= htonl(IN_CLASSB_NET);
else if (IN_CLASSA(b.s_addr))
- b.s_addr &= IN_CLASSA_NET;
+ b.s_addr &= htonl(IN_CLASSA_NET);
return b;
}