mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
UCI: added get value functions with a default value
This commit is contained in:
parent
e0334ebe18
commit
2e4bc3688b
13 changed files with 72 additions and 186 deletions
|
|
@ -862,9 +862,7 @@ static int set_voice_profile_sip_registerserver(char *refparam, struct dmctx *ct
|
|||
/*#Device.Services.VoiceService.{i}.VoiceProfile.{i}.SIP.RegistrarServerPort!UCI:asterisk/sip_service_provider,@i-1/port*/
|
||||
static int get_voice_profile_sip_registerserverport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct sip_args *)data)->sip_section, "port", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct sip_args *)data)->sip_section, "port", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -937,9 +935,7 @@ static int set_sip_user_agent_domain(char *refparam, struct dmctx *ctx, void *da
|
|||
/*#Device.Services.VoiceService.{i}.VoiceProfile.{i}.SIP.UserAgentPort!UCI:asterisk/sip_advanced,SIP/bindport*/
|
||||
static int get_sip_user_agent_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("asterisk", "sip_options", "bindport", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "bindport", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -960,14 +956,7 @@ static int set_sip_user_agent_port(char *refparam, struct dmctx *ctx, void *data
|
|||
/*#Device.Services.VoiceService.{i}.VoiceProfile.{i}.SIP.UserAgentTransport!UCI:asterisk/sip_service_provider,@i-1/transport*/
|
||||
static int get_sip_user_agent_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *tmp;
|
||||
struct sip_args *sipargs = (struct sip_args *)data;
|
||||
|
||||
dmuci_get_value_by_section_string(sipargs->sip_section, "transport", &tmp);
|
||||
if (tmp[0] == '\0')
|
||||
*value = "udp";
|
||||
else
|
||||
*value = tmp;
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct sip_args *)data)->sip_section, "transport", "udp");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1015,9 +1004,7 @@ static int set_sip_outbound_proxy(char *refparam, struct dmctx *ctx, void *data,
|
|||
/*#Device.Services.VoiceService.{i}.VoiceProfile.{i}.SIP.OutboundProxyPort!UCI:asterisk/sip_service_provider,@i-1/outboundproxyport*/
|
||||
static int get_sip_outbound_proxy_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct sip_args *)data)->sip_section, "outboundproxyport", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct sip_args *)data)->sip_section, "outboundproxyport", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1060,9 +1047,7 @@ static int set_sip_registration_period(char *refparam, struct dmctx *ctx, void *
|
|||
/*#Device.Services.VoiceService.{i}.VoiceProfile.{i}.SIP.ReInviteExpires!UCI:asterisk/sip_advanced,SIP/registertimeout*/
|
||||
static int get_sip_re_invite_expires(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("asterisk", "sip_options", "registertimeout", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "1";
|
||||
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "registertimeout", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1227,13 +1212,7 @@ static int set_sip_fax_t38_enable(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int get_voice_service_vp_rtp_portmin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
dmuci_get_option_value_string("asterisk", "sip_options", "rtpstart", &tmp);
|
||||
if(tmp[0] == '\0')
|
||||
*value = "5000";
|
||||
else
|
||||
*value = tmp;
|
||||
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtpstart", "5000");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1253,13 +1232,7 @@ static int set_voice_service_vp_rtp_portmin(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
static int get_voice_service_vp_rtp_portmax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
dmuci_get_option_value_string("asterisk", "sip_options", "rtpend", &tmp);
|
||||
if(tmp[0] == '\0')
|
||||
*value = "31000";
|
||||
else
|
||||
*value = tmp;
|
||||
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtpend", "31000");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1324,13 +1297,7 @@ static int get_voice_service_vp_rtp_rtcp_enable(char *refparam, struct dmctx *ct
|
|||
|
||||
static int get_voice_service_vp_rtp_rtcp_txrepeatinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
dmuci_get_option_value_string("asterisk", "sip_options", "rtcpinterval", &tmp);
|
||||
if(tmp[0] == '\0')
|
||||
*value = "5000";
|
||||
else
|
||||
*value = tmp;
|
||||
*value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtcpinterval", "5000");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1667,11 +1634,7 @@ static int set_line_calling_features_caller_id_name(char *refparam, struct dmctx
|
|||
|
||||
static int get_line_calling_features_callwaiting(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
struct tel_args *telargs = (struct tel_args *)data;
|
||||
|
||||
dmuci_get_value_by_section_string(telargs->tel_section, "callwaiting", value);
|
||||
if((*value)[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct tel_args *)data)->tel_section, "callwaiting", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -334,9 +334,7 @@ static int get_DynamicDNS_SupportedServices(char *refparam, struct dmctx *ctx, v
|
|||
/*#Device.DynamicDNS.Client.{i}.Enable!UCI:ddns/service,@i-1/enabled*/
|
||||
static int get_DynamicDNSClient_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", value);
|
||||
if (*value[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enabled", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -570,9 +568,7 @@ static int get_DynamicDNSClient_HostnameNumberOfEntries(char *refparam, struct d
|
|||
/*#Device.DynamicDNS.Client.{i}.Hostname.{i}.Enable!UCI:ddns/service,@i-1/enabled*/
|
||||
static int get_DynamicDNSClientHostname_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", value);
|
||||
if (*value[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enabled", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -692,9 +688,7 @@ static int get_DynamicDNSClientHostname_LastUpdate(char *refparam, struct dmctx
|
|||
/*#Device.DynamicDNS.Server.{i}.Enable!UCI:ddns/service,@i-1/enabled*/
|
||||
static int get_DynamicDNSServer_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", value);
|
||||
if (*value[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enabled", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -963,9 +957,7 @@ static int set_DynamicDNSServer_Protocol(char *refparam, struct dmctx *ctx, void
|
|||
/*#Device.DynamicDNS.Server.{i}.CheckInterval!UCI:ddns/service,@i-1/check_interval*/
|
||||
static int get_DynamicDNSServer_CheckInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "check_interval", value);
|
||||
if (*value[0] == '\0')
|
||||
*value = "600";
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "check_interval", "600");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1003,9 +995,7 @@ static int set_DynamicDNSServer_CheckInterval(char *refparam, struct dmctx *ctx,
|
|||
/*#Device.DynamicDNS.Server.{i}.RetryInterval!UCI:ddns/service,@i-1/retry_interval*/
|
||||
static int get_DynamicDNSServer_RetryInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "retry_interval", value);
|
||||
if (*value[0] == '\0')
|
||||
*value = "259200";
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "retry_interval", "259200");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1042,9 +1032,7 @@ static int set_DynamicDNSServer_RetryInterval(char *refparam, struct dmctx *ctx,
|
|||
/*#Device.DynamicDNS.Server.{i}.MaxRetries!UCI:ddns/service,@i-1/retry_count*/
|
||||
static int get_DynamicDNSServer_MaxRetries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "retry_count", value);
|
||||
if (*value[0] == '\0')
|
||||
*value = "5";
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "retry_count", "5");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -617,9 +617,7 @@ static int set_EthernetInterface_LowerLayers(char *refparam, struct dmctx *ctx,
|
|||
/*#Device.Ethernet.Interface.{i}.Upstream!UCI:ports/ethport,@i-1/uplink*/
|
||||
static int get_EthernetInterface_Upstream(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "uplink", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct eth_port_args *)data)->eth_port_sec, "uplink", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1456,9 +1454,7 @@ static int get_EthernetVLANTerminationStats_MulticastPacketsReceived(char *refpa
|
|||
/*#Device.Ethernet.RMONStats.{i}.Enable!UCI:ports/ethport,@i-1/rmon*/
|
||||
static int get_EthernetRMONStats_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct eth_rmon_args *)data)->eth_rmon_sec, "rmon", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "1";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct eth_rmon_args *)data)->eth_rmon_sec, "rmon", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -235,9 +235,7 @@ static int set_management_server_connection_request_passwd(char *refparam, struc
|
|||
/*#Device.ManagementServer.UpgradesManaged!UCI:cwmp/cpe,cpe/upgrades_managed*/
|
||||
static int get_upgrades_managed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("cwmp", "cpe", "upgrades_managed", value);
|
||||
if ((*value)[0] == '\0')
|
||||
dmasprintf(value, "%s", "false");
|
||||
*value = dmuci_get_option_value_fallback_def("cwmp", "cpe", "upgrades_managed", "false");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -413,11 +411,8 @@ static int set_management_server_retry_interval_multiplier(char *refparam, struc
|
|||
/*#Device.ManagementServer.AliasBasedAddressing!UCI:cwmp/cpe,cpe/amd_version*/
|
||||
static int get_alias_based_addressing(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("cwmp", "cpe", "amd_version", value);
|
||||
if ((*value)[0] == '\0'|| atoi(*value) <= AMD_4)
|
||||
*value = "false";
|
||||
else
|
||||
*value = "true";
|
||||
char *res = dmuci_get_option_value_fallback_def("cwmp", "cpe", "amd_version", "5");
|
||||
*value = (atoi(res) <= AMD_4) ? "false" : "true";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -550,10 +550,7 @@ static int get_router_ipv4forwarding_status(char *refparam, struct dmctx *ctx, v
|
|||
/*#Device.Routing.Router.{i}.IPv4Forwarding.{i}.DestIPAddress!UCI:network/route,@i-1/target*/
|
||||
static int get_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
if (((struct routingfwdargs *)data)->routefwdsection != NULL)
|
||||
dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "target", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "0.0.0.0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "target", "0.0.0.0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -574,10 +571,7 @@ static int set_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, v
|
|||
/*#Device.Routing.Router.{i}.IPv4Forwarding.{i}.DestSubnetMask!UCI:network/route,@i-1/netmask*/
|
||||
static int get_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
if (((struct routingfwdargs *)data)->routefwdsection != NULL)
|
||||
dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "netmask", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "255.255.255.255";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "netmask", "255.255.255.255");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -621,10 +615,7 @@ static int get_router_ipv4forwarding_origin(char *refparam, struct dmctx *ctx, v
|
|||
/*#Device.Routing.Router.{i}.IPv4Forwarding.{i}.GatewayIPAddress!UCI:network/route,@i-1/gateway*/
|
||||
static int get_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
if (((struct routingfwdargs *)data)->routefwdsection != NULL)
|
||||
dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "gateway", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "0.0.0.0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "gateway", "0.0.0.0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -679,10 +670,7 @@ static int set_router_ipv4forwarding_interface_linker_parameter(char *refparam,
|
|||
/*#Device.Routing.Router.{i}.IPv4Forwarding.{i}.ForwardingMetric!UCI:network/route,@i-1/metric*/
|
||||
static int get_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
if (((struct routingfwdargs *)data)->routefwdsection != NULL)
|
||||
dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "metric", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "metric", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -728,10 +716,7 @@ static int get_RoutingRouterIPv6Forwarding_Status(char *refparam, struct dmctx *
|
|||
/*#Device.Routing.Router.{i}.IPv6Forwarding.{i}.DestIPPrefix!UCI:network/route,@i-1/target*/
|
||||
static int get_RoutingRouterIPv6Forwarding_DestIPPrefix(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
if (((struct routingfwdargs *)data)->routefwdsection != NULL)
|
||||
dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "target", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "::";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "target", "::");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -771,10 +756,7 @@ static int set_RoutingRouterIPv6Forwarding_ForwardingPolicy(char *refparam, stru
|
|||
/*#Device.Routing.Router.{i}.IPv6Forwarding.{i}.NextHop!UCI:network/route,@i-1/gateway*/
|
||||
static int get_RoutingRouterIPv6Forwarding_NextHop(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
if (((struct routingfwdargs *)data)->routefwdsection != NULL)
|
||||
dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "gateway", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "::";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "gateway", "::");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -836,10 +818,7 @@ static int get_RoutingRouterIPv6Forwarding_Origin(char *refparam, struct dmctx *
|
|||
/*#Device.Routing.Router.{i}.IPv6Forwarding.{i}.ForwardingMetric!UCI:network/route,@i-1/metric*/
|
||||
static int get_RoutingRouterIPv6Forwarding_ForwardingMetric(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
if (((struct routingfwdargs *)data)->routefwdsection != NULL)
|
||||
dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "metric", value);
|
||||
if ((*value)[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "metric", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -367,10 +367,7 @@ static int browseUPnPDescriptionServiceInstanceInst(struct dmctx *dmctx, DMNODE
|
|||
/*#Device.UPnP.Device.Enable!UCI:upnpd/upnpd,config/enabled*/
|
||||
static int get_UPnPDevice_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string("upnpd","config","enabled", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
*value = "1";
|
||||
}
|
||||
*value = dmuci_get_option_value_fallback_def("upnpd", "config", "enabled", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1168,9 +1168,7 @@ static int set_WiFiAccessPointSecurity_MFPConfig(char *refparam, struct dmctx *c
|
|||
/*#Device.WiFi.AccessPoint.{i}.WPS.Enable!UCI:wireless/wifi-iface,@i-1/wps*/
|
||||
static int get_WiFiAccessPointWPS_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "wps", value);
|
||||
if(*value[0] == '\0')
|
||||
*value= "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct wifi_acp_args *)data)->wifi_acp_sec, "wps", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1764,9 +1762,7 @@ static int set_WiFiEndPointProfileSecurity_MFPConfig(char *refparam, struct dmct
|
|||
/*#Device.WiFi.EndPoint.{i}.WPS.Enable!UCI:wireless/wifi-iface,@i-1/wps*/
|
||||
static int get_WiFiEndPointWPS_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct wifi_enp_args *)data)->wifi_enp_sec, "wps", value);
|
||||
if(*value[0] == '\0')
|
||||
*value = "0";
|
||||
*value = dmuci_get_value_by_section_fallback_def(((struct wifi_enp_args *)data)->wifi_enp_sec, "wps", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,10 +103,7 @@ static int set_x_iopsys_eu_button_longpress(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
static int get_x_iopsys_eu_button_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
*value = "1";
|
||||
}
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enable", "1");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,11 +32,8 @@ int browseXIopsysEuDropbear(struct dmctx *dmctx, DMNODE *parent_node, void *prev
|
|||
**************************************************************************************/
|
||||
static int get_x_iopsys_eu_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "PasswordAuth", value);
|
||||
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1')
|
||||
*value = "1";
|
||||
else
|
||||
*value = "0";
|
||||
char *res = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "PasswordAuth", "1");
|
||||
*value = ((strcmp(res, "on") == 0) || *res == '1') ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -59,11 +56,8 @@ static int set_x_iopsys_eu_dropbear_password_auth(char *refparam, struct dmctx *
|
|||
|
||||
static int get_x_iopsys_eu_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "RootPasswordAuth", value);
|
||||
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1')
|
||||
*value = "1";
|
||||
else
|
||||
*value = "0";
|
||||
char *res = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "RootPasswordAuth", "1");
|
||||
*value = ((strcmp(res, "on") == 0) || *res == '1') ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -86,10 +80,7 @@ static int set_x_iopsys_eu_dropbear_root_password_auth(char *refparam, struct dm
|
|||
|
||||
static int get_x_iopsys_eu_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "Port", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
*value = "22";
|
||||
}
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "Port", "22");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -100,10 +91,7 @@ static int set_x_iopsys_eu_dropbear_port(char *refparam, struct dmctx *ctx, void
|
|||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (value[0] == '\0')
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "Port", "22");
|
||||
else
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "Port", value);
|
||||
dmuci_set_value_by_section((struct uci_section *)data, "Port", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -138,11 +126,7 @@ static int set_x_iopsys_eu_dropbear_root_login(char *refparam, struct dmctx *ctx
|
|||
|
||||
static int get_x_iopsys_eu_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "verbose", value);
|
||||
if ((*value)[0] == '\0' || (*value)[0] == '0' )
|
||||
*value = "0";
|
||||
else
|
||||
*value = "1";
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "verbose", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -165,11 +149,7 @@ static int set_x_iopsys_eu_dropbear_verbose(char *refparam, struct dmctx *ctx, v
|
|||
|
||||
static int get_x_iopsys_eu_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "GatewayPorts", value);
|
||||
if ((*value)[0] == '\0' || (*value)[0] == '0' )
|
||||
*value = "0";
|
||||
else
|
||||
*value = "1";
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "GatewayPorts", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -249,10 +229,7 @@ static int set_x_iopsys_eu_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx
|
|||
|
||||
static int get_x_iopsys_eu_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "SSHKeepAlive", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
*value = "300";
|
||||
}
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "SSHKeepAlive", "300");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -274,10 +251,7 @@ static int set_x_iopsys_eu_dropbear_ssh_keepalive(char *refparam, struct dmctx *
|
|||
|
||||
static int get_x_iopsys_eu_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "IdleTimeout", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
*value = "300";
|
||||
}
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "IdleTimeout", "300");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,10 +73,7 @@ static int set_x_iopsys_eu_owsd_global_redirect(char *refparam, struct dmctx *ct
|
|||
**************************************************************************************/
|
||||
static int get_x_iopsys_eu_owsd_virtualhost_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "port", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
*value = "";
|
||||
}
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "port", "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -125,12 +122,8 @@ static int set_x_iopsys_eu_owsd_virtualhost_interface(char *refparam, struct dmc
|
|||
|
||||
static int get_x_iopsys_eu_owsd_virtualhost_ipv6_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "ipv6", value);
|
||||
if ((*value)[0] != '\0' && (*value)[0] == 'o' && (*value)[1] == 'n' ) {
|
||||
*value = "1";
|
||||
}
|
||||
else
|
||||
*value = "0";
|
||||
char *res = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "ipv6", "1");
|
||||
*value = (strcmp(res, "on") == 0) ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -153,10 +146,7 @@ static int set_x_iopsys_eu_owsd_virtualhost_ipv6_enable(char *refparam, struct d
|
|||
|
||||
static int get_x_iopsys_eu_owsd_virtualhost_whitelist_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "whitelist_interface_as_origin", value);
|
||||
if ((*value)[0] == '\0' ) {
|
||||
*value = "0";
|
||||
}
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "whitelist_interface_as_origin", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -179,10 +169,7 @@ static int set_x_iopsys_eu_owsd_virtualhost_whitelist_interface(char *refparam,
|
|||
|
||||
static int get_x_iopsys_eu_owsd_virtualhost_whitelist_dhcp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string((struct uci_section *)data, "whitelist_dhcp_domains", value);
|
||||
if ((*value)[0] == '\0') {
|
||||
*value = "0";
|
||||
}
|
||||
*value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "whitelist_dhcp_domains", "0");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,7 @@ static int set_server_ip_address(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int get_server_port_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *tmp;
|
||||
dmuci_get_option_value_string("system", "@system[0]", "log_port", &tmp);
|
||||
if (tmp[0] == '\0')
|
||||
*value = "514";
|
||||
else
|
||||
*value = tmp;
|
||||
*value = dmuci_get_option_value_fallback_def("system", "@system[0]", "log_port", "514");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -55,12 +50,7 @@ static int set_server_port_number(char *refparam, struct dmctx *ctx, void *data,
|
|||
|
||||
static int get_remote_log_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char *tmp;
|
||||
dmuci_get_option_value_string("system", "@system[0]", "conloglevel", &tmp);
|
||||
if (tmp[0] == '\0')
|
||||
*value = "7";
|
||||
else
|
||||
*value = tmp;
|
||||
*value = dmuci_get_option_value_fallback_def("system", "@system[0]", "conloglevel", "7");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -182,6 +182,17 @@ int dmuci_get_option_value_string(char *package, char *section, char *option, ch
|
|||
return 0;
|
||||
}
|
||||
|
||||
char *dmuci_get_option_value_fallback_def(char *package, char *section, char *option, char *default_value)
|
||||
{
|
||||
char *value = "";
|
||||
|
||||
dmuci_get_option_value_string(package, section, option, &value);
|
||||
if (*value == '\0')
|
||||
value = default_value;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int dmuci_get_option_value_list(char *package, char *section, char *option, struct uci_list **value)
|
||||
{
|
||||
struct uci_element *e;
|
||||
|
|
@ -597,6 +608,17 @@ not_found:
|
|||
return -1;
|
||||
}
|
||||
|
||||
char *dmuci_get_value_by_section_fallback_def(struct uci_section *s, char *option, char *default_value)
|
||||
{
|
||||
char *value = "";
|
||||
|
||||
dmuci_get_value_by_section_string(s, option, &value);
|
||||
if (*value == '\0')
|
||||
value = default_value;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int dmuci_get_value_by_section_list(struct uci_section *s, char *option, struct uci_list **value)
|
||||
{
|
||||
struct uci_element *e;
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ void free_all_list_package_change(struct list_head *clist);
|
|||
int dmuci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *package, char *section, char *option, char *value);
|
||||
int dmuci_get_section_type(char *package, char *section,char **value);
|
||||
int dmuci_get_option_value_string(char *package, char *section, char *option, char **value);
|
||||
char *dmuci_get_option_value_fallback_def(char *package, char *section, char *option, char *default_value);
|
||||
int dmuci_get_option_value_list(char *package, char *section, char *option, struct uci_list **value);
|
||||
struct uci_option *dmuci_get_option_ptr(char *cfg_path, char *package, char *section, char *option);
|
||||
int db_get_value_string(char *package, char *section, char *option, char **value);
|
||||
|
|
@ -173,6 +174,7 @@ char * dmuci_add_section_and_rename(char *package, char *stype, struct uci_secti
|
|||
int dmuci_delete(char *package, char *section, char *option, char *value);
|
||||
int dmuci_lookup_ptr_by_section(struct uci_context *ctx, struct uci_ptr *ptr, struct uci_section *s, char *option, char *value);
|
||||
int dmuci_get_value_by_section_string(struct uci_section *s, char *option, char **value);
|
||||
char *dmuci_get_value_by_section_fallback_def(struct uci_section *s, char *option, char *default_value);
|
||||
int dmuci_get_value_by_section_list(struct uci_section *s, char *option, struct uci_list **value);
|
||||
char *dmuci_set_value_by_section(struct uci_section *s, char *option, char *value);
|
||||
int dmuci_delete_by_section(struct uci_section *s, char *option, char *value);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue