diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-17 11:54:52 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-17 11:54:52 +0200 |
commit | ac906fa85e61b4e34161709de777616f858bc945 (patch) | |
tree | 7b247714814fd9dcf3fd3dccf954521b29eef5a2 /networking/udhcp/serverpacket.c | |
parent | ed8982bfc0e9895fe707a5f6152cf184e06f2052 (diff) | |
download | busybox-w32-ac906fa85e61b4e34161709de777616f858bc945.tar.gz busybox-w32-ac906fa85e61b4e34161709de777616f858bc945.tar.bz2 busybox-w32-ac906fa85e61b4e34161709de777616f858bc945.zip |
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/serverpacket.c')
-rw-r--r-- | networking/udhcp/serverpacket.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/networking/udhcp/serverpacket.c b/networking/udhcp/serverpacket.c index d9c5ce3ed..831165d8e 100644 --- a/networking/udhcp/serverpacket.c +++ b/networking/udhcp/serverpacket.c | |||
@@ -27,48 +27,48 @@ | |||
27 | 27 | ||
28 | 28 | ||
29 | /* send a packet to gateway_nip using the kernel ip stack */ | 29 | /* send a packet to gateway_nip using the kernel ip stack */ |
30 | static int send_packet_to_relay(struct dhcpMessage *payload) | 30 | static int send_packet_to_relay(struct dhcpMessage *dhcp_pkt) |
31 | { | 31 | { |
32 | DEBUG("Forwarding packet to relay"); | 32 | log1("Forwarding packet to relay"); |
33 | 33 | ||
34 | return udhcp_send_kernel_packet(payload, | 34 | return udhcp_send_kernel_packet(dhcp_pkt, |
35 | server_config.server_nip, SERVER_PORT, | 35 | server_config.server_nip, SERVER_PORT, |
36 | payload->gateway_nip, SERVER_PORT); | 36 | dhcp_pkt->gateway_nip, SERVER_PORT); |
37 | } | 37 | } |
38 | 38 | ||
39 | 39 | ||
40 | /* send a packet to a specific mac address and ip address by creating our own ip packet */ | 40 | /* send a packet to a specific mac address and ip address by creating our own ip packet */ |
41 | static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcast) | 41 | static int send_packet_to_client(struct dhcpMessage *dhcp_pkt, int force_broadcast) |
42 | { | 42 | { |
43 | const uint8_t *chaddr; | 43 | const uint8_t *chaddr; |
44 | uint32_t ciaddr; | 44 | uint32_t ciaddr; |
45 | 45 | ||
46 | // Was: | 46 | // Was: |
47 | //if (force_broadcast) { /* broadcast */ } | 47 | //if (force_broadcast) { /* broadcast */ } |
48 | //else if (payload->ciaddr) { /* unicast to payload->ciaddr */ } | 48 | //else if (dhcp_pkt->ciaddr) { /* unicast to dhcp_pkt->ciaddr */ } |
49 | //else if (payload->flags & htons(BROADCAST_FLAG)) { /* broadcast */ } | 49 | //else if (dhcp_pkt->flags & htons(BROADCAST_FLAG)) { /* broadcast */ } |
50 | //else { /* unicast to payload->yiaddr */ } | 50 | //else { /* unicast to dhcp_pkt->yiaddr */ } |
51 | // But this is wrong: yiaddr is _our_ idea what client's IP is | 51 | // But this is wrong: yiaddr is _our_ idea what client's IP is |
52 | // (for example, from lease file). Client may not know that, | 52 | // (for example, from lease file). Client may not know that, |
53 | // and may not have UDP socket listening on that IP! | 53 | // and may not have UDP socket listening on that IP! |
54 | // We should never unicast to payload->yiaddr! | 54 | // We should never unicast to dhcp_pkt->yiaddr! |
55 | // payload->ciaddr, OTOH, comes from client's request packet, | 55 | // dhcp_pkt->ciaddr, OTOH, comes from client's request packet, |
56 | // and can be used. | 56 | // and can be used. |
57 | 57 | ||
58 | if (force_broadcast | 58 | if (force_broadcast |
59 | || (payload->flags & htons(BROADCAST_FLAG)) | 59 | || (dhcp_pkt->flags & htons(BROADCAST_FLAG)) |
60 | || !payload->ciaddr | 60 | || !dhcp_pkt->ciaddr |
61 | ) { | 61 | ) { |
62 | DEBUG("broadcasting packet to client"); | 62 | log1("Broadcasting packet to client"); |
63 | ciaddr = INADDR_BROADCAST; | 63 | ciaddr = INADDR_BROADCAST; |
64 | chaddr = MAC_BCAST_ADDR; | 64 | chaddr = MAC_BCAST_ADDR; |
65 | } else { | 65 | } else { |
66 | DEBUG("unicasting packet to client ciaddr"); | 66 | log1("Unicasting packet to client ciaddr"); |
67 | ciaddr = payload->ciaddr; | 67 | ciaddr = dhcp_pkt->ciaddr; |
68 | chaddr = payload->chaddr; | 68 | chaddr = dhcp_pkt->chaddr; |
69 | } | 69 | } |
70 | 70 | ||
71 | return udhcp_send_raw_packet(payload, | 71 | return udhcp_send_raw_packet(dhcp_pkt, |
72 | /*src*/ server_config.server_nip, SERVER_PORT, | 72 | /*src*/ server_config.server_nip, SERVER_PORT, |
73 | /*dst*/ ciaddr, CLIENT_PORT, chaddr, | 73 | /*dst*/ ciaddr, CLIENT_PORT, chaddr, |
74 | server_config.ifindex); | 74 | server_config.ifindex); |
@@ -76,11 +76,11 @@ static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcas | |||
76 | 76 | ||
77 | 77 | ||
78 | /* send a dhcp packet, if force broadcast is set, the packet will be broadcast to the client */ | 78 | /* send a dhcp packet, if force broadcast is set, the packet will be broadcast to the client */ |
79 | static int send_packet(struct dhcpMessage *payload, int force_broadcast) | 79 | static int send_packet(struct dhcpMessage *dhcp_pkt, int force_broadcast) |
80 | { | 80 | { |
81 | if (payload->gateway_nip) | 81 | if (dhcp_pkt->gateway_nip) |
82 | return send_packet_to_relay(payload); | 82 | return send_packet_to_relay(dhcp_pkt); |
83 | return send_packet_to_client(payload, force_broadcast); | 83 | return send_packet_to_client(dhcp_pkt, force_broadcast); |
84 | } | 84 | } |
85 | 85 | ||
86 | 86 | ||
@@ -201,7 +201,7 @@ int FAST_FUNC send_NAK(struct dhcpMessage *oldpacket) | |||
201 | 201 | ||
202 | init_packet(&packet, oldpacket, DHCPNAK); | 202 | init_packet(&packet, oldpacket, DHCPNAK); |
203 | 203 | ||
204 | DEBUG("Sending NAK"); | 204 | log1("Sending NAK"); |
205 | return send_packet(&packet, 1); | 205 | return send_packet(&packet, 1); |
206 | } | 206 | } |
207 | 207 | ||