summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-02-24 00:34:41 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-02-24 00:34:41 +0000
commitf0a2adfc17f2b0b7965f011a1638e40747a75461 (patch)
tree96be7a0c37df6b267d48a276e1d197ed3166e0b0 /sbin
parent9a849fd3974295740bddbecc49ae9d1efb5e94e5 (diff)
cut debug crap
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/packet.c44
-rw-r--r--sbin/dhclient/tree.c27
2 files changed, 6 insertions, 65 deletions
diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c
index 5632e2e2247..5a096051cd2 100644
--- a/sbin/dhclient/packet.c
+++ b/sbin/dhclient/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.5 2004/02/23 18:27:37 henning Exp $ */
+/* $OpenBSD: packet.c,v 1.6 2004/02/24 00:34:40 henning Exp $ */
/* Packet assembly code, originally contributed by Archie Cobbs. */
@@ -54,17 +54,9 @@ checksum(unsigned char *buf, unsigned nbytes, u_int32_t sum)
{
int i;
-#ifdef DEBUG_CHECKSUM
- debug("checksum (%x %d %x)", buf, nbytes, sum);
-#endif
-
/* Checksum all the pairs of bytes first... */
for (i = 0; i < (nbytes & ~1U); i += 2) {
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug("sum = %x", sum);
-#endif
sum += (u_int16_t)ntohs(*((u_int16_t *)(buf + i)));
- /* Add carry. */
if (sum > 0xFFFF)
sum -= 0xFFFF;
}
@@ -75,11 +67,7 @@ checksum(unsigned char *buf, unsigned nbytes, u_int32_t sum)
* the high byte.
*/
if (i < nbytes) {
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug("sum = %x", sum);
-#endif
sum += buf[i] << 8;
- /* Add carry. */
if (sum > 0xFFFF)
sum -= 0xFFFF;
}
@@ -93,18 +81,7 @@ checksum(unsigned char *buf, unsigned nbytes, u_int32_t sum)
u_int32_t
wrapsum(u_int32_t sum)
{
-#ifdef DEBUG_CHECKSUM
- debug("wrapsum (%x)", sum);
-#endif
-
sum = ~sum & 0xFFFF;
-#ifdef DEBUG_CHECKSUM_VERBOSE
- debug("sum = %x", sum);
-#endif
-
-#ifdef DEBUG_CHECKSUM
- debug("wrapsum returns %x", htons(sum));
-#endif
return (htons(sum));
}
@@ -144,10 +121,7 @@ assemble_udp_ip_header(struct interface_info *interface, unsigned char *buf,
ip.ip_src.s_addr = from;
ip.ip_dst.s_addr = to;
- /* Checksum the IP header... */
ip.ip_sum = wrapsum(checksum((unsigned char *)&ip, sizeof(ip), 0));
-
- /* Copy the ip header into the buffer... */
memcpy(&buf[*bufix], &ip, sizeof(ip));
*bufix += sizeof(ip);
@@ -157,16 +131,11 @@ assemble_udp_ip_header(struct interface_info *interface, unsigned char *buf,
udp.uh_ulen = htons(sizeof(udp) + len);
memset(&udp.uh_sum, 0, sizeof(udp.uh_sum));
- /*
- * Compute UDP checksums, including the ``pseudo-header'', the
- * UDP header and the data.
- */
udp.uh_sum = wrapsum(checksum((unsigned char *)&udp, sizeof(udp),
checksum(data, len, checksum((unsigned char *)&ip.ip_src,
- 2 * sizeof(ip.ip_src),
- IPPROTO_UDP + (u_int32_t)ntohs(udp.uh_ulen)))));
+ 2 * sizeof(ip.ip_src),
+ IPPROTO_UDP + (u_int32_t)ntohs(udp.uh_ulen)))));
- /* Copy the udp header into the buffer... */
memcpy(&buf[*bufix], &udp, sizeof(udp));
*bufix += sizeof(udp);
}
@@ -216,12 +185,10 @@ decode_udp_ip_header(struct interface_info *interface, unsigned char *buf,
return (-1);
}
- /* Check the IP packet length. */
if (ntohs(ip->ip_len) != buflen)
debug("ip length %d disagrees with bytes received %d.",
ntohs(ip->ip_len), buflen);
- /* Copy out the IP source address... */
memcpy(&from->sin_addr, &ip->ip_src, 4);
/*
@@ -255,8 +222,8 @@ decode_udp_ip_header(struct interface_info *interface, unsigned char *buf,
sum = wrapsum(checksum((unsigned char *)udp, sizeof(*udp),
checksum(data, len, checksum((unsigned char *)&ip->ip_src,
- 2 * sizeof(ip->ip_src),
- IPPROTO_UDP + (u_int32_t)ntohs(udp->uh_ulen)))));
+ 2 * sizeof(ip->ip_src),
+ IPPROTO_UDP + (u_int32_t)ntohs(udp->uh_ulen)))));
udp_packets_seen++;
if (usum && usum != sum) {
@@ -270,7 +237,6 @@ decode_udp_ip_header(struct interface_info *interface, unsigned char *buf,
return (-1);
}
- /* Copy out the port... */
memcpy(&from->sin_port, &udp->uh_sport, sizeof(udp->uh_sport));
return (ip_len + sizeof(*udp));
diff --git a/sbin/dhclient/tree.c b/sbin/dhclient/tree.c
index e14977ca750..94a35e64e06 100644
--- a/sbin/dhclient/tree.c
+++ b/sbin/dhclient/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.6 2004/02/23 20:09:02 deraadt Exp $ */
+/* $OpenBSD: tree.c,v 1.7 2004/02/24 00:34:40 henning Exp $ */
/* Routines for manipulating parse trees... */
@@ -286,25 +286,12 @@ do_host_lookup(int *bufix, unsigned char **bufp, int *bufcount,
int i;
int new_len;
-#ifdef DEBUG_EVAL
- debug("time: now = %d dns = %d %d diff = %d",
- cur_time, dns->timeout, cur_time - dns->timeout);
-#endif
-
/* If the record hasn't timed out, just copy the data and return. */
if (cur_time <= dns->timeout) {
-#ifdef DEBUG_EVAL
- debug("easy copy: %x %d %x",
- dns->data, dns->data_len,
- dns->data ? *(int *)(dns->data) : 0);
-#endif
do_data_copy(bufix, bufp, bufcount,
dns->data, dns->data_len);
return (dns->timeout);
}
-#ifdef DEBUG_EVAL
- debug("Looking up %s", dns->hostname);
-#endif
/* Otherwise, look it up... */
h = gethostbyname(dns->hostname);
@@ -328,10 +315,6 @@ do_host_lookup(int *bufix, unsigned char **bufp, int *bufcount,
return (cur_time + 60);
}
-#ifdef DEBUG_EVAL
- debug("Lookup succeeded; first address is %x", h->h_addr_list[0]);
-#endif
-
/* Count the number of addresses we got... */
for (i = 0; h->h_addr_list[i]; i++)
;
@@ -363,10 +346,6 @@ do_host_lookup(int *bufix, unsigned char **bufp, int *bufcount,
memcpy(dns->data + h->h_length * i,
h->h_addr_list[i], h->h_length);
}
-#ifdef DEBUG_EVAL
- debug("dns -> data: %x h -> h_addr_list [0]: %x",
- *(int *)(dns->data), h->h_addr_list[0]);
-#endif
dns->data_len = new_len;
/*
@@ -375,10 +354,6 @@ do_host_lookup(int *bufix, unsigned char **bufp, int *bufcount,
*/
dns->timeout = cur_time + 3600;
-#ifdef DEBUG_EVAL
- debug("hard copy: %x %d %x",
- dns->data, dns->data_len, *(int *)(dns->data));
-#endif
do_data_copy(bufix, bufp, bufcount, dns->data, dns->data_len);
return (dns->timeout);
}