diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/connection_profile.h | 722 | ||||
-rwxr-xr-x | include/net_connection.h | 355 | ||||
-rw-r--r-- | include/net_connection_private.h | 62 |
3 files changed, 1014 insertions, 125 deletions
diff --git a/include/connection_profile.h b/include/connection_profile.h new file mode 100644 index 0000000..02cc11d --- /dev/null +++ b/include/connection_profile.h @@ -0,0 +1,722 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef __TIZEN_NETWORK_CONNECTION_PROFILE_H__ +#define __TIZEN_NETWORK_CONNECTION_PROFILE_H__ + +#include <tizen.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @addtogroup CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE +* @{ +*/ + +/** +* @brief Security type of Wi-Fi +*/ +typedef enum +{ + CONNECTION_WIFI_SECURITY_TYPE_NONE = 0, /**< Security disabled */ + CONNECTION_WIFI_SECURITY_TYPE_WEP = 1, /**< WEP */ + CONNECTION_WIFI_SECURITY_TYPE_WPA_PSK = 2, /**< WPA-PSK */ + CONNECTION_WIFI_SECURITY_TYPE_WPA2_PSK = 3, /**< WPA2-PSK */ + CONNECTION_WIFI_SECURITY_TYPE_EAP = 4, /**< EAP */ +} connection_wifi_security_type_e; + +/** +* @brief Below encryption modes are used in infrastructure and ad-hoc mode +*/ +typedef enum +{ + CONNECTION_WIFI_ENCRYPTION_TYPE_NONE = 0, /**< Encryption disabled */ + CONNECTION_WIFI_ENCRYPTION_TYPE_WEP = 1, /**< WEP */ + CONNECTION_WIFI_ENCRYPTION_TYPE_TKIP = 2, /**< TKIP */ + CONNECTION_WIFI_ENCRYPTION_TYPE_AES = 3, /**< AES */ + CONNECTION_WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED = 4, /**< TKIP and AES are both supported */ +} connection_wifi_encryption_type_e; + +/** +* @} +*/ + + +/** +* @addtogroup CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE +* @{ +*/ + +/** +* @brief This enumeration defines the cellular protocol type. +*/ +typedef enum +{ + CONNECTION_CELLULAR_NETWORK_TYPE_UNKNOWN = 0, /**< Not defined */ + CONNECTION_CELLULAR_NETWORK_TYPE_GPRS = 1, /**< GPRS type */ + CONNECTION_CELLULAR_NETWORK_TYPE_EDGE = 2, /**< EDGE type */ + CONNECTION_CELLULAR_NETWORK_TYPE_UMTS = 3, /**< UMTS type */ +} connection_cellular_network_type_e; + +/** +* @breif This enum indicates cellular service type +*/ +typedef enum +{ + CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN = 0, /**< Unknown */ + CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET = 1, /**< Established for Internet */ + CONNECTION_CELLULAR_SERVICE_TYPE_MMS = 2, /**< Established for MMS */ + CONNECTION_CELLULAR_SERVICE_TYPE_WAP = 3, /**< Established for WAP */ + CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET = 4, /**< Established for prepaid internet service */ + CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS = 5, /**< Established for prepaid MMS service */ +} connection_cellular_service_type_e; + +/** +* @brief Cellular Authentication Type +*/ +typedef enum +{ + CONNECTION_CELLULAR_AUTH_TYPE_NONE = 0, /**< No authentication */ + CONNECTION_CELLULAR_AUTH_TYPE_PAP = 1, /**< PAP authentication */ + CONNECTION_CELLULAR_AUTH_TYPE_CHAP = 2, /**< CHAP authentication */ +} connection_cellular_auth_type_e; + +/** +* @} +*/ + + +/** +* @addtogroup CAPI_NETWORK_CONNECTION_PROFILE_MODULE +* @{ +*/ + +/** +* @brief The handle of profile +*/ +typedef void* connection_profile_h; + +/** +* @brief This enumeration defines the profile state type. +*/ +typedef enum +{ + CONNECTION_PROFILE_STATE_DISCONNECTED = 0, /**< Disconnected state */ + CONNECTION_PROFILE_STATE_ASSOCIATION = 1, /**< Association state */ + CONNECTION_PROFILE_STATE_CONFIGURATION = 2, /**< Configuration state */ + CONNECTION_PROFILE_STATE_CONNECTED = 3, /**< Connected state */ +} connection_profile_state_e; + +/** +* @brief Enumerations of Address family +*/ +typedef enum +{ + CONNECTION_ADDRESS_FAMILY_IPV4 = 0, /**< IPV4 Address type */ + CONNECTION_ADDRESS_FAMILY_IPV6 = 1, /**< IPV6 Address type */ +} connection_address_family_e; + +/** +* @brief Net IP configuration Type +*/ +typedef enum +{ + CONNECTION_IP_CONFIG_TYPE_NONE = 0, /**< Not defined */ + CONNECTION_IP_CONFIG_TYPE_STATIC = 1, /**< Manual IP configuration */ + CONNECTION_IP_CONFIG_TYPE_DYNAMIC = 2, /**< Config IP using DHCP client*/ + CONNECTION_IP_CONFIG_TYPE_AUTO = 3, /**< Config IP from Auto IP pool (169.254/16). Later with DHCP client, if available */ + CONNECTION_IP_CONFIG_TYPE_FIXED = 4, /**< Indicates an IP address that can not be modified */ +} connection_ip_config_type_e; + +/** +* @brief This enumeration defines the proxy method type. +*/ +typedef enum +{ + CONNECTION_PROXY_TYPE_DIRECT = 0, /**< Direct connection */ + CONNECTION_PROXY_TYPE_AUTO = 1, /**< Auto configuration(Use PAC file). If URL property is not set, DHCP/WPAD auto-discover will be tried */ + CONNECTION_PROXY_TYPE_MANUAL = 2, /**< Manual configuration */ +} connection_proxy_type_e; + +/** +* @enum connection_profile_type_e +* @brief Enumerations of network connection type. +*/ +typedef enum{ + CONNECTION_PROFILE_TYPE_CELLULAR = 0, /**< Cellular type */ + CONNECTION_PROFILE_TYPE_WIFI = 1, /**< Wi-Fi type */ + CONNECTION_PROFILE_TYPE_ETHERNET = 2, /**< Ethernet type */ +} connection_profile_type_e; + +/** +* @brief Creates the profile handle. +* @remarks @a profile must be released with connection_profile_destroy(). +* @param[in] type The type of profile +* @param[out] profile The handle of the profile +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +* @see connection_profile_destroy() +*/ +int connection_profile_create(connection_profile_type_e type, connection_profile_h* profile); + +/** +* @brief Destroys the profile handle. +* @param[out] connection The handle to the connection +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @see connection_profile_create() +*/ +int connection_profile_destroy(connection_profile_h profile); + +/** +* @brief Clons the profile handle. +* @remarks @a cloned_profile must be released with connection_profile_destroy(). +* @param[in] origin_profile The handle of origin profile +* @param[out] cloned_profile The handle of cloned profile +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +* @see connection_profile_destroy() +*/ +int connection_profile_clone(connection_profile_h* cloned_profile, connection_profile_h origin_profile); + +/** +* @brief Gets the profile name. +* @remarks @a profile_name must be released with free() by you. +* @param[in] profile The handle of profile +* @param[out] profile_name The name of profile +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +*/ +int connection_profile_get_name(connection_profile_h profile, char** profile_name); + +/** +* @brief Gets the network type. +* @param[in] profile The handle of profile +* @param[out] type The type of profile +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e* type); + +/** +* @brief Gets the name of network interface. For example, eth0 and pdp0. +* @remarks @a interface_name must be released with free() by you. +* @param[in] profile The handle of profile +* @param[out] interface_name The name of network interface +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +*/ +int connection_profile_get_network_interface_name(connection_profile_h profile, char** interface_name); + +/** +* @brief Gets the network type. +* @param[in] profile The handle of profile +* @param[out] state The state of profile +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_state(connection_profile_h profile, connection_profile_state_e* state); + +/** +* @brief Gets the IP config type. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[out] type The type of IP config +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e* type); + +/** +* @brief Gets the IP address. +* @remarks @a ip_address must be released with free() by you. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[out] ip_address The IP address +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_ip_address(connection_profile_h profile, connection_address_family_e address_family, char** ip_address); + +/** +* @brief Gets the Subnet Mask. +* @remarks @a subnet_mask must be released with free() by you. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[out] subnet_mask The subnet mask +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_subnet_mask(connection_profile_h profile, connection_address_family_e address_family, char** subnet_mask); + +/** +* @brief Gets the Gateway address. +* @remarks @a gateway_address must be released with free() by you. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[out] gateway_address The gateway address +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_gateway_address(connection_profile_h profile, connection_address_family_e address_family, char** gateway_address); + +/** +* @brief Gets the DNS address. +* @remarks The allowance of DNS address is 2. @a dns_address must be released with free() by you. +* @param[in] profile The handle of profile +* @param[in] order The order of DNS address. It starts from 1, which means first DNS address. +* @param[in] address_family The address family +* @param[out] dns_address The DNS address +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_dns_address(connection_profile_h profile, int order, connection_address_family_e address_family, char** dns_address); + +/** +* @brief Gets the Proxy type. +* @param[in] profile The handle of profile +* @param[out] type The type of proxy +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e* type); + +/** +* @brief Gets the Proxy address. +* @remarks @a proxy_address must be released with free() by you. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[out] proxy_address The proxy address +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_proxy_address(connection_profile_h profile, connection_address_family_e address_family, char** proxy_address); + +/** +* @brief Sets the IP config type. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[in] type The type of IP config +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_set_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e type); + +/** +* @brief Sets the IP address. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[in] ip_address The IP address +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_set_ip_address(connection_profile_h profile, connection_address_family_e address_family, const char* ip_address); + +/** +* @brief Sets the Subnet Mask. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[in] subnet_mask The subnet mask +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_set_subnet_mask(connection_profile_h profile, connection_address_family_e address_family, const char* subnet_mask); + +/** +* @brief Sets the Gateway address. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[in] gateway_address The gateway address +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_set_gateway_address(connection_profile_h profile, connection_address_family_e address_family, const char* gateway_address); + +/** +* @brief Sets the DNS address. +* @remarks The allowance of DNS address is 2. +* @param[in] profile The handle of profile +* @param[in] order The order of DNS address. It starts from 1, which means first DNS address. +* @param[in] address_family The address family +* @param[in] dns_address The DNS address +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_set_dns_address(connection_profile_h profile, int order, connection_address_family_e address_family, const char* dns_address); + +/** +* @brief Sets the Proxy type. +* @param[in] profile The handle of profile +* @param[in] type The type of proxy +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_set_proxy_type(connection_profile_h profile, connection_proxy_type_e type); + +/** +* @brief Sets the Proxy address. +* @param[in] profile The handle of profile +* @param[in] address_family The address family +* @param[in] gateway_address The gateway address +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_set_proxy_address(connection_profile_h profile, connection_address_family_e address_family, const char* proxy_address); + +/** +* @brief Called when the state of profile is changed. +* @param[in] profile The handle of profile +* @param[in] is_requested Indicates whether this change is requested or not +* @param[in] user_data The user data passed from the callback registration function +* @see connection_profile_set_state_changed_cb() +* @see connection_profile_unset_state_changed_cb() +*/ +typedef void(*connection_profile_state_changed_cb)(connection_profile_h profile, bool is_requested, void* user_data); + +/** +* @brief Registers the callback called when the state of profile is changed. +* @param[in] profile The handle of profile +* @param[in] callback The callback function to be called +* @param[in] user_data The user data passed to the callback function +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @see connection_profile_state_changed_cb() +* @see connection_profile_unset_state_changed_cb() +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_set_state_changed_cb(connection_profile_h profile, connection_profile_state_changed_cb callback, void* user_data); + +/** +* @brief Unregisters the callback called when the state of profile is changed. +* @param[in] profile The handle of profile +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @see connection_profile_state_changed_cb() +* @see connection_profile_set_state_changed_cb() +*/ +int connection_profile_unset_state_changed_cb(connection_profile_h profile); + +/** +* @} +*/ + + +/** +* @addtogroup CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE +* @{ +*/ + +/** +* @brief Gets the ESSID(Extended Service Set Identifier). +* @remarks @a essid must be released with free() by you. +* @param[in] profile The handle of profile +* @param[out] essid The ESSID +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +*/ +int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid); + +/** +* @brief Gets the BSSID(Basic Service Set Identifier). +* @remarks @a bssid must be released with free() by you. +* @param[in] profile The handle of profile +* @param[out] bssid The BSSID +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +*/ +int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid); + +/** +* @brief Gets the RSSI. +* @param[in] profile The handle of profile +* @param[out] rssi The RSSI +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi); + +/** +* @brief Gets the frequency (MHz). +* @param[in] profile The handle of profile +* @param[out] frequency The frequency +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency); + +/** +* @brief Gets the max speed (Mbps). +* @param[in] profile The handle of profile +* @param[out] max_speed The max speed +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed); + +/** +* @brief Gets the security mode of Wi-Fi. +* @param[in] profile The handle of profile +* @param[out] type The type of Wi-Fi security +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e* type); + +/** +* @brief Gets the security mode of Wi-Fi. +* @param[in] profile The handle of profile +* @param[out] type The type of Wi-Fi security +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e* type); + +/** +* @brief Checks whether passphrase is required. +* @param[in] profile The handle of profile +* @param[out] required Indicates whether passphrase is required or not +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required); + +/** +* @brief Sets the passphrase of Wi-Fi WPA. +* @param[in] profile The handle of profile +* @param[in] passphrase The passphrase of Wi-Fi security +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase); + +/** +* @brief Checks whether WPS(Wi-Fi Protected Setup) is supported. +* @remarks If WPS is supported, you can connect access point with WPS by wifi_connect_with_wps(). +* @param[in] profile The handle of profile +* @param[out] supported Indicates whether WPS is supported or not +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported); + +/** +* @} +*/ + + +/** +* @addtogroup CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE +* @{ +*/ + +/** +* @brief Gets the cellular network type. +* @param[in] profile The handle of profile +* @param[out] type The type of cellular +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_cellular_network_type(connection_profile_h profile, connection_cellular_network_type_e* type); + +/** +* @brief Gets the service type. +* @param[in] profile The handle of profile +* @param[out] type The type of cellular service +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_cellular_service_type(connection_profile_h profile, connection_cellular_service_type_e* type); + +/** +* @brief Gets the APN(access point name). +* @remarks @a apn must be released with free() by you. +* @param[in] profile The handle of profile +* @param[out] apn The name of APN +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +*/ +int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn); + +/** +* @brief Gets the authentication information. +* @remarks @a user_name and @a password must be released with free() by you. +* @param[in] profile The handle of profile +* @param[out] type The type of authentication +* @param[out] user_name The user name +* @param[out] password The password +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e* type, char** user_name, char** password); + +/** +* @brief Gets the home URL. +* @remarks @a home_url must be released with free() by you. +* @param[in] profile The handle of profile +* @param[out] home_url The home URL +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +*/ +int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url); + +/** +* @brief Gets the state of roaming. +* @param[in] profile The handle of profile +* @param[out] is_roaming Indicates whether cellular is in roaming or not +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming); + +/** +* @brief Sets the service type. +* @param[in] profile The handle of profile +* @param[out] type The type of cellular service +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_set_cellular_service_type(connection_profile_h profile, connection_cellular_service_type_e service_type); + +/** +* @brief Sets the APN(Access Point Name). +* @param[in] profile The handle of profile +* @param[out] apn The name of APN +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn); + +/** +* @brief Sets the Athentication information. +* @param[in] profile The handle of profile +* @param[out] type The type of authentication +* @param[out] user_name The user name +* @param[out] password The password +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_set_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e type, const char* user_name, const char* password); + +/** +* @brief Sets the home URL. +* @param[in] profile The handle of profile +* @param[out] home_url The home URL +* @return 0 on success, otherwise negative error value. +* @retval #CONNECTION_ERROR_NONE Successful +* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter +*/ +int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url); + +/** +* @} +*/ + + +#ifdef __cplusplus +} + +#endif + +#endif /* __TIZEN_NETWORK_CONNECTION_PROFILE_H__ */ diff --git a/include/net_connection.h b/include/net_connection.h index 6159cfa..3963d48 100755 --- a/include/net_connection.h +++ b/include/net_connection.h @@ -18,49 +18,41 @@ #ifndef __NET_CONNECTION_INTF_H__ /* To prevent inclusion of a header file twice */ #define __NET_CONNECTION_INTF_H__ -#include <tizen.h> +#include "connection_profile.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +#ifndef DEPRECATED +#define DEPRECATED __attribute__((deprecated)) +#endif /** - * @addtogroup CAPI_NETWORK_CONNECTION_MODULE + * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE * @{ */ - /** - * @brief Enumerations of connection errors. - */ -typedef enum -{ - CONNECTION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - CONNECTION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - CONNECTION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */ - CONNECTION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */ - CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */ -}connection_error_e; + * @brief The connection handle for all connection functions. +*/ +typedef void* connection_h; /** - * @brief Enumerations of network status. - */ -typedef enum -{ - CONNECTION_NETWORK_STATE_DISCONNECTED = 0, /**< Disconnected */ - CONNECTION_NETWORK_STATE_WIFI = 1, /**< Wi-Fi is used for default connection */ - CONNECTION_NETWORK_STATE_CELLULAR = 2, /**< Cellular is used for default connection */ -}connection_network_state_e; + * @brief The iterator handle for profiles. +*/ +typedef void* connection_profile_iterator_h; /** - * @brief Enumerations of Address type + * @brief Enumerations of connection type. */ typedef enum { - CONNECTION_ADDRESS_FAMILY_IPV4 = 0, /**< IPV4 Address type */ - CONNECTION_ADDRESS_FAMILY_IPV6 = 1, /**< IPV6 Address type */ -} connection_address_family_e; + CONNECTION_TYPE_DISCONNECTED = 0, /**< Disconnected */ + CONNECTION_TYPE_WIFI = 1, /**< Wi-Fi is used for default connection */ + CONNECTION_TYPE_CELLULAR = 2, /**< Cellular is used for default connection */ + CONNECTION_TYPE_ETHERNET = 3, /**< Ethernet is used for default connection */ +} connection_type_e; /** * @brief Enumerations of cellular network state. @@ -72,7 +64,7 @@ typedef enum CONNECTION_CELLULAR_STATE_ROAMING_OFF = 2, /**< Roaming is turned off */ CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE = 3, /**< Call is only available. */ CONNECTION_CELLULAR_STATE_AVAILABLE = 4, /**< Available */ -}connection_cellular_state_e; +} connection_cellular_state_e; /** * @brief This enumeration defines the Wi-Fi state. @@ -85,35 +77,73 @@ typedef enum } connection_wifi_state_e; /** - * @brief The connection handle for all connection functions. -*/ -typedef struct connection_handle_s * connection_h; + * @brief This enumeration defines the ethernet state. + */ +typedef enum +{ + CONNECTION_ETHERNET_STATE_DEACTIVATED = 0, /**< Deactivated state */ + CONNECTION_ETHERNET_STATE_DISCONNECTED = 1, /**< disconnected state */ + CONNECTION_ETHERNET_STATE_CONNECTED = 2, /**< Connected state */ +} connection_ethernet_state_e; /** - * @brief Called when the state of network is changed. - * @param[in] connection_network_state_e The state of current network connection - * @param[in] user_data The user data passed from the callback registration function - * @see connection_set_network_status_changed_cb() - * @see connection_unset_network_status_changed_cb() + * @brief This enumeration defines the type of connection iterator. */ -typedef void(*connection_network_state_changed_cb)(connection_network_state_e state, void* user_data); +typedef enum +{ + CONNECTION_ITERATOR_TYPE_REGISTERED = 0, /**< The iterator of registered profile */ + CONNECTION_ITERATOR_TYPE_CONNECTED = 1, /**< The iterator of connected profile */ +} connection_iterator_type_e; /** - * @brief Called when the address is changed. - * @param[in] ipv4_address The ipv4 address of current network connection - * @param[in] ipv6_address The ipv6 address of current network connection - * @param[in] user_data The user data passed from the callback registration function - * @see connection_set_ip_address_changed_cb() - * @see connection_unset_ip_address_changed_cb() - * @see connection_set_proxy_address_changed_cb() - * @see connection_unset_proxy_address_changed_cb() + * @brief Enumerations of connection errors. */ -typedef void(*connection_address_changed_cb)(const char* ipv4_address, const char* ipv6_address, void* user_data); +typedef enum +{ + CONNECTION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + CONNECTION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + CONNECTION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */ + CONNECTION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */ + CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */ + CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0401, /**< Operation failed */ + CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_NETWORK_CLASS|0x0402, /**< End of iteration */ + CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_NETWORK_CLASS|0x0403, /**< There is no connection */ +} connection_error_e; + +/** + * @} +*/ + +/** + * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE + * @{ +*/ + +/** + * @brief Enumerations of statistics type. + */ +typedef enum +{ + CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA = 0, /**< Last received data */ + CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA = 1, /**< Last sent data */ + CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA = 2, /**< Total received data */ + CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA = 3, /**< Total sent data */ +} connection_statistics_type_e; + +/** + * @} +*/ + +/** + * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE + * @{ +*/ + /** * @brief Creates a handle for managing data connections. * @remarks @a handle must be released with connection_destroy(). - * @param[out] connection The handle to the connection + * @param[out] connection The handle of the connection * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter @@ -124,7 +154,7 @@ int connection_create(connection_h* connection); /** * @brief Destroys the connection handle. - * @param[in] connection The handle to the connection + * @param[in] connection The handle of the connection * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter @@ -133,40 +163,64 @@ int connection_create(connection_h* connection); int connection_destroy(connection_h connection); /** - * @brief Gets the network state. - * @details The returned status is for the current connection. - * @param[in] connection The handle to the connection + * @brief Called when the type of connection is changed. + * @param[in] type The type of current network connection + * @param[in] user_data The user data passed from the callback registration function + * @see connection_set_network_type_changed_cb() + * @see connection_unset_network_type_changed_cb() + */ +typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_data); + +/** + * @brief Called when the address is changed. + * @param[in] ipv4_address The IP address for IPv4 + * @param[in] ipv6_address The IP address for IPv6 + * @param[in] user_data The user data passed from the callback registration function + * @see connection_set_ip_address_changed_cb() + * @see connection_unset_ip_address_changed_cb() + * @see connection_set_proxy_address_changed_cb() + * @see connection_unset_proxy_address_changed_cb() + */ +typedef void(*connection_address_changed_cb)(const char* ipv4_address, const char* ipv6_address, void* user_data); + + +/** + * @brief Gets the type. + * @details The returned type is for the current connection. + * @param[in] connection The handle of the connection * @param[out] state The state of network * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the state due to internal error + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ -int connection_get_network_state(connection_h connection, connection_network_state_e* state); +int connection_get_type(connection_h connection, connection_type_e* type); /** * @brief Gets the IP address of the current connection. * @remarks @a ip_address must be released with free() by you. - * @param[in] connection The handle to the connection + * @param[in] connection The handle of the connection * @param[in] address_family The address family * @param[out] ip_address The pointer to IP address string. * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the ip address due to internal error + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family */ int connection_get_ip_address(connection_h connection, connection_address_family_e address_family, char** ip_address); /** * @brief Gets the proxy address of the current connection. * @remarks @a proxy must be released with free() by you. - * @param[in] connection The handle to the connection + * @param[in] connection The handle of the connection * @param[in] address_family The address family * @param[out] proxy The proxy address * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the proxy due to internal error + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family */ int connection_get_proxy(connection_h connection, connection_address_family_e address_family, char** proxy); @@ -178,7 +232,7 @@ int connection_get_proxy(connection_h connection, connection_address_family_e ad * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the state due to internal error + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state); @@ -190,47 +244,63 @@ int connection_get_cellular_state(connection_h connection, connection_cellular_s * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the state due to internal error + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state); /** - * @brief Registers the callback called when the state of current connection is changed. + * @brief Gets the state of ethernet. + * @details The returned state is for the ethernet connection state. + * @param[in] connection The handle of connection + * @param[out] state The state of Ethernet connection + * @return 0 on success, otherwise negative error value. + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + */ +int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state); + +/** + * @brief Registers the callback called when the type of current connection is changed. * @param[in] connection The handle of connection * @param[in] callback The callback function to be called * @param[in] user_data The user data passed to the callback function * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ -int connection_set_network_state_changed_cb(connection_h connection, connection_network_state_changed_cb callback, void* user_data); +int connection_set_type_changed_cb(connection_h connection, connection_type_changed_cb callback, void* user_data); /** - * @brief Unregisters the callback called when the state of current connection is changed. + * @brief Unregisters the callback called when the type of current connection is changed. * @param[in] connection The handle of connection * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ -int connection_unset_network_state_changed_cb(connection_h connection); +int connection_unset_type_changed_cb(connection_h connection); /** - * @brief Registers the callback called when the ip address is changed. + * @brief Registers the callback called when the IP address is changed. * @param[in] connection The handle of connection * @param[in] callback The callback function to be called * @param[in] user_data The user data passed to the callback function * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ int connection_set_ip_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data); /** - * @brief Unregisters the callback called when the ip address is changed. + * @brief Unregisters the callback called when the IP address is changed. * @param[in] connection The handle of connection * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ int connection_unset_ip_address_changed_cb(connection_h connection); @@ -242,6 +312,7 @@ int connection_unset_ip_address_changed_cb(connection_h connection); * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ int connection_set_proxy_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data); @@ -251,97 +322,165 @@ int connection_set_proxy_address_changed_cb(connection_h connection, connection_ * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ int connection_unset_proxy_address_changed_cb(connection_h connection); /** - * @brief Gets the received data size of the last cellular packet data connection. - * @param[in] connection The handle to the connection - * @param[out] size The received data size of the last cellular packet data connection ( bytes ) + * @brief Adds new profile which is created by connection_profile_created(). + * @param[in] connection The handle of connection + * @param[in] profile The handle of profile * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the size due to internal error + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ -int connection_get_last_received_data_size(connection_h connection, int* size); +int connection_add_profile(connection_h connection, connection_profile_h profile); /** - * @brief Gets the sent data size of the last cellular packet data connection. - * @param[in] connection The handle to the connection - * @param[out] size The sent data size of the last cellular packet data connection. + * @brief Removes existing profile. + * @param[in] connection The handle of connection + * @param[in] profile The handle of profile * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the size due to internal error + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ -int connection_get_last_sent_data_size(connection_h connection, int* size); +int connection_remove_profile(connection_h connection, connection_profile_h profile); /** - * @brief Gets the total received data size of all cellular packet data connections. - * @param[in] connection The handle to the connection - * @param[out] size The total received data size of all cellular packet data connections (bytes) + * @brief Updates existing profile. + * @param[in] connection The handle of connection + * @param[in] profile The handle of profile * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the size due to internal error + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ -int connection_get_total_received_data_size (connection_h connection, int* size); +int connection_update_profile(connection_h connection, connection_profile_h profile); /** - * @brief Gets the total sent data size of all cellular packet data connections. - * @param[in] connection The handle to the connection - * @param[out] size The total sent data size of all cellular packet data connections (bytes) + * @brief Gets a iterator of the profiles. + * @remarks @a profile_iterator must be released with connection_destroy(). + * @param[in] connection The handle of connection + * @param[in] type The type of connetion iterator + * @param[out] profile_iterator The iterator of profile * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the size due to internal error + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ -int connection_get_total_sent_data_size (connection_h connection, int* size); +int connection_get_profile_iterator(connection_h connection, connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator); /** - * @brief Gets the received data size of the last Wi-Fi packet data connection. - * @param[in] connection The handle to the connection - * @param[out] size The received data size of the last Wi-Fi packet data connection ( bytes ) + * @brief Moves the profile iterator to the next position and gets a profile handle. + * @param[in] profile_iterator The iterator of profile + * @param[out] profile The handle of profile * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the size due to internal error + * @retval #CONNECTION_ERROR_ITERATOR_END End of iteration */ -int connection_get_wifi_last_received_data_size(connection_h connection, int* size); +int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, connection_profile_h* profile); /** - * @brief Gets the sent data size of the last Wi-Fi packet data connection. - * @param[in] connection The handle to the connection - * @param[out] size The sent data size of the last Wi-Fi packet data connection. + * @brief Checks whether the next element of profile iterator exists or not. + * @param[in] profile_iterator The iterator of profile + * @return @c true if next element exists, \n @c false if next element doesn't exist + */ +bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator); + +/** + * @brief Destroys a iterator of the profiles. + * @param[in] profile_iterator The iterator of profile * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the size due to internal error */ -int connection_get_wifi_last_sent_data_size(connection_h connection, int* size); +int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator); /** - * @brief Gets the total received data size of all Wi-Fi packet data connections. - * @param[in] connection The handle to the connection - * @param[out] size The total received data size of all Wi-Fi packet data connections (bytes) + * @brief Gets the name of default profile. + * @remarks @a profile must be released with connection_profile_destroy(). + * @param[in] connection The handle of connection + * @param[out] profile The handle of profile * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the size due to internal error + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_NO_CONNECTION There is no connection */ -int connection_get_wifi_total_received_data_size (connection_h connection, int* size); +int connection_get_current_profile(connection_h connection, connection_profile_h* profile); /** - * @brief Gets the total sent data size of all Wi-Fi packet data connections. - * @param[in] connection The handle to the connection - * @param[out] size The total sent data size of all Wi-Fi packet data connections (bytes) + * @brief Opens the connection with the profile, asynchronously. + * @param[in] connection The handle of connection + * @param[in] profile The handle of profile * @return 0 on success, otherwise negative error value. * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_INVALID_OPERATION Cannot retrieve the size due to internal error + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed */ -int connection_get_wifi_total_sent_data_size (connection_h connection, int* size); +int connection_open_profile(connection_h connection, connection_profile_h profile); +/** + * @brief Opens the connection with service type, asynchronously. + * @remarks @a profile must be released with connection_profile_destroy(). + * @param[in] connection The handle of connection + * @param[in] type The type of cellular service + * @param[out] profile The handle of profile + * @return 0 on success, otherwise negative error value. + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + */ +int connection_open_cellular_service_type(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile); + +/** + * @brief Closes the connection with the profile. + * @param[in] connection The handle of connection + * @param[in] profile The handle of profile + * @return 0 on success, otherwise negative error value. + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + */ +int connection_close_profile(connection_h connection, connection_profile_h profile); + +/** + * @} +*/ + +/** + * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE + * @{ +*/ + +/** + * @brief Gets the statistics information. + * @param[in] connection_type The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported. + * @param[in] statistics_type The type of statistics + * @param[out] size The received data size of the last cellular packet data connection (bytes) + * @return 0 on success, otherwise negative error value. + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + */ +int connection_get_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* size); + +/** + * @brief Resets the statistics information + * @param[in] connection_type The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported. + * @param[in] statistics_type The type of statistics + * @return 0 on success, otherwise negative error value. + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + */ +int connection_reset_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type); /** * @} diff --git a/include/net_connection_private.h b/include/net_connection_private.h index b74d6a1..40f198c 100644 --- a/include/net_connection_private.h +++ b/include/net_connection_private.h @@ -19,7 +19,23 @@ #ifndef __NET_CONNECTION_PRIVATE_H__ /* To prevent inclusion of a header file twice */ #define __NET_CONNECTION_PRIVATE_H__ -#include <net_connection.h> +#include <dlog.h> +#include <network-cm-intf.h> +#include <network-wifi-intf.h> +#include "net_connection.h" + +#define TIZEN_NET_CONNECTION "net_connection" + +#define CONNECTION_INFO LOG_VERBOSE +#define CONNECTION_ERROR LOG_ERROR +#define CONNECTION_WARN LOG_WARN + +#define CONNECTION_LOG(log_level, format, args...) \ + SLOG(log_level,TIZEN_NET_CONNECTION, "[%s][Ln: %d] " format, __FILE__, __LINE__, ##args) + +#define CONNECTION_MUTEX_LOCK _connection_inter_mutex_lock() + +#define CONNECTION_MUTEX_UNLOCK _connection_inter_mutex_unlock() #ifdef __cplusplus extern "C" { @@ -27,7 +43,7 @@ extern "C" { typedef struct _connection_handle_s { - connection_network_state_changed_cb state_changed_callback; + connection_type_changed_cb state_changed_callback; connection_address_changed_cb ip_changed_callback; connection_address_changed_cb proxy_changed_callback; void *state_changed_user_data; @@ -35,21 +51,33 @@ typedef struct _connection_handle_s void *proxy_changed_user_data; } connection_handle_s; -/** - * @internal - * @brief same as number of callbacks in connection_event_callbacks_s - */ -typedef enum -{ - LAST_SENT_DATA_SIZE, - LAST_RECEIVED_DATA_SIZE, - TOTAL_SENT_DATA_SIZE, - TOTAL_RECEIVED_DATA_SIZE, - LAST_WIFI_SENT_DATA_SIZE, - LAST_WIFI_RECEIVED_DATA_SIZE, - TOTAL_WIFI_SENT_DATA_SIZE, - TOTAL_WIFI_RECEIVED_DATA_SIZE, -} stat_request_e; + +bool _connection_libnet_init(void); +bool _connection_libnet_deinit(void); +bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state); +bool _connection_libnet_check_profile_validity(connection_profile_h profile); +int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, + connection_profile_iterator_h* profile_iterator); +bool _connection_libnet_iterator_has_next(connection_profile_iterator_h profile_iterator); +int _connection_libnet_get_iterator_next(connection_profile_iterator_h profile_iter_h, connection_profile_h *profile); +int _connection_libnet_destroy_iterator(connection_profile_iterator_h profile_iter_h); +int _connection_libnet_get_current_profile(connection_profile_h *profile); +int _connection_libnet_open_profile(connection_profile_h profile); +int _connection_libnet_open_cellular_service_type(connection_cellular_service_type_e type, connection_profile_h *profile); +int _connection_libnet_close_profile(connection_profile_h profile); +void _connection_libnet_add_to_profile_list(connection_profile_h profile); +void _connection_libnet_remove_from_profile_list(connection_profile_h profile); +bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile, + connection_profile_state_changed_cb callback, void *user_data); +void _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile); +int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type); +int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size); + +net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(connection_cellular_service_type_e svc_type); +net_state_type_t _connection_profile_convert_to_net_state(connection_profile_state_e state); + +void _connection_inter_mutex_lock(void); +void _connection_inter_mutex_unlock(void); #ifdef __cplusplus } |