Ticket refs#596: WiFi Life cannot be controlled via TR-069

This commit is contained in:
Amin Ben Ramdhane 2019-04-25 13:49:09 +01:00
parent 7faa875dcb
commit cd777bbd2d
8 changed files with 234 additions and 1 deletions

View file

@ -28,6 +28,7 @@ libdatamodel_la_SOURCES = \
../dm/dmtree/common/x_iopsys_eu_dropbear.c \
../dm/dmtree/common/x_iopsys_eu_owsd.c \
../dm/dmtree/common/x_iopsys_eu_buttons.c \
../dm/dmtree/common/x_iopsys_eu_wifilife.c \
../dm/dmtree/common/root.c
if XMPP_ENABLE

View file

@ -28,6 +28,7 @@
#include "x_iopsys_eu_owsd.h"
#include "x_iopsys_eu_dropbear.h"
#include "x_iopsys_eu_buttons.h"
#include "x_iopsys_eu_wifilife.h"
#ifdef UPNP_TR064
#include "upnp_deviceinfo.h"
#include "upnp_configuration.h"
@ -86,6 +87,7 @@ DMOBJ tRoot_098_Obj[] = {
{CUSTOM_PREFIX"Owsd", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,XIopsysEuOwsdObj, XIopsysEuOwsdParams, NULL},
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, &DMNONE, NULL, X_IOPSYS_EU_DropbearParams, NULL},
{CUSTOM_PREFIX"Buttons", &DMREAD, NULL, NULL, NULL, browseXIopsysEuButton, NULL, &DMNONE, NULL, X_IOPSYS_EU_ButtonParams, NULL},
{CUSTOM_PREFIX"WiFiLife", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE, X_IOPSYS_EU_WiFiLifeObj, X_IOPSYS_EU_WiFiLifeParams, NULL},
{"LANDevice", &DMWRITE, add_landevice, delete_landevice, NULL, browselandeviceInst, &DMFINFRM, &DMNONE,tLANDeviceObj, tLANDeviceParam, NULL},
{"WANDevice", &DMREAD, NULL, NULL, NULL, browsewandeviceInst, &DMFINFRM, &DMWANConnectionDevicenotif,tWANDeviceObj, tWANDeviceParam, NULL},
{"LANInterfaces", &DMREAD, NULL, NULL, check_laninterfaces, NULL, &DMFINFRM, &DMNONE,tLANInterfacesObj, tLANInterfacesParam, NULL},
@ -119,6 +121,7 @@ DMOBJ tRoot_181_Obj[] = {
{CUSTOM_PREFIX"Owsd", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,XIopsysEuOwsdObj, XIopsysEuOwsdParams, NULL},
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, &DMNONE, NULL, X_IOPSYS_EU_DropbearParams, NULL},
{CUSTOM_PREFIX"Buttons", &DMREAD, NULL, NULL, NULL, browseXIopsysEuButton, NULL, &DMNONE, NULL, X_IOPSYS_EU_ButtonParams, NULL},
{CUSTOM_PREFIX"WiFiLife", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE, X_IOPSYS_EU_WiFiLifeObj, X_IOPSYS_EU_WiFiLifeParams, NULL},
{"Bridging",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tBridgingObj, NULL, NULL},
{"WiFi",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tWifiObj, tWifiParams, NULL},
{"IP",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPObj, NULL, NULL},

View file

@ -0,0 +1,130 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#include <uci.h>
#include <ctype.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "x_iopsys_eu_wifilife.h"
/*** DMROOT.X_IOPSYS_EU_WiFiLife. ****/
DMOBJ X_IOPSYS_EU_WiFiLifeObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, nextobj, leaf*/
{"Steering", &DMREAD, NULL, NULL, NULL, browseWifiLifeSteeringObj, NULL, NULL, NULL, WiFiLifeSteeringParams, NULL},
{0}
};
DMLEAF X_IOPSYS_EU_WiFiLifeParams[] = {
{"Enable", &DMWRITE, DMT_BOOL, get_x_iopsys_eu_wifilife_enable, set_x_iopsys_eu_wifilife_enable, NULL, NULL},
{0}
};
DMLEAF WiFiLifeSteeringParams[] = {
{"Enable", &DMWRITE, DMT_BOOL, get_wifilife_steering_enable, set_wifilife_steering_enable, NULL, NULL},
{"LegacyFallback", &DMWRITE, DMT_BOOL, get_wifilife_steering_legacy_fallback, set_wifilife_steering_legacy_fallback, NULL, NULL},
{0}
};
int browseWifiLifeSteeringObj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *isteer = NULL, *isteer_last = NULL;
struct uci_section *s = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap("wifilife", "steer", "dmmap_wifilife", &dup_list);
list_for_each_entry(p, &dup_list, list) {
isteer = handle_update_instance(1, dmctx, &isteer_last, update_instance_alias, 3, p->dmmap_section, "steer_instance", "steer_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p->config_section, isteer) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
/*************************************************************************************
**** GET / SET function ****
**************************************************************************************/
int get_x_iopsys_eu_wifilife_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("wifilife", "@wifilife[0]", "enabled", value);
if ((*value)[0] == '\0') {
*value = "1";
}
return 0;
}
int set_x_iopsys_eu_wifilife_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value("wifilife", "@wifilife[0]", "enabled", b?"1":"0");
return 0;
}
return 0;
}
int get_wifilife_steering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "enabled", value);
if ((*value)[0] == '\0')
*value = "0";
return 0;
}
int set_wifilife_steering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "enabled", b?"1":"0");
return 0;
}
return 0;
}
int get_wifilife_steering_legacy_fallback(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section *)data, "fallback_legacy", value);
if ((*value)[0] == '\0')
*value = "0";
return 0;
}
int set_wifilife_steering_legacy_fallback(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section((struct uci_section *)data, "fallback_legacy", b?"1":"0");
return 0;
}
return 0;
}

View file

@ -0,0 +1,27 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*/
#ifndef __WIFILIFE_H
#define __WIFILIFE_H
extern DMOBJ X_IOPSYS_EU_WiFiLifeObj[];
extern DMLEAF X_IOPSYS_EU_WiFiLifeParams[];
extern DMLEAF WiFiLifeSteeringParams[];
int browseWifiLifeSteeringObj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_x_iopsys_eu_wifilife_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_iopsys_eu_wifilife_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_wifilife_steering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_wifilife_steering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_wifilife_steering_legacy_fallback(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_wifilife_steering_legacy_fallback(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif // __WIFILIFE_H

View file

@ -164,6 +164,7 @@ DMOBJ tWlanConfigurationObj[] = {
{"WEPKey", &DMREAD, NULL, NULL, NULL, browseWepKeyInst, NULL, NULL, NULL, tWepKeyParam, NULL},
{"PreSharedKey", &DMREAD, NULL, NULL, NULL, browsepresharedkeyInst, NULL, NULL, NULL, tpresharedkeyParam, NULL},
{"AssociatedDevice", &DMREAD, NULL, NULL, NULL, browseassociateddeviceInst, NULL, NULL, NULL, tassociateddeviceParam, NULL},
{CUSTOM_PREFIX"IEEE80211r", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIEEE80211rParams, NULL},
{0}
};
@ -239,6 +240,12 @@ DMLEAF tassociateddeviceParam[] = {
{0}
};
/*** LANDevice.{i}.WLANConfiguration.{i}.X_IOPSYS_EU_IEEE80211r. ***/
DMLEAF tIEEE80211rParams[] = {
{"Enable", &DMWRITE, DMT_BOOL, get_ieee80211r_enable, set_ieee80211r_enable, NULL, NULL},
{0}
};
inline int init_ldargs_lan(struct ldlanargs *args, struct uci_section *s, char *iwan)
{
args->ldlansection = s;
@ -3011,6 +3018,33 @@ int set_wlan_wps_enable(char *refparam, struct dmctx *ctx, void *data, char *ins
return 0;
}
int get_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct ldwlanargs *wlanargs = (struct ldwlanargs *)data;
dmuci_get_value_by_section_string(wlanargs->lwlansection, "ieee80211r", value);
if ((*value)[0] == '\0')
*value = "0";
return 0;
}
int set_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct ldwlanargs *wlanargs = (struct ldwlanargs *)data;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section(wlanargs->lwlansection, "ieee80211r", b?"1":"0");
return 0;
}
return 0;
}
int get_x_iopsys_eu_channelmode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct ldwlanargs *wlanargs = (struct ldwlanargs *)data;

View file

@ -21,6 +21,7 @@ extern DMLEAF tIPInterfaceParam[];
extern DMLEAF tlanethernetinterfaceconfigParam[];
extern DMOBJ tLanhost_Config_ManagementObj[];
extern DMLEAF tWlanConfigurationParam[];
extern DMLEAF tIEEE80211rParams[];
extern DMLEAF tWPSParam[];
extern DMLEAF tWepKeyParam[];
extern DMLEAF tpresharedkeyParam[];
@ -205,6 +206,7 @@ int get_x_iopsys_eu_maxssid(char *refparam, struct dmctx *ctx, void *data, char
int get_x_iopsys_eu_scantimer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_iopsys_eu_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_wps_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_wep_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_psk_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_psk_assoc_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
@ -271,6 +273,7 @@ int set_x_iopsys_eu_maxssid(char *refparam, struct dmctx *ctx, void *data, char
int set_x_iopsys_eu_scantimer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_iopsys_eu_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_wps_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_wep_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_wep_key1(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_psk_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);

View file

@ -109,11 +109,11 @@ DMLEAF tWifiSsidStatsParams[] = {
};
/*** WiFi.AccessPoint. ***/
DMOBJ tAcessPointSecurityObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"Security", &DMWRITE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tWifiAcessPointSecurityParams, NULL},
{"AssociatedDevice", &DMREAD, NULL, NULL, NULL, browse_wifi_associated_device, NULL, NULL, tWifiAcessPointAssociatedDeviceObj, tWifiAcessPointAssociatedDeviceParams, get_linker_associated_device},
{CUSTOM_PREFIX"IEEE80211r", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tWifiAcessPointIEEE80211rParams, NULL},
{0}
};
@ -158,6 +158,13 @@ DMLEAF tWifiAcessPointAssociatedDeviceParams[] = {
{0}
};
/*** WiFi.AccessPoint.X_IOPSYS_EU_IEEE80211r. ***/
DMLEAF tWifiAcessPointIEEE80211rParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"Enable", &DMWRITE, DMT_BOOL, get_access_point_ieee80211r_enable, set_access_point_ieee80211r_enable, NULL, NULL},
{0}
};
/*** WiFi.AccessPoint.AssociatedDevice.Stats. ***/
DMOBJ tWifiAcessPointAssociatedDeviceObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, nextobj, leaf*/
@ -1340,6 +1347,7 @@ int get_access_point_associative_device_mac(char *refparam, struct dmctx *ctx, v
dmasprintf(value, cur_wifi_associative_device_args_ptr->macaddress);
return 0;
}
int get_access_point_associative_device_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr=(struct wifi_associative_device_args*)data;
@ -1347,6 +1355,30 @@ int get_access_point_associative_device_active(char *refparam, struct dmctx *ctx
return 0;
}
int get_access_point_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "ieee80211r", value);
if ((*value)[0] == '\0')
*value = "0";
return 0;
}
int set_access_point_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
string_to_bool(value, &b);
dmuci_set_value_by_section(((struct wifi_acp_args *)data)->wifi_acp_sec, "ieee80211r", b?"1":"0");
return 0;
}
return 0;
}
int get_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *ss;

View file

@ -58,6 +58,7 @@ extern DMLEAF tWifiSsidParams[];
extern DMLEAF tWifiRadioParams[];
extern DMLEAF tWifiAcessPointSecurityParams[];
extern DMLEAF tWifiAcessPointAssociatedDeviceParams[];
extern DMLEAF tWifiAcessPointIEEE80211rParams[];
extern DMOBJ tWifiAcessPointAssociatedDeviceObj[];
extern DMLEAF tWifiAcessPointAssociatedDeviceStatsParams[];
extern DMLEAF tWifiRadioStatsParams[];
@ -124,6 +125,7 @@ int get_access_point_security_wepkey_index(char *refparam, struct dmctx *ctx, vo
int get_access_point_security_rekey_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_radius_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_radius_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_lastdatadownlinkrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_lastdatauplinkrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_associative_device_signalstrength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
@ -176,6 +178,7 @@ int set_access_point_security_rekey_interval(char *refparam, struct dmctx *ctx,
int set_access_point_security_radius_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_radius_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_radius_secret(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_ieee80211r_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_neighboring_wifi_diagnostics_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
static int set_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif