From: Nishant Chaprana Date: Fri, 6 Apr 2018 09:10:29 +0000 (+0530) Subject: Added API to set and get PMF for Mesh Network X-Git-Tag: submit/tizen/20180412.075158^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c5db75e7cac1bd45f6642208d9f6d3f68074d2d;p=platform%2Fcore%2Fapi%2Fwifi-mesh.git Added API to set and get PMF for Mesh Network Change-Id: I9d852d5580a8acc128e7ccc3f69aa18f1c32e33c Signed-off-by: Nishant Chaprana --- diff --git a/include/wifi-mesh.h b/include/wifi-mesh.h index ec13a3b..093066d 100644 --- a/include/wifi-mesh.h +++ b/include/wifi-mesh.h @@ -113,6 +113,16 @@ typedef enum { MESH_SECURITY_SAE, /**< Simultaneous Authentication of Equals */ } wifi_mesh_security_type_e; +/** + * @brief Enumeration for the pmf(Protected management Frames) type of the Wi-Fi Mesh network. + * @since_tizen 5.0 + */ +typedef enum { + MESH_PMF_NONE = 0, /**< PMF in not available */ + MESH_PMF_OPTIONAL, /**< PMF is optional */ + MESH_PMF_REQUIRED, /**< PMF is mandatory */ +} wifi_mesh_pmf_type_e; + /** * @brief Enumeration for the connection state of the Wi-Fi Mesh network. * @since_tizen 5.0 @@ -922,6 +932,7 @@ int wifi_mesh_network_clone(wifi_mesh_network_h* dst, wifi_mesh_network_h src); * @param[in] rssi The Received Signal Strength Indicator * @param[in] security The security type for network * @param[in] passphrase The passphrase for network connection + * @param[in] pmf The pmf type for network connection * * @return 0 on success, otherwise a negative error value. * @retval #WIFI_MESH_ERROR_NONE Successful @@ -935,7 +946,7 @@ int wifi_mesh_network_clone(wifi_mesh_network_h* dst, wifi_mesh_network_h src); */ int wifi_mesh_network_new_with(wifi_mesh_network_h* network, const char *meshid, const char *bssid, int channel, int rssi, wifi_mesh_security_type_e security, - const char *passphrase); + const char *passphrase, wifi_mesh_pmf_type_e pmf); /** * @brief Destroys network handle. @@ -1144,6 +1155,44 @@ int wifi_mesh_network_get_security(wifi_mesh_network_h network, int wifi_mesh_network_set_security(wifi_mesh_network_h network, wifi_mesh_security_type_e security); +/** + * @brief Gets the pmf type. + * @details This function is to get the pmf type. + * + * @since_tizen 5.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[out] pmf The pmf type for network. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_set_pmf() + * + */ +int wifi_mesh_network_get_pmf(wifi_mesh_network_h network, + wifi_mesh_pmf_type_e *pmf); + +/** + * @brief Sets the pmf type. + * @details This function is to set the pmf type. + * + * @since_tizen 5.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] pmf The pmf type for network. + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see wifi_mesh_network_get_pmf() + * + */ +int wifi_mesh_network_set_pmf(wifi_mesh_network_h network, + wifi_mesh_pmf_type_e pmf); + /** * @brief Sets the passphrase for network connection. * @details This function is to set the passphrase. diff --git a/include/wifi-mesh_private.h b/include/wifi-mesh_private.h index d257aaa..bf05428 100644 --- a/include/wifi-mesh_private.h +++ b/include/wifi-mesh_private.h @@ -80,6 +80,7 @@ struct mesh_network_s { int rssi; /**< RSSI */ int data_rate; /**< Data rate */ wifi_mesh_security_type_e security; /**< Security type */ + wifi_mesh_pmf_type_e pmf; /**< Pmf type */ char passphrase[MAX_PASSPHRASE_LEN]; /**< Passphrase */ wifi_mesh_connection_state_e state; /**< Connection state */ wifi_mesh_ip_config_type_e ipv4_type; /**< IPv4 Config Type */ diff --git a/src/wifi-mesh-dbus.c b/src/wifi-mesh-dbus.c index 191529b..c3ed396 100644 --- a/src/wifi-mesh-dbus.c +++ b/src/wifi-mesh-dbus.c @@ -1523,7 +1523,7 @@ int _mesh_create_network(wifi_mesh_h handle, wifi_mesh_network_h _network) } variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "create_mesh_network", - g_variant_new("(sii)", n->meshid, n->channel, n->security), + g_variant_new("(siii)", n->meshid, n->channel, n->security, n->pmf), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); diff --git a/src/wifi-mesh.c b/src/wifi-mesh.c index d59495e..eeb2ec3 100644 --- a/src/wifi-mesh.c +++ b/src/wifi-mesh.c @@ -78,6 +78,7 @@ EXPORT_API int wifi_mesh_network_clone(wifi_mesh_network_h* dst, wifi_mesh_netwo net->rssi = _src->rssi; net->data_rate = _src->data_rate; net->security = _src->security; + net->pmf = _src->pmf; if (strlen(_src->passphrase) > 0) snprintf(net->passphrase, MAX_PASSPHRASE_LEN, "%s", _src->passphrase); @@ -88,7 +89,7 @@ EXPORT_API int wifi_mesh_network_clone(wifi_mesh_network_h* dst, wifi_mesh_netwo EXPORT_API int wifi_mesh_network_new_with(wifi_mesh_network_h* network, const char *meshid, const char *bssid, int channel, int rssi, wifi_mesh_security_type_e security, - const char *passphrase) + const char *passphrase, wifi_mesh_pmf_type_e pmf) { struct mesh_network_s *net; @@ -109,6 +110,7 @@ EXPORT_API int wifi_mesh_network_new_with(wifi_mesh_network_h* network, const ch net->channel = channel; net->rssi = rssi; net->security = security; + net->pmf = pmf; if (passphrase) snprintf(net->passphrase, MAX_PASSPHRASE_LEN, "%s", passphrase); @@ -314,6 +316,42 @@ EXPORT_API int wifi_mesh_network_set_security(wifi_mesh_network_h network, wifi_ return WIFI_MESH_ERROR_NONE; } +EXPORT_API int wifi_mesh_network_get_pmf(wifi_mesh_network_h network, wifi_mesh_pmf_type_e *pmf) +{ + struct mesh_network_s *net = (struct mesh_network_s *)network; + + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + if (NULL == network || NULL == pmf) { + /* LCOV_EXCL_START */ + LOGE("Invalid parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + *pmf = net->pmf; + + return WIFI_MESH_ERROR_NONE; +} + +EXPORT_API int wifi_mesh_network_set_pmf(wifi_mesh_network_h network, wifi_mesh_pmf_type_e pmf) +{ + struct mesh_network_s *net = (struct mesh_network_s *)network; + + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + if (NULL == network) { + /* LCOV_EXCL_START */ + LOGE("Invalid parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + net->pmf = pmf; + + return WIFI_MESH_ERROR_NONE; +} + EXPORT_API int wifi_mesh_network_set_passphrase(wifi_mesh_network_h network, const char* passphrase) { struct mesh_network_s *net = (struct mesh_network_s *)network; diff --git a/test/wifi-mesh-network.c b/test/wifi-mesh-network.c index bb7f7eb..55f2d05 100644 --- a/test/wifi-mesh-network.c +++ b/test/wifi-mesh-network.c @@ -44,6 +44,7 @@ static char security[MENU_DATA_SIZE + 1] = "2"; static char meshid[MENU_DATA_SIZE + 1] = "meshnet"; static char mesh_channel[MENU_DATA_SIZE + 1] = "161"; static char mesh_security[MENU_DATA_SIZE + 1] = "0"; +static char mesh_pmf[MENU_DATA_SIZE + 1] = "0"; static char mesh_passphrase[MENU_DATA_SIZE + 1] = ""; static char network_idx[MENU_DATA_SIZE + 1] = "1"; @@ -720,6 +721,7 @@ static int run_create_network(MManager *mm, struct menu_data *menu) int ret; int _mesh_channel = 1; wifi_mesh_security_type_e security = MESH_SECURITY_NONE; + wifi_mesh_pmf_type_e pmf = MESH_PMF_NONE; wifi_mesh_network_h net = NULL; msg("Create a new Mesh Network"); @@ -732,8 +734,13 @@ static int run_create_network(MManager *mm, struct menu_data *menu) security = ((1 == ret) ? MESH_SECURITY_SAE : MESH_SECURITY_NONE); } + if (strlen(mesh_pmf)) { + ret = (unsigned short)strtol(mesh_pmf, NULL, 10); + pmf = ((2 < ret) ? MESH_PMF_NONE : ret); + } + wifi_mesh_network_new_with(&net, meshid, NULL, _mesh_channel, 0, - security, security == MESH_SECURITY_SAE ? mesh_passphrase : NULL); + security, security == MESH_SECURITY_SAE ? mesh_passphrase : NULL, pmf); ret = wifi_mesh_create_network(mesh, net); wifi_mesh_network_destroy(net); if (WIFI_MESH_ERROR_NONE != ret) { @@ -1043,8 +1050,9 @@ static struct menu_data menu_create_network[] = { { "1", "Mesh ID", NULL, NULL, meshid }, { "2", "Channel", NULL, NULL, mesh_channel }, { "3", "Security (0=None,1=SAE)", NULL, NULL, mesh_security }, - { "4", "Passphrase", NULL, NULL, mesh_passphrase }, - { "5", "Run", NULL, run_create_network, NULL }, + { "4", "PMF (0=None,1=OPTIONAL,2=REQUIRED)", NULL, NULL, mesh_pmf }, + { "5", "Passphrase", NULL, NULL, mesh_passphrase }, + { "6", "Run", NULL, run_create_network, NULL }, { NULL, NULL, }, };