aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/udhcp/Config.in10
-rw-r--r--networking/udhcp/common.c6
-rw-r--r--networking/udhcp/dhcpc.c18
-rw-r--r--networking/udhcp/dhcpd.c2
-rw-r--r--networking/udhcp/libbb_udhcp.h2
5 files changed, 27 insertions, 11 deletions
diff --git a/networking/udhcp/Config.in b/networking/udhcp/Config.in
index 773293744..3954b467f 100644
--- a/networking/udhcp/Config.in
+++ b/networking/udhcp/Config.in
@@ -37,6 +37,16 @@ config CONFIG_APP_UDHCPC
37 37
38 See http://udhcp.busybox.net for further details. 38 See http://udhcp.busybox.net for further details.
39 39
40config CONFIG_FEATURE_UDHCP_SYSLOG
41 bool "Log udhcp messages to syslog"
42 default n
43 depends on CONFIG_APP_UDHCPD || CONFIG_APP_UDHCPC
44 help
45 If not daemonized, udhcpd prints its messages to stdout/stderr.
46 If this option is selected, it will also log them to syslog.
47
48 See http://udhcp.busybox.net for further details.
49
40config CONFIG_FEATURE_UDHCP_DEBUG 50config CONFIG_FEATURE_UDHCP_DEBUG
41 bool "Compile udhcp with noisy debugging messages" 51 bool "Compile udhcp with noisy debugging messages"
42 default n 52 default n
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index 1ae65f750..c34b3de26 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -67,7 +67,7 @@ void udhcp_background(const char *pidfile)
67#endif /* __uClinux__ */ 67#endif /* __uClinux__ */
68} 68}
69 69
70void udhcp_start_log_and_pid(const char *client_server, const char *pidfile) 70void udhcp_start_log_and_pid(const char *pidfile)
71{ 71{
72 int pid_fd; 72 int pid_fd;
73 73
@@ -82,9 +82,9 @@ void udhcp_start_log_and_pid(const char *client_server, const char *pidfile)
82 setlinebuf(stdout); 82 setlinebuf(stdout);
83 83
84 if (ENABLE_FEATURE_UDHCP_SYSLOG) { 84 if (ENABLE_FEATURE_UDHCP_SYSLOG) {
85 openlog(client_server, LOG_PID, LOG_LOCAL0); 85 openlog(bb_applet_name, LOG_PID, LOG_LOCAL0);
86 logmode |= LOGMODE_SYSLOG; 86 logmode |= LOGMODE_SYSLOG;
87 } 87 }
88 88
89 bb_info_msg("%s (v%s) started", client_server, BB_VER); 89 bb_info_msg("%s (v%s) started", bb_applet_name, BB_VER);
90} 90}
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 5b2612e56..eb1f1db8d 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -32,6 +32,11 @@
32#include "signalpipe.h" 32#include "signalpipe.h"
33 33
34static int state; 34static int state;
35/* Something is definitely wrong here. IPv4 addresses
36 * in variables of type long?? BTW, we use inet_ntoa()
37 * in the code. Manpage says that struct in_addr has a member of type long (!)
38 * which holds IPv4 address, and the struct is passed by value (!!)
39 */
35static unsigned long requested_ip; /* = 0 */ 40static unsigned long requested_ip; /* = 0 */
36static unsigned long server_addr; 41static unsigned long server_addr;
37static unsigned long timeout; 42static unsigned long timeout;
@@ -267,7 +272,7 @@ int udhcpc_main(int argc, char *argv[])
267 } 272 }
268 273
269 /* Start the log, sanitize fd's, and write a pid file */ 274 /* Start the log, sanitize fd's, and write a pid file */
270 udhcp_start_log_and_pid("udhcpc", client_config.pidfile); 275 udhcp_start_log_and_pid(client_config.pidfile);
271 276
272 if (read_interface(client_config.interface, &client_config.ifindex, 277 if (read_interface(client_config.interface, &client_config.ifindex,
273 NULL, client_config.arp) < 0) 278 NULL, client_config.arp) < 0)
@@ -446,8 +451,9 @@ int udhcpc_main(int argc, char *argv[])
446 case INIT_SELECTING: 451 case INIT_SELECTING:
447 /* Must be a DHCPOFFER to one of our xid's */ 452 /* Must be a DHCPOFFER to one of our xid's */
448 if (*message == DHCPOFFER) { 453 if (*message == DHCPOFFER) {
449 if ((temp = get_option(&packet, DHCP_SERVER_ID))) { 454 temp = get_option(&packet, DHCP_SERVER_ID);
450 memcpy(&server_addr, temp, 4); 455 if (temp) {
456 server_addr = *(uint32_t*)temp;
451 xid = packet.xid; 457 xid = packet.xid;
452 requested_ip = packet.yiaddr; 458 requested_ip = packet.yiaddr;
453 459
@@ -465,12 +471,12 @@ int udhcpc_main(int argc, char *argv[])
465 case RENEWING: 471 case RENEWING:
466 case REBINDING: 472 case REBINDING:
467 if (*message == DHCPACK) { 473 if (*message == DHCPACK) {
468 if (!(temp = get_option(&packet, DHCP_LEASE_TIME))) { 474 temp = get_option(&packet, DHCP_LEASE_TIME);
475 if (!temp) {
469 bb_error_msg("No lease time with ACK, using 1 hour lease"); 476 bb_error_msg("No lease time with ACK, using 1 hour lease");
470 lease = 60 * 60; 477 lease = 60 * 60;
471 } else { 478 } else {
472 memcpy(&lease, temp, 4); 479 lease = ntohl(*(uint32_t*)temp);
473 lease = ntohl(lease);
474 } 480 }
475 481
476 /* enter bound state */ 482 /* enter bound state */
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 8715661b7..bee4ffdb3 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -55,7 +55,7 @@ int udhcpd_main(int argc, char *argv[])
55 read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]); 55 read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
56 56
57 /* Start the log, sanitize fd's, and write a pid file */ 57 /* Start the log, sanitize fd's, and write a pid file */
58 udhcp_start_log_and_pid("udhcpd", server_config.pidfile); 58 udhcp_start_log_and_pid(server_config.pidfile);
59 59
60 if ((option = find_option(server_config.options, DHCP_LEASE_TIME))) { 60 if ((option = find_option(server_config.options, DHCP_LEASE_TIME))) {
61 memcpy(&server_config.lease, option->data + 2, 4); 61 memcpy(&server_config.lease, option->data + 2, 4);
diff --git a/networking/udhcp/libbb_udhcp.h b/networking/udhcp/libbb_udhcp.h
index b353876d2..ab4ad06a4 100644
--- a/networking/udhcp/libbb_udhcp.h
+++ b/networking/udhcp/libbb_udhcp.h
@@ -21,7 +21,7 @@
21#define COMBINED_BINARY 21#define COMBINED_BINARY
22 22
23void udhcp_background(const char *pidfile); 23void udhcp_background(const char *pidfile);
24void udhcp_start_log_and_pid(const char *client_server, const char *pidfile); 24void udhcp_start_log_and_pid(const char *pidfile);
25 25
26void udhcp_run_script(struct dhcpMessage *packet, const char *name); 26void udhcp_run_script(struct dhcpMessage *packet, const char *name);
27 27