diff --git a/src/dataelements.c b/src/dataelements.c index 330a5e691315c683d52f0e854e7e769e2d6ba609..a1f1e0313861add1a2f45002758933058c460504 100644 --- a/src/dataelements.c +++ b/src/dataelements.c @@ -32,6 +32,7 @@ typedef struct set_ssid_operate_param { char *mfp; char *haul; char *text; + char *mld_enab; } set_ssid_param; typedef struct validate_ssid_param { @@ -4470,6 +4471,7 @@ static operation_args WiFiDataElementsNetwork_SetSSID_args = { "AKMsAllowed", "HaulType", "Type", + BBF_VENDOR_PREFIX"EnableMLD", NULL }, .out = (const char *[]) { @@ -4528,12 +4530,13 @@ static char *process_set_ssid_add_req(struct dmctx *ctx, set_ssid_param *op_para struct uci_section *s = NULL; char curr_band[90] = {0}; char passwd[256] = {0}; - bool enable = true; + bool enable = true, mld_enable = false; char **band_arr = NULL; size_t band_arr_length = 0; char **enc_arr = NULL; size_t enc_arr_length = 0; unsigned idx = 1; + char mld_id[3] = {0}; if (op_param == NULL) { bbfdm_set_fault_message(ctx, "Internal Error"); @@ -4544,6 +4547,11 @@ static char *process_set_ssid_add_req(struct dmctx *ctx, set_ssid_param *op_para string_to_bool(op_param->enab, &enable); } + /* If not mld capabled device ignore mld enable config */ + if (mld_capable && DM_STRLEN(op_param->mld_enab) != 0) { + string_to_bool(op_param->mld_enab, &mld_enable); + } + if (DM_STRLEN(op_param->band) == 0 || DM_LSTRCMP(op_param->band, "All") == 0) { struct radio_info *node = NULL; int len = 0; @@ -4599,6 +4607,34 @@ static char *process_set_ssid_add_req(struct dmctx *ctx, set_ssid_param *op_para return "Error_Invalid_Input"; } + /* If MLD config enabled then find an unused mld id */ + if (mld_enable == true) { + for (int id = 1; id <= 24; id++) { + char mld_str[3] = {0}; + struct uci_section *mld_sec = NULL; + + snprintf(mld_str, sizeof(mld_str), "%d", id); + mld_sec = get_dup_section_in_config_opt("mapcontroller", "mld", "id", mld_str); + if (mld_sec == NULL) { + snprintf(mld_id, sizeof(mld_id), "%s", mld_str); + break; + } + } + + if (DM_STRLEN(mld_id) == 0) { + bbfdm_set_fault_message(ctx, "No free MLD unit in range of 1 to 24"); + return "Error_Other"; + } else { + char *haul_type = get_haultype_uci_value(op_param->haul); + + dmuci_add_section("mapcontroller", "mld", &s); + dmuci_set_value_by_section(s, "ssid", op_param->ssid); + dmuci_set_value_by_section(s, "key", passwd); + dmuci_set_value_by_section(s, "type", haul_type); + dmuci_set_value_by_section(s, "id", mld_id); + } + } + for (int i = 0; i < band_arr_length; i++) { char sec_name[64]; char *encryp = NULL; @@ -4620,6 +4656,7 @@ static char *process_set_ssid_add_req(struct dmctx *ctx, set_ssid_param *op_para dmuci_set_value_by_section(s, "encryption", encryp); dmuci_set_value_by_section(s, "type", haul_type); dmuci_set_value_by_section(s, "enabled", (enable == true) ? "1" : "0"); + dmuci_set_value_by_section(s, "mld_id", (mld_enable == true) ? mld_id : ""); if (DM_LSTRCMP(band_arr[i], "2.4") == 0) { dmuci_set_value_by_section(s, "band", "2"); @@ -4641,6 +4678,7 @@ static char *process_set_ssid_add_req(struct dmctx *ctx, set_ssid_param *op_para dmuci_set_value_by_section(dmmap_s, "name", name); dmuci_set_value_by_section(dmmap_s, "ap_section_name", sec_name); dmuci_set_value_by_section(dmmap_s, "device", device ? device : ""); + dmuci_set_value_by_section(dmmap_s, "mld_id", (mld_enable == true) ? mld_id : ""); dmuci_set_value_by_section(dmmap_s, "text", DM_STRLEN(op_param->text) ? op_param->text : ""); } @@ -4742,6 +4780,11 @@ static char *process_set_ssid_change_req(struct dmctx *ctx, set_ssid_param *op_p return "Error_Invalid_Input"; } + if (DM_STRLEN(op_param->mld_enab) != 0) { + bbfdm_set_fault_message(ctx, "Once assigned, MLD setting can not be modified"); + return "Error_Invalid_Input"; + } + if (DM_STRLEN(op_param->new_ssid) != 0) { /* There should not exist any ssid with new value */ unsigned idx = 0; @@ -4989,6 +5032,7 @@ static int operate_WiFiDataElementsNetwork_SetSSID(char *refparam, struct dmctx op_param.akm = dmjson_get_value((json_object *)value, 1, "AKMsAllowed"); op_param.haul = dmjson_get_value((json_object *)value, 1, "HaulType"); op_param.text = dmjson_get_value((json_object *)value, 1, "Type"); + op_param.mld_enab = dmjson_get_value((json_object *)value, 1, BBF_VENDOR_PREFIX"EnableMLD"); if (DM_STRLEN(op_param.ssid) == 0 || validate_band_value(ctx, op_param.band) != 0 || validate_akms_value(ctx, op_param.akm) != 0 || validate_haultype_value(ctx, op_param.haul) != 0) { @@ -5002,6 +5046,12 @@ static int operate_WiFiDataElementsNetwork_SetSSID(char *refparam, struct dmctx goto end; } + if (DM_STRLEN(op_param.mld_enab) != 0 && bbfdm_validate_boolean(ctx, op_param.mld_enab) != 0) { + bbfdm_set_fault_message(ctx, "Invalid Enable value: (%s)", op_param.mld_enab); + snprintf(status, sizeof(status), "%s", "Error_Invalid_Input"); + goto end; + } + switch (op) { case SET_SSID_ADD: snprintf(status, sizeof(status), "%s", process_set_ssid_add_req(ctx, &op_param));