summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2004-05-04 21:25:28 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2004-05-04 21:25:28 +0000
commit5a6ba6e15fe81b53aabd942f225da0cd247f721f (patch)
tree481b79f1c3ca87e4790cb930789b9935a4d35be1
parent5de28bae13cc7585dcea2ebe433e6d6a1b08c7b9 (diff)
remove DEBUG_PACKET stuff; henning ok
-rw-r--r--usr.sbin/dhcpd/convert.c24
-rw-r--r--usr.sbin/dhcpd/dhcp.c16
-rw-r--r--usr.sbin/dhcpd/dhcpd.h5
-rw-r--r--usr.sbin/dhcpd/options.c249
-rw-r--r--usr.sbin/dhcpd/print.c70
5 files changed, 4 insertions, 360 deletions
diff --git a/usr.sbin/dhcpd/convert.c b/usr.sbin/dhcpd/convert.c
index 4f1e6fc93e5..e2750f67da9 100644
--- a/usr.sbin/dhcpd/convert.c
+++ b/usr.sbin/dhcpd/convert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: convert.c,v 1.3 2004/05/04 20:28:40 deraadt Exp $ */
+/* $OpenBSD: convert.c,v 1.4 2004/05/04 21:25:27 deraadt Exp $ */
/*
* Safe copying of option values into and out of the option buffer,
@@ -54,17 +54,6 @@ getULong(unsigned char *buf)
return (ntohl(ibuf));
}
-#ifdef DEBUG_PACKET
-int32_t
-getLong(unsigned char *(buf))
-{
- int32_t ibuf;
-
- memcpy(&ibuf, buf, sizeof(ibuf));
- return (ntohl(ibuf));
-}
-#endif
-
u_int16_t
getUShort(unsigned char *buf)
{
@@ -74,17 +63,6 @@ getUShort(unsigned char *buf)
return (ntohs(ibuf));
}
-#ifdef DEBUG_PACKET
-int16_t
-getShort(unsigned char *buf)
-{
- int16_t ibuf;
-
- memcpy(&ibuf, buf, sizeof(ibuf));
- return (ntohs(ibuf));
-}
-#endif
-
void
putULong(unsigned char *obuf, u_int32_t val)
{
diff --git a/usr.sbin/dhcpd/dhcp.c b/usr.sbin/dhcpd/dhcp.c
index 530fcb9ef3d..10278f81dd4 100644
--- a/usr.sbin/dhcpd/dhcp.c
+++ b/usr.sbin/dhcpd/dhcp.c
@@ -537,13 +537,6 @@ nak_lease(struct packet *packet, struct iaddr *cip)
packet->raw->chaddr), packet->raw->giaddr.s_addr ?
inet_ntoa(packet->raw->giaddr) : packet->interface->name);
-#ifdef DEBUG_PACKET
- dump_packet(packet);
- dump_raw((unsigned char *)packet->raw, packet->packet_length);
- dump_packet(&outgoing);
- dump_raw((unsigned char *)&raw, outgoing.packet_length);
-#endif
-
hto.htype = packet->raw->htype;
hto.hlen = packet->raw->hlen;
memcpy(hto.haddr, packet->raw->chaddr, hto.hlen);
@@ -1082,11 +1075,6 @@ ack_lease(struct packet *packet, struct lease *lease, unsigned int offer,
state->options[i]->tree = NULL;
}
-#ifdef DEBUG_PACKET
- dump_packet(packet);
- dump_raw((unsigned char *)packet->raw, packet->packet_length);
-#endif
-
lease->state = state;
/* If this is a DHCPOFFER, ping the lease address before actually
@@ -1218,10 +1206,6 @@ dhcp_reply(struct lease *lease)
to.sin_len = sizeof to;
#endif
-#ifdef DEBUG_PACKET
- dump_raw((unsigned char *)&raw, packet_length);
-#endif
-
/* Make sure outgoing packets are at least as big
as a BOOTP packet. */
if (packet_length < BOOTP_MIN_LEN)
diff --git a/usr.sbin/dhcpd/dhcpd.h b/usr.sbin/dhcpd/dhcpd.h
index 57e6a98aa17..b1cf14672c5 100644
--- a/usr.sbin/dhcpd/dhcpd.h
+++ b/usr.sbin/dhcpd/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.12 2004/05/04 20:28:40 deraadt Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.13 2004/05/04 21:25:27 deraadt Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998, 1999
@@ -701,9 +701,6 @@ void free_tree(struct tree *, char *);
/* print.c */
char *print_hw_addr(int, int, unsigned char *);
void dump_raw(unsigned char *, int);
-#ifdef DEBUG_PACKET
-void dump_packet(struct packet *);
-#endif
/* bpf.c */
int if_register_bpf(struct interface_info *);
diff --git a/usr.sbin/dhcpd/options.c b/usr.sbin/dhcpd/options.c
index cd8157c61fb..eb19bb0e60e 100644
--- a/usr.sbin/dhcpd/options.c
+++ b/usr.sbin/dhcpd/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.3 2004/05/04 20:28:40 deraadt Exp $ */
+/* $OpenBSD: options.c,v 1.4 2004/05/04 21:25:27 deraadt Exp $ */
/* DHCP options parsing and reassembly. */
@@ -457,253 +457,6 @@ store_options(unsigned char *buffer, int buflen, struct tree_cache **options,
return (bufix);
}
-#ifdef DEBUG_PACKET
-/*
- * Format the specified option so that a human can easily read it.
- */
-char *
-pretty_print_option(unsigned int code, unsigned char *data, int len,
- int emit_commas, int emit_quotes)
-{
- static char optbuf[32768]; /* XXX */
- int hunksize = 0;
- int numhunk = -1;
- int numelem = 0;
- char fmtbuf[32];
- int i, j, k;
- char *op = optbuf;
- int opleft = sizeof(optbuf);
- unsigned char *dp = data;
- struct in_addr foo;
- char comma;
-
-
- /* Code should be between 0 and 255. */
- if (code > 255)
- error("pretty_print_option: bad code %d\n", code);
-
- if (emit_commas)
- comma = ',';
- else
- comma = ' ';
-
- /* Figure out the size of the data. */
- for (i = 0; dhcp_options[code].format[i]; i++) {
- if (!numhunk) {
- warn("%s: Excess information in format string: %s",
- dhcp_options[code].name,
- &(dhcp_options[code].format[i]));
- break;
- }
- numelem++;
- fmtbuf[i] = dhcp_options[code].format[i];
- switch (dhcp_options[code].format[i]) {
- case 'A':
- --numelem;
- fmtbuf[i] = 0;
- numhunk = 0;
- break;
- case 'X':
- for (k = 0; k < len; k++)
- if (!isascii(data[k]) ||
- !isprint(data[k]))
- break;
- if (k == len) {
- fmtbuf[i] = 't';
- numhunk = -2;
- } else {
- fmtbuf[i] = 'x';
- hunksize++;
- comma = ':';
- numhunk = 0;
- }
- fmtbuf[i + 1] = 0;
- break;
- case 't':
- fmtbuf[i] = 't';
- fmtbuf[i + 1] = 0;
- numhunk = -2;
- break;
- case 'I':
- case 'l':
- case 'L':
- hunksize += 4;
- break;
- case 's':
- case 'S':
- hunksize += 2;
- break;
- case 'b':
- case 'B':
- case 'f':
- hunksize++;
- break;
- case 'e':
- break;
- default:
- warn("%s: garbage in format string: %s",
- dhcp_options[code].name,
- &(dhcp_options[code].format[i]));
- break;
- }
- }
-
- /* Check for too few bytes... */
- if (hunksize > len) {
- warn("%s: expecting at least %d bytes; got %d",
- dhcp_options[code].name, hunksize, len);
- return ("<error>");
- }
- /* Check for too many bytes... */
- if (numhunk == -1 && hunksize < len)
- warn("%s: %d extra bytes",
- dhcp_options[code].name, len - hunksize);
-
- /* If this is an array, compute its size. */
- if (!numhunk)
- numhunk = len / hunksize;
- /* See if we got an exact number of hunks. */
- if (numhunk > 0 && numhunk * hunksize < len)
- warn("%s: %d extra bytes at end of array",
- dhcp_options[code].name, len - numhunk * hunksize);
-
- /* A one-hunk array prints the same as a single hunk. */
- if (numhunk < 0)
- numhunk = 1;
-
- /* Cycle through the array (or hunk) printing the data. */
- for (i = 0; i < numhunk; i++) {
- for (j = 0; j < numelem; j++) {
- int opcount;
- switch (fmtbuf[j]) {
- case 't':
- if (emit_quotes) {
- *op++ = '"';
- opleft--;
- }
- for (; dp < data + len; dp++) {
- if (!isascii(*dp) ||
- !isprint(*dp)) {
- if (dp + 1 != data + len ||
- *dp != 0) {
- snprintf(op, opleft,
- "\\%03o", *dp);
- op += 4;
- opleft -= 4;
- }
- } else if (*dp == '"' ||
- *dp == '\'' ||
- *dp == '$' ||
- *dp == '`' ||
- *dp == '\\') {
- *op++ = '\\';
- *op++ = *dp;
- opleft -= 2;
- } else {
- *op++ = *dp;
- opleft--;
- }
- }
- if (emit_quotes) {
- *op++ = '"';
- opleft--;
- }
-
- *op = 0;
- break;
- case 'I':
- foo.s_addr = htonl(getULong(dp));
- opcount = strlcpy(op, inet_ntoa(foo), opleft);
- if (opcount >= opleft)
- goto toobig;
- opleft -= opcount;
- dp += 4;
- break;
- case 'l':
- opcount = snprintf(op, opleft, "%ld",
- (long)getLong(dp));
- if (opcount >= opleft)
- goto toobig;
- opleft -= opcount;
- dp += 4;
- break;
- case 'L':
- opcount = snprintf(op, opleft, "%ld",
- (unsigned long)getULong(dp));
- if (opcount >= opleft)
- goto toobig;
- opleft -= opcount;
- dp += 4;
- break;
- case 's':
- opcount = snprintf(op, opleft, "%d",
- getShort(dp));
- if (opcount >= opleft)
- goto toobig;
- opleft -= opcount;
- dp += 2;
- break;
- case 'S':
- opcount = snprintf(op, opleft, "%d",
- getUShort(dp));
- if (opcount >= opleft)
- goto toobig;
- opleft -= opcount;
- dp += 2;
- break;
- case 'b':
- opcount = snprintf(op, opleft, "%d",
- *(char *)dp++);
- if (opcount >= opleft)
- goto toobig;
- opleft -= opcount;
- break;
- case 'B':
- opcount = snprintf(op, opleft, "%d", *dp++);
- if (opcount >= opleft)
- goto toobig;
- opleft -= opcount;
- break;
- case 'x':
- opcount = snprintf(op, opleft, "%x", *dp++);
- if (opcount >= opleft)
- goto toobig;
- opleft -= opcount;
- break;
- case 'f':
- opcount = strlcpy(op,
- *dp++ ? "true" : "false", opleft);
- if (opcount >= opleft)
- goto toobig;
- opleft -= opcount;
- break;
- default:
- warn("Unexpected format code %c", fmtbuf[j]);
- }
- op += strlen(op);
- opleft -= strlen(op);
- if (opleft < 1)
- goto toobig;
- if (j + 1 < numelem && comma != ':') {
- *op++ = ' ';
- opleft--;
- }
- }
- if (i + 1 < numhunk) {
- *op++ = comma;
- opleft--;
- }
- if (opleft < 1)
- goto toobig;
-
- }
- return (optbuf);
- toobig:
- warn("dhcp option too large");
- return ("<error>");
-}
-#endif /* DEBUG_PACKET */
-
void
do_packet(struct interface_info *interface, struct dhcp_packet *packet,
int len, unsigned int from_port, struct iaddr from, struct hardware *hfrom)
diff --git a/usr.sbin/dhcpd/print.c b/usr.sbin/dhcpd/print.c
index 30de7624a22..69642907582 100644
--- a/usr.sbin/dhcpd/print.c
+++ b/usr.sbin/dhcpd/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.7 2004/05/04 20:28:40 deraadt Exp $ */
+/* $OpenBSD: print.c,v 1.8 2004/05/04 21:25:27 deraadt Exp $ */
/* Turn data structures into printable text. */
@@ -72,71 +72,3 @@ bad:
return habuf;
}
-
-#ifdef DEBUG_PACKET
-void
-dump_packet(struct packet *tp)
-{
- struct dhcp_packet *tdp = tp->raw;
-
- debug("packet length %d", tp->packet_length);
- debug("op = %d htype = %d hlen = %d hops = %d", tdp->op, tdp->htype,
- tdp->hlen, tdp->hops);
- debug("xid = %x secs = %d flags = %x", tdp->xid, tdp->secs,
- tdp->flags);
- debug("ciaddr = %s", inet_ntoa(tdp->ciaddr));
- debug("yiaddr = %s", inet_ntoa(tdp->yiaddr));
- debug("siaddr = %s", inet_ntoa(tdp->siaddr));
- debug("giaddr = %s", inet_ntoa(tdp->giaddr));
- debug("chaddr = %02x:%02x:%02x:%02x:%02x:%02x",
- ((unsigned char *)(tdp->chaddr))[0],
- ((unsigned char *)(tdp->chaddr))[1],
- ((unsigned char *)(tdp->chaddr))[2],
- ((unsigned char *)(tdp->chaddr))[3],
- ((unsigned char *)(tdp->chaddr))[4],
- ((unsigned char *)(tdp->chaddr))[5]);
- debug("filename = %s", tdp->file);
- debug("server_name = %s", tdp->sname);
- if (tp->options_valid) {
- int i;
-
- for (i = 0; i < 256; i++) {
- if (tp->options[i].data)
- debug(" %s = %s", dhcp_options[i].name,
- pretty_print_option(i, tp->options[i].data,
- tp->options[i].len, 1, 1));
- }
- }
- debug("%s", "");
-}
-
-void
-dump_raw(unsigned char *buf, int len)
-{
- char lbuf[80];
- int i, j, llen = sizeof(lbuf), lbix = 0;
-
- lbuf[0] = 0;
-
- for (i = 0; i < len; i++) {
- if ((i & 15) == 0) {
- if (lbix)
- note("%s", lbuf);
- j = snprintf(lbuf, llen, "%03x:", i);
- if (j >= llen)
- return;
- lbix += j;
- llen -= j;
- } else if ((i & 7) == 0) {
- lbuf[lbix++] = ' ';
- len--;
- }
- j = snprintf(&lbuf[lbix], llen, " %02x", buf[i]);
- if (j >= llen)
- return;
- lbix += j;
- llen -= j;
- }
- note("%s", lbuf);
-}
-#endif /* DEBUG_PACKET */