X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fconnection_profile.c;h=b2e95c6b16bba86f5077ae1ec4faed251875ead4;hb=refs%2Fchanges%2F42%2F65942%2F11;hp=188c947bfa6141a14b7dc691c172c5e7954e775c;hpb=956dfff1aed2bd742d8d8042a19e6f48072fb186;p=platform%2Fcore%2Fapi%2Fconnection.git diff --git a/src/connection_profile.c b/src/connection_profile.c index 188c947..b2e95c6 100755 --- a/src/connection_profile.c +++ b/src/connection_profile.c @@ -34,7 +34,7 @@ static net_dev_info_t* __profile_get_net_info(net_profile_info_t *profile_info) case NET_DEVICE_WIFI: return &profile_info->ProfileInfo.Wlan.net_info; case NET_DEVICE_ETHERNET: - return &profile_info->ProfileInfo.Ethernet.net_info; + return &profile_info->ProfileInfo.Ethernet.net_info; //LCOV_EXCL_LINE case NET_DEVICE_BLUETOOTH: return &profile_info->ProfileInfo.Bluetooth.net_info; case NET_DEVICE_DEFAULT: @@ -59,12 +59,14 @@ static char *__profile_convert_ip_to_string(net_addr_t *ip_addr, connection_addr inet_ntop(AF_INET, ipaddr, ipstr, INET_ADDRSTRLEN); } else { + //LCOV_EXCL_START ipaddr = (unsigned char *)&ip_addr->Data.Ipv6.s6_addr; ipstr = g_try_malloc0(INET6_ADDRSTRLEN); if (ipstr == NULL) return NULL; inet_ntop(AF_INET6, ipaddr, ipstr, INET6_ADDRSTRLEN); + //LCOV_EXCL_STOP } return ipstr; @@ -77,13 +79,15 @@ static void __profile_init_cellular_profile(net_profile_info_t *profile_info, co profile_info->profile_type = NET_DEVICE_CELLULAR; profile_info->ProfileState = NET_STATE_TYPE_IDLE; + profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_UNKNOWN; + profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_UNKNOWN; profile_info->ProfileInfo.Pdp.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF; profile_info->ProfileInfo.Pdp.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT; g_strlcpy(profile_info->ProfileInfo.Pdp.Keyword, keyword, NET_PDP_APN_LEN_MAX); if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &default_subscriber_id) != 0) - CONNECTION_LOG(CONNECTION_ERROR, + CONNECTION_LOG(CONNECTION_ERROR, //LCOV_EXCL_LINE "Failed to get VCONF_TELEPHONY_DEFAULT_DATA_SERVICE"); profile = (connection_profile_h)profile_info; @@ -101,6 +105,7 @@ static void __profile_init_wifi_profile(net_profile_info_t *profile_info) profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_NONE; } +//LCOV_EXCL_START static const char* __profile_get_ethernet_proxy(void) { char *proxy; @@ -114,7 +119,9 @@ static const char* __profile_get_ethernet_proxy(void) return proxy; } +//LCOV_EXCL_STOP +//LCOV_EXCL_START connection_cellular_service_type_e _profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type) { switch (svc_type) { @@ -203,16 +210,16 @@ net_state_type_t _connection_profile_convert_to_net_state(connection_profile_sta return libnet_state; } - +//LCOV_EXCL_STOP /* Connection profile ********************************************************/ EXPORT_API int connection_profile_create(connection_profile_type_e type, const char* keyword, connection_profile_h* profile) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE); - if(type == CONNECTION_PROFILE_TYPE_CELLULAR) + if (type == CONNECTION_PROFILE_TYPE_CELLULAR) CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); - else if(type == CONNECTION_PROFILE_TYPE_WIFI) + else if (type == CONNECTION_PROFILE_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); if (type != CONNECTION_PROFILE_TYPE_CELLULAR && @@ -230,8 +237,8 @@ EXPORT_API int connection_profile_create(connection_profile_type_e type, const c if (rv == CONNECTION_ERROR_PERMISSION_DENIED) return rv; else if (rv != CONNECTION_ERROR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Failed to create profile"); - return CONNECTION_ERROR_OPERATION_FAILED; + CONNECTION_LOG(CONNECTION_ERROR, "Failed to create profile"); //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)); @@ -336,8 +343,8 @@ EXPORT_API int connection_profile_get_name(connection_profile_h profile, char** *profile_name = g_strdup(profile_info->ProfileInfo.Wlan.essid); break; case NET_DEVICE_ETHERNET: - *profile_name = g_strdup(profile_info->ProfileInfo.Ethernet.net_info.DevName); - break; + *profile_name = g_strdup(profile_info->ProfileInfo.Ethernet.net_info.DevName); //LCOV_EXCL_LINE + break; //LCOV_EXCL_LINE case NET_DEVICE_BLUETOOTH: { char *bt_name = strrchr(profile_info->ProfileName, '/'); if (bt_name == NULL) @@ -356,7 +363,7 @@ EXPORT_API int connection_profile_get_name(connection_profile_h profile, char** return CONNECTION_ERROR_NONE; } -EXPORT_API int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e* type) +EXPORT_API int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e *type) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE); @@ -375,8 +382,8 @@ EXPORT_API int connection_profile_get_type(connection_profile_h profile, connect *type = CONNECTION_PROFILE_TYPE_WIFI; break; case NET_DEVICE_ETHERNET: - *type = CONNECTION_PROFILE_TYPE_ETHERNET; - break; + *type = CONNECTION_PROFILE_TYPE_ETHERNET; //LCOV_EXCL_LINE + break; //LCOV_EXCL_LINE case NET_DEVICE_BLUETOOTH: *type = CONNECTION_PROFILE_TYPE_BT; break; @@ -425,11 +432,11 @@ EXPORT_API int connection_profile_refresh(connection_profile_h profile) rv = net_get_profile_info(profile_info->ProfileName, &profile_info_local); if (rv == NET_ERR_ACCESS_DENIED) { - CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); - return CONNECTION_ERROR_PERMISSION_DENIED; + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //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"); - return CONNECTION_ERROR_OPERATION_FAILED; + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get profile information"); //LCOV_EXCL_LINE + return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } memcpy(profile, &profile_info_local, sizeof(net_profile_info_t)); @@ -453,7 +460,7 @@ EXPORT_API int connection_profile_get_state(connection_profile_h profile, connec } EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profile, - connection_address_family_e address_family, connection_ip_config_type_e* type) + connection_address_family_e address_family, connection_ip_config_type_e *type) { net_ip_config_type_t profile_type; @@ -479,6 +486,7 @@ EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profil if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) { switch (profile_type) { + //LCOV_EXCL_START case NET_IP_CONFIG_TYPE_STATIC: *type = CONNECTION_IP_CONFIG_TYPE_STATIC; break; @@ -500,8 +508,10 @@ EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profil break; default: return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } } else { + //LCOV_EXCL_START switch (profile_type) { case NET_IP_CONFIG_TYPE_STATIC: *type = CONNECTION_IP_CONFIG_TYPE_STATIC; @@ -519,6 +529,7 @@ EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profil return CONNECTION_ERROR_OPERATION_FAILED; } + //LCOV_EXCL_STOP } return CONNECTION_ERROR_NONE; @@ -576,12 +587,14 @@ EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile, return CONNECTION_ERROR_OPERATION_FAILED; if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + //LCOV_EXCL_START prefixlen = g_try_malloc0(MAX_PREFIX_LENGTH); if (prefixlen != NULL) { snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d", net_info->PrefixLen6); *subnet_mask = prefixlen; } else *subnet_mask = NULL; + //LCOV_EXCL_STOP } else *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask, address_family); @@ -610,7 +623,7 @@ EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profi if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) *gateway_address = __profile_convert_ip_to_string( &net_info->GatewayAddr6, address_family); else @@ -643,14 +656,14 @@ EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4) + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr[order-1], address_family); - else if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr6[order-1], + else if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) //LCOV_EXCL_LINE + *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr6[order-1], //LCOV_EXCL_LINE address_family); else - CONNECTION_LOG(CONNECTION_ERROR, "Invalid address family\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid address family\n"); //LCOV_EXCL_LINE if (*dns_address == NULL) return CONNECTION_ERROR_OUT_OF_MEMORY; @@ -658,7 +671,7 @@ EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, return CONNECTION_ERROR_NONE; } -EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e* type) +EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e *type) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE); @@ -673,6 +686,7 @@ EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, c if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_START if (profile_info->profile_type == NET_DEVICE_ETHERNET) { proxy = __profile_get_ethernet_proxy(); if (proxy == NULL) @@ -682,8 +696,10 @@ EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, c return CONNECTION_ERROR_NONE; } + //LCOV_EXCL_STOP switch (net_info->ProxyMethod) { + //LCOV_EXCL_START case NET_PROXY_TYPE_DIRECT: *type = CONNECTION_PROXY_TYPE_DIRECT; break; @@ -696,6 +712,7 @@ EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, c case NET_PROXY_TYPE_UNKNOWN: default: return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } return CONNECTION_ERROR_NONE; @@ -746,13 +763,14 @@ EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profil if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4) + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) profile_type = &net_info->IpConfigType ; else profile_type = &net_info->IpConfigType6 ; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4) { + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) { switch (type) { + //LCOV_EXCL_START case CONNECTION_IP_CONFIG_TYPE_STATIC: *profile_type = NET_IP_CONFIG_TYPE_STATIC; net_info->IpAddr.Data.Ipv4.s_addr = 0; @@ -778,8 +796,10 @@ EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profil default: return CONNECTION_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_STOP } } else { + //LCOV_EXCL_START switch (type) { case CONNECTION_IP_CONFIG_TYPE_STATIC: *profile_type = NET_IP_CONFIG_TYPE_STATIC; @@ -800,6 +820,7 @@ EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profil default: return CONNECTION_ERROR_INVALID_PARAMETER; } + //LCOV_EXCL_STOP } return CONNECTION_ERROR_NONE; @@ -822,12 +843,14 @@ EXPORT_API int connection_profile_set_ip_address(connection_profile_h profile, if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + 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) return CONNECTION_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_STOP } else { if (ip_address == NULL) net_info->IpAddr.Data.Ipv4.s_addr = 0; @@ -856,15 +879,17 @@ EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile, if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + //LCOV_EXCL_START if (subnet_mask == NULL) net_info->PrefixLen6 = 0 ; else net_info->PrefixLen6 = atoi(subnet_mask) ; + //LCOV_EXCL_STOP } else { 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 ) + else if (inet_pton(AF_INET, subnet_mask , &net_info->SubnetMask.Data.Ipv4) < 1) return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -888,11 +913,13 @@ EXPORT_API int connection_profile_set_gateway_address(connection_profile_h profi if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + 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) return CONNECTION_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_STOP } else { if (gateway_address == NULL) net_info->GatewayAddr.Data.Ipv4.s_addr = 0; @@ -922,7 +949,8 @@ EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile, if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + 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); @@ -930,6 +958,7 @@ EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile, return CONNECTION_ERROR_INVALID_PARAMETER; if (net_info->DnsCount6 < order) net_info->DnsCount6 = order; + //LCOV_EXCL_STOP } else { net_info->DnsAddr[order-1].Type = NET_ADDR_IPV4; if (dns_address == NULL) @@ -958,6 +987,7 @@ EXPORT_API int connection_profile_set_proxy_type(connection_profile_h profile, c return CONNECTION_ERROR_OPERATION_FAILED; switch (type) { + //LCOV_EXCL_START case CONNECTION_PROXY_TYPE_DIRECT: net_info->ProxyMethod = NET_PROXY_TYPE_DIRECT; break; @@ -969,6 +999,7 @@ EXPORT_API int connection_profile_set_proxy_type(connection_profile_h profile, c break; default: return CONNECTION_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_STOP } return CONNECTION_ERROR_NONE; @@ -1012,7 +1043,7 @@ EXPORT_API int connection_profile_set_state_changed_cb(connection_profile_h prof if (_connection_libnet_add_to_profile_cb_list(profile, callback, user_data)) return CONNECTION_ERROR_NONE; - return CONNECTION_ERROR_OPERATION_FAILED; + return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } EXPORT_API int connection_profile_unset_state_changed_cb(connection_profile_h profile) @@ -1131,7 +1162,7 @@ EXPORT_API int connection_profile_get_wifi_max_speed(connection_profile_h profil return CONNECTION_ERROR_NONE; } -EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e* type) +EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e *type) { CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); @@ -1146,6 +1177,7 @@ EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h pr return CONNECTION_ERROR_INVALID_PARAMETER; switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) { + //LCOV_EXCL_START case WLAN_SEC_MODE_NONE: *type = CONNECTION_WIFI_SECURITY_TYPE_NONE; break; @@ -1163,12 +1195,13 @@ EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h pr break; default: return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } return CONNECTION_ERROR_NONE; } -EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e* type) +EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e *type) { CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); @@ -1183,6 +1216,7 @@ EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h return CONNECTION_ERROR_INVALID_PARAMETER; switch (profile_info->ProfileInfo.Wlan.security_info.enc_mode) { + //LCOV_EXCL_START case WLAN_ENC_MODE_NONE: *type = CONNECTION_WIFI_ENCRYPTION_TYPE_NONE; break; @@ -1200,6 +1234,7 @@ EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h break; default: return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } return CONNECTION_ERROR_NONE; @@ -1225,6 +1260,7 @@ EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile } switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) { + //LCOV_EXCL_START case WLAN_SEC_MODE_NONE: *required = false; break; @@ -1236,6 +1272,7 @@ EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile break; default: return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } return CONNECTION_ERROR_NONE; @@ -1305,8 +1342,8 @@ EXPORT_API int connection_profile_get_cellular_service_type(connection_profile_h *type = _profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType); if (*type == CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid service type Passed"); - return CONNECTION_ERROR_OPERATION_FAILED; + CONNECTION_LOG(CONNECTION_ERROR, "Invalid service type Passed"); //LCOV_EXCL_LINE + return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } return CONNECTION_ERROR_NONE; @@ -1324,8 +1361,8 @@ EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile, net_profile_info_t *profile_info = profile; if (profile_info->profile_type != NET_DEVICE_CELLULAR) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); - return CONNECTION_ERROR_INVALID_PARAMETER; + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE + return CONNECTION_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE } *apn = g_strdup(profile_info->ProfileInfo.Pdp.Apn); @@ -1336,7 +1373,7 @@ EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile, } EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h profile, - connection_cellular_auth_type_e* type, char** user_name, char** password) + connection_cellular_auth_type_e *type, char** user_name, char** password) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); @@ -1354,6 +1391,7 @@ EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h pr } switch (profile_info->ProfileInfo.Pdp.AuthInfo.AuthType) { + //LCOV_EXCL_START case NET_PDP_AUTH_NONE: *type = CONNECTION_CELLULAR_AUTH_TYPE_NONE; break; @@ -1365,6 +1403,7 @@ EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h pr break; default: return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } *user_name = g_strdup(profile_info->ProfileInfo.Pdp.AuthInfo.UserName); @@ -1373,8 +1412,8 @@ EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h pr *password = g_strdup(profile_info->ProfileInfo.Pdp.AuthInfo.Password); if (*password == NULL) { - g_free(*user_name); - return CONNECTION_ERROR_OUT_OF_MEMORY; + g_free(*user_name); //LCOV_EXCL_LINE + return CONNECTION_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE } return CONNECTION_ERROR_NONE; @@ -1403,6 +1442,82 @@ EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h pro return CONNECTION_ERROR_NONE; } +EXPORT_API int connection_profile_get_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e* type) +{ + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); + + if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + switch (profile_info->ProfileInfo.Pdp.PdnType) { + //LCOV_EXCL_START + case NET_PDN_TYPE_UNKNOWN: + *type = CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN; + break; + case NET_PDN_TYPE_IPV4: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4; + break; + case NET_PDN_TYPE_IPV6: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV6; + break; + case NET_PDN_TYPE_IPV4_IPV6: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6; + break; + default: + return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP + } + + return CONNECTION_ERROR_NONE; +} + +EXPORT_API int connection_profile_get_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e* type) +{ + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); + + if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + switch (profile_info->ProfileInfo.Pdp.RoamPdnType) { + //LCOV_EXCL_START + case NET_PDN_TYPE_UNKNOWN: + *type = CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN; + break; + case NET_PDN_TYPE_IPV4: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4; + break; + case NET_PDN_TYPE_IPV6: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV6; + break; + case NET_PDN_TYPE_IPV4_IPV6: + *type = CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6; + break; + default: + return CONNECTION_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP + } + + return CONNECTION_ERROR_NONE; +} + EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); @@ -1517,6 +1632,7 @@ EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h } switch (service_type) { + //LCOV_EXCL_START case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET: profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_INTERNET; break; @@ -1538,6 +1654,7 @@ EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN: default: return CONNECTION_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_STOP } return CONNECTION_ERROR_NONE; @@ -1583,6 +1700,7 @@ EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h pr } switch (type) { + //LCOV_EXCL_START case CONNECTION_CELLULAR_AUTH_TYPE_NONE: profile_info->ProfileInfo.Pdp.AuthInfo.AuthType = NET_PDP_AUTH_NONE; break; @@ -1594,6 +1712,7 @@ EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h pr break; default: 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); @@ -1622,3 +1741,73 @@ EXPORT_API int connection_profile_set_cellular_home_url(connection_profile_h pro return CONNECTION_ERROR_NONE; } + +EXPORT_API int connection_profile_set_cellular_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type) +{ + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); + + if (!(_connection_libnet_check_profile_validity(profile))) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + switch (type) { + //LCOV_EXCL_START + case CONNECTION_CELLULAR_PDN_TYPE_IPV4: + profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_IPV4; + break; + case CONNECTION_CELLULAR_PDN_TYPE_IPV6: + profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_IPV6; + break; + case CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6: + profile_info->ProfileInfo.Pdp.PdnType = NET_PDN_TYPE_IPV4_IPV6; + break; + default: + return CONNECTION_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_STOP + } + + return CONNECTION_ERROR_NONE; +} + +EXPORT_API int connection_profile_set_cellular_roam_pdn_type(connection_profile_h profile, connection_cellular_pdn_type_e type) +{ + CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); + + if (!(_connection_libnet_check_profile_validity(profile))) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + switch (type) { + //LCOV_EXCL_START + case CONNECTION_CELLULAR_PDN_TYPE_IPV4: + profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_IPV4; + break; + case CONNECTION_CELLULAR_PDN_TYPE_IPV6: + profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_IPV6; + break; + case CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6: + profile_info->ProfileInfo.Pdp.RoamPdnType = NET_PDN_TYPE_IPV4_IPV6; + break; + default: + return CONNECTION_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_STOP + } + + return CONNECTION_ERROR_NONE; +}