src: convert allow_slaac_only to boolean master
authorÁlvaro Fernández Rojas <[email protected]>
Sat, 6 Dec 2025 12:47:37 +0000 (13:47 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Sat, 6 Dec 2025 14:12:04 +0000 (15:12 +0100)
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 <[email protected]>
src/config.c
src/config.h
src/odhcp6c.c

index 23928cb52840fc1f38c8d0fc922c19a85f120725..7db8b020127ecbbeeb0da76e51cbe09542bfff74 100644 (file)
@@ -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
+}
index 0cedcb762ce22dbc14b3dbd1be591115285c1636..03dbf88990db58b2376db2faad1d9992c32be588 100644 (file)
@@ -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);
index 6b01e12315da9bc18b1087b2a167e0943009e569..d859e9020635bc9eedb81b07c3a8c02569e36ee0 100644 (file)
@@ -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;