]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
byte-order conversion
authorwessels <>
Fri, 20 Sep 1996 13:31:02 +0000 (13:31 +0000)
committerwessels <>
Fri, 20 Sep 1996 13:31:02 +0000 (13:31 +0000)
debug level changes

src/icmp.cc
src/net_db.cc

index e3d5a10be223c698156f6847ec4deba6bee48332..01923ba79107555ce472ef9aff52032bd5db6b10 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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
@@ -225,7 +225,7 @@ icmpRecv(int unused1, void *unused2)
     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();
@@ -245,6 +245,16 @@ icmpRecv(int unused1, void *unused2)
     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) {
@@ -344,7 +354,7 @@ icmpSend(int fd, icmpQueueData * queue)
 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),
index 111e53828ceed1a5b0059ca60640a0773a8714ac..b21556afce8dd3c59c056f7032a5d9082354b07c 100644 (file)
@@ -102,7 +102,7 @@ netdbSendPing(int fdunused, struct hostent *hp, void *data)
     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);
@@ -122,7 +122,7 @@ netdbHandlePingReply(struct sockaddr_in *from, int hops, int rtt)
 {
     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;
@@ -130,7 +130,7 @@ netdbHandlePingReply(struct sockaddr_in *from, int hops, int rtt)
        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);
@@ -141,11 +141,11 @@ networkFromInaddr(struct in_addr a)
 {
     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;
 }