From: saerome kim Date: Tue, 22 Aug 2017 10:23:06 +0000 (+0900) Subject: Added new CAPI to get IPv4 details X-Git-Tag: submit/tizen/20170828.225740~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=234a7a0a98ad64b771fc5c3c225128f8392a8457;p=platform%2Fcore%2Fapi%2Fwifi-mesh.git Added new CAPI to get IPv4 details This patch adds new CAPI to get below IPv4 details: 1. IPv4 Config Type 2. IPv4 Address 3. IPv4 Subnet Mask Change-Id: I092931b8d5d007ceaca76a8eaec71380b33828c7 Signed-off-by: Saurav Babu --- diff --git a/include/wifi-mesh.h b/include/wifi-mesh.h index fbfea15..7c73c5b 100644 --- a/include/wifi-mesh.h +++ b/include/wifi-mesh.h @@ -95,6 +95,13 @@ typedef enum { */ #define MAX_PASSPHRASE_LEN (64+1) +/** + * @brief The maximum length of IPv4 Address + * + * @since_tizen 4.0 + */ +#define MAX_IPV4_ADDRESS_LEN 16 + /** * @brief Enumeration for the security type of the Wi-Fi Mesh network. * @since_tizen 4.0 @@ -115,6 +122,25 @@ typedef enum { WIFI_MESH_CONNECTION_STATE_CONNECTED /**< Wi-Fi Mesh network is connected */ } wifi_mesh_connection_state_e; +/** + * @brief Enumeration for address family of the Wi-Fi Mesh network. + * @since_tizen 4.0 +*/ +typedef enum { + WIFI_MESH_ADDRESS_FAMILY_IPV4 = 0, /**< IPV4 Address type */ + WIFI_MESH_ADDRESS_FAMILY_IPV6 = 1, /**< IPV6 Address type */ +} wifi_mesh_address_family_e; + +/** + * @brief Enumeration for the IP Config Type of the Wi-Fi Mesh network. + * @since_tizen 4.0 + */ +typedef enum { + WIFI_MESH_IP_CONFIG_TYPE_UNKNOWN = 0, /**< Unknown IP Config Type */ + WIFI_MESH_IP_CONFIG_TYPE_DYNAMIC, /**< DHCP IP Config Type */ + WIFI_MESH_IP_CONFIG_TYPE_STATIC /**< Static IP Config Type */ +} wifi_mesh_ip_config_type_e; + /** * @brief The events for wifi_mesh_event_cb * @@ -507,6 +533,61 @@ int wifi_mesh_network_set_passphrase(wifi_mesh_network_h network, const char* pa */ int wifi_mesh_network_get_connection_state(wifi_mesh_network_h network, wifi_mesh_connection_state_e *state); +/** + * @brief Gets the IP Config Type + * @details This function is to gets the IP Config Type + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] address_family Address Family + * @param[out] ip_type The IP Config Type + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int wifi_mesh_network_get_ip_config_type(wifi_mesh_network_h network, + wifi_mesh_address_family_e address_family, + wifi_mesh_ip_config_type_e *ip_type); + +/** + * @brief Gets the IP Address + * @details This function is to gets the IP Address + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] address_family Address Family + * @param[out] ip_address The IP Address + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int wifi_mesh_network_get_ip_address(wifi_mesh_network_h network, + wifi_mesh_address_family_e address_family, char **ip_address); + +/** + * @brief Gets the Subnet Mask + * @details This function is to gets the subnet mask + * + * @since_tizen 4.0 + * + * @param[in] network The Wi-Fi mesh network information handle. + * @param[in] address_family Address Family + * @param[out] subnet_mask The Subnet Mask + * + * @return 0 on success, otherwise a negative error value. + * @retval #WIFI_MESH_ERROR_NONE Successful + * @retval #WIFI_MESH_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int wifi_mesh_network_get_subnet_mask(wifi_mesh_network_h network, + wifi_mesh_address_family_e address_family, char **subnet_mask); + /** * @brief Gets address from the Wi-Fi mesh peer. * @details This function is to return mesh network id diff --git a/include/wifi-mesh_private.h b/include/wifi-mesh_private.h index 049ebfc..d7b975c 100644 --- a/include/wifi-mesh_private.h +++ b/include/wifi-mesh_private.h @@ -81,6 +81,9 @@ struct mesh_network_s { wifi_mesh_security_type_e security; /**< Security 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 */ + char ipv4_address[MAX_IPV4_ADDRESS_LEN]; /**< IPv4 Address */ + char ipv4_netmask[MAX_IPV4_ADDRESS_LEN]; /**< IPv4 Netmask */ }; struct mesh_station_info_s { diff --git a/src/wifi-mesh-dbus.c b/src/wifi-mesh-dbus.c index aa7711f..d3674db 100644 --- a/src/wifi-mesh-dbus.c +++ b/src/wifi-mesh-dbus.c @@ -1124,10 +1124,14 @@ int _mesh_get_joined_mesh_network(wifi_mesh_h handle, wifi_mesh_network_h* _netw int channel = -1; int security = -1; int state = 0; + int ipv4_type = 0; + char *ipv4_address = NULL; + char *ipv4_netmask = NULL; int svc_result = 0; - g_variant_get(variant, "(ssiiii)", &meshid, &bssid, &channel, - &security, &state, &svc_result); + g_variant_get(variant, "(ssiiiissi)", &meshid, &bssid, &channel, + &security, &state, &ipv4_type, &ipv4_address, &ipv4_netmask, + &svc_result); LOGD("get_joined_mesh_network status 0x%x", svc_result); result = __convert_service_error_type(svc_result); @@ -1139,6 +1143,9 @@ int _mesh_get_joined_mesh_network(wifi_mesh_h handle, wifi_mesh_network_h* _netw g_joined_network.data_rate = 0; g_joined_network.security = MESH_SECURITY_NONE; g_joined_network.state = WIFI_MESH_CONNECTION_STATE_DISCONNECTED; + g_joined_network.ipv4_type = WIFI_MESH_IP_CONFIG_TYPE_UNKNOWN; + memset(g_joined_network.ipv4_address, 0, MAX_IPV4_ADDRESS_LEN); + memset(g_joined_network.ipv4_netmask, 0, MAX_IPV4_ADDRESS_LEN); if (SERVICE_ERROR_NO_DATA == svc_result) { *_network = NULL; @@ -1160,6 +1167,17 @@ int _mesh_get_joined_mesh_network(wifi_mesh_h handle, wifi_mesh_network_h* _netw g_joined_network.rssi = -1; g_joined_network.security = security; g_joined_network.state = state; + g_joined_network.ipv4_type = ipv4_type; + if (ipv4_address) { + LOGD(" IPv4 Address : %s", ipv4_address); + snprintf(g_joined_network.ipv4_address, MAX_IPV4_ADDRESS_LEN, "%s", + ipv4_address); + } + if (ipv4_netmask) { + LOGD(" IPv4 Netmask : %s", ipv4_netmask); + snprintf(g_joined_network.ipv4_netmask, MAX_IPV4_ADDRESS_LEN, "%s", + ipv4_netmask); + } *_network = &g_joined_network; } else if (error) { diff --git a/src/wifi-mesh.c b/src/wifi-mesh.c index b5de9fd..c7658bc 100644 --- a/src/wifi-mesh.c +++ b/src/wifi-mesh.c @@ -354,6 +354,79 @@ EXPORT_API int wifi_mesh_network_get_connection_state(wifi_mesh_network_h networ return WIFI_MESH_ERROR_NONE; } +EXPORT_API int wifi_mesh_network_get_ip_config_type(wifi_mesh_network_h network, + wifi_mesh_address_family_e address_family, + wifi_mesh_ip_config_type_e *ip_type) +{ + struct mesh_network_s *net = (struct mesh_network_s *)network; + + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + if (NULL == network || ip_type == NULL) { + /* LCOV_EXCL_START */ + LOGE("Invalid parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + if (address_family != WIFI_MESH_ADDRESS_FAMILY_IPV4) { + LOGE("Invalid Address Family %d", address_family); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + } + + *ip_type = net->ipv4_type; + + return WIFI_MESH_ERROR_NONE; +} + +EXPORT_API int wifi_mesh_network_get_ip_address(wifi_mesh_network_h network, + wifi_mesh_address_family_e address_family, char **ip_address) +{ + struct mesh_network_s *net = (struct mesh_network_s *)network; + + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + if (NULL == network || ip_address == NULL) { + /* LCOV_EXCL_START */ + LOGE("Invalid parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + if (address_family != WIFI_MESH_ADDRESS_FAMILY_IPV4) { + LOGE("Invalid Address Family %d", address_family); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + } + + *ip_address = strdup(net->ipv4_address); + + return WIFI_MESH_ERROR_NONE; +} + +EXPORT_API int wifi_mesh_network_get_subnet_mask(wifi_mesh_network_h network, + wifi_mesh_address_family_e address_family, char **subnet_mask) +{ + struct mesh_network_s *net = (struct mesh_network_s *)network; + + CHECK_FEATURE_SUPPORTED(MESH_FEATURE); + + if (NULL == network || subnet_mask == NULL) { + /* LCOV_EXCL_START */ + LOGE("Invalid parameter"); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ + } + + if (address_family != WIFI_MESH_ADDRESS_FAMILY_IPV4) { + LOGE("Invalid Address Family %d", address_family); + return WIFI_MESH_ERROR_INVALID_PARAMETER; + } + + *subnet_mask = strdup(net->ipv4_netmask); + + return WIFI_MESH_ERROR_NONE; +} + EXPORT_API int wifi_mesh_peer_get_address(wifi_mesh_peer_h peer, char **address) { struct mesh_peer_s *peer_info = (struct mesh_peer_s *)peer; diff --git a/test/wifi-mesh-network.c b/test/wifi-mesh-network.c index 0d6b153..fa8b708 100644 --- a/test/wifi-mesh-network.c +++ b/test/wifi-mesh-network.c @@ -461,6 +461,9 @@ static int run_get_joined_mesh_network(MManager *mm, struct menu_data *menu) bool joined = false; wifi_mesh_connection_state_e _state = WIFI_MESH_CONNECTION_STATE_DISCONNECTED; wifi_mesh_security_type_e _security = MESH_SECURITY_NONE; + wifi_mesh_ip_config_type_e _ipv4_type = WIFI_MESH_IP_CONFIG_TYPE_UNKNOWN; + char *_ipv4_address = NULL; + char *_ipv4_netmask = NULL; wifi_mesh_network_h network = NULL; msg("Get Joined Mesh Network Information"); @@ -491,9 +494,20 @@ static int run_get_joined_mesh_network(MManager *mm, struct menu_data *menu) (MESH_SECURITY_SAE == _security) ? "SAE" : "NONE"); wifi_mesh_network_get_connection_state(network, &_state); msgb(" State = %s", wifi_mesh_connection_event_to_string(_state)); + wifi_mesh_network_get_ip_config_type(network, + WIFI_MESH_ADDRESS_FAMILY_IPV4, &_ipv4_type); + msgb(" IPv4 Config Type = %d", _ipv4_type); + wifi_mesh_network_get_ip_address(network, WIFI_MESH_ADDRESS_FAMILY_IPV4, + &_ipv4_address); + msgb(" IPv4 Address = %s", _ipv4_address); + wifi_mesh_network_get_subnet_mask(network, + WIFI_MESH_ADDRESS_FAMILY_IPV4, &_ipv4_netmask); + msgb(" IPv4 Subnet Mask = %s", _ipv4_netmask); if (_meshid) free(_meshid); if (_bssid) free(_bssid); + if (_ipv4_address) free(_ipv4_address); + if (_ipv4_netmask) free(_ipv4_netmask); } msg(""); msg(" - wifi_mesh_get_joined_network() ret: [0x%X] [%s]",