aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-06-17 11:57:09 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-06-17 11:57:09 +0200
commit31af3d5a1dbc750d8646f948ce642e6ae57ce880 (patch)
tree37d72b13f986b1da25def340771b49be4dd3028b /networking/udhcp/dhcpd.c
parentac906fa85e61b4e34161709de777616f858bc945 (diff)
downloadbusybox-w32-31af3d5a1dbc750d8646f948ce642e6ae57ce880.tar.gz
busybox-w32-31af3d5a1dbc750d8646f948ce642e6ae57ce880.tar.bz2
busybox-w32-31af3d5a1dbc750d8646f948ce642e6ae57ce880.zip
udhcp: shorten mac len from 16 to 6 in lease file
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/dhcpd.c')
-rw-r--r--networking/udhcp/dhcpd.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index cbc968401..348246341 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -18,7 +18,7 @@
18 18
19 19
20/* globals */ 20/* globals */
21struct dhcpOfferedAddr *leases; 21struct dyn_lease *leases;
22/* struct server_config_t server_config is in bb_common_bufsiz1 */ 22/* struct server_config_t server_config is in bb_common_bufsiz1 */
23 23
24 24
@@ -27,7 +27,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
27{ 27{
28 fd_set rfds; 28 fd_set rfds;
29 int server_socket = -1, retval, max_sock; 29 int server_socket = -1, retval, max_sock;
30 struct dhcpMessage packet; 30 struct dhcp_packet packet;
31 uint8_t *state, *server_id, *requested; 31 uint8_t *state, *server_id, *requested;
32 uint32_t server_id_aligned = server_id_aligned; /* for compiler */ 32 uint32_t server_id_aligned = server_id_aligned; /* for compiler */
33 uint32_t requested_aligned = requested_aligned; 33 uint32_t requested_aligned = requested_aligned;
@@ -36,7 +36,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
36 unsigned num_ips; 36 unsigned num_ips;
37 unsigned opt; 37 unsigned opt;
38 struct option_set *option; 38 struct option_set *option;
39 struct dhcpOfferedAddr *lease, static_lease; 39 struct dyn_lease *lease, static_lease;
40 IF_FEATURE_UDHCP_PORT(char *str_P;) 40 IF_FEATURE_UDHCP_PORT(char *str_P;)
41 41
42#if ENABLE_FEATURE_UDHCP_PORT 42#if ENABLE_FEATURE_UDHCP_PORT
@@ -170,6 +170,11 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
170 continue; 170 continue;
171 } 171 }
172 172
173 if (packet.hlen != 6) {
174 bb_error_msg("MAC length != 6, ignoring packet");
175 continue;
176 }
177
173 state = get_option(&packet, DHCP_MESSAGE_TYPE); 178 state = get_option(&packet, DHCP_MESSAGE_TYPE);
174 if (state == NULL) { 179 if (state == NULL) {
175 bb_error_msg("no message type option, ignoring packet"); 180 bb_error_msg("no message type option, ignoring packet");
@@ -181,7 +186,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
181 if (static_lease_ip) { 186 if (static_lease_ip) {
182 bb_info_msg("Found static lease: %x", static_lease_ip); 187 bb_info_msg("Found static lease: %x", static_lease_ip);
183 188
184 memcpy(&static_lease.lease_mac16, &packet.chaddr, 16); 189 memcpy(&static_lease.lease_mac, &packet.chaddr, 6);
185 static_lease.lease_nip = static_lease_ip; 190 static_lease.lease_nip = static_lease_ip;
186 static_lease.expires = 0; 191 static_lease.expires = 0;
187 192
@@ -212,7 +217,6 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
212 if (lease) { 217 if (lease) {
213 if (server_id) { 218 if (server_id) {
214 /* SELECTING State */ 219 /* SELECTING State */
215 log1("server_id = %08x", ntohl(server_id_aligned));
216 if (server_id_aligned == server_config.server_nip 220 if (server_id_aligned == server_config.server_nip
217 && requested 221 && requested
218 && requested_aligned == lease->lease_nip 222 && requested_aligned == lease->lease_nip
@@ -242,7 +246,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
242 if (lease) { 246 if (lease) {
243 if (lease_expired(lease)) { 247 if (lease_expired(lease)) {
244 /* probably best if we drop this lease */ 248 /* probably best if we drop this lease */
245 memset(lease->lease_mac16, 0, 16); 249 memset(lease->lease_mac, 0, sizeof(lease->lease_mac));
246 } else { 250 } else {
247 /* make some contention for this address */ 251 /* make some contention for this address */
248 send_NAK(&packet); 252 send_NAK(&packet);
@@ -264,7 +268,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
264 case DHCPDECLINE: 268 case DHCPDECLINE:
265 log1("Received DECLINE"); 269 log1("Received DECLINE");
266 if (lease) { 270 if (lease) {
267 memset(lease->lease_mac16, 0, 16); 271 memset(lease->lease_mac, 0, sizeof(lease->lease_mac));
268 lease->expires = time(NULL) + server_config.decline_time; 272 lease->expires = time(NULL) + server_config.decline_time;
269 } 273 }
270 break; 274 break;