From: wessels <> Date: Fri, 20 Sep 1996 13:31:02 +0000 (+0000) Subject: byte-order conversion X-Git-Tag: SQUID_3_0_PRE1~5760 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=040934a9146dac2ff627c0086b643a755a63afb1;p=thirdparty%2Fsquid.git byte-order conversion debug level changes --- diff --git a/src/icmp.cc b/src/icmp.cc index e3d5a10be2..01923ba791 100644 --- a/src/icmp.cc +++ b/src/icmp.cc @@ -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), diff --git a/src/net_db.cc b/src/net_db.cc index 111e53828c..b21556afce 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -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; }