* 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.
+ * limitations under the License.
*/
#include <stdio.h>
#include <glib.h>
#include "net_connection.h"
+#include "connection_extension.h"
+
#include <tizen_error.h>
-#define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1;}
+#define LOG_RED "\033[0;31m"
+#define LOG_GREEN "\033[0;32m"
+#define LOG_BROWN "\033[0;33m"
+#define LOG_BLUE "\033[0;34m"
+#define LOG_END "\033[0;m"
+
+#define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1; }
gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
return false;
}
- buf[rv-1]='\0';
-
+ buf[rv-1] = '\0';
return true;
}
}
}
+static const char *test_print_connection_type(connection_type_e type)
+{
+ switch (type) {
+ case CONNECTION_TYPE_DISCONNECTED:
+ return "Disconnected";
+ case CONNECTION_TYPE_WIFI:
+ return "Wifi";
+ case CONNECTION_TYPE_CELLULAR:
+ return "Cellular";
+ case CONNECTION_TYPE_ETHERNET:
+ return "Ethernet";
+ case CONNECTION_TYPE_BT:
+ return "BT";
+ case CONNECTION_TYPE_NET_PROXY:
+ return "Net_Proxy";
+ default:
+ return "Unknown";
+ }
+}
+
+static const char *test_print_cellular_state(connection_cellular_state_e state)
+{
+ switch (state) {
+ case CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE:
+ return "Out of service";
+ case CONNECTION_CELLULAR_STATE_FLIGHT_MODE:
+ return "Flight mode";
+ case CONNECTION_CELLULAR_STATE_ROAMING_OFF:
+ return "Roaming off";
+ case CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE:
+ return "Call only available";
+ case CONNECTION_CELLULAR_STATE_AVAILABLE:
+ return "Available";
+ case CONNECTION_CELLULAR_STATE_CONNECTED:
+ return "Connected";
+ default:
+ return "Unknown";
+ }
+}
+
+static const char *test_print_wifi_state(connection_wifi_state_e state)
+{
+ switch (state) {
+ case CONNECTION_WIFI_STATE_DEACTIVATED:
+ return "Deactivated";
+ case CONNECTION_WIFI_STATE_DISCONNECTED:
+ return "Disconnected";
+ case CONNECTION_WIFI_STATE_CONNECTED:
+ return "Connected";
+ default:
+ return "Unknown";
+ }
+}
+
+static const char *test_print_cellular_service_type(connection_cellular_service_type_e type)
+{
+ switch (type) {
+ case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN:
+ return "Unknown";
+ case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET:
+ return "Internet";
+ case CONNECTION_CELLULAR_SERVICE_TYPE_MMS:
+ return "MMS";
+ case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET:
+ return "Prepaid internet";
+ case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS:
+ return "Prepaid MMS";
+ case CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING:
+ return "Tethering";
+ case CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION:
+ return "Application";
+ default:
+ return "Unknown";
+ }
+}
+
+static const char* test_print_cellular_auth_type(connection_cellular_auth_type_e type)
+{
+ switch (type) {
+ case CONNECTION_CELLULAR_AUTH_TYPE_PAP:
+ return "PAP";
+ case CONNECTION_CELLULAR_AUTH_TYPE_CHAP:
+ return "CHAP";
+ case CONNECTION_CELLULAR_AUTH_TYPE_NONE:
+ default:
+ return "None";
+ }
+}
+
+static const char* test_print_cellular_pdn_type(connection_cellular_pdn_type_e type)
+{
+ switch (type) {
+ case CONNECTION_CELLULAR_PDN_TYPE_IPV4:
+ return "IPv4";
+ case CONNECTION_CELLULAR_PDN_TYPE_IPV6:
+ return "IPv6";
+ case CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6:
+ return "Dual";
+ case CONNECTION_CELLULAR_PDN_TYPE_UNKNOWN:
+ default:
+ return "Unknown";
+ }
+}
+
static const char *test_print_error(connection_error_e error)
{
switch (error) {
return "CONNECTION_ERROR_PERMISSION_DENIED";
case CONNECTION_ERROR_NOT_SUPPORTED:
return "CONNECTION_ERROR_NOT_SUPPORTED";
+ case CONNECTION_ERROR_NOT_INITIALIZED:
+ return "CONNECTION_ERROR_NOT_INITIALIZED";
+ case CONNECTION_ERROR_ALREADY_INITIALIZED:
+ return "CONNECTION_ERROR_ALREADY_INITIALIZED";
default:
return "CONNECTION_ERROR_UNKNOWN";
}
if (result == CONNECTION_ERROR_NONE)
printf("Connection open Succeeded\n");
else
- printf("Connection open Failed, err : %d\n", result);
+ printf("Connection open Failed, err : [%s]\n", test_print_error(result));
}
static void test_connection_closed_callback(connection_error_e result, void* user_data)
if (result == CONNECTION_ERROR_NONE)
printf("Connection close Succeeded\n");
else
- printf("Connection close Failed, err : %d\n", result);
+ printf("Connection close Failed, err : [%s]\n", test_print_error(result));
}
static void test_connection_reset_profile_callback(connection_error_e result, void* user_data)
if (result == CONNECTION_ERROR_NONE)
printf("Default profile setting Succeeded\n");
else
- printf("Default profile setting Failed, err : %d\n", result);
+ printf("Default profile setting Failed, err : [%s]\n", test_print_error(result));
+}
+
+void test_get_ethernet_cable_state_callback(connection_ethernet_cable_state_e state,
+ void* user_data)
+{
+ if (state == CONNECTION_ETHERNET_CABLE_ATTACHED)
+ printf("Ethernet Cable Connected\n");
+ else if (state == CONNECTION_ETHERNET_CABLE_DETACHED)
+ printf("Ethernet Cable Disconnected\n");
}
static bool test_get_user_selected_profile(connection_profile_h *profile, bool select)
rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get profile iterator [%d]\n", rv);
+ printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
return false;
}
return false;
}
- if (profile_type == CONNECTION_PROFILE_TYPE_WIFI) {
- char *essid;
- connection_profile_get_wifi_essid(profile_h, &essid);
- printf("%d. state:[%s], profile name:%s, essid:%s\n",
- profile_count, test_print_state(profile_state),
- profile_name, (essid)? essid : "");
- g_free(essid);
-
- profile_list[profile_count] = profile_h;
- profile_count++;
- } else {
- printf("%d. state:[%s], profile name : %s\n",
- profile_count, test_print_state(profile_state), profile_name);
-
- profile_list[profile_count] = profile_h;
- profile_count++;
+ printf("%d. state:[%s], profile name:%s", profile_count,
+ test_print_state(profile_state), profile_name);
+ if (profile_type == CONNECTION_PROFILE_TYPE_CELLULAR) {
+ connection_cellular_service_type_e service_type;
+ if (connection_profile_get_cellular_service_type(
+ profile_h, &service_type) !=
+ CONNECTION_ERROR_NONE)
+ printf("Fail to get cellular service type!\n");
+
+ printf("[%s]",
+ test_print_cellular_service_type(service_type));
}
+ printf("\n");
+
+ profile_list[profile_count] = profile_h;
+ profile_count++;
g_free(profile_name);
if (profile_count >= 100)
return -1;
if (test_get_user_string("Input Apn - (Enter for skip) :", input_str1, 100)) {
+ g_strstrip(input_str1);
rv = connection_profile_set_cellular_apn(profile, input_str1);
if (rv != CONNECTION_ERROR_NONE)
return -1;
}
if (test_get_user_string("Input Proxy - (Enter for skip) :", input_str1, 100)) {
+ g_strstrip(input_str1);
rv = connection_profile_set_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, input_str1);
if (rv != CONNECTION_ERROR_NONE)
return -1;
}
if (test_get_user_string("Input HomeURL - (Enter for skip) :", input_str1, 100)) {
+ g_strstrip(input_str1);
rv = connection_profile_set_cellular_home_url(profile, input_str1);
if (rv != CONNECTION_ERROR_NONE)
return -1;
if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false)
input_str2[0] = 0;
+ g_strstrip(input_str1);
+ g_strstrip(input_str2);
rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2);
if (rv != CONNECTION_ERROR_NONE)
return -1;
}
}
+ if (test_get_user_int("Input PdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
+ switch (input_int) {
+ case 1:
+ rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
+ break;
+ case 2:
+ rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
+ break;
+ case 3:
+ rv = connection_profile_set_cellular_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
+ break;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_int("Input RoamPdnType(1:IPv4 2:IPv6 3:IPv4v6) - (Enter for skip) :", &input_int)) {
+ switch (input_int) {
+ case 1:
+ rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4);
+ break;
+ case 2:
+ rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV6);
+ break;
+ case 3:
+ rv = connection_profile_set_cellular_roam_pdn_type(profile, CONNECTION_CELLULAR_PDN_TYPE_IPV4_IPv6);
+ break;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
return 1;
}
return 1;
}
-static int test_update_ip_info(connection_profile_h profile)
+static int test_update_dns_info(connection_profile_h profile,
+ connection_address_family_e address_family)
+{
+ int rv = 0;
+ char input_str[100] = {0,};
+ if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_dns_address(profile,
+ 1,
+ address_family,
+ input_str);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+
+ if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_dns_address(profile,
+ 2,
+ address_family,
+ input_str);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+ }
+ return 1;
+}
+
+static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
{
int rv = 0;
+ int input_int = 0;
char input_str[100] = {0,};
if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
rv = connection_profile_set_ip_address(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) {
rv = connection_profile_set_subnet_mask(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
}
- if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
- rv = connection_profile_set_gateway_address(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
- input_str);
+ if (test_get_user_int("Input Prefix Length - (Enter for skip) :", &input_int)) {
+ rv = connection_profile_set_prefix_length(profile,
+ address_family,
+ input_int);
if (rv != CONNECTION_ERROR_NONE)
return -1;
}
- if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
- rv = connection_profile_set_dns_address(profile,
- 1,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_gateway_address(profile,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
-
- if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
- rv = connection_profile_set_dns_address(profile,
- 2,
- CONNECTION_ADDRESS_FAMILY_IPV4,
- input_str);
- if (rv != CONNECTION_ERROR_NONE)
- return -1;
- }
}
+ if (test_update_dns_info(profile, address_family) < 0)
+ return -1;
+
return 1;
}
-static int test_update_proxy_info(connection_profile_h profile)
+static int test_update_proxy_info(connection_profile_h profile, connection_address_family_e address_family)
{
int rv = 0;
int input_int = 0;
if (test_get_user_string("Input auto Proxy URL or Proxy address"
" - (Enter for skip) :", input_str, 100)) {
rv = connection_profile_set_proxy_address(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
+ address_family,
input_str);
if (rv != CONNECTION_ERROR_NONE)
return -1;
return 1;
}
+
+
static int test_update_network_info(connection_profile_h profile)
{
int rv = 0;
int input_int = 0;
+ int dns_input = 0;
+ int address_family = 0;
+
+ test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
- if (test_get_user_int("Input IPv4 Address Type (DHCP:1, Static:2)"
+ if (test_get_user_int("Input IPv4/IPv6 Address Type (DHCP:1, Static:2, Auto:3)"
" - (Enter for skip) :", &input_int)) {
switch (input_int) {
case 1:
rv = connection_profile_set_ip_config_type(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
- CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
+ address_family,
+ CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
+ if (test_get_user_int("Input DNS Address Type (Static:1, DHCP:2)"
+ " - (Enter for skip) :", &dns_input)) {
+ switch (dns_input) {
+ case CONNECTION_DNS_CONFIG_TYPE_STATIC:
+ rv = connection_profile_set_dns_config_type(
+ profile,
+ address_family,
+ CONNECTION_DNS_CONFIG_TYPE_STATIC);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ if (test_update_dns_info(profile,
+ address_family) == -1)
+ return -1;
+ break;
+ case CONNECTION_DNS_CONFIG_TYPE_DYNAMIC:
+ rv = connection_profile_set_dns_config_type(
+ profile,
+ address_family,
+ CONNECTION_DNS_CONFIG_TYPE_DYNAMIC);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ break;
+ }
+ }
break;
case 2:
rv = connection_profile_set_ip_config_type(profile,
- CONNECTION_ADDRESS_FAMILY_IPV4,
- CONNECTION_IP_CONFIG_TYPE_STATIC);
+ address_family,
+ CONNECTION_IP_CONFIG_TYPE_STATIC);
if (rv != CONNECTION_ERROR_NONE)
return -1;
- if (test_update_ip_info(profile) == -1)
+ if (test_update_ip_info(profile, address_family) == -1)
return -1;
- if (test_update_proxy_info(profile) == -1)
+ if (test_update_proxy_info(profile, address_family) == -1)
return -1;
break;
+ case 3:
+ rv = connection_profile_set_ip_config_type(profile,
+ address_family,
+ CONNECTION_IP_CONFIG_TYPE_AUTO);
+ break;
default:
return -1;
}
static void test_print_cellular_info(connection_profile_h profile)
{
- connection_cellular_network_type_e network_type;
connection_cellular_service_type_e service_type;
+ connection_cellular_pdn_type_e pdn_type;
+ connection_cellular_pdn_type_e roam_pdn_type;
char *apn = NULL;
connection_cellular_auth_type_e auth_type;
char *user_name = NULL;
bool hidden = false;
bool editable = false;
- if (connection_profile_get_cellular_network_type(profile, &network_type) != CONNECTION_ERROR_NONE)
- printf("Fail to get cellular network type!\n");
- else
- printf("Cellular network type : %d\n", network_type);
-
if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE)
printf("Fail to get cellular service type!\n");
else
- printf("Cellular service type : %d\n", service_type);
+ printf("Cellular service type : %s\n", test_print_cellular_service_type(service_type));
+
+ if (connection_profile_get_cellular_pdn_type(profile, &pdn_type) != CONNECTION_ERROR_NONE)
+ printf("Fail to get cellular pdn type!\n");
+ else
+ printf("Cellular pdn type : %s\n", test_print_cellular_pdn_type(pdn_type));
+
+ if (connection_profile_get_cellular_roam_pdn_type(profile, &roam_pdn_type) != CONNECTION_ERROR_NONE)
+ printf("Fail to get cellular roam pdn type!\n");
+ else
+ printf("Cellular roam pdn type : %s\n", test_print_cellular_pdn_type(roam_pdn_type));
if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE)
printf("Fail to get cellular APN!\n");
if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE)
printf("Fail to get auth info!\n");
else {
- printf("Cellular auth type : %d\n", auth_type);
+ printf("Cellular auth type : %s\n", test_print_cellular_auth_type(auth_type));
printf("Cellular user_name : %s\n", user_name);
printf("Cellular password : %s\n", password);
g_free(user_name);
}
if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE)
- printf("Fail to get cellular is roaming!\n");
+ printf("Fail to get cellular roaming state!\n");
else
printf("Cellular roaming : %s\n", roaming ? "true" : "false");
printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false");
}
-static void test_print_network_info(connection_profile_h profile)
+static void test_print_mesh_info(connection_profile_h profile)
+{
+ char *essid = NULL;
+ char *bssid = NULL;
+ int rssi = 0;
+ int frequency = 0;
+ connection_wifi_security_type_e security_type;
+ bool pass_required = false;
+
+ if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Mesh essid!\n");
+ else {
+ printf("Mesh essid : %s\n", essid);
+ g_free(essid);
+ }
+
+ if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Mesh bssid!\n");
+ else {
+ printf("Mesh bssid : %s\n", bssid);
+ g_free(bssid);
+ }
+
+ if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Mesh rssi!\n");
+ else
+ printf("Mesh rssi : %d\n", rssi);
+
+ if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Mesh frequency!\n");
+ else
+ printf("Mesh frequency : %d\n", frequency);
+
+ if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Mesh security type!\n");
+ else
+ printf("Mesh security type : %d\n", security_type);
+
+ if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Mesh passphrase required!\n");
+ else
+ printf("Mesh passphrase required : %s\n", pass_required ? "true" : "false");
+}
+
+static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
{
char *interface_name = NULL;
- connection_ip_config_type_e ip_type;
char *ip = NULL;
char *subnet = NULL;
char *gateway = NULL;
+ char *dhcp_server = NULL;
+ int dhcp_lease_duration = 0;
char *dns1 = NULL;
char *dns2 = NULL;
- connection_proxy_type_e proxy_type;
char *proxy = NULL;
+ int prefix_len;
+ connection_ip_config_type_e ip_type;
+ connection_proxy_type_e proxy_type;
+ connection_dns_config_type_e dns_type;
if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
printf("Fail to get interface name!\n");
g_free(interface_name);
}
- if (connection_profile_get_ip_config_type(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_type) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
printf("Fail to get ipconfig type!\n");
- else
- printf("Ipconfig type : %d\n", ip_type);
-
- if (connection_profile_get_ip_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip) != CONNECTION_ERROR_NONE)
+ else {
+ if (ip_type == CONNECTION_IP_CONFIG_TYPE_STATIC)
+ printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_STATIC");
+ else if (ip_type == CONNECTION_IP_CONFIG_TYPE_DYNAMIC)
+ printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_DYNAMIC");
+ else if (ip_type == CONNECTION_IP_CONFIG_TYPE_AUTO)
+ printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_AUTO");
+ else if (ip_type == CONNECTION_IP_CONFIG_TYPE_FIXED)
+ printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_FIXED");
+ else
+ printf("ip type : %s\n", "CONNECTION_IP_CONFIG_TYPE_NONE");
+ }
+
+ if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
printf("Fail to get IP address!\n");
else {
printf("IP address : %s\n", ip);
g_free(ip);
}
- if (connection_profile_get_subnet_mask(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &subnet) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
+ printf("Fail to get gateway!\n");
+ else {
+ printf("Gateway : %s\n", gateway);
+ g_free(gateway);
+ }
+
+ if (connection_profile_get_dhcp_server_address(profile, address_family, &dhcp_server) != CONNECTION_ERROR_NONE)
+ printf("Fail to get DHCP Server address!\n");
+ else {
+ printf("DHCP Server : %s\n", dhcp_server);
+ g_free(dhcp_server);
+ }
+
+ if (connection_profile_get_dhcp_lease_duration(profile, address_family, &dhcp_lease_duration) != CONNECTION_ERROR_NONE)
+ printf("Fail to get DHCP lease duration!\n");
+ else {
+ printf("DHCP lease duration : %d\n", dhcp_lease_duration);
+ }
+
+ if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
printf("Fail to get subnet mask!\n");
else {
printf("Subnet mask : %s\n", subnet);
g_free(subnet);
}
- if (connection_profile_get_gateway_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &gateway) != CONNECTION_ERROR_NONE)
- printf("Fail to get gateway!\n");
+ if (connection_profile_get_prefix_length(profile, address_family, &prefix_len) != CONNECTION_ERROR_NONE)
+ printf("Fail to get prefix length!\n");
+ else
+ printf("Prefix length : %d\n", prefix_len);
+
+ if (connection_profile_get_dns_config_type(profile, address_family, &dns_type) != CONNECTION_ERROR_NONE)
+ printf("Fail to get DNS configuration type!\n");
else {
- printf("Gateway : %s\n", gateway);
- g_free(gateway);
+ if (dns_type == CONNECTION_DNS_CONFIG_TYPE_STATIC)
+ printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_STATIC");
+ else if (dns_type == CONNECTION_DNS_CONFIG_TYPE_DYNAMIC)
+ printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_DYNAMIC");
+ else
+ printf("DNS config type : %s\n", "CONNECTION_DNS_CONFIG_TYPE_NONE");
}
- if (connection_profile_get_dns_address(profile, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &dns1) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
printf("Fail to get DNS1!\n");
else {
printf("DNS1 : %s\n", dns1);
g_free(dns1);
}
- if (connection_profile_get_dns_address(profile, 2, CONNECTION_ADDRESS_FAMILY_IPV4, &dns2) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
printf("Fail to get DNS2!\n");
else {
printf("DNS2 : %s\n", dns2);
if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE)
printf("Fail to get proxy type!\n");
- else
- printf("Proxy type : %d\n", proxy_type);
+ else {
+ if (proxy_type == CONNECTION_PROXY_TYPE_DIRECT)
+ printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_DIRECT");
+ else if (proxy_type == CONNECTION_PROXY_TYPE_AUTO)
+ printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_AUTO");
+ else
+ printf("proxy type : %s\n", "CONNECTION_PROXY_TYPE_MANUAL");
+ }
- if (connection_profile_get_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy) != CONNECTION_ERROR_NONE)
+ if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
printf("Fail to get proxy!\n");
else {
printf("Proxy : %s\n", proxy);
connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
+ connection_set_ethernet_cable_state_changed_cb(connection,
+ test_get_ethernet_cable_state_callback, NULL);
} else {
- printf("Client registration failed %d\n", err);
+ printf("Client registration failed [%s]\n", test_print_error(err));
return -1;
}
rv = CONNECTION_ERROR_INVALID_OPERATION;
}
- if (rv != CONNECTION_ERROR_NONE){
- printf("Client deregistration fail [%d]\n", rv);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Client deregistration fail [%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ if (state_cb_list) {
+ for (list = state_cb_list; list; list = list->next) {
+ profile = list->data;
+ connection_profile_destroy(profile);
+ }
+
+ g_slist_free(state_cb_list);
+ state_cb_list = NULL;
+ }
+
+ connection = NULL;
+ printf("Client deregistration success\n");
+
+ return 1;
+}
+
+int test_register_client_cs(void)
+{
+ int tid = 0;
+ test_get_user_int("Input a TID in C# API :", &tid);
+
+ int err = connection_create_cs(tid, &connection);
+
+ if (CONNECTION_ERROR_NONE == err) {
+ connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
+ connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
+ connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
+ connection_set_ethernet_cable_state_changed_cb(connection,
+ test_get_ethernet_cable_state_callback, NULL);
+ } else {
+ printf("Client registration failed [%s]\n", test_print_error(err));
+ return -1;
+ }
+
+ printf("Client registration success\n");
+ return 1;
+}
+
+int test_deregister_client_cs(void)
+{
+ int rv = 0;
+ GSList *list;
+ connection_profile_h profile;
+ int tid = 0;
+
+ test_get_user_int("Input a TID in C# API :", &tid);
+
+ if (connection != NULL)
+ rv = connection_destroy_cs(tid, connection);
+ else {
+ printf("Cannot deregister : Handle is NULL\n");
+ rv = CONNECTION_ERROR_INVALID_OPERATION;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Client deregistration fail [%s]\n", test_print_error(rv));
return -1;
}
rv = connection_get_type(connection, &net_state);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get network state [%d]\n", rv);
+ printf("Fail to get network state [%s]\n", test_print_error(rv));
return -1;
}
- printf("Retval = %d network connection state [%d]\n", rv, net_state);
+ printf("Retval = [%s] network connection state [%s]\n",
+ test_print_error(rv), test_print_connection_type(net_state));
return 1;
}
rv = connection_get_cellular_state(connection, &cellular_state);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get Cellular state [%d]\n", rv);
+ printf("Fail to get Cellular state [%s]\n", test_print_error(rv));
return -1;
}
- printf("Retval = %d Cellular state [%d]\n", rv, cellular_state);
+ printf("Retval = [%s] Cellular state [%s]\n",
+ test_print_error(rv), test_print_cellular_state(cellular_state));
return 1;
}
rv = connection_get_wifi_state(connection, &wifi_state);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get WiFi state [%d]\n", rv);
+ printf("Fail to get WiFi state [%s]\n", test_print_error(rv));
return -1;
}
- printf("Retval = %d WiFi state [%d]\n", rv, wifi_state);
+ printf("Retval = [%s] WiFi state [%s]\n",
+ test_print_error(rv), test_print_wifi_state(wifi_state));
return 1;
}
int test_get_current_ip(void)
{
char *ip_addr = NULL;
+ int input;
+ bool rv;
- connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
+ rv = test_get_user_int("Input Address type to get"
+ "(1:IPV4, 2:IPV6):", &input);
- if (ip_addr == NULL) {
- printf("IP address does not exist\n");
+ if (rv == false) {
+ printf("Invalid input!!\n");
return -1;
}
- printf("IPv4 address : %s\n", ip_addr);
- g_free(ip_addr);
+ switch (input) {
+ case 1:
+ connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
+ if (ip_addr == NULL) {
+ printf("IPv4 address does not exist\n");
+ return -1;
+ }
+ printf("IPv4 address : %s\n", ip_addr);
+ break;
+ case 2:
+ connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
+ if (ip_addr == NULL) {
+ printf("IPv6 address does not exist\n");
+ return -1;
+ }
+ printf("IPv6 address : %s\n", ip_addr);
+ break;
+ default:
+ printf("Wrong IP address family!!\n");
+ return -1;
+ }
+
+ g_free(ip_addr);
return 1;
}
connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
printf("last recv data size [%lld]\n", rv);
connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
- printf("last sent data size [%lld]\n",rv );
+ printf("last sent data size [%lld]\n", rv);
connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
- printf("total received data size [%lld]\n",rv );
+ printf("total received data size [%lld]\n", rv);
connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
printf("total sent data size [%lld]\n", rv);
connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
printf("WiFi last recv data size [%lld]\n", rv);
connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
- printf("WiFi last sent data size [%lld]\n",rv );
+ printf("WiFi last sent data size [%lld]\n", rv);
connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
- printf("WiFi total received data size [%lld]\n",rv );
+ printf("WiFi total received data size [%lld]\n", rv);
connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
printf("WiFi total sent data size [%lld]\n", rv);
rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get profile iterator [%d]\n", rv);
+ printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
return -1;
}
printf("Fail to get profile name\n");
return -1;
}
- printf("profile name : %s\n", profile_name);
+ printf("profile name is %s\n", profile_name);
g_free(profile_name);
if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) {
rv = connection_get_current_profile(connection, &profile_h);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get profile iterator [%d]\n", rv);
+ printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
return -1;
}
char *profile_name = NULL;
rv = test_get_user_int("Input profile type to get"
- "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering):", &input);
+ "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering, 6:Application):", &input);
if (rv == false) {
printf("Invalid input!!\n");
case 5:
service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
break;
+ case 6:
+ service_type = CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION;
+ break;
default:
printf("Wrong number!!\n");
return -1;
if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false)
return -1;
+ g_strstrip(input_str);
rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile);
if (rv != CONNECTION_ERROR_NONE)
RETURN_FAIL_DESTROY(profile);
break;
case CONNECTION_PROFILE_TYPE_ETHERNET:
- case CONNECTION_PROFILE_TYPE_BT:
- printf("Not supported!\n");
- /* fall through */
+ if (test_update_network_info(profile) == -1)
+ return -1;
+
+ break;
+ case CONNECTION_PROFILE_TYPE_BT:
+ printf("Not supported!\n");
+ /* fall through */
default:
+ {
+ int profile_type = prof_type;
+ if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
+ if (test_update_wifi_info(profile) == -1)
+ return -1;
+ break;
+ }
+ }
return -1;
}
{
connection_profile_type_e prof_type;
connection_profile_state_e profile_state;
+ connection_profile_state_e profile_ipv6_state;
connection_profile_h profile;
char *profile_name = NULL;
+ int address_family = 0;
printf("\n** Choose a profile to print. **\n");
if (test_get_user_selected_profile(&profile, true) == false)
}
if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
- printf("Fail to get profile state\n");
+ printf("Fail to get profile IPv4 state\n");
return -1;
} else
printf("Profile State : %s\n", test_print_state(profile_state));
+ if (connection_profile_get_ipv6_state(profile, &profile_ipv6_state) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile IPv6 state\n");
+ return -1;
+ } else
+ printf("Profile IPv6 State : %s\n", test_print_state(profile_ipv6_state));
+
if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
return -1;
+ test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
+
switch (prof_type) {
case CONNECTION_PROFILE_TYPE_CELLULAR:
printf("Profile Type : Cellular\n");
printf("Profile Type : Bluetooth\n");
break;
default:
+ {
+ int profile_type = prof_type;
+ if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
+ printf("Profile Type : Mesh\n");
+ test_print_mesh_info(profile);
+ break;
+ }
+ }
return -1;
}
- test_print_network_info(profile);
+ test_print_network_info(profile, address_family);
return 1;
}
connection_profile_state_e profile_state;
connection_profile_h profile;
char *profile_name = NULL;
+ int address_family = 0;
printf("\n** Choose a profile to refresh. **\n");
if (test_get_user_selected_profile(&profile, true) == false)
if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
return -1;
+ test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
+
switch (prof_type) {
case CONNECTION_PROFILE_TYPE_CELLULAR:
printf("Profile Type : Cellular\n");
printf("Profile Type : Bluetooth\n");
break;
default:
+ {
+ int profile_type = prof_type;
+ if (profile_type == CONNECTION_PROFILE_TYPE_MESH) {
+ printf("Profile Type : Mesh\n");
+ test_print_mesh_info(profile);
+ break;
+ }
+ }
return -1;
}
- test_print_network_info(profile);
+ test_print_network_info(profile, address_family);
return 1;
}
int test_add_route(void)
{
int rv = 0;
- char ip_addr[30];
- char if_name[40];
+ char ip_addr[100] = {0};
+ char if_name[40] = {0};
- if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 30) == false)
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
return -1;
if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
return -1;
+ g_strstrip(ip_addr);
+ g_strstrip(if_name);
rv = connection_add_route(connection, if_name, ip_addr);
if (rv != CONNECTION_ERROR_NONE) {
printf("Fail to get add new route [%d]\n", rv);
return -1;
}
+ printf("Add Route successfully\n");
return 1;
}
int test_remove_route(void)
{
int rv = 0;
- char ip_addr[30];
- char if_name[40];
+ char ip_addr[100] = {0};
+ char if_name[40] = {0};
- if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 30) == false)
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
return -1;
if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
return -1;
+ g_strstrip(ip_addr);
+ g_strstrip(if_name);
rv = connection_remove_route(connection, if_name, ip_addr);
if (rv != CONNECTION_ERROR_NONE) {
printf("Fail to remove the route [%s]\n", test_print_error(rv));
return -1;
}
+ printf("Remove Route successfully\n");
+
+ return 1;
+}
+
+int test_add_route_ipv6(void)
+{
+ int rv = 0;
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+
+ if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get add new route [%d]\n", rv);
+ return -1;
+ }
+ printf("Add Route successfully\n");
return 1;
}
+int test_remove_route_ipv6(void)
+{
+ int rv = 0;
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+
+ if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to remove the route [%d]\n", rv);
+ return -1;
+ }
+ printf("Remove Route successfully\n");
+
+ return 1;
+}
+
+int test_add_route_entry(void)
+{
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+ int input;
+ bool input_rv;
+ int rv = 0;
+
+ input_rv = test_get_user_int("Input Address type to get"
+ "(1:IPV4, 2:IPV6):", &input);
+
+ if (input_rv == false) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ switch (input) {
+ case 1:
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get add new route [%d]\n", rv);
+ return -1;
+ }
+ printf("Add Route successfully\n");
+ break;
+
+ case 2:
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_add_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get add new route [%d]\n", rv);
+ return -1;
+ }
+ printf("Add Route successfully\n");
+ break;
+
+ default:
+ printf("Wrong IP address family!!\n");
+ return -1;
+
+ }
+
+ return 1;
+
+}
+
+int test_remove_route_entry(void)
+{
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+ int input;
+ bool input_rv;
+ int rv = 0;
+
+ input_rv = test_get_user_int("Input Address type to get"
+ "(1:IPV4, 2:IPV6):", &input);
+
+ if (input_rv == false) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ switch (input) {
+ case 1:
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV4, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to remove the route [%s]\n", test_print_error(rv));
+ return -1;
+ }
+ printf("Remove Route successfully\n");
+
+ break;
+
+ case 2:
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_remove_route_entry(connection, CONNECTION_ADDRESS_FAMILY_IPV6, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to remove the route [%d]\n", rv);
+ return -1;
+ }
+ printf("Remove Route successfully\n");
+ break;
+
+ default:
+ printf("Wrong IP address family!!\n");
+ return -1;
+
+ }
+
+ return 1;
+
+}
+
int test_get_bt_state(void)
{
int rv = 0;
rv = connection_get_bt_state(connection, &bt_state);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get Bluetooth state [%d]\n", rv);
+ printf("Fail to get Bluetooth state [%s]\n", test_print_error(rv));
return -1;
}
- printf("Retval = %d, Bluetooth state [%d]\n", rv, bt_state);
+ printf("Retval = [%s], Bluetooth state [%d]\n", test_print_error(rv), bt_state);
return 1;
}
return 1;
}
+int test_get_mac_address(void)
+{
+ int rv = 0, type = 0;
+ connection_type_e conn_type;
+ char *mac_addr = NULL;
+
+ test_get_user_int("Input connection type (1:wifi, 2:ethernet)", &type);
+
+ switch (type) {
+ case 1:
+ conn_type = CONNECTION_TYPE_WIFI;
+ break;
+ case 2:
+ conn_type = CONNECTION_TYPE_ETHERNET;
+ break;
+ default:
+ printf("Wrong number!!\n");
+ return -1;
+ }
+
+ rv = connection_get_mac_address(connection, conn_type, &mac_addr);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get MAC address [%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ printf("mac address is %s\n", mac_addr);
+
+ g_free(mac_addr);
+
+ return 1;
+}
+
+int test_get_ethernet_cable_state(void)
+{
+ int rv = 0;
+ connection_ethernet_cable_state_e cable_state;
+
+ rv = connection_get_ethernet_cable_state(connection, &cable_state);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get ethernet cable state [%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ printf("Retval = [%s], Ethernet cable state [%d]\n", test_print_error(rv), cable_state);
+
+ return 1;
+}
+
int test_reset_profile(void)
{
int type, sim_id, rv;
return -1;
}
- if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE) {
+ if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+static bool test_get_ipv6_address_callback(char *ipv6_address, void* user_data)
+{
+ printf("IPv6 Address : %s\n", ipv6_address);
+ return true;
+}
+
+int test_foreach_ipv6_address(void)
+{
+ int rv = 0;
+ int type;
+ connection_type_e conn_type;
+
+ test_get_user_int("Input Connection Type(1: WiFi 2: Ethernet) :", &type);
+
+ switch (type) {
+ case 1:
+ conn_type = CONNECTION_TYPE_WIFI;
+ break;
+ case 2:
+ conn_type = CONNECTION_TYPE_ETHERNET;
+ break;
+ default:
+ printf("Wrong number!!\n");
+ return -1;
+ }
+
+ rv = connection_foreach_ipv6_address(connection, conn_type, test_get_ipv6_address_callback, NULL);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get IPv6 address\n");
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_is_metered_network(void)
+{
+ int rv = 0;
+ bool metered_state;
+
+ rv = connection_is_metered_network(connection, &metered_state);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get metered state [%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ printf("Retval = [%s] metered state [%s]\n",
+ test_print_error(rv), metered_state ? "TRUE" : "FALSE");
+
+ return 1;
+}
+
+int test_start_tcpdump(void)
+{
+ if (connection_profile_start_tcpdump(connection) != CONNECTION_ERROR_NONE) {
+ return -1;
+ }
+
+ printf("Successfully started tcpdump\n");
+
+ return 1;
+}
+
+int test_stop_tcpdump(void)
+{
+ if (connection_profile_stop_tcpdump(connection) != CONNECTION_ERROR_NONE) {
+ return -1;
+ }
+
+ printf("Successfully stopped tcpdump\n");
+
+ return 1;
+}
+
+int test_get_tcpdump_state(void)
+{
+ gboolean tcpdump_state = FALSE;
+
+ if (connection_profile_get_tcpdump_state(connection, &tcpdump_state) != CONNECTION_ERROR_NONE) {
+ return -1;
+ }
+
+ printf("tcpdump %s running\n", tcpdump_state ? "is" : "is not");
+
+ return 1;
+}
+
+int test_mptcp_enable(void)
+{
+ int rv = 0;
+ bool supported = false;
+ rv = connection_mptcp_is_supported(connection, &supported);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+ printf("MPTCP Support: %d\n", supported);
+
+ rv = connection_mptcp_enable(connection, CONNECTION_MPTCP_ENABLE_ALL);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int test_mptcp_disable(void)
+{
+ int rv = 0;
+ rv = connection_mptcp_disable(connection);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+ return 1;
+}
+
+int test_mptcp_set_path_manager(void)
+{
+ int rv = 0;
+ int input = 0;
+ rv = test_get_user_int("Input Path Manager (1: default, 2: fullmesh)", &input);
+
+ switch (input) {
+ case 1:
+ rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_DEFAULT);
+ break;
+ case 2:
+ rv = connection_mptcp_set_path_manager(connection, CONNECTION_MPTCP_PM_FULLMESH);
+ break;
+ default:
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_mptcp_get_path_manager(void)
+{
+ int rv = 0;
+ connection_mptcp_path_manager_e pm;
+
+ rv = connection_mptcp_get_path_manager(connection, &pm);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ switch (pm) {
+ case CONNECTION_MPTCP_PM_DEFAULT:
+ printf("Path Manager: Default\n");
+ break;
+ case CONNECTION_MPTCP_PM_FULLMESH:
+ printf("Path Manager: FullMesh\n");
+ break;
+ default:
+ printf("Error: Invalid Path Manager\n");
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_mptcp_set_scheduler(void)
+{
+ int rv = 0;
+ int input = 0;
+ rv = test_get_user_int("Input Scheduler (1: default, 2: roundrobin)", &input);
+
+ switch (input) {
+ case 1:
+ rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_DEFAULT);
+ break;
+ case 2:
+ rv = connection_mptcp_set_scheduler(connection, CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN);
+ break;
+ default:
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_mptcp_get_scheduler(void)
+{
+ int rv = 0;
+ connection_mptcp_scheduler_e scheduler;
+
+ rv = connection_mptcp_get_scheduler(connection, &scheduler);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Failure[%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ switch (scheduler) {
+ case CONNECTION_MPTCP_SCHEDULER_DEFAULT:
+ printf("Scheduler: Default\n");
+ break;
+ case CONNECTION_MPTCP_SCHEDULER_ROUNDROBIN:
+ printf("Scheduler: RountRobin\n");
+ break;
+ default:
+ printf("Error: Invalid Scheduler\n");
return -1;
}
int main(int argc, char **argv)
{
GMainLoop *mainloop;
- mainloop = g_main_loop_new (NULL, FALSE);
+ mainloop = g_main_loop_new(NULL, FALSE);
GIOChannel *channel = g_io_channel_unix_new(0);
- g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread,NULL );
+ g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL);
printf("Test Thread created...\n");
- g_main_loop_run (mainloop);
+ g_main_loop_run(mainloop);
return 0;
}
{
int rv = 0;
char a[100];
-
+
memset(a, '\0', 100);
printf("Event received from stdin\n");
-
+
rv = read(0, a, 100);
-
+
if (rv < 0 || a[0] == '0') {
if (connection != NULL)
test_deregister_client();
exit(1);
}
- if (*a == '\n' || *a == '\r'){
+ if (*a == '\n' || *a == '\r') {
+/* Public API */
printf("\n\n Network Connection API Test App\n\n");
printf("Options..\n");
- printf("1 - Create Handle and set callbacks\n");
- printf("2 - Destroy Handle(unset callbacks automatically)\n");
- printf("3 - Get network state\n");
- printf("4 - Get cellular state (please insert SIM Card)\n");
- printf("5 - Get wifi state (please turn on WiFi)\n");
- printf("6 - Get current proxy address \n");
- printf("7 - Get current Ip address\n");
- printf("8 - Get cellular data call statistics\n");
- printf("9 - Get WiFi data call statistics\n");
- printf("a - Get Profile list\n");
- printf("b - Get Connected Profile list\n");
- printf("c - Get Current profile\n");
- printf("d - Open connection with profile\n");
- printf("e - Get default cellular service by type\n");
- printf("f - Set default cellular service by type\n");
- printf("g - Close connection with profile\n");
- printf("h - Add profile(Cellular only)\n");
- printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n");
- printf("j - Update profile\n");
- printf("k - Get profile info\n");
- printf("l - Refresh profile info\n");
- printf("m - Set state changed callback\n");
- printf("n - Unset state changed callback\n");
- printf("o - Reset cellular data call statistics\n");
- printf("p - Reset WiFi data call statistics\n");
- printf("q - Add new route\n");
- printf("r - Get Bluetooth state\n");
- printf("s - Get profile id\n");
- printf("0 - Exit \n");
- printf("ENTER - Show options menu.......\n");
+ printf(LOG_BLUE "[Public APIs]\n" LOG_END);
+ printf(LOG_GREEN "1 - Create Handle and set callbacks\n" LOG_END);
+ printf("2 - Destroy Handle(unset callbacks automatically)\n");
+ printf(LOG_GREEN "3 - Get network state\n" LOG_END);
+ printf(LOG_GREEN "4 - Get cellular state (please insert SIM Card)\n" LOG_END);
+ printf(LOG_GREEN "5 - Get wifi state (please turn on WiFi)\n" LOG_END);
+ printf("6 - Get current proxy address \n");
+ printf("7 - Get current Ip address\n");
+ printf("8 - Get cellular data call statistics\n");
+ printf("9 - Get WiFi data call statistics\n");
+ printf(LOG_GREEN "a - Get Profile list\n" LOG_END);
+ printf(LOG_GREEN "b - Get Connected Profile list\n" LOG_END);
+ printf(LOG_GREEN "c - Get Current profile\n" LOG_END);
+ printf("d - Open connection with profile\n");
+ printf("e - Get default cellular service by type\n");
+ printf("f - Set default cellular service by type\n");
+ printf("g - Close connection with profile\n");
+ printf("h - Add profile(Cellular and Wifi only)\n");
+ printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n");
+ printf("j - Update profile\n");
+ printf("k - Get profile info\n");
+ printf("l - Refresh profile info\n");
+ printf("m - Set state changed callback\n");
+ printf("n - Unset state changed callback\n");
+ printf("o - Reset cellular data call statistics\n");
+ printf("p - Reset WiFi data call statistics\n");
+ printf("q - Add new route\n");
+ printf("r - Remove a route\n");
+ printf("s - Get Bluetooth state\n");
+ printf("t - Get profile id\n");
+ printf("u - Reset profile\n");
+ printf("v - Get all cellular default profiles\n");
+ printf("w - Get mac address\n");
+ printf("x - Get ethernet cable state\n");
+ printf("B - Add IPv6 new route\n");
+ printf("C - Remove IPv6 route\n");
+ printf("D - Add new route entry\n");
+ printf("E - Remove route entry\n");
+ printf("F - Get all IPv6 address\n");
+ printf("G - Get metered state\n");
+/* Extension API */
+ printf(LOG_BLUE "[Extension API]\n" LOG_END);
+ printf("H - Start TCP Dump\n");
+ printf("I - Stop TCP Dump\n");
+ printf("J - Get TCP Dump State\n");
+ printf("K - Enable MPTCP (internal)\n");
+ printf("L - Disable MPTCP (internal)\n");
+ printf("M - Set MPTCP Path Manager (internal)\n");
+ printf("N - Get MPTCP Path Manager (internal)\n");
+ printf("O - Set MPTCP Scheduler (internal)\n");
+ printf("P - Get MPTCP Scheduler (internal)\n");
+ printf(LOG_GREEN "Q - Create Handle and set callbacks in C# API\n" LOG_END);
+ printf("R - Destroy Handle(unset callbacks automatically in C# API)\n");
+ printf(LOG_RED "0 - Exit \n" LOG_END);
+ printf("ENTER - Show options menu.......\n");
}
switch (a[0]) {
+/* Public API */
case '1':
rv = test_register_client();
break;
case 'v':
rv = test_get_default_profile_list();
break;
+ case 'w':
+ rv = test_get_mac_address();
+ break;
+ case 'x':
+ rv = test_get_ethernet_cable_state();
+ break;
+ case 'B':
+ rv = test_add_route_ipv6();
+ break;
+ case 'C':
+ rv = test_remove_route_ipv6();
+ break;
+ case 'D':
+ rv = test_add_route_entry();
+ break;
+ case 'E':
+ rv = test_remove_route_entry();
+ break;
+ case 'F':
+ rv = test_foreach_ipv6_address();
+ break;
+ case 'G':
+ rv = test_is_metered_network();
+ break;
+/* Extension API */
+ case 'H':
+ rv = test_start_tcpdump();
+ break;
+ case 'I':
+ rv = test_stop_tcpdump();
+ break;
+ case 'J':
+ rv = test_get_tcpdump_state();
+ break;
+ case 'K':
+ rv = test_mptcp_enable();
+ break;
+ case 'L':
+ rv = test_mptcp_disable();
+ break;
+ case 'M':
+ rv = test_mptcp_set_path_manager();
+ break;
+ case 'N':
+ rv = test_mptcp_get_path_manager();
+ break;
+ case 'O':
+ rv = test_mptcp_set_scheduler();
+ break;
+ case 'P':
+ rv = test_mptcp_get_scheduler();
+ break;
+ case 'Q':
+ rv = test_register_client_cs();
+ break;
+ case 'R':
+ rv = test_deregister_client_cs();
+ break;
+
}
if (rv == 1)