diff options
author | Ted Lemon <source@isc.org> | 1996-02-29 18:32:57 +0000 |
---|---|---|
committer | Ted Lemon <source@isc.org> | 1996-02-29 18:32:57 +0000 |
commit | 0366d39ed5c9cb097d11eb04a9b8c007c8dffe4f (patch) | |
tree | 2794a5c31350c10d8f67a17e4b57f1039155a893 | |
parent | a3e52198fc47bb2cfe22a3e3331ef648ea744f0c (diff) | |
download | isc-dhcp-0366d39ed5c9cb097d11eb04a9b8c007c8dffe4f.tar.gz |
Fix debugging statements; add raw data dumper
-rw-r--r-- | common/print.c | 48 | ||||
-rw-r--r-- | print.c | 48 |
2 files changed, 66 insertions, 30 deletions
diff --git a/common/print.c b/common/print.c index 0faef1fa..0af176c3 100644 --- a/common/print.c +++ b/common/print.c @@ -75,28 +75,28 @@ void print_lease (lease) struct tm *t; char tbuf [32]; - printf (" Lease %s", - piaddr (lease -> ip_addr)); + debug (" Lease %s", + piaddr (lease -> ip_addr)); t = gmtime (&lease -> starts); strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t); - printf (" start %s", tbuf); + debug (" start %s", tbuf); t = gmtime (&lease -> ends); strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t); - printf (" end %s", tbuf); + debug (" end %s", tbuf); t = gmtime (&lease -> timestamp); strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t); - printf (" stamp %s\n", tbuf); + debug (" stamp %s", tbuf); - printf (" hardware addr = %s", - print_hw_addr (lease -> hardware_addr.htype, + debug (" hardware addr = %s", + print_hw_addr (lease -> hardware_addr.htype, lease -> hardware_addr.hlen, lease -> hardware_addr.haddr)); - printf (" host %s state %x\n", - lease -> host ? lease -> host -> name : "<none>", - lease -> state); + debug (" host %s state %x", + lease -> host ? lease -> host -> name : "<none>", + lease -> state); } void dump_packet (tp) @@ -104,14 +104,15 @@ void dump_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 ("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 ("giaddr = %s", inet_ntoa (tdp -> giaddr)); debug ("chaddr = %02.2x:%02.2x:%02.2x:%02.2x:%02.2x:%02.2x", ((unsigned char *)(tdp -> chaddr)) [0], ((unsigned char *)(tdp -> chaddr)) [1], @@ -119,19 +120,36 @@ void dump_packet (tp) ((unsigned char *)(tdp -> chaddr)) [3], ((unsigned char *)(tdp -> chaddr)) [4], ((unsigned char *)(tdp -> chaddr)) [5]); - debug ("filename = %s\n", tdp -> file); - debug ("server_name = %s\n", tdp -> sname); + 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) - printf (" %s = %s\n", + debug (" %s = %s", dhcp_options [i].name, pretty_print_option (i, tp -> options [i].data, tp -> options [i].len)); } } + debug (""); +} + +void dump_raw (buf, len) + unsigned char *buf; + int len; +{ + int i; + + for (i = 0; i < len; i++) { + if ((i & 15) == 0) + fprintf (stderr, "\n%03x:", i); + else if ((i & 7) == 0) + fprintf (stderr, " "); + fprintf (stderr, " %02x", buf [i]); + } + fprintf (stderr, "\n"); } @@ -75,28 +75,28 @@ void print_lease (lease) struct tm *t; char tbuf [32]; - printf (" Lease %s", - piaddr (lease -> ip_addr)); + debug (" Lease %s", + piaddr (lease -> ip_addr)); t = gmtime (&lease -> starts); strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t); - printf (" start %s", tbuf); + debug (" start %s", tbuf); t = gmtime (&lease -> ends); strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t); - printf (" end %s", tbuf); + debug (" end %s", tbuf); t = gmtime (&lease -> timestamp); strftime (tbuf, sizeof tbuf, "%D %H:%M:%S", t); - printf (" stamp %s\n", tbuf); + debug (" stamp %s", tbuf); - printf (" hardware addr = %s", - print_hw_addr (lease -> hardware_addr.htype, + debug (" hardware addr = %s", + print_hw_addr (lease -> hardware_addr.htype, lease -> hardware_addr.hlen, lease -> hardware_addr.haddr)); - printf (" host %s state %x\n", - lease -> host ? lease -> host -> name : "<none>", - lease -> state); + debug (" host %s state %x", + lease -> host ? lease -> host -> name : "<none>", + lease -> state); } void dump_packet (tp) @@ -104,14 +104,15 @@ void dump_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 ("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 ("giaddr = %s", inet_ntoa (tdp -> giaddr)); debug ("chaddr = %02.2x:%02.2x:%02.2x:%02.2x:%02.2x:%02.2x", ((unsigned char *)(tdp -> chaddr)) [0], ((unsigned char *)(tdp -> chaddr)) [1], @@ -119,19 +120,36 @@ void dump_packet (tp) ((unsigned char *)(tdp -> chaddr)) [3], ((unsigned char *)(tdp -> chaddr)) [4], ((unsigned char *)(tdp -> chaddr)) [5]); - debug ("filename = %s\n", tdp -> file); - debug ("server_name = %s\n", tdp -> sname); + 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) - printf (" %s = %s\n", + debug (" %s = %s", dhcp_options [i].name, pretty_print_option (i, tp -> options [i].data, tp -> options [i].len)); } } + debug (""); +} + +void dump_raw (buf, len) + unsigned char *buf; + int len; +{ + int i; + + for (i = 0; i < len; i++) { + if ((i & 15) == 0) + fprintf (stderr, "\n%03x:", i); + else if ((i & 7) == 0) + fprintf (stderr, " "); + fprintf (stderr, " %02x", buf [i]); + } + fprintf (stderr, "\n"); } |