mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-02-10 05:42:59 +01:00
Ticket refs #3489: TR181: Invalid enumeration parameter values
This commit is contained in:
parent
49f1bd8204
commit
437273a254
16 changed files with 94 additions and 70 deletions
|
|
@ -90,12 +90,8 @@ static int get_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data,
|
|||
char *encapsulation;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct atm_args *)data)->atm_sec, "encapsulation", &encapsulation);
|
||||
if (strcmp(encapsulation, "vcmux") == 0)
|
||||
*value = "VCMUX";
|
||||
else if (strcmp(encapsulation, "llc") == 0)
|
||||
*value = "LLC";
|
||||
else
|
||||
*value = "";
|
||||
|
||||
*value = (strcmp(encapsulation, "vcmux") == 0) ? "VCMUX" : "LLC";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -651,12 +651,13 @@ static int get_dhcp_status(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *v = NULL;
|
||||
*value = "Error_Misconfigured";
|
||||
|
||||
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
|
||||
dmuci_get_value_by_section_string(s, "ignore", &v);
|
||||
*value = (v && *v == '1') ? "Disabled" : "Enabled";
|
||||
return 0;
|
||||
}
|
||||
*value = "Error_Misconfigured";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1552,6 +1553,8 @@ static int get_DHCPv4Client_Status(char *refparam, struct dmctx *ctx, void *data
|
|||
/*#Device.DHCPv4.Client.{i}.DHCPStatus!UBUS:network.interface/status/interface,@Name/ipv4-address[@i-1].address*/
|
||||
static int get_DHCPv4Client_DHCPStatus(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "Init";
|
||||
|
||||
if (((struct dhcp_client_args *)data)->dhcp_client_conf == NULL)
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -830,14 +830,15 @@ static int set_DHCPv6ServerPool_Enable(char *refparam, struct dmctx *ctx, void *
|
|||
static int get_DHCPv6ServerPool_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
char *v= NULL;
|
||||
char *v = NULL;
|
||||
*value = "Error_Misconfigured";
|
||||
|
||||
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcpv6_args *)data)->interface, s) {
|
||||
dmuci_get_value_by_section_string(s, "ignore", &v);
|
||||
*value = (v && *v == '1') ? "Disabled" : "Enabled";
|
||||
return 0;
|
||||
}
|
||||
*value="Error_Misconfigured";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -358,11 +358,7 @@ static int get_relay_enable(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
static int get_relay_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *path = "/etc/rc.d/*dnsmasq";
|
||||
if (check_file(path))
|
||||
*value = "Enabled";
|
||||
else
|
||||
*value = "Disabled";
|
||||
*value = (check_file("/etc/rc.d/*dnsmasq")) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -493,7 +489,7 @@ static int get_nslookupdiagnostics_result_number_of_entries(char *refparam, stru
|
|||
|
||||
static int get_result_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "Status", value);
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "Status", "Error_Other");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -417,20 +417,21 @@ static char *get_dsl_standard(char *str)
|
|||
/*#Device.DSL.Line.{i}.StandardsSupported!UBUS:dsl.line.0/status//standards_supported*/
|
||||
static int get_DSLLine_StandardsSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *standards_supported,*pch, *spch, *tmp, *tmpPtr, *str = "";
|
||||
char *standards_supported, *pch, *spch, *tmp, *tmpPtr = NULL, *str = NULL;
|
||||
|
||||
*value = "";
|
||||
*value = "G.992.1_Annex_A";
|
||||
standards_supported = get_dsl_value_array_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "standards_supported");
|
||||
if(standards_supported[0] == '\0')
|
||||
if (standards_supported[0] == '\0')
|
||||
return 0;
|
||||
for (pch = strtok_r(standards_supported, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch))
|
||||
{
|
||||
for (pch = strtok_r(standards_supported, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch)) {
|
||||
tmp = get_dsl_standard(pch);
|
||||
if(*str == '\0')
|
||||
if(!str)
|
||||
dmasprintf(&str, "%s", tmp);
|
||||
else {
|
||||
tmpPtr = str;
|
||||
tmpPtr = dmstrdup(str);
|
||||
dmfree(str);
|
||||
dmasprintf(&str, "%s,%s", tmpPtr, tmp);
|
||||
dmfree(tmpPtr);
|
||||
}
|
||||
}
|
||||
*value = str;
|
||||
|
|
@ -529,19 +530,19 @@ static int get_DSLLine_CurrentProfile(char *refparam, struct dmctx *ctx, void *d
|
|||
/*#Device.DSL.Line.{i}.PowerManagementState!UBUS:dsl.line.0/status//power_management_state*/
|
||||
static int get_DSLLine_PowerManagementState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *power_management_state = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "power_management_state");
|
||||
if(strcmp(power_management_state, "l0") == 0)
|
||||
char *power_mng_state = get_dsl_value_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "power_management_state");
|
||||
if(strcmp(power_mng_state, "l0") == 0)
|
||||
*value = "L0";
|
||||
else if(strcmp(power_management_state, "l1") == 0)
|
||||
else if(strcmp(power_mng_state, "l1") == 0)
|
||||
*value = "L1";
|
||||
else if(strcmp(power_management_state, "l2") == 0)
|
||||
else if(strcmp(power_mng_state, "l2") == 0)
|
||||
*value = "L2";
|
||||
else if(strcmp(power_management_state, "l3") == 0)
|
||||
else if(strcmp(power_mng_state, "l3") == 0)
|
||||
*value = "L3";
|
||||
else if(strcmp(power_management_state, "l4") == 0)
|
||||
else if(strcmp(power_mng_state, "l4") == 0)
|
||||
*value = "L4";
|
||||
else
|
||||
*value = power_management_state;
|
||||
*value = power_mng_state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -953,10 +954,8 @@ static char *get_dsl_link_encapsulation_standard(char *str)
|
|||
dsl_link_encapsulation_standard = "G.993.2_Annex_K_ATM";
|
||||
else if(strcmp(str, "vdsl2_ptm") == 0)
|
||||
dsl_link_encapsulation_standard = "G.993.2_Annex_K_PTM";
|
||||
else if(strcmp(str, "auto") == 0)
|
||||
dsl_link_encapsulation_standard = "G.994.1";
|
||||
else
|
||||
dsl_link_encapsulation_standard = "unknown";
|
||||
dsl_link_encapsulation_standard = "G.994.1";
|
||||
|
||||
return dsl_link_encapsulation_standard;
|
||||
}
|
||||
|
|
@ -964,20 +963,21 @@ static char *get_dsl_link_encapsulation_standard(char *str)
|
|||
/*#Device.DSL.Channel.{i}.LinkEncapsulationSupported!UBUS:dsl.channel.0/status//link_encapsulation_supported*/
|
||||
static int get_DSLChannel_LinkEncapsulationSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *link_encapsulation_supported,*pch, *spch, *tmp, *tmpPtr, *str = "";
|
||||
char *link_encap,*pch, *spch, *tmp, *tmpPtr = NULL, *str = NULL;
|
||||
|
||||
*value = "";
|
||||
link_encapsulation_supported = get_dsl_value_array_without_argument("dsl.channel", ((struct dsl_channel_args*)data)->id, "status", "link_encapsulation_supported");
|
||||
if(link_encapsulation_supported[0] == '\0')
|
||||
*value = "G.994.1";
|
||||
link_encap = get_dsl_value_array_without_argument("dsl.channel", ((struct dsl_channel_args*)data)->id, "status", "link_encapsulation_supported");
|
||||
if(link_encap[0] == '\0')
|
||||
return 0;
|
||||
for (pch = strtok_r(link_encapsulation_supported, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch))
|
||||
{
|
||||
for (pch = strtok_r(link_encap, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch)) {
|
||||
tmp = get_dsl_link_encapsulation_standard(pch);
|
||||
if(*str == '\0')
|
||||
if(!str)
|
||||
dmasprintf(&str, "%s", tmp);
|
||||
else {
|
||||
tmpPtr = str;
|
||||
tmpPtr = dmstrdup(str);
|
||||
dmfree(str);
|
||||
dmasprintf(&str, "%s,%s", tmpPtr, tmp);
|
||||
dmfree(tmpPtr);
|
||||
}
|
||||
}
|
||||
*value = str;
|
||||
|
|
|
|||
|
|
@ -363,7 +363,11 @@ static int ubus_ieee1905_info(const char *option, char **value)
|
|||
/*#Device.IEEE1905.Version!UBUS:ieee1905/info//version*/
|
||||
static int get_IEEE1905_Version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return ubus_ieee1905_info("version", value);
|
||||
char *version = NULL;
|
||||
ubus_ieee1905_info("version", &version);
|
||||
if (version && *version == '0')
|
||||
*value = "1905.1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.IEEE1905.AL.IEEE1905Id!UBUS:ieee1905/info//ieee1905id*/
|
||||
|
|
@ -375,7 +379,11 @@ static int get_IEEE1905AL_IEEE1905Id(char *refparam, struct dmctx *ctx, void *da
|
|||
/*#Device.IEEE1905.AL.Status!UBUS:ieee1905/info//status*/
|
||||
static int get_IEEE1905AL_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return ubus_ieee1905_info("status", value);
|
||||
char *version = NULL;
|
||||
ubus_ieee1905_info("status", &version);
|
||||
if (version && *version == '0')
|
||||
*value = "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.IEEE1905.AL.LastChange!UBUS:ieee1905/info//last_change*/
|
||||
|
|
@ -445,7 +453,7 @@ static int get_IEEE1905ALInterface_MediaType(char *refparam, struct dmctx *ctx,
|
|||
{
|
||||
json_object *res = NULL;
|
||||
dmubus_call((char *)data, "info", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
DM_ASSERT(res, *value = "Generic PHY");
|
||||
*value = dmjson_get_value(res, 1, "interface_type");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -495,7 +503,7 @@ static int get_IEEE1905ALInterface_PowerState(char *refparam, struct dmctx *ctx,
|
|||
{
|
||||
json_object *res = NULL;
|
||||
dmubus_call((char *)data, "info", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
DM_ASSERT(res, *value = "Unsupported");
|
||||
*value = dmjson_get_value(res, 1, "power_state");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -967,7 +975,7 @@ static int get_IEEE1905ALNetworkTopology_Status(char *refparam, struct dmctx *ct
|
|||
{
|
||||
json_object *res;
|
||||
dmubus_call("topology", "status", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
DM_ASSERT(res, *value = "Error_Misconfigured");
|
||||
*value = dmjson_get_value(res, 1, "status");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1262,7 +1270,6 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_MediaType(char *
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceInterface_PowerState(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = dmjson_get_value((json_object *)data, 1, "power_status");
|
||||
|
|
@ -1476,7 +1483,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTuple_InterfaceLis
|
|||
/*#Device.IEEE1905.AL.Security.SetupMethod!UCI:ieee1905/security,security/method*/
|
||||
static int get_IEEE1905ALSecurity_SetupMethod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("ieee1905", "security", "method", value);
|
||||
*value = dmuci_get_option_value_fallback_def("ieee1905", "security", "method", "PBC");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ static int get_alias_based_addressing(char *refparam, struct dmctx *ctx, void *d
|
|||
/*#Device.ManagementServer.InstanceMode!UCI:cwmp/cpe,cpe/instance_mode*/
|
||||
static int get_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("cwmp", "cpe", "instance_mode", value);
|
||||
*value = dmuci_get_option_value_fallback_def("cwmp", "cpe", "instance_mode", "InstanceNumber");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -512,7 +512,7 @@ static int get_nat_port_mapping_protocol(char *refparam, struct dmctx *ctx, void
|
|||
else if (strcmp(proto, "udp") == 0)
|
||||
*value = "UDP";
|
||||
else
|
||||
*value = "TCP/UDP";
|
||||
*value = "TCP,UDP";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ static int get_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *i
|
|||
bool bstatus = false, bpend = false;
|
||||
|
||||
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct uci_section *)data)), String}}, 1, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
DM_ASSERT(res, *value = "Unconfigured");
|
||||
jobj = dmjson_get_obj(res, 1, "up");
|
||||
if (jobj) {
|
||||
status = dmjson_get_value(res, 1, "up");
|
||||
|
|
|
|||
|
|
@ -3450,7 +3450,7 @@ int os_set_QoSQueue_DropAlgorithm(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
int os_get_QoSQueue_SchedulerAlgorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "scheduling", value);
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "scheduling", "SP");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -611,6 +611,8 @@ static int get_router_ipv4forwarding_origin(char *refparam, struct dmctx *ctx, v
|
|||
{
|
||||
if (((struct routingfwdargs *)data)->type != ROUTE_DYNAMIC)
|
||||
*value = "Static";
|
||||
else
|
||||
*value = "DHCPv4";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,12 +55,7 @@ static int set_time_enable(char *refparam, struct dmctx *ctx, void *data, char *
|
|||
|
||||
static int get_time_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *path = "/etc/rc.d/*ntpd";
|
||||
|
||||
if (check_file(path))
|
||||
*value = "Synchronized";
|
||||
else
|
||||
*value = "Disabled";
|
||||
*value = (check_file("/etc/rc.d/*ntpd")) ? "Synchronized" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -685,7 +685,7 @@ static int get_USBPort_Power(char *refparam, struct dmctx *ctx, void *data, char
|
|||
__read_sysfs_usb_port(data, "power/control", pwrctl, sizeof(pwrctl));
|
||||
|
||||
if (pwrctl[0] == 0)
|
||||
*value = "";
|
||||
*value = "Unknown";
|
||||
else if (!strcmp(pwrctl, "auto"))
|
||||
*value ="Self";
|
||||
else
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ int os_get_wifi_access_point_status (char *refparam, struct dmctx *ctx, void *da
|
|||
dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "device", &iface);
|
||||
snprintf(object, sizeof(object), "wifi.ap.%s", iface);
|
||||
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, status = "");
|
||||
DM_ASSERT(res, status = "Error_Misconfigured");
|
||||
status = dmjson_get_value(res, 1, "status");
|
||||
|
||||
if (strcmp(status, "running") == 0 || strcmp(status, "up") == 0)
|
||||
|
|
@ -325,7 +325,7 @@ int os__get_radio_supported_frequency_bands(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
|
||||
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
DM_ASSERT(res, *value = "2.4GHz,5GHz");
|
||||
*value = dmjson_get_value_array_all(res, DELIMITOR, 1, "supp_bands");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -380,6 +380,7 @@ int os__get_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struc
|
|||
json_object *res = NULL, *neighboring_wifi_obj = NULL;
|
||||
char object[32];
|
||||
|
||||
*value = "None";
|
||||
uci_foreach_sections("wireless", "wifi-device", ss) {
|
||||
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(ss));
|
||||
dmubus_call(object, "scanresults", UBUS_ARGS{}, 0, &res);
|
||||
|
|
@ -497,7 +498,7 @@ int os__get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct
|
|||
|
||||
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
|
||||
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
DM_ASSERT(res, *value = "Auto");
|
||||
dmjson_foreach_obj_in_array(res, arrobj, supp_channels, i, 1, "supp_channels") {
|
||||
bandwidth = dmjson_get_value(supp_channels, 1, "bandwidth");
|
||||
if (bandwidth && !strstr(bandwidth_list, !strcmp(bandwidth, "8080") ? "80+80" : !strcmp(bandwidth, "80") ? ",80MHz" : bandwidth)) {
|
||||
|
|
@ -523,7 +524,7 @@ int os__get_WiFiRadio_CurrentOperatingChannelBandwidth(char *refparam, struct dm
|
|||
|
||||
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
|
||||
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
DM_ASSERT(res, *value = "20MHz");
|
||||
bandwidth = dmjson_get_value(res, 1, "bandwidth");
|
||||
if (bandwidth)
|
||||
dmasprintf(value, "%sMHz", bandwidth);
|
||||
|
|
@ -562,7 +563,7 @@ static int get_radio_standards(struct uci_section *section, char **value)
|
|||
|
||||
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(section));
|
||||
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, *value = "");
|
||||
DM_ASSERT(res, *value = "n,ax");
|
||||
|
||||
standard = dmjson_get_value(res, 1, "standard");
|
||||
standards = strsplit(standard, "/", &length);
|
||||
|
|
|
|||
|
|
@ -819,9 +819,7 @@ static int get_access_point_security_supported_modes(char *refparam, struct dmct
|
|||
|
||||
static void get_security_mode(char **value, char *encryption)
|
||||
{
|
||||
if (strcmp(encryption, "none") == 0)
|
||||
*value = "None";
|
||||
else if (strcmp(encryption, "wep-open") == 0 || strcmp(encryption, "wep-shared") == 0)
|
||||
if (strcmp(encryption, "wep-open") == 0 || strcmp(encryption, "wep-shared") == 0)
|
||||
*value = "WEP-64";
|
||||
else if (strcmp(encryption, "psk") == 0)
|
||||
*value = "WPA-Personal";
|
||||
|
|
@ -836,7 +834,7 @@ static void get_security_mode(char **value, char *encryption)
|
|||
else if (strcmp(encryption, "wpa-mixed") == 0 || strcmp(encryption, "mixed-wpa") == 0)
|
||||
*value = "WPA-WPA2-Enterprise";
|
||||
else
|
||||
*value = "unknown";
|
||||
*value = "None";
|
||||
}
|
||||
|
||||
static void reset_wlan(struct uci_section *s)
|
||||
|
|
@ -1105,12 +1103,12 @@ static int get_WiFiAccessPointSecurity_MFPConfig(char *refparam, struct dmctx *c
|
|||
{
|
||||
dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "ieee80211w", value);
|
||||
|
||||
if(!*value || *value[0] == 0 || *value[0] == '0')
|
||||
*value = "Disabled";
|
||||
else if (*value[0] == '1')
|
||||
if (*value[0] == '1')
|
||||
*value = "Optional";
|
||||
else if (*value[0] == '2')
|
||||
*value = "Required";
|
||||
else
|
||||
*value = "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1147,6 +1147,23 @@ int string_to_bool(char *v, bool *b)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static char *get_default_value_by_type(int type)
|
||||
{
|
||||
switch (type) {
|
||||
case DMT_UNINT:
|
||||
case DMT_INT:
|
||||
case DMT_UNLONG:
|
||||
case DMT_LONG:
|
||||
case DMT_BOOL:
|
||||
case DMT_BASE64:
|
||||
return "0";
|
||||
case DMT_TIME:
|
||||
return "0001-01-01T00:00:00Z";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void dmentry_instance_lookup_inparam(struct dmctx *ctx)
|
||||
{
|
||||
char *pch, *spch, *in_param;
|
||||
|
|
@ -1243,6 +1260,10 @@ static int get_value_param(DMPARAM_ARGS)
|
|||
|
||||
dmastrcat(&full_param, node->current_object, lastname);
|
||||
(get_cmd)(full_param, dmctx, data, instance, &value);
|
||||
|
||||
if (value && *value == '\0')
|
||||
value = get_default_value_by_type(type);
|
||||
|
||||
add_list_paramameter(dmctx, full_param, value, DMT_TYPE[type], NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1263,6 +1284,10 @@ static int mparam_get_value_in_param(DMPARAM_ARGS)
|
|||
}
|
||||
|
||||
(get_cmd)(full_param, dmctx, data, instance, &value);
|
||||
|
||||
if (value && *value == '\0')
|
||||
value = get_default_value_by_type(type);
|
||||
|
||||
add_list_paramameter(dmctx, full_param, value, DMT_TYPE[type], NULL, 0);
|
||||
dmctx->stop = true;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue