From: Álvaro Fernández Rojas Date: Sat, 6 Dec 2025 12:47:37 +0000 (+0100) Subject: src: convert allow_slaac_only to boolean X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=HEAD;p=project%2Fodhcp6c.git src: convert allow_slaac_only to boolean It's declared as a boolean in the OpenWrt wiki, and the package script doesn't pass any value. Signed-off-by: Álvaro Fernández Rojas --- diff --git a/src/config.c b/src/config.c index 23928cb..7db8b02 100644 --- a/src/config.c +++ b/src/config.c @@ -85,7 +85,7 @@ void config_dhcp_reset(void) { config_dhcp.ia_na_mode = IA_MODE_TRY; config_dhcp.ia_pd_mode = IA_MODE_NONE; config_dhcp.client_options = DHCPV6_CLIENT_FQDN | DHCPV6_ACCEPT_RECONFIGURE; - config_dhcp.allow_slaac_only = 0; + config_dhcp.allow_slaac_only = true; config_dhcp.oro_user_cnt = 0; memset(config_dhcp.message_rtx, 0, sizeof(config_dhcp.message_rtx)); config_dhcp.message_rtx[CONFIG_DHCP_SOLICIT].delay_max = DHCPV6_MAX_DELAY; @@ -146,7 +146,7 @@ void config_set_client_options(enum dhcpv6_config option, bool enable) { bool config_set_request_addresses(char* mode) { if (!strcmp(mode, "force")) { config_dhcp.ia_na_mode = IA_MODE_FORCE; - config_dhcp.allow_slaac_only = -1; + config_dhcp.allow_slaac_only = false; } else if (!strcmp(mode, "none")) { config_dhcp.ia_na_mode = IA_MODE_NONE; } else if (!strcmp(mode, "try")) { @@ -182,7 +182,7 @@ bool config_set_request_prefix(unsigned int length, unsigned int id) { void config_set_force_prefix(bool enable) { if (enable) { - config_dhcp.allow_slaac_only = -1; + config_dhcp.allow_slaac_only = false; config_dhcp.ia_pd_mode = IA_MODE_FORCE; } else { config_dhcp.ia_pd_mode = IA_MODE_NONE; @@ -193,7 +193,7 @@ void config_set_stateful_only(bool enable) { config_dhcp.stateful_only_mode = enable; } -void config_set_allow_slaac_only(int value) { +void config_set_allow_slaac_only(bool value) { config_dhcp.allow_slaac_only = value; } @@ -614,4 +614,4 @@ void config_apply_dhcp_rtx(struct dhcpv6_retx* dhcpv6_retx) dhcpv6_retx[DHCPV6_MSG_RELEASE].max_rc = config_dhcp.message_rtx[CONFIG_DHCP_RELEASE].rc_max; dhcpv6_retx[DHCPV6_MSG_DECLINE].init_timeo = config_dhcp.message_rtx[CONFIG_DHCP_DECLINE].timeout_init; dhcpv6_retx[DHCPV6_MSG_DECLINE].max_rc = config_dhcp.message_rtx[CONFIG_DHCP_DECLINE].rc_max; -} \ No newline at end of file +} diff --git a/src/config.h b/src/config.h index 0cedcb7..03dbf88 100644 --- a/src/config.h +++ b/src/config.h @@ -90,7 +90,7 @@ struct config_dhcp { enum odhcp6c_ia_mode ia_na_mode; enum odhcp6c_ia_mode ia_pd_mode; unsigned int client_options; - int allow_slaac_only; + bool allow_slaac_only; unsigned int oro_user_cnt; struct config_dhcp_rtx message_rtx[CONFIG_DHCP_MAX]; uint32_t irt_default; @@ -110,7 +110,7 @@ bool config_set_request_addresses(char *mode); bool config_set_request_prefix(unsigned int length, unsigned int id); void config_set_force_prefix(bool enable); void config_set_stateful_only(bool enable); -void config_set_allow_slaac_only(int value); +void config_set_allow_slaac_only(bool value); void config_clear_requested_options(void) ; bool config_add_requested_options(unsigned int option); void config_clear_send_options(void); diff --git a/src/odhcp6c.c b/src/odhcp6c.c index 6b01e12..d859e90 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -186,10 +186,10 @@ int main(_o_unused int argc, char* const argv[]) config_dhcp = config_dhcp_get(); config_dhcp_reset(); - while ((c = getopt(argc, argv, "S::DN:V:P:FB:c:i:r:Ru:Ux:s:EkK:t:C:m:Lhedp:fav")) != -1) { + while ((c = getopt(argc, argv, "SDN:V:P:FB:c:i:r:Ru:Ux:s:EkK:t:C:m:Lhedp:fav")) != -1) { switch (c) { case 'S': - config_set_allow_slaac_only((optarg) ? atoi(optarg) : -1); + config_set_allow_slaac_only(false); break; case 'D': @@ -881,7 +881,7 @@ bool odhcp6c_signal_process(void) signal_usr2 = true; } - if (ra_updated && (bound || config_dhcp->allow_slaac_only >= 0)) { + if (ra_updated && (bound || config_dhcp->allow_slaac_only)) { notify_state_change("ra-updated", (!ra && !bound) ? script_sync_delay : script_accu_delay, false); ra = true;