Skip to content

Commit 60db35c

Browse files
bcarlson-devnarendradandu
authored andcommitted
RDKBWIFI44-45: Translate read-only vap_mode and vap_index to easymesh and allow passwordless station encoding/decoding (rdkcentral#509)
* RDKBWIFI-44: Translate read-only `vap_mode` and `vap_index` to easymesh Reason for change: Allows for greater filtering of VAPs and finer detail when subscribing / publishing to OneWifi paths. Risks: Low Priority: P1 Signed-off-by: Benjamin Carlson <b.carlson@cablelabs.com> * RDKBWIFI-45: Allow passwordless station encoding/decoding Reason for change: Subdoc cannot be updated unless password is set for the station interface Risks: Low Priority: P1 Signed-off-by: Benjamin Carlson <b.carlson@cablelabs.com> --------- Signed-off-by: Benjamin Carlson <b.carlson@cablelabs.com> Co-authored-by: Narendra Varma Dandu <narendandu@gmail.com> Cherrypicked from commit 125c7d1
1 parent ce7f5cf commit 60db35c

2 files changed

Lines changed: 36 additions & 31 deletions

File tree

source/webconfig/wifi_decoder.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ webconfig_error_t decode_open_radius_object(const cJSON *radius, wifi_radius_set
12551255
}
12561256

12571257
webconfig_error_t decode_security_object(const cJSON *security, wifi_vap_security_t *security_info,
1258-
int band)
1258+
int band, wifi_vap_mode_t vap_mode)
12591259
{
12601260
const cJSON *param, *object;
12611261

@@ -1436,15 +1436,18 @@ webconfig_error_t decode_security_object(const cJSON *security, wifi_vap_securit
14361436
return webconfig_error_none;
14371437
}
14381438

1439-
decode_param_string(security, "Passphrase", param);
1439+
decode_param_allow_empty_string(security, "Passphrase", param);
14401440

1441-
if (security_info->mode != wifi_security_mode_none &&
1442-
(strlen(param->valuestring) < MIN_PWD_LEN || strlen(param->valuestring) > MAX_PWD_LEN)) {
1443-
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d invalid password length: %d\n", __func__,
1444-
__LINE__, strlen(param->valuestring));
1445-
return webconfig_error_decode;
1441+
if (vap_mode != wifi_vap_mode_sta) {
1442+
if (security_info->mode != wifi_security_mode_none &&
1443+
(strlen(param->valuestring) < MIN_PWD_LEN || strlen(param->valuestring) > MAX_PWD_LEN)) {
1444+
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d invalid password length: %d\n", __func__,
1445+
__LINE__, strlen(param->valuestring));
1446+
return webconfig_error_decode;
1447+
}
14461448
}
14471449

1450+
14481451
strncpy(security_info->u.key.key, param->valuestring, sizeof(security_info->u.key.key) - 1);
14491452

14501453
decode_param_bool(security, "Wpa3_transition_disable", param);
@@ -1823,7 +1826,7 @@ webconfig_error_t decode_hotspot_open_vap_object(const cJSON *vap, wifi_vap_info
18231826
}
18241827

18251828
decode_param_object(vap, "Security", security);
1826-
if (decode_security_object(security, &vap_info->u.bss_info.security, band) != webconfig_error_none) {
1829+
if (decode_security_object(security, &vap_info->u.bss_info.security, band, vap_info->vap_mode) != webconfig_error_none) {
18271830
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: Security objects validation failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
18281831
return webconfig_error_decode;
18291832
}
@@ -1868,7 +1871,7 @@ webconfig_error_t decode_hotspot_secure_vap_object(const cJSON *vap, wifi_vap_in
18681871
}
18691872

18701873
decode_param_object(vap, "Security", security);
1871-
if (decode_security_object(security, &vap_info->u.bss_info.security, band) != webconfig_error_none) {
1874+
if (decode_security_object(security, &vap_info->u.bss_info.security, band, vap_info->vap_mode) != webconfig_error_none) {
18721875
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: Security objects validation failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
18731876
return webconfig_error_decode;
18741877
}
@@ -1910,7 +1913,7 @@ webconfig_error_t decode_lnf_psk_vap_object(const cJSON *vap, wifi_vap_info_t *v
19101913
}
19111914

19121915
decode_param_object(vap, "Security", security);
1913-
if (decode_security_object(security, &vap_info->u.bss_info.security, band) != webconfig_error_none) {
1916+
if (decode_security_object(security, &vap_info->u.bss_info.security, band, vap_info->vap_mode) != webconfig_error_none) {
19141917
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: Security objects validation failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
19151918
return webconfig_error_decode;
19161919
}
@@ -1955,7 +1958,7 @@ webconfig_error_t decode_lnf_radius_vap_object(const cJSON *vap, wifi_vap_info_t
19551958
}
19561959

19571960
decode_param_object(vap, "Security", security);
1958-
if (decode_security_object(security, &vap_info->u.bss_info.security, band) != webconfig_error_none) {
1961+
if (decode_security_object(security, &vap_info->u.bss_info.security, band, vap_info->vap_mode) != webconfig_error_none) {
19591962
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: Security objects validation failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
19601963
return webconfig_error_decode;
19611964
}
@@ -2001,7 +2004,7 @@ webconfig_error_t decode_iot_vap_object(const cJSON *vap, wifi_vap_info_t *vap_i
20012004
}
20022005

20032006
decode_param_object(vap, "Security", security);
2004-
if (decode_security_object(security, &vap_info->u.bss_info.security, band) != webconfig_error_none) {
2007+
if (decode_security_object(security, &vap_info->u.bss_info.security, band, vap_info->vap_mode) != webconfig_error_none) {
20052008
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: Security objects validation failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
20062009
return webconfig_error_decode;
20072010
}
@@ -2047,7 +2050,7 @@ webconfig_error_t decode_mesh_backhaul_vap_object(const cJSON *vap, wifi_vap_inf
20472050
}
20482051

20492052
decode_param_object(vap, "Security", security);
2050-
if (decode_security_object(security, &vap_info->u.bss_info.security, band) != webconfig_error_none) {
2053+
if (decode_security_object(security, &vap_info->u.bss_info.security, band, vap_info->vap_mode) != webconfig_error_none) {
20512054
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: Security objects validation failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
20522055
return webconfig_error_decode;
20532056
}
@@ -2093,7 +2096,7 @@ webconfig_error_t decode_private_vap_object(const cJSON *vap, wifi_vap_info_t *v
20932096
}
20942097

20952098
decode_param_object(vap, "Security", security);
2096-
if (decode_security_object(security, &vap_info->u.bss_info.security, band) != webconfig_error_none) {
2099+
if (decode_security_object(security, &vap_info->u.bss_info.security, band, vap_info->vap_mode) != webconfig_error_none) {
20972100
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: Security objects validation failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
20982101
return webconfig_error_decode;
20992102
}
@@ -2147,7 +2150,7 @@ webconfig_error_t decode_wifiapi_vap_object(const cJSON *vap, wifi_vap_info_t *v
21472150
}
21482151

21492152
decode_param_object(vap, "Security", security);
2150-
if (decode_security_object(security, &vap_info->u.bss_info.security, band) != webconfig_error_none) {
2153+
if (decode_security_object(security, &vap_info->u.bss_info.security, band, vap_info->vap_mode) != webconfig_error_none) {
21512154
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: Security objects validation failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
21522155
return webconfig_error_decode;
21532156
}
@@ -2254,7 +2257,7 @@ webconfig_error_t decode_mesh_sta_object(const cJSON *vap, wifi_vap_info_t *vap_
22542257
}
22552258

22562259
decode_param_object(vap, "Security", security);
2257-
if (decode_security_object(security, &vap_info->u.sta_info.security, band) != webconfig_error_none) {
2260+
if (decode_security_object(security, &vap_info->u.sta_info.security, band, vap_info->vap_mode) != webconfig_error_none) {
22582261
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: Security objects validation failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
22592262
return webconfig_error_decode;
22602263
}

source/webconfig/wifi_encoder.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ webconfig_error_t encode_radius_object(const wifi_radius_settings_t *radius_info
10981098
}
10991099

11001100
webconfig_error_t encode_security_object(const wifi_vap_security_t *security_info, cJSON *security,
1101-
bool is_6g)
1101+
bool is_6g, wifi_vap_mode_t vap_mode)
11021102
{
11031103
cJSON *obj;
11041104

@@ -1289,12 +1289,14 @@ webconfig_error_t encode_security_object(const wifi_vap_security_t *security_inf
12891289
return webconfig_error_none;
12901290
}
12911291

1292-
if (security_info->mode != wifi_security_mode_none &&
1293-
(strlen(security_info->u.key.key) < MIN_PWD_LEN ||
1294-
strlen(security_info->u.key.key) > MAX_PWD_LEN)) {
1295-
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d invalid password length: %d\n", __func__,
1296-
__LINE__, strlen(security_info->u.key.key));
1297-
return webconfig_error_encode;
1292+
if (vap_mode != wifi_vap_mode_sta) {
1293+
if (security_info->mode != wifi_security_mode_none &&
1294+
(strlen(security_info->u.key.key) < MIN_PWD_LEN ||
1295+
strlen(security_info->u.key.key) > MAX_PWD_LEN)) {
1296+
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d invalid password length: %d\n", __func__,
1297+
__LINE__, strlen(security_info->u.key.key));
1298+
return webconfig_error_encode;
1299+
}
12981300
}
12991301

13001302
cJSON_AddBoolToObject(security, "Wpa3_transition_disable",
@@ -1331,7 +1333,7 @@ webconfig_error_t encode_hotspot_open_vap_object(const wifi_vap_info_t *vap_info
13311333
is_6g = strstr(vap_info->vap_name, "6g") ? true : false;
13321334
obj = cJSON_CreateObject();
13331335
cJSON_AddItemToObject(vap_obj, "Security", obj);
1334-
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g) != webconfig_error_none) {
1336+
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g, vap_info->vap_mode) != webconfig_error_none) {
13351337
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d Security object encode failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
13361338
return webconfig_error_encode;
13371339
}
@@ -1380,7 +1382,7 @@ webconfig_error_t encode_hotspot_secure_vap_object(const wifi_vap_info_t *vap_in
13801382
is_6g = strstr(vap_info->vap_name, "6g") ? true : false;
13811383
obj = cJSON_CreateObject();
13821384
cJSON_AddItemToObject(vap_obj, "Security", obj);
1383-
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g) != webconfig_error_none) {
1385+
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g, vap_info->vap_mode) != webconfig_error_none) {
13841386
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d Security object encode failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
13851387
return webconfig_error_encode;
13861388
}
@@ -1423,7 +1425,7 @@ webconfig_error_t encode_lnf_psk_vap_object(const wifi_vap_info_t *vap_info,
14231425

14241426
obj = cJSON_CreateObject();
14251427
cJSON_AddItemToObject(vap_obj, "Security", obj);
1426-
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g) != webconfig_error_none) {
1428+
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g, vap_info->vap_mode) != webconfig_error_none) {
14271429
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d Security object encode failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
14281430
return webconfig_error_encode;
14291431
}
@@ -1454,7 +1456,7 @@ webconfig_error_t encode_lnf_radius_vap_object(const wifi_vap_info_t *vap_info,
14541456
is_6g = strstr(vap_info->vap_name, "6g") ? true : false;
14551457
obj = cJSON_CreateObject();
14561458
cJSON_AddItemToObject(vap_obj, "Security", obj);
1457-
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g) != webconfig_error_none) {
1459+
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g, vap_info->vap_mode) != webconfig_error_none) {
14581460
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d Security object encode failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
14591461
return webconfig_error_encode;
14601462
}
@@ -1484,7 +1486,7 @@ webconfig_error_t encode_mesh_backhaul_vap_object(const wifi_vap_info_t *vap_inf
14841486
bool is_6g = strstr(vap_info->vap_name, "6g")?true:false;
14851487
obj = cJSON_CreateObject();
14861488
cJSON_AddItemToObject(vap_obj, "Security", obj);
1487-
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g) != webconfig_error_none) {
1489+
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g, vap_info->vap_mode) != webconfig_error_none) {
14881490
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d Security object encode failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
14891491
return webconfig_error_encode;
14901492
}
@@ -1514,7 +1516,7 @@ webconfig_error_t encode_iot_vap_object(const wifi_vap_info_t *vap_info,
15141516
bool is_6g = strstr(vap_info->vap_name, "6g")?true:false;
15151517
obj = cJSON_CreateObject();
15161518
cJSON_AddItemToObject(vap_obj, "Security", obj);
1517-
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g) != webconfig_error_none) {
1519+
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g, vap_info->vap_mode) != webconfig_error_none) {
15181520
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d Security object encode failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
15191521
return webconfig_error_encode;
15201522
}
@@ -1544,7 +1546,7 @@ webconfig_error_t encode_private_vap_object(const wifi_vap_info_t *vap_info,
15441546
bool is_6g = strstr(vap_info->vap_name, "6g")?true:false;
15451547
obj = cJSON_CreateObject();
15461548
cJSON_AddItemToObject(vap_obj, "Security", obj);
1547-
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g) != webconfig_error_none) {
1549+
if (encode_security_object(&vap_info->u.bss_info.security, obj, is_6g, vap_info->vap_mode) != webconfig_error_none) {
15481550
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d Security object encode failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
15491551
return webconfig_error_encode;
15501552
}
@@ -1626,7 +1628,7 @@ webconfig_error_t encode_mesh_sta_object(const wifi_vap_info_t *vap_info,
16261628
// Security
16271629
obj = cJSON_CreateObject();
16281630
cJSON_AddItemToObject(vap_obj, "Security", obj);
1629-
if (encode_security_object(&vap_info->u.sta_info.security, obj, is_6g) != webconfig_error_none) {
1631+
if (encode_security_object(&vap_info->u.sta_info.security, obj, is_6g, vap_info->vap_mode) != webconfig_error_none) {
16301632
wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d Security object encode failed for %s\n",__FUNCTION__, __LINE__, vap_info->vap_name);
16311633
return webconfig_error_encode;
16321634
}

0 commit comments

Comments
 (0)