summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko2021-06-03 16:14:04 +0200
committerDenys Vlasenko2021-06-03 16:14:04 +0200
commitf6def87a2e73e65fb6743cb5b6d0592b390628e5 (patch)
tree40963f11d21645cc84f0db78f401e673a4f3a458 /networking
parent2f1d13d56aecc622366f717932929db5f0b8b35b (diff)
downloadbusybox-f6def87a2e73e65fb6743cb5b6d0592b390628e5.zip
busybox-f6def87a2e73e65fb6743cb5b6d0592b390628e5.tar.gz
udhcpc: code shrink, rename functions, no logic changes
function old new delta d4_run_script - 739 +739 d4_recv_raw_packet - 484 +484 d4_run_script_deconfig - 12 +12 perform_release 207 200 -7 udhcpc_main 2598 2556 -42 udhcp_recv_raw_packet 484 - -484 udhcp_run_script 739 - -739 ------------------------------------------------------------------------------ (add/remove: 3/2 grow/shrink: 0/2 up/down: 1235/-1272) Total: -37 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/udhcp/d6_dhcpc.c4
-rw-r--r--networking/udhcp/dhcpc.c30
2 files changed, 19 insertions, 15 deletions
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 276ceca..1a58f5f 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -441,7 +441,7 @@ static char **fill_envp(const uint8_t *option, const uint8_t *option_end)
return envp;
}
-/* Call a script with a par file and env vars */
+/* Call a script with env vars */
static void d6_run_script(const uint8_t *option, const uint8_t *option_end,
const char *name)
{
@@ -464,7 +464,7 @@ static void d6_run_script(const uint8_t *option, const uint8_t *option_end,
free(envp);
}
-/* Call a script with a par file and no env var */
+/* Call a script with no env var */
static void d6_run_script_no_option(const char *name)
{
d6_run_script(NULL, NULL, name);
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index e0bddcd..e55b606 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -566,8 +566,8 @@ static void fill_envp(struct dhcp_packet *packet)
}
}
-/* Call a script with a par file and env vars */
-static void udhcp_run_script(struct dhcp_packet *packet, const char *name)
+/* Call a script with env vars */
+static void d4_run_script(struct dhcp_packet *packet, const char *name)
{
char *argv[3];
@@ -585,6 +585,10 @@ static void udhcp_run_script(struct dhcp_packet *packet, const char *name)
client_data.envp = NULL;
}
+static void d4_run_script_deconfig(void)
+{
+ d4_run_script(NULL, "deconfig");
+}
/*** Sending/receiving packets ***/
@@ -882,7 +886,7 @@ int send_release(uint32_t server, uint32_t ciaddr)
/* Returns -1 on errors that are fatal for the socket, -2 for those that aren't */
/* NOINLINE: limit stack usage in caller */
-static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
+static NOINLINE int d4_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
{
int bytes;
struct ip_udp_dhcp_packet packet;
@@ -1143,7 +1147,7 @@ static void perform_release(uint32_t server_addr, uint32_t requested_ip)
* Users requested to be notified in all cases, even if not in one
* of the states above.
*/
- udhcp_run_script(NULL, "deconfig");
+ d4_run_script_deconfig();
client_data.state = RELEASED;
}
@@ -1374,7 +1378,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
srand(monotonic_us());
client_data.state = INIT_SELECTING;
- udhcp_run_script(NULL, "deconfig");
+ d4_run_script_deconfig();
packet_num = 0;
timeout = 0;
lease_remaining = 0;
@@ -1460,7 +1464,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
}
leasefail:
change_listen_mode(LISTEN_NONE);
- udhcp_run_script(NULL, "leasefail");
+ d4_run_script(NULL, "leasefail");
#if BB_MMU /* -b is not supported on NOMMU */
if (opt & OPT_b) { /* background if no lease */
bb_simple_info_msg("no lease, forking to background");
@@ -1555,7 +1559,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
/* Timed out, enter init state */
change_listen_mode(LISTEN_NONE);
bb_simple_info_msg("lease lost, entering init state");
- udhcp_run_script(NULL, "deconfig");
+ d4_run_script_deconfig();
client_data.state = INIT_SELECTING;
client_data.first_secs = 0; /* make secs field count from 0 */
timeout = 0;
@@ -1595,7 +1599,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
/* Two SIGUSR1 received, start things over */
case RENEW_REQUESTED:
change_listen_mode(LISTEN_NONE);
- udhcp_run_script(NULL, "deconfig");
+ d4_run_script_deconfig();
/* Wake from SIGUSR2-induced deconfigured state */
default:
@@ -1627,7 +1631,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
if (client_data.listen_mode == LISTEN_KERNEL)
len = udhcp_recv_kernel_packet(&packet, client_data.sockfd);
else
- len = udhcp_recv_raw_packet(&packet, client_data.sockfd);
+ len = d4_recv_raw_packet(&packet, client_data.sockfd);
if (len == -1) {
/* Error is severe, reopen socket */
bb_error_msg("read error: "STRERROR_FMT", reopening socket" STRERROR_ERRNO);
@@ -1772,7 +1776,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
send_decline(/*xid,*/ server_addr, packet.yiaddr);
if (client_data.state != REQUESTING)
- udhcp_run_script(NULL, "deconfig");
+ d4_run_script_deconfig();
client_data.state = INIT_SELECTING;
client_data.first_secs = 0; /* make secs field count from 0 */
requested_ip = 0;
@@ -1784,7 +1788,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
#endif
/* enter bound state */
start = monotonic_sec();
- udhcp_run_script(&packet, client_data.state == REQUESTING ? "bound" : "renew");
+ d4_run_script(&packet, client_data.state == REQUESTING ? "bound" : "renew");
lease_remaining -= (unsigned)monotonic_sec() - start;
if (lease_remaining < 0)
lease_remaining = 0;
@@ -1831,9 +1835,9 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
/* return to init state */
change_listen_mode(LISTEN_NONE);
bb_info_msg("received %s", "DHCP NAK");
- udhcp_run_script(&packet, "nak");
+ d4_run_script(&packet, "nak");
if (client_data.state != REQUESTING)
- udhcp_run_script(NULL, "deconfig");
+ d4_run_script_deconfig();
sleep(3); /* avoid excessive network traffic */
client_data.state = INIT_SELECTING;
client_data.first_secs = 0; /* make secs field count from 0 */