From 4aeb252016a0d3031b8af74848932a249c225ef3 Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Wed, 13 Apr 2022 14:28:27 +0100 Subject: [PATCH] IEEE1905: Add support for Device.IEEE1905.AL.Interface.{i}.LowerLayers parameter --- dmtree/json/tr181.json | 13 ++++++++++++- dmtree/tr181/ieee1905.c | 13 +++++++++++++ dmtree/tr181/wifi.c | 8 +++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/dmtree/json/tr181.json b/dmtree/json/tr181.json index 2b692378..0d41c394 100644 --- a/dmtree/json/tr181.json +++ b/dmtree/json/tr181.json @@ -88497,7 +88497,18 @@ "list": { "datatype": "string", "maxsize": 1024 - } + }, + "mapping": [ + { + "type": "ubus", + "ubus": { + "object": "ieee1905", + "method": "info", + "args": {}, + "key": "interface[@i-1].ifname" + } + } + ] }, "InterfaceStackReference": { "type": "string", diff --git a/dmtree/tr181/ieee1905.c b/dmtree/tr181/ieee1905.c index b6b8f0dd..e8b210da 100644 --- a/dmtree/tr181/ieee1905.c +++ b/dmtree/tr181/ieee1905.c @@ -439,6 +439,18 @@ static int get_IEEE1905ALInterface_Status(char *refparam, struct dmctx *ctx, voi return 0; } +/*#Device.IEEE1905.AL.Interface.{i}.LowerLayers!UBUS:ieee1905/info//interface[@i-1].ifname*/ +static int get_IEEE1905ALInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) +{ + char *linker = dmjson_get_value((json_object *)data, 1, "ifname"); + adm_entry_get_linker_param(ctx, "Device.Ethernet.Interface.", linker, value); + if (!(*value) || (*value)[0] == 0) + adm_entry_get_linker_param(ctx, "Device.WiFi.Radio.", linker, value); + if (!(*value) || (*value)[0] == 0) + adm_entry_get_linker_param(ctx, "Device.WiFi.AccessPoint.", linker, value); + return 0; +} + #if 0 static int get_IEEE1905ALInterface_InterfaceStackReference(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { @@ -1613,6 +1625,7 @@ DMLEAF tIEEE1905ALInterfaceParams[] = { /* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/ {"InterfaceId", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_InterfaceId, NULL, BBFDM_BOTH, "2.9"}, {"Status", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_Status, NULL, BBFDM_BOTH, "2.9"}, +{"LowerLayers", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_LowerLayers, NULL, BBFDM_BOTH, "2.9"}, //{"InterfaceStackReference", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_InterfaceStackReference, NULL, BBFDM_BOTH, "2.9"}, {"MediaType", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_MediaType, NULL, BBFDM_BOTH, "2.9"}, //{"GenericPhyOUI", &DMREAD, DMT_STRING, get_IEEE1905ALInterface_GenericPhyOUI, NULL, BBFDM_BOTH, "2.9"}, diff --git a/dmtree/tr181/wifi.c b/dmtree/tr181/wifi.c index fa16142e..e378282f 100644 --- a/dmtree/tr181/wifi.c +++ b/dmtree/tr181/wifi.c @@ -62,6 +62,12 @@ static int get_linker_Wifi_Ssid(char *refparam, struct dmctx *dmctx, void *data, return 0; } +static int get_linker_Wifi_AccessPoint(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) +{ + *linker = (data && ((struct wifi_acp_args *)data)->ifname) ? ((struct wifi_acp_args *)data)->ifname : ""; + return 0; +} + static int get_linker_associated_device(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) { *linker = data ? dmjson_get_value((json_object *)data, 1, "macaddr") : ""; @@ -6225,7 +6231,7 @@ DMOBJ tWiFiObj[] = { {"DataElements", &DMREAD, NULL, NULL, "file:/etc/init.d/decollector", NULL, NULL, NULL, tWiFiDataElementsObj, NULL, NULL, BBFDM_BOTH, NULL, "2.13"}, {"Radio", &DMREAD, NULL, NULL, NULL, browseWifiRadioInst, NULL, NULL, tWiFiRadioObj, tWiFiRadioParams, get_linker_Wifi_Radio, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}, "2.0"}, {"SSID", &DMWRITE, add_wifi_ssid, delete_wifi_ssid, NULL, browseWifiSsidInst, NULL, NULL, tWiFiSSIDObj, tWiFiSSIDParams, get_linker_Wifi_Ssid, BBFDM_BOTH, LIST_KEY{"Name", "Alias", "BSSID", NULL}, "2.0"}, -{"AccessPoint", &DMWRITE, add_wifi_accesspoint, delete_wifi_accesspoint, NULL, browseWifiAccessPointInst, NULL, NULL, tWiFiAccessPointObj, tWiFiAccessPointParams, NULL, BBFDM_BOTH, LIST_KEY{"SSIDReference", "Alias", NULL}, "2.0"}, +{"AccessPoint", &DMWRITE, add_wifi_accesspoint, delete_wifi_accesspoint, NULL, browseWifiAccessPointInst, NULL, NULL, tWiFiAccessPointObj, tWiFiAccessPointParams, get_linker_Wifi_AccessPoint, BBFDM_BOTH, LIST_KEY{"SSIDReference", "Alias", NULL}, "2.0"}, {"NeighboringWiFiDiagnostic", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tWiFiNeighboringWiFiDiagnosticObj, tWiFiNeighboringWiFiDiagnosticParams, NULL, BBFDM_BOTH, NULL, "2.7"}, {"EndPoint", &DMWRITE, addObjWiFiEndPoint, delObjWiFiEndPoint, NULL, browseWiFiEndPointInst, NULL, NULL, tWiFiEndPointObj, tWiFiEndPointParams, NULL, BBFDM_BOTH, LIST_KEY{"SSIDReference", "Alias", NULL}, "2.0"}, {0}