aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/clientpacket.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-06-17 11:54:52 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-06-17 11:54:52 +0200
commitac906fa85e61b4e34161709de777616f858bc945 (patch)
tree7b247714814fd9dcf3fd3dccf954521b29eef5a2 /networking/udhcp/clientpacket.c
parented8982bfc0e9895fe707a5f6152cf184e06f2052 (diff)
downloadbusybox-ac906fa85e61b4e34161709de777616f858bc945.tar.gz
udhcp: change UDHCP_DEBUG into int, make verbosity selectable with -v
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/clientpacket.c')
-rw-r--r--networking/udhcp/clientpacket.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 068f947cc..7d44697ec 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -203,7 +203,7 @@ int FAST_FUNC send_release(uint32_t server, uint32_t ciaddr)
/* Returns -1 on errors that are fatal for the socket, -2 for those that aren't */
-int FAST_FUNC udhcp_recv_raw_packet(struct dhcpMessage *payload, int fd)
+int FAST_FUNC udhcp_recv_raw_packet(struct dhcpMessage *dhcp_pkt, int fd)
{
int bytes;
struct udp_dhcp_packet packet;
@@ -212,19 +212,19 @@ int FAST_FUNC udhcp_recv_raw_packet(struct dhcpMessage *payload, int fd)
memset(&packet, 0, sizeof(packet));
bytes = safe_read(fd, &packet, sizeof(packet));
if (bytes < 0) {
- DEBUG("Cannot read on raw listening socket - ignoring");
+ log1("Packet read error, ignoring");
/* NB: possible down interface, etc. Caller should pause. */
return bytes; /* returns -1 */
}
if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) {
- DEBUG("Packet is too short, ignoring");
+ log1("Packet is too short, ignoring");
return -2;
}
if (bytes < ntohs(packet.ip.tot_len)) {
/* packet is bigger than sizeof(packet), we did partial read */
- DEBUG("Oversized packet, ignoring");
+ log1("Oversized packet, ignoring");
return -2;
}
@@ -238,7 +238,7 @@ int FAST_FUNC udhcp_recv_raw_packet(struct dhcpMessage *payload, int fd)
/* || bytes > (int) sizeof(packet) - can't happen */
|| ntohs(packet.udp.len) != (uint16_t)(bytes - sizeof(packet.ip))
) {
- DEBUG("Unrelated/bogus packet");
+ log1("Unrelated/bogus packet, ignoring");
return -2;
}
@@ -246,7 +246,7 @@ int FAST_FUNC udhcp_recv_raw_packet(struct dhcpMessage *payload, int fd)
check = packet.ip.check;
packet.ip.check = 0;
if (check != udhcp_checksum(&packet.ip, sizeof(packet.ip))) {
- DEBUG("Bad IP header checksum, ignoring");
+ log1("Bad IP header checksum, ignoring");
return -2;
}
@@ -257,16 +257,17 @@ int FAST_FUNC udhcp_recv_raw_packet(struct dhcpMessage *payload, int fd)
check = packet.udp.check;
packet.udp.check = 0;
if (check && check != udhcp_checksum(&packet, bytes)) {
- bb_error_msg("packet with bad UDP checksum received, ignoring");
+ log1("Packet with bad UDP checksum received, ignoring");
return -2;
}
- memcpy(payload, &packet.data, bytes - (sizeof(packet.ip) + sizeof(packet.udp)));
+ memcpy(dhcp_pkt, &packet.data, bytes - (sizeof(packet.ip) + sizeof(packet.udp)));
- if (payload->cookie != htonl(DHCP_MAGIC)) {
- bb_error_msg("received bogus message (bad magic), ignoring");
+ if (dhcp_pkt->cookie != htonl(DHCP_MAGIC)) {
+ bb_info_msg("Packet with bad magic, ignoring");
return -2;
}
- DEBUG("Got valid DHCP packet");
+ log1("Got valid DHCP packet");
+ udhcp_dump_packet(dhcp_pkt);
return bytes - (sizeof(packet.ip) + sizeof(packet.udp));
}