diff options
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r-- | networking/udhcp/dhcpd.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index b481e6ef2..8715661b7 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c | |||
@@ -66,7 +66,7 @@ int udhcpd_main(int argc, char *argv[]) | |||
66 | /* Sanity check */ | 66 | /* Sanity check */ |
67 | num_ips = ntohl(server_config.end) - ntohl(server_config.start) + 1; | 67 | num_ips = ntohl(server_config.end) - ntohl(server_config.start) + 1; |
68 | if (server_config.max_leases > num_ips) { | 68 | if (server_config.max_leases > num_ips) { |
69 | LOG(LOG_ERR, "max_leases value (%lu) not sane, " | 69 | bb_error_msg("max_leases value (%lu) not sane, " |
70 | "setting to %lu instead", | 70 | "setting to %lu instead", |
71 | server_config.max_leases, num_ips); | 71 | server_config.max_leases, num_ips); |
72 | server_config.max_leases = num_ips; | 72 | server_config.max_leases = num_ips; |
@@ -90,7 +90,7 @@ int udhcpd_main(int argc, char *argv[]) | |||
90 | 90 | ||
91 | if (server_socket < 0) | 91 | if (server_socket < 0) |
92 | if ((server_socket = listen_socket(INADDR_ANY, SERVER_PORT, server_config.interface)) < 0) { | 92 | if ((server_socket = listen_socket(INADDR_ANY, SERVER_PORT, server_config.interface)) < 0) { |
93 | LOG(LOG_ERR, "FATAL: couldn't create server socket, %m"); | 93 | bb_perror_msg("FATAL: couldn't create server socket"); |
94 | return 2; | 94 | return 2; |
95 | } | 95 | } |
96 | 96 | ||
@@ -109,19 +109,19 @@ int udhcpd_main(int argc, char *argv[]) | |||
109 | timeout_end = time(0) + server_config.auto_time; | 109 | timeout_end = time(0) + server_config.auto_time; |
110 | continue; | 110 | continue; |
111 | } else if (retval < 0 && errno != EINTR) { | 111 | } else if (retval < 0 && errno != EINTR) { |
112 | DEBUG(LOG_INFO, "error on select"); | 112 | DEBUG("error on select"); |
113 | continue; | 113 | continue; |
114 | } | 114 | } |
115 | 115 | ||
116 | switch (udhcp_sp_read(&rfds)) { | 116 | switch (udhcp_sp_read(&rfds)) { |
117 | case SIGUSR1: | 117 | case SIGUSR1: |
118 | LOG(LOG_INFO, "Received a SIGUSR1"); | 118 | bb_info_msg("Received a SIGUSR1"); |
119 | write_leases(); | 119 | write_leases(); |
120 | /* why not just reset the timeout, eh */ | 120 | /* why not just reset the timeout, eh */ |
121 | timeout_end = time(0) + server_config.auto_time; | 121 | timeout_end = time(0) + server_config.auto_time; |
122 | continue; | 122 | continue; |
123 | case SIGTERM: | 123 | case SIGTERM: |
124 | LOG(LOG_INFO, "Received a SIGTERM"); | 124 | bb_info_msg("Received a SIGTERM"); |
125 | return 0; | 125 | return 0; |
126 | case 0: break; /* no signal */ | 126 | case 0: break; /* no signal */ |
127 | default: continue; /* signal or error (probably EINTR) */ | 127 | default: continue; /* signal or error (probably EINTR) */ |
@@ -129,7 +129,7 @@ int udhcpd_main(int argc, char *argv[]) | |||
129 | 129 | ||
130 | if ((bytes = udhcp_get_packet(&packet, server_socket)) < 0) { /* this waits for a packet - idle */ | 130 | if ((bytes = udhcp_get_packet(&packet, server_socket)) < 0) { /* this waits for a packet - idle */ |
131 | if (bytes == -1 && errno != EINTR) { | 131 | if (bytes == -1 && errno != EINTR) { |
132 | DEBUG(LOG_INFO, "error on read, %m, reopening socket"); | 132 | DEBUG("error on read, %s, reopening socket", strerror(errno)); |
133 | close(server_socket); | 133 | close(server_socket); |
134 | server_socket = -1; | 134 | server_socket = -1; |
135 | } | 135 | } |
@@ -137,7 +137,7 @@ int udhcpd_main(int argc, char *argv[]) | |||
137 | } | 137 | } |
138 | 138 | ||
139 | if ((state = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) { | 139 | if ((state = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) { |
140 | DEBUG(LOG_ERR, "couldn't get option from packet, ignoring"); | 140 | bb_error_msg("Couldn't get option from packet, ignoring"); |
141 | continue; | 141 | continue; |
142 | } | 142 | } |
143 | 143 | ||
@@ -146,7 +146,7 @@ int udhcpd_main(int argc, char *argv[]) | |||
146 | 146 | ||
147 | if(static_lease_ip) | 147 | if(static_lease_ip) |
148 | { | 148 | { |
149 | printf("Found static lease: %x\n", static_lease_ip); | 149 | bb_info_msg("Found static lease: %x", static_lease_ip); |
150 | 150 | ||
151 | memcpy(&static_lease.chaddr, &packet.chaddr, 16); | 151 | memcpy(&static_lease.chaddr, &packet.chaddr, 16); |
152 | static_lease.yiaddr = static_lease_ip; | 152 | static_lease.yiaddr = static_lease_ip; |
@@ -162,14 +162,14 @@ int udhcpd_main(int argc, char *argv[]) | |||
162 | 162 | ||
163 | switch (state[0]) { | 163 | switch (state[0]) { |
164 | case DHCPDISCOVER: | 164 | case DHCPDISCOVER: |
165 | DEBUG(LOG_INFO,"received DISCOVER"); | 165 | DEBUG("Received DISCOVER"); |
166 | 166 | ||
167 | if (sendOffer(&packet) < 0) { | 167 | if (sendOffer(&packet) < 0) { |
168 | LOG(LOG_ERR, "send OFFER failed"); | 168 | bb_error_msg("Send OFFER failed"); |
169 | } | 169 | } |
170 | break; | 170 | break; |
171 | case DHCPREQUEST: | 171 | case DHCPREQUEST: |
172 | DEBUG(LOG_INFO, "received REQUEST"); | 172 | DEBUG("received REQUEST"); |
173 | 173 | ||
174 | requested = get_option(&packet, DHCP_REQUESTED_IP); | 174 | requested = get_option(&packet, DHCP_REQUESTED_IP); |
175 | server_id = get_option(&packet, DHCP_SERVER_ID); | 175 | server_id = get_option(&packet, DHCP_SERVER_ID); |
@@ -180,7 +180,7 @@ int udhcpd_main(int argc, char *argv[]) | |||
180 | if (lease) { | 180 | if (lease) { |
181 | if (server_id) { | 181 | if (server_id) { |
182 | /* SELECTING State */ | 182 | /* SELECTING State */ |
183 | DEBUG(LOG_INFO, "server_id = %08x", ntohl(server_id_align)); | 183 | DEBUG("server_id = %08x", ntohl(server_id_align)); |
184 | if (server_id_align == server_config.server && requested && | 184 | if (server_id_align == server_config.server && requested && |
185 | requested_align == lease->yiaddr) { | 185 | requested_align == lease->yiaddr) { |
186 | sendACK(&packet, lease->yiaddr); | 186 | sendACK(&packet, lease->yiaddr); |
@@ -224,22 +224,22 @@ int udhcpd_main(int argc, char *argv[]) | |||
224 | } | 224 | } |
225 | break; | 225 | break; |
226 | case DHCPDECLINE: | 226 | case DHCPDECLINE: |
227 | DEBUG(LOG_INFO,"received DECLINE"); | 227 | DEBUG("Received DECLINE"); |
228 | if (lease) { | 228 | if (lease) { |
229 | memset(lease->chaddr, 0, 16); | 229 | memset(lease->chaddr, 0, 16); |
230 | lease->expires = time(0) + server_config.decline_time; | 230 | lease->expires = time(0) + server_config.decline_time; |
231 | } | 231 | } |
232 | break; | 232 | break; |
233 | case DHCPRELEASE: | 233 | case DHCPRELEASE: |
234 | DEBUG(LOG_INFO,"received RELEASE"); | 234 | DEBUG("Received RELEASE"); |
235 | if (lease) lease->expires = time(0); | 235 | if (lease) lease->expires = time(0); |
236 | break; | 236 | break; |
237 | case DHCPINFORM: | 237 | case DHCPINFORM: |
238 | DEBUG(LOG_INFO,"received INFORM"); | 238 | DEBUG("Received INFORM"); |
239 | send_inform(&packet); | 239 | send_inform(&packet); |
240 | break; | 240 | break; |
241 | default: | 241 | default: |
242 | LOG(LOG_WARNING, "unsupported DHCP message (%02x) -- ignoring", state[0]); | 242 | bb_info_msg("Unsupported DHCP message (%02x) - ignoring", state[0]); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||