#include <vconf/vconf.h>
#include "net_connection_private.h"
+#include "connection_extension.h"
#define HTTP_PROXY "http_proxy"
#define MAX_PREFIX_LENGTH 6
return &profile_info->ProfileInfo.Ethernet.net_info; //LCOV_EXCL_LINE
case NET_DEVICE_BLUETOOTH:
return &profile_info->ProfileInfo.Bluetooth.net_info;
+ case NET_DEVICE_MESH:
+ return &profile_info->ProfileInfo.Mesh.net_info;
case NET_DEVICE_DEFAULT:
case NET_DEVICE_USB:
case NET_DEVICE_UNKNOWN:
/* Connection profile ********************************************************/
EXPORT_API int connection_profile_create(connection_profile_type_e type, const char* keyword, connection_profile_h* profile)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
if (type == CONNECTION_PROFILE_TYPE_CELLULAR)
if (type != CONNECTION_PROFILE_TYPE_CELLULAR &&
type != CONNECTION_PROFILE_TYPE_WIFI) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
int rv = _connection_libnet_check_profile_privilege();
- if (rv == CONNECTION_ERROR_PERMISSION_DENIED)
- return rv;
- else if (rv != CONNECTION_ERROR_NONE) {
+ if (rv == CONNECTION_ERROR_PERMISSION_DENIED) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return rv; //LCOV_EXCL_LINE
+ } else if (rv != CONNECTION_ERROR_NONE) {
CONNECTION_LOG(CONNECTION_ERROR, "Failed to create profile"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
net_profile_info_t *profile_info = g_try_malloc0(sizeof(net_profile_info_t));
- if (profile_info == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (profile_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
- switch (type) {
- case CONNECTION_PROFILE_TYPE_CELLULAR:
+ if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
if (keyword == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
g_free(profile_info);
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
__profile_init_cellular_profile(profile_info, keyword);
- break;
- case CONNECTION_PROFILE_TYPE_WIFI:
+ } else if (type == CONNECTION_PROFILE_TYPE_WIFI) {
__profile_init_wifi_profile(profile_info);
- break;
- default:
- break;
}
*profile = (connection_profile_h)profile_info;
_connection_libnet_add_to_profile_list(*profile);
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_destroy(connection_profile_h profile)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile))) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
_connection_libnet_remove_from_profile_list(profile);
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_clone(connection_profile_h* cloned_profile, connection_profile_h origin_profile)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(origin_profile)) || cloned_profile == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
*cloned_profile = g_try_malloc0(sizeof(net_profile_info_t));
- if (*cloned_profile == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*cloned_profile == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
memcpy(*cloned_profile, origin_profile, sizeof(net_profile_info_t));
_connection_libnet_add_to_profile_list(*cloned_profile);
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_id(connection_profile_h profile, char** profile_id)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || profile_id == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
char *prof_id = strrchr(profile_info->ProfileName, '/');
- if (prof_id == NULL)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ if (prof_id == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
prof_id++;
*profile_id = g_strdup(prof_id);
- if (*profile_id == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*profile_id == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_name(connection_profile_h profile, char** profile_name)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || profile_name == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
break; //LCOV_EXCL_LINE
case NET_DEVICE_BLUETOOTH: {
char *bt_name = strrchr(profile_info->ProfileName, '/');
- if (bt_name == NULL)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ if (bt_name == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
bt_name++;
*profile_name = g_strdup(bt_name);
} break;
+ case NET_DEVICE_MESH:
+ *profile_name = g_strdup(profile_info->ProfileInfo.Mesh.essid);
+ break;
default:
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
- if (*profile_name == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*profile_name == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e *type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
case NET_DEVICE_BLUETOOTH:
*type = CONNECTION_PROFILE_TYPE_BT;
break;
+ case NET_DEVICE_MESH:
+ *type = CONNECTION_PROFILE_TYPE_MESH;
+ break;
default:
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type");
- return CONNECTION_ERROR_OPERATION_FAILED;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_network_interface_name(connection_profile_h profile, char** interface_name)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || interface_name == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
*interface_name = g_strdup(net_info->DevName);
- if (*interface_name == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*interface_name == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
{
int rv;
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile))) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t profile_info_local;
net_profile_info_t *profile_info = profile;
- rv = net_get_profile_info(profile_info->ProfileName, &profile_info_local);
+ rv = net_get_profile_info(NULL, profile_info->ProfileName, &profile_info_local);
if (rv == NET_ERR_ACCESS_DENIED) {
CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
} else if (rv != NET_ERR_NONE) {
CONNECTION_LOG(CONNECTION_ERROR, "Failed to get profile information"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
memcpy(profile, &profile_info_local, sizeof(net_profile_info_t));
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_state(connection_profile_h profile, connection_profile_state_e* state)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || state == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
*state = _profile_convert_to_cp_state(profile_info->ProfileState);
+ CONN_UNLOCK;
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_internet_state(connection_profile_h profile,
+ connection_internet_state_e *state)
+{
+ CONN_LOCK;
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (!(_connection_libnet_check_profile_validity(profile)) || state == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *profile_info = profile;
+ if (profile_info->ProfileState == NET_STATE_TYPE_ONLINE)
+ *state = CONNECTION_INTERNET_STATE_ONLINE;
+ else
+ *state = CONNECTION_INTERNET_STATE_OFFLINE;
+
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
{
net_ip_config_type_t profile_type;
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
type == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
profile_type = net_info->IpConfigType;
*type = CONNECTION_IP_CONFIG_TYPE_NONE;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_OPERATION_FAILED;
//LCOV_EXCL_STOP
}
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_OPERATION_FAILED;
}
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile,
connection_address_family_e address_family, char** ip_address)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
ip_address == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr6,
- address_family);
- else
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
*ip_address = __profile_convert_ip_to_string(&net_info->IpAddr,
address_family);
+ } else {
+ if (net_get_preferred_ipv6_address(net_info->ProfileName, ip_address) != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get preferred ipv6 address"); //LCOV_EXCL_LINE
+ *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr6, //LCOV_EXCL_LINE
+ address_family);
+ }
+ }
- if (*ip_address == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*ip_address == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile,
connection_address_family_e address_family, char** subnet_mask)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
subnet_mask == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
- CONNECTION_LOG(CONNECTION_ERROR,
+ CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
"Please uses connection_profile_get_prefix_length()");
- return CONNECTION_ERROR_NOT_SUPPORTED;
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
*subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask,
address_family);
- if (*subnet_mask == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*subnet_mask == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profile,
connection_address_family_e address_family, char** gateway_address)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
gateway_address == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
*gateway_address = __profile_convert_ip_to_string(
*gateway_address = __profile_convert_ip_to_string(
&net_info->GatewayAddr, address_family);
- if (*gateway_address == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*gateway_address == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
connection_profile_h profile,
connection_address_family_e address_family, char** dhcp_server)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
CONNECTION_LOG(CONNECTION_ERROR, "Not supported");
+ CONN_UNLOCK;
return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
}
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4) ||
dhcp_server == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
CONNECTION_LOG(CONNECTION_INFO, "IP Config %d, DHCP Server Address %s",
net_info->IpConfigType, (net_info->BServerAddr ? "TRUE" : "FALSE"));
*dhcp_server = __profile_convert_ip_to_string(&net_info->ServerAddr,
address_family);
- if (*dhcp_server == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*dhcp_server == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
connection_profile_h profile,
connection_address_family_e address_family, int* dhcp_lease_duration)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
dhcp_lease_duration == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
CONNECTION_LOG(CONNECTION_ERROR, "Not supported");
+ CONN_UNLOCK;
return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
CONNECTION_LOG(CONNECTION_INFO, "Lease duration : %d",
net_info->DHCPLeaseDuration);
*dhcp_lease_duration = net_info->DHCPLeaseDuration;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, int order,
connection_address_family_e address_family, char** dns_address)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
order <= 0 ||
order > NET_DNS_ADDR_MAX) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
*dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr[order-1],
*dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr6[order-1], //LCOV_EXCL_LINE
address_family);
- if (*dns_address == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*dns_address == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e *type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
//LCOV_EXCL_START
if (profile_info->profile_type == NET_DEVICE_ETHERNET) {
free(proxy);
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
//LCOV_EXCL_STOP
break;
case NET_PROXY_TYPE_UNKNOWN:
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_OPERATION_FAILED;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_proxy_address(connection_profile_h profile,
connection_address_family_e address_family, char** proxy_address)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
proxy_address == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
*proxy_address = g_strdup(net_info->ProxyAddr);
- if (*proxy_address == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*proxy_address == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
{
net_ip_config_type_t *profile_type = NULL;
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
profile_type = &net_info->IpConfigType ;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
//LCOV_EXCL_STOP
}
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_ip_address(connection_profile_h profile,
connection_address_family_e address_family, const char* ip_address)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
//LCOV_EXCL_START
if (ip_address == NULL)
inet_pton(AF_INET6, "::", &net_info->IpAddr6.Data.Ipv6);
- else if (inet_pton(AF_INET6, ip_address,
- &net_info->IpAddr6.Data.Ipv6) < 1)
+ else if (inet_pton(AF_INET6, ip_address, &net_info->IpAddr6.Data.Ipv6) < 1) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
//LCOV_EXCL_STOP
} else {
if (ip_address == NULL)
net_info->IpAddr.Data.Ipv4.s_addr = 0;
- else if (inet_pton(AF_INET, ip_address,
- &net_info->IpAddr.Data.Ipv4) < 1)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ else if (inet_pton(AF_INET, ip_address, &net_info->IpAddr.Data.Ipv4) < 1) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile,
connection_address_family_e address_family, const char* subnet_mask)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
- CONNECTION_LOG(CONNECTION_ERROR,
+ CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE
"Please uses connection_profile_set_prefix_length()");
- return CONNECTION_ERROR_NOT_SUPPORTED;
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (subnet_mask == NULL)
net_info->SubnetMask.Data.Ipv4.s_addr = 0;
- else if (inet_pton(AF_INET, subnet_mask , &net_info->SubnetMask.Data.Ipv4) < 1)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ else if (inet_pton(AF_INET, subnet_mask , &net_info->SubnetMask.Data.Ipv4) < 1) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
net_info->PrefixLen = __profile_convert_netmask_to_prefix_len(subnet_mask);
if (net_info->PrefixLen <= 0 || net_info->PrefixLen > 31) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid Prefix length: %d", net_info->PrefixLen);
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid Prefix length: %d", net_info->PrefixLen); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_gateway_address(connection_profile_h profile,
connection_address_family_e address_family, const char* gateway_address)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
//LCOV_EXCL_START
if (gateway_address == NULL)
inet_pton(AF_INET6, "::", &net_info->GatewayAddr6.Data.Ipv6);
- else if (inet_pton(AF_INET6, gateway_address, &net_info->GatewayAddr6.Data.Ipv6) < 1)
+ else if (inet_pton(AF_INET6, gateway_address, &net_info->GatewayAddr6.Data.Ipv6) < 1) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
//LCOV_EXCL_STOP
} else {
if (gateway_address == NULL)
net_info->GatewayAddr.Data.Ipv4.s_addr = 0;
- else if (inet_pton(AF_INET, gateway_address, &(net_info->GatewayAddr.Data.Ipv4)) < 1)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ else if (inet_pton(AF_INET, gateway_address, &(net_info->GatewayAddr.Data.Ipv4)) < 1) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile, int order,
connection_address_family_e address_family, const char* dns_address)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
order <= 0 ||
order > NET_DNS_ADDR_MAX) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
//LCOV_EXCL_START
net_info->DnsAddr6[order-1].Type = NET_ADDR_IPV6;
if (dns_address == NULL)
inet_pton(AF_INET6, "::", &net_info->DnsAddr6[order-1].Data.Ipv6);
- else if (inet_pton(AF_INET6, dns_address, &net_info->DnsAddr6[order-1].Data.Ipv6) < 1)
+ else if (inet_pton(AF_INET6, dns_address, &net_info->DnsAddr6[order-1].Data.Ipv6) < 1) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
if (net_info->DnsCount6 < order)
net_info->DnsCount6 = order;
//LCOV_EXCL_STOP
net_info->DnsAddr[order-1].Type = NET_ADDR_IPV4;
if (dns_address == NULL)
net_info->DnsAddr[order-1].Data.Ipv4.s_addr = 0;
- else if (inet_pton(AF_INET, dns_address, &(net_info->DnsAddr[order-1].Data.Ipv4)) < 1)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ else if (inet_pton(AF_INET, dns_address, &(net_info->DnsAddr[order-1].Data.Ipv4)) < 1) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
if (net_info->DnsCount < order)
net_info->DnsCount = order;
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_proxy_type(connection_profile_h profile, connection_proxy_type_e type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile))) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
switch (type) {
//LCOV_EXCL_START
net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
{
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
- CONNECTION_LOG(CONNECTION_ERROR, "Address Family: ", address_family);
+ CONNECTION_LOG(CONNECTION_ERROR, "Address Family: %d", address_family);
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (proxy_address == NULL)
net_info->ProxyAddr[0] = '\0';
else
g_strlcpy(net_info->ProxyAddr, proxy_address, NET_PROXY_LEN_MAX);
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_state_changed_cb(connection_profile_h profile,
connection_profile_state_changed_cb callback, void* user_data)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || callback == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (_connection_libnet_add_to_profile_cb_list(profile, callback, user_data))
+ if (_connection_libnet_add_to_profile_cb_list(profile, callback, user_data)) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
+ }
+ CONN_UNLOCK; //LCOV_EXCL_LINE
return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
EXPORT_API int connection_profile_unset_state_changed_cb(connection_profile_h profile)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile))) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (_connection_libnet_remove_from_profile_cb_list(profile) != true)
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ if (_connection_libnet_remove_from_profile_cb_list(profile) != true) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
/* Wi-Fi profile *************************************************************/
EXPORT_API int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || essid == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ if (profile_info->profile_type != NET_DEVICE_WIFI &&
+ profile_info->profile_type != NET_DEVICE_MESH) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
- *essid = g_strdup(profile_info->ProfileInfo.Wlan.essid);
- if (*essid == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (profile_info->profile_type == NET_DEVICE_WIFI)
+ *essid = g_strdup(profile_info->ProfileInfo.Wlan.essid);
+ else
+ *essid = g_strdup(profile_info->ProfileInfo.Mesh.essid);
+ if (*essid == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || bssid == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ if (profile_info->profile_type != NET_DEVICE_WIFI &&
+ profile_info->profile_type != NET_DEVICE_MESH) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
- *bssid = g_strdup(profile_info->ProfileInfo.Wlan.bssid);
- if (*bssid == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (profile_info->profile_type == NET_DEVICE_WIFI)
+ *bssid = g_strdup(profile_info->ProfileInfo.Wlan.bssid);
+ else
+ *bssid = g_strdup(profile_info->ProfileInfo.Mesh.bssid);
+
+ if (*bssid == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || rssi == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ if (profile_info->profile_type != NET_DEVICE_WIFI &&
+ profile_info->profile_type != NET_DEVICE_MESH) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
- *rssi = (int)profile_info->ProfileInfo.Wlan.Strength;
+ if (profile_info->profile_type == NET_DEVICE_WIFI)
+ *rssi = (int)profile_info->ProfileInfo.Wlan.Strength;
+ else
+ *rssi = (int)profile_info->ProfileInfo.Mesh.Strength;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || frequency == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ if (profile_info->profile_type != NET_DEVICE_WIFI &&
+ profile_info->profile_type != NET_DEVICE_MESH) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
- *frequency = (int)profile_info->ProfileInfo.Wlan.frequency;
+ if (profile_info->profile_type == NET_DEVICE_WIFI)
+ *frequency = (int)profile_info->ProfileInfo.Wlan.frequency;
+ else
+ *frequency = (int)profile_info->ProfileInfo.Mesh.frequency;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || max_speed == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ if (profile_info->profile_type != NET_DEVICE_WIFI) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
- *max_speed = (int)profile_info->ProfileInfo.Wlan.max_rate / 1000000;
+ *max_speed = profile_info->ProfileInfo.Wlan.max_rate;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e *type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ wlan_security_mode_type_t sec_mode;
+ if (profile_info->profile_type != NET_DEVICE_WIFI &&
+ profile_info->profile_type != NET_DEVICE_MESH) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
- switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) {
+ if (profile_info->profile_type == NET_DEVICE_WIFI)
+ sec_mode = profile_info->ProfileInfo.Wlan.security_info.sec_mode;
+ else
+ sec_mode = profile_info->ProfileInfo.Mesh.security_info.sec_mode;
+
+ switch (sec_mode) {
//LCOV_EXCL_START
case WLAN_SEC_MODE_NONE:
*type = CONNECTION_WIFI_SECURITY_TYPE_NONE;
case WLAN_SEC_MODE_WPA2_PSK:
*type = CONNECTION_WIFI_SECURITY_TYPE_WPA2_PSK;
break;
+ case WLAN_SEC_MODE_SAE:
+ *type = CONNECTION_WIFI_SECURITY_TYPE_SAE;
+ break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_OPERATION_FAILED;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e *type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ if (profile_info->profile_type != NET_DEVICE_WIFI) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
switch (profile_info->ProfileInfo.Wlan.security_info.enc_mode) {
//LCOV_EXCL_START
*type = CONNECTION_WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_OPERATION_FAILED;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || required == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ wlan_security_mode_type_t sec_mode;
+ if (profile_info->profile_type != NET_DEVICE_WIFI &&
+ profile_info->profile_type != NET_DEVICE_MESH) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
if (profile_info->Favourite) {
- *required = false;
- return CONNECTION_ERROR_NONE;
+ *required = false; //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_NONE; //LCOV_EXCL_LINE
}
- switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) {
+ if (profile_info->profile_type == NET_DEVICE_WIFI)
+ sec_mode = profile_info->ProfileInfo.Wlan.security_info.sec_mode;
+ else
+ sec_mode = profile_info->ProfileInfo.Mesh.security_info.sec_mode;
+
+ switch (sec_mode) {
//LCOV_EXCL_START
case WLAN_SEC_MODE_NONE:
*required = false;
case WLAN_SEC_MODE_IEEE8021X:
case WLAN_SEC_MODE_WPA_PSK:
case WLAN_SEC_MODE_WPA2_PSK:
+ case WLAN_SEC_MODE_SAE:
*required = true;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_OPERATION_FAILED;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || passphrase == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ if (profile_info->profile_type != NET_DEVICE_WIFI &&
+ profile_info->profile_type != NET_DEVICE_MESH) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
- g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.psk.pskKey,
- passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN);
+ if (profile_info->profile_type == NET_DEVICE_WIFI)
+ g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.psk.pskKey,
+ passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN);
+ else
+ g_strlcpy(profile_info->ProfileInfo.Mesh.security_info.authentication.sae.saeKey,
+ passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN);
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || supported == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_WIFI)
+ if (profile_info->profile_type != NET_DEVICE_WIFI) {
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
if (profile_info->ProfileInfo.Wlan.security_info.wps_support)
*supported = true;
else
*supported = false;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_cellular_service_type(connection_profile_h profile,
connection_cellular_service_type_e* type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (*type == CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid service type Passed"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
*apn = g_strdup(profile_info->ProfileInfo.Pdp.Apn);
- if (*apn == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*apn == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h profile,
connection_cellular_auth_type_e *type, char** user_name, char** password)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
type == NULL || user_name == NULL || password == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
*type = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_OPERATION_FAILED;
//LCOV_EXCL_STOP
}
*user_name = g_strdup(profile_info->ProfileInfo.Pdp.AuthInfo.UserName);
- if (*user_name == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*user_name == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
*password = g_strdup(profile_info->ProfileInfo.Pdp.AuthInfo.Password);
if (*password == NULL) {
g_free(*user_name); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
*home_url = g_strdup(profile_info->ProfileInfo.Pdp.HomeURL);
- if (*home_url == NULL)
- return CONNECTION_ERROR_OUT_OF_MEMORY;
+ if (*home_url == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e *type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
*type = CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_OPERATION_FAILED;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e *type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
*type = CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_OPERATION_FAILED;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || is_roaming == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
else
*is_roaming = false;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_is_cellular_hidden(connection_profile_h profile, bool* is_hidden)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || is_hidden == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
else
*is_hidden = false;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_is_cellular_editable(connection_profile_h profile, bool* is_editable)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || is_editable == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
else
*is_editable = false;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_is_cellular_default(connection_profile_h profile, bool* is_default)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || is_default == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
else
*is_default = false;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h profile,
connection_cellular_service_type_e service_type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile))) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
break;
case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN:
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
g_strlcpy(profile_info->ProfileInfo.Pdp.Apn, apn, NET_PDP_APN_LEN_MAX+1);
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h profile,
connection_cellular_auth_type_e type, const char* user_name, const char* password)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
user_name == NULL || password == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
profile_info->ProfileInfo.Pdp.AuthInfo.AuthType = NET_PDP_AUTH_CHAP;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
//LCOV_EXCL_STOP
}
g_strlcpy(profile_info->ProfileInfo.Pdp.AuthInfo.UserName, user_name, NET_PDP_AUTH_USERNAME_LEN_MAX+1);
g_strlcpy(profile_info->ProfileInfo.Pdp.AuthInfo.Password, password, NET_PDP_AUTH_PASSWORD_LEN_MAX+1);
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
g_strlcpy(profile_info->ProfileInfo.Pdp.HomeURL, home_url, NET_HOME_URL_LEN_MAX);
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile))) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_IPV4_IPV6;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile))) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_IPV4_IPV6;
break;
default:
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
//LCOV_EXCL_STOP
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_ipv6_state(connection_profile_h profile, connection_profile_state_e *state)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile)) ||
state == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
*state = _profile_convert_to_cp_state(profile_info->ProfileState6);
- if (*state < 0)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_dns_config_type(connection_profile_h profile,
connection_address_family_e address_family, connection_dns_config_type_e type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile))) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
(type != CONNECTION_DNS_CONFIG_TYPE_STATIC &&
type != CONNECTION_DNS_CONFIG_TYPE_DYNAMIC)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
net_dns_config_type_t *profileType = NULL;
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
profileType = &net_info->DnsConfigType;
*profileType6 = type;
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_dns_config_type(connection_profile_h profile,
connection_address_family_e address_family, connection_dns_config_type_e *type)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
type == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_dns_config_type_t profileType;
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
profileType = net_info->DnsConfigType;
break;
}
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_set_prefix_length(connection_profile_h profile,
connection_address_family_e address_family, int prefix_len)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
net_info->PrefixLen = prefix_len;
} else
net_info->PrefixLen6 = prefix_len;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}
EXPORT_API int connection_profile_get_prefix_length(connection_profile_h profile,
connection_address_family_e address_family, int *prefix_len)
{
+ CONN_LOCK;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE,
TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
prefix_len == NULL) {
CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ CONN_UNLOCK;
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
- if (net_info == NULL)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (net_info == NULL) {
+ CONN_UNLOCK; //LCOV_EXCL_LINE
+ return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
*prefix_len = net_info->PrefixLen;
else if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
*prefix_len = net_info->PrefixLen6;
+ CONN_UNLOCK;
return CONNECTION_ERROR_NONE;
}