aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/d6_dhcpc.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-05-26 15:01:13 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-05-26 15:03:05 +0200
commitbcb1fc3e6ca6fe902610f507eaf9b0b58a5c583a (patch)
tree7d591d16007a2a162e13b1f601fc33c9115299e8 /networking/udhcp/d6_dhcpc.c
parent818d9e02f2de87aef3ba72c2b3bcec6eed4ef974 (diff)
downloadbusybox-w32-bcb1fc3e6ca6fe902610f507eaf9b0b58a5c583a.tar.gz
busybox-w32-bcb1fc3e6ca6fe902610f507eaf9b0b58a5c583a.tar.bz2
busybox-w32-bcb1fc3e6ca6fe902610f507eaf9b0b58a5c583a.zip
udhcp: rename client_config to client_data, server_config to server_data
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp/d6_dhcpc.c')
-rw-r--r--networking/udhcp/d6_dhcpc.c152
1 files changed, 76 insertions, 76 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 1973af99b..15e9f3924 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -63,7 +63,7 @@
63#include <netpacket/packet.h> 63#include <netpacket/packet.h>
64#include <linux/filter.h> 64#include <linux/filter.h>
65 65
66/* "struct client_config_t client_config" is in bb_common_bufsiz1 */ 66/* "struct client_data_t client_data" is in bb_common_bufsiz1 */
67 67
68static const struct dhcp_optflag d6_optflags[] = { 68static const struct dhcp_optflag d6_optflags[] = {
69#if ENABLE_FEATURE_UDHCPC6_RFC3646 69#if ENABLE_FEATURE_UDHCPC6_RFC3646
@@ -427,7 +427,7 @@ static char **fill_envp(const uint8_t *option, const uint8_t *option_end)
427 client6_data.env_ptr = NULL; 427 client6_data.env_ptr = NULL;
428 client6_data.env_idx = 0; 428 client6_data.env_idx = 0;
429 429
430 *new_env() = xasprintf("interface=%s", client_config.interface); 430 *new_env() = xasprintf("interface=%s", client_data.interface);
431 431
432 if (option) 432 if (option)
433 option_to_env(option, option_end); 433 option_to_env(option, option_end);
@@ -449,8 +449,8 @@ static void d6_run_script(const uint8_t *option, const uint8_t *option_end,
449 envp = fill_envp(option, option_end); 449 envp = fill_envp(option, option_end);
450 450
451 /* call script */ 451 /* call script */
452 log1("executing %s %s", client_config.script, name); 452 log1("executing %s %s", client_data.script, name);
453 argv[0] = (char*) client_config.script; 453 argv[0] = (char*) client_data.script;
454 argv[1] = (char*) name; 454 argv[1] = (char*) name;
455 argv[2] = NULL; 455 argv[2] = NULL;
456 spawn_and_wait(argv); 456 spawn_and_wait(argv);
@@ -486,7 +486,7 @@ static uint8_t *init_d6_packet(struct d6_packet *packet, char type, uint32_t xid
486 packet->d6_xid32 = xid; 486 packet->d6_xid32 = xid;
487 packet->d6_msg_type = type; 487 packet->d6_msg_type = type;
488 488
489 clientid = (void*)client_config.clientid; 489 clientid = (void*)client_data.clientid;
490 return mempcpy(packet->d6_options, clientid, clientid->len + 2+2); 490 return mempcpy(packet->d6_options, clientid, clientid->len + 2+2);
491} 491}
492 492
@@ -499,7 +499,7 @@ static uint8_t *add_d6_client_options(uint8_t *ptr)
499 499
500 ptr += 4; 500 ptr += 4;
501 for (option = 1; option < 256; option++) { 501 for (option = 1; option < 256; option++) {
502 if (client_config.opt_mask[option >> 3] & (1 << (option & 7))) { 502 if (client_data.opt_mask[option >> 3] & (1 << (option & 7))) {
503 ptr[0] = (option >> 8); 503 ptr[0] = (option >> 8);
504 ptr[1] = option; 504 ptr[1] = option;
505 ptr += 2; 505 ptr += 2;
@@ -518,7 +518,7 @@ static uint8_t *add_d6_client_options(uint8_t *ptr)
518 ptr = mempcpy(ptr, &opt_fqdn_req, sizeof(opt_fqdn_req)); 518 ptr = mempcpy(ptr, &opt_fqdn_req, sizeof(opt_fqdn_req));
519#endif 519#endif
520 /* Add -x options if any */ 520 /* Add -x options if any */
521 curr = client_config.options; 521 curr = client_data.options;
522 while (curr) { 522 while (curr) {
523 len = (curr->data[D6_OPT_LEN] << 8) | curr->data[D6_OPT_LEN + 1]; 523 len = (curr->data[D6_OPT_LEN] << 8) | curr->data[D6_OPT_LEN + 1];
524 ptr = mempcpy(ptr, curr->data, D6_OPT_DATA + len); 524 ptr = mempcpy(ptr, curr->data, D6_OPT_DATA + len);
@@ -528,7 +528,7 @@ static uint8_t *add_d6_client_options(uint8_t *ptr)
528 return ptr; 528 return ptr;
529} 529}
530 530
531static int d6_mcast_from_client_config_ifindex(struct d6_packet *packet, uint8_t *end) 531static int d6_mcast_from_client_data_ifindex(struct d6_packet *packet, uint8_t *end)
532{ 532{
533 /* FF02::1:2 is "All_DHCP_Relay_Agents_and_Servers" address */ 533 /* FF02::1:2 is "All_DHCP_Relay_Agents_and_Servers" address */
534 static const uint8_t FF02__1_2[16] = { 534 static const uint8_t FF02__1_2[16] = {
@@ -540,7 +540,7 @@ static int d6_mcast_from_client_config_ifindex(struct d6_packet *packet, uint8_t
540 packet, (end - (uint8_t*) packet), 540 packet, (end - (uint8_t*) packet),
541 /*src*/ &client6_data.ll_ip6, CLIENT_PORT6, 541 /*src*/ &client6_data.ll_ip6, CLIENT_PORT6,
542 /*dst*/ (struct in6_addr*)FF02__1_2, SERVER_PORT6, MAC_BCAST_ADDR, 542 /*dst*/ (struct in6_addr*)FF02__1_2, SERVER_PORT6, MAC_BCAST_ADDR,
543 client_config.ifindex 543 client_data.ifindex
544 ); 544 );
545} 545}
546 546
@@ -671,7 +671,7 @@ static NOINLINE int send_d6_discover(uint32_t xid, struct in6_addr *requested_ip
671 opt_ptr = add_d6_client_options(opt_ptr); 671 opt_ptr = add_d6_client_options(opt_ptr);
672 672
673 bb_info_msg("sending %s", "discover"); 673 bb_info_msg("sending %s", "discover");
674 return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); 674 return d6_mcast_from_client_data_ifindex(&packet, opt_ptr);
675} 675}
676 676
677/* Multicast a DHCPv6 request message 677/* Multicast a DHCPv6 request message
@@ -728,7 +728,7 @@ static NOINLINE int send_d6_select(uint32_t xid)
728 opt_ptr = add_d6_client_options(opt_ptr); 728 opt_ptr = add_d6_client_options(opt_ptr);
729 729
730 bb_info_msg("sending %s", "select"); 730 bb_info_msg("sending %s", "select");
731 return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); 731 return d6_mcast_from_client_data_ifindex(&packet, opt_ptr);
732} 732}
733 733
734/* Unicast or broadcast a DHCP renew message 734/* Unicast or broadcast a DHCP renew message
@@ -806,9 +806,9 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st
806 &packet, (opt_ptr - (uint8_t*) &packet), 806 &packet, (opt_ptr - (uint8_t*) &packet),
807 our_cur_ipv6, CLIENT_PORT6, 807 our_cur_ipv6, CLIENT_PORT6,
808 server_ipv6, SERVER_PORT6, 808 server_ipv6, SERVER_PORT6,
809 client_config.ifindex 809 client_data.ifindex
810 ); 810 );
811 return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); 811 return d6_mcast_from_client_data_ifindex(&packet, opt_ptr);
812} 812}
813 813
814/* Unicast a DHCP release message */ 814/* Unicast a DHCP release message */
@@ -835,7 +835,7 @@ int send_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6)
835 &packet, (opt_ptr - (uint8_t*) &packet), 835 &packet, (opt_ptr - (uint8_t*) &packet),
836 our_cur_ipv6, CLIENT_PORT6, 836 our_cur_ipv6, CLIENT_PORT6,
837 server_ipv6, SERVER_PORT6, 837 server_ipv6, SERVER_PORT6,
838 client_config.ifindex 838 client_data.ifindex
839 ); 839 );
840} 840}
841 841
@@ -903,12 +903,12 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac
903 903
904/*** Main ***/ 904/*** Main ***/
905 905
906/* Values for client_config.listen_mode */ 906/* Values for client_data.listen_mode */
907#define LISTEN_NONE 0 907#define LISTEN_NONE 0
908#define LISTEN_KERNEL 1 908#define LISTEN_KERNEL 1
909#define LISTEN_RAW 2 909#define LISTEN_RAW 2
910 910
911/* Values for client_config.state */ 911/* Values for client_data.state */
912/* initial state: (re)start DHCP negotiation */ 912/* initial state: (re)start DHCP negotiation */
913#define INIT_SELECTING 0 913#define INIT_SELECTING 0
914/* discover was sent, DHCPOFFER reply received */ 914/* discover was sent, DHCPOFFER reply received */
@@ -1016,35 +1016,35 @@ static void change_listen_mode(int new_mode)
1016 : "none" 1016 : "none"
1017 ); 1017 );
1018 1018
1019 client_config.listen_mode = new_mode; 1019 client_data.listen_mode = new_mode;
1020 if (client_config.sockfd >= 0) { 1020 if (client_data.sockfd >= 0) {
1021 close(client_config.sockfd); 1021 close(client_data.sockfd);
1022 client_config.sockfd = -1; 1022 client_data.sockfd = -1;
1023 } 1023 }
1024 if (new_mode == LISTEN_KERNEL) 1024 if (new_mode == LISTEN_KERNEL)
1025 client_config.sockfd = udhcp_listen_socket(/*INADDR_ANY,*/ CLIENT_PORT6, client_config.interface); 1025 client_data.sockfd = udhcp_listen_socket(/*INADDR_ANY,*/ CLIENT_PORT6, client_data.interface);
1026 else if (new_mode != LISTEN_NONE) 1026 else if (new_mode != LISTEN_NONE)
1027 client_config.sockfd = d6_raw_socket(client_config.ifindex); 1027 client_data.sockfd = d6_raw_socket(client_data.ifindex);
1028 /* else LISTEN_NONE: client_config.sockfd stays closed */ 1028 /* else LISTEN_NONE: client_data.sockfd stays closed */
1029} 1029}
1030 1030
1031/* Called only on SIGUSR1 */ 1031/* Called only on SIGUSR1 */
1032static void perform_renew(void) 1032static void perform_renew(void)
1033{ 1033{
1034 bb_info_msg("performing DHCP renew"); 1034 bb_info_msg("performing DHCP renew");
1035 switch (client_config.state) { 1035 switch (client_data.state) {
1036 case BOUND: 1036 case BOUND:
1037 change_listen_mode(LISTEN_KERNEL); 1037 change_listen_mode(LISTEN_KERNEL);
1038 case RENEWING: 1038 case RENEWING:
1039 case REBINDING: 1039 case REBINDING:
1040 client_config.state = RENEW_REQUESTED; 1040 client_data.state = RENEW_REQUESTED;
1041 break; 1041 break;
1042 case RENEW_REQUESTED: /* impatient are we? fine, square 1 */ 1042 case RENEW_REQUESTED: /* impatient are we? fine, square 1 */
1043 d6_run_script_no_option("deconfig"); 1043 d6_run_script_no_option("deconfig");
1044 case REQUESTING: 1044 case REQUESTING:
1045 case RELEASED: 1045 case RELEASED:
1046 change_listen_mode(LISTEN_RAW); 1046 change_listen_mode(LISTEN_RAW);
1047 client_config.state = INIT_SELECTING; 1047 client_data.state = INIT_SELECTING;
1048 break; 1048 break;
1049 case INIT_SELECTING: 1049 case INIT_SELECTING:
1050 break; 1050 break;
@@ -1054,10 +1054,10 @@ static void perform_renew(void)
1054static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6) 1054static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *our_cur_ipv6)
1055{ 1055{
1056 /* send release packet */ 1056 /* send release packet */
1057 if (client_config.state == BOUND 1057 if (client_data.state == BOUND
1058 || client_config.state == RENEWING 1058 || client_data.state == RENEWING
1059 || client_config.state == REBINDING 1059 || client_data.state == REBINDING
1060 || client_config.state == RENEW_REQUESTED 1060 || client_data.state == RENEW_REQUESTED
1061 ) { 1061 ) {
1062 bb_info_msg("unicasting a release"); 1062 bb_info_msg("unicasting a release");
1063 send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */ 1063 send_d6_release(server_ipv6, our_cur_ipv6); /* unicast */
@@ -1071,7 +1071,7 @@ static void perform_d6_release(struct in6_addr *server_ipv6, struct in6_addr *ou
1071 */ 1071 */
1072 d6_run_script_no_option("deconfig"); 1072 d6_run_script_no_option("deconfig");
1073 change_listen_mode(LISTEN_NONE); 1073 change_listen_mode(LISTEN_NONE);
1074 client_config.state = RELEASED; 1074 client_data.state = RELEASED;
1075} 1075}
1076 1076
1077///static uint8_t* alloc_dhcp_option(int code, const char *str, int extra) 1077///static uint8_t* alloc_dhcp_option(int code, const char *str, int extra)
@@ -1091,7 +1091,7 @@ static void client_background(void)
1091 bb_daemonize(0); 1091 bb_daemonize(0);
1092 logmode &= ~LOGMODE_STDIO; 1092 logmode &= ~LOGMODE_STDIO;
1093 /* rewrite pidfile, as our pid is different now */ 1093 /* rewrite pidfile, as our pid is different now */
1094 write_pidfile(client_config.pidfile); 1094 write_pidfile(client_data.pidfile);
1095} 1095}
1096#endif 1096#endif
1097 1097
@@ -1170,9 +1170,9 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1170 /* Default options */ 1170 /* Default options */
1171 IF_FEATURE_UDHCP_PORT(SERVER_PORT6 = 547;) 1171 IF_FEATURE_UDHCP_PORT(SERVER_PORT6 = 547;)
1172 IF_FEATURE_UDHCP_PORT(CLIENT_PORT6 = 546;) 1172 IF_FEATURE_UDHCP_PORT(CLIENT_PORT6 = 546;)
1173 client_config.interface = "eth0"; 1173 client_data.interface = "eth0";
1174 client_config.script = CONFIG_UDHCPC_DEFAULT_SCRIPT; 1174 client_data.script = CONFIG_UDHCPC_DEFAULT_SCRIPT;
1175 client_config.sockfd = -1; 1175 client_data.sockfd = -1;
1176 1176
1177 /* Parse command line */ 1177 /* Parse command line */
1178 opt = getopt32long(argv, "^" 1178 opt = getopt32long(argv, "^"
@@ -1184,8 +1184,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1184 "v" 1184 "v"
1185 "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ 1185 "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */
1186 , udhcpc6_longopts 1186 , udhcpc6_longopts
1187 , &client_config.interface, &client_config.pidfile, &str_r /* i,p */ 1187 , &client_data.interface, &client_data.pidfile, &str_r /* i,p */
1188 , &client_config.script /* s */ 1188 , &client_data.script /* s */
1189 , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ 1189 , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */
1190 , &list_O 1190 , &list_O
1191 , &list_x 1191 , &list_x
@@ -1216,29 +1216,29 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1216 n = udhcp_option_idx(optstr, d6_option_strings); 1216 n = udhcp_option_idx(optstr, d6_option_strings);
1217 n = d6_optflags[n].code; 1217 n = d6_optflags[n].code;
1218 } 1218 }
1219 client_config.opt_mask[n >> 3] |= 1 << (n & 7); 1219 client_data.opt_mask[n >> 3] |= 1 << (n & 7);
1220 } 1220 }
1221 if (!(opt & OPT_o)) { 1221 if (!(opt & OPT_o)) {
1222 unsigned i, n; 1222 unsigned i, n;
1223 for (i = 0; (n = d6_optflags[i].code) != 0; i++) { 1223 for (i = 0; (n = d6_optflags[i].code) != 0; i++) {
1224 if (d6_optflags[i].flags & OPTION_REQ) { 1224 if (d6_optflags[i].flags & OPTION_REQ) {
1225 client_config.opt_mask[n >> 3] |= 1 << (n & 7); 1225 client_data.opt_mask[n >> 3] |= 1 << (n & 7);
1226 } 1226 }
1227 } 1227 }
1228 } 1228 }
1229 while (list_x) { 1229 while (list_x) {
1230 char *optstr = xstrdup(llist_pop(&list_x)); 1230 char *optstr = xstrdup(llist_pop(&list_x));
1231 udhcp_str2optset(optstr, &client_config.options, 1231 udhcp_str2optset(optstr, &client_data.options,
1232 d6_optflags, d6_option_strings, 1232 d6_optflags, d6_option_strings,
1233 /*dhcpv6:*/ 1 1233 /*dhcpv6:*/ 1
1234 ); 1234 );
1235 free(optstr); 1235 free(optstr);
1236 } 1236 }
1237 1237
1238 if (d6_read_interface(client_config.interface, 1238 if (d6_read_interface(client_data.interface,
1239 &client_config.ifindex, 1239 &client_data.ifindex,
1240 &client6_data.ll_ip6, 1240 &client6_data.ll_ip6,
1241 client_config.client_mac) 1241 client_data.client_mac)
1242 ) { 1242 ) {
1243 return 1; 1243 return 1;
1244 } 1244 }
@@ -1252,8 +1252,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1252 clientid->data[1] = 3; /* DUID-LL */ 1252 clientid->data[1] = 3; /* DUID-LL */
1253 clientid->data[3] = 1; /* ethernet */ 1253 clientid->data[3] = 1; /* ethernet */
1254 clientid_mac_ptr = clientid->data + 2+2; 1254 clientid_mac_ptr = clientid->data + 2+2;
1255 memcpy(clientid_mac_ptr, client_config.client_mac, 6); 1255 memcpy(clientid_mac_ptr, client_data.client_mac, 6);
1256 client_config.clientid = (void*)clientid; 1256 client_data.clientid = (void*)clientid;
1257 } 1257 }
1258 1258
1259#if !BB_MMU 1259#if !BB_MMU
@@ -1271,13 +1271,13 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1271 /* Make sure fd 0,1,2 are open */ 1271 /* Make sure fd 0,1,2 are open */
1272 bb_sanitize_stdio(); 1272 bb_sanitize_stdio();
1273 /* Create pidfile */ 1273 /* Create pidfile */
1274 write_pidfile(client_config.pidfile); 1274 write_pidfile(client_data.pidfile);
1275 /* Goes to stdout (unless NOMMU) and possibly syslog */ 1275 /* Goes to stdout (unless NOMMU) and possibly syslog */
1276 bb_info_msg("started, v"BB_VER); 1276 bb_info_msg("started, v"BB_VER);
1277 /* Set up the signal pipe */ 1277 /* Set up the signal pipe */
1278 udhcp_sp_setup(); 1278 udhcp_sp_setup();
1279 1279
1280 client_config.state = INIT_SELECTING; 1280 client_data.state = INIT_SELECTING;
1281 d6_run_script_no_option("deconfig"); 1281 d6_run_script_no_option("deconfig");
1282 change_listen_mode(LISTEN_RAW); 1282 change_listen_mode(LISTEN_RAW);
1283 packet_num = 0; 1283 packet_num = 0;
@@ -1296,16 +1296,16 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1296 /* silence "uninitialized!" warning */ 1296 /* silence "uninitialized!" warning */
1297 unsigned timestamp_before_wait = timestamp_before_wait; 1297 unsigned timestamp_before_wait = timestamp_before_wait;
1298 1298
1299 //bb_error_msg("sockfd:%d, listen_mode:%d", client_config.sockfd, client_config.listen_mode); 1299 //bb_error_msg("sockfd:%d, listen_mode:%d", client_data.sockfd, client_data.listen_mode);
1300 1300
1301 /* Was opening raw or udp socket here 1301 /* Was opening raw or udp socket here
1302 * if (client_config.listen_mode != LISTEN_NONE && client_config.sockfd < 0), 1302 * if (client_data.listen_mode != LISTEN_NONE && client_data.sockfd < 0),
1303 * but on fast network renew responses return faster 1303 * but on fast network renew responses return faster
1304 * than we open sockets. Thus this code is moved 1304 * than we open sockets. Thus this code is moved
1305 * to change_listen_mode(). Thus we open listen socket 1305 * to change_listen_mode(). Thus we open listen socket
1306 * BEFORE we send renew request (see "case BOUND:"). */ 1306 * BEFORE we send renew request (see "case BOUND:"). */
1307 1307
1308 udhcp_sp_fd_set(pfds, client_config.sockfd); 1308 udhcp_sp_fd_set(pfds, client_data.sockfd);
1309 1309
1310 tv = timeout - already_waited_sec; 1310 tv = timeout - already_waited_sec;
1311 retval = 0; 1311 retval = 0;
@@ -1334,20 +1334,20 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1334 * or if the status of the bridge changed). 1334 * or if the status of the bridge changed).
1335 * Refresh ifindex and client_mac: 1335 * Refresh ifindex and client_mac:
1336 */ 1336 */
1337 if (d6_read_interface(client_config.interface, 1337 if (d6_read_interface(client_data.interface,
1338 &client_config.ifindex, 1338 &client_data.ifindex,
1339 &client6_data.ll_ip6, 1339 &client6_data.ll_ip6,
1340 client_config.client_mac) 1340 client_data.client_mac)
1341 ) { 1341 ) {
1342 goto ret0; /* iface is gone? */ 1342 goto ret0; /* iface is gone? */
1343 } 1343 }
1344 1344
1345 memcpy(clientid_mac_ptr, client_config.client_mac, 6); 1345 memcpy(clientid_mac_ptr, client_data.client_mac, 6);
1346 1346
1347 /* We will restart the wait in any case */ 1347 /* We will restart the wait in any case */
1348 already_waited_sec = 0; 1348 already_waited_sec = 0;
1349 1349
1350 switch (client_config.state) { 1350 switch (client_data.state) {
1351 case INIT_SELECTING: 1351 case INIT_SELECTING:
1352 if (!discover_retries || packet_num < discover_retries) { 1352 if (!discover_retries || packet_num < discover_retries) {
1353 if (packet_num == 0) 1353 if (packet_num == 0)
@@ -1396,12 +1396,12 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1396 * were seen in the wild. Treat them similarly 1396 * were seen in the wild. Treat them similarly
1397 * to "no response to discover" case */ 1397 * to "no response to discover" case */
1398 change_listen_mode(LISTEN_RAW); 1398 change_listen_mode(LISTEN_RAW);
1399 client_config.state = INIT_SELECTING; 1399 client_data.state = INIT_SELECTING;
1400 goto leasefail; 1400 goto leasefail;
1401 case BOUND: 1401 case BOUND:
1402 /* 1/2 lease passed, enter renewing state */ 1402 /* 1/2 lease passed, enter renewing state */
1403 client_config.state = RENEWING; 1403 client_data.state = RENEWING;
1404 client_config.first_secs = 0; /* make secs field count from 0 */ 1404 client_data.first_secs = 0; /* make secs field count from 0 */
1405 change_listen_mode(LISTEN_KERNEL); 1405 change_listen_mode(LISTEN_KERNEL);
1406 log1("entering renew state"); 1406 log1("entering renew state");
1407 /* fall right through */ 1407 /* fall right through */
@@ -1424,7 +1424,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1424 } 1424 }
1425 /* Timed out, enter rebinding state */ 1425 /* Timed out, enter rebinding state */
1426 log1("entering rebinding state"); 1426 log1("entering rebinding state");
1427 client_config.state = REBINDING; 1427 client_data.state = REBINDING;
1428 /* fall right through */ 1428 /* fall right through */
1429 case REBINDING: 1429 case REBINDING:
1430 /* Switch to bcast receive */ 1430 /* Switch to bcast receive */
@@ -1440,8 +1440,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1440 /* Timed out, enter init state */ 1440 /* Timed out, enter init state */
1441 bb_info_msg("lease lost, entering init state"); 1441 bb_info_msg("lease lost, entering init state");
1442 d6_run_script_no_option("deconfig"); 1442 d6_run_script_no_option("deconfig");
1443 client_config.state = INIT_SELECTING; 1443 client_data.state = INIT_SELECTING;
1444 client_config.first_secs = 0; /* make secs field count from 0 */ 1444 client_data.first_secs = 0; /* make secs field count from 0 */
1445 /*timeout = 0; - already is */ 1445 /*timeout = 0; - already is */
1446 packet_num = 0; 1446 packet_num = 0;
1447 continue; 1447 continue;
@@ -1457,10 +1457,10 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1457 /* Is it a signal? */ 1457 /* Is it a signal? */
1458 switch (udhcp_sp_read()) { 1458 switch (udhcp_sp_read()) {
1459 case SIGUSR1: 1459 case SIGUSR1:
1460 client_config.first_secs = 0; /* make secs field count from 0 */ 1460 client_data.first_secs = 0; /* make secs field count from 0 */
1461 already_waited_sec = 0; 1461 already_waited_sec = 0;
1462 perform_renew(); 1462 perform_renew();
1463 if (client_config.state == RENEW_REQUESTED) { 1463 if (client_data.state == RENEW_REQUESTED) {
1464 /* We might be either on the same network 1464 /* We might be either on the same network
1465 * (in which case renew might work), 1465 * (in which case renew might work),
1466 * or we might be on a completely different one 1466 * or we might be on a completely different one
@@ -1495,15 +1495,15 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1495 int len; 1495 int len;
1496 1496
1497 /* A packet is ready, read it */ 1497 /* A packet is ready, read it */
1498 if (client_config.listen_mode == LISTEN_KERNEL) 1498 if (client_data.listen_mode == LISTEN_KERNEL)
1499 len = d6_recv_kernel_packet(&srv6_buf, &packet, client_config.sockfd); 1499 len = d6_recv_kernel_packet(&srv6_buf, &packet, client_data.sockfd);
1500 else 1500 else
1501 len = d6_recv_raw_packet(&srv6_buf, &packet, client_config.sockfd); 1501 len = d6_recv_raw_packet(&srv6_buf, &packet, client_data.sockfd);
1502 if (len == -1) { 1502 if (len == -1) {
1503 /* Error is severe, reopen socket */ 1503 /* Error is severe, reopen socket */
1504 bb_error_msg("read error: "STRERROR_FMT", reopening socket" STRERROR_ERRNO); 1504 bb_error_msg("read error: "STRERROR_FMT", reopening socket" STRERROR_ERRNO);
1505 sleep(discover_timeout); /* 3 seconds by default */ 1505 sleep(discover_timeout); /* 3 seconds by default */
1506 change_listen_mode(client_config.listen_mode); /* just close and reopen */ 1506 change_listen_mode(client_data.listen_mode); /* just close and reopen */
1507 } 1507 }
1508 /* If this packet will turn out to be unrelated/bogus, 1508 /* If this packet will turn out to be unrelated/bogus,
1509 * we will go back and wait for next one. 1509 * we will go back and wait for next one.
@@ -1520,7 +1520,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1520 continue; 1520 continue;
1521 } 1521 }
1522 1522
1523 switch (client_config.state) { 1523 switch (client_data.state) {
1524 case INIT_SELECTING: 1524 case INIT_SELECTING:
1525 if (packet.d6_msg_type == D6_MSG_ADVERTISE) 1525 if (packet.d6_msg_type == D6_MSG_ADVERTISE)
1526 goto type_is_ok; 1526 goto type_is_ok;
@@ -1546,12 +1546,12 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1546 bb_info_msg("received DHCP NAK (%u)", option->data[4]); 1546 bb_info_msg("received DHCP NAK (%u)", option->data[4]);
1547 d6_run_script(packet.d6_options, 1547 d6_run_script(packet.d6_options,
1548 packet_end, "nak"); 1548 packet_end, "nak");
1549 if (client_config.state != REQUESTING) 1549 if (client_data.state != REQUESTING)
1550 d6_run_script_no_option("deconfig"); 1550 d6_run_script_no_option("deconfig");
1551 change_listen_mode(LISTEN_RAW); 1551 change_listen_mode(LISTEN_RAW);
1552 sleep(3); /* avoid excessive network traffic */ 1552 sleep(3); /* avoid excessive network traffic */
1553 client_config.state = INIT_SELECTING; 1553 client_data.state = INIT_SELECTING;
1554 client_config.first_secs = 0; /* make secs field count from 0 */ 1554 client_data.first_secs = 0; /* make secs field count from 0 */
1555 requested_ipv6 = NULL; 1555 requested_ipv6 = NULL;
1556 timeout = 0; 1556 timeout = 0;
1557 packet_num = 0; 1557 packet_num = 0;
@@ -1571,7 +1571,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1571 client6_data.server_id = option; 1571 client6_data.server_id = option;
1572 if (packet.d6_msg_type == D6_MSG_ADVERTISE) { 1572 if (packet.d6_msg_type == D6_MSG_ADVERTISE) {
1573 /* enter requesting state */ 1573 /* enter requesting state */
1574 client_config.state = REQUESTING; 1574 client_data.state = REQUESTING;
1575 timeout = 0; 1575 timeout = 0;
1576 packet_num = 0; 1576 packet_num = 0;
1577 already_waited_sec = 0; 1577 already_waited_sec = 0;
@@ -1746,9 +1746,9 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1746 timeout = 61; 1746 timeout = 61;
1747 /* enter bound state */ 1747 /* enter bound state */
1748 d6_run_script(packet.d6_options, packet_end, 1748 d6_run_script(packet.d6_options, packet_end,
1749 (client_config.state == REQUESTING ? "bound" : "renew")); 1749 (client_data.state == REQUESTING ? "bound" : "renew"));
1750 1750
1751 client_config.state = BOUND; 1751 client_data.state = BOUND;
1752 change_listen_mode(LISTEN_NONE); 1752 change_listen_mode(LISTEN_NONE);
1753 if (opt & OPT_q) { /* quit after lease */ 1753 if (opt & OPT_q) { /* quit after lease */
1754 goto ret0; 1754 goto ret0;
@@ -1777,7 +1777,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1777 perform_d6_release(&srv6_buf, requested_ipv6); 1777 perform_d6_release(&srv6_buf, requested_ipv6);
1778 retval = 0; 1778 retval = 0;
1779 ret: 1779 ret:
1780 /*if (client_config.pidfile) - remove_pidfile has its own check */ 1780 /*if (client_data.pidfile) - remove_pidfile has its own check */
1781 remove_pidfile(client_config.pidfile); 1781 remove_pidfile(client_data.pidfile);
1782 return retval; 1782 return retval;
1783} 1783}