diff --git a/include/tr_181/ml/cosa_wifi_dml.h b/include/tr_181/ml/cosa_wifi_dml.h index 1fc5ae0c8..9e17fcd90 100644 --- a/include/tr_181/ml/cosa_wifi_dml.h +++ b/include/tr_181/ml/cosa_wifi_dml.h @@ -2228,5 +2228,38 @@ InterworkingElement_Validate ULONG *puLength ); +BOOL +DPP_GetParamUlongValue + ( + ANSC_HANDLE hInsContext, + char* ParamName, + ULONG* puLong + ); + +ULONG +DPP_GetParamStringValue + ( + ANSC_HANDLE hInsContext, + char* ParamName, + char* pValue, + ULONG* pUlSize + ); + +BOOL +DPP_SetParamUlongValue + ( + ANSC_HANDLE hInsContext, + char* ParamName, + ULONG uValue + ); + +BOOL +DPP_SetParamStringValue + ( + ANSC_HANDLE hInsContext, + char* ParamName, + char* pString + ); + #endif diff --git a/source/core/Makefile.am b/source/core/Makefile.am index 2f17382c0..4452768dd 100644 --- a/source/core/Makefile.am +++ b/source/core/Makefile.am @@ -104,11 +104,7 @@ OneWifi_SOURCES += $(top_srcdir)/source/ccsp/ccsp_api.c endif OneWifi_SOURCES += $(top_srcdir)/source/platform/rdkb/misc.c $(top_srcdir)/source/platform/common/common.c -if ONEWIFI_DML_SUPPORT -if EASYCONNECT_SUPPORT OneWifi_SOURCES += wifi_easy_connect.c -endif -endif OneWifi_SOURCES += $(top_srcdir)/source/stats/wifi_associated_devices_msmt.c if JOURNALCTL_SUPPORT OneWifi_SOURCES += $(top_srcdir)/lib/log/log_journal.c diff --git a/source/core/wifi_data_plane.c b/source/core/wifi_data_plane.c index fe4964246..0c6c465dd 100644 --- a/source/core/wifi_data_plane.c +++ b/source/core/wifi_data_plane.c @@ -56,14 +56,10 @@ void process_event_timeout(wifi_data_plane_event_t *event, wifi_data_plane_t *mo { switch (event->type) { -#if !defined(_BWG_PRODUCT_REQ_) -#if defined (DUAL_CORE_XB3) || (defined(_XB6_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_)) - case wifi_data_plane_event_type_dpp: - //process_easy_connect_event_timeout(event->u.dpp_ctx, &module->module_easy_connect);//ONE_WIFI + case wifi_data_plane_event_type_dpp: + process_easy_connect_event_timeout(event->u.dpp_ctx, &module->module_easy_connect);//ONE_WIFI break; -#endif -#endif default: UNREFERENCED_PARAMETER(module); break; @@ -99,13 +95,9 @@ void process_event(wifi_data_plane_event_t *event, wifi_data_plane_t *module) switch (event->type) { -#if defined (DUAL_CORE_XB3) || (defined(_XB6_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_)) -#if !defined(_BWG_PRODUCT_REQ_) case wifi_data_plane_event_type_dpp: - //process_easy_connect_event(event->u.dpp_ctx, &module->module_easy_connect);//ONE_WIFI + process_easy_connect_event(event->u.dpp_ctx, &module->module_easy_connect);//ONE_WIFI break; -#endif -#endif case wifi_data_plane_event_type_anqp: process_passpoint_event(event->u.anqp_ctx); break; @@ -147,19 +139,19 @@ void *process_data_plane_function (void *data) pthread_mutex_lock(&proc_data->lock); rc = pthread_cond_timedwait(&proc_data->cond, &proc_data->lock, &time_to_wait); - if (rc == ETIMEDOUT) { - /*wifi_util_dbg_print(WIFI_MON, "%s:%d: Running eloop\n", __func__, __LINE__); - hapd_wpa_run(); - timeout_count++; - if (timeout_count < 100) { - pthread_mutex_unlock(&proc_data->lock); - continue; - } - timeout_count = 0;*/ - //wifi_util_dbg_print(WIFI_MON, "%s:%d: Data plane timed out\n", __func__, __LINE__); - process_timeout(); - clock_gettime(CLOCK_MONOTONIC, &proc_data->last_polled_time); - } + // if (rc == ETIMEDOUT) { + // wifi_util_dbg_print(WIFI_MON, "%s:%d: Running eloop\n", __func__, __LINE__); + // hapd_wpa_run(); + // timeout_count++; + // if (timeout_count < 100) { + // pthread_mutex_unlock(&proc_data->lock); + // continue; + // } + // timeout_count = 0; + // //wifi_util_dbg_print(WIFI_MON, "%s:%d: Data plane timed out\n", __func__, __LINE__); + // process_timeout(); + // clock_gettime(CLOCK_MONOTONIC, &proc_data->last_polled_time); + // } // dequeue data count = queue_count(proc_data->queue); @@ -286,23 +278,25 @@ void auth_frame_received(unsigned int ap_index, mac_address_t sta, void *data, u void eapol_frame_sent(unsigned int ap_index, mac_address_t sta, wifi_eapol_type_t type, void *data, unsigned int len) { - // wifi_8021x_data_t *eapol; + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP ... \n", __func__, __LINE__); - //printf("%s:%d Enter: frame length:%d\n", __func__, __LINE__, len); + wifi_8021x_data_t *eapol; - // eapol = malloc(sizeof(wifi_8021x_data_t)); - // memset(eapol, 0, sizeof(wifi_8021x_data_t)); + printf("%s:%d Enter: frame length:%d\n", __func__, __LINE__, len); - // eapol->data = malloc(len); - // memcpy(eapol->data, data, len); - // eapol->len = len; + eapol = malloc(sizeof(wifi_8021x_data_t)); + memset(eapol, 0, sizeof(wifi_8021x_data_t)); - // eapol->vap = ap_index; - // memcpy(eapol->mac, sta, sizeof(mac_address_t)); - // eapol->type = type; - // eapol->dir = wifi_direction_downlink; + eapol->data = malloc(len); + memcpy(eapol->data, data, len); + eapol->len = len; + + eapol->vap = ap_index; + memcpy(eapol->mac, sta, sizeof(mac_address_t)); + eapol->type = type; + eapol->dir = wifi_direction_downlink; - //data_plane_queue_push(data_plane_queue_create_packet(eapol, wifi_data_plane_packet_type_8021x, TRUE)); + data_plane_queue_push(data_plane_queue_create_packet(eapol, wifi_data_plane_packet_type_8021x, TRUE)); } @@ -339,10 +333,9 @@ void deinit_wifi_data_plane() int init_wifi_data_plane() { -#if defined (DUAL_CORE_XB3) || \ - (defined(_XB6_PRODUCT_REQ_) && !defined(_XB8_PRODUCT_REQ_)) || \ - (defined(_CBR_PRODUCT_REQ_) && !(defined(_CBR2_PRODUCT_REQ_)) ) +wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP ... \n", __func__, __LINE__); + pthread_condattr_t cond_attr; pthread_attr_t attr; pthread_attr_t *attrp = NULL; @@ -391,18 +384,18 @@ int init_wifi_data_plane() wifi_util_dbg_print(WIFI_MON,"CosaWifiInitialize Error - WiFi failed to Initialize Passpoint.\n"); } #endif//ONE_WIFI - //wifi_hal_mgmt_frame_callbacks_register(mgmt_frame_received_callback); - wifi_util_dbg_print(WIFI_MON, "%s:%d: init_wifi_data_plane completed ### \n", __func__, __LINE__); -#endif + wifi_hal_mgmt_frame_callbacks_register(mgmt_frame_received_callback); + wifi_util_error_print(WIFI_MON, "%s:%d: init_wifi_data_plane completed ### \n", __func__, __LINE__); +// #endif return 0; } bool data_plane_queue_check_event(wifi_data_plane_event_type_t type, void *ctx) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP ... \n", __func__, __LINE__); bool matched = false; -#if defined (DUAL_CORE_XB3) || (defined(_XB6_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_)) unsigned int i, count; wifi_data_plane_queue_data_t *queue_data = NULL; wifi_data_plane_event_t *event; @@ -421,15 +414,10 @@ bool data_plane_queue_check_event(wifi_data_plane_event_type_t type, void *ctx) switch (event->type) { case wifi_data_plane_event_type_dpp: -#if !defined(_BWG_PRODUCT_REQ_) -#if 0 + if (is_matching_easy_connect_event(event->u.dpp_ctx, ctx) == true) { matched = true; } -#endif//ONE_WIFI -#else - UNREFERENCED_PARAMETER(ctx); -#endif break; case wifi_data_plane_event_type_anqp: @@ -448,19 +436,15 @@ bool data_plane_queue_check_event(wifi_data_plane_event_type_t type, void *ctx) pthread_mutex_unlock(&g_data_plane_module.lock); -#else - UNREFERENCED_PARAMETER(type); - UNREFERENCED_PARAMETER(ctx); -#endif - return matched; } void * data_plane_queue_remove_event(wifi_data_plane_event_type_t type, void *ctx) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP ... \n", __func__, __LINE__); + void *ptr = NULL; -#if defined (DUAL_CORE_XB3) || (defined(_XB6_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_)) unsigned int i, count; wifi_data_plane_event_t *event; wifi_data_plane_queue_data_t *queue_data = NULL; @@ -479,16 +463,12 @@ data_plane_queue_remove_event(wifi_data_plane_event_type_t type, void *ctx) switch (event->type) { case wifi_data_plane_event_type_dpp: -#if !defined(_BWG_PRODUCT_REQ_) -#if 0 + if (is_matching_easy_connect_event(event->u.dpp_ctx, ctx) == true) { ptr = event->u.dpp_ctx; matched = true; } -#endif//ONE_WIFI -#else - UNREFERENCED_PARAMETER(ctx); -#endif + break; case wifi_data_plane_event_type_anqp: @@ -508,18 +488,16 @@ data_plane_queue_remove_event(wifi_data_plane_event_type_t type, void *ctx) pthread_mutex_unlock(&g_data_plane_module.lock); - -#else - UNREFERENCED_PARAMETER(type); - UNREFERENCED_PARAMETER(ctx); -#endif - + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 14 ... \n", __func__, __LINE__); + return ptr; } wifi_data_plane_queue_data_t * data_plane_queue_create_packet(void *ptr, wifi_data_plane_packet_type_t type, BOOL setSignalThread) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP ... \n", __func__, __LINE__); + wifi_data_plane_queue_data_t *data; data = malloc(sizeof(wifi_data_plane_queue_data_t)); @@ -566,13 +544,15 @@ data_plane_queue_create_event(void *ptr, wifi_data_plane_event_type_t type, BOOL switch (type) { case wifi_data_plane_event_type_dpp: + wifi_util_error_print(WIFI_DPP, "%s:%d: wifi_data_plane_event_type_dpp \n", __func__, __LINE__); data->u.event.u.dpp_ctx = ptr; break; case wifi_data_plane_event_type_anqp: data->u.event.u.anqp_ctx = ptr; break; - } + } + wifi_util_error_print(WIFI_DPP, "%s:%d: End \n", __func__, __LINE__); return data; } diff --git a/source/core/wifi_easy_connect.c b/source/core/wifi_easy_connect.c index 0472e511c..c92be3b3f 100644 --- a/source/core/wifi_easy_connect.c +++ b/source/core/wifi_easy_connect.c @@ -16,6 +16,11 @@ See the License for the specific language governing permissions and limitations under the License. **************************************************************************/ +#include "cosa_apis.h" +#include "cosa_dbus_api.h" +#include "cosa_wifi_apis.h" +#include "cosa_wifi_internal.h" +#include "plugin_main_apis.h" #include #include #include @@ -50,8 +55,8 @@ extern bool is_device_associated(int ap_index, char *mac); extern bool wifi_api_is_device_associated(int ap_index, char *mac); static wifi_easy_connect_t g_easy_connect = {0}; -PCOSA_DML_WIFI_DPP_STA_CFG find_dpp_sta_dml_wifi_ap(unsigned int ap_index, mac_address_t sta_mac); -PCOSA_DML_WIFI_DPP_CFG find_dpp_dml_wifi_ap(unsigned int ap_index); +wifi_vap_dpp_sta_t find_dpp_sta_dml_wifi_ap(unsigned int ap_index, mac_address_t sta_mac); +wifi_vap_dpp_t find_dpp_dml_wifi_ap(unsigned int ap_index); INT wifi_dppProcessAuthResponse(wifi_device_dpp_context_t *dpp_ctx); INT wifi_dppProcessConfigRequest(wifi_device_dpp_context_t *ctx); INT wifi_dppProcessConfigResult(wifi_device_dpp_context_t *dpp_ctx); @@ -111,55 +116,56 @@ static char *resp_status[] = { void set_dpp_device_context_states(wifi_device_dpp_context_t *ctx, wifi_dpp_state_t state, wifi_activation_status_t activation_status, wifi_enrollee_responder_status_t enrollee_status, - PCOSA_DML_WIFI_DPP_STA_CFG pWifiDppSta) + wifi_vap_dpp_sta_t pWifiDppSta) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 1 ... \n", __func__, __LINE__); + ctx->session_data.state = state; ctx->activation_status = activation_status; ctx->enrollee_status = enrollee_status; -#if 0 - strcpy((char*)pWifiDppSta->ActivationStatus, acti_status[activation_status]); - strcpy((char*)pWifiDppSta->EnrolleeResponderStatus, resp_status[enrollee_status]); -#else +// #if 0 + strcpy((char*)pWifiDppSta.ActivationStatus, acti_status[activation_status]); + strcpy((char*)pWifiDppSta.EnrolleeResponderStatus, resp_status[enrollee_status]); +// #else //This implementation part is remaining -#endif//ONE_WIFI TBD +// #endif//ONE_WIFI TBD } void process_easy_connect_event(wifi_device_dpp_context_t *ctx, wifi_easy_connect_t *module) { - UNREFERENCED_PARAMETER(module); + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP ... \n", __func__, __LINE__); + + // UNREFERENCED_PARAMETER(module); int rc; ssid_t ssid; char passphrase[64] = {0x0}; - PCOSA_DML_WIFI_DPP_CFG pWifiDppCfg; - PCOSA_DML_WIFI_DPP_STA_CFG pWifiDppSta = NULL; -#if 0 - pWifiDppCfg = find_dpp_dml_wifi_ap(ctx->ap_index); - if (pWifiDppCfg == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Could not find dpp config in database\n", __func__, __LINE__); - return; - } - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Found dpp config in database\n", __func__, __LINE__); - // check if the STA was provisioned by us - pWifiDppSta = find_dpp_sta_dml_wifi_ap(ctx->ap_index, ctx->session_data.sta_mac); - if (pWifiDppSta == NULL) { - return; - } -#endif//ONE_WIFI + // wifi_vap_dpp_t pWifiDppCfg; + wifi_vap_dpp_sta_t pWifiDppSta; + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 2 31... \n", __func__, __LINE__); + if (ctx->session_data.state == STATE_DPP_UNPROVISIONED) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 2 32... \n", __func__, __LINE__); + if (wifi_dppInitiate(ctx) == RETURN_OK) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send success\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send success 1 \n", __func__, __LINE__); SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_AUTH_RSP_PENDING, ActStatus_In_Progress, RESPONDER_STATUS_RESPONSE_PENDING); + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 2 33... \n", __func__, __LINE__); + log_dpp_diagnostics("Wifi DPP: STATE_DPP_AUTH_RSP_PENDING\n"); } else { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send failed\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send failed\n", __func__, __LINE__); ctx->dpp_init_retries++; } data_plane_queue_push(data_plane_queue_create_event(ctx,wifi_data_plane_event_type_dpp, FALSE)); //need to pass NoLock } else if (ctx->session_data.state == STATE_DPP_AUTH_RSP_PENDING) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 2 34... \n", __func__, __LINE__); + if (ctx->type == dpp_context_type_received_frame_auth_rsp) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Sending DPP Authentication Cnf ... \n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Sending DPP Authentication Cnf ... \n", __func__, __LINE__); rc = wifi_dppProcessAuthResponse(ctx); + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 2 35... \n", __func__, __LINE__); + ctx->type = dpp_context_type_session_data; free(ctx->received_frame.frame); ctx->received_frame.length = 0; @@ -187,13 +193,9 @@ void process_easy_connect_event(wifi_device_dpp_context_t *ctx, wifi_easy_connec if ((ctx->type == dpp_context_type_received_frame_cfg_req) && (wifi_dppProcessConfigRequest(ctx) == RETURN_OK)) { ctx->config.wifiTech = WIFI_DPP_TECH_INFRA; /*TODO CID: 160007 Out-of-bounds access - Fix in QTN code*/ - wifi_getSSIDName(ctx->ap_index, ssid); /*CID: 160016 BUFFER_SIZE_WARNING*/ - strncpy(ctx->config.discovery, ssid, sizeof(ctx->config.discovery)-1); ctx->config.discovery[sizeof(ctx->config.discovery)-1] = '\0'; - wifi_getApSecurityKeyPassphrase(ctx->ap_index, passphrase); - strncpy(ctx->config.credentials.creds.passPhrase, passphrase, sizeof(ctx->config.credentials.creds.passPhrase)); - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Sending DPP Config Rsp ... ssid: %s passphrase: %s\n", __func__, __LINE__, + wifi_util_error_print(WIFI_DPP, "%s:%d: Sending DPP Config Rsp ... ssid: %s passphrase: %s\n", __func__, __LINE__, ctx->config.discovery, ctx->config.credentials.creds.passPhrase); rc = wifi_dppSendConfigResponse(ctx); ctx->type = dpp_context_type_session_data; @@ -207,8 +209,7 @@ void process_easy_connect_event(wifi_device_dpp_context_t *ctx, wifi_easy_connec } else { SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_CFG_FAILED, ActStatus_Config_Error, RESPONDER_STATUS_CONFIGURATION_FAILURE); - //log_dpp_diagnostics("%s MAC: %s\n", "Wifi DPP: RESPONDER_STATUS_CONFIGURATION_FAILURE", pWifiDppSta->ClientMac);//ONE_WIFI - //pWifiDppSta->Activate = FALSE;//ONE_WIFI + pWifiDppSta.Activate = FALSE;//ONE_WIFI end_device_provisioning(ctx); } } @@ -221,25 +222,24 @@ void process_easy_connect_event(wifi_device_dpp_context_t *ctx, wifi_easy_connec if (rc == RETURN_OK) { SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_PROVISIONED, ActStatus_OK, RESPONDER_STATUS_OK); - //pWifiDppSta->Activate = FALSE;//ONE_WIFI + pWifiDppSta.Activate = FALSE;//ONE_WIFI log_dpp_diagnostics("Wifi DPP: RESPONDER_STATUS_OK\n"); end_device_provisioning(ctx); } else { SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_CFG_FAILED, ActStatus_Config_Error, RESPONDER_STATUS_CONFIG_REJECTED); - //pWifiDppSta->Activate = FALSE;//ONE_WIFI - //log_dpp_diagnostics("%s MAC: %s\n", "Wifi DPP: RESPONDER_STATUS_CONFIG_REJECTED", pWifiDppSta->ClientMac);//ONE_WIFI + pWifiDppSta.Activate = FALSE;//ONE_WIFI end_device_provisioning(ctx); } } } else if (ctx->session_data.state == STATE_DPP_PROVISIONED) { if (ctx->type == dpp_context_type_received_frame_recfg_announce) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Trying to send DPP Reconfig Authentication Request\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Trying to send DPP Reconfig Authentication Request\n", __func__, __LINE__); if (wifi_dppReconfigInitiate(ctx) == RETURN_OK) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Reconfig Authentication Request Frame send success\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Reconfig Authentication Request Frame send success\n", __func__, __LINE__); log_dpp_diagnostics("Wifi DPP: STATE_DPP_RECFG_AUTH_RSP_PENDING\n"); } else { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send failed\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send failed\n", __func__, __LINE__); ctx->dpp_init_retries++; } SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_RECFG_AUTH_RSP_PENDING, @@ -253,7 +253,7 @@ void process_easy_connect_event(wifi_device_dpp_context_t *ctx, wifi_easy_connec free(ctx->received_frame.frame); ctx->received_frame.length = 0; if (rc == RETURN_OK) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Sending DPP Authentication Cnf ... \n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Sending DPP Authentication Cnf ... \n", __func__, __LINE__); rc = wifi_dppSendReconfigAuthCnf(ctx); if (rc == RETURN_OK) { SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_AUTHENTICATED, @@ -278,36 +278,29 @@ void process_easy_connect_event(wifi_device_dpp_context_t *ctx, wifi_easy_connec void process_easy_connect_event_timeout(wifi_device_dpp_context_t *ctx, wifi_easy_connect_t *module) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 3 ... \n", __func__, __LINE__); + UNREFERENCED_PARAMETER(module); - PCOSA_DML_WIFI_DPP_CFG pWifiDppCfg; - PCOSA_DML_WIFI_DPP_STA_CFG pWifiDppSta = NULL; + wifi_vap_dpp_sta_t pWifiDppSta; mac_addr_str_t mac_str; int next_ch = 0; -#if 0 - pWifiDppCfg = find_dpp_dml_wifi_ap(ctx->ap_index); - if (pWifiDppCfg == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Could not find dpp config in database\n", __func__, __LINE__); - return; - } - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Found dpp config in database\n", __func__, __LINE__); + + wifi_util_error_print(WIFI_DPP, "%s:%d: Found dpp config in database\n", __func__, __LINE__); // check if the STA was provisioned by us pWifiDppSta = find_dpp_sta_dml_wifi_ap(ctx->ap_index, ctx->session_data.sta_mac); - if (pWifiDppSta == NULL) { - return; - } -#endif//ONE_WIFI - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP context state:%d DPP init retries:%d Max retries:%d\n", __func__, __LINE__, + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP context state:%d DPP init retries:%d Max retries:%d\n", __func__, __LINE__, ctx->session_data.state, ctx->dpp_init_retries, ctx->max_retries); if ((ctx->session_data.state == STATE_DPP_AUTH_RSP_PENDING) || (ctx->session_data.state == STATE_DPP_UNPROVISIONED)) { if (ctx->dpp_init_retries < ctx->max_retries) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Trying to send DPP Authentication Request Frame ... \n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Trying to send DPP Authentication Request Frame ... \n", __func__, __LINE__); if (wifi_dppInitiate(ctx) == RETURN_OK) { SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_AUTH_RSP_PENDING, ActStatus_No_Response, RESPONDER_STATUS_RESPONSE_PENDING); log_dpp_diagnostics("Wifi DPP: STATE_DPP_AUTH_RSP_PENDING\n"); - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send success\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send success2 \n", __func__, __LINE__); + //reached here } else { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send failed\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send failed\n", __func__, __LINE__); } ctx->dpp_init_retries++; data_plane_queue_push(data_plane_queue_create_event(ctx,wifi_data_plane_event_type_dpp, FALSE)); //need to pass NoLock @@ -318,28 +311,28 @@ void process_easy_connect_event_timeout(wifi_device_dpp_context_t *ctx, wifi_eas SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_AUTH_RSP_PENDING, ActStatus_No_Response, RESPONDER_STATUS_RESPONSE_PENDING); log_dpp_diagnostics("Wifi DPP: STATE_DPP_AUTH_RSP_PENDING\n"); - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send success\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send success 3\n", __func__, __LINE__); } else { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send failed\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Authentication Request Frame send failed\n", __func__, __LINE__); } ctx->dpp_init_retries++; data_plane_queue_push(data_plane_queue_create_event(ctx,wifi_data_plane_event_type_dpp, FALSE)); //need to pass NoLock } else { SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_AUTH_FAILED, ActStatus_Failed, RESPONDER_STATUS_AUTH_FAILURE); - //log_dpp_diagnostics("%s MAC: %s\n", "Wifi DPP: RESPONDER_STATUS_AUTH_FAILURE", pWifiDppSta->ClientMac);//ONE_WIFI - //pWifiDppSta->Activate = FALSE;//ONE_WIFI + //log_dpp_diagnostics("%s MAC: %s\n", "Wifi DPP: RESPONDER_STATUS_AUTH_FAILURE", pWifiDppSta.ClientMac);//ONE_WIFI + pWifiDppSta.Activate = FALSE;//ONE_WIFI end_device_provisioning(ctx); } } else if (ctx->session_data.state == STATE_DPP_RECFG_AUTH_RSP_PENDING) { if (ctx->dpp_init_retries < ctx->max_retries) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Trying to send DPP Reconfig Authentication Request Frame ... \n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Trying to send DPP Reconfig Authentication Request Frame ... \n", __func__, __LINE__); ctx->dpp_init_retries++; if (wifi_dppReconfigInitiate(ctx) == RETURN_OK) { log_dpp_diagnostics("Wifi DPP: STATE_DPP_RECFG_AUTH_RSP_PENDING\n"); - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Reconfig Authentication Request Frame send success\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Reconfig Authentication Request Frame send success\n", __func__, __LINE__); } else { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Reconfig Authentication Request Frame send failed\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Reconfig Authentication Request Frame send failed\n", __func__, __LINE__); } SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_RECFG_AUTH_RSP_PENDING, ActStatus_No_Response, RESPONDER_STATUS_RESPONSE_PENDING); @@ -348,8 +341,8 @@ void process_easy_connect_event_timeout(wifi_device_dpp_context_t *ctx, wifi_eas } else { SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_RECFG_AUTH_FAILED, ActStatus_Failed, RESPONDER_STATUS_AUTH_FAILURE); - //log_dpp_diagnostics("%s MAC: %s\n", "Wifi DPP: RESPONDER_STATUS_AUTH_FAILURE", pWifiDppSta->ClientMac);//ONE_WIFI - //pWifiDppSta->Activate = FALSE;//ONE_WIFI + //log_dpp_diagnostics("%s MAC: %s\n", "Wifi DPP: RESPONDER_STATUS_AUTH_FAILURE", pWifiDppSta.ClientMac);//ONE_WIFI + pWifiDppSta.Activate = FALSE;//ONE_WIFI end_device_provisioning(ctx); } } else if (ctx->session_data.state == STATE_DPP_AUTHENTICATED) { @@ -358,7 +351,7 @@ void process_easy_connect_event_timeout(wifi_device_dpp_context_t *ctx, wifi_eas SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_UNPROVISIONED, ActStatus_Failed, RESPONDER_STATUS_AUTH_FAILURE); //log_dpp_diagnostics("%s MAC: %s\n", "Wifi DPP: RESPONDER_STATUS_AUTH_FAILURE", pWifiDppSta->ClientMac);//ONE_WIFI - //pWifiDppSta->Activate = FALSE;//ONE_WIFI + pWifiDppSta.Activate = FALSE;//ONE_WIFI end_device_provisioning(ctx); } else { ctx->check_for_config_requested++; @@ -370,28 +363,17 @@ void process_easy_connect_event_timeout(wifi_device_dpp_context_t *ctx, wifi_eas // now start checking for associated state on the vap index if ((ctx->enrollee_version == 1)) { /* configurator shall support both 2.0 & 1.0, hence check only enrollee */ to_mac_str(ctx->session_data.sta_mac, mac_str); - if (wifi_api_is_device_associated(ctx->ap_index, mac_str) == true) { SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_PROVISIONED, ActStatus_OK, RESPONDER_STATUS_OK); - //pWifiDppSta->Activate = FALSE;//ONE_WIFI + pWifiDppSta.Activate = FALSE;//ONE_WIFI log_dpp_diagnostics("Wifi DPP: RESPONDER_STATUS_OK\n"); end_device_provisioning(ctx); - } else if (ctx->check_for_associated >= ctx->max_retries/*5*/) { - SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_UNPROVISIONED, - ActStatus_Config_Error, RESPONDER_STATUS_CONFIG_REJECTED); - //pWifiDppSta->Activate = FALSE;//ONE_WIFI - //log_dpp_diagnostics("%s MAC: %s\n", "Wifi DPP: RESPONDER_STATUS_CONFIG_REJECTED", pWifiDppSta->ClientMac);//ONE_WIFI - end_device_provisioning(ctx); - } else { - ctx->check_for_associated++; - data_plane_queue_push(data_plane_queue_create_event(ctx,wifi_data_plane_event_type_dpp, FALSE)); //need to pass NoLock - } } } else if ((ctx->session_data.state == STATE_DPP_AUTH_FAILED) || (ctx->session_data.state == STATE_DPP_RECFG_AUTH_FAILED)) { // Authentication Cnf send failure SET_DPP_DEVICE_CONTEXT_STATES(ctx, STATE_DPP_UNPROVISIONED, ActStatus_Failed, RESPONDER_STATUS_AUTH_FAILURE); - //pWifiDppSta->Activate = FALSE;//ONE_WIFI + pWifiDppSta.Activate = FALSE;//ONE_WIFI //log_dpp_diagnostics("%s MAC: %s\n", "Wifi DPP: RESPONDER_STATUS_AUTH_FAILURE", pWifiDppSta->ClientMac);//ONE_WIFI end_device_provisioning(ctx); } @@ -399,6 +381,8 @@ void process_easy_connect_event_timeout(wifi_device_dpp_context_t *ctx, wifi_eas bool is_matching_easy_connect_event(wifi_device_dpp_context_t *ctx, void *ptr) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 4 ... \n", __func__, __LINE__); + wifi_easy_connect_event_match_criteria_t *criteria = (wifi_easy_connect_event_match_criteria_t *) ptr; if ((ctx->ap_index != criteria->apIndex) || (memcmp(ctx->session_data.sta_mac, criteria->sta_mac, sizeof(mac_address_t)) != 0)) { return false; @@ -411,6 +395,8 @@ bool is_matching_easy_connect_event(wifi_device_dpp_context_t *ctx, void *ptr) void dppAuthResponse_callback(UINT apIndex, mac_address_t sta, unsigned char *frame, unsigned int len) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 5 ... \n", __func__, __LINE__); + wifi_device_dpp_context_t *ctx = NULL; wifi_easy_connect_event_match_criteria_t criteria; @@ -418,11 +404,11 @@ void dppAuthResponse_callback(UINT apIndex, mac_address_t sta, unsigned char *fr memcpy(criteria.sta_mac, sta, sizeof(mac_address_t)); criteria.state = STATE_DPP_AUTH_RSP_PENDING; - wifi_util_dbg_print(WIFI_DPP, "%s:%d apIndex=%d mac=%02x:%02x:%02x:%02x:%02x:%02x len=%d\n", __func__, __LINE__, apIndex, sta[0], sta[1], sta[2], sta[3], sta[4], sta[5], len); + wifi_util_error_print(WIFI_DPP, "%s:%d apIndex=%d mac=%02x:%02x:%02x:%02x:%02x:%02x len=%d\n", __func__, __LINE__, apIndex, sta[0], sta[1], sta[2], sta[3], sta[4], sta[5], len); ctx = (wifi_device_dpp_context_t *)data_plane_queue_remove_event(wifi_data_plane_event_type_dpp, &criteria); if (ctx == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d ctx NULL\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d ctx NULL\n", __func__, __LINE__); return; } @@ -437,6 +423,7 @@ void dppAuthResponse_callback(UINT apIndex, mac_address_t sta, unsigned char *fr void dppConfigRequest_callback(UINT apIndex, mac_address_t sta, UCHAR token, UCHAR *configAttributes, UINT len) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 6 ... \n", __func__, __LINE__); wifi_device_dpp_context_t *ctx = NULL; wifi_easy_connect_event_match_criteria_t criteria; @@ -444,11 +431,11 @@ void dppConfigRequest_callback(UINT apIndex, mac_address_t sta, UCHAR token, UCH memcpy(criteria.sta_mac, sta, sizeof(mac_address_t)); criteria.state = STATE_DPP_AUTHENTICATED; - wifi_util_dbg_print(WIFI_DPP, "%s:%d apIndex=%d mac=%02x:%02x:%02x:%02x:%02x:%02x len=%d\n", __func__, __LINE__, apIndex, sta[0], sta[1], sta[2], sta[3], sta[4], sta[5], len); + wifi_util_error_print(WIFI_DPP, "%s:%d apIndex=%d mac=%02x:%02x:%02x:%02x:%02x:%02x len=%d\n", __func__, __LINE__, apIndex, sta[0], sta[1], sta[2], sta[3], sta[4], sta[5], len); ctx = (wifi_device_dpp_context_t *)data_plane_queue_remove_event(wifi_data_plane_event_type_dpp, &criteria); if (ctx == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d ctx NULL\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d ctx NULL\n", __func__, __LINE__); return; } @@ -463,6 +450,8 @@ void dppConfigRequest_callback(UINT apIndex, mac_address_t sta, UCHAR token, UCH void dppConfigResult_callback(UINT apIndex, mac_address_t sta, UCHAR *frame, UINT len) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 7 ... \n", __func__, __LINE__); + wifi_device_dpp_context_t *ctx = NULL; wifi_easy_connect_event_match_criteria_t criteria; @@ -470,11 +459,11 @@ void dppConfigResult_callback(UINT apIndex, mac_address_t sta, UCHAR *frame, UIN memcpy(criteria.sta_mac, sta, sizeof(mac_address_t)); criteria.state = STATE_DPP_CFG_RSP_SENT; - wifi_util_dbg_print(WIFI_DPP, "%s:%d apIndex=%d mac=%02x:%02x:%02x:%02x:%02x:%02x len=%d\n", __func__, __LINE__, apIndex, sta[0], sta[1], sta[2], sta[3], sta[4], sta[5], len); + wifi_util_error_print(WIFI_DPP, "%s:%d apIndex=%d mac=%02x:%02x:%02x:%02x:%02x:%02x len=%d\n", __func__, __LINE__, apIndex, sta[0], sta[1], sta[2], sta[3], sta[4], sta[5], len); ctx = (wifi_device_dpp_context_t *)data_plane_queue_remove_event(wifi_data_plane_event_type_dpp, &criteria); if (ctx == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d ctx NULL\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d ctx NULL\n", __func__, __LINE__); return; } @@ -489,35 +478,29 @@ void dppConfigResult_callback(UINT apIndex, mac_address_t sta, UCHAR *frame, UIN void dppReconfigAnnounce_callback(UINT apIndex, mac_address_t sta, UCHAR *frame, UINT len) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 8 ... \n", __func__, __LINE__); + wifi_device_dpp_context_t *ctx = NULL; - PCOSA_DML_WIFI_DPP_STA_CFG pWifiDppSta; - PCOSA_DML_WIFI_DPP_CFG pWifiDppCfg; + wifi_vap_dpp_sta_t pWifiDppSta; + wifi_vap_dpp_t pWifiDppCfg; mac_addr_str_t mac_str; wifi_easy_connect_event_match_criteria_t criteria; -#if 0 pWifiDppCfg = find_dpp_dml_wifi_ap(apIndex); - if (pWifiDppCfg == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Could not find dpp config in database\n", __func__, __LINE__); - return; - } - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Found dpp config in database\n", __func__, __LINE__); + + wifi_util_error_print(WIFI_DPP, "%s:%d: Found dpp config in database\n", __func__, __LINE__); // check if the STA was provisioned by us pWifiDppSta = find_dpp_sta_dml_wifi_ap(apIndex, sta); - if (pWifiDppSta == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Could not find station:%s in database\n", __func__, __LINE__, to_mac_str(sta, mac_str)); - return; - } -#endif//ONE_WIFI - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Found dpp station:%s config in database\n", __func__, __LINE__, to_mac_str(sta, mac_str)); + + wifi_util_error_print(WIFI_DPP, "%s:%d: Found dpp station:%s config in database\n", __func__, __LINE__, to_mac_str(sta, mac_str)); // check the sctivation status - //if (strcmp(pWifiDppSta->ActivationStatus, enum_str(ActStatus_OK)) != 0) { - // wifi_util_dbg_print(WIFI_DPP, "%s:%d: The station was never activated in database\n", __func__, __LINE__); - // return; + if (strcmp(pWifiDppSta.ActivationStatus, enum_str(ActStatus_OK)) != 0) { + wifi_util_error_print(WIFI_DPP, "%s:%d: The station was never activated in database\n", __func__, __LINE__); + return; - //} + } // check if the request for reconfiguring is in the queue already criteria.apIndex = apIndex; @@ -525,22 +508,22 @@ void dppReconfigAnnounce_callback(UINT apIndex, mac_address_t sta, UCHAR *frame, criteria.state = STATE_DPP_PROVISIONED; if (data_plane_queue_check_event(wifi_data_plane_event_type_dpp, &criteria) == true) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: The station is already in queue\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: The station is already in queue\n", __func__, __LINE__); return; } if (wifi_dppProcessReconfigAnnouncement(frame, len, g_easy_connect.csign[apIndex].sign_key_hash) != RETURN_OK) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: C-sign-key hash does not match\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: C-sign-key hash does not match\n", __func__, __LINE__); return; } - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Creating device context\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Creating device context\n", __func__, __LINE__); // create context and push in queue ctx = (wifi_device_dpp_context_t *)malloc(sizeof(wifi_device_dpp_context_t)); if (ctx == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Exit. Allocation was unsuccessful.\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Exit. Allocation was unsuccessful.\n", __func__, __LINE__); return; } memset(ctx, 0, sizeof(wifi_device_dpp_context_t)); @@ -553,12 +536,12 @@ void dppReconfigAnnounce_callback(UINT apIndex, mac_address_t sta, UCHAR *frame, // set the csign instance ctx->config.cSignInstance = g_easy_connect.csign[ctx->ap_index].csign_inst; - wifi_util_dbg_print(WIFI_DPP, "%s:%d: ap index: %d recfg ctx:%p csign instance:%p\n", __func__, __LINE__, ctx->ap_index, + wifi_util_error_print(WIFI_DPP, "%s:%d: ap index: %d recfg ctx:%p csign instance:%p\n", __func__, __LINE__, ctx->ap_index, ctx->config.reconfigCtx, ctx->config.cSignInstance); - //ctx->configurator_version = pWifiDppCfg->Version;//ONE_WIFI + ctx->configurator_version = pWifiDppCfg.version;//ONE_WIFI memcpy(ctx->session_data.sta_mac, sta, sizeof(mac_address_t)); - //ctx->max_retries = pWifiDppSta->MaxRetryCount;//ONE_WIFI + ctx->max_retries = pWifiDppSta.MaxRetryCount;//ONE_WIFI ctx->session_data.session = wifi_dpp_session_type_reconfig; ctx->session_data.state = STATE_DPP_PROVISIONED; @@ -568,22 +551,27 @@ void dppReconfigAnnounce_callback(UINT apIndex, mac_address_t sta, UCHAR *frame, memset(ctx->session_data.u.reconfig_data.iPubKey, 0, 256); strcpy(ctx->session_data.u.reconfig_data.iPubKey, g_easy_connect.reconfig[ctx->ap_index].reconf_pub_key); -#if 0 - if (strcmp(pWifiDppSta->Cred.KeyManagement, "Common-PSK") == 0) { + if (strcmp(pWifiDppSta.Cred.KeyManagement, "Common-PSK") == 0) { ctx->config.credentials.keyManagement = WIFI_DPP_KEY_MGMT_PSK; - } else if (strcmp(pWifiDppSta->Cred.KeyManagement, "DPPPSKSAE") == 0) { + } else if (strcmp(pWifiDppSta.Cred.KeyManagement, "DPP") == 0) { + ctx->config.credentials.keyManagement = WIFI_DPP_KEY_MGMT_DPP; + }else if (strcmp(pWifiDppSta.Cred.KeyManagement, "DPPSAE") == 0) { + ctx->config.credentials.keyManagement = WIFI_DPP_KEY_MGMT_SAE; + }else if (strcmp(pWifiDppSta.Cred.KeyManagement, "PSKSAE") == 0) { + ctx->config.credentials.keyManagement = WIFI_DPP_KEY_MGMT_PSKSAE; + }else if (strcmp(pWifiDppSta.Cred.KeyManagement, "DPPPSKSAE") == 0) { ctx->config.credentials.keyManagement = WIFI_DPP_KEY_MGMT_DPPPSKSAE; } -#else - //This Implementation part is remaining -#endif//ONE_WIFI - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Pushing event for processing\n", __func__, __LINE__); + + wifi_util_error_print(WIFI_DPP, "%s:%d: Pushing event for processing\n", __func__, __LINE__); data_plane_queue_push(data_plane_queue_create_event(ctx,wifi_data_plane_event_type_dpp, TRUE)); } void dppReconfigAuthResponse_callback(UINT apIndex, mac_address_t sta, unsigned char *frame, unsigned int len) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 9 ... \n", __func__, __LINE__); + wifi_device_dpp_context_t *ctx = NULL; wifi_easy_connect_event_match_criteria_t criteria; @@ -591,15 +579,15 @@ void dppReconfigAuthResponse_callback(UINT apIndex, mac_address_t sta, unsigned memcpy(criteria.sta_mac, sta, sizeof(mac_address_t)); criteria.state = STATE_DPP_RECFG_AUTH_RSP_PENDING; - wifi_util_dbg_print(WIFI_DPP, "%s:%d apIndex=%d mac=%02x:%02x:%02x:%02x:%02x:%02x len=%d\n", __func__, __LINE__, apIndex, sta[0], sta[1], sta[2], sta[3], sta[4], sta[5], len); + wifi_util_error_print(WIFI_DPP, "%s:%d apIndex=%d mac=%02x:%02x:%02x:%02x:%02x:%02x len=%d\n", __func__, __LINE__, apIndex, sta[0], sta[1], sta[2], sta[3], sta[4], sta[5], len); ctx = (wifi_device_dpp_context_t *)data_plane_queue_remove_event(wifi_data_plane_event_type_dpp, &criteria); if (ctx == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d ctx NULL\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d ctx NULL\n", __func__, __LINE__); return; } - wifi_util_dbg_print(WIFI_DPP, "%s:%d setting up context\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d setting up context\n", __func__, __LINE__); ctx->type = dpp_context_type_received_frame_recfg_auth_rsp; ctx->received_frame.frame = malloc(len); @@ -612,11 +600,13 @@ void dppReconfigAuthResponse_callback(UINT apIndex, mac_address_t sta, unsigned int find_best_dpp_channel(wifi_device_dpp_context_t *ctx) { + wifi_util_error_print(WIFI_DPP, "%s:%d: Test DPP 10 ... \n", __func__, __LINE__); + unsigned int ch; - wifi_util_dbg_print(WIFI_DPP, "%s: ctx->current_attempts = %d, ctx->num_channels=%d, %d\n", __func__, ctx->current_attempts, ctx->num_channels, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s: ctx->current_attempts = %d, ctx->num_channels=%d, %d\n", __func__, ctx->current_attempts, ctx->num_channels, __LINE__); if (ctx->current_attempts >= ctx->num_channels) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Exit\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Exit\n", __func__, __LINE__); return -1; } ch = ctx->channels_list[ctx->current_attempts]; @@ -625,40 +615,34 @@ int find_best_dpp_channel(wifi_device_dpp_context_t *ctx) return ch; } -int start_device_provisioning (PCOSA_DML_WIFI_AP pWiFiAP, ULONG staIndex) +int start_device_provisioning (wifi_vap_info_t *pWiFiAP, ULONG staIndex) { wifi_device_dpp_context_t *ctx = NULL; unsigned int i; - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Enter\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Enter\n", __func__, __LINE__); if(pWiFiAP == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: PCOSA_DML_WIFI_AP is NULL\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: PCOSA_DML_WIFI_AP is NULL\n", __func__, __LINE__); return RETURN_ERR; } -#if 0 - PCOSA_DML_WIFI_DPP_STA_CFG pWifiDppSta = &pWiFiAP->DPP.Cfg[staIndex-1]; - ULONG apIndex = pWiFiAP->AP.Cfg.InstanceNumber -1; - UCHAR dppVersion = pWiFiAP->DPP.Version; -#else - PCOSA_DML_WIFI_DPP_STA_CFG pWifiDppSta = NULL;//ONE_WIFI TBD - //ULONG apIndex = pWiFiAP->AP.Cfg.InstanceNumber -1;//ONE_WIFI - uint8_t radio_index = 0, vap_index = 0;//Temporary take static value - ULONG apIndex = (radio_index * MAX_NUM_VAP_PER_RADIO) + vap_index; - UCHAR dppVersion = 0;//ONE_WIFI TBD -#endif//ONE_WIFI -#if 0 +// #if 0 + wifi_vap_dpp_sta_t *pWifiDppSta = &pWiFiAP->vap_dpp.sta_array[staIndex-1]; + ULONG apIndex = pWiFiAP->vap_index; + UCHAR dppVersion = pWiFiAP->vap_dpp.version; + wifi_util_error_print(WIFI_DPP, "%s:%d: Enter version %d \n", __func__, __LINE__, dppVersion); + if(pWifiDppSta == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: PCOSA_DML_WIFI_DPP_STA_CFG is NULL\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: PCOSA_DML_WIFI_DPP_STA_CFG is NULL\n", __func__, __LINE__); return RETURN_ERR; } -#endif//ONE_WIFI +// #endif//ONE_WIFI // create context and push in queue ctx = (wifi_device_dpp_context_t *)malloc(sizeof(wifi_device_dpp_context_t)); if(ctx == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Exit. Allocation was unsuccessful.\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Exit. Allocation was unsuccessful.\n", __func__, __LINE__); return RETURN_ERR; } memset(ctx, 0, sizeof(wifi_device_dpp_context_t)); @@ -673,41 +657,48 @@ int start_device_provisioning (PCOSA_DML_WIFI_AP pWiFiAP, ULONG staIndex) ctx->config.cSignInstance = g_easy_connect.csign[ctx->ap_index].csign_inst; ctx->session_data.session = wifi_dpp_session_type_config; + + memset(ctx->config.discovery, 0x0, sizeof(char)*32); + memset(ctx->config.credentials.creds.passPhrase, 0x0, sizeof(char)*64); + strncpy(ctx->config.discovery, pWiFiAP->u.sta_info.ssid, sizeof(ctx->config.discovery)-1); + strncpy(ctx->config.credentials.creds.passPhrase, pWiFiAP->u.bss_info.security.u.key.key, sizeof(ctx->config.credentials.creds.passPhrase)); memset(ctx->session_data.u.config_data.iPubKey, 0x0, sizeof(char)*256); memset(ctx->session_data.u.config_data.rPubKey, 0x0, sizeof(char)*256); -#if 0 +// #if 0 to_mac_bytes(pWifiDppSta->ClientMac, ctx->session_data.sta_mac); strcpy(ctx->session_data.u.config_data.iPubKey, pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo); strcpy(ctx->session_data.u.config_data.rPubKey, pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo); for (i = 0; i < pWifiDppSta->NumChannels; i++) { ctx->channels_list[i] = pWifiDppSta->Channels[i]; - wifi_util_dbg_print(WIFI_DPP, "%s:%d: ctx->channels_list[%d] = %d\n", __func__, __LINE__, i, ctx->channels_list[i]); + wifi_util_error_print(WIFI_DPP, "%s:%d: ctx->channels_list[%d] = %d\n", __func__, __LINE__, i, ctx->channels_list[i]); } ctx->num_channels = pWifiDppSta->NumChannels; - wifi_util_dbg_print(WIFI_DPP, "%s:%d: ctx->num_channels = %d pWifiDppSta->NumChannels = %d\n", __func__, __LINE__, ctx->num_channels, pWifiDppSta->NumChannels); -#else + wifi_util_error_print(WIFI_DPP, "%s:%d: ctx->num_channels = %d pWifiDppSta.NumChannels = %d\n", __func__, __LINE__, ctx->num_channels, pWifiDppSta->NumChannels); +// #else //This implementation part is remaining -#endif//ONE_WIFI +// #endif//ONE_WIFI ctx->session_data.state = STATE_DPP_UNPROVISIONED; - //ctx->max_retries = pWifiDppSta->MaxRetryCount;//ONE_WIFI + ctx->max_retries = pWifiDppSta->MaxRetryCount;//ONE_WIFI ctx->session_data.channel = find_best_dpp_channel(ctx); - wifi_util_dbg_print(WIFI_DPP, "%s:%d: After find_best_dpp_channel\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: After find_best_dpp_channel\n", __func__, __LINE__); -#if 0 +// #if 0 if (strcmp(pWifiDppSta->Cred.KeyManagement, "Common-PSK") == 0) { ctx->config.credentials.keyManagement = WIFI_DPP_KEY_MGMT_PSK; } else if (strcmp(pWifiDppSta->Cred.KeyManagement, "DPPPSKSAE") == 0) { ctx->config.credentials.keyManagement = WIFI_DPP_KEY_MGMT_DPPPSKSAE; } -#else - //This implementation part is remaining -#endif +// #else + //This implementation part is remaininsg +// #endif + wifi_util_error_print(WIFI_DPP, "%s:%d: Before data_plane_queue_push\n", __func__, __LINE__); + data_plane_queue_push(data_plane_queue_create_event(ctx,wifi_data_plane_event_type_dpp, TRUE)); - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP Activate started thread and Exit\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP Activate started thread and Exit\n", __func__, __LINE__); return RETURN_OK; } @@ -716,83 +707,39 @@ void destroy_easy_connect (void) { } -PCOSA_DML_WIFI_DPP_CFG find_dpp_dml_wifi_ap(unsigned int apIndex) +wifi_vap_dpp_t find_dpp_dml_wifi_ap(unsigned int apIndex) { + wifi_vap_info_t *vapInfo = getVapInfo(apIndex); + return vapInfo->vap_dpp; -#if 0 - PCOSA_DATAMODEL_WIFI pMyObject; - PSINGLE_LINK_ENTRY pSLinkEntry = NULL; - PCOSA_DML_WIFI_AP pWifiAp = NULL; - - pMyObject = g_easy_connect.wifi_dml; - if (pMyObject == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: wifi data model not found\n", __func__, __LINE__); - return NULL; - } - - if ((pSLinkEntry = AnscQueueGetEntryByIndex(&pMyObject->AccessPointQueue, apIndex)) == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d Data Model object not found!\n", __func__, __LINE__); - return NULL; - } - - if ((pWifiAp = ACCESS_COSA_CONTEXT_LINK_OBJECT(pSLinkEntry)->hContext) == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d Data Model object not found!\n", __func__, __LINE__); - return NULL; - } - - return &pWifiAp->DPP; -#else - return NULL; - //This implementation part is remaining -#endif//ONE_WIFI } -PCOSA_DML_WIFI_DPP_STA_CFG find_dpp_sta_dml_wifi_ap(unsigned int ap_index, mac_address_t sta_mac) +wifi_vap_dpp_sta_t find_dpp_sta_dml_wifi_ap(unsigned int ap_index, mac_address_t sta_mac) { -#if 0 - unsigned int i; - bool found = false; - PCOSA_DML_WIFI_DPP_CFG pWifiApDpp; - PCOSA_DML_WIFI_DPP_STA_CFG pWifiApDppSta = NULL; + wifi_vap_dpp_sta_t pWifiDppSta; mac_address_t bmac; - - if ((pWifiApDpp = find_dpp_dml_wifi_ap(ap_index)) == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP config not found\n", __func__, __LINE__); - return NULL; - } - - for (i = 0; i < COSA_DML_WIFI_DPP_STA_MAX; i++) { - pWifiApDppSta = &pWifiApDpp->Cfg[i]; - if (pWifiApDppSta == NULL) { - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP STA config not found\n", __func__, __LINE__); - continue; - } - - wifi_util_dbg_print(WIFI_DPP, "%s:%d: DPP config for STA:%s\n", __func__, __LINE__, pWifiApDppSta->ClientMac); - to_mac_bytes (pWifiApDppSta->ClientMac, bmac); + unsigned int i; + // wifi_vap_info_t *vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(ap_index); + wifi_vap_info_t *vapInfo = getVapInfo(ap_index); + for (i = 0; i < vapInfo->vap_dpp.staIndex; i++) { + pWifiDppSta = vapInfo->vap_dpp.sta_array[i]; + wifi_util_error_print(WIFI_DPP, "%s:%d: DPP config for STA:%s\n", __func__, __LINE__, pWifiDppSta); + to_mac_bytes (pWifiDppSta.ClientMac, bmac); if (memcmp(bmac, sta_mac, sizeof(mac_address_t)) == 0) { - found = true; break; } - } - - wifi_util_dbg_print(WIFI_DPP, "%s:%d: data found:%d\n", __func__, __LINE__, found); - return (found == true)?pWifiApDppSta:NULL; -#else - //Thisimplementation part is remaining - return NULL; -#endif//ONE_WIFI TBD + } + + return pWifiDppSta; } //int init_easy_connect (PCOSA_DATAMODEL_WIFI pWifiDataModel) -int init_easy_connect () +int init_easy_connect (wifi_vap_dpp_t pWifiApDPP) { - int i; -// PCOSA_DML_WIFI_DPP_CFG pWifiApDPP;//ONE_WIFI + int i = 0; - wifi_util_dbg_print(WIFI_DPP, "%s:%d: Enter\n", __func__, __LINE__); + wifi_util_error_print(WIFI_DPP, "%s:%d: Enter\n", __func__, __LINE__); - //g_easy_connect.wifi_dml = pWifiDataModel;//ONE_WIFI g_easy_connect.channels_on_ap[0].num = 5; g_easy_connect.channels_on_ap[0].channels[0] = 1; @@ -816,22 +763,15 @@ int init_easy_connect () g_easy_connect.channels_on_ap[1].channels[9] = 157; g_easy_connect.channels_on_ap[1].channels[10] = 161; g_easy_connect.channels_on_ap[1].channels[11] = 165; -#if 0 - for (i = 0; i < MAX_NUM_RADIOS; i++) { - pWifiApDPP = find_dpp_dml_wifi_ap(i); - if (pWifiApDPP != NULL) { - wifi_dppCreateReconfigContext(i, pWifiApDPP->Recfg.PrivateReconfigAccessKey, (void*)&g_easy_connect.reconfig[i].reconf_ctx, - g_easy_connect.reconfig[i].reconf_pub_key); - wifi_dppCreateCSignIntance(i, pWifiApDPP->Recfg.PrivateSigningKey, (void*)&g_easy_connect.csign[i].csign_inst, + + wifi_dppCreateCSignIntance(i, pWifiApDPP.reconfig.PrivateSigningKey, (void*)&g_easy_connect.csign[i].csign_inst, g_easy_connect.csign[i].sign_key_hash); + wifi_dppCreateReconfigContext(i, pWifiApDPP.reconfig.PrivateReconfigAccessKey, (void*)&g_easy_connect.reconfig[i].reconf_ctx, + g_easy_connect.reconfig[i].reconf_pub_key); + - wifi_util_dbg_print(WIFI_DPP, "%s:%d: ap:%d reconfig context:%p csign instance: %p\n", __func__, __LINE__, i, + wifi_util_error_print(WIFI_DPP, "%s:%d: ap:%d reconfig context:%p csign instance: %p\n", __func__, __LINE__, i, g_easy_connect.reconfig[i].reconf_ctx, g_easy_connect.csign[i].csign_inst); - } - } -#else - //This Implementation part is remaining -#endif//ONE_WIFI TBD wifi_dpp_frame_received_callbacks_register(dppAuthResponse_callback, dppConfigRequest_callback, dppConfigResult_callback, dppReconfigAnnounce_callback, dppReconfigAuthResponse_callback); diff --git a/source/core/wifi_easy_connect.h b/source/core/wifi_easy_connect.h index d5b2d3db7..6f8d41bba 100644 --- a/source/core/wifi_easy_connect.h +++ b/source/core/wifi_easy_connect.h @@ -32,6 +32,7 @@ typedef struct { unsigned int channels[32]; } wifi_easy_connect_best_enrollee_channels_t; +#define MAX_DPP_VAP 8 typedef struct { void *reconf_ctx; char reconf_pub_key[512]; @@ -43,8 +44,9 @@ typedef struct { } wifi_easy_connect_csign_t; typedef struct { - wifi_easy_connect_reconfig_t reconfig[MAX_NUM_RADIOS]; - wifi_easy_connect_csign_t csign[MAX_NUM_RADIOS]; + wifi_vap_info_t vapInfo; + wifi_easy_connect_reconfig_t reconfig[MAX_DPP_VAP]; + wifi_easy_connect_csign_t csign[MAX_DPP_VAP]; wifi_easy_connect_best_enrollee_channels_t channels_on_ap[2]; } wifi_easy_connect_t; diff --git a/source/dml/tr_181/ml/cosa_wifi_dml.c b/source/dml/tr_181/ml/cosa_wifi_dml.c index ced3b22fb..505f71b0e 100755 --- a/source/dml/tr_181/ml/cosa_wifi_dml.c +++ b/source/dml/tr_181/ml/cosa_wifi_dml.c @@ -149,7 +149,53 @@ extern bool wifi_api_is_device_associated(int ap_index, char *mac); ***********************************************************************/ +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) +typedef enum{ + ClientMac, + InitiatorBootstrapSubjectPublicKeyInfo, + ResponderBootstrapSubjectPublicKeyInfo, + Channels, + MaxRetryCount +} dpp_cmd; + +typedef struct { + char ClientMac; + char InitiatorBootstrapSubjectPublicKeyInfo; + char ResponderBootstrapSubjectPublicKeyInfo; + char Channels; + char MaxRetryCount; +} __attribute__((packed)) status; + +static status dmcli_status = {0}; + +static void set_status(dpp_cmd cmd) +{ + switch(cmd) + { + case ClientMac: + {dmcli_status.ClientMac = 1;} + break; + case InitiatorBootstrapSubjectPublicKeyInfo: + { dmcli_status.InitiatorBootstrapSubjectPublicKeyInfo = 1;} + break ; + case ResponderBootstrapSubjectPublicKeyInfo: + { dmcli_status.ResponderBootstrapSubjectPublicKeyInfo = 1;} + break; + case Channels: + { dmcli_status.Channels = 1;} + break; + case MaxRetryCount: + { dmcli_status.MaxRetryCount = 1;} + break; + default: + break; + } +} +#endif // !defined(_HUB4_PRODUCT_REQ_) + + static BOOL isHotspotSSIDIpdated = FALSE; +bool isDPPparamsNotFetched = FALSE; BOOL IsValidMacAddress(char *mac); ULONG InterworkingElement_Commit(ANSC_HANDLE hInsContext); void *Wifi_Hosts_Sync_Func(void *pt, int index, wifi_associated_dev_t *associated_dev, BOOL bCallForFullSync, BOOL bCallFromDisConnCB); @@ -14730,7 +14776,7 @@ DPP_Commit ) { UNREFERENCED_PARAMETER(hInsContext); - return ANSC_STATUS_FAILURE; + return ANSC_STATUS_SUCCESS; } /********************************************************************** @@ -14804,13 +14850,268 @@ DPP_GetParamUlongValue ULONG* puLong ) { - if (AnscEqualString(ParamName, "Version", TRUE)) +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_)//dpp_test + if (isDPPparamsNotFetched) + { + CosaDmlWifi_getDppConfigFromPSM(); + } + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)hInsContext; + + if (pcfg == NULL) + { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Null pointer get fail\n", __FUNCTION__,__LINE__); + return FALSE; + } + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number-1); + // wifi_vap_dpp_t *pWifiDpp = (wifi_vap_dpp_t *)(&vapInfo->vap_dpp); + + if (strcmp(ParamName, "Version") == 0) { + *puLong = vapInfo->vap_dpp.version; return TRUE; } +#else + if (strcmp(ParamName, "Version") == 0) + { + *puLong = 0; + return TRUE; + } +#endif // !defined(_HUB4_PRODUCT_REQ_) + UNREFERENCED_PARAMETER(hInsContext); + UNREFERENCED_PARAMETER(ParamName); + UNREFERENCED_PARAMETER(puLong); return FALSE; } + +char* PSM_Get_Record_Status2(char *recName, char *strValue) +{ + int retry = 0; + int retPsmGet = CCSP_SUCCESS; + while(retry++ < 2) { + retPsmGet = PSM_Get_Record_Value2(bus_handle, g_Subsystem, recName, NULL, &strValue); + if (retPsmGet == CCSP_SUCCESS) { + wifi_util_dbg_print(WIFI_PSM,"%s:%d retPsmGet success for %s and strValue is %s\n", __FUNCTION__,__LINE__, recName, strValue); + return strValue; + } else if (retPsmGet == CCSP_CR_ERR_INVALID_PARAM) { + wifi_util_dbg_print(WIFI_PSM,"%s:%d PSM_Get_Record_Value2 (%s) returned error %d \n",__FUNCTION__,__LINE__,recName,retPsmGet); + return NULL; + } else { + wifi_util_dbg_print(WIFI_PSM,"%s:%d PSM_Get_Record_Value2 param (%s) returned error %d retry in 10 seconds \n",__FUNCTION__,__LINE__,recName,retPsmGet); + continue; + } + } + return NULL; +} + +void CosaDmlWifi_getDppConfigFromPSM(){ + + char recName[256]; + char strValue[256] = {0}; + char *str = NULL; + + int staIndex; + static char *DppVersion = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.Version"; + static char *DppPrivateSigningKey = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.PrivateSigningKey"; + static char *DppPrivateReconfigAccessKey = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.PrivateReconfigAccessKey"; + + static char *DppClientMac = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.ClientMac"; + static char *DppInitPubKeyInfo = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.InitiatorBootstrapSubjectPublicKeyInfo"; + static char *DppRespPubKeyInfo = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.ResponderBootstrapSubjectPublicKeyInfo"; + static char *DppChannels = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.Channels"; + static char *DppMaxRetryCnt = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.MaxRetryCount"; + // static char *DppActivate = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.Activate"; + static char *DppActivationStatus = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.ActivationStatus"; + static char *DppEnrolleeRespStatus = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.EnrolleeResponderStatus"; + static char *DppEnrolleeKeyManagement = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.KeyManagement"; + + wifi_vap_dpp_sta_t *pWifiDppSta; + + ULONG instance_number = 1; + if(isDPPparamsNotFetched) { + isDPPparamsNotFetched = FALSE; + } + /* for each Device.WiFi.AccessPoint.{i}. */ + + for ( instance_number = 1; instance_number < MAX_NUM_VAP_PER_RADIO; instance_number++ + ) + { + wifi_vap_info_t *vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number-1); + if(vapInfo == NULL) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Null pointer get fail\n", __FUNCTION__,__LINE__); + return; + } + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppPrivateSigningKey, instance_number); + + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test recName %s \n", __FUNCTION__,recName); + + str = PSM_Get_Record_Status2(recName, strValue); + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test strValue for DppPrivateSigningKey %s \n", __FUNCTION__,str); + if (str != NULL) { + AnscZeroMemory(vapInfo->vap_dpp.reconfig.PrivateSigningKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateSigningKey)); + strcpy_s(vapInfo->vap_dpp.reconfig.PrivateSigningKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateSigningKey), str); + + wifi_util_error_print(WIFI_DMCLI,"dpp_test vap_dpp_cfg.reconfig.PrivateSigningKey is %s \n", str); + } else { + AnscZeroMemory(vapInfo->vap_dpp.reconfig.PrivateSigningKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateSigningKey)); + strcpy_s(vapInfo->vap_dpp.reconfig.PrivateSigningKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateSigningKey), "default123"); + + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test default value of vap_dpp_cfg.reconfig.PrivateSigningKey %s \n", __FUNCTION__,vapInfo->vap_dpp.reconfig.PrivateSigningKey); + + } + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppPrivateReconfigAccessKey, instance_number); + + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + AnscZeroMemory(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey)); + strcpy_s(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey), str); + + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test vap_dpp.reconfig.PrivateReconfigAccessKey %s \n", __FUNCTION__,vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey); + } else { + AnscZeroMemory(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey)); + strcpy_s(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey), "default123"); + + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test default of vap_dpp.reconfig.PrivateReconfigAccessKey %s \n", __FUNCTION__,vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey); + } + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppVersion, instance_number); + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + vapInfo->vap_dpp.version = _ansc_atoi(str); + wifi_util_error_print(WIFI_DMCLI,"dpp_test vap_dpp_cfg.version is %d \n", vapInfo->vap_dpp.version); + } else { + vapInfo->vap_dpp.version = 1; + wifi_util_error_print(WIFI_DMCLI,":%s:%d dpp_test default of vap_dpp_cfg.version %d \n", __func__, __LINE__, vapInfo->vap_dpp.version); + } + + + +//dpp_test for station + /* for each Device.WiFi.AccessPoint.{i}.X_RDKCENTRAL-COM_DPP.STA.{i}. */ + + for (staIndex = 1; staIndex <= COSA_DML_WIFI_DPP_STA_MAX; staIndex++) + { + pWifiDppSta = &vapInfo->vap_dpp.sta_array[staIndex-1]; + if(!pWifiDppSta) + continue; + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppClientMac, instance_number, staIndex); + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + strcpy(pWifiDppSta->ClientMac, str); + wifi_util_error_print(WIFI_DMCLI,"dpp_test pWifiDppSta->ClientMac is %d \n", pWifiDppSta->ClientMac); + } else { + strcpy(pWifiDppSta->ClientMac, ""); + wifi_util_error_print(WIFI_DMCLI,":%s:%d dpp_test default of pWifiDppSta->ClientMac = %s \n", __func__, __LINE__, pWifiDppSta->ClientMac); + } + + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppInitPubKeyInfo, instance_number, staIndex); + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + strcpy(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo, str); + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo %s \n", __FUNCTION__,pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo); + } else { + strcpy(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo, ""); + wifi_util_error_print(WIFI_DMCLI,":%s:%d dpp_test default of pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo = %s \n", __func__, __LINE__, pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo); + } + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppRespPubKeyInfo, instance_number, staIndex); + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + strcpy(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo, str); + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo %s \n", __FUNCTION__,pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo); + } else { + strcpy(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo, ""); + wifi_util_error_print(WIFI_DMCLI,":%s:%d dpp_test default of pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo = %s \n", __func__, __LINE__, pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo); + } + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppChannels, instance_number, staIndex); + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + CosaDmlWiFi_ParseEasyConnectEnrolleeChannels(instance_number - 1, pWifiDppSta, str); + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test %d \n", __FUNCTION__,pWifiDppSta->Channels); + } else { + CosaDmlWiFi_ParseEasyConnectEnrolleeChannels(instance_number - 1, pWifiDppSta, ""); + wifi_util_error_print(WIFI_DMCLI,":%s:%d dpp_test default of pWifiDppSta->Channels = %d \n", __func__, __LINE__, pWifiDppSta->Channels); + } + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppMaxRetryCnt, instance_number, staIndex); + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + pWifiDppSta->MaxRetryCount = _ansc_atoi(str); + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test %d \n", __FUNCTION__,pWifiDppSta->MaxRetryCount); + } else { + pWifiDppSta->MaxRetryCount = 0; + wifi_util_error_print(WIFI_DMCLI,":%s:%d dpp_test default of pWifiDppSta->MaxRetryCount = %d \n", __func__, __LINE__, pWifiDppSta->MaxRetryCount); + } + + //Always Initialize to false + pWifiDppSta->Activate = FALSE; + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppActivationStatus, instance_number, staIndex); + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + strcpy(pWifiDppSta->ActivationStatus, str); + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test pWifiDppSta->ActivationStatus %s \n", __FUNCTION__,pWifiDppSta->ActivationStatus); + } else { + strcpy(pWifiDppSta->ActivationStatus, ""); + wifi_util_error_print(WIFI_DMCLI,":%s:%d dpp_test default of pWifiDppSta->ActivationStatus = %s \n", __func__, __LINE__, pWifiDppSta->ActivationStatus); + } + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppEnrolleeRespStatus, instance_number, staIndex); + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + strcpy(pWifiDppSta->EnrolleeResponderStatus, str); + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test pWifiDppSta->EnrolleeResponderStatus %s \n", __FUNCTION__,pWifiDppSta->EnrolleeResponderStatus); + } else { + strcpy(pWifiDppSta->EnrolleeResponderStatus, ""); + wifi_util_error_print(WIFI_DMCLI,":%s:%d dpp_test default of pWifiDppSta->EnrolleeResponderStatus = %s \n", __func__, __LINE__, pWifiDppSta->EnrolleeResponderStatus); + } + + memset(recName, 0, sizeof(recName)); + memset(strValue, 0, sizeof(strValue)); + snprintf(recName, sizeof(recName), DppEnrolleeKeyManagement, instance_number, staIndex); + str = PSM_Get_Record_Status2(recName, strValue); + if (str != NULL) { + strcpy(pWifiDppSta->Cred.KeyManagement, str); + wifi_util_error_print(WIFI_DMCLI, "%s: dpp_test pWifiDppSta->Cred.KeyManagement %s \n", __FUNCTION__,pWifiDppSta->Cred.KeyManagement); + } else { + strcpy(pWifiDppSta->Cred.KeyManagement, ""); + wifi_util_error_print(WIFI_DMCLI,":%s:%d dpp_test default of pWifiDppSta->Cred.KeyManagement = %s \n", __func__, __LINE__, pWifiDppSta->Cred.KeyManagement); + } + // if (WiFi_startDPP(vapInfo, staIndex) == ANSC_STATUS_SUCCESS) + // { + // // save update from backup + // CcspTraceError(("%s:%d:SUCCESS\n",__func__, __LINE__)); + // pWifiDppSta->Activate = TRUE; + // } + } + } +} + /********************************************************************** caller: owner of this object @@ -14858,16 +15159,62 @@ DPP_GetParamStringValue ULONG* pUlSize ) { - if( AnscEqualString(ParamName, "PrivateSigningKey", TRUE)) +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)hInsContext; + + if (pcfg == NULL) { - AnscCopyString(pValue, ""); + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Null pointer get fail\n", __FUNCTION__,__LINE__); + return FALSE; + } + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number-1); + errno_t rc = -1; + if (strcmp(ParamName, "PrivateSigningKey") == 0) + { + if( AnscSizeOfString(vapInfo->vap_dpp.reconfig.PrivateSigningKey) < *pUlSize) + { + rc = strcpy_s(pValue, *pUlSize, vapInfo->vap_dpp.reconfig.PrivateSigningKey); + AnscCopyString(pValue, vapInfo->vap_dpp.reconfig.PrivateSigningKey); + ERR_CHK(rc); + CcspWifiTrace(("RDK_LOG_ERROR, dpp_test(%s)value(%s), 1 validation error!!!\n", __func__,vapInfo->vap_dpp.reconfig.PrivateSigningKey)); + return 0; + } + else { + *pUlSize = AnscSizeOfString(vapInfo->vap_dpp.reconfig.PrivateSigningKey) +1; + CcspWifiTrace(("RDK_LOG_ERROR, dpp_test(%s)value(%s), 2 validation error!!!\n", __func__,vapInfo->vap_dpp.reconfig.PrivateSigningKey)); + return 1; + } + } + if (strcmp(ParamName, "PrivateReconfigAccessKey") == 0) + { + if( AnscSizeOfString(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey) < *pUlSize) + { + + rc = strcpy_s(pValue, *pUlSize, vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey); + ERR_CHK(rc); + AnscCopyString(pValue, vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey); + CcspWifiTrace(("RDK_LOG_ERROR, dpp_test(%s)value(%s), 3 validation error!!!\n", __func__,vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey)); + return 0; + } + else { + *pUlSize = AnscSizeOfString(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey) +1; + CcspWifiTrace(("RDK_LOG_ERROR, dpp_test(%s)value(%s), 4 validation error!!!\n", __func__,vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey)); + return 1; + } + } +#else + if (strcmp(ParamName, "PrivateSigningKey") == 0) + { + pValue[0] = '\0'; return 0; } - if( AnscEqualString(ParamName, "PrivateReconfigAccessKey", TRUE)) + if (strcmp(ParamName, "PrivateReconfigAccessKey") == 0) { - AnscCopyString(pValue, ""); + pValue[0] = '\0'; return 0; } +#endif // !defined(_HUB4_PRODUCT_REQ_) UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(ParamName); UNREFERENCED_PARAMETER(pValue); @@ -14913,9 +15260,33 @@ DPP_SetParamUlongValue ULONG uValue ) { +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)hInsContext; + + if (pcfg == NULL) + { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Null pointer get fail\n", __FUNCTION__,__LINE__); + return FALSE; + } + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number-1); + + /* check the parameter name and set the corresponding value */ + if (strcmp(ParamName, "Version") == 0) + { + vapInfo->vap_dpp.version = uValue; + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppVersion(instance_number,uValue)){ + return FALSE; + } + set_dml_cache_vap_config_changed(instance_number - 1); + return TRUE; + } +#else // !defined(_HUB4_PRODUCT_REQ_) UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(ParamName); UNREFERENCED_PARAMETER(uValue); +#endif return FALSE; } @@ -14957,9 +15328,53 @@ DPP_SetParamStringValue char* pString ) { +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)hInsContext; + + if (pcfg == NULL) + { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Null pointer get fail\n", __FUNCTION__,__LINE__); + return FALSE; + } + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number-1); + + errno_t rc = -1; + if (strcmp(ParamName, "PrivateSigningKey") == 0) + { + if (AnscSizeOfString(pString) > (sizeof(vapInfo->vap_dpp.reconfig.PrivateSigningKey) - 1)) + return FALSE; + + AnscZeroMemory(vapInfo->vap_dpp.reconfig.PrivateSigningKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateSigningKey)); + rc = strcpy_s(vapInfo->vap_dpp.reconfig.PrivateSigningKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateSigningKey), pString); + ERR_CHK(rc); + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppReconfig(instance_number,ParamName,pString)){ + return FALSE; + } + // set_dml_cache_vap_config_changed(instance_number - 1); + return TRUE; + } + if (strcmp(ParamName, "PrivateReconfigAccessKey") == 0) + { + if (AnscSizeOfString(pString) > (sizeof(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey) - 1)) + return FALSE; + + AnscZeroMemory(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey)); + rc = strcpy_s(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey, sizeof(vapInfo->vap_dpp.reconfig.PrivateReconfigAccessKey), pString); + ERR_CHK(rc); + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppReconfig(instance_number,ParamName,pString)){ + return FALSE; + } + init_easy_connect(vapInfo->vap_dpp); + init_wifi_data_plane(); + // set_dml_cache_vap_config_changed(instance_number - 1); + return TRUE; + } +#else // !defined(_HUB4_PRODUCT_REQ_) UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(pString); UNREFERENCED_PARAMETER(ParamName); +#endif return FALSE; } @@ -14983,86 +15398,376 @@ DPP_SetParamStringValue ***********************************************************************/ -/********************************************************************** - - caller: owner of this object - - prototype: - - BOOL - DPP_STA_GetParamBoolValue - ( - ANSC_HANDLE hInsContext, - char* ParamName, - BOOL* pBool - ); - - description: - - This function is called to retrieve Boolean parameter value; - - argument: ANSC_HANDLE hInsContext, - The instance handle; - - char* ParamName, - The parameter name; - - BOOL* pBool - The buffer of returned boolean value; - - return: TRUE if succeeded. - -**********************************************************************/ -BOOL -DPP_STA_GetParamBoolValue +ULONG +DPP_STA_GetEntryCount ( - ANSC_HANDLE hInsContext, - char* ParamName, - BOOL* pBool + ANSC_HANDLE hInsContext ) { UNREFERENCED_PARAMETER(hInsContext); - UNREFERENCED_PARAMETER(ParamName); - UNREFERENCED_PARAMETER(pBool); - /* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */ - return FALSE; + return COSA_DML_WIFI_DPP_STA_MAX; } +static ANSC_STATUS GetInsNumsByWifiDppSta(wifi_vap_dpp_sta_t *pWifiDppSta, ULONG *apIns, ULONG *dppStaIdx,UCHAR *dppVersion) +{ + + int staIndex; + ULONG instance_number = 1; + /* for each Device.WiFi.AccessPoint.{i}. */ + + for ( instance_number = 1; instance_number < MAX_NUM_VAP_PER_RADIO; instance_number++) + { -/********************************************************************** + wifi_vap_info_t *vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number-1); + if(vapInfo == NULL) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Null pointer get fail\n", __FUNCTION__,__LINE__); + return; + } + /* for each Device.WiFi.AccessPoint.{i}.X_RDKCENTRAL-COM_DPP.STA.{i}. */ + + for (staIndex = 1; staIndex <= COSA_DML_WIFI_DPP_STA_MAX; staIndex++) + { - caller: owner of this object + if((ANSC_HANDLE)pWifiDppSta == (ANSC_HANDLE)&vapInfo->vap_dpp.sta_array[staIndex-1]){ + *apIns=instance_number; + *dppStaIdx=staIndex; + *dppVersion=&vapInfo->vap_dpp.version; + //wifi_util_error_print(WIFI_DMCLI, "%s:%d inside the if cond: apind-%lu , staind-%lu\n", __func__, __LINE__,*apIns,*dppStaIdx); + return ANSC_STATUS_SUCCESS; + } + } + } + + CcspTraceError(("%s:%d:FAILED\n",__func__, __LINE__)); + return ANSC_STATUS_FAILURE; +} - prototype: +static wifi_vap_info_t * GetApInsByDppSta(wifi_vap_dpp_sta_t *pWifiDppSta, ULONG *dppStaIdx) +{ + int staIndex; + ULONG instance_number = 1; + /* for each Device.WiFi.AccessPoint.{i}. */ + wifi_util_error_print(WIFI_DMCLI,"%s:%d inside get ap\n", __FUNCTION__,__LINE__); - BOOL - DPP_STA_GetParamIntValue - ( - ANSC_HANDLE hInsContext, - char* ParamName, - int* pInt - ); + for ( instance_number = 1; instance_number < MAX_NUM_VAP_PER_RADIO; instance_number++) + { - description: + wifi_vap_info_t *vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number-1); + if(vapInfo == NULL) { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Null pointer get fail\n", __FUNCTION__,__LINE__); + return; + } + /* for each Device.WiFi.AccessPoint.{i}.X_RDKCENTRAL-COM_DPP.STA.{i}. */ + + for (staIndex = 1; staIndex <= COSA_DML_WIFI_DPP_STA_MAX; staIndex++) + { + wifi_util_error_print(WIFI_DMCLI,"%s:%d inside get ap sta loop\n", __FUNCTION__,__LINE__); - This function is called to retrieve integer parameter value; + if((ANSC_HANDLE)pWifiDppSta == (ANSC_HANDLE)&vapInfo->vap_dpp.sta_array[staIndex-1]){ + *dppStaIdx=staIndex; + wifi_util_error_print(WIFI_DMCLI, "%s:%d inside the if cond: apind-%lu , staind-%lu\n", __func__, __LINE__,*dppStaIdx); + return vapInfo; + } + } + } + CcspTraceError(("%s:%d:FAILED\n",__func__, __LINE__)); + return NULL; +} - argument: ANSC_HANDLE hInsContext, - The instance handle; +static BOOL DPP_STA_ProvisionStart_Validate(wifi_vap_dpp_sta_t *pWifiDppSta) +{ +// #if !defined(_BWG_PRODUCT_REQ_) +// #if !defined(_XF3_PRODUCT_REQ_) && !defined(_CBR_PRODUCT_REQ_) && !defined(_HUB4_PRODUCT_REQ_) && !defined(_PLATFORM_RASPBERRYPI_) && !defined(_PLATFORM_TURRIS_) + int asn1len; + const unsigned char *key; + ULONG apIns, staIndex; + char buff[512]; + unsigned char keyasn1[1024]; - char* ParamName, - The parameter name; + if ((WiFi_IsValidMacAddr(pWifiDppSta->ClientMac) == 0) || + (strlen(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo) <= 0) || + (strlen(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo) <= 0) || + (pWifiDppSta->NumChannels == 0)) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d One or more parameters were empty\n", __func__, __LINE__); + return FALSE; + } - int* pInt - The buffer of returned integer value; + if (pWifiDppSta->Activate == TRUE) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Activation already in progress\n", __func__, __LINE__); + snprintf(buff, sizeof(buff), "%s\n", "Wifi DPP: Activation already done"); + return FALSE; + } - return: TRUE if succeeded. + /* check the parameter name and return the corresponding value */ + if ((pWifiDppSta->MaxRetryCount < 0) || (pWifiDppSta->MaxRetryCount > 120)) + { + wifi_util_error_print(WIFI_DMCLI, "%s:%d: MaxRetryCount validation error!!!\n", __func__, __LINE__); + CcspWifiTrace(("RDK_LOG_ERROR,(%s), MaxRetryCount validation error!!!\n", __func__)); + CcspTraceError(("%s:%d:FAILED\n",__func__, __LINE__)); + return FALSE; + } -**********************************************************************/ -BOOL -DPP_STA_GetParamIntValue - ( - ANSC_HANDLE hInsContext, + memset(keyasn1, 0, sizeof(keyasn1)); + if ((asn1len = EVP_DecodeBlock(keyasn1, (unsigned char *)pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo, + strlen(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo))) < 0) { + CcspTraceError(("%s:%d:FAILED\n",__func__, __LINE__)); + wifi_util_error_print(WIFI_DMCLI, "%s:%d Failed to decode base 64 responder public key\n", __func__, __LINE__); + return FALSE; + } + key = keyasn1; + if (!(d2i_EC_PUBKEY(NULL, &key, asn1len))) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Failed to decode base 64 responder public key\n", __func__, __LINE__); + CcspTraceError(("%s:%d:FAILED\n",__func__, __LINE__)); + return FALSE; + } + + memset(keyasn1, 0, sizeof(keyasn1)); + if ((asn1len = EVP_DecodeBlock(keyasn1, (unsigned char *)pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo, + strlen(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo))) < 0) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Failed to decode base 64 initiator public key\n", __func__, __LINE__); + CcspTraceError(("%s:%d:FAILED\n",__func__, __LINE__)); + return FALSE; + } + + key = keyasn1; + if (!(d2i_EC_PUBKEY(NULL, &key, asn1len))) { + wifi_util_error_print(WIFI_DMCLI, "%s:%d Failed to decode base 64 initiator public key\n", __func__, __LINE__); + CcspTraceError(("%s:%d:FAILED\n",__func__, __LINE__)); + return FALSE; + + } + + wifi_util_error_print(WIFI_DMCLI, "%s:%d validation end \n", __func__, __LINE__); + + return TRUE; +} + +static BOOL IsValidChannel(int apIndex, int channel) +{ +#ifdef WIFI_HAL_VERSION_3 + UINT radioIndex = getRadioIndexFromAp(apIndex); + if(wifiRadioChannelIsValid(radioIndex, channel) == ANSC_STATUS_SUCCESS) + { + return TRUE; + } + return FALSE; +#else + BOOL ret = FALSE; + ULONG IsChanHome = 0; + + switch(channel) + { + case 1 ... 11: //2.4 Ghz + { + ret = ((apIndex == 0) ? TRUE: FALSE); + } + break; + case 36: + case 38: + case 40: + case 42: + case 44: + case 46: + case 48: + { + ret = ((apIndex == 1) ? TRUE: FALSE); + } + break; + case 50: //DFS + case 52: //DFS + case 54: //DFS + case 56: //DFS + case 58: //DFS + case 60: //DFS + case 62: //DFS + case 64: //DFS + { + wifi_getRadioChannel(apIndex, &IsChanHome); + if((ULONG)channel == IsChanHome) { + ret = TRUE; + } + else { + ret = FALSE; //don't allow DFS ch if not home channel + } + } + break; + case 68: //UNII-2e + case 96: //UNII-3 + { + ret = FALSE; + } + break; + case 100: //DFS + case 102: //DFS + case 104: //DFS + case 106: + case 108: //DFS + case 110: + case 112: //DFS + case 114: + case 116: //DFS + case 118: + case 120: //DFS + case 122: + case 124: //DFS + case 126: + case 128: //DFS + case 132: //DFS + case 134: + case 136: //DFS + case 138: + case 140: //DFS + case 142: + case 144: + { + wifi_getRadioChannel(apIndex, &IsChanHome); + if((ULONG)channel == IsChanHome) { + ret = TRUE; + } + else { + ret = FALSE; //don't allow DFS ch if not home channel + } + } + break; + case 149: + case 151: + case 153: + case 155: + case 157: + case 159: + case 161: + case 165: + { + ret = ((apIndex == 1) ? TRUE: FALSE); + } + break; + default: + ret = FALSE; + break; + } + + return ret; +#endif +} + +ANSC_HANDLE +DPP_STA_GetEntry + ( + ANSC_HANDLE hInsContext, + ULONG nIndex, + ULONG* pInsNumber + ) +{ + wifi_vap_info_t *pcfg = (wifi_vap_info_t *)hInsContext; + + if (pcfg == NULL) + { + wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Null pointer get fail\n", __FUNCTION__,__LINE__); + return FALSE; + } + uint8_t instance_number = convert_vap_name_to_index(&((webconfig_dml_t *)get_webconfig_dml())->hal_cap.wifi_prop, pcfg->vap_name)+1; + wifi_vap_info_t *vapInfo = (wifi_vap_info_t *) get_dml_cache_vap_info(instance_number-1); + wifi_vap_dpp_t *pWifiDppSta = (wifi_vap_dpp_t *)(&vapInfo->vap_dpp); + //pWifiDppSta->sta_array[nIndex].MaxRetryCount = 10; + + if (nIndex >= COSA_DML_WIFI_DPP_STA_MAX) + return (ANSC_HANDLE)NULL; + + *pInsNumber = nIndex + 1; + return (ANSC_HANDLE)&pWifiDppSta->sta_array[nIndex]; +} +/********************************************************************** + + caller: owner of this object + + prototype: + + BOOL + DPP_STA_GetParamBoolValue + ( + ANSC_HANDLE hInsContext, + char* ParamName, + BOOL* pBool + ); + + description: + + This function is called to retrieve Boolean parameter value; + + argument: ANSC_HANDLE hInsContext, + The instance handle; + + char* ParamName, + The parameter name; + + BOOL* pBool + The buffer of returned boolean value; + + return: TRUE if succeeded. + +**********************************************************************/ +BOOL +DPP_STA_GetParamBoolValue + ( + ANSC_HANDLE hInsContext, + char* ParamName, + BOOL* pBool + ) +{ +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_dpp_sta_t *pWifiDppSta = (wifi_vap_dpp_sta_t*)hInsContext; + + /* check the parameter name and return the corresponding value */ + if (strcmp(ParamName, "Activate") == 0) + { + /* collect value */ + *pBool = pWifiDppSta->Activate; + return TRUE; + } +#else // !defined(_HUB4_PRODUCT_REQ_) + UNREFERENCED_PARAMETER(hInsContext); + UNREFERENCED_PARAMETER(ParamName); + UNREFERENCED_PARAMETER(pBool); +#endif + /* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */ + return FALSE; +} + + +/********************************************************************** + + caller: owner of this object + + prototype: + + BOOL + DPP_STA_GetParamIntValue + ( + ANSC_HANDLE hInsContext, + char* ParamName, + int* pInt + ); + + description: + + This function is called to retrieve integer parameter value; + + argument: ANSC_HANDLE hInsContext, + The instance handle; + + char* ParamName, + The parameter name; + + int* pInt + The buffer of returned integer value; + + return: TRUE if succeeded. + +**********************************************************************/ +BOOL +DPP_STA_GetParamIntValue + ( + ANSC_HANDLE hInsContext, char* ParamName, int* pInt ) @@ -15112,9 +15817,19 @@ DPP_STA_GetParamUlongValue ULONG* puLong ) { +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_dpp_sta_t *pWifiDppSta = (wifi_vap_dpp_sta_t*)hInsContext; + + if (strcmp(ParamName, "MaxRetryCount") == 0) + { + *puLong = pWifiDppSta->MaxRetryCount; + return TRUE; + } +#else // !defined(_HUB4_PRODUCT_REQ_) UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(ParamName); UNREFERENCED_PARAMETER(puLong); +#endif return FALSE; } @@ -15165,10 +15880,131 @@ DPP_STA_GetParamStringValue ULONG* pUlSize ) { + #if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_dpp_sta_t *pWifiDppSta = (wifi_vap_dpp_sta_t*)hInsContext; + ULONG apIns, staIndex; + UCHAR dppVersion; + unsigned int i; + errno_t rc = -1; + + if (GetInsNumsByWifiDppSta(pWifiDppSta, &apIns, &staIndex, &dppVersion) != ANSC_STATUS_SUCCESS) + { + return -1; + } + /* check the parameter name and return the corresponding value */ + if (strcmp(ParamName, "ClientMac") == 0) + { + /* collect value */ + if( AnscSizeOfString(pWifiDppSta->ClientMac) < *pUlSize) + { + /* collect value */ + rc = strcpy_s(pValue, *pUlSize, pWifiDppSta->ClientMac); + ERR_CHK(rc); + return 0; + } + else + { + *pUlSize = AnscSizeOfString(pWifiDppSta->ClientMac)+1; + return 1; + } + } + + if (strcmp(ParamName, "Channels") == 0) + { + char channelsList[256]; + + channelsList[0] = 0; + + for (i = 0; i < pWifiDppSta->NumChannels && i < 32 ; i++) { + if (pWifiDppSta->Channels[i] == 0) + break; + sprintf(&channelsList[strlen(channelsList)], "%d,", pWifiDppSta->Channels[i]); + } + + if (pWifiDppSta->NumChannels > 0) { + channelsList[strlen(channelsList) - 1] = 0; + } + + /* collect value */ + if( AnscSizeOfString(channelsList) < *pUlSize) + { + /* collect value */ + strncpy(pValue, channelsList,(strlen(channelsList)+1)); + return 0; + } + else + { + *pUlSize = AnscSizeOfString(channelsList)+1; + return 1; + } + } + + if (strcmp(ParamName, "InitiatorBootstrapSubjectPublicKeyInfo") == 0) + { + if( AnscSizeOfString(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo) < *pUlSize) + { + rc = strcpy_s(pValue, *pUlSize, pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo); + ERR_CHK(rc); + return 0; + } + else { + *pUlSize = AnscSizeOfString(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo) +1; + return 1; + } + } + + if (strcmp(ParamName, "ResponderBootstrapSubjectPublicKeyInfo") == 0) + { + if( AnscSizeOfString(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo) < *pUlSize) + { + rc = strcpy_s(pValue, *pUlSize, pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo); + ERR_CHK(rc); + return 0; + } + else + { + *pUlSize = AnscSizeOfString(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo) +1; + return 1; + } + } + + if (strcmp(ParamName, "ActivationStatus") == 0) + { + if( AnscSizeOfString((char*)pWifiDppSta->ActivationStatus) < *pUlSize) + { + /* collect value */ + rc = strcpy_s(pValue, *pUlSize, (char*)pWifiDppSta->ActivationStatus); + ERR_CHK(rc); + return 0; + } + else + { + *pUlSize = AnscSizeOfString((char*)pWifiDppSta->ActivationStatus) +1; + return 1; + } + } + + if (strcmp(ParamName, "EnrolleeResponderStatus") == 0) + { + /* collect value */ + if( AnscSizeOfString((char*)pWifiDppSta->EnrolleeResponderStatus) < *pUlSize) + { + rc = strcpy_s(pValue, *pUlSize, (char*)pWifiDppSta->EnrolleeResponderStatus); + ERR_CHK(rc); + return 0; + } + else + { + *pUlSize = AnscSizeOfString((char*)pWifiDppSta->EnrolleeResponderStatus) +1; + return 1; + } + } +#else // !defined(_HUB4_PRODUCT_REQ_) UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(ParamName); UNREFERENCED_PARAMETER(pValue); UNREFERENCED_PARAMETER(pUlSize); +#endif return -1; } @@ -15210,11 +16046,107 @@ DPP_STA_SetParamBoolValue BOOL bValue ) { +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_dpp_sta_t *pWifiDppSta = (wifi_vap_dpp_sta_t*)hInsContext; + ULONG apIns = 0, staIndex = 0; + wifi_vap_info_t *vap_info= NULL; + + BOOL ret; + BOOL rfc; + char *recName = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.EasyConnect.Enable"; + char* strValue = NULL; + wifi_util_error_print(WIFI_DMCLI,"%s:%d inside the activate fn\n", __FUNCTION__,__LINE__); + + + if(PSM_Get_Record_Value2(bus_handle,g_Subsystem, recName, NULL, &strValue) != CCSP_SUCCESS) { + //wifi_dpp_dml_dbg_print(1, "%s: fail to get PSM record for RFC EasyConnect\n", __func__); + CcspTraceError(("%s: fail to get PSM record for RFC EasyConnect\n",__func__)); + } + else + { + rfc = atoi(strValue); + ((CCSP_MESSAGE_BUS_INFO *)bus_handle)->freefunc(strValue); + if(!rfc) + { + CcspTraceError(("%s: RFC for EasyConnect is disabled. Enable RFC to activate DPP\n",__func__)); + return FALSE; + } + } + wifi_util_error_print(WIFI_DMCLI,"%s:%d before the parameter comparison\n", __FUNCTION__,__LINE__); + + + //check the parameter name and set the corresponding value + if (strcmp(ParamName, "Activate") == 0) + { + if (bValue == TRUE) { + wifi_util_error_print(WIFI_DMCLI,"%s:%d b4 getapins\n", __FUNCTION__,__LINE__); + + if (NULL == (vap_info = GetApInsByDppSta(pWifiDppSta, &staIndex))) + { + CcspTraceError(("%s:%d:GetApIns failed\n",__func__, __LINE__)); + return FALSE; + } + wifi_util_error_print(WIFI_DMCLI,"%s:%d after getapins\n", __FUNCTION__,__LINE__); + + if((dmcli_status.MaxRetryCount == 1) && + (dmcli_status.ClientMac == 1) && + (dmcli_status.InitiatorBootstrapSubjectPublicKeyInfo == 1) && + (dmcli_status.ResponderBootstrapSubjectPublicKeyInfo == 1) && + (dmcli_status.Channels == 1)) + { + if (pWifiDppSta->Activate == TRUE) //for new request if activate is true means it's fatched from PS. + pWifiDppSta->Activate = FALSE; + wifi_util_error_print(WIFI_DMCLI,"%s:%d b4 provisionstart\n", __FUNCTION__,__LINE__); + + if ((DPP_STA_ProvisionStart_Validate(pWifiDppSta) == FALSE)) + { + CcspTraceError(("%s:%d: Validate failed\n",__func__, __LINE__)); + return FALSE; + } + wifi_util_error_print(WIFI_DMCLI,"%s:%d after provisionstart\n", __FUNCTION__,__LINE__); + + // init_easy_connect(vap_info); + + // sleep(10); + if (WiFi_startDPP(vap_info, staIndex) == ANSC_STATUS_SUCCESS) + { + // save update to backup + CcspTraceError(("%s:%d:SUCCESS\n",__func__, __LINE__)); + pWifiDppSta->Activate = bValue; + memset(&dmcli_status, 0x0, sizeof(status)); //clear + ret = TRUE; + }else{ + ret = FALSE; + } + wifi_util_error_print(WIFI_DMCLI,"%s:%d b4 set dpp value\n", __FUNCTION__,__LINE__); + + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppValue(apIns,staIndex,"ActivationStatus", (char*)pWifiDppSta->ActivationStatus)){ + CcspTraceError(("%s\n", "set ActivationStatus to PSM failed")); + } + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppValue(apIns,staIndex,"EnrolleeResponderStatus", (char*)pWifiDppSta->EnrolleeResponderStatus)){ + CcspTraceError(("%s\n", "set EnrolleeResponderStatus to PSM failed")); + } + wifi_util_error_print(WIFI_DMCLI,"%s:%d after set dpp value\n", __FUNCTION__,__LINE__); + + return ret; + } else { + char buff[64]; + CcspTraceError(("%s:%d: Not all expected parameters present\n",__func__, __LINE__)); + snprintf(buff, sizeof(buff), "%s\n", "Wifi DPP: ActStatus_Config_Error"); + return FALSE; + } + wifi_util_error_print(WIFI_DMCLI,"%s:%d at the end\n", __FUNCTION__,__LINE__); + + } + } +#else // !defined(_HUB4_PRODUCT_REQ_) + //CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(ParamName); UNREFERENCED_PARAMETER(bValue); - return FALSE; +#endif + return FALSE; } /********************************************************************** @@ -15299,9 +16231,38 @@ DPP_STA_SetParamUlongValue ULONG uValue ) { + #if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_dpp_sta_t *pWifiDppSta = (wifi_vap_dpp_sta_t*)hInsContext; + ULONG apIns, staIndex; + UCHAR dppVersion; + char setValue[8]={0}; + errno_t rc = -1; + + rc = sprintf_s(setValue, sizeof(setValue), "%li",uValue); + if(rc < EOK) + { + ERR_CHK(rc); + } + + if (GetInsNumsByWifiDppSta(pWifiDppSta, &apIns, &staIndex, &dppVersion) != ANSC_STATUS_SUCCESS) + { + return -1; + } + /* check the parameter name and set the corresponding value */ + if (strcmp(ParamName, "MaxRetryCount") == 0) + { + pWifiDppSta->MaxRetryCount = uValue; + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppValue(apIns,staIndex,ParamName,setValue)){ + return FALSE; + } + (void) set_status(MaxRetryCount); + return TRUE; + } +#else // !defined(_HUB4_PRODUCT_REQ_) UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(ParamName); UNREFERENCED_PARAMETER(uValue); +#endif return FALSE; } @@ -15343,9 +16304,159 @@ DPP_STA_SetParamStringValue char* pString ) { + #if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_dpp_sta_t *pWifiDppSta = (wifi_vap_dpp_sta_t*)hInsContext; + ULONG apIns, staIndex; + UCHAR dppVersion; + char channelsList[128] = {0}; + errno_t rc = -1; + + if (GetInsNumsByWifiDppSta(pWifiDppSta, &apIns, &staIndex, &dppVersion) != ANSC_STATUS_SUCCESS) + { + return -1; + } + // check the parameter name and set the corresponding value + if (strcmp(ParamName, "ClientMac") == 0) + { + if (AnscSizeOfString(pString) > (sizeof(pWifiDppSta->ClientMac) - 1)) + return FALSE; + if(WiFi_IsValidMacAddr(pString) == 0) + return FALSE; + + rc = strcpy_s(pWifiDppSta->ClientMac, sizeof(pWifiDppSta->ClientMac), pString); + //wifi_util_error_print(WIFI_DMCLI,"%s:%d APINDEX:%lu,staindex:%lu\n", __FUNCTION__,__LINE__,apIns,staIndex); + ERR_CHK(rc); + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppValue(apIns,staIndex,ParamName,pString)){ + return FALSE; + } + (void) set_status(ClientMac); + return TRUE; + } + + if (strcmp(ParamName, "InitiatorBootstrapSubjectPublicKeyInfo") == 0) + { + + if (AnscSizeOfString(pString) > (sizeof(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo) - 1)) + return FALSE; + + AnscZeroMemory(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo, sizeof(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo)); + rc = strcpy_s(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo, sizeof(pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo), pString); + wifi_util_error_print(WIFI_DMCLI,"%s:%d InitiatorBootstrapSubjectPublicKeyInfo:%s\n", __FUNCTION__,__LINE__,pWifiDppSta->InitiatorBootstrapSubjectPublicKeyInfo); + ERR_CHK(rc); + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppValue(apIns,staIndex,ParamName,pString)){ + return FALSE; + } + (void) set_status(InitiatorBootstrapSubjectPublicKeyInfo); + return TRUE; + } + + if (strcmp(ParamName, "ResponderBootstrapSubjectPublicKeyInfo") == 0) + { + if (AnscSizeOfString(pString) > (sizeof(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo) - 1)) + return FALSE; + + AnscZeroMemory(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo, sizeof(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo)); + rc = strcpy_s(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo, sizeof(pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo), pString); + wifi_util_error_print(WIFI_DMCLI,"%s:%d ResponderBootstrapSubjectPublicKeyInfo:%s\n", __FUNCTION__,__LINE__,pWifiDppSta->ResponderBootstrapSubjectPublicKeyInfo); + ERR_CHK(rc); + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppValue(apIns,staIndex,ParamName,pString)){ + return FALSE; + } + (void) set_status(ResponderBootstrapSubjectPublicKeyInfo); + return TRUE; + } + + if (strcmp(ParamName, "KeyManagement") == 0) + { + + if (AnscSizeOfString(pString) > sizeof(pWifiDppSta->Cred.KeyManagement) - 1) + return FALSE; + + AnscZeroMemory(pWifiDppSta->Cred.KeyManagement, sizeof(pWifiDppSta->Cred.KeyManagement)); + rc = strcpy_s(pWifiDppSta->Cred.KeyManagement, sizeof(pWifiDppSta->Cred.KeyManagement), pString); + + wifi_util_error_print(WIFI_DMCLI,"%s:%d Cred.KeyManagement:%s\n", __FUNCTION__,__LINE__,pWifiDppSta->Cred.KeyManagement); + ERR_CHK(rc); + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppValue(apIns,staIndex,ParamName,pString)){ + return FALSE; + } + return TRUE; + } + + if (strcmp(ParamName, "Channels") == 0) + { + + CcspWifiTrace(("RDK_LOG_WARN, %s-%d\n",__FUNCTION__,__LINE__)); + if((GetInsNumsByWifiDppSta(pWifiDppSta, &apIns, &staIndex, &dppVersion) != ANSC_STATUS_SUCCESS)) + { + CcspTraceError(("***Error*****DPP: no AP Index\n")); + return FALSE; + } + + if(AnscSizeOfString((char *)pWifiDppSta->Channels)) + { + + int channel[32] = {0x0}; + int i = 0; + char *tmp = NULL, token[256] = {0}; + char *saveptr = NULL; + wifi_util_error_print(WIFI_DMCLI,"%s:%d 2 inside ka 1st if:\n", __FUNCTION__,__LINE__); + + AnscZeroMemory(token, sizeof(token)); + rc = strcpy_s(token, sizeof(token), pString); + ERR_CHK(rc); + + if ((0 != strlen(token)) && (0 != strncmp(token, " ", 1))) { //Check for Channel is Empty or not RDKB-27958 + tmp=strtok_r(token, ",", &saveptr); + wifi_util_error_print(WIFI_DMCLI,"%s:%d inside if:\n", __FUNCTION__,__LINE__); + + if(tmp == NULL) + { + CcspTraceError(("********DPP Validate:Failed Channels\n")); + wifi_util_error_print(WIFI_DMCLI,"%s:%dinside tmp is null:\n", __FUNCTION__,__LINE__); + + return FALSE; + } + while (tmp != NULL && i < 32 ) + { + channel[i] = atoi(tmp); + tmp = strtok_r(NULL, ",", &saveptr); + + wifi_util_error_print(WIFI_DMCLI,"%s:%d, inside while:\n", __FUNCTION__,__LINE__); + + if(IsValidChannel(apIns-1, channel[i]) != TRUE) + { + CcspTraceError(("********DPP Validate:Failed Channels\n")); + return FALSE; + } + i++; + } + } else { + CcspTraceInfo(("DPP empty string case entered !!!\n")); + } + } + + if (ANSC_STATUS_SUCCESS != CosaDmlWiFi_ParseEasyConnectEnrolleeChannels(apIns - 1, pWifiDppSta, pString)) { + CcspTraceError(("***Error*****DPP: no Enrollee channel\n")); + return FALSE; + } + + if (ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppValue(apIns,staIndex,ParamName, WiFi_ChannelsListToString(pWifiDppSta, channelsList))){ + CcspTraceError(("***Error*****DPP: CosaDmlWiFi_setDppValue\n")); + return FALSE; + } + CcspTraceError(("***Error*****DPP: CosaDmlWiFi_setDppValue dpp_test Numchannels %d\n",pWifiDppSta->NumChannels)); + + (void) set_status(Channels); + return TRUE; + } + +#else // !defined(_HUB4_PRODUCT_REQ_) + // CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(ParamName); UNREFERENCED_PARAMETER(pString); +#endif return FALSE; } @@ -15520,9 +16631,46 @@ DPP_STA_Credential_GetParamStringValue ) { UNREFERENCED_PARAMETER(pUlSize); +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_dpp_sta_t *pWifiDppSta = (wifi_vap_dpp_sta_t*)hInsContext; + errno_t rc = -1; + + // check the parameter name and return the corresponding value + if (strcmp(ParamName, "KeyManagement") == 0) + { + //collect value + rc = strcpy_s(pValue, *pUlSize, pWifiDppSta->Cred.KeyManagement); + ERR_CHK(rc); + //AnscCopyString(pValue, "not_allowed_to_show"); + //wifi_dpp_dml_dbg_print(1, "%s= '%s'\n", ParamName, pWifiDppSta->Cred.KeyManagement); + return 0; + } + + if (strcmp(ParamName, "psk_hex") == 0) + { + // collect value + //AnscCopyString(pValue, pWifiDppSta->Cred.psk_hex); + rc = strcpy_s(pValue, *pUlSize, "not_allowed_to_show"); + ERR_CHK(rc); + //wifi_dpp_dml_dbg_print(1, "%s= '%s'\n", ParamName, pWifiDppSta->Cred.psk_hex); + return 0; + } + + if (strcmp(ParamName, "password") == 0) + { + // collect value + //AnscCopyString(pValue, pWifiDppSta->Cred.password); + rc = strcpy_s(pValue, *pUlSize, "not_allowed_to_show"); + ERR_CHK(rc); + //wifi_dpp_dml_dbg_print(1, "%s= '%s'\n", ParamName, pWifiDppSta->Cred.password); + return 0; + } +#else // !defined(_HUB4_PRODUCT_REQ_) + // CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(ParamName); UNREFERENCED_PARAMETER(pValue); +#endif return -1; } @@ -15564,11 +16712,37 @@ DPP_STA_Credential_SetParamStringValue char* pString ) { +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + wifi_vap_dpp_sta_t *pWifiDppSta = (wifi_vap_dpp_sta_t*)hInsContext; + ULONG apIns, staIndex; + UCHAR dppVersion; + errno_t rc = -1; + + if (GetInsNumsByWifiDppSta(pWifiDppSta, &apIns, &staIndex, &dppVersion) != ANSC_STATUS_SUCCESS) + { + return FALSE; + } + + /* check the parameter name and set the corresponding value */ + if (strcmp(ParamName, "KeyManagement") == 0) + { + if (AnscSizeOfString(pString) > sizeof(pWifiDppSta->Cred.KeyManagement) - 1) + return FALSE; + + rc = strcpy_s(pWifiDppSta->Cred.KeyManagement, sizeof(pWifiDppSta->Cred.KeyManagement), pString); + ERR_CHK(rc); + if(ANSC_STATUS_SUCCESS != CosaDmlWiFi_setDppValue(apIns,staIndex,ParamName,pString)){ + return FALSE; + } + return TRUE; + } +#else// !defined(_HUB4_PRODUCT_REQ_) + /* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */ UNREFERENCED_PARAMETER(hInsContext); UNREFERENCED_PARAMETER(ParamName); UNREFERENCED_PARAMETER(pString); - /* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */ - return TRUE; +#endif + return FALSE; } /********************************************************************** diff --git a/source/dml/tr_181/sbapi/cosa_wifi_apis.c b/source/dml/tr_181/sbapi/cosa_wifi_apis.c index c492720a4..287a3796e 100644 --- a/source/dml/tr_181/sbapi/cosa_wifi_apis.c +++ b/source/dml/tr_181/sbapi/cosa_wifi_apis.c @@ -2019,3 +2019,274 @@ bool get_inst_override_ttl() instant_measurement_config_t *pcfg = (instant_measurement_config_t *) get_dml_harvester(); return pcfg->u_inst_client_def_override_ttl; } +// #if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) + +ANSC_STATUS +CosaDmlWiFi_setDppVersion(ULONG apIns, ULONG version){ + int retPsmSet = CCSP_SUCCESS; + char recName[256]; + char value[2]={0}; + errno_t rc = -1; + static char *DppVersion = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.Version"; + + rc = sprintf_s(value, sizeof(value) , "%li",version); + if(rc < EOK) + { + ERR_CHK(rc); + } + memset(recName, 0, sizeof(recName)); + snprintf(recName, sizeof(recName), DppVersion, apIns); + + retPsmSet = PSM_Set_Record_Value2(bus_handle,g_Subsystem, recName, ccsp_string, value); + if (retPsmSet == CCSP_SUCCESS) { + return ANSC_STATUS_SUCCESS; + }else{ + CcspTraceError(("%s:%d: PSM Set Failed: %s\n", __func__, __LINE__,recName)); + return ANSC_STATUS_FAILURE; + } +} + +ANSC_STATUS +CosaDmlWiFi_setDppReconfig(ULONG apIns,char* ParamName,char *value ){ + int retPsmSet = CCSP_SUCCESS; + char recName[256]; + static char *DppPrivateSigningKey = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.PrivateSigningKey"; + static char *DppPrivateReconfigAccessKey = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.PrivateReconfigAccessKey"; + + memset(recName, 0, sizeof(recName)); + + if (strcmp(ParamName, "PrivateSigningKey") == 0){ + snprintf(recName, sizeof(recName), DppPrivateSigningKey, apIns); + }else if (strcmp(ParamName, "PrivateReconfigAccessKey") == 0){ + snprintf(recName, sizeof(recName), DppPrivateReconfigAccessKey, apIns); + }else{ + CcspTraceError(("%s:%d: Invalid Config: %s\n", __func__, __LINE__,recName)); + return ANSC_STATUS_FAILURE; + } + retPsmSet = PSM_Set_Record_Value2(bus_handle,g_Subsystem, recName, ccsp_string, value); + if (retPsmSet == CCSP_SUCCESS) { + return ANSC_STATUS_SUCCESS; + }else{ + CcspTraceError(("%s:%d: PSM Set Failed: %s\n", __func__, __LINE__,recName)); + return ANSC_STATUS_FAILURE; + } +} + +ANSC_STATUS +CosaDmlWiFi_setDppValue(ULONG apIns, ULONG staIndex,char* ParamName,char *value ){ + int retPsmSet = CCSP_SUCCESS; + char recName[256]; + static char *DppClientMac = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.ClientMac"; + static char *DppInitPubKeyInfo = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.InitiatorBootstrapSubjectPublicKeyInfo"; + static char *DppRespPubKeyInfo = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.ResponderBootstrapSubjectPublicKeyInfo"; + static char *DppChannels = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.Channels"; + static char *DppMaxRetryCnt = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.MaxRetryCount"; + static char *DppActivate = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.Activate"; + static char *DppActivationStatus = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.ActivationStatus"; + static char *DppEnrolleeRespStatus = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.EnrolleeResponderStatus"; + static char *DppEnrolleeKeyManagement = "eRT.com.cisco.spvtg.ccsp.tr181pa.Device.WiFi.AccessPoint.%d.X_RDKCENTRAL-COM_DPP.STA.%d.KeyManagement"; + + + if (strcmp(ParamName, "ClientMac") == 0){ + wifi_util_error_print(WIFI_DMCLI,"%s:%d inside set fn fn\n", __FUNCTION__,__LINE__); + sprintf(recName, DppClientMac, apIns,staIndex); + }else if (strcmp(ParamName, "InitiatorBootstrapSubjectPublicKeyInfo") == 0){ + sprintf(recName, DppInitPubKeyInfo, apIns,staIndex); + }else if (strcmp(ParamName, "ResponderBootstrapSubjectPublicKeyInfo") == 0){ + sprintf(recName, DppRespPubKeyInfo, apIns,staIndex); + }else if (strcmp(ParamName, "Channels") == 0){ + sprintf(recName, DppChannels, apIns,staIndex); + }else if (strcmp(ParamName, "MaxRetryCount") == 0){ + sprintf(recName, DppMaxRetryCnt, apIns,staIndex); + }else if (strcmp(ParamName, "Activate") == 0){ + sprintf(recName, DppActivate, apIns,staIndex); + }else if (strcmp(ParamName, "ActivationStatus") == 0){ + sprintf(recName, DppActivationStatus, apIns,staIndex); + }else if (strcmp(ParamName, "EnrolleeResponderStatus") == 0){ + sprintf(recName, DppEnrolleeRespStatus, apIns,staIndex); + }else if (strcmp(ParamName, "KeyManagement") == 0){ + sprintf(recName, DppEnrolleeKeyManagement, apIns,staIndex); + }else { + return ANSC_STATUS_FAILURE; + } + + retPsmSet = PSM_Set_Record_Value2(bus_handle,g_Subsystem, recName, ccsp_string, value); + if (retPsmSet == CCSP_SUCCESS) { + return ANSC_STATUS_SUCCESS; + }else{ + CcspTraceError(("%s:%d: PSM Set Failed: %s\n", __func__, __LINE__,recName)); + return ANSC_STATUS_FAILURE; + } +} + + + +ANSC_STATUS +WiFi_startDPP(wifi_vap_info_t *pWiFiAP, ULONG staIndex) +{ + if (start_device_provisioning(pWiFiAP, staIndex) == RETURN_OK) { + CcspTraceError(("%s:%d: DPP Authentication Request Frame send success\n", __func__, __LINE__)); + return ANSC_STATUS_SUCCESS; + } else { + CcspTraceError(("%s:%d: DPP Authentication Request Frame send failed\n", __func__, __LINE__)); + return ANSC_STATUS_FAILURE; + } + return ANSC_STATUS_FAILURE; +} + +BOOL CosaDmlWiFi_ValidateEasyConnectSingleChannelString(UINT apIndex, const char *pString) +{ +//TODO for triband +#ifdef WIFI_HAL_VERSION_3 + if((strncmp((CHAR *)getVAPName(apIndex), "private_ssid_2g", strlen("private_ssid_2g")) == 0) && + (atoi(pString) >= 1) && (atoi(pString) <= 11)) { + return true; + } + if(strncmp((CHAR *)getVAPName(apIndex), "private_ssid_5g", strlen("private_ssid_5g")) == 0) + { + if (((atoi(pString) >= 36) && (atoi(pString) < 52)) || + ((atoi(pString) >= 136) && (atoi(pString) <= 165))) + { + return true; + } + } + +#else + if ((apIndex == 0) && (atoi(pString) >= 1) && (atoi(pString) <= 11)) { + return true; + } + if ((apIndex == 1) && (atoi(pString) >= 36) && (atoi(pString) < 52)) { + return true; + } + if ((apIndex == 1) && (atoi(pString) >= 136) && (atoi(pString) <= 165)) { + return true; + } +#endif + return false; +} + +#if !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) +void CosaDmlWiFi_AllPossibleEasyConnectChannels(UINT apIndex, wifi_vap_dpp_sta_t *pWifiDppSta) +{ +#if !defined(_BWG_PRODUCT_REQ_) +#if !defined(_XF3_PRODUCT_REQ_) && !defined(_CBR_PRODUCT_REQ_) && !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) && !defined(_PLATFORM_TURRIS_) && !defined(_PLATFORM_RASPBERRYPI_) + wifi_easy_connect_best_enrollee_channels_t *channels; + unsigned int i, tmp; + ULONG op_channel = 0; + channels = get_easy_connect_best_enrollee_channels(apIndex); + pWifiDppSta->NumChannels = channels->num; + for (i = 0; i < channels->num; i++) { + pWifiDppSta->Channels[i] = channels->channels[i]; + } +#ifdef WIFI_HAL_VERSION_3 + if (wifi_getRadioChannel(getRadioIndexFromAp(apIndex), &op_channel) != RETURN_OK) { +#else + if (wifi_getRadioChannel(apIndex%2, &op_channel) != RETURN_OK) { +#endif + return; + } + for (i = 0; i < pWifiDppSta->NumChannels; i++) { + if (op_channel == pWifiDppSta->Channels[i]) { + //swap + tmp = pWifiDppSta->Channels[0]; + pWifiDppSta->Channels[0] = op_channel; + pWifiDppSta->Channels[i] = tmp; + break; + } + } +#endif //#if !defined(_XF3_PRODUCT_REQ_) && !defined(_CBR_PRODUCT_REQ_) && !defined(_HUB4_PRODUCT_REQ_) && !defined(_XB7_PRODUCT_REQ_) && !defined(_PLATFORM_TURRIS_) && !defined(_PLATFORM_RASPBERRYPI_) +#endif //#if !defined(_BWG_PRODUCT_REQ_) + UNREFERENCED_PARAMETER(apIndex); + UNREFERENCED_PARAMETER(pWifiDppSta); +} + +ANSC_STATUS CosaDmlWiFi_ParseEasyConnectEnrolleeChannels(UINT apIndex, wifi_vap_dpp_sta_t *pWifiDppSta, const char *pString) +{ + char tmpStr[256] = {0x0}; + char *ptr, *tmp; + unsigned int i, j = 0; + CcspWifiTrace(("RDK_LOG_WARN, %s:%d\n",__FUNCTION__,__LINE__)); + if (strcmp(pString, "") == 0) { + // Empty String + CosaDmlWiFi_AllPossibleEasyConnectChannels(apIndex, pWifiDppSta); + } else { + memset(tmpStr, 0, sizeof(tmpStr)); + for (i = 0; i < strlen(pString) && i < sizeof(tmpStr); i++) { + if (((pString[i] >= '0') && (pString[i] <='9')) || pString[i] == ',') { + tmpStr[j] = pString[i]; + j++; + } + } + // there is only one channel + if ((ptr = strchr(tmpStr, ',')) == NULL) { + if (CosaDmlWiFi_ValidateEasyConnectSingleChannelString(apIndex, tmpStr) == true) { + pWifiDppSta->NumChannels = 1; + pWifiDppSta->Channels[0] = atoi(tmpStr); + } else { + CosaDmlWiFi_AllPossibleEasyConnectChannels(apIndex, pWifiDppSta); + } + } else { + // there are comma separated channels + ptr = tmpStr; + tmp = tmpStr; + pWifiDppSta->NumChannels = 0; + while ((ptr = strchr(tmp, ',')) != NULL && (pWifiDppSta->NumChannels < 32)) { + *ptr = 0; + ptr++; + if (CosaDmlWiFi_ValidateEasyConnectSingleChannelString(apIndex, tmp) == true) { + pWifiDppSta->Channels[pWifiDppSta->NumChannels] = atoi(tmp); + pWifiDppSta->NumChannels += 1; + } + tmp = ptr; + } + if (CosaDmlWiFi_ValidateEasyConnectSingleChannelString(apIndex, tmp) == true && (pWifiDppSta->NumChannels < 32)) { + pWifiDppSta->Channels[pWifiDppSta->NumChannels] = atoi(tmp); + pWifiDppSta->NumChannels += 1; + } + } + } + return ANSC_STATUS_SUCCESS; +} +#endif +/*int CosaDmlWiFi_IsValidMacAddr(const char* mac) +{ + int i = 0; + int s = 0; + + while (*mac) + { + if (isxdigit(*mac)) + { + i++; + } + else if (*mac == ':') + { + if (i == 0 || i / 2 - 1 != s) + break; + ++s; + } + else + { + s = -1; + } + ++mac; + } + return (i == 12 && (s == 5 || s == 0)); +}*/ +char *WiFi_ChannelsListToString(wifi_vap_dpp_sta_t *pWifiDppSta, char *string) +{ + char tmpStr[8]; + unsigned int i; + errno_t rc = -1; + for (i = 0; i < pWifiDppSta->NumChannels; i++) { + snprintf(tmpStr, sizeof(tmpStr), "%d,", pWifiDppSta->Channels[i]); + /*string is a pointer pointing to 128 bytes */ + rc = strcat_s(string, 128 ,tmpStr); + ERR_CHK(rc); + } + if (pWifiDppSta->NumChannels > 0) { + string[strlen(string) - 1] = 0; + } + wifi_util_error_print(WIFI_DMCLI,"%s:%d inside string fn:%d\n", __FUNCTION__,__LINE__,pWifiDppSta->NumChannels); + return string; +} \ No newline at end of file diff --git a/source/dml/tr_181/sbapi/cosa_wifi_apis.h b/source/dml/tr_181/sbapi/cosa_wifi_apis.h index b737e0b5b..e519b28a0 100755 --- a/source/dml/tr_181/sbapi/cosa_wifi_apis.h +++ b/source/dml/tr_181/sbapi/cosa_wifi_apis.h @@ -270,6 +270,7 @@ ANSC_STATUS guardIntervalDmlEnumtoHalEnum(UINT ccspGiEnum, wifi_guard_interval_t ANSC_STATUS operChanBandwidthDmlEnumtoHalEnum(UINT ccspBw, wifi_channelBandwidth_t *halBw); INT getSecurityTypeFromString(const char *securityName, wifi_security_modes_t *securityType, COSA_DML_WIFI_SECURITY *cosaSecurityType); +char *WiFi_ChannelsListToString(wifi_vap_dpp_sta_t *pWifiDppSta, char *string); void WriteWiFiLog(char *); void AssociatedDevice_callback_register(); int decode_json_obj(bus_handle_t *handle, const char *json_name);