mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-14 21:20:28 +01:00
Ticket refs #4283: Map Device.WiFi.AccessPoint/EndPoint.{i}.Security.ModesSupported to ubus objects
This commit is contained in:
parent
dca35827c7
commit
bc71c91903
3 changed files with 76 additions and 5 deletions
|
|
@ -124,8 +124,9 @@ int os__browse_wifi_associated_device(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
char * os__get_radio_frequency_nocache(const struct wifi_radio_args *args);
|
||||
char * os__get_radio_channel_nocache(const struct wifi_radio_args *args);
|
||||
void os__wifi_start_scan(const char *radio);
|
||||
int os_get_wifi_access_point_status (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int os_get_wifi_access_point_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int os_get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int os_get_supported_modes(const char *ubus_method, const char *ifname, char **value);
|
||||
char * os__get_default_wpa_key();
|
||||
int os__get_WiFiDataElementsNetwork_ID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int os__set_WiFiDataElementsNetwork_ID(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ int os__get_access_point_associative_device_statistics_retrans_count(char *refpa
|
|||
|
||||
|
||||
/*#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)
|
||||
int os_get_wifi_access_point_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
char object[32], *status = NULL, *iface;
|
||||
|
|
@ -664,6 +664,63 @@ int os_get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *dat
|
|||
return get_radio_standards(((struct wifi_radio_args *)data)->wifi_radio_sec, value);
|
||||
}
|
||||
|
||||
static char *get_data_model_mode(const char *ubus_mode)
|
||||
{
|
||||
if (strcmp(ubus_mode, "WEP64") == 0)
|
||||
return "WEP-64";
|
||||
else if (strcmp(ubus_mode, "WEP128") == 0)
|
||||
return "WEP-128";
|
||||
else if (strcmp(ubus_mode, "WPAPSK") == 0)
|
||||
return "WPA-Personal";
|
||||
else if (strcmp(ubus_mode, "WPA2PSK") == 0)
|
||||
return "WPA2-Personal";
|
||||
else if (strcmp(ubus_mode, "WPA3PSK") == 0)
|
||||
return "WPA3-Personal";
|
||||
else if (strcmp(ubus_mode, "WPAPSK+WPA2PSK") == 0)
|
||||
return "WPA-WPA2-Personal";
|
||||
else if (strcmp(ubus_mode, "WPA2PSK+WPA3PSK") == 0)
|
||||
return "WPA3-Personal-Transition";
|
||||
else if (strcmp(ubus_mode, "WPA") == 0)
|
||||
return "WPA-Enterprise";
|
||||
else if (strcmp(ubus_mode, "WPA2") == 0)
|
||||
return "WPA2-Enterprise";
|
||||
else if (strcmp(ubus_mode, "WPA3") == 0)
|
||||
return "WPA3-Enterprise";
|
||||
else if (strcmp(ubus_mode, "WPA+WPA2") == 0)
|
||||
return "WPA-WPA2-Enterprise";
|
||||
else
|
||||
return "None";
|
||||
}
|
||||
|
||||
int os_get_supported_modes(const char *ubus_method, const char *ifname, char **value)
|
||||
{
|
||||
char *dm_default_modes_supported = "None,WEP-64,WEP-128,WPA-Personal,WPA2-Personal,WPA3-Personal,WPA-WPA2-Personal,WPA3-Personal-Transition,WPA-Enterprise,WPA2-Enterprise,WPA3-Enterprise,WPA-WPA2-Enterprise";
|
||||
char *dm_wifi_driver_modes_supported = "NONE,WEP64,WEP128,WPAPSK,WPA2PSK,WPA3PSK,WPAPSK+WPA2PSK,WPA2PSK+WPA3PSK,WPA,WPA2,WPA3,WPA+WPA2";
|
||||
json_object *res = NULL, *supported_modes = NULL;
|
||||
char list_modes[256], object[32], *mode = NULL;
|
||||
unsigned pos = 0, idx = 0;
|
||||
|
||||
snprintf(object, sizeof(object), "%s.%s", ubus_method, ifname);
|
||||
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, *value = dm_default_modes_supported);
|
||||
|
||||
list_modes[0] = 0;
|
||||
dmjson_foreach_value_in_array(res, supported_modes, mode, idx, 1, "supp_security") {
|
||||
if (!strstr(dm_wifi_driver_modes_supported, mode))
|
||||
continue;
|
||||
|
||||
pos += snprintf(&list_modes[pos], sizeof(list_modes) - pos, "%s,", get_data_model_mode(mode));
|
||||
}
|
||||
|
||||
/* cut tailing ',' */
|
||||
if (pos)
|
||||
list_modes[pos - 1] = 0;
|
||||
|
||||
*value = (*list_modes != '\0') ? dmstrdup(list_modes) : dm_default_modes_supported;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int os__get_access_point_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res = NULL, *assoclist = NULL, *arrobj = NULL;
|
||||
|
|
|
|||
|
|
@ -808,8 +808,7 @@ static int set_WiFiAccessPoint_UAPSDEnable(char *refparam, struct dmctx *ctx, vo
|
|||
|
||||
static int get_access_point_security_supported_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "None,WEP-64,WEP-128,WPA-Personal,WPA2-Personal,WPA3-Personal,WPA-WPA2-Personal,WPA3-Personal-Transition,WPA-Enterprise,WPA2-Enterprise,WPA3-Enterprise,WPA-WPA2-Enterprise";
|
||||
return 0;
|
||||
return os_get_supported_modes("wifi.ap", ((struct wifi_acp_args *)data)->ifname, value);
|
||||
}
|
||||
|
||||
static char *get_security_mode(struct uci_section *section)
|
||||
|
|
@ -1466,6 +1465,11 @@ static int get_WiFiEndPoint_SSIDReference(char *refparam, struct dmctx *ctx, voi
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_WiFiEndPointSecurity_ModesSupported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return os_get_supported_modes("wifi.backhaul", ((struct wifi_enp_args *)data)->ifname, value);
|
||||
}
|
||||
|
||||
static int get_WiFiEndPointProfile_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "1";
|
||||
|
|
@ -1555,11 +1559,20 @@ static int get_WiFiEndPointProfileSecurity_ModeEnabled(char *refparam, struct dm
|
|||
|
||||
static int set_WiFiEndPointProfileSecurity_ModeEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *supported_modes = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string(value, -1, -1, NULL, NULL))
|
||||
return FAULT_9007;
|
||||
|
||||
// Get the list of all supported security modes
|
||||
get_WiFiEndPointSecurity_ModesSupported(refparam, ctx, data, instance, &supported_modes);
|
||||
|
||||
// Check if the input value is a valid security mode
|
||||
if (supported_modes && strstr(supported_modes, value) == NULL)
|
||||
return FAULT_9007;
|
||||
|
||||
return 0;
|
||||
case VALUESET:
|
||||
set_security_mode((struct uci_section *)data, value);
|
||||
|
|
@ -2435,7 +2448,7 @@ DMLEAF tWiFiEndPointStatsParams[] = {
|
|||
/* *** Device.WiFi.EndPoint.{i}.Security. *** */
|
||||
DMLEAF tWiFiEndPointSecurityParams[] = {
|
||||
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type*/
|
||||
//{"ModesSupported", &DMREAD, DMT_STRING, get_WiFiEndPointSecurity_ModesSupported, NULL, BBFDM_BOTH},
|
||||
{"ModesSupported", &DMREAD, DMT_STRING, get_WiFiEndPointSecurity_ModesSupported, NULL, BBFDM_BOTH},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue