aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r--networking/udhcp/dhcpd.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 2de074f9b..79677ee93 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -61,11 +61,11 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc
61 || (dhcp_pkt->flags & htons(BROADCAST_FLAG)) 61 || (dhcp_pkt->flags & htons(BROADCAST_FLAG))
62 || dhcp_pkt->ciaddr == 0 62 || dhcp_pkt->ciaddr == 0
63 ) { 63 ) {
64 log1("Broadcasting packet to client"); 64 log1("broadcasting packet to client");
65 ciaddr = INADDR_BROADCAST; 65 ciaddr = INADDR_BROADCAST;
66 chaddr = MAC_BCAST_ADDR; 66 chaddr = MAC_BCAST_ADDR;
67 } else { 67 } else {
68 log1("Unicasting packet to client ciaddr"); 68 log1("unicasting packet to client ciaddr");
69 ciaddr = dhcp_pkt->ciaddr; 69 ciaddr = dhcp_pkt->ciaddr;
70 chaddr = dhcp_pkt->chaddr; 70 chaddr = dhcp_pkt->chaddr;
71 } 71 }
@@ -79,7 +79,7 @@ static void send_packet_to_client(struct dhcp_packet *dhcp_pkt, int force_broadc
79/* Send a packet to gateway_nip using the kernel ip stack */ 79/* Send a packet to gateway_nip using the kernel ip stack */
80static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt) 80static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt)
81{ 81{
82 log1("Forwarding packet to relay"); 82 log1("forwarding packet to relay");
83 83
84 udhcp_send_kernel_packet(dhcp_pkt, 84 udhcp_send_kernel_packet(dhcp_pkt,
85 server_config.server_nip, SERVER_PORT, 85 server_config.server_nip, SERVER_PORT,
@@ -214,7 +214,7 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
214 add_server_options(&packet); 214 add_server_options(&packet);
215 215
216 addr.s_addr = packet.yiaddr; 216 addr.s_addr = packet.yiaddr;
217 bb_info_msg("Sending OFFER of %s", inet_ntoa(addr)); 217 bb_error_msg("sending OFFER of %s", inet_ntoa(addr));
218 /* send_packet emits error message itself if it detects failure */ 218 /* send_packet emits error message itself if it detects failure */
219 send_packet(&packet, /*force_bcast:*/ 0); 219 send_packet(&packet, /*force_bcast:*/ 0);
220} 220}
@@ -226,7 +226,7 @@ static NOINLINE void send_NAK(struct dhcp_packet *oldpacket)
226 226
227 init_packet(&packet, oldpacket, DHCPNAK); 227 init_packet(&packet, oldpacket, DHCPNAK);
228 228
229 log1("Sending NAK"); 229 log1("sending NAK");
230 send_packet(&packet, /*force_bcast:*/ 1); 230 send_packet(&packet, /*force_bcast:*/ 1);
231} 231}
232 232
@@ -247,7 +247,7 @@ static NOINLINE void send_ACK(struct dhcp_packet *oldpacket, uint32_t yiaddr)
247 add_server_options(&packet); 247 add_server_options(&packet);
248 248
249 addr.s_addr = yiaddr; 249 addr.s_addr = yiaddr;
250 bb_info_msg("Sending ACK to %s", inet_ntoa(addr)); 250 bb_error_msg("sending ACK to %s", inet_ntoa(addr));
251 send_packet(&packet, /*force_bcast:*/ 0); 251 send_packet(&packet, /*force_bcast:*/ 0);
252 252
253 p_host_name = (const char*) udhcp_get_option(oldpacket, DHCP_HOST_NAME); 253 p_host_name = (const char*) udhcp_get_option(oldpacket, DHCP_HOST_NAME);
@@ -361,7 +361,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
361 write_pidfile(server_config.pidfile); 361 write_pidfile(server_config.pidfile);
362 /* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */ 362 /* if (!..) bb_perror_msg("can't create pidfile %s", pidfile); */
363 363
364 bb_info_msg("%s (v"BB_VER") started", applet_name); 364 bb_error_msg("started, v"BB_VER);
365 365
366 option = udhcp_find_option(server_config.options, DHCP_LEASE_TIME); 366 option = udhcp_find_option(server_config.options, DHCP_LEASE_TIME);
367 server_config.max_lease_sec = DEFAULT_LEASE_TIME; 367 server_config.max_lease_sec = DEFAULT_LEASE_TIME;
@@ -427,18 +427,18 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
427 goto continue_with_autotime; 427 goto continue_with_autotime;
428 } 428 }
429 if (retval < 0 && errno != EINTR) { 429 if (retval < 0 && errno != EINTR) {
430 log1("Error on select"); 430 log1("error on select");
431 continue; 431 continue;
432 } 432 }
433 433
434 switch (udhcp_sp_read(&rfds)) { 434 switch (udhcp_sp_read(&rfds)) {
435 case SIGUSR1: 435 case SIGUSR1:
436 bb_info_msg("Received SIGUSR1"); 436 bb_error_msg("received %s", "SIGUSR1");
437 write_leases(); 437 write_leases();
438 /* why not just reset the timeout, eh */ 438 /* why not just reset the timeout, eh */
439 goto continue_with_autotime; 439 goto continue_with_autotime;
440 case SIGTERM: 440 case SIGTERM:
441 bb_info_msg("Received SIGTERM"); 441 bb_error_msg("received %s", "SIGTERM");
442 write_leases(); 442 write_leases();
443 goto ret0; 443 goto ret0;
444 case 0: /* no signal: read a packet */ 444 case 0: /* no signal: read a packet */
@@ -451,7 +451,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
451 if (bytes < 0) { 451 if (bytes < 0) {
452 /* bytes can also be -2 ("bad packet data") */ 452 /* bytes can also be -2 ("bad packet data") */
453 if (bytes == -1 && errno != EINTR) { 453 if (bytes == -1 && errno != EINTR) {
454 log1("Read error: %s, reopening socket", strerror(errno)); 454 log1("read error: %s, reopening socket", strerror(errno));
455 close(server_socket); 455 close(server_socket);
456 server_socket = -1; 456 server_socket = -1;
457 } 457 }
@@ -486,7 +486,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
486 /* Look for a static/dynamic lease */ 486 /* Look for a static/dynamic lease */
487 static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr); 487 static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr);
488 if (static_lease_nip) { 488 if (static_lease_nip) {
489 bb_info_msg("Found static lease: %x", static_lease_nip); 489 bb_error_msg("found static lease: %x", static_lease_nip);
490 memcpy(&fake_lease.lease_mac, &packet.chaddr, 6); 490 memcpy(&fake_lease.lease_mac, &packet.chaddr, 6);
491 fake_lease.lease_nip = static_lease_nip; 491 fake_lease.lease_nip = static_lease_nip;
492 fake_lease.expires = 0; 492 fake_lease.expires = 0;
@@ -504,13 +504,13 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
504 switch (state[0]) { 504 switch (state[0]) {
505 505
506 case DHCPDISCOVER: 506 case DHCPDISCOVER:
507 log1("Received DISCOVER"); 507 log1("received %s", "DISCOVER");
508 508
509 send_offer(&packet, static_lease_nip, lease, requested_ip_opt, arpping_ms); 509 send_offer(&packet, static_lease_nip, lease, requested_ip_opt, arpping_ms);
510 break; 510 break;
511 511
512 case DHCPREQUEST: 512 case DHCPREQUEST:
513 log1("Received REQUEST"); 513 log1("received %s", "REQUEST");
514/* RFC 2131: 514/* RFC 2131:
515 515
516o DHCPREQUEST generated during SELECTING state: 516o DHCPREQUEST generated during SELECTING state:
@@ -635,7 +635,7 @@ o DHCPREQUEST generated during REBINDING state:
635 * chaddr must be filled in, 635 * chaddr must be filled in,
636 * ciaddr must be 0 (we do not check this) 636 * ciaddr must be 0 (we do not check this)
637 */ 637 */
638 log1("Received DECLINE"); 638 log1("received %s", "DECLINE");
639 if (server_id_opt 639 if (server_id_opt
640 && requested_ip_opt 640 && requested_ip_opt
641 && lease /* chaddr matches this lease */ 641 && lease /* chaddr matches this lease */
@@ -655,7 +655,7 @@ o DHCPREQUEST generated during REBINDING state:
655 * chaddr must be filled in, 655 * chaddr must be filled in,
656 * ciaddr must be filled in 656 * ciaddr must be filled in
657 */ 657 */
658 log1("Received RELEASE"); 658 log1("received %s", "RELEASE");
659 if (server_id_opt 659 if (server_id_opt
660 && lease /* chaddr matches this lease */ 660 && lease /* chaddr matches this lease */
661 && packet.ciaddr == lease->lease_nip 661 && packet.ciaddr == lease->lease_nip
@@ -665,7 +665,7 @@ o DHCPREQUEST generated during REBINDING state:
665 break; 665 break;
666 666
667 case DHCPINFORM: 667 case DHCPINFORM:
668 log1("Received INFORM"); 668 log1("received %s", "INFORM");
669 send_inform(&packet); 669 send_inform(&packet);
670 break; 670 break;
671 } 671 }