From 61a1c576642f90ef37cf704ec52de6caf4a31ad6 Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Tue, 12 May 2020 00:05:40 +0100 Subject: [PATCH] Add sysfs and procfs mapping + update mapping of some parameters + clean up --- dmtree/tr104/voice_services.c | 3 +- dmtree/tr181/atm.c | 2 +- dmtree/tr181/deviceinfo-iopsyswrt.c | 8 + dmtree/tr181/deviceinfo.c | 2 +- dmtree/tr181/ethernet.c | 38 +- dmtree/tr181/managementserver.c | 2 +- dmtree/tr181/ppp.c | 33 +- dmtree/tr181/ptm.c | 7 +- dmtree/tr181/upnp.c | 28 +- dmtree/tr181/users.c | 3 +- dmtree/tr181/wifi-iopsyswrt.c | 2 - dmtree/tr181/wifi-openwrt.c | 33 -- dmtree/tr181/wifi.c | 148 ++--- json/X_IOPSYS_EU_Buttons.json | 213 +++++++ json/X_IOPSYS_EU_Dropbear.json | 333 +++++++++++ json/X_IOPSYS_EU_OWSD.json | 417 ++++++++++++++ json/X_IOPSYS_EU_Syslog.json | 79 +++ json/X_IOPSYS_EU_WiFiLife.json | 99 ++++ json/tr104.json | 104 ++++ json/tr181.json | 857 ++++++++++++++++++++-------- tools/generate_json.py | 84 +-- 21 files changed, 2027 insertions(+), 468 deletions(-) create mode 100644 json/X_IOPSYS_EU_Buttons.json create mode 100644 json/X_IOPSYS_EU_Dropbear.json create mode 100644 json/X_IOPSYS_EU_OWSD.json create mode 100644 json/X_IOPSYS_EU_Syslog.json create mode 100644 json/X_IOPSYS_EU_WiFiLife.json diff --git a/dmtree/tr104/voice_services.c b/dmtree/tr104/voice_services.c index 56d747d0..a9bbd942 100644 --- a/dmtree/tr104/voice_services.c +++ b/dmtree/tr104/voice_services.c @@ -1080,7 +1080,6 @@ static int set_sip_re_invite_expires(char *refparam, struct dmctx *ctx, void *da return 0; } - static int get_sip_call_lines(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { struct sip_args *sipargs = (struct sip_args *)data; @@ -1381,6 +1380,7 @@ static int set_voice_service_vp_rtp_srtp_enable(char *refparam, struct dmctx *ct } /*******************LINE **********************************/ +/*#Device.Services.VoiceService.{i}.VoiceProfile.{i}.Line.{i}.Enable!UCI:voice_client/tel_line,@i-1/enabled*/ static int get_voice_profile_line_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *tmp; @@ -1413,6 +1413,7 @@ static int set_voice_profile_line_enable(char *refparam, struct dmctx *ctx, void return 0; } +/*#Device.Services.VoiceService.{i}.VoiceProfile.{i}.Line.{i}.DirectoryNumber!UCI:voice_client/tel_line,@i-1/extension*/ static int get_line_directory_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { struct tel_args *telargs = (struct tel_args *)data; diff --git a/dmtree/tr181/atm.c b/dmtree/tr181/atm.c index c32ccf6e..f3416543 100644 --- a/dmtree/tr181/atm.c +++ b/dmtree/tr181/atm.c @@ -44,7 +44,7 @@ static inline int init_atm_link(struct atm_args *args, struct uci_section *s, ch /************************************************************************** * SET & GET DSL LINK PARAMETERS ***************************************************************************/ -/*#Device.ATM.Link.{i}.DestinationAddress!UCI:dsl/atm-device,@i-1/vpi*/ +/*#Device.ATM.Link.{i}.DestinationAddress!UCI:dsl/atm-device,@i-1/vpi&UCI:dsl/atm-device,@i-1/vci*/ static int get_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *vpi, *vci; diff --git a/dmtree/tr181/deviceinfo-iopsyswrt.c b/dmtree/tr181/deviceinfo-iopsyswrt.c index a4449cdc..5204d5f4 100644 --- a/dmtree/tr181/deviceinfo-iopsyswrt.c +++ b/dmtree/tr181/deviceinfo-iopsyswrt.c @@ -112,6 +112,7 @@ int os__get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, cha return 0; } +/*#Device.DeviceInfo.ProcessStatus.ProcessNumberOfEntries!UBUS:router.system/processes//processes*/ int os__get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value) { json_object *res = NULL, *processes = NULL; @@ -127,42 +128,49 @@ int os__get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *d return 0; } +/*#Device.DeviceInfo.ProcessStatus.Process.{i}.PID!UBUS:router.system/processes//processes[@i-1].pid*/ int os__get_process_pid(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value) { *value = dmjson_get_value((json_object *)data, 1, "pid"); return 0; } +/*#Device.DeviceInfo.ProcessStatus.Process.{i}.Command!UBUS:router.system/processes//processes[@i-1].command*/ int os__get_process_command(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value) { *value = dmjson_get_value((json_object *)data, 1, "command"); return 0; } +/*#Device.DeviceInfo.ProcessStatus.Process.{i}.Size!UBUS:router.system/processes//processes[@i-1].vsz*/ int os__get_process_size(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value) { *value = dmjson_get_value((json_object *)data, 1, "vsz"); return 0; } +/*#Device.DeviceInfo.ProcessStatus.Process.{i}.Priority!UBUS:router.system/processes//processes[@i-1].priority*/ int os__get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value) { *value = dmjson_get_value((json_object *)data, 1, "priority"); return 0; } +/*#Device.DeviceInfo.ProcessStatus.Process.{i}.CPUTime!UBUS:router.system/processes//processes[@i-1].cputime*/ int os__get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value) { *value = dmjson_get_value((json_object *)data, 1, "cputime"); return 0; } +/*#Device.DeviceInfo.ProcessStatus.Process.{i}.State!UBUS:router.system/processes//processes[@i-1].state*/ int os__get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value) { *value = dmjson_get_value((json_object *)data, 1, "state"); return 0; } +/*#Device.DeviceInfo.ProcessStatus.Process.{i}.!UBUS:router.system/processes//processes*/ int os__browseProcessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) { json_object *res = NULL, *processes = NULL, *arrobj = NULL; diff --git a/dmtree/tr181/deviceinfo.c b/dmtree/tr181/deviceinfo.c index 4318c140..8c130e03 100644 --- a/dmtree/tr181/deviceinfo.c +++ b/dmtree/tr181/deviceinfo.c @@ -79,6 +79,7 @@ static int get_device_softwareversion(char *refparam, struct dmctx *ctx, void *d return 0; } +/*#Device.DeviceInfo.UpTime!PROCFS:/proc/uptime*/ static int get_device_info_uptime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { FILE *fp = NULL; @@ -278,7 +279,6 @@ static int browseVcfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_da return 0; } -//Browse VendorLogFile instances static int browseVlfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) { struct uci_section *sys_log_sec, *dm_sec; diff --git a/dmtree/tr181/ethernet.c b/dmtree/tr181/ethernet.c index 3437752d..c0d9a360 100644 --- a/dmtree/tr181/ethernet.c +++ b/dmtree/tr181/ethernet.c @@ -462,6 +462,7 @@ static int set_EthernetInterface_Enable(char *refparam, struct dmctx *ctx, void return 0; } +/*#Device.Ethernet.Interface.{i}.Status!SYSFS:/sys/class/net/@Name/operstate*/ static int get_EthernetInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { get_net_device_sysfs(((struct eth_port_args *)data)->ifname, "operstate", value); @@ -552,6 +553,7 @@ static int set_EthernetInterface_LowerLayers(char *refparam, struct dmctx *ctx, return 0; } +/*#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); @@ -560,7 +562,7 @@ static int get_EthernetInterface_Upstream(char *refparam, struct dmctx *ctx, voi return 0; } -/*#Device.Ethernet.Interface.{i}.MACAddress!UBUS:network.device/status/name,@Name/macaddr*/ +/*#Device.Ethernet.Interface.{i}.MACAddress!SYSFS:/sys/class/net/@Name/address*/ static int get_EthernetInterface_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "address", value); @@ -693,54 +695,55 @@ static int set_EthernetInterface_EEEEnable(char *refparam, struct dmctx *ctx, vo return 0; } -/*#Device.Ethernet.Interface.{i}.Stats.BytesSent!UBUS:network.device/status/name,@Name/statistics.tx_bytes*/ +/*#Device.Ethernet.Interface.{i}.Stats.BytesSent!SYSFS:/sys/class/net/@Name/statistics/tx_bytes*/ static int get_EthernetInterfaceStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "statistics/tx_bytes", value); } -/*#Device.Ethernet.Interface.{i}.Stats.BytesReceived!UBUS:network.device/status/name,@Name/statistics.rx_bytes*/ +/*#Device.Ethernet.Interface.{i}.Stats.BytesReceived!SYSFS:/sys/class/net/@Name/statistics/rx_bytes*/ static int get_EthernetInterfaceStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "statistics/rx_bytes", value); } -/*#Device.Ethernet.Interface.{i}.Stats.PacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_packets*/ +/*#Device.Ethernet.Interface.{i}.Stats.PacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_packets*/ static int get_EthernetInterfaceStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "statistics/tx_packets", value); } -/*#Device.Ethernet.Interface.{i}.Stats.PacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_packets*/ +/*#Device.Ethernet.Interface.{i}.Stats.PacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_packets*/ static int get_EthernetInterfaceStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "statistics/rx_packets", value); } -/*#Device.Ethernet.Interface.{i}.Stats.ErrorsSent!UBUS:network.device/status/name,@Name/statistics.tx_errors*/ +/*#Device.Ethernet.Interface.{i}.Stats.ErrorsSent!SYSFS:/sys/class/net/@Name/statistics/tx_errors*/ static int get_EthernetInterfaceStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "statistics/tx_errors", value); } -/*#Device.Ethernet.Interface.{i}.Stats.ErrorsReceived!UBUS:network.device/status/name,@Name/statistics.rx_errors*/ +/*#Device.Ethernet.Interface.{i}.Stats.ErrorsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_errors*/ static int get_EthernetInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "statistics/rx_errors", value); } -/*#Device.Ethernet.Interface.{i}.Stats.DiscardPacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_dropped*/ +/*#Device.Ethernet.Interface.{i}.Stats.DiscardPacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_dropped*/ static int get_EthernetInterfaceStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "statistics/tx_dropped", value); } -/*#Device.Ethernet.Interface.{i}.Stats.DiscardPacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_dropped*/ +/*#Device.Ethernet.Interface.{i}.Stats.DiscardPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_dropped*/ static int get_EthernetInterfaceStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "statistics/rx_dropped", value); } +/*#Device.Ethernet.Interface.{i}.Stats.DiscardPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/multicast*/ static int get_EthernetInterfaceStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_port_sysfs(data, "statistics/multicast", value); @@ -1394,54 +1397,55 @@ static int set_EthernetVLANTermination_TPID(char *refparam, struct dmctx *ctx, v return 0; } -/*#Device.Ethernet.VLANTermination.{i}.Stats.BytesSent!UBUS:network.device/status/name,@Name/statistics.tx_bytes*/ +/*#Device.Ethernet.VLANTermination.{i}.Stats.BytesSent!SYSFS:/sys/class/net/@Name/statistics/tx_bytes*/ static int get_EthernetVLANTerminationStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_iface_sysfs(data, "statistics/tx_bytes", value); } -/*#Device.Ethernet.VLANTermination.{i}.Stats.BytesReceived!UBUS:network.device/status/name,@Name/statistics.rx_bytes*/ +/*#Device.Ethernet.VLANTermination.{i}.Stats.BytesReceived!SYSFS:/sys/class/net/@Name/statistics/rx_bytes*/ static int get_EthernetVLANTerminationStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_iface_sysfs(data, "statistics/rx_bytes", value); } -/*#Device.Ethernet.VLANTermination.{i}.Stats.PacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_packets*/ +/*#Device.Ethernet.VLANTermination.{i}.Stats.PacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_packets*/ static int get_EthernetVLANTerminationStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_iface_sysfs(data, "statistics/tx_packets", value); } -/*#Device.Ethernet.VLANTermination.{i}.Stats.PacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_packets*/ +/*#Device.Ethernet.VLANTermination.{i}.Stats.PacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_packets*/ static int get_EthernetVLANTerminationStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_iface_sysfs(data, "statistics/rx_packets", value); } -/*#Device.Ethernet.VLANTermination.{i}.Stats.ErrorsSent!UBUS:network.device/status/name,@Name/statistics.tx_errors*/ +/*#Device.Ethernet.VLANTermination.{i}.Stats.ErrorsSent!SYSFS:/sys/class/net/@Name/statistics/tx_errors*/ static int get_EthernetVLANTerminationStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_iface_sysfs(data, "statistics/tx_errors", value); } -/*#Device.Ethernet.VLANTermination.{i}.Stats.ErrorsReceived!UBUS:network.device/status/name,@Name/statistics.rx_errors*/ +/*#Device.Ethernet.VLANTermination.{i}.Stats.ErrorsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_errors*/ static int get_EthernetVLANTerminationStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_iface_sysfs(data, "statistics/rx_errors", value); } -/*#Device.Ethernet.VLANTermination.{i}.Stats.DiscardPacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_dropped*/ +/*#Device.Ethernet.VLANTermination.{i}.Stats.DiscardPacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_dropped*/ static int get_EthernetVLANTerminationStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_iface_sysfs(data, "statistics/tx_dropped", value); } -/*#Device.Ethernet.VLANTermination.{i}.Stats.DiscardPacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_dropped*/ +/*#Device.Ethernet.VLANTermination.{i}.Stats.DiscardPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_dropped*/ static int get_EthernetVLANTerminationStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_iface_sysfs(data, "statistics/rx_dropped", value); } +/*#Device.Ethernet.VLANTermination.{i}.Stats.MulticastPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/multicast*/ static int get_EthernetVLANTerminationStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return eth_iface_sysfs(data, "statistics/multicast", value); diff --git a/dmtree/tr181/managementserver.c b/dmtree/tr181/managementserver.c index 0be3070b..a0753705 100644 --- a/dmtree/tr181/managementserver.c +++ b/dmtree/tr181/managementserver.c @@ -229,7 +229,7 @@ static int set_management_server_connection_request_passwd(char *refparam, struc return 0; } -/*#Device.ManagementServer.ConnectionRequestPassword!UCI:cwmp/cpe,cpe/upgrades_managed*/ +/*#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); diff --git a/dmtree/tr181/ppp.c b/dmtree/tr181/ppp.c index 1b9836aa..45912152 100644 --- a/dmtree/tr181/ppp.c +++ b/dmtree/tr181/ppp.c @@ -80,16 +80,13 @@ static int set_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *i /*#Device.PPP.Interface.{i}.Status!UBUS:network.interface/status/interface,@Name/up*/ static int get_PPPInterface_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - json_object *res; + json_object *res = NULL; char *status; dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct uci_section *)data)), String}}, 1, &res); DM_ASSERT(res, *value = "Down"); status = dmjson_get_value(res, 1, "up"); - if (strcmp(status, "true") == 0) - *value= "Up"; - else - *value= "Down"; + *value = (strcmp(status, "true") == 0) ? "Up" : "Down"; return 0; } @@ -208,64 +205,63 @@ static int ppp_read_sysfs(struct uci_section *sect, const char *name, char **val int rc = 0; dmuci_get_value_by_section_string(sect, "proto", &proto); - if (!strcmp(proto, "pppoe")) { char *ifname; - dmuci_get_value_by_section_string(sect, "ifname", &ifname); rc = get_net_device_sysfs(ifname, name, value); } return rc; } -/*#Device.PPP.Interface.{i}.Stats.BytesReceived!UBUS:network.device/status/name,@Name/statistics.rx_bytes*/ +/*#Device.PPP.Interface.{i}.Stats.BytesReceived!SYSFS:/sys/class/net/@Name/statistics/rx_bytes*/ static int get_ppp_eth_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return ppp_read_sysfs(data, "statistics/rx_bytes", value); } -/*#Device.PPP.Interface.{i}.Stats.BytesSent!UBUS:network.device/status/name,@Name/statistics.tx_bytes*/ +/*#Device.PPP.Interface.{i}.Stats.BytesSent!SYSFS:/sys/class/net/@Name/statistics/tx_bytes*/ static int get_ppp_eth_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return ppp_read_sysfs(data, "statistics/tx_bytes", value); } -/*#Device.PPP.Interface.{i}.Stats.PacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_packets*/ +/*#Device.PPP.Interface.{i}.Stats.PacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_packets*/ static int get_ppp_eth_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return ppp_read_sysfs(data, "statistics/rx_packets", value); } -/*#Device.PPP.Interface.{i}.Stats.PacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_packets*/ +/*#Device.PPP.Interface.{i}.Stats.PacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_packets*/ static int get_ppp_eth_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return ppp_read_sysfs(data, "statistics/tx_packets", value); } -/*#Device.PPP.Interface.{i}.Stats.ErrorsSent!UBUS:network.device/status/name,@Name/statistics.tx_errors*/ +/*#Device.PPP.Interface.{i}.Stats.ErrorsSent!SYSFS:/sys/class/net/@Name/statistics/tx_errors*/ static int get_PPPInterfaceStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return ppp_read_sysfs(data, "statistics/tx_errors", value); } -/*#Device.PPP.Interface.{i}.Stats.ErrorsReceived!UBUS:network.device/status/name,@Name/statistics.rx_errors*/ +/*#Device.PPP.Interface.{i}.Stats.ErrorsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_errors*/ static int get_PPPInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return ppp_read_sysfs(data, "statistics/rx_errors", value); } -/*#Device.PPP.Interface.{i}.Stats.DiscardPacketsSent!UBUS:network.device/status/name,@Name/statistics.tx_dropped*/ +/*#Device.PPP.Interface.{i}.Stats.DiscardPacketsSent!SYSFS:/sys/class/net/@Name/statistics/tx_dropped*/ static int get_PPPInterfaceStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return ppp_read_sysfs(data, "statistics/tx_dropped", value); } -/*#Device.PPP.Interface.{i}.Stats.DiscardPacketsReceived!UBUS:network.device/status/name,@Name/statistics.rx_dropped*/ +/*#Device.PPP.Interface.{i}.Stats.DiscardPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/rx_dropped*/ static int get_PPPInterfaceStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return ppp_read_sysfs(data, "statistics/rx_dropped", value); } +/*#Device.PPP.Interface.{i}.Stats.MulticastPacketsReceived!SYSFS:/sys/class/net/@Name/statistics/multicast*/ static int get_PPPInterfaceStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return ppp_read_sysfs(data, "statistics/multicast", value); @@ -396,11 +392,10 @@ static int set_PPPInterfacePPPoE_ServiceName(char *refparam, struct dmctx *ctx, ***************************************************************************/ static int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if(((struct uci_section *)data)) { + if(((struct uci_section *)data)) dmasprintf(linker, "%s", section_name(((struct uci_section *)data))); - return 0; - } - *linker = ""; + else + *linker = ""; return 0; } diff --git a/dmtree/tr181/ptm.c b/dmtree/tr181/ptm.c index 3070c3cf..52ffbc45 100644 --- a/dmtree/tr181/ptm.c +++ b/dmtree/tr181/ptm.c @@ -24,11 +24,10 @@ struct ptm_args ***************************************************************************/ static int get_ptm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data && ((struct ptm_args *)data)->ifname) { + if (data && ((struct ptm_args *)data)->ifname) *linker = ((struct ptm_args *)data)->ifname; - return 0; - } - *linker = "" ; + else + *linker = "" ; return 0; } diff --git a/dmtree/tr181/upnp.c b/dmtree/tr181/upnp.c index 879f80b8..5e400215 100644 --- a/dmtree/tr181/upnp.c +++ b/dmtree/tr181/upnp.c @@ -59,41 +59,37 @@ struct upnp_description_file_info { ***************************************************************************/ static int get_root_device_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data && ((struct upnpdiscovery *)data)->uuid) { + if (data && ((struct upnpdiscovery *)data)->uuid) dmasprintf(linker, "%s", ((struct upnpdiscovery *)data)->uuid); - return 0; - } - *linker = "" ; + else + *linker = "" ; return 0; } static int get_device_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data && ((struct upnpdiscovery *)data)->uuid){ + if (data && ((struct upnpdiscovery *)data)->uuid) dmasprintf(linker, "%s", ((struct upnpdiscovery *)data)->uuid); - return 0; - } - *linker = "" ; + else + *linker = "" ; return 0; } static int get_device_instance_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data && ((struct upnp_device_inst *)data)->udn){ + if (data && ((struct upnp_device_inst *)data)->udn) dmasprintf(linker, "%s", ((struct upnp_device_inst *)data)->udn); - return 0; - } - *linker = "" ; + else + *linker = "" ; return 0; } static int get_service_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data && ((struct upnpdiscovery *)data)->usn){ + if (data && ((struct upnpdiscovery *)data)->usn) dmasprintf(linker, "%s", ((struct upnpdiscovery *)data)->usn); - return 0; - } - *linker = "" ; + else + *linker = "" ; return 0; } diff --git a/dmtree/tr181/users.c b/dmtree/tr181/users.c index deb895eb..75e9750a 100644 --- a/dmtree/tr181/users.c +++ b/dmtree/tr181/users.c @@ -34,6 +34,7 @@ static int add_users_user(char *refparam, struct dmctx *ctx, void *data, char ** struct uci_section *s, *dmmap_user; char ib[8], *last_inst = NULL, *sect_name = NULL, *username, *v; + check_create_dmmap_package("dmmap_users"); last_inst = get_last_instance_bbfdm("dmmap_users", "user", "user_instance"); snprintf(ib, sizeof(ib), "%s", last_inst ? last_inst : "1"); dmasprintf(&username, "user_%d", atoi(ib)+1); @@ -41,7 +42,7 @@ static int add_users_user(char *refparam, struct dmctx *ctx, void *data, char ** dmuci_rename_section_by_section(s, username); dmuci_set_value_by_section(s, "enabled", "1"); dmuci_set_value_by_section(s, "password", username); - check_create_dmmap_package("dmmap_users"); + dmuci_add_section_bbfdm("dmmap_users", "user", &dmmap_user, &v); dmuci_set_value_by_section(dmmap_user, "section_name", sect_name); *instance = update_instance_bbfdm(dmmap_user, last_inst, "user_instance"); diff --git a/dmtree/tr181/wifi-iopsyswrt.c b/dmtree/tr181/wifi-iopsyswrt.c index 96dfd27d..48d8a845 100644 --- a/dmtree/tr181/wifi-iopsyswrt.c +++ b/dmtree/tr181/wifi-iopsyswrt.c @@ -275,11 +275,9 @@ int os_get_wifi_access_point_status (char *refparam, struct dmctx *ctx, void *da dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "device", &iface); snprintf(object, sizeof(object), "wifi.ap.%s", iface); dmubus_call(object, "status", UBUS_ARGS{}, 0, &res); - DM_ASSERT(res, status = ""); status = dmjson_get_value(res, 1, "status"); - if (strcmp(status, "running") == 0 || strcmp(status, "up") == 0) *value = "Enabled"; else diff --git a/dmtree/tr181/wifi-openwrt.c b/dmtree/tr181/wifi-openwrt.c index 4518ad70..e96141da 100644 --- a/dmtree/tr181/wifi-openwrt.c +++ b/dmtree/tr181/wifi-openwrt.c @@ -6,187 +6,156 @@ static int not_implemented(char **value) return 0; } -/*#Device.WiFi.SSID.{i}.BSSID!UBUS:wifi.ap.@Name/status//bssid*/ int os__get_wlan_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.Radio.{i}.Stats.BytesSent!UBUS:wifi.radio.@Name/stats//tx_bytes*/ int os__get_WiFiRadioStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.Radio.{i}.Stats.BytesReceived!UBUS:wifi.radio.@Name/stats//rx_bytes*/ int os__get_WiFiRadioStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.Radio.{i}.Stats.PacketsSent!UBUS:wifi.radio.@Name/stats//tx_packets*/ int os__get_WiFiRadioStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.Radio.{i}.Stats.PacketsReceived!UBUS:wifi.radio.@Name/stats//rx_packets*/ int os__get_WiFiRadioStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.Radio.{i}.Stats.ErrorsSent!UBUS:wifi.radio.@Name/stats//tx_error_packets*/ int os__get_WiFiRadioStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.Radio.{i}.Stats.ErrorsReceived!UBUS:wifi.radio.@Name/stats//rx_error_packets*/ int os__get_WiFiRadioStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.Radio.{i}.Stats.DiscardPacketsSent!UBUS:wifi.radio.@Name/stats//tx_dropped_packets*/ int os__get_WiFiRadioStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.Radio.{i}.Stats.DiscardPacketsReceived!UBUS:wifi.radio.@Name/stats//rx_dropped_packets*/ int os__get_WiFiRadioStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.Radio.{i}.Stats.FCSErrorCount!UBUS:wifi.radio.@Name/stats//rx_fcs_error_packets*/ int os__get_WiFiRadioStats_FCSErrorCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.BytesSent!UBUS:wifi.ap.@Name/stats//tx_bytes*/ int os__get_WiFiSSIDStats_BytesSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.BytesReceived!UBUS:wifi.ap.@Name/stats//rx_bytes*/ int os__get_WiFiSSIDStats_BytesReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.PacketsSent!UBUS:wifi.ap.@Name/stats//tx_packets*/ int os__get_WiFiSSIDStats_PacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.PacketsReceived!UBUS:wifi.ap.@Name/stats//rx_packets*/ int os__get_WiFiSSIDStats_PacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.ErrorsSent!UBUS:wifi.ap.@Name/stats//tx_error_packets*/ int os__get_WiFiSSIDStats_ErrorsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.ErrorsReceived!UBUS:wifi.ap.@Name/stats//rx_error_packets*/ int os__get_WiFiSSIDStats_ErrorsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.DiscardPacketsSent!UBUS:wifi.ap.@Name/stats//tx_dropped_packets*/ int os__get_WiFiSSIDStats_DiscardPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.DiscardPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_dropped_packets*/ int os__get_WiFiSSIDStats_DiscardPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.UnicastPacketsSent!UBUS:wifi.ap.@Name/stats//tx_unicast_packets*/ int os__get_WiFiSSIDStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.UnicastPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_unicast_packets*/ int os__get_WiFiSSIDStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.MulticastPacketsSent!UBUS:wifi.ap.@Name/stats//tx_multicast_packets*/ int os__get_WiFiSSIDStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.MulticastPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_multicast_packets*/ int os__get_WiFiSSIDStats_MulticastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.BroadcastPacketsSent!UBUS:wifi.ap.@Name/stats//tx_broadcast_packets*/ int os__get_WiFiSSIDStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.BroadcastPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_broadcast_packets*/ int os__get_WiFiSSIDStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.RetransCount!UBUS:wifi.ap.@Name/stats//tx_retrans_packets*/ int os__get_WiFiSSIDStats_RetransCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.FailedRetransCount!UBUS:wifi.ap.@Name/stats//tx_retrans_fail_packets*/ int os__get_WiFiSSIDStats_FailedRetransCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.RetryCount!UBUS:wifi.ap.@Name/stats//tx_retry_packets*/ int os__get_WiFiSSIDStats_RetryCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.MultipleRetryCount!UBUS:wifi.ap.@Name/stats//tx_multi_retry_packets*/ int os__get_WiFiSSIDStats_MultipleRetryCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.ACKFailureCount!UBUS:wifi.ap.@Name/stats//ack_fail_packets*/ int os__get_WiFiSSIDStats_ACKFailureCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.AggregatedPacketCount!UBUS:wifi.ap.@Name/stats//aggregate_packets*/ int os__get_WiFiSSIDStats_AggregatedPacketCount(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); } -/*#Device.WiFi.SSID.{i}.Stats.UnknownProtoPacketsReceived!UBUS:wifi.ap.@Name/stats//rx_unknown_packets*/ int os__get_WiFiSSIDStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); @@ -237,7 +206,6 @@ int os__get_access_point_associative_device_statistics_multiple_retry_count(char return not_implemented(value); } -/*#Device.WiFi.AccessPoint.{i}.Status!UBUS:wifi.ap.@Name/status//status*/ int os_get_wifi_access_point_status (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); @@ -332,7 +300,6 @@ int os__browseWifiNeighboringWiFiDiagnosticResultInst(struct dmctx *dmctx, DMNOD return 0; } -/*#Device.WiFi.Radio.{i}.OperatingStandards!UBUS:wifi.radio.@Name/status//standard*/ int os_get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { return not_implemented(value); diff --git a/dmtree/tr181/wifi.c b/dmtree/tr181/wifi.c index 42b447a8..4d2b9206 100644 --- a/dmtree/tr181/wifi.c +++ b/dmtree/tr181/wifi.c @@ -22,31 +22,28 @@ ***************************************************************************/ static int get_linker_Wifi_Radio(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data && ((struct wifi_radio_args *)data)->wifi_radio_sec) { + if (data && ((struct wifi_radio_args *)data)->wifi_radio_sec) *linker = section_name(((struct wifi_radio_args *)data)->wifi_radio_sec); - return 0; - } - *linker = ""; + else + *linker = ""; return 0; } static int get_linker_Wifi_Ssid(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data && ((struct wifi_ssid_args *)data)->ifname) { + if (data && ((struct wifi_ssid_args *)data)->ifname) *linker = ((struct wifi_ssid_args *)data)->ifname; - return 0; - } - *linker = ""; + else + *linker = ""; return 0; } static int get_linker_associated_device(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { - if (data) { + if (data) *linker = dmjson_get_value((json_object *)data, 1, "macaddr"); - return 0; - } - *linker = ""; + else + *linker = ""; return 0; } /************************************************************************** @@ -112,12 +109,12 @@ static int get_WiFi_SSIDNumberOfEntries(char *refparam, struct dmctx *ctx, void static int get_WiFi_AccessPointNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { struct uci_section *s; - int nbre= 0; - char *mode= NULL; + int nbre = 0; + char *mode = NULL; uci_foreach_sections("wireless", "wifi-iface", s) { dmuci_get_value_by_section_string(s, "mode", &mode); - if ((strlen(mode)>0 || mode[0] != '\0') && strcmp(mode, "ap") != 0) + if ((strlen(mode) > 0 || mode[0] != '\0') && strcmp(mode, "ap") != 0) continue; nbre++; } @@ -142,15 +139,11 @@ static int get_WiFi_EndPointNumberOfEntries(char *refparam, struct dmctx *ctx, v } /*#Device.WiFi.SSID.{i}.Enable!UCI:wireless/wifi-iface,@i-1/disabled*/ +/*#Device.WiFi.AccessPoint.{i}.Enable!UCI:wireless/wifi-iface,@i-1/disabled*/ static int get_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *val; - - dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "disabled", &val); - if ((val[0] == '\0') || (val[0] == '0')) - *value = "1"; - else - *value = "0"; + dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "disabled", value); + *value = ((*value)[0] == '1') ? "0" : "1"; return 0; } @@ -175,10 +168,7 @@ static int set_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char * static int get_wifi_status (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "disabled", value); - if ((*value)[0] == '\0' || (*value)[0] == '0') - *value = "Up"; - else - *value = "Down"; + *value = ((*value)[0] == '1') ? "Down" : "Up"; return 0; } @@ -207,9 +197,8 @@ static int set_wlan_ssid(char *refparam, struct dmctx *ctx, void *data, char *in /*#Device.WiFi.SSID.{i}.MACAddress!UBUS:network.device/status/name,@Name/macaddr*/ static int get_WiFiSSID_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - json_object *res; + json_object *res = NULL; dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct wifi_ssid_args *)data)->ifname, String}}, 1, &res); - DM_ASSERT(res, *value = ""); *value = dmjson_get_value(res, 1, "macaddr"); return 0; @@ -218,13 +207,8 @@ static int get_WiFiSSID_MACAddress(char *refparam, struct dmctx *ctx, void *data /*#Device.WiFi.Radio.{i}.Enable!UCI:wireless/wifi-device,@i-1/disabled*/ static int get_radio_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *val; - dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "disabled", &val); - - if (val[0] == '1') - *value = "0"; - else - *value = "1"; + dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "disabled", value); + *value = ((*value)[0] == '1') ? "0" : "1"; return 0; } @@ -249,10 +233,7 @@ static int set_radio_enable(char *refparam, struct dmctx *ctx, void *data, char static int get_radio_status (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "disabled", value); - if ((*value)[0] == '1') - *value = "Down"; - else - *value = "Up"; + *value = ((*value)[0] == '1') ? "Down" : "Up"; return 0; } @@ -281,6 +262,7 @@ static int get_WiFiRadio_Name(char *refparam, struct dmctx *ctx, void *data, cha return 0; } +/*#Device.WiFi.Radio.{i}.X_IOPSYS_EU_MaxAllowedAssociations!UCI:wireless/wifi-device,@i-1/maxassoc*/ static int get_radio_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "maxassoc", value); @@ -300,6 +282,7 @@ static int set_radio_maxassoc(char *refparam, struct dmctx *ctx, void *data, cha return 0; } +/*#Device.WiFi.Radio.{i}.X_IOPSYS_EU_DFSEnable!UCI:wireless/wifi-device,@i-1/dfsc*/ static int get_radio_dfsenable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *val; @@ -515,13 +498,8 @@ static int set_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx /*#Device.WiFi.Radio.{i}.PreambleType!UCI:wireless/wifi-device,@i-1/short_preamble*/ static int get_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *preamble = NULL; - - dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "short_preamble", &preamble); - if (preamble[0] == '\0' || strlen(preamble) == 0 || strcmp(preamble, "1") != 0) - *value = "long"; - else - *value = "short"; + dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "short_preamble", value); + *value = ((*value)[0] == '0') ? "short" : "long"; return 0; } @@ -533,10 +511,7 @@ static int set_WiFiRadio_PreambleType(char *refparam, struct dmctx *ctx, void *d return FAULT_9007; break; case VALUESET: - if(strcmp(value, "short") == 0) - dmuci_set_value_by_section(((struct wifi_radio_args *)data)->wifi_radio_sec, "short_preamble", "1"); - else - dmuci_set_value_by_section(((struct wifi_radio_args *)data)->wifi_radio_sec, "short_preamble", "0"); + dmuci_set_value_by_section(((struct wifi_radio_args *)data)->wifi_radio_sec, "short_preamble", (strcmp(value, "short") == 0) ? "1" : "0"); break; } return 0; @@ -600,11 +575,8 @@ static int get_WiFiRadio_RegulatoryDomain(char *refparam, struct dmctx *ctx, voi dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "country", &country); arr = strsplit(country, "/", &length); - if(arr && arr[0]) + if (arr && arr[0]) dmasprintf(value, "%s ", arr[0]); - else - *value= ""; - return 0; } @@ -684,12 +656,8 @@ static int set_radio_auto_channel_enable(char *refparam, struct dmctx *ctx, void /*#Device.WiFi.SSID.{i}.SSIDAdvertisementEnabled!UCI:wireless/wifi-iface,@i-1/hidden*/ static int get_wlan_ssid_advertisement_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *hidden; - dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "hidden", &hidden); - if (hidden[0] == '1' && hidden[1] == '\0') - *value = "0"; - else - *value = "1"; + dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "hidden", value); + *value = ((*value)[0] == '1') ? "0" : "1"; return 0; } @@ -704,7 +672,7 @@ static int set_wlan_ssid_advertisement_enable(char *refparam, struct dmctx *ctx, return 0; case VALUESET: string_to_bool(value, &b); - dmuci_set_value_by_section(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "hidden", b ? "" : "1"); + dmuci_set_value_by_section(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "hidden", b ? "0" : "1"); return 0; } @@ -714,11 +682,8 @@ static int set_wlan_ssid_advertisement_enable(char *refparam, struct dmctx *ctx, /*#Device.WiFi.AccessPoint.{i}.WMMEnable!UCI:wireless/wifi-device,@i-1/wmm*/ static int get_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - bool b; dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "device", value); dmuci_get_option_value_string("wireless", *value, "wmm", value); - string_to_bool(*value, &b); - *value = (b) ? "true" : "false"; return 0; } @@ -735,15 +700,9 @@ static int set_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char * case VALUESET: string_to_bool(value, &b); dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "device", &device); - if (b) { - dmuci_set_value("wireless", device, "wmm", "1"); - dmuci_set_value("wireless", device, "wmm_noack", "1"); - dmuci_set_value("wireless", device, "wmm_apsd", "1"); - } else { - dmuci_set_value("wireless", device, "wmm", "0"); - dmuci_set_value("wireless", device, "wmm_noack", ""); - dmuci_set_value("wireless", device, "wmm_apsd", ""); - } + dmuci_set_value("wireless", device, "wmm", b ? "1" : "0"); + dmuci_set_value("wireless", device, "wmm_noack", b ? "1" : ""); + dmuci_set_value("wireless", device, "wmm_apsd", b ? "1" : ""); return 0; } return 0; @@ -752,9 +711,8 @@ static int set_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char * /*#Device.WiFi.AccessPoint.{i}.MaxAssociatedDevices!UCI:wireless/wifi-iface,@i-1/maxassoc*/ static int get_access_point_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *device; - dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "device", &device); - dmuci_get_option_value_string("wireless", device, "maxassoc", value); + dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "device", value); + dmuci_get_option_value_string("wireless", *value, "maxassoc", value); return 0; } @@ -797,10 +755,8 @@ static int get_WiFiAccessPoint_WMMCapability(char *refparam, struct dmctx *ctx, /*#Device.WiFi.AccessPoint.{i}.MaxAllowedAssociations!UCI:wireless/wifi-iface,@i-1/maxassoc*/ static int get_WiFiAccessPoint_MaxAllowedAssociations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - char *device; - - dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "device", &device); - dmuci_get_option_value_string("wireless", device, "maxassoc", value); + dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "device", value); + dmuci_get_option_value_string("wireless", *value, "maxassoc", value); return 0; } @@ -847,14 +803,13 @@ static int set_WiFiAccessPoint_IsolationEnable(char *refparam, struct dmctx *ctx return 0; } +/*#Device.WiFi.AccessPoint.{i}.AllowedMACAddress!UCI:wireless/wifi-iface,@i-1/maclist*/ static int get_WiFiAccessPoint_AllowedMACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { struct uci_list *val; dmuci_get_value_by_section_list(((struct wifi_acp_args *)data)->wifi_acp_sec, "maclist", &val); if (val) *value = dmuci_list_to_string(val, " "); - else - *value = ""; return 0; } @@ -870,10 +825,9 @@ static int set_WiFiAccessPoint_AllowedMACAddress(char *refparam, struct dmctx *c return FAULT_9007; break; case VALUESET: - arr= strsplit(value, " ", &length); - for (i = 0; i < length; i++){ + arr = strsplit(value, " ", &length); + for (i = 0; i < length; i++) dmuci_add_list_value_by_section(((struct wifi_acp_args *)data)->wifi_acp_sec, "maclist", arr[i]); - } break; } return 0; @@ -972,6 +926,7 @@ static int reset_wlan(struct uci_section *s) return 0; } +/*#Device.WiFi.AccessPoint.{i}.Security.ModeEnabled!UCI:wireless/wifi-iface,@i-1/encryption&UCI:wireless/wifi-iface,@i-1/cipher*/ static int get_access_point_security_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *encryption, *cipher; @@ -1092,15 +1047,13 @@ static int set_access_point_security_wepkey(char *refparam, struct dmctx *ctx, v return 0; } +/*#Device.WiFi.AccessPoint.{i}.Security.X_IOPSYS_EU_WEPKeyInde!UCI:wireless/wifi-iface,@i-1/key_index*/ static int get_access_point_security_wepkey_index(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *key_index; dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "key_index", &key_index); - if (*key_index == '\0') - *value = "1"; - else - *value = key_index; + *value = (*key_index == '\0') ? "1" : key_index; return 0; } @@ -1111,9 +1064,8 @@ static int set_access_point_security_wepkey_index(char *refparam, struct dmctx * //TODO return 0; case VALUESET: - if (atoi(value)>=1 && atoi(value)<=4) { + if (atoi(value) >= 1 && atoi(value) <= 4) dmuci_set_value_by_section(((struct wifi_acp_args *)data)->wifi_acp_sec, "key_index", value); - } return 0; } return 0; @@ -1122,6 +1074,7 @@ static int set_access_point_security_wepkey_index(char *refparam, struct dmctx * static int set_access_point_security_shared_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { char *encryption; + switch (action) { case VALUECHECK: if (dm_validate_hexBinary(value, RANGE_ARGS{{NULL,"32"}}, 1)) @@ -1129,9 +1082,8 @@ static int set_access_point_security_shared_key(char *refparam, struct dmctx *ct return 0; case VALUESET: dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "encryption", &encryption); - if (strcmp(encryption, "psk") == 0 || strcmp(encryption, "psk2") == 0 || strcmp(encryption, "mixed-psk") == 0 ) { + if (strcmp(encryption, "psk") == 0 || strcmp(encryption, "psk2") == 0 || strcmp(encryption, "mixed-psk") == 0 ) dmuci_set_value_by_section(((struct wifi_acp_args *)data)->wifi_acp_sec, "key", value); - } return 0; } return 0; @@ -1148,9 +1100,8 @@ static int set_access_point_security_passphrase(char *refparam, struct dmctx *ct return 0; case VALUESET: dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "encryption", &encryption); - if (strcmp(encryption, "psk") == 0 || strcmp(encryption, "psk2") == 0 || strcmp(encryption, "mixed-psk") == 0 ) { + if (strcmp(encryption, "psk") == 0 || strcmp(encryption, "psk2") == 0 || strcmp(encryption, "mixed-psk") == 0 ) set_access_point_security_shared_key(refparam, ctx, data, instance, value, action); - } return 0; } return 0; @@ -1176,11 +1127,8 @@ static int set_access_point_security_rekey_interval(char *refparam, struct dmctx return 0; case VALUESET: dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "encryption", &encryption); - if (strcmp(encryption, "wep-open") == 0 || strcmp(encryption, "wep-shared") == 0 || strcmp(encryption, "none") == 0) - return 0; - else { + if (strcmp(encryption, "wep-open") != 0 && strcmp(encryption, "wep-shared") != 0 && strcmp(encryption, "none") != 0) dmuci_set_value_by_section(((struct wifi_acp_args *)data)->wifi_acp_sec, "gtk_rekey", value); - } return 0; } return 0; @@ -1719,7 +1667,7 @@ static int set_WiFiEndPointProfile_SSID(char *refparam, struct dmctx *ctx, void return 0; } -/*#Device.WiFi.EndPoint.{i}.Profile.{i}.Security.SSID!UCI:wireless/wifi-iface,@i-1/encryption*/ +/*#Device.WiFi.EndPoint.{i}.Profile.{i}.Security.SSID!UCI:wireless/wifi-iface,@i-1/encryption&UCI:wireless/wifi-iface,@i-1/cipher*/ static int get_WiFiEndPointProfileSecurity_ModeEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { char *encryption, *cipher; diff --git a/json/X_IOPSYS_EU_Buttons.json b/json/X_IOPSYS_EU_Buttons.json new file mode 100644 index 00000000..1c95cff7 --- /dev/null +++ b/json/X_IOPSYS_EU_Buttons.json @@ -0,0 +1,213 @@ +{ + "Device.X_IOPSYS_EU_Buttons.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "array": true, + "mapping": { + "type": "uci", + "uci": { + "file": "buttons", + "section": { + "type": "button" + }, + "dmmapfile": "dmmap_buttons" + } + }, + "Alias": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dmmap_buttons", + "section": { + "type": "button", + "index": "@i-1" + }, + "option": { + "name": "buttonalias" + }, + "path": "/etc/bbfdm" + } + } + ] + }, + "Enable": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "buttons", + "section": { + "type": "button", + "index": "@i-1" + }, + "option": { + "name": "enable" + } + } + } + ] + }, + "Name": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "buttons", + "section": { + "type": "button", + "index": "@i-1" + }, + "option": { + "name": "@Name" + } + } + } + ] + }, + "GPIOButton": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": false, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "buttons", + "section": { + "type": "button", + "index": "@i-1" + }, + "option": { + "name": "button" + } + } + } + ] + }, + "HotplugInterface": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": false, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "buttons", + "section": { + "type": "button", + "index": "@i-1" + }, + "option": { + "name": "hotplug" + } + } + } + ] + }, + "HotplugInterfaceForLongPress": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": false, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "buttons", + "section": { + "type": "button", + "index": "@i-1" + }, + "option": { + "name": "hotplug_long" + } + } + } + ] + }, + "MinPressTime": { + "type": "unsignedInt", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "buttons", + "section": { + "type": "button", + "index": "@i-1" + }, + "option": { + "name": "minpress" + } + } + } + ] + }, + "LongPressTime": { + "type": "unsignedInt", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "buttons", + "section": { + "type": "button", + "index": "@i-1" + }, + "option": { + "name": "longpress" + } + } + } + ] + } + } +} diff --git a/json/X_IOPSYS_EU_Dropbear.json b/json/X_IOPSYS_EU_Dropbear.json new file mode 100644 index 00000000..4a2fb033 --- /dev/null +++ b/json/X_IOPSYS_EU_Dropbear.json @@ -0,0 +1,333 @@ +{ + "Device.X_IOPSYS_EU_Dropbear.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "array": true, + "mapping": { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear" + }, + "dmmapfile": "dmmap_dropbear" + } + }, + "Alias": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dmmap_dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "dropbearalias" + }, + "path":"/etc/bbfdm", + } + } + ] + }, + "PasswordAuth": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "PasswordAuth" + } + } + } + ] + }, + "RootPasswordAuth": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "RootPasswordAuth" + } + } + } + ] + }, + "Port": { + "type": "unsignedInt", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "Port" + } + } + } + ] + }, + "RootLogin": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "RootLogin" + } + } + } + ] + }, + "GatewayPorts": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "GatewayPorts" + } + } + } + ] + }, + "Interface": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "Interface" + } + } + } + ] + }, + "RSAKeyFile": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "rsakeyfile" + } + } + } + ] + }, + "DSSKeyFile": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "dsskeyfile" + } + } + } + ] + }, + "SSHKeepAlive": { + "type": "unsignedInt", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "SSHKeepAlive" + } + } + } + ] + }, + "IdleTimeout": { + "type": "unsignedInt", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "IdleTimeout" + } + } + } + ] + }, + "Verbose": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "verbose" + } + } + } + ] + }, + "BannerFile": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dropbear", + "section": { + "type": "dropbear", + "index": "@i-1" + }, + "option": { + "name": "BannerFile" + } + } + } + ] + } + } +} diff --git a/json/X_IOPSYS_EU_OWSD.json b/json/X_IOPSYS_EU_OWSD.json new file mode 100644 index 00000000..ff198b98 --- /dev/null +++ b/json/X_IOPSYS_EU_OWSD.json @@ -0,0 +1,417 @@ +{ + "Device.X_IOPSYS_EU_OWSD.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "array": false, + "UnixSocket": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "name": "global" + }, + "option": { + "name": "sock" + } + } + } + ] + }, + "URLRedirect": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "name": "global" + }, + "option": { + "name": "redirect" + } + } + } + ] + }, + "Device.X_IOPSYS_EU_OWSD.UbusProxy.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "array": false, + "Enable": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "name": "ubusproxy" + }, + "option": { + "name": "enable" + } + } + } + ] + + }, + "PeerCertificate": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "name": "ubusproxy" + }, + "option": { + "name": "peer_cert" + } + } + } + ] + }, + "PeerKey": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "name": "ubusproxy" + }, + "option": { + "name": "peer_key" + } + } + } + ] + }, + "PeerCA": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "name": "ubusproxy" + }, + "option": { + "name": "peer_ca" + } + } + } + ] + } + }, + "Device.X_IOPSYS_EU_OWSD.VirtualHost.{i}.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "array": true, + "mapping": { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen" + }, + "dmmapfile": "dmmap_owsd" + } + }, + "Alias": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "dmmap_owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "olistenalias" + }, + "path":"/etc/bbfdm", + } + } + ] + }, + "Interface": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "interface" + }, + "ref": "Device.IP.Interface" + } + } + ] + }, + "Port": { + "type": "unsignedInt", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "port" + } + } + } + ] + }, + "IPv6Enable": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "ipv6" + } + } + } + ] + }, + "AllowInterfaceIPAddressAsOrigin": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "whitelist_interface_as_origin" + } + } + } + ] + }, + "AllowDHCPDomainsAsOrigin": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "whitelist_dhcp_domains" + } + } + } + ] + }, + "AllowedOrigins": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "origin" + } + } + } + ] + }, + "Certificate": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "cert" + } + } + } + ] + }, + "Key": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "key" + } + } + } + ] + }, + "CA": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "owsd", + "section": { + "type": "owsd-listen", + "index": "@i-1" + }, + "option": { + "name": "ca" + } + } + } + ] + } + } + } +} diff --git a/json/X_IOPSYS_EU_Syslog.json b/json/X_IOPSYS_EU_Syslog.json new file mode 100644 index 00000000..fc71c867 --- /dev/null +++ b/json/X_IOPSYS_EU_Syslog.json @@ -0,0 +1,79 @@ +{ + "Device.X_IOPSYS_EU_Syslog.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "array": false, + "ServerIPAddress": { + "type": "string", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "system", + "section": { + "name": "@system[0]" + }, + "option": { + "name": "log_ip" + } + } + } + ] + }, + "ServerPort": { + "type": "unsignedInt", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "system", + "section": { + "name": "@system[0]" + }, + "option": { + "name": "log_port" + } + } + } + ] + }, + "ConsoleLogLevel": { + "type": "unsignedInt", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "system", + "section": { + "name": "@system[0]" + }, + "option": { + "name": "conloglevel" + } + } + } + ] + } + } +} diff --git a/json/X_IOPSYS_EU_WiFiLife.json b/json/X_IOPSYS_EU_WiFiLife.json new file mode 100644 index 00000000..c085c76e --- /dev/null +++ b/json/X_IOPSYS_EU_WiFiLife.json @@ -0,0 +1,99 @@ +{ + "Device.X_IOPSYS_EU_WiFiLife.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "array": false, + "Enable": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wifilife", + "section": { + "name": "@wifilife[0]" + }, + "option": { + "name": "enabled" + } + } + } + ] + }, + "Device.X_IOPSYS_EU_WiFiLife.Steering": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "array": true, + "mapping": { + "type": "uci", + "uci": { + "file": "wifilife", + "section": { + "type": "steer" + }, + "dmmapfile": "dmmap_wifilife" + } + }, + "Enable": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wifilife", + "section": { + "type": "steer", + "index": "@i-1" + }, + "option": { + "name": "enabled" + } + } + } + ] + }, + "LegacyFallback": { + "type": "boolean", + "protocols": [ + "cwmp", + "usp" + ], + "read": true, + "write": true, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wifilife", + "section": { + "type": "steer", + "index": "@i-1" + }, + "option": { + "name": "fallback_legacy" + } + } + } + ] + } + } + } +} diff --git a/json/tr104.json b/json/tr104.json index d273e90c..4fa94517 100644 --- a/json/tr104.json +++ b/json/tr104.json @@ -1958,7 +1958,32 @@ "max": 999 } ] + }, + "X_IOPSYS_EU_CallLines": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "voice_client", + "section": { + "type": "sip_advanced", + "name": "SIP" }, + "option": { + "name": "call_lines" + } + } + } + ] + }, "Device.Services.VoiceService.{i}.VoiceProfile.{i}.SIP.EventSubscribe.{i}.": { "type": "object", "protocols": [ @@ -3777,6 +3802,21 @@ "Disabled", "Quiescent", "Enabled" + ], + "mapping": [ + { + "type": "uci", + "uci": { + "file": "voice_client", + "section": { + "type": "tel_line", + "index": "@i-1" + }, + "option": { + "name": "enabled" + } + } + } ] }, "Alias": { @@ -3807,6 +3847,21 @@ { "max": 32 } + ], + "mapping": [ + { + "type": "uci", + "uci": { + "file": "voice_client", + "section": { + "type": "tel_line", + "index": "@i-1" + }, + "option": { + "name": "extension" + } + } + } ] }, "Status": { @@ -3887,6 +3942,55 @@ } ] }, + + "X_IOPSYS_EU_LineProfile": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + ] + }, + "X_IOPSYS_EU_TELLine": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + ] + }, + "X_IOPSYS_EU_ComfortNoiseEnable": { + "type": "boolean", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "mapping": [ + { + "type": "uci", + "uci": { + "file": "voice_client", + "section": { + "type": "tel_line", + "index": "@i-1" + }, + "option": { + "name": "noise" + } + } + } + ] + }, "Device.Services.VoiceService.{i}.VoiceProfile.{i}.Line.{i}.SIP.": { "type": "object", "protocols": [ diff --git a/json/tr181.json b/json/tr181.json index c94b2d65..26b4f960 100644 --- a/json/tr181.json +++ b/json/tr181.json @@ -589,7 +589,13 @@ "usp" ], "datatype": "unsignedInt", - "unit": "seconds" + "unit": "seconds", + "mapping": [ + { + "type": "procfs", + "file": "/proc/uptime" + } + ] }, "FirstUseDate": { "type": "dateTime", @@ -707,6 +713,26 @@ } ] }, + "X_IOPSYS_EU_BaseMACAddress": { + "type": "string", + "read": true, + "write": false, + "protocols": [ + "usp" + ], + "datatype": "string", + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "router.system", + "method": "info", + "args": {}, + "key": "basemac" + } + } + ] + }, "Device.DeviceInfo.VendorConfigFile.{i}.": { "type": "object", "protocols": [ @@ -1040,7 +1066,18 @@ "cwmp", "usp" ], - "datatype": "unsignedInt" + "datatype": "unsignedInt", + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "router.system", + "method": "processes", + "args": {}, + "key": "processes" + } + } + ] }, "Device.DeviceInfo.ProcessStatus.Process.{i}.": { "type": "object", @@ -1050,6 +1087,15 @@ ], "access": false, "array": true, + "mapping": { + "type": "ubus", + "ubus": { + "object": "router.system", + "method": "processes", + "args": {}, + "key": "processes" + } + }, "PID": { "type": "unsignedInt", "read": true, @@ -1058,7 +1104,18 @@ "cwmp", "usp" ], - "datatype": "unsignedInt" + "datatype": "unsignedInt", + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "router.system", + "method": "processes", + "args": {}, + "key": "processes[@i-1].pid" + } + } + ] }, "Command": { "type": "string", @@ -1073,6 +1130,17 @@ { "max": 256 } + ], + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "router.system", + "method": "processes", + "args": {}, + "key": "processes[@i-1].command" + } + } ] }, "Size": { @@ -1084,7 +1152,18 @@ "usp" ], "datatype": "unsignedInt", - "unit": "kilobytes" + "unit": "kilobytes", + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "router.system", + "method": "processes", + "args": {}, + "key": "processes[@i-1].vsz" + } + } + ] }, "Priority": { "type": "unsignedInt", @@ -1099,6 +1178,17 @@ { "max": 99 } + ], + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "router.system", + "method": "processes", + "args": {}, + "key": "processes[@i-1].priority" + } + } ] }, "CPUTime": { @@ -1110,7 +1200,18 @@ "usp" ], "datatype": "unsignedInt", - "unit": "milliseconds" + "unit": "milliseconds", + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "router.system", + "method": "processes", + "args": {}, + "key": "processes[@i-1].cputime" + } + } + ] }, "State": { "type": "string", @@ -1128,6 +1229,17 @@ "Idle", "Uninterruptible", "Zombie" + ], + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "router.system", + "method": "processes", + "args": {}, + "key": "processes[@i-1].state" + } + } ] } } @@ -6287,6 +6399,58 @@ { "max": 256 } + ], + "mapping": [ + { + "type": "uci", + "uci": { + "file": "system", + "section": { + "type": "system", + "name": "@system[0]" + }, + "option": { + "name": "timezone" + } + } + } + ] + }, + "X_IOPSYS_EU_LocalTimeZoneName": { + "type": "string", + "read": true, + "write": false, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "system", + "section": { + "type": "system", + "name": "@system[0]" + }, + "option": { + "name": "zonename" + } + } + } + ] + }, + "X_IOPSYS_EU_SourceInterface": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ ] } }, @@ -16098,6 +16262,19 @@ "name": "vpi" } } + }, + { + "type": "uci", + "uci": { + "file": "dsl", + "section": { + "type": "atm-device", + "index": "@i-1" + }, + "option": { + "name": "vci" + } + } } ] }, @@ -17243,6 +17420,12 @@ "NotPresent", "LowerLayerDown", "Error" + ], + "mapping": [ + { + "type": "sysfs", + "file": "/sys/class/net/@Name/operstate" + } ] }, "Alias": { @@ -17335,7 +17518,22 @@ "cwmp", "usp" ], - "datatype": "boolean" + "datatype": "boolean", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "ports", + "section": { + "type": "ethport", + "index": "@i-1" + }, + "option": { + "name": "uplink" + } + } + } + ] }, "MACAddress": { "type": "string", @@ -17356,15 +17554,8 @@ ], "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "macaddr" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/address" } ] }, @@ -17503,15 +17694,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_bytes" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_bytes" } ] }, @@ -17526,15 +17710,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_bytes" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_bytes" } ] }, @@ -17549,15 +17726,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_packets" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_packets" } ] }, @@ -17572,15 +17742,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_packets" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_packets" } ] }, @@ -17595,15 +17758,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_errors" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_errors" } ] }, @@ -17618,15 +17774,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_errors" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_errors" } ] }, @@ -17661,15 +17810,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_dropped" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_dropped" } ] }, @@ -17684,15 +17826,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_dropped" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_dropped" } ] }, @@ -18216,15 +18351,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_bytes" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_bytes" } ] }, @@ -18239,15 +18367,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_bytes" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_bytes" } ] }, @@ -18262,15 +18383,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_packets" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_packets" } ] }, @@ -18285,15 +18399,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_packets" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_packets" } ] }, @@ -18308,15 +18415,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_errors" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_errors" } ] }, @@ -18331,15 +18431,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_errors" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_errors" } ] }, @@ -18374,15 +18467,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_dropped" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_dropped" } ] }, @@ -18397,15 +18483,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_dropped" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_dropped" } ] }, @@ -18427,7 +18506,13 @@ "cwmp", "usp" ], - "datatype": "unsignedLong" + "datatype": "unsignedLong", + "mapping": [ + { + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/multicast" + } + ] }, "BroadcastPacketsSent": { "type": "unsignedLong", @@ -29632,6 +29717,56 @@ "datatype": "string" } }, + "X_IOPSYS_EU_MaxAllowedAssociations": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wireless", + "section": { + "type": "wifi-device", + "index": "@i-1" + }, + "option": { + "name": "maxassoc" + } + } + } + ] + }, + "X_IOPSYS_EU_DFSEnable": { + "type": "boolean", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "boolean", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wireless", + "section": { + "type": "wifi-device", + "index": "@i-1" + }, + "option": { + "name": "dfsc" + } + } + } + ] + }, "Device.WiFi.Radio.{i}.Stats.": { "type": "object", "protocols": [ @@ -30931,7 +31066,22 @@ "cwmp", "usp" ], - "datatype": "boolean" + "datatype": "boolean", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wireless", + "section": { + "type": "wifi-iface", + "index": "@i-1" + }, + "option": { + "name": "disabled" + } + } + } + ] }, "Status": { "type": "string", @@ -31189,7 +31339,22 @@ "pattern": [ "([0-9A-Fa-f][0-9A-Fa-f]:){5}([0-9A-Fa-f][0-9A-Fa-f])" ] - } + }, + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wireless", + "section": { + "type": "wifi-iface", + "index": "@i-1" + }, + "option": { + "name": "maclist" + } + } + } + ] }, "MaxAllowedAssociations": { "type": "unsignedInt", @@ -31258,7 +31423,35 @@ "cwmp", "usp" ], - "datatype": "string" + "datatype": "string", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wireless", + "section": { + "type": "wifi-iface", + "index": "@i-1" + }, + "option": { + "name": "encryption" + } + } + }, + { + "type": "uci", + "uci": { + "file": "wireless", + "section": { + "type": "wifi-iface", + "index": "@i-1" + }, + "option": { + "name": "cipher" + } + } + } + ] }, "WEPKey": { "type": "hexBinary", @@ -31486,6 +31679,31 @@ ], "datatype": "boolean" }, + "X_IOPSYS_EU_WEPKeyIndex": { + "type": "unsignedInt", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "unsignedInt", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wireless", + "section": { + "type": "wifi-iface", + "index": "@i-1" + }, + "option": { + "name": "key_index" + } + } + } + ] + }, "Reset()": { "type": "command", "protocols": [ @@ -32445,6 +32663,40 @@ ], "unit": "seconds" } + }, + "Device.WiFi.AccessPoint.{i}.X_IOPSYS_EU_IEEE80211r.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "access": false, + "array": false, + "Enable": { + "type": "boolean", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "boolean", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "wireless", + "section": { + "type": "wifi-iface", + "index": "@i-1" + }, + "option": { + "name": "disabled" + } + } + } + ] + } } }, "Device.WiFi.EndPoint.{i}.": { @@ -35871,6 +36123,18 @@ "max": 4094 } ] + }, + "X_IOPSYS_EU_VLANPriority": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + ] } }, "Device.Bridging.Bridge.{i}.VLANPort.{i}.": { @@ -37360,15 +37624,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_bytes" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_bytes" } ] }, @@ -37383,15 +37640,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_bytes" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_bytes" } ] }, @@ -37406,15 +37656,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_packets" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_packets" } ] }, @@ -37429,15 +37672,8 @@ "datatype": "unsignedLong", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_packets" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_packets" } ] }, @@ -37452,15 +37688,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_errors" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_errors" } ] }, @@ -37475,15 +37704,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_errors" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_errors" } ] }, @@ -37518,15 +37740,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.tx_dropped" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/tx_dropped" } ] }, @@ -37541,15 +37756,8 @@ "datatype": "unsignedInt", "mapping": [ { - "type": "ubus", - "ubus": { - "object": "network.device", - "method": "status", - "args": { - "name": "@Name" - }, - "key": "statistics.rx_dropped" - } + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/rx_dropped" } ] }, @@ -37571,7 +37779,13 @@ "cwmp", "usp" ], - "datatype": "unsignedLong" + "datatype": "unsignedLong", + "mapping": [ + { + "type": "sysfs", + "file": "/sys/class/net/@Name/statistics/multicast" + } + ] }, "BroadcastPacketsSent": { "type": "unsignedLong", @@ -38200,7 +38414,19 @@ } } ] - } + }, + "X_IOPSYS_EU_FirewallEnabled": { + "type": "boolean", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "boolean", + "mapping": [ + ] + }, }, "Device.IP.Interface.{i}.Stats.": { "type": "object", @@ -58705,6 +58931,18 @@ ], "datatype": "boolean" }, + "X_IOPSYS_EU_Status": { + "type": "string", + "read": true, + "write": false, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + ] + }, "Device.UPnP.Device.Capabilities.": { "type": "object", "protocols": [ @@ -61064,7 +61302,152 @@ "usp" ], "datatype": "boolean" + }, + "X_IOPSYS_EU_ICMPType": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "firewall", + "section": { + "type": "rule", + "index": "@i-1" + }, + "option": { + "name": "icmp_type" } + } + } + ] + }, + "X_IOPSYS_EU_SourceMACAddress": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "firewall", + "section": { + "type": "rule", + "index": "@i-1" + }, + "option": { + "name": "src_mac" + } + } + } + ] + }, + "Device.Firewall.Chain.{i}.Rule.{i}.X_IOPSYS_EU_TimeSpan.": { + "type": "object", + "protocols": [ + "cwmp", + "usp" + ], + "access": false, + "array": false, + "SupportedDays": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string" + }, + "Days": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "firewall", + "section": { + "type": "rule", + "index": "@i-1" + }, + "option": { + "name": "weekdays" + } + } + } + ] + }, + "StartTime": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "firewall", + "section": { + "type": "rule", + "index": "@i-1" + }, + "option": { + "name": "start_time" + } + } + } + ] + }, + "StopTime": { + "type": "string", + "read": true, + "write": true, + "protocols": [ + "cwmp", + "usp" + ], + "datatype": "string", + "mapping": [ + { + "type": "uci", + "uci": { + "file": "firewall", + "section": { + "type": "rule", + "index": "@i-1" + }, + "option": { + "name": "stop_time" + } + } + } + ] + } + } + } } }, diff --git a/tools/generate_json.py b/tools/generate_json.py index d2a1fdd4..99c079a5 100755 --- a/tools/generate_json.py +++ b/tools/generate_json.py @@ -246,8 +246,8 @@ def getparammapping(dmobject, dmparam): for value in listmapping: if param in value: hasmapping = 1 - comment = value.split("!") - mapping = comment[1] + config_type = value.split("!") + mapping = config_type[1] mapping = mapping.replace("*/\n", "") break @@ -261,12 +261,12 @@ def getobjmapping(dmobject): else: obj = dmobject.get('name') for value in listmapping: - comment = value.split("!") - mapping = comment[0] + config_type = value.split("!") + mapping = config_type[0] mapping = mapping.replace("/*#", "") if obj == mapping: hasmapping = 1 - mapping = comment[1] + mapping = config_type[1] mapping = mapping.replace("*/\n", "") break @@ -312,46 +312,56 @@ def printclosefile (): def printOBJMaPPING (mapping): fp = open('./.json_tmp', 'a') - comment = mapping.split(":") - config = comment[1].split("/") - if comment[0] == "UCI": - type = "uci" - elif comment[0] == "UBUS": - type = "ubus" - else: - type = "cli" + config_type = mapping.split(":") + config = config_type[1].split("/") print >> fp, "\"mapping\": {" - print >> fp, "\"type\": \"%s\"," % type - print >> fp, "\"%s\": {" % type - if comment[0] == "UCI": + print >> fp, "\"type\": \"%s\"," % config_type[0].lower() + print >> fp, "\"%s\": {" % config_type[0].lower() + + # UCI + if config_type[0] == "UCI": print >> fp, "\"file\": \"%s\"," % config[0] print >> fp, "\"section\": {" print >> fp, "\"type\": \"%s\"" % config[1] print >> fp, "}," print >> fp, "\"dmmapfile\": \"%s\"" % config[2] + + # UBUS + elif config_type[0] == "UBUS": + print >> fp, "\"object\": \"%s\"," % config[0] + print >> fp, "\"method\": \"%s\"," % config[1] + print >> fp, "\"args\": {" + if config[2] != "": + args = config[2].split(",") + print >> fp, "\"%s\": \"%s\"" % (args[0], args[1]) print >> fp, "}" - print >> fp, "}" + print >> fp, "\"key\": \"%s\"" % config[3] + + print >> fp, "}\n}" fp.close() def printPARAMMaPPING (mapping): fp = open('./.json_tmp', 'a') lst = mapping.split("&") - count = len(lst) print >> fp, "\"mapping\": [" - for i in range(count): - comment = lst[i].split(":") - config = comment[1].split("/") - if comment[0] == "UCI": - type = "uci" - elif comment[0] == "UBUS": - type = "ubus" - else: - type = "cli" - print >> fp, "{" - print >> fp, "\"type\": \"%s\"," % type - print >> fp, "\"%s\": {" % type + for i in range(len(lst)): + config_type = lst[i].split(":") + config = config_type[1].split("/") - if comment[0] == "UCI": + print >> fp, "{" + print >> fp, "\"type\": \"%s\"," % config_type[0].lower() + + # SYSFS || PROCFS + if config_type[0] == "SYSFS" or config_type[0] == "PROCFS": + print >> fp, "\"file\": \"%s\"" % config_type[1] + + # UCI, UBUS, CLI + else: + # Only for UCI, UBUS, CLI + print >> fp, "\"%s\": {" % config_type[0].lower() + + # UCI + if config_type[0] == "UCI": print >> fp, "\"file\": \"%s\"," % config[0] print >> fp, "\"section\": {" var = config[1].split(",") @@ -368,7 +378,9 @@ def printPARAMMaPPING (mapping): print >> fp, "\"option\": {" print >> fp, "\"name\": \"%s\"" % config[2] print >> fp, "}" - elif comment[0] == "UBUS": + + # UBUS + elif config_type[0] == "UBUS": print >> fp, "\"object\": \"%s\"," % config[0] print >> fp, "\"method\": \"%s\"," % config[1] print >> fp, "\"args\": {" @@ -377,14 +389,16 @@ def printPARAMMaPPING (mapping): print >> fp, "\"%s\": \"%s\"" % (args[0], args[1]) print >> fp, "}" print >> fp, "\"key\": \"%s\"" % config[3] - else: + + # CLI + elif config_type[0] == "CLI": print >> fp, "\"command\": \"%s\"," % config[0] print >> fp, "\"args\": \"%s\"" % config[1] print >> fp, "}" + print >> fp, "}" - print >> fp, "]" - print >> fp, "}" + print >> fp, "]\n}" fp.close() def removelastline ():