diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-02 15:51:50 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-02 15:51:50 +0200 |
| commit | 949e9621d10faada3bb55a4aa206df44e7d39ae8 (patch) | |
| tree | 63778eac77dc9b9fb6f30410a581d87f7ae2b707 | |
| parent | 698cdef538f51bb85b68d591b1e42eb6b04d891c (diff) | |
| download | busybox-w32-949e9621d10faada3bb55a4aa206df44e7d39ae8.tar.gz busybox-w32-949e9621d10faada3bb55a4aa206df44e7d39ae8.tar.bz2 busybox-w32-949e9621d10faada3bb55a4aa206df44e7d39ae8.zip | |
udhcpc: get rid of client_data.fqdn field
function old new delta
attach_option 253 276 +23
udhcpc_main 2582 2588 +6
udhcpc6_main 2579 2571 -8
add_client_options 175 158 -17
udhcp_insert_new_option 169 138 -31
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 29/-56) Total: -27 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | networking/udhcp/common.c | 13 | ||||
| -rw-r--r-- | networking/udhcp/common.h | 5 | ||||
| -rw-r--r-- | networking/udhcp/d6_dhcpc.c | 40 | ||||
| -rw-r--r-- | networking/udhcp/dhcpc.c | 71 | ||||
| -rw-r--r-- | networking/udhcp/dhcpc.h | 4 |
5 files changed, 57 insertions, 76 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 7929950f5..b325c4112 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c | |||
| @@ -424,7 +424,6 @@ int FAST_FUNC udhcp_str2nip(const char *str, void *arg) | |||
| 424 | void* FAST_FUNC udhcp_insert_new_option( | 424 | void* FAST_FUNC udhcp_insert_new_option( |
| 425 | struct option_set **opt_list, | 425 | struct option_set **opt_list, |
| 426 | unsigned code, | 426 | unsigned code, |
| 427 | const void *buffer, | ||
| 428 | unsigned length, | 427 | unsigned length, |
| 429 | bool dhcpv6) | 428 | bool dhcpv6) |
| 430 | { | 429 | { |
| @@ -434,17 +433,15 @@ void* FAST_FUNC udhcp_insert_new_option( | |||
| 434 | log2("attaching option %02x to list", code); | 433 | log2("attaching option %02x to list", code); |
| 435 | new = xmalloc(sizeof(*new)); | 434 | new = xmalloc(sizeof(*new)); |
| 436 | if (!dhcpv6) { | 435 | if (!dhcpv6) { |
| 437 | new->data = xmalloc(length + OPT_DATA); | 436 | new->data = xzalloc(length + OPT_DATA); |
| 438 | new->data[OPT_CODE] = code; | 437 | new->data[OPT_CODE] = code; |
| 439 | new->data[OPT_LEN] = length; | 438 | new->data[OPT_LEN] = length; |
| 440 | memcpy(new->data + OPT_DATA, buffer, length); | ||
| 441 | } else { | 439 | } else { |
| 442 | new->data = xmalloc(length + D6_OPT_DATA); | 440 | new->data = xzalloc(length + D6_OPT_DATA); |
| 443 | new->data[D6_OPT_CODE] = code >> 8; | 441 | new->data[D6_OPT_CODE] = code >> 8; |
| 444 | new->data[D6_OPT_CODE + 1] = code & 0xff; | 442 | new->data[D6_OPT_CODE + 1] = code & 0xff; |
| 445 | new->data[D6_OPT_LEN] = length >> 8; | 443 | new->data[D6_OPT_LEN] = length >> 8; |
| 446 | new->data[D6_OPT_LEN + 1] = length & 0xff; | 444 | new->data[D6_OPT_LEN + 1] = length & 0xff; |
| 447 | memcpy(new->data + D6_OPT_DATA, buffer, length); | ||
| 448 | } | 445 | } |
| 449 | 446 | ||
| 450 | curr = opt_list; | 447 | curr = opt_list; |
| @@ -498,7 +495,11 @@ static NOINLINE void attach_option( | |||
| 498 | existing = udhcp_find_option(*opt_list, optflag->code); | 495 | existing = udhcp_find_option(*opt_list, optflag->code); |
| 499 | if (!existing) { | 496 | if (!existing) { |
| 500 | /* make a new option */ | 497 | /* make a new option */ |
| 501 | udhcp_insert_new_option(opt_list, optflag->code, buffer, length, dhcpv6); | 498 | uint8_t *p = udhcp_insert_new_option(opt_list, optflag->code, length, dhcpv6); |
| 499 | if (!dhcpv6) | ||
| 500 | memcpy(p + OPT_DATA, buffer, length); | ||
| 501 | else | ||
| 502 | memcpy(p + D6_OPT_DATA, buffer, length); | ||
| 502 | goto ret; | 503 | goto ret; |
| 503 | } | 504 | } |
| 504 | 505 | ||
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index e5af62874..48a23792a 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
| @@ -321,12 +321,11 @@ void udhcp_dump_packet(struct dhcp_packet *packet) FAST_FUNC; | |||
| 321 | int FAST_FUNC udhcp_str2nip(const char *str, void *arg); | 321 | int FAST_FUNC udhcp_str2nip(const char *str, void *arg); |
| 322 | 322 | ||
| 323 | #if !ENABLE_UDHCPC6 | 323 | #if !ENABLE_UDHCPC6 |
| 324 | #define udhcp_insert_new_option(opt_list, code, buffer, length, dhcpv6) \ | 324 | #define udhcp_insert_new_option(opt_list, code, length, dhcpv6) \ |
| 325 | udhcp_insert_new_option(opt_list, code, buffer, length) | 325 | udhcp_insert_new_option(opt_list, code, length) |
| 326 | #endif | 326 | #endif |
| 327 | void* FAST_FUNC udhcp_insert_new_option(struct option_set **opt_list, | 327 | void* FAST_FUNC udhcp_insert_new_option(struct option_set **opt_list, |
| 328 | unsigned code, | 328 | unsigned code, |
| 329 | const void *buffer, | ||
| 330 | unsigned length, | 329 | unsigned length, |
| 331 | bool dhcpv6); | 330 | bool dhcpv6); |
| 332 | 331 | ||
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 3fd1fa7ce..c68dc8c4f 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
| @@ -1111,17 +1111,6 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou | |||
| 1111 | client_data.state = RELEASED; | 1111 | client_data.state = RELEASED; |
| 1112 | } | 1112 | } |
| 1113 | 1113 | ||
| 1114 | ///static uint8_t* alloc_dhcp_option(int code, const char *str, int extra) | ||
| 1115 | ///{ | ||
| 1116 | /// uint8_t *storage; | ||
| 1117 | /// int len = strnlen(str, 255); | ||
| 1118 | /// storage = xzalloc(len + extra + OPT_DATA); | ||
| 1119 | /// storage[OPT_CODE] = code; | ||
| 1120 | /// storage[OPT_LEN] = len + extra; | ||
| 1121 | /// memcpy(storage + extra + OPT_DATA, str, len); | ||
| 1122 | /// return storage; | ||
| 1123 | ///} | ||
| 1124 | |||
| 1125 | #if BB_MMU | 1114 | #if BB_MMU |
| 1126 | static void client_background(void) | 1115 | static void client_background(void) |
| 1127 | { | 1116 | { |
| @@ -1283,23 +1272,24 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
| 1283 | free(optstr); | 1272 | free(optstr); |
| 1284 | } | 1273 | } |
| 1285 | 1274 | ||
| 1286 | if (d6_read_interface(client_data.interface, | ||
| 1287 | &client_data.ifindex, | ||
| 1288 | &client6_data.ll_ip6, | ||
| 1289 | client_data_client_mac) | ||
| 1290 | ) { | ||
| 1291 | return 1; | ||
| 1292 | } | ||
| 1293 | |||
| 1294 | clientid_mac_ptr = NULL; | 1275 | clientid_mac_ptr = NULL; |
| 1295 | if (!udhcp_find_option(client_data.options, D6_OPT_CLIENTID)) { | 1276 | if (!udhcp_find_option(client_data.options, D6_OPT_CLIENTID)) { |
| 1296 | /* not set, set the default client ID */ | 1277 | /* not set, set the default client ID */ |
| 1297 | client_data.clientid[1] = 3; /* DUID-LL */ | ||
| 1298 | client_data.clientid[3] = 1; /* ethernet */ | ||
| 1299 | clientid_mac_ptr = udhcp_insert_new_option( | 1278 | clientid_mac_ptr = udhcp_insert_new_option( |
| 1300 | &client_data.options, D6_OPT_CLIENTID, | 1279 | &client_data.options, D6_OPT_CLIENTID, |
| 1301 | client_data.clientid, 2+2 + 6, /*dhcp6:*/ 1); | 1280 | 2+2 + 6, /*dhcp6:*/ 1); |
| 1302 | clientid_mac_ptr += 2+2 + 2+2; /* skip option code, len, DUID-LL, ethernet */ | 1281 | clientid_mac_ptr += 2+2; /* skip option code, len */ |
| 1282 | clientid_mac_ptr[1] = 3; /* DUID-LL */ | ||
| 1283 | clientid_mac_ptr[3] = 1; /* type: ethernet */ | ||
| 1284 | clientid_mac_ptr += 2+2; /* skip DUID-LL, ethernet */ | ||
| 1285 | } | ||
| 1286 | |||
| 1287 | if (d6_read_interface(client_data.interface, | ||
| 1288 | &client_data.ifindex, | ||
| 1289 | &client6_data.ll_ip6, | ||
| 1290 | client_data.client_mac) | ||
| 1291 | ) { | ||
| 1292 | return 1; | ||
| 1303 | } | 1293 | } |
| 1304 | 1294 | ||
| 1305 | #if !BB_MMU | 1295 | #if !BB_MMU |
| @@ -1386,13 +1376,13 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
| 1386 | if (d6_read_interface(client_data.interface, | 1376 | if (d6_read_interface(client_data.interface, |
| 1387 | &client_data.ifindex, | 1377 | &client_data.ifindex, |
| 1388 | &client6_data.ll_ip6, | 1378 | &client6_data.ll_ip6, |
| 1389 | client_data_client_mac) | 1379 | client_data.client_mac) |
| 1390 | ) { | 1380 | ) { |
| 1391 | goto ret0; /* iface is gone? */ | 1381 | goto ret0; /* iface is gone? */ |
| 1392 | } | 1382 | } |
| 1393 | 1383 | ||
| 1394 | if (clientid_mac_ptr) | 1384 | if (clientid_mac_ptr) |
| 1395 | memcpy(clientid_mac_ptr, client_data_client_mac, 6); | 1385 | memcpy(clientid_mac_ptr, client_data.client_mac, 6); |
| 1396 | 1386 | ||
| 1397 | switch (client_data.state) { | 1387 | switch (client_data.state) { |
| 1398 | case INIT_SELECTING: | 1388 | case INIT_SELECTING: |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 16228f048..ab669d2b5 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
| @@ -609,7 +609,7 @@ static void init_packet(struct dhcp_packet *packet, char type) | |||
| 609 | secs = client_data.last_secs - client_data.first_secs; | 609 | secs = client_data.last_secs - client_data.first_secs; |
| 610 | packet->secs = (secs < 0xffff) ? htons(secs) : 0xffff; | 610 | packet->secs = (secs < 0xffff) ? htons(secs) : 0xffff; |
| 611 | 611 | ||
| 612 | memcpy(packet->chaddr, client_data_client_mac, 6); | 612 | memcpy(packet->chaddr, client_data.client_mac, 6); |
| 613 | } | 613 | } |
| 614 | 614 | ||
| 615 | static void add_client_options(struct dhcp_packet *packet) | 615 | static void add_client_options(struct dhcp_packet *packet) |
| @@ -635,9 +635,6 @@ static void add_client_options(struct dhcp_packet *packet) | |||
| 635 | packet->options[end + OPT_DATA + len] = DHCP_END; | 635 | packet->options[end + OPT_DATA + len] = DHCP_END; |
| 636 | } | 636 | } |
| 637 | 637 | ||
| 638 | if (client_data.fqdn) | ||
| 639 | udhcp_add_binary_option(packet, client_data.fqdn); | ||
| 640 | |||
| 641 | /* Request broadcast replies if we have no IP addr */ | 638 | /* Request broadcast replies if we have no IP addr */ |
| 642 | if ((option_mask32 & OPT_B) && packet->ciaddr == 0) | 639 | if ((option_mask32 & OPT_B) && packet->ciaddr == 0) |
| 643 | packet->flags |= htons(BROADCAST_FLAG); | 640 | packet->flags |= htons(BROADCAST_FLAG); |
| @@ -715,7 +712,6 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested) | |||
| 715 | udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested); | 712 | udhcp_add_simple_option(&packet, DHCP_REQUESTED_IP, requested); |
| 716 | 713 | ||
| 717 | /* Add options: maxsize, | 714 | /* Add options: maxsize, |
| 718 | * optionally: fqdn, client-id, | ||
| 719 | * "param req" option according to -O, options specified with -x | 715 | * "param req" option according to -O, options specified with -x |
| 720 | */ | 716 | */ |
| 721 | add_client_options(&packet); | 717 | add_client_options(&packet); |
| @@ -759,7 +755,6 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste | |||
| 759 | udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); | 755 | udhcp_add_simple_option(&packet, DHCP_SERVER_ID, server); |
| 760 | 756 | ||
| 761 | /* Add options: maxsize, | 757 | /* Add options: maxsize, |
| 762 | * optionally: fqdn, client-id, | ||
| 763 | * "param req" option according to -O, and options specified with -x | 758 | * "param req" option according to -O, and options specified with -x |
| 764 | */ | 759 | */ |
| 765 | add_client_options(&packet); | 760 | add_client_options(&packet); |
| @@ -804,7 +799,6 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) | |||
| 804 | packet.ciaddr = ciaddr; | 799 | packet.ciaddr = ciaddr; |
| 805 | 800 | ||
| 806 | /* Add options: maxsize, | 801 | /* Add options: maxsize, |
| 807 | * optionally: fqdn, client-id, | ||
| 808 | * "param req" option according to -O, and options specified with -x | 802 | * "param req" option according to -O, and options specified with -x |
| 809 | */ | 803 | */ |
| 810 | add_client_options(&packet); | 804 | add_client_options(&packet); |
| @@ -1154,17 +1148,6 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip) | |||
| 1154 | client_data.state = RELEASED; | 1148 | client_data.state = RELEASED; |
| 1155 | } | 1149 | } |
| 1156 | 1150 | ||
| 1157 | static uint8_t* alloc_dhcp_option(int code, const char *str, int extra) | ||
| 1158 | { | ||
| 1159 | uint8_t *storage; | ||
| 1160 | int len = strnlen(str, 255); | ||
| 1161 | storage = xzalloc(len + extra + OPT_DATA); | ||
| 1162 | storage[OPT_CODE] = code; | ||
| 1163 | storage[OPT_LEN] = len + extra; | ||
| 1164 | memcpy(storage + extra + OPT_DATA, str, len); | ||
| 1165 | return storage; | ||
| 1166 | } | ||
| 1167 | |||
| 1168 | #if BB_MMU | 1151 | #if BB_MMU |
| 1169 | static void client_background(void) | 1152 | static void client_background(void) |
| 1170 | { | 1153 | { |
| @@ -1284,8 +1267,13 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
| 1284 | IF_UDHCP_VERBOSE(, &dhcp_verbose) | 1267 | IF_UDHCP_VERBOSE(, &dhcp_verbose) |
| 1285 | ); | 1268 | ); |
| 1286 | if (opt & OPT_F) { | 1269 | if (opt & OPT_F) { |
| 1270 | char *p; | ||
| 1271 | unsigned len; | ||
| 1287 | /* FQDN option format: [0x51][len][flags][0][0]<fqdn> */ | 1272 | /* FQDN option format: [0x51][len][flags][0][0]<fqdn> */ |
| 1288 | client_data.fqdn = alloc_dhcp_option(DHCP_FQDN, str_F, 3); | 1273 | len = strlen(str_F); |
| 1274 | p = udhcp_insert_new_option( | ||
| 1275 | &client_data.options, DHCP_FQDN, | ||
| 1276 | len + 3, /*dhcp6:*/ 0); | ||
| 1289 | /* Flag bits: 0000NEOS | 1277 | /* Flag bits: 0000NEOS |
| 1290 | * S: 1 = Client requests server to update A RR in DNS as well as PTR | 1278 | * S: 1 = Client requests server to update A RR in DNS as well as PTR |
| 1291 | * O: 1 = Server indicates to client that DNS has been updated regardless | 1279 | * O: 1 = Server indicates to client that DNS has been updated regardless |
| @@ -1294,9 +1282,10 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
| 1294 | * N: 1 = Client requests server to not update DNS (S must be 0 then) | 1282 | * N: 1 = Client requests server to not update DNS (S must be 0 then) |
| 1295 | * Two [0] bytes which follow are deprecated and must be 0. | 1283 | * Two [0] bytes which follow are deprecated and must be 0. |
| 1296 | */ | 1284 | */ |
| 1297 | client_data.fqdn[OPT_DATA + 0] = 0x1; | 1285 | p[OPT_DATA + 0] = 0x1; |
| 1298 | /*client_data.fqdn[OPT_DATA + 1] = 0; - xzalloc did it */ | 1286 | /*p[OPT_DATA + 1] = 0; - xzalloc did it */ |
| 1299 | /*client_data.fqdn[OPT_DATA + 2] = 0; */ | 1287 | /*p[OPT_DATA + 2] = 0; */ |
| 1288 | memcpy(p + OPT_DATA + 3, str_F, len); /* do not store NUL byte */ | ||
| 1300 | } | 1289 | } |
| 1301 | if (opt & OPT_r) | 1290 | if (opt & OPT_r) |
| 1302 | requested_ip = inet_addr(str_r); | 1291 | requested_ip = inet_addr(str_r); |
| @@ -1333,31 +1322,35 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
| 1333 | free(optstr); | 1322 | free(optstr); |
| 1334 | } | 1323 | } |
| 1335 | if (str_V[0] != '\0') { | 1324 | if (str_V[0] != '\0') { |
| 1325 | char *p; | ||
| 1326 | unsigned len; | ||
| 1336 | //msg added 2021-06 | 1327 | //msg added 2021-06 |
| 1337 | bb_error_msg("option -V VENDOR is deprecated, use -x vendor:VENDOR"); | 1328 | bb_error_msg("option -V VENDOR is deprecated, use -x vendor:VENDOR"); |
| 1338 | udhcp_insert_new_option( | 1329 | len = strlen(str_V); |
| 1330 | p = udhcp_insert_new_option( | ||
| 1339 | &client_data.options, DHCP_VENDOR, | 1331 | &client_data.options, DHCP_VENDOR, |
| 1340 | str_V, strlen(str_V), /*dhcp6:*/ 0); | 1332 | len, /*dhcp6:*/ 0); |
| 1333 | memcpy(p + OPT_DATA, str_V, len); /* do not store NUL byte */ | ||
| 1334 | } | ||
| 1335 | |||
| 1336 | clientid_mac_ptr = NULL; | ||
| 1337 | if (!(opt & OPT_C) && !udhcp_find_option(client_data.options, DHCP_CLIENT_ID)) { | ||
| 1338 | /* not suppressed and not set, create default client ID */ | ||
| 1339 | clientid_mac_ptr = udhcp_insert_new_option( | ||
| 1340 | &client_data.options, DHCP_CLIENT_ID, | ||
| 1341 | 1 + 6, /*dhcp6:*/ 0); | ||
| 1342 | clientid_mac_ptr[OPT_DATA] = 1; /* type: ethernet */ | ||
| 1343 | clientid_mac_ptr += OPT_DATA + 1; /* skip option code, len, ethernet */ | ||
| 1341 | } | 1344 | } |
| 1342 | 1345 | ||
| 1343 | if (udhcp_read_interface(client_data.interface, | 1346 | if (udhcp_read_interface(client_data.interface, |
| 1344 | &client_data.ifindex, | 1347 | &client_data.ifindex, |
| 1345 | NULL, | 1348 | NULL, |
| 1346 | client_data_client_mac) | 1349 | client_data.client_mac) |
| 1347 | ) { | 1350 | ) { |
| 1348 | return 1; | 1351 | return 1; |
| 1349 | } | 1352 | } |
| 1350 | 1353 | ||
| 1351 | clientid_mac_ptr = NULL; | ||
| 1352 | if (!(opt & OPT_C) && !udhcp_find_option(client_data.options, DHCP_CLIENT_ID)) { | ||
| 1353 | /* not suppressed and not set, set the default client ID */ | ||
| 1354 | client_data_client_mac[-1] = 1; /* type: ethernet */ | ||
| 1355 | clientid_mac_ptr = udhcp_insert_new_option( | ||
| 1356 | &client_data.options, DHCP_CLIENT_ID, | ||
| 1357 | client_data_client_mac - 1, 1 + 6, /*dhcp6:*/ 0); | ||
| 1358 | clientid_mac_ptr += 3; /* skip option code, len, ethernet */ | ||
| 1359 | } | ||
| 1360 | |||
| 1361 | #if !BB_MMU | 1354 | #if !BB_MMU |
| 1362 | /* on NOMMU reexec (i.e., background) early */ | 1355 | /* on NOMMU reexec (i.e., background) early */ |
| 1363 | if (!(opt & OPT_f)) { | 1356 | if (!(opt & OPT_f)) { |
| @@ -1443,12 +1436,12 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
| 1443 | if (udhcp_read_interface(client_data.interface, | 1436 | if (udhcp_read_interface(client_data.interface, |
| 1444 | &client_data.ifindex, | 1437 | &client_data.ifindex, |
| 1445 | NULL, | 1438 | NULL, |
| 1446 | client_data_client_mac) | 1439 | client_data.client_mac) |
| 1447 | ) { | 1440 | ) { |
| 1448 | goto ret0; /* iface is gone? */ | 1441 | goto ret0; /* iface is gone? */ |
| 1449 | } | 1442 | } |
| 1450 | if (clientid_mac_ptr) | 1443 | if (clientid_mac_ptr) |
| 1451 | memcpy(clientid_mac_ptr, client_data_client_mac, 6); | 1444 | memcpy(clientid_mac_ptr, client_data.client_mac, 6); |
| 1452 | 1445 | ||
| 1453 | switch (client_data.state) { | 1446 | switch (client_data.state) { |
| 1454 | case INIT_SELECTING: | 1447 | case INIT_SELECTING: |
| @@ -1643,7 +1636,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
| 1643 | 1636 | ||
| 1644 | /* Ignore packets that aren't for us */ | 1637 | /* Ignore packets that aren't for us */ |
| 1645 | if (packet.hlen != 6 | 1638 | if (packet.hlen != 6 |
| 1646 | || memcmp(packet.chaddr, client_data_client_mac, 6) != 0 | 1639 | || memcmp(packet.chaddr, client_data.client_mac, 6) != 0 |
| 1647 | ) { | 1640 | ) { |
| 1648 | //FIXME: need to also check that last 10 bytes are zero | 1641 | //FIXME: need to also check that last 10 bytes are zero |
| 1649 | log1("chaddr does not match%s", ", ignoring packet"); // log2? | 1642 | log1("chaddr does not match%s", ", ignoring packet"); // log2? |
| @@ -1755,7 +1748,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
| 1755 | if (!arpping(requested_ip, | 1748 | if (!arpping(requested_ip, |
| 1756 | NULL, | 1749 | NULL, |
| 1757 | (uint32_t) 0, | 1750 | (uint32_t) 0, |
| 1758 | client_data_client_mac, | 1751 | client_data.client_mac, |
| 1759 | client_data.interface, | 1752 | client_data.interface, |
| 1760 | arpping_ms) | 1753 | arpping_ms) |
| 1761 | ) { | 1754 | ) { |
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h index 5c710963f..cd9ead6bd 100644 --- a/networking/udhcp/dhcpc.h +++ b/networking/udhcp/dhcpc.h | |||
| @@ -8,8 +8,7 @@ | |||
| 8 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | 8 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN |
| 9 | 9 | ||
| 10 | struct client_data_t { | 10 | struct client_data_t { |
| 11 | uint8_t clientid[2+2 + 6]; /* Our mac address (prefixed by padding used for client-id) */ | 11 | uint8_t client_mac[6]; /* Our mac address */ |
| 12 | #define client_data_client_mac (client_data.clientid + 2+2) | ||
| 13 | IF_FEATURE_UDHCP_PORT(uint16_t port;) | 12 | IF_FEATURE_UDHCP_PORT(uint16_t port;) |
| 14 | int ifindex; /* Index number of the interface to use */ | 13 | int ifindex; /* Index number of the interface to use */ |
| 15 | uint8_t opt_mask[256 / 8]; /* Bitmask of options to send (-O option) */ | 14 | uint8_t opt_mask[256 / 8]; /* Bitmask of options to send (-O option) */ |
| @@ -18,7 +17,6 @@ struct client_data_t { | |||
| 18 | char *pidfile; /* Optionally store the process ID */ | 17 | char *pidfile; /* Optionally store the process ID */ |
| 19 | const char *script; /* User script to run at dhcp events */ | 18 | const char *script; /* User script to run at dhcp events */ |
| 20 | struct option_set *options; /* list of DHCP options to send to server */ | 19 | struct option_set *options; /* list of DHCP options to send to server */ |
| 21 | uint8_t *fqdn; /* Optional fully qualified domain name to use */ | ||
| 22 | llist_t *envp; /* list of DHCP options used for env vars */ | 20 | llist_t *envp; /* list of DHCP options used for env vars */ |
| 23 | 21 | ||
| 24 | unsigned first_secs; | 22 | unsigned first_secs; |
