From 5839164c2940ff09930f19003eee57f967f1ba95 Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Sat, 17 Oct 2020 14:08:40 +0100 Subject: [PATCH] TR-181: Fixed invalid int && unsignedInt && hexBinary parameter values --- dmentryjson.c | 2 + .../tr104/servicesvoiceservicecallcontrol.c | 6 +- dmtree/tr104/servicesvoiceservicecalllog.c | 6 +- .../tr104/servicesvoiceservicecapabilities.c | 8 +- dmtree/tr104/servicesvoiceservicepots.c | 6 +- dmtree/tr104/servicesvoiceservicesip.c | 8 +- .../tr104/servicesvoiceservicevoipprofile.c | 14 +- dmtree/tr143/diagnostics.c | 14 +- dmtree/tr181/atm.c | 2 +- dmtree/tr181/bridging.c | 4 +- dmtree/tr181/deviceinfo.c | 15 +- dmtree/tr181/dhcpv4.c | 130 +++++------------- dmtree/tr181/dhcpv6.c | 11 +- dmtree/tr181/dns.c | 6 +- dmtree/tr181/dsl.c | 28 ++-- dmtree/tr181/dynamicdns.c | 2 +- dmtree/tr181/ethernet.c | 7 +- dmtree/tr181/firewall.c | 3 +- dmtree/tr181/gre.c | 2 +- dmtree/tr181/hosts-iopsyswrt.c | 26 ++-- dmtree/tr181/ieee1905.c | 34 ++--- dmtree/tr181/managementserver.c | 29 ++-- dmtree/tr181/nat.c | 2 +- dmtree/tr181/ppp.c | 4 +- dmtree/tr181/qos-iopsyswrt.c | 60 ++++---- dmtree/tr181/routing.c | 18 ++- dmtree/tr181/security.c | 8 +- dmtree/tr181/usb.c | 2 +- dmtree/tr181/users.c | 12 +- dmtree/tr181/wifi-iopsyswrt.c | 35 ++--- dmtree/tr181/wifi.c | 32 ++--- dmtree/tr181/x_iopsys_eu_buttons.c | 4 +- dmtree/tr181/x_iopsys_eu_igmp.c | 45 ++---- dmtree/tr181/x_iopsys_eu_owsd.c | 8 +- libbbf_api/dmjson.h | 1 + 35 files changed, 250 insertions(+), 344 deletions(-) diff --git a/dmentryjson.c b/dmentryjson.c index 58aaecfa..991f7387 100644 --- a/dmentryjson.c +++ b/dmentryjson.c @@ -687,6 +687,8 @@ static void parse_param(char *object, char *param, json_object *jobj, DMLEAF *pl pleaf[i].type = DMT_LONG; else if (strcmp(json_object_get_string(type), "dateTime") == 0) pleaf[i].type = DMT_TIME; + else if (strcmp(json_object_get_string(type), "base64") == 0) + pleaf[i].type = DMT_BASE64; else pleaf[i].type = DMT_STRING; diff --git a/dmtree/tr104/servicesvoiceservicecallcontrol.c b/dmtree/tr104/servicesvoiceservicecallcontrol.c index 3f93cea1..a447f645 100644 --- a/dmtree/tr104/servicesvoiceservicecallcontrol.c +++ b/dmtree/tr104/servicesvoiceservicecallcontrol.c @@ -456,7 +456,7 @@ static int set_ServicesVoiceServiceCallControlOutgoingMap_CLIPNoScreeningNumber( /*#Device.Services.VoiceService.{i}.CallControl.NumberingPlan.InterDigitTimerStd!UCI:asterisk/tel_advanced,tel_options/interdigit*/ static int get_ServicesVoiceServiceCallControlNumberingPlan_InterDigitTimerStd(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "tel_options", "interdigit", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "tel_options", "interdigit", "15000"); return 0; } @@ -477,7 +477,7 @@ static int set_ServicesVoiceServiceCallControlNumberingPlan_InterDigitTimerStd(c /*#Device.Services.VoiceService.{i}.CallControl.CallingFeatures.Set.CallWaitingEnable!UCI:asterisk/advanced_features,call_features/callwaiting_enabled*/ static int get_ServicesVoiceServiceCallControlCallingFeaturesSet_CallWaitingEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "call_features", "callwaiting_enabled", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "call_features", "callwaiting_enabled", "1"); return 0; } @@ -501,7 +501,7 @@ static int set_ServicesVoiceServiceCallControlCallingFeaturesSet_CallWaitingEnab /*#Device.Services.VoiceService.{i}.CallControl.CallingFeatures.Set.CallForwardUnconditionalEnable!UCI:asterisk/advanced_features,call_features/callforward_enabled*/ static int get_ServicesVoiceServiceCallControlCallingFeaturesSet_CallForwardUnconditionalEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "call_features", "callforward_enabled", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "call_features", "callforward_enabled", "1"); return 0; } diff --git a/dmtree/tr104/servicesvoiceservicecalllog.c b/dmtree/tr104/servicesvoiceservicecalllog.c index 941e4697..512134cf 100644 --- a/dmtree/tr104/servicesvoiceservicecalllog.c +++ b/dmtree/tr104/servicesvoiceservicecalllog.c @@ -94,11 +94,7 @@ static int get_ServicesVoiceServiceCallLog_Start(char *refparam, struct dmctx *c static int get_ServicesVoiceServiceCallLog_Duration(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { struct call_log_entry *entry = (struct call_log_entry *)data; - - if (entry) { - *value = dmstrdup(entry->duration); - } - + *value = (entry) ? dmstrdup(entry->duration) : "0"; return 0; } diff --git a/dmtree/tr104/servicesvoiceservicecapabilities.c b/dmtree/tr104/servicesvoiceservicecapabilities.c index 585b15a6..7368c685 100644 --- a/dmtree/tr104/servicesvoiceservicecapabilities.c +++ b/dmtree/tr104/servicesvoiceservicecapabilities.c @@ -37,6 +37,8 @@ static int browseServicesVoiceServiceCapabilitiesCodecInst(struct dmctx *dmctx, static int get_ServicesVoiceServiceCapabilities_MaxLineCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { db_get_value_string("hw", "board", "VoicePorts", value); + if ((*value)[0] == '\0') + *value = "-1"; return 0; } @@ -54,7 +56,8 @@ static int get_ServicesVoiceServiceCapabilities_MaxSessionCount(char *refparam, if (max_line && *max_line) { int max_session = 2 * atoi(max_line); dmasprintf(value, "%d", max_session); - } + } else + *value = "-1"; return 0; } @@ -146,7 +149,8 @@ static int get_ServicesVoiceServiceCapabilitiesCodec_BitRate(char *refparam, str if (data) { struct codec_info *codec = (struct codec_info *)data; dmasprintf(value, "%d", codec->bit_rate); - } + } else + *value = "0"; return 0; } diff --git a/dmtree/tr104/servicesvoiceservicepots.c b/dmtree/tr104/servicesvoiceservicepots.c index 7fcbaf02..40b2a860 100644 --- a/dmtree/tr104/servicesvoiceservicepots.c +++ b/dmtree/tr104/servicesvoiceservicepots.c @@ -124,7 +124,7 @@ static int get_ServicesVoiceServicePOTSFXS_TerminalType(char *refparam, struct d /*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.TransmitGain!UCI:asterisk/tel_line,@i-1/txgain*/ static int get_ServicesVoiceServicePOTSFXSVoiceProcessing_TransmitGain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "txgain", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "txgain", "0"); return 0; } @@ -145,7 +145,7 @@ static int set_ServicesVoiceServicePOTSFXSVoiceProcessing_TransmitGain(char *ref /*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.ReceiveGain!UCI:asterisk/tel_line,@i-1/rxgain*/ static int get_ServicesVoiceServicePOTSFXSVoiceProcessing_ReceiveGain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "rxgain", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "rxgain", "0"); return 0; } @@ -166,7 +166,7 @@ static int set_ServicesVoiceServicePOTSFXSVoiceProcessing_ReceiveGain(char *refp /*#Device.Services.VoiceService.{i}.POTS.FXS.{i}.VoiceProcessing.EchoCancellationEnable!UCI:asterisk/tel_line,@i-1/echo_cancel*/ static int get_ServicesVoiceServicePOTSFXSVoiceProcessing_EchoCancellationEnable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "echo_cancel", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "echo_cancel", "1"); return 0; } diff --git a/dmtree/tr104/servicesvoiceservicesip.c b/dmtree/tr104/servicesvoiceservicesip.c index 8e4c63a2..f4fbd2e7 100644 --- a/dmtree/tr104/servicesvoiceservicesip.c +++ b/dmtree/tr104/servicesvoiceservicesip.c @@ -218,7 +218,7 @@ static int delObjServicesVoiceServiceSIPNetworkFQDNServer(char *refparam, struct /*#Device.Services.VoiceService.{i}.SIP.Client.{i}.Enable!UCI:asterisk/sip_service_provider,@i-1/enabled*/ static int get_ServicesVoiceServiceSIPClient_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enabled", "1"); return 0; } @@ -361,7 +361,7 @@ static int get_ServicesVoiceServiceSIPClientContact_Origin(char *refparam, struc /*#Device.Services.VoiceService.{i}.SIP.Client.{i}.Contact.Port!UCI:asterisk/sip_advanced,sip_options/bindport*/ static int get_ServicesVoiceServiceSIPClientContact_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "sip_options", "bindport", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "bindport", "0"); return 0; } @@ -463,7 +463,7 @@ static int get_ServicesVoiceServiceSIPClientContact_UserAgent(char *refparam, st /*#Device.Services.VoiceService.{i}.SIP.Network.{i}.Enable!UCI:asterisk/sip_service_provider,@i-1/enabled*/ static int get_ServicesVoiceServiceSIPNetwork_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enabled", "1"); return 0; } @@ -858,7 +858,7 @@ static int set_ServicesVoiceServiceSIPNetwork_RegisterExpires(char *refparam, st /*#Device.Services.VoiceService.{i}.SIP.Network.{i}.DSCPMark!UCI:asterisk/sip_advanced,sip_options/tos_sip*/ static int get_ServicesVoiceServiceSIPNetwork_DSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "sip_options", "tos_sip", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "tos_sip", "0"); return 0; } diff --git a/dmtree/tr104/servicesvoiceservicevoipprofile.c b/dmtree/tr104/servicesvoiceservicevoipprofile.c index 2f0553f5..77787b1f 100644 --- a/dmtree/tr104/servicesvoiceservicevoipprofile.c +++ b/dmtree/tr104/servicesvoiceservicevoipprofile.c @@ -58,7 +58,7 @@ static int set_ServicesVoiceServiceVoIPProfile_DTMFMethod(char *refparam, struct /*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.LocalPortMin!UCI:asterisk/sip_advanced,sip_options/rtpstart*/ static int get_ServicesVoiceServiceVoIPProfileRTP_LocalPortMin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "sip_options", "rtpstart", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtpstart", "1024"); return 0; } @@ -79,7 +79,7 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_LocalPortMin(char *refparam, s /*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.LocalPortMax!UCI:asterisk/sip_advanced,sip_options/rtpend*/ static int get_ServicesVoiceServiceVoIPProfileRTP_LocalPortMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "sip_options", "rtpend", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtpend", "1024"); return 0; } @@ -100,7 +100,7 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_LocalPortMax(char *refparam, s /*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.DSCPMark!UCI:asterisk/sip_advanced,sip_options/tos_audio*/ static int get_ServicesVoiceServiceVoIPProfileRTP_DSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "sip_options", "tos_audio", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "tos_audio", "0"); return 0; } @@ -121,7 +121,7 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_DSCPMark(char *refparam, struc /*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.TelephoneEventPayloadType!UCI:asterisk/tel_advanced,tel_options/tel_event_pt*/ static int get_ServicesVoiceServiceVoIPProfileRTP_TelephoneEventPayloadType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "tel_options", "tel_event_pt", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "tel_options", "tel_event_pt", "0"); return 0; } @@ -174,7 +174,7 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_JitterBufferType(char *refpara /*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.JitterBufferMaxSize!UCI:asterisk/tel_advanced,tel_options/jbmaxsize*/ static int get_ServicesVoiceServiceVoIPProfileRTP_JitterBufferMaxSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "tel_options", "jbmaxsize", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "tel_options", "jbmaxsize", "0"); return 0; } @@ -195,7 +195,7 @@ static int set_ServicesVoiceServiceVoIPProfileRTP_JitterBufferMaxSize(char *refp /*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.RTCP.TxRepeatInterval!UCI:asterisk/sip_advanced,sip_options/rtcpinterval*/ static int get_ServicesVoiceServiceVoIPProfileRTPRTCP_TxRepeatInterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("asterisk", "sip_options", "rtcpinterval", value); + *value = dmuci_get_option_value_fallback_def("asterisk", "sip_options", "rtcpinterval", "1"); return 0; } @@ -216,7 +216,7 @@ static int set_ServicesVoiceServiceVoIPProfileRTPRTCP_TxRepeatInterval(char *ref /*#Device.Services.VoiceService.{i}.VoIPProfile.{i}.RTP.SRTP.Enable!UCI:asterisk/sip_service_provider,@i-1/encryption*/ static int get_ServicesVoiceServiceVoIPProfileRTPSRTP_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "encryption", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "encryption", "1"); return 0; } diff --git a/dmtree/tr143/diagnostics.c b/dmtree/tr143/diagnostics.c index 130e88f8..4aa14a02 100644 --- a/dmtree/tr143/diagnostics.c +++ b/dmtree/tr143/diagnostics.c @@ -597,7 +597,7 @@ static int set_IPDiagnosticsDownloadDiagnostics_DSCP(char *refparam, struct dmct static int get_IPDiagnosticsDownloadDiagnostics_EthernetPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = get_diagnostics_option("download", "ethernetpriority"); + *value = get_diagnostics_option_fallback_def("download", "ethernetpriority", "0"); return 0; } @@ -786,13 +786,13 @@ static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TestBytesRece static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "TotalBytesReceived", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TotalBytesReceived", "0"); return 0; } static int get_IPDiagnosticsDownloadDiagnosticsPerConnectionResult_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "TotalBytesSent", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TotalBytesSent", "0"); return 0; } @@ -1128,19 +1128,19 @@ static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_EOMTime(char *r static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TestBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "TestBytesSent", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TestBytesSent", "0"); return 0; } static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "TotalBytesReceived", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TotalBytesReceived", "0"); return 0; } static int get_IPDiagnosticsUploadDiagnosticsPerConnectionResult_TotalBytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "TotalBytesSent", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "TotalBytesSent", "0"); return 0; } @@ -1229,7 +1229,7 @@ static int set_IPDiagnosticsUDPEchoDiagnostics_Host(char *refparam, struct dmctx static int get_IPDiagnosticsUDPEchoDiagnostics_Port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = get_diagnostics_option("udpechodiag", "port"); + *value = get_diagnostics_option_fallback_def("udpechodiag", "port", "1"); return 0; } diff --git a/dmtree/tr181/atm.c b/dmtree/tr181/atm.c index 8153b3fb..e88266f6 100644 --- a/dmtree/tr181/atm.c +++ b/dmtree/tr181/atm.c @@ -27,7 +27,7 @@ static int get_atm_linker(char *refparam, struct dmctx *dmctx, void *data, char *linker = ((struct atm_args *)data)->ifname; return 0; } - *linker = "" ; + *linker = ""; return 0; } diff --git a/dmtree/tr181/bridging.c b/dmtree/tr181/bridging.c index 72b5e2cb..205b1df1 100644 --- a/dmtree/tr181/bridging.c +++ b/dmtree/tr181/bridging.c @@ -1564,7 +1564,7 @@ static int set_BridgingBridgePort_ManagementPort(char *refparam, struct dmctx *c static int get_BridgingBridgePort_DefaultUserPriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_sec, "priority", value); + *value = dmuci_get_value_by_section_fallback_def(((struct bridge_port_args *)data)->bridge_port_sec, "priority", "0"); return 0; } @@ -1699,7 +1699,7 @@ static int set_BridgingBridgePort_DSCP_Eth_Priority_Map(char *refparam, struct d static int get_BridgingBridgePort_PVID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string(((struct bridge_port_args *)data)->bridge_port_sec, "vid", value); + *value = dmuci_get_value_by_section_fallback_def(((struct bridge_port_args *)data)->bridge_port_sec, "vid", "1"); return 0; } diff --git a/dmtree/tr181/deviceinfo.c b/dmtree/tr181/deviceinfo.c index bf674e44..86498acd 100644 --- a/dmtree/tr181/deviceinfo.c +++ b/dmtree/tr181/deviceinfo.c @@ -187,7 +187,7 @@ static int get_DeviceInfo_ProcessorNumberOfEntries(char *refparam, struct dmctx static int get_DeviceInfo_SupportedDataModelNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmasprintf(value, "%d", sizeof(Data_Models)/sizeof(struct Supported_Data_Models)); + dmasprintf(value, "%d", ARRAY_SIZE(Data_Models)); return 0; } @@ -213,15 +213,16 @@ static int get_vcf_date(char *refparam, struct dmctx *ctx, void *data, char *ins { DIR *dir; struct dirent *d_file; - struct stat attr; - char path[280]; - char date[sizeof "AAAA-MM-JJTHH:MM:SSZ"]; + char *config_name; - *value = ""; - dmuci_get_value_by_section_string((struct uci_section *)data, "name", value); + *value = "0001-01-01T00:00:00Z"; + dmuci_get_value_by_section_string((struct uci_section *)data, "name", &config_name); if ((dir = opendir (DEFAULT_CONFIG_DIR)) != NULL) { while ((d_file = readdir (dir)) != NULL) { - if(strcmp(*value, d_file->d_name) == 0) { + if (strcmp(config_name, d_file->d_name) == 0) { + char date[sizeof("AAAA-MM-JJTHH:MM:SSZ")], path[128] = {0}; + struct stat attr; + snprintf(path, sizeof(path), DEFAULT_CONFIG_DIR"%s", d_file->d_name); stat(path, &attr); strftime(date, sizeof(date), "%Y-%m-%dT%H:%M:%SZ", localtime(&attr.st_mtime)); diff --git a/dmtree/tr181/dhcpv4.c b/dmtree/tr181/dhcpv4.c index 86961a65..80c82a18 100644 --- a/dmtree/tr181/dhcpv4.c +++ b/dmtree/tr181/dhcpv4.c @@ -665,8 +665,7 @@ static int get_dhcp_sever_pool_order(char *refparam, struct dmctx *ctx, void *da struct uci_section *dmmap_sect = NULL; get_dmmap_section_of_config_section("dmmap_dhcp", "dhcp", section_name(((struct dhcp_args *)data)->dhcp_sec), &dmmap_sect); - if (dmmap_sect) - dmuci_get_value_by_section_string(dmmap_sect, "order", value); + dmuci_get_value_by_section_string(dmmap_sect, "order", value); return 0; } @@ -1447,20 +1446,9 @@ static int get_DHCPv4_ClientNumberOfEntries(char *refparam, struct dmctx *ctx, v /*#Device.DHCPv4.Client.{i}.Enable!UCI:network/interface,@i-1/disabled*/ static int get_DHCPv4Client_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *v = NULL; - - if(((struct dhcp_client_args *)data)->dhcp_client_conf == NULL) { - *value = "0"; - return 0; - } - - dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", &v); - - if (v == NULL || strlen(v) == 0 || strcmp(v, "1") != 0) - *value = "1"; - else - *value = "0"; - + char *disabled = NULL; + dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", &disabled); + *value = (disabled[0] == '1') ? "0" : "1"; return 0; } @@ -1505,15 +1493,12 @@ static int set_DHCPv4Client_Alias(char *refparam, struct dmctx *ctx, void *data, static int get_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - if(((struct dhcp_client_args *)data)->dhcp_client_conf == NULL) { - *value = ""; - return 0; + if (((struct dhcp_client_args *)data)->dhcp_client_conf) { + char *linker = dmstrdup(section_name(((struct dhcp_client_args *)data)->dhcp_client_conf)); + adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), linker, value); + if (*value == NULL) + *value = ""; } - - char *linker = dmstrdup(section_name(((struct dhcp_client_args *)data)->dhcp_client_conf)); - adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim), linker, value); - if (*value == NULL) - *value = ""; return 0; } @@ -1558,40 +1543,24 @@ static int set_DHCPv4Client_Interface(char *refparam, struct dmctx *ctx, void *d /*#Device.DHCPv4.Client.{i}.Status!UCI:network/interface,@i-1/disabled*/ static int get_DHCPv4Client_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *v = NULL; - if (((struct dhcp_client_args *)data)->dhcp_client_conf == NULL) { - *value = "Error_Misconfigured"; - return 0; - } - - dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", &v); - if (v == NULL || strlen(v) == 0 || strcmp(v, "1") != 0) - *value = "Enabled"; - else - *value = "Disabled"; - + char *disabled = NULL; + dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", &disabled); + *value = (disabled[0] == '1') ? "Disabled" : "Enabled"; return 0; } /*#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) { - char *ipaddr = ""; - json_object *res, *jobj; - if (((struct dhcp_client_args *)data)->dhcp_client_conf == NULL) return 0; + json_object *res; dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct dhcp_client_args *)data)->dhcp_client_conf), String}}, 1, &res); - if (res) { - jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address"); - ipaddr = dmjson_get_value(jobj, 1, "address"); - } - - if (ipaddr[0] == '\0') - *value = "Requesting"; - else - *value = "Bound"; + DM_ASSERT(res, *value = "Requesting"); + json_object *jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address"); + char *ipaddr = dmjson_get_value(jobj, 1, "address"); + *value = (ipaddr[0] == '\0') ? "Requesting" : "Bound"; return 0; } @@ -1690,7 +1659,7 @@ static int get_DHCPv4Client_LeaseTimeRemaining(char *refparam, struct dmctx *ctx return 0; dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct dhcp_client_args *)data)->dhcp_client_conf), String}}, 1, &res); - DM_ASSERT(res, *value = ""); + DM_ASSERT(res, *value = "-1"); *value = dmjson_get_value(res, 2, "data", "leasetime"); return 0; } @@ -1698,16 +1667,13 @@ static int get_DHCPv4Client_LeaseTimeRemaining(char *refparam, struct dmctx *ctx /*#Device.DHCPv4.Client.{i}.SentOptionNumberOfEntries!UCI:network/interface,@i-1/sendopts*/ static int get_DHCPv4Client_SentOptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *v = NULL; - size_t length; + char *sendopts = NULL; + size_t length = 0; + + dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "sendopts", &sendopts); + if (sendopts && *sendopts) + strsplit(sendopts, " ", &length); - if (((struct dhcp_client_args *)data)->dhcp_client_conf != NULL) - dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "sendopts", &v); - if (v == NULL) { - *value = "0"; - return 0; - } - strsplit(v, " ", &length); dmasprintf(value, "%d", length); return 0; } @@ -1715,16 +1681,13 @@ static int get_DHCPv4Client_SentOptionNumberOfEntries(char *refparam, struct dmc /*#Device.DHCPv4.Client.{i}.ReqOptionNumberOfEntries!UCI:network/interface,@i-1/reqopts*/ static int get_DHCPv4Client_ReqOptionNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *v = NULL; - size_t length; + char *reqopts = NULL; + size_t length = 0; + + dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "reqopts", &reqopts); + if (reqopts && *reqopts) + strsplit(reqopts, " ", &length); - if (((struct dhcp_client_args *)data)->dhcp_client_conf != NULL) - dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "reqopts", &v); - if (v == NULL) { - *value = "0"; - return 0; - } - strsplit(v, " ", &length); dmasprintf(value, "%d", length); return 0; } @@ -2033,7 +1996,7 @@ static int set_DHCPv4ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, static int get_DHCPv4Server_PoolNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { struct uci_section *s; - int i= 0; + int i = 0; uci_foreach_sections("dhcp", "dhcp", s) { i++; @@ -2145,19 +2108,9 @@ static int set_DHCPv4ServerPoolOption_Value(char *refparam, struct dmctx *ctx, v /*#Device.DHCPv4.Relay.Forwarding.{i}.Enable!UCI:network/interface,@i-1/disabled*/ static int get_DHCPv4RelayForwarding_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *v = NULL; - - if(((struct dhcp_client_args *)data)->dhcp_client_conf == NULL) { - *value = "0"; - return 0; - } - - dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", &v); - if (v == NULL || strlen(v) == 0 || strcmp(v, "1") != 0) - *value = "1"; - else - *value = "0"; - + char *disabled = NULL; + dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", &disabled); + *value = (disabled[0] == '1') ? "0" : "1"; return 0; } @@ -2387,18 +2340,9 @@ static int set_DHCPv4RelayForwarding_ChaddrExclude(char *refparam, struct dmctx /*#Device.DHCPv4.Relay.Forwarding.{i}.Status!UCI:network/interface,@i-1/disabled*/ static int get_DHCPv4RelayForwarding_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *v = NULL; - - if (((struct dhcp_client_args *)data)->dhcp_client_conf == NULL) { - *value= "Error_Misconfigured"; - return 0; - } - dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", &v); - if (v == NULL || strlen(v) == 0 || strcmp(v, "1") != 0) - *value= "Enabled"; - else - *value= "Disabled"; - + char *disabled = NULL; + dmuci_get_value_by_section_string(((struct dhcp_client_args *)data)->dhcp_client_conf, "disabled", &disabled); + *value = (disabled[0] == '1') ? "Disabled" : "Enabled"; return 0; } diff --git a/dmtree/tr181/dhcpv6.c b/dmtree/tr181/dhcpv6.c index fa7378b9..ebd0a9e4 100644 --- a/dmtree/tr181/dhcpv6.c +++ b/dmtree/tr181/dhcpv6.c @@ -631,7 +631,7 @@ static int get_DHCPv6Client_RequestAddresses(char *refparam, struct dmctx *ctx, { char *v = NULL; if(((struct dhcpv6_client_args *)data)->dhcp_client_conf == NULL) { - *value = ""; + *value = "0"; return 0; } @@ -665,7 +665,7 @@ static int get_DHCPv6Client_RequestPrefixes(char *refparam, struct dmctx *ctx, v { char *v = ""; if (((struct dhcpv6_client_args *)data)->dhcp_client_conf == NULL) { - *value = ""; + *value = "0"; return 0; } @@ -875,8 +875,7 @@ static int get_DHCPv6ServerPool_Order(char *refparam, struct dmctx *ctx, void *d struct uci_section *dmmap_sect = NULL; get_dmmap_section_of_config_section("dmmap_dhcpv6", "dhcp", section_name(((struct dhcpv6_args *)data)->dhcp_sec), &dmmap_sect); - if (dmmap_sect) - dmuci_get_value_by_section_string(dmmap_sect, "order", value); + dmuci_get_value_by_section_string(dmmap_sect, "order", value); return 0; } @@ -1273,7 +1272,7 @@ static int get_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, size_t length; if(strcmp(((struct dhcpv6_client_option_args *)data)->option_tag, "0") == 0){ - *value= "0"; + *value = "0"; return 0; } @@ -1282,7 +1281,7 @@ static int get_DHCPv6ServerPoolOption_Enable(char *refparam, struct dmctx *ctx, uci_foreach_element(dhcp_option_list, e) { buf = strsplit(e->name, ",", &length); if (strcmp(buf[0], ((struct dhcpv6_client_option_args *)data)->option_tag) == 0) { - *value= "1"; + *value = "1"; return 0; } } diff --git a/dmtree/tr181/dns.c b/dmtree/tr181/dns.c index 762a41e8..475e39ba 100644 --- a/dmtree/tr181/dns.c +++ b/dmtree/tr181/dns.c @@ -293,7 +293,7 @@ static int get_client_server_number_of_entries(char *refparam, struct dmctx *ctx static int get_server_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "enable", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enable", "1"); return 0; } @@ -381,7 +381,7 @@ static int get_relay_forward_number_of_entries(char *refparam, struct dmctx *ctx static int get_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "enable", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enable", "1"); return 0; } @@ -520,7 +520,7 @@ static int get_result_d_n_s_server_i_p(char *refparam, struct dmctx *ctx, void * static int get_result_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "ResponseTime", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "ResponseTime", "0"); return 0; } diff --git a/dmtree/tr181/dsl.c b/dmtree/tr181/dsl.c index d813d4e7..e7b31085 100644 --- a/dmtree/tr181/dsl.c +++ b/dmtree/tr181/dsl.c @@ -440,19 +440,20 @@ static int get_DSLLine_StandardsSupported(char *refparam, struct dmctx *ctx, voi /*#Device.DSL.Line.{i}.XTSE!UBUS:dsl.line.0/status//xtse*/ static int get_DSLLine_XTSE(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *xtse,*pch, *spch, *tmpPtr, *str = ""; + char *xtse, *pch, *spch, *tmpPtr = NULL, *str = NULL; - *value = ""; + *value = "0000000000000000"; xtse = get_dsl_value_array_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "xtse"); if(xtse[0] == '\0') return 0; - for (pch = strtok_r(xtse, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch)) - { - if(*str == '\0') + for (pch = strtok_r(xtse, ",", &spch); pch; pch = strtok_r(NULL, ",", &spch)) { + if(!str) dmasprintf(&str, "%s", pch); else { - tmpPtr = str; + tmpPtr = dmstrdup(str); + dmfree(str); dmasprintf(&str, "%s%s", tmpPtr, pch); + dmfree(tmpPtr); } } *value = str; @@ -470,19 +471,20 @@ static int get_DSLLine_StandardUsed(char *refparam, struct dmctx *ctx, void *dat /*#Device.DSL.Line.{i}.XTSUsed!UBUS:dsl.line.0/status//xtse_used*/ static int get_DSLLine_XTSUsed(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *xtse_used,*pch, *spch, *tmpPtr, *str = ""; + char *xtse_used,*pch, *spch, *tmpPtr = NULL, *str = NULL; - *value = ""; + *value = "0000000000000000"; xtse_used = get_dsl_value_array_without_argument("dsl.line", ((struct dsl_line_args*)data)->id, "status", "xtse_used"); - if(xtse_used[0] == '\0') + if (xtse_used[0] == '\0') return 0; - for (pch = strtok_r(xtse_used, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch)) - { - if(*str == '\0') + for (pch = strtok_r(xtse_used, ",", &spch); pch != NULL; pch = strtok_r(NULL, ",", &spch)) { + if(!str) dmasprintf(&str, "%s", pch); else { - tmpPtr = str; + tmpPtr = dmstrdup(str); + dmfree(str); dmasprintf(&str, "%s%s", tmpPtr, pch); + dmfree(tmpPtr); } } *value = str; diff --git a/dmtree/tr181/dynamicdns.c b/dmtree/tr181/dynamicdns.c index 8f9d3396..a45f6551 100644 --- a/dmtree/tr181/dynamicdns.c +++ b/dmtree/tr181/dynamicdns.c @@ -658,7 +658,7 @@ static int get_DynamicDNSClientHostname_LastUpdate(char *refparam, struct dmctx FILE* fp = NULL; char *pch = NULL, *spch = NULL, *last_time = NULL, *uptime = NULL, *rundir = NULL; char current_time[32] = "", buf[16] = "", path[64] = ""; - *value = "0"; + *value = "0001-01-01T00:00:00Z"; dmuci_get_option_value_string("ddns", "global", "ddns_rundir", &rundir); if (*rundir == '\0') diff --git a/dmtree/tr181/ethernet.c b/dmtree/tr181/ethernet.c index 41083039..3b678cbf 100644 --- a/dmtree/tr181/ethernet.c +++ b/dmtree/tr181/ethernet.c @@ -522,7 +522,7 @@ static int get_Ethernet_RMONStatsNumberOfEntries(char *refparam, struct dmctx *c /*#Device.Ethernet.Interface.{i}.Enable!UCI:ports/ethport,@i-1/enabled*/ static int get_EthernetInterface_Enable(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, "enabled", value); + *value = dmuci_get_value_by_section_fallback_def(((struct eth_port_args *)data)->eth_port_sec, "enabled", "1"); return 0; } @@ -754,7 +754,7 @@ static int get_EthernetInterface_EEECapability(char *refparam, struct dmctx *ctx /*#Device.Ethernet.Interface.{i}.EEEEnable!UCI:ports/ethport,@i-1/eee*/ static int get_EthernetInterface_EEEEnable(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, "eee", value); + *value = dmuci_get_value_by_section_fallback_def(((struct eth_port_args *)data)->eth_port_sec, "eee", "1"); return 0; } @@ -1311,8 +1311,7 @@ static int set_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx /*#Device.Ethernet.VLANTermination.{i}.VLANID!UCI:network/device,@i-1/vid*/ static int get_EthernetVLANTermination_VLANID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = "0"; - dmuci_get_value_by_section_string(((struct dm_args *)data)->section, "vid", value); + *value = dmuci_get_value_by_section_fallback_def(((struct dm_args *)data)->section, "vid", "1"); return 0; } diff --git a/dmtree/tr181/firewall.c b/dmtree/tr181/firewall.c index 511a8914..ff3bf378 100644 --- a/dmtree/tr181/firewall.c +++ b/dmtree/tr181/firewall.c @@ -275,8 +275,7 @@ static int get_rule_order(char *refparam, struct dmctx *ctx, void *data, char *i { struct uci_section *dms = NULL; get_dmmap_section_of_config_section("dmmap_firewall", "rule", section_name((struct uci_section *)data), &dms); - if (dms) - dmuci_get_value_by_section_string(dms, "firewall_chain_rule_instance", value); + dmuci_get_value_by_section_string(dms, "firewall_chain_rule_instance", value); return 0; } diff --git a/dmtree/tr181/gre.c b/dmtree/tr181/gre.c index 04b0173f..163e23a5 100644 --- a/dmtree/tr181/gre.c +++ b/dmtree/tr181/gre.c @@ -272,7 +272,7 @@ static int set_GRETunnel_Alias(char *refparam, struct dmctx *ctx, void *data, ch static int get_GRETunnel_KeepAliveThreshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "keepalive", value); + *value = dmuci_get_value_by_section_fallback_def(((struct dmmap_dup *)data)->config_section, "keepalive", "3"); return 0; } diff --git a/dmtree/tr181/hosts-iopsyswrt.c b/dmtree/tr181/hosts-iopsyswrt.c index 99fc2325..63d15c0c 100644 --- a/dmtree/tr181/hosts-iopsyswrt.c +++ b/dmtree/tr181/hosts-iopsyswrt.c @@ -83,7 +83,7 @@ int os__get_Hosts_HostNumberOfEntries(char *refparam, struct dmctx *ctx, void *d dmubus_call("router.network", "hosts", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = "0"); json_object_object_get_ex(res, "hosts", &hosts); - nbre_hosts = json_object_array_length(hosts); + nbre_hosts = (hosts) ? json_object_array_length(hosts) : 0; dmasprintf(value, "%d", nbre_hosts); return 0; } @@ -245,19 +245,21 @@ int os__get_HostsHost_Active(char *refparam, struct dmctx *ctx, void *data, char /*#Device.Hosts.Host.{i}.ActiveLastChange!UBUS:router.network/hosts//hosts[@i-1].activelstch*/ int os__get_HostsHost_ActiveLastChange(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char local_time[32] = {0}; - time_t t_time; - *value = "0001-01-01T00:00:00Z"; + char *lastchange = dmjson_get_value((json_object *)data, 1, "activelstch"); - t_time = atoi(lastchange); - if (localtime(&t_time) == NULL) - return -1; + if (lastchange && *lastchange != '\0' && atoi(lastchange) > 0) { + time_t t_time = atoi(lastchange); + if (localtime(&t_time) == NULL) + return -1; - if (strftime(local_time, sizeof(local_time), "%Y-%m-%dT%H:%M:%SZ", localtime(&t_time)) == 0) - return -1; + char local_time[32] = {0}; - *value = dmstrdup(local_time); + if (strftime(local_time, sizeof(local_time), "%Y-%m-%dT%H:%M:%SZ", localtime(&t_time)) == 0) + return -1; + + *value = dmstrdup(local_time); + } return 0; } @@ -268,7 +270,7 @@ int os__get_HostsHost_IPv4AddressNumberOfEntries(char *refparam, struct dmctx *c size_t nbre_addr = 0; json_object_object_get_ex((json_object *)data, "ipv4addr", &ipv4addr); - nbre_addr = json_object_array_length(ipv4addr); + nbre_addr = (ipv4addr) ? json_object_array_length(ipv4addr) : 0; dmasprintf(value, "%d", nbre_addr); return 0; } @@ -280,7 +282,7 @@ int os__get_HostsHost_IPv6AddressNumberOfEntries(char *refparam, struct dmctx *c size_t nbre_addr = 0; json_object_object_get_ex((json_object *)data, "ipv6addr", &ipv6addr); - nbre_addr = json_object_array_length(ipv6addr); + nbre_addr = (ipv6addr) ? json_object_array_length(ipv6addr) : 0; dmasprintf(value, "%d", nbre_addr); return 0; } diff --git a/dmtree/tr181/ieee1905.c b/dmtree/tr181/ieee1905.c index a437f5a4..5f97d2d9 100644 --- a/dmtree/tr181/ieee1905.c +++ b/dmtree/tr181/ieee1905.c @@ -37,7 +37,7 @@ static int browseIEEE1905ALInterfaceInst(struct dmctx *dmctx, DMNODE *parent_nod if (result == NULL) return 0; json_object_object_get_ex(result, "names", &interfaces); - size_t num_interface = json_object_array_length(interfaces); + size_t num_interface = (interfaces) ? json_object_array_length(interfaces) : 0; for (i = 0; i < num_interface; i++) { interface_id = json_object_array_get_idx(interfaces, i); snprintf(object, sizeof(object), "ieee1905.al.%s", json_object_get_string(interface_id)); @@ -355,7 +355,7 @@ static int ubus_ieee1905_info(const char *option, char **value) { json_object *res = NULL; dmubus_call("ieee1905", "info", UBUS_ARGS{}, 0, &res); - DM_ASSERT(res, *value = ""); + DM_ASSERT(res, *value = "0"); *value = dmjson_get_value(res, 1, option); return 0; } @@ -519,7 +519,7 @@ static int get_IEEE1905ALInterface_VendorPropertiesNumberOfEntries(char *refpara { json_object *res = NULL; dmubus_call((char *)data, "info", UBUS_ARGS{}, 0, &res); - DM_ASSERT(res, *value = ""); + DM_ASSERT(res, *value = "0"); *value = dmjson_get_value(res, 1, "vendor_nr"); return 0; } @@ -532,8 +532,7 @@ static int get_IEEE1905ALInterface_LinkNumberOfEntries(char *refparam, struct dm dmubus_call((char *)data, "link_info", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = "0"); json_object_object_get_ex(res, "links", &links); - if (links) - num_links = json_object_array_length(links); + num_links = (links) ? json_object_array_length(links) : 0; dmasprintf(value, "%d", num_links); return 0; @@ -808,7 +807,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_MACSourceAddressFlag(char /*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.EtherType!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/ether_type*/ static int get_IEEE1905ALForwardingTableForwardingRule_EtherType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "ether_type", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "ether_type", "0"); return 0; } @@ -853,7 +852,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_EtherTypeFlag(char *refpa /*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.Vid!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/vid*/ static int get_IEEE1905ALForwardingTableForwardingRule_Vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "vid", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "vid", "0"); return 0; } @@ -898,7 +897,7 @@ static int set_IEEE1905ALForwardingTableForwardingRule_VidFlag(char *refparam, s /*#Device.IEEE1905.AL.ForwardingTable.ForwardingRule.{i}.PCP!UCI:dmmap_forwarding_rule/forwarding_rule,@i-1/pcp*/ static int get_IEEE1905ALForwardingTableForwardingRule_PCP(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "pcp", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "pcp", "0"); return 0; } @@ -975,7 +974,7 @@ static int get_IEEE1905ALNetworkTopology_Status(char *refparam, struct dmctx *ct static int get_IEEE1905ALNetworkTopology_MaxChangeLogEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("topology", "topology", "maxlog", value); + *value = dmuci_get_option_value_fallback_def("topology", "topology", "maxlog", "1"); return 0; } @@ -1001,11 +1000,9 @@ static int get_IEEE1905ALNetworkTopology_LastChange(char *refparam, struct dmctx dmubus_call("topology", "changelog", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = ""); json_object_object_get_ex(res, "changelog", &obj); - if (obj) { - num = json_object_array_length(obj); - if (num != 0) - dmasprintf(value, "Device.IEEE1905.AL.NetworkTopology.ChangeLog.%d", num); - } + num = (obj) ? json_object_array_length(obj) : 0; + if (num != 0) + dmasprintf(value, "Device.IEEE1905.AL.NetworkTopology.ChangeLog.%d", num); return 0; } @@ -1018,8 +1015,7 @@ static int get_IEEE1905ALNetworkTopology_IEEE1905DeviceNumberOfEntries(char *ref dmubus_call("topology", "dump", UBUS_ARGS{}, 0, &res); DM_ASSERT(res, *value = "0"); json_object_object_get_ex(res, "nodes", &obj); - if (obj) - num_nodes = json_object_array_length(obj); + num_nodes = (obj) ? json_object_array_length(obj) : 0; dmasprintf(value, "%d", num_nodes); return 0; @@ -1044,8 +1040,7 @@ static int get_IEEE1905ALNetworkTopology_NonIEEE1905NeighborNumberOfEntries(char json_object_object_get_ex(res, "self", &obj); if (obj) { json_object_object_get_ex(obj, "non1905_neighbors", &obj_nbr); - if (obj_nbr != NULL) - num_nodes = json_object_array_length(obj_nbr); + num_nodes = (obj_nbr) ? json_object_array_length(obj_nbr) : 0; } dmasprintf(value, "%d", num_nodes); return 0; @@ -1388,8 +1383,7 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceIEEE1905Neighbor_MetricNum const struct obj_node *node_val = (struct obj_node *)data; json_object_object_get_ex(node_val->data, "link_metrics", &link_metrics); - if (link_metrics) - num = json_object_array_length(link_metrics); + num = (link_metrics) ? json_object_array_length(link_metrics) : 0; dmasprintf(value, "%d", num); return 0; diff --git a/dmtree/tr181/managementserver.c b/dmtree/tr181/managementserver.c index 9a930aca..1c5314bd 100644 --- a/dmtree/tr181/managementserver.c +++ b/dmtree/tr181/managementserver.c @@ -95,7 +95,7 @@ static int get_management_server_key(char *refparam, struct dmctx *ctx, void *da /*#Device.ManagementServer.PeriodicInformEnable!UCI:cwmp/acs,acs/periodic_inform_enable*/ static int get_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("cwmp", "acs", "periodic_inform_enable", value); + *value = dmuci_get_option_value_fallback_def("cwmp", "acs", "periodic_inform_enable", "1"); return 0; } @@ -120,7 +120,7 @@ static int set_management_server_periodic_inform_enable(char *refparam, struct d /*#Device.ManagementServer.PeriodicInformInterval!UCI:cwmp/acs,acs/periodic_inform_interval*/ static int get_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("cwmp", "acs", "periodic_inform_interval", value); + *value = dmuci_get_option_value_fallback_def("cwmp", "acs", "periodic_inform_interval", "1800"); return 0; } @@ -142,16 +142,15 @@ static int set_management_server_periodic_inform_interval(char *refparam, struct /*#Device.ManagementServer.PeriodicInformTime!UCI:cwmp/acs,acs/periodic_inform_time*/ static int get_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - time_t time_value; + *value = "0001-01-01T00:00:00Z"; - dmuci_get_option_value_string("cwmp", "acs", "periodic_inform_time", value); - if ((*value)[0] != '0' && (*value)[0] != '\0') { - time_value = atoi(*value); + char *periodic_inform_time; + dmuci_get_option_value_string("cwmp", "acs", "periodic_inform_time", &periodic_inform_time); + if (periodic_inform_time && *periodic_inform_time != '\0' && atoi(periodic_inform_time) > 0) { + time_t time_value = atoi(periodic_inform_time); char s_now[sizeof "AAAA-MM-JJTHH:MM:SSZ"]; strftime(s_now, sizeof s_now, "%Y-%m-%dT%H:%M:%SZ", localtime(&time_value)); *value = dmstrdup(s_now); // MEM WILL BE FREED IN DMMEMCLEAN - } else { - *value = "0001-01-01T00:00:00Z"; } return 0; } @@ -315,7 +314,7 @@ static int set_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *ins /*#Device.ManagementServer.UDPLightweightNotificationPort!UCI:cwmp/lwn,lwn/port*/ static int get_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("cwmp", "lwn", "port", value); + *value = dmuci_get_option_value_fallback_def("cwmp", "lwn", "port", "7547"); return 0; } @@ -367,7 +366,7 @@ static int set_management_server_http_compression(char *refparam, struct dmctx * /*#Device.ManagementServer.CWMPRetryMinimumWaitInterval!UCI:cwmp/acs,acs/retry_min_wait_interval*/ static int get_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("cwmp", "acs", "retry_min_wait_interval", value); + *value = dmuci_get_option_value_fallback_def("cwmp", "acs", "retry_min_wait_interval", "5"); return 0; } @@ -389,7 +388,7 @@ static int set_management_server_retry_min_wait_interval(char *refparam, struct /*#Device.ManagementServer.CWMPRetryIntervalMultiplier!UCI:cwmp/acs,acs/retry_interval_multiplier*/ static int get_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("cwmp", "acs", "retry_interval_multiplier", value); + *value = dmuci_get_option_value_fallback_def("cwmp", "acs", "retry_interval_multiplier", "2000"); return 0; } @@ -451,7 +450,7 @@ static int get_upd_cr_address(char *refparam, struct dmctx *ctx, void *data, cha /*#Device.ManagementServer.STUNEnable!UCI:stun/stun,stun/enable*/ static int get_stun_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("stun", "stun", "enable", value); + *value = dmuci_get_option_value_fallback_def("stun", "stun", "enable", "1"); return 0; } @@ -496,7 +495,7 @@ static int set_stun_server_address(char *refparam, struct dmctx *ctx, void *data /*#Device.ManagementServer.STUNServerPort!UCI:stun/stun,stun/server_port*/ static int get_stun_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("stun", "stun", "server_port", value); + *value = dmuci_get_option_value_fallback_def("stun", "stun", "server_port", "3478"); return 0; } @@ -559,7 +558,7 @@ static int set_stun_password(char *refparam, struct dmctx *ctx, void *data, char /*#Device.ManagementServer.STUNMaximumKeepAlivePeriod!UCI:stun/stun,stun/max_keepalive*/ static int get_stun_maximum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("stun", "stun", "max_keepalive", value); + *value = dmuci_get_option_value_fallback_def("stun", "stun", "max_keepalive", "-1"); return 0; } @@ -580,7 +579,7 @@ static int set_stun_maximum_keepalive_period(char *refparam, struct dmctx *ctx, /*#Device.ManagementServer.STUNMinimumKeepAlivePeriod!UCI:stun/stun,stun/min_keepalive*/ static int get_stun_minimum_keepalive_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("stun", "stun", "min_keepalive", value); + *value = dmuci_get_option_value_fallback_def("stun", "stun", "min_keepalive", "30"); return 0; } diff --git a/dmtree/tr181/nat.c b/dmtree/tr181/nat.c index 4c62faa0..2b5febf1 100644 --- a/dmtree/tr181/nat.c +++ b/dmtree/tr181/nat.c @@ -484,7 +484,7 @@ static int set_nat_port_mapping_external_port_end_range(char *refparam, struct d /*#Device.NAT.PortMapping.{i}.InternalPort!UCI:firewall/redirect,@i-1/dest_port*/ static int get_nat_port_mapping_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "dest_port", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "dest_port", "0"); return 0; } diff --git a/dmtree/tr181/ppp.c b/dmtree/tr181/ppp.c index 1d19cecc..2cbe4d19 100644 --- a/dmtree/tr181/ppp.c +++ b/dmtree/tr181/ppp.c @@ -96,7 +96,7 @@ static int get_PPPInterface_LastChange(char *refparam, struct dmctx *ctx, void * { json_object *res; 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 = "0"); *value = dmjson_get_value(res, 1, "uptime"); return 0; } @@ -308,7 +308,7 @@ static int get_PPP_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, v { struct uci_section *s; char *proto; - int nbre= 0; + int nbre = 0; uci_foreach_sections("network", "interface", s) { dmuci_get_value_by_section_string(s, "proto", &proto); diff --git a/dmtree/tr181/qos-iopsyswrt.c b/dmtree/tr181/qos-iopsyswrt.c index 5368820d..160f7408 100644 --- a/dmtree/tr181/qos-iopsyswrt.c +++ b/dmtree/tr181/qos-iopsyswrt.c @@ -767,9 +767,7 @@ int os_get_QoS_AvailableAppList(char *refparam, struct dmctx *ctx, void *data, c #endif int os_get_QoSClassification_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 = "0"; + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enable", "1"); return 0; } @@ -783,10 +781,7 @@ int os_set_QoSClassification_Enable(char *refparam, struct dmctx *ctx, void *dat break; case VALUESET: string_to_bool(value, &b); - if (b) - dmuci_set_value_by_section((struct uci_section *)data, "enable", "1"); - else - dmuci_set_value_by_section((struct uci_section *)data, "enable", "0"); + dmuci_set_value_by_section((struct uci_section *)data, "enable", (b) ? "1" : "0"); break; } return 0; @@ -1139,7 +1134,7 @@ int os_set_QoSClassification_SourceIP(char *refparam, struct dmctx *ctx, void *d int os_get_QoSClassification_Protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "proto", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "proto", "-1"); return 0; } @@ -1160,7 +1155,7 @@ int os_set_QoSClassification_Protocol(char *refparam, struct dmctx *ctx, void *d int os_get_QoSClassification_DestPort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "dest_port", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "dest_port", "-1"); return 0; } @@ -1180,7 +1175,7 @@ int os_set_QoSClassification_DestPort(char *refparam, struct dmctx *ctx, void *d int os_get_QoSClassification_DestPortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "dest_port_range", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "dest_port_range", "-1"); return 0; } @@ -1218,7 +1213,7 @@ int os_set_QoSClassification_DestPortExclude(char *refparam, struct dmctx *ctx, int os_get_QoSClassification_SourcePort(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "src_port", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "src_port", "-1"); return 0; } @@ -1238,7 +1233,7 @@ int os_set_QoSClassification_SourcePort(char *refparam, struct dmctx *ctx, void int os_get_QoSClassification_SourcePortRangeMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "src_port_range", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "src_port_range", "-1"); return 0; } @@ -1388,7 +1383,7 @@ int os_set_QoSClassification_DestMACExclude(char *refparam, struct dmctx *ctx, v #endif int os_get_QoSClassification_Ethertype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "ethertype", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "ethertype", "-1"); return 0; } @@ -2038,7 +2033,7 @@ int os_set_QoSClassification_TCPACKExclude(char *refparam, struct dmctx *ctx, vo #endif int os_get_QoSClassification_IPLengthMin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "ip_len_min", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "ip_len_min", "0"); return 0; } @@ -2058,7 +2053,7 @@ int os_set_QoSClassification_IPLengthMin(char *refparam, struct dmctx *ctx, void int os_get_QoSClassification_IPLengthMax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "ip_len_max", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "ip_len_max", "0"); return 0; } @@ -2096,7 +2091,7 @@ int os_set_QoSClassification_IPLengthExclude(char *refparam, struct dmctx *ctx, #endif int os_get_QoSClassification_DSCPCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "dscp_filter", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "dscp_filter", "-1"); return 0; } @@ -2135,7 +2130,7 @@ int os_set_QoSClassification_DSCPExclude(char *refparam, struct dmctx *ctx, void /*#Device.QoS.Classification.{i}.DSCPMark!UCI:qos/classify,@i-1/dscp*/ int os_get_QoSClassification_DSCPMark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "dscp_mark", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "dscp_mark", "-1"); return 0; } @@ -2154,7 +2149,7 @@ int os_set_QoSClassification_DSCPMark(char *refparam, struct dmctx *ctx, void *d } int os_get_QoSClassification_EthernetPriorityCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "pcp_check", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "pcp_check", "-1"); return 0; } @@ -2300,7 +2295,7 @@ int os_set_QoSClassification_EthernetDEIExclude(char *refparam, struct dmctx *ct #endif int os_get_QoSClassification_VLANIDCheck(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "vid_check", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "vid_check", "-1"); return 0; } @@ -2374,7 +2369,7 @@ int os_set_QoSClassification_ForwardingPolicy(char *refparam, struct dmctx *ctx, #endif int os_get_QoSClassification_TrafficClass(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "traffic_class", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "traffic_class", "-1"); return 0; } @@ -3317,7 +3312,7 @@ int os_get_QoSQueue_BufferLength(char *refparam, struct dmctx *ctx, void *data, int os_get_QoSQueue_Weight(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "weight", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "weight", "0"); return 0; } @@ -3338,7 +3333,7 @@ int os_set_QoSQueue_Weight(char *refparam, struct dmctx *ctx, void *data, char * /*#Device.QoS.Queue.{i}.Precedence!UCI:qos/queue,@i-1/precedence*/ int os_get_QoSQueue_Precedence(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "precedence", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "precedence", "1"); return 0; } @@ -3467,7 +3462,7 @@ int os_set_QoSQueue_ShapingRate(char *refparam, struct dmctx *ctx, void *data, c int os_get_QoSQueue_ShapingBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "burst_size", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "burst_size", "0"); return 0; } @@ -3565,44 +3560,43 @@ int os_set_QoSQueueStats_Interface(char *refparam, struct dmctx *ctx, void *data int os_get_QoSQueueStats_OutputPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value=""; + *value = "0"; return 0; } int os_get_QoSQueueStats_OutputBytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value=""; + *value = "0"; return 0; } int os_get_QoSQueueStats_DroppedPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value=""; + *value = "0"; return 0; } int os_get_QoSQueueStats_DroppedBytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value=""; + *value = "0"; return 0; } int os_get_QoSQueueStats_QueueOccupancyPackets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value=""; + *value = "0"; return 0; } int os_get_QoSQueueStats_QueueOccupancyPercentage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value=""; + *value = "0"; return 0; } int os_get_QoSShaper_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "enable", value); - *value = (*value[0] == '1') ? "1" : "0"; + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enable", "1"); return 0; } @@ -3695,7 +3689,7 @@ int os_set_QoSShaper_Interface(char *refparam, struct dmctx *ctx, void *data, ch int os_get_QoSShaper_ShapingRate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "rate", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "rate", "-1"); return 0; } @@ -3715,7 +3709,7 @@ int os_set_QoSShaper_ShapingRate(char *refparam, struct dmctx *ctx, void *data, int os_get_QoSShaper_ShapingBurstSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "burst_size", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "burst_size", "0"); return 0; } diff --git a/dmtree/tr181/routing.c b/dmtree/tr181/routing.c index c58f6dea..9a1392f0 100644 --- a/dmtree/tr181/routing.c +++ b/dmtree/tr181/routing.c @@ -671,7 +671,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) { - *value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "metric", "0"); + *value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "metric", "-1"); return 0; } @@ -820,7 +820,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) { - *value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "metric", "0"); + *value = dmuci_get_value_by_section_fallback_def(((struct routingfwdargs *)data)->routefwdsection, "metric", "-1"); return 0; } @@ -973,12 +973,16 @@ static int get_RoutingRouteInformationInterfaceSetting_SourceRouter(char *refpar static int get_RoutingRouteInformationInterfaceSetting_RouteLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char local_time[32] = {0}; - char *valid = dmjson_get_value((struct json_object *)data, 1, "valid"); *value = "0001-01-01T00:00:00Z"; - if (get_shift_time_time(atoi(valid), local_time, sizeof(local_time)) == -1) - return 0; - *value = dmstrdup(local_time); + + char *valid = dmjson_get_value((struct json_object *)data, 1, "valid"); + if (valid && *valid != '\0' && atoi(valid) > 0) { + char local_time[32] = {0}; + + if (get_shift_time_time(atoi(valid), local_time, sizeof(local_time)) == -1) + return 0; + *value = dmstrdup(local_time); + } return 0; } diff --git a/dmtree/tr181/security.c b/dmtree/tr181/security.c index f88e2a6d..51bad9ec 100644 --- a/dmtree/tr181/security.c +++ b/dmtree/tr181/security.c @@ -316,9 +316,9 @@ static int get_SecurityCertificate_LastModif(char *refparam, struct dmctx *ctx, { struct certificate_profile *cert_profile = (struct certificate_profile*)data; struct stat b; - char t[ 100 ] = ""; + char t[sizeof("AAAA-MM-JJTHH:MM:SSZ")] = "0001-01-01T00:00:00Z"; if (!stat(cert_profile->path, &b)) - strftime(t, 100, "%Y-%m-%dT%H:%M:%SZ", localtime( &b.st_mtime)); + strftime(t, sizeof(t), "%Y-%m-%dT%H:%M:%SZ", localtime(&b.st_mtime)); *value = dmstrdup(t); return 0; } @@ -360,7 +360,7 @@ static int get_SecurityCertificate_Issuer(char *refparam, struct dmctx *ctx, voi static int get_SecurityCertificate_NotBefore(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = ""; + *value = "0001-01-01T00:00:00Z"; #ifdef LOPENSSL struct tm not_before_time; struct certificate_profile *cert_profile = (struct certificate_profile*)data; @@ -378,7 +378,7 @@ static int get_SecurityCertificate_NotBefore(char *refparam, struct dmctx *ctx, static int get_SecurityCertificate_NotAfter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = ""; + *value = "0001-01-01T00:00:00Z"; #ifdef LOPENSSL struct tm not_after_time; struct certificate_profile *cert_profile = (struct certificate_profile*)data; diff --git a/dmtree/tr181/usb.c b/dmtree/tr181/usb.c index a798d763..49d51321 100644 --- a/dmtree/tr181/usb.c +++ b/dmtree/tr181/usb.c @@ -918,7 +918,7 @@ static int get_USBUSBHostsHostDevice_ProductID(char *refparam, struct dmctx *ctx char *idproduct = NULL; unsigned int ui_idproduct; - *value = ""; + *value = "0"; int rc = read_sysfs_usb_port(data, "idProduct", &idproduct); if(idproduct != NULL) { diff --git a/dmtree/tr181/users.c b/dmtree/tr181/users.c index 0e01e02b..62b2100d 100644 --- a/dmtree/tr181/users.c +++ b/dmtree/tr181/users.c @@ -122,7 +122,7 @@ static int get_user_alias(char *refparam, struct dmctx *ctx, void *data, char *i /*#Device.Users.User.{i}.Enable!UCI:users/user,@i-1/enabled*/ static int get_user_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enabled", "1"); return 0; } @@ -142,7 +142,7 @@ static int get_user_password(char *refparam, struct dmctx *ctx, void *data, char /*#Device.Users.User.{i}.RemoteAccessCapable!UCI:users/user,@i-1/remote_access*/ static int get_user_remote_accessable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "remote_access", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "remote_access", "1"); return 0; } @@ -172,13 +172,15 @@ static int set_user_alias(char *refparam, struct dmctx *ctx, void *data, char *i static int set_user_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { + bool b; switch (action) { case VALUECHECK: if (dm_validate_boolean(value)) return FAULT_9007; break; case VALUESET: - dmuci_set_value_by_section((struct uci_section *)data, "enabled", value); + string_to_bool(value, &b); + dmuci_set_value_by_section((struct uci_section *)data, "enabled", b ? "1" : "0"); break; } return 0; @@ -220,13 +222,15 @@ static int set_user_password(char *refparam, struct dmctx *ctx, void *data, char static int set_user_remote_accessable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { + bool b; switch (action) { case VALUECHECK: if (dm_validate_boolean(value)) return FAULT_9007; break; case VALUESET: - dmuci_set_value_by_section((struct uci_section *)data, "remote_access", value); + string_to_bool(value, &b); + dmuci_set_value_by_section((struct uci_section *)data, "remote_access", b ? "1" : "0"); break; } return 0; diff --git a/dmtree/tr181/wifi-iopsyswrt.c b/dmtree/tr181/wifi-iopsyswrt.c index 4bf8fd75..8829e6f9 100644 --- a/dmtree/tr181/wifi-iopsyswrt.c +++ b/dmtree/tr181/wifi-iopsyswrt.c @@ -32,10 +32,7 @@ static int ssid_read_ubus(const struct wifi_ssid_args *args, const char *name, c snprintf(object, sizeof(object), "wifi.ap.%s", args->ifname); dmubus_call(object, "stats", UBUS_ARGS{}, 0, &res); - if (!res) { - *value = "0"; - return 0; - } + DM_ASSERT(res, *value = "0"); *value = dmjson_get_value(res, 1, name); return 0; } @@ -47,10 +44,7 @@ static int radio_read_ubus(const struct wifi_radio_args *args, const char *name, snprintf(object, sizeof(object), "wifi.radio.%s", section_name(args->wifi_radio_sec)); dmubus_call(object, "stats", UBUS_ARGS{}, 0, &res); - if (!res) { - *value = "0"; - return 0; - } + DM_ASSERT(res, *value = "0"); *value = dmjson_get_value(res, 1, name); return 0; } @@ -305,7 +299,7 @@ int os__get_radio_max_bit_rate (char *refparam, struct dmctx *ctx, void *data, c 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 = "0"); *value = dmjson_get_value(res, 1, "maxrate"); return 0; } @@ -346,7 +340,7 @@ int os__get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *i char object[32]; 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 = "1"); *value = dmjson_get_value(res, 1, "channel"); } return 0; @@ -413,8 +407,7 @@ int os__get_neighboring_wifi_diagnostics_result_number_entries(char *refparam, s dmubus_call(object, "scanresults", UBUS_ARGS{}, 0, &res); if (res) { json_object_object_get_ex(res, "accesspoints", &accesspoints); - if (accesspoints) - entries = json_object_array_length(accesspoints); + entries = (accesspoints) ? json_object_array_length(accesspoints) : 0; } result = result + entries; entries = 0; @@ -842,8 +835,7 @@ int os__get_WiFiDataElementsNetworkDeviceRadio_ScanResultNumberOfEntries(char *r json_object *scanres_arr = NULL; json_object_object_get_ex((json_object *)data, "ScanResultList", &scanres_arr); - if (scanres_arr) - num_scanres = json_object_array_length(scanres_arr); + num_scanres = (scanres_arr) ? json_object_array_length(scanres_arr) : 0; dmasprintf(value, "%d", num_scanres); return 0; @@ -856,8 +848,7 @@ int os__get_WiFiDataElementsNetworkDeviceRadioBackhaulSta_MACAddress(char *refpa if (data) { json_object_object_get_ex((json_object *)data, "BackhaulSta", &backsta_obj); - if (backsta_obj) - *value = dmjson_get_value(backsta_obj, 1, "MACAddress"); + *value = (backsta_obj) ? dmjson_get_value(backsta_obj, 1, "MACAddress") : ""; } return 0; } @@ -868,8 +859,7 @@ int os__get_WiFiDataElementsNetworkDeviceRadioCapabilities_HTCapabilities(char * json_object *caps_obj = NULL; json_object_object_get_ex((json_object *)data, "Capabilites", &caps_obj); - if (caps_obj) - *value = dmjson_get_value(caps_obj, 1, "HTCapabilities"); + *value = (caps_obj) ? dmjson_get_value(caps_obj, 1, "HTCapabilities") : ""; return 0; } @@ -880,8 +870,7 @@ int os__get_WiFiDataElementsNetworkDeviceRadioCapabilities_VHTCapabilities(char json_object *caps_obj = NULL; json_object_object_get_ex((json_object *)data, "Capabilites", &caps_obj); - if (caps_obj) - *value = dmjson_get_value(caps_obj, 1, "VHTCapabilities"); + *value = (caps_obj) ? dmjson_get_value(caps_obj, 1, "VHTCapabilities") : ""; return 0; } @@ -892,8 +881,7 @@ int os__get_WiFiDataElementsNetworkDeviceRadioCapabilities_HECapabilities(char * json_object *caps_obj = NULL; json_object_object_get_ex((json_object *)data, "Capabilites", &caps_obj); - if (caps_obj) - *value = dmjson_get_value(caps_obj, 1, "HECapabilities"); + *value = (caps_obj) ? dmjson_get_value(caps_obj, 1, "HECapabilities") : ""; return 0; } @@ -904,8 +892,7 @@ int os__get_WiFiDataElementsNetworkDeviceRadioCapabilities_CapableOperatingClass json_object *caps_obj = NULL; json_object_object_get_ex((json_object *)data, "Capabilites", &caps_obj); - if (caps_obj) - *value = dmjson_get_value(caps_obj, 1, "NumberOfOpClass"); + *value = (caps_obj) ? dmjson_get_value(caps_obj, 1, "NumberOfOpClass") : "0"; return 0; } diff --git a/dmtree/tr181/wifi.c b/dmtree/tr181/wifi.c index 4dd39483..716d638b 100644 --- a/dmtree/tr181/wifi.c +++ b/dmtree/tr181/wifi.c @@ -790,9 +790,7 @@ static int set_access_point_control_enable(char *refparam, struct dmctx *ctx, vo /*#Device.WiFi.AccessPoint.{i}.UAPSDEnable!UCI:wireless/wifi-iface,@i-1/wmm_apsd*/ static int get_WiFiAccessPoint_UAPSDEnable(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, "wmm_apsd", value); - if (!*value || *value[0] == 0) - *value = "0"; + *value = dmuci_get_value_by_section_fallback_def(((struct wifi_acp_args *)data)->wifi_acp_sec, "wmm_apsd", "0"); return 0; } @@ -1012,9 +1010,7 @@ static int set_access_point_security_passphrase(char *refparam, struct dmctx *ct /*#Device.WiFi.AccessPoint.{i}.Security.RekeyingInterval!UCI:wireless/wifi-iface,@i-1/wpa_group_rekey*/ static int get_access_point_security_rekey_interval(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, "wpa_group_rekey", value); - if (!*value || *value[0] == 0) - *value = "0"; + *value = dmuci_get_value_by_section_fallback_def(((struct wifi_acp_args *)data)->wifi_acp_sec, "wpa_group_rekey", "0"); return 0; } @@ -1064,7 +1060,7 @@ static int set_access_point_security_radius_ip_address(char *refparam, struct dm /*#Device.WiFi.AccessPoint.{i}.Security.RadiusServerPort!UCI:wireless/wifi-iface,@i-1/auth_port*/ static int get_access_point_security_radius_server_port(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, "auth_port", value); + *value = dmuci_get_value_by_section_fallback_def(((struct wifi_acp_args *)data)->wifi_acp_sec, "auth_port", "1812"); return 0; } @@ -1298,7 +1294,7 @@ static int set_WiFiAccessPointAccounting_ServerIPAddr(char *refparam, struct dmc /*#Device.WiFi.AccessPoint.{i}.Accounting.ServerPort!UCI:wireless/wifi-iface,@i-1/acct_port*/ static int get_WiFiAccessPointAccounting_ServerPort(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, "acct_port", value); + *value = dmuci_get_value_by_section_fallback_def(((struct wifi_acp_args *)data)->wifi_acp_sec, "acct_port", "1813"); return 0; } @@ -1382,19 +1378,21 @@ static int get_WiFiAccessPointAssociatedDevice_Retransmissions(char *refparam, s /*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.AssociationTime!UBUS:wifi.ap.@Name/stations//stations[i-1].in_network*/ static int get_WiFiAccessPointAssociatedDevice_AssociationTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char local_time[32] = {0}; - time_t t_time; - *value = "0001-01-01T00:00:00Z"; + char *in_network = dmjson_get_value((json_object *)data, 1, "in_network"); - t_time = time(NULL) - atoi(in_network); - if (localtime(&t_time) == NULL) - return -1; + if (in_network && *in_network != '\0' && atoi(in_network) > 0) { + time_t t_time = time(NULL) - atoi(in_network); + if (localtime(&t_time) == NULL) + return -1; - if (strftime(local_time, sizeof(local_time), "%Y-%m-%dT%H:%M:%SZ", localtime(&t_time)) == 0) - return -1; + char local_time[32] = {0}; - *value = dmstrdup(local_time); + if (strftime(local_time, sizeof(local_time), "%Y-%m-%dT%H:%M:%SZ", localtime(&t_time)) == 0) + return -1; + + *value = dmstrdup(local_time); + } return 0; } diff --git a/dmtree/tr181/x_iopsys_eu_buttons.c b/dmtree/tr181/x_iopsys_eu_buttons.c index 9e6dcd18..813cc366 100644 --- a/dmtree/tr181/x_iopsys_eu_buttons.c +++ b/dmtree/tr181/x_iopsys_eu_buttons.c @@ -67,7 +67,7 @@ static int get_x_iopsys_eu_button_hotplug_long(char *refparam, struct dmctx *ctx static int get_x_iopsys_eu_button_minpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "minpress", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "minpress", "0"); return 0; } @@ -86,7 +86,7 @@ static int set_x_iopsys_eu_button_minpress(char *refparam, struct dmctx *ctx, vo static int get_x_iopsys_eu_button_longpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "longpress", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "longpress", "0"); return 0; } diff --git a/dmtree/tr181/x_iopsys_eu_igmp.c b/dmtree/tr181/x_iopsys_eu_igmp.c index b327988a..204790ad 100644 --- a/dmtree/tr181/x_iopsys_eu_igmp.c +++ b/dmtree/tr181/x_iopsys_eu_igmp.c @@ -742,14 +742,7 @@ int set_mcasts_filter_address(char *refparam, struct dmctx *ctx, void *data, cha int get_mcast_snooping_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *val; - dmuci_get_value_by_section_string((struct uci_section *)data, "enable", &val); - - if (strcmp(val, "1") == 0) - *value = "true"; - else - *value = "false"; - + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enable", "1"); return 0; } @@ -837,7 +830,7 @@ int set_mcast_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char int get_mcast_snooping_robustness(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "robustness", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "robustness", "0"); return 0; } @@ -859,9 +852,7 @@ int set_mcast_snooping_robustness(char *refparam, struct dmctx *ctx, void *data, int get_mcast_snooping_aggregation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *val; - dmuci_get_value_by_section_string((struct uci_section *)data, "aggregation", &val); - *value = (strcmp(val, "1") == 0) ? "true" : "false"; + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "aggregation", "1"); return 0; } @@ -1457,9 +1448,7 @@ static int get_igmpp_cgrp_stats_lrcvd(char *refparam, struct dmctx *ctx, void *d int get_mcast_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *val; - dmuci_get_value_by_section_string((struct uci_section *)data, "enable", &val); - *value = (strcmp(val, "1") == 0) ? "true" : "false"; + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "enable", "1"); return 0; } int set_mcast_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) @@ -1505,25 +1494,25 @@ static int set_igmp_proxy_version(char *refparam, struct dmctx *ctx, void *data, int get_mcast_proxy_robustness(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "robustness", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "robustness", "0"); return 0; } int get_mcastp_query_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "query_interval", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "query_interval", "0"); return 0; } int get_mcastp_q_response_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "query_response_interval", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "query_response_interval", "0"); return 0; } int get_mcastp_last_mq_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_value_by_section_string((struct uci_section *)data, "last_member_query_interval", value); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "last_member_query_interval", "0"); return 0; } @@ -1592,27 +1581,13 @@ int set_mcast_proxy_robustness(char *refparam, struct dmctx *ctx, void *data, ch int get_mcast_proxy_aggregation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *val; - dmuci_get_value_by_section_string((struct uci_section *)data, "aggregation", &val); - - if (strcmp(val, "1") == 0) - *value = "true"; - else - *value = "false"; - + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "aggregation", "1"); return 0; } int get_mcast_proxy_fast_leave(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *val; - dmuci_get_value_by_section_string((struct uci_section *)data, "fast_leave", &val); - - if (strcmp(val, "1") == 0) - *value = "true"; - else - *value = "false"; - + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "fast_leave", "1"); return 0; } diff --git a/dmtree/tr181/x_iopsys_eu_owsd.c b/dmtree/tr181/x_iopsys_eu_owsd.c index 239e3bfc..72df9b3b 100644 --- a/dmtree/tr181/x_iopsys_eu_owsd.c +++ b/dmtree/tr181/x_iopsys_eu_owsd.c @@ -76,7 +76,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) { - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "port", ""); + *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "port", "0"); return 0; } @@ -258,19 +258,21 @@ static int set_x_iopsys_eu_owsd_virtualhost_alias(char *refparam, struct dmctx * static int get_x_iopsys_eu_owsd_ubus_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - dmuci_get_option_value_string("owsd","ubusproxy","enable", value); + *value = dmuci_get_option_value_fallback_def("owsd","ubusproxy","enable", "1"); return 0; } static int set_x_iopsys_eu_owsd_ubus_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { + bool b; switch (action) { case VALUECHECK: if (dm_validate_boolean(value)) return FAULT_9007; return 0; case VALUESET: - dmuci_set_value("owsd", "ubusproxy", "enable", value); + string_to_bool(value, &b); + dmuci_set_value("owsd", "ubusproxy", "enable", b ? "1" : "0"); return 0; } return 0; diff --git a/libbbf_api/dmjson.h b/libbbf_api/dmjson.h index 4188b789..f5b711e7 100644 --- a/libbbf_api/dmjson.h +++ b/libbbf_api/dmjson.h @@ -47,6 +47,7 @@ char *__dmjson_get_value_array_all(json_object *mainjobj, char *delim, int argc, #define dmjson_get_value(JOBJ,ARGC,args...) \ __dmjson_get_value_in_obj(JOBJ, ARGC, ##args) + #define dmjson_get_obj(JOBJ,ARGC,args...) \ __dmjson_get_obj(JOBJ, ARGC, ##args)