mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Simplify management server url
This commit is contained in:
parent
3b2e55fdef
commit
2ccba8af73
4 changed files with 28 additions and 5 deletions
|
|
@ -17,18 +17,22 @@
|
|||
/*#Device.ManagementServer.URL!UCI:cwmp/acs,acs/url*/
|
||||
static int get_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *dhcp = NULL, *url = NULL, *provisioning_value = NULL;
|
||||
char *dhcp = NULL, *url = NULL, *dhcp_url = NULL;
|
||||
bool discovery = false;
|
||||
|
||||
dmuci_get_option_value_string("cwmp", "acs", "dhcp_discovery", &dhcp);
|
||||
dmuci_get_option_value_string("cwmp", "acs", "url", &url);
|
||||
dmuci_get_option_value_string("cwmp", "acs", "dhcp_url", &provisioning_value);
|
||||
dmuci_get_option_value_string("cwmp", "acs", "dhcp_url", &dhcp_url);
|
||||
|
||||
if ( ((dhcp && strcmp(dhcp, "enable") == 0 ) || ((url == NULL) || (url[0] == '\0'))) && ((provisioning_value != NULL) && (provisioning_value[0] != '\0')) )
|
||||
*value = provisioning_value;
|
||||
else if ((url != NULL) && (url[0] != '\0'))
|
||||
discovery = dmuci_string_to_boolean(dhcp);
|
||||
|
||||
if ((discovery == true) && (DM_STRLEN(dhcp_url) != 0))
|
||||
*value = dhcp_url;
|
||||
else if (DM_STRLEN(url) != 0)
|
||||
*value = url;
|
||||
else
|
||||
*value = "";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ do { \
|
|||
DST[SIZE-1] = '\0'; \
|
||||
} while(0)
|
||||
|
||||
#define DM_STRLEN(SRC) (SRC != NULL) ? strlen(SRC) : 0
|
||||
|
||||
#define UBUS_ARGS (struct ubus_arg[])
|
||||
#define RANGE_ARGS (struct range_args[])
|
||||
#define LIST_KEY (const char *[])
|
||||
|
|
|
|||
|
|
@ -908,3 +908,19 @@ end:
|
|||
|
||||
return val;
|
||||
}
|
||||
|
||||
bool dmuci_string_to_boolean(char *value)
|
||||
{
|
||||
if (!value)
|
||||
return false;
|
||||
|
||||
if (strncasecmp(value, "true", 4) == 0 ||
|
||||
value[0] == '1' ||
|
||||
strncasecmp(value, "on", 2) == 0 ||
|
||||
strncasecmp(value, "yes", 3) == 0 ||
|
||||
strncasecmp(value, "enable", 6) == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -376,6 +376,7 @@ int dmuci_set_value_varstate(char *package, char *section, char *option, char *v
|
|||
|
||||
char *dmuci_get_value_by_path(char *path, char *package, char *section, char *option);
|
||||
char *dmuci_set_value_by_path(char *path, char *package, char *section, char *option, char *value);
|
||||
bool dmuci_string_to_boolean(char *value);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue