connection_set_default_cb set_default_cb;
connection_reset_cb reset_profile_cb;
libnet_ethernet_cable_state_changed_cb ethernet_cable_state_changed_cb;
+ libnet_type_changed_cb type_changed_cb;
+ libnet_ip_changed_cb ip_changed_cb;
+ libnet_proxy_changed_cb proxy_changed_cb;
void *opened_user_data;
void *closed_user_data;
void *set_default_user_data;
};
static __thread struct _profile_list_s profile_iterator = {0, 0, NULL};
-static __thread struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL, NULL, false};
+static __thread struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, false};
static __thread GSList *managed_idler_list = NULL;
static __thread bool connection_is_feature_checked[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
static __thread bool connection_feature_supported[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
libnet.ethernet_cable_state_changed_cb(state);
}
+static void __libnet_type_changed_cb(int type)
+{
+ if (libnet.type_changed_cb)
+ libnet.type_changed_cb(type);
+}
+
+static void __libnet_ip_changed_cb(connection_address_family_e addr_family,
+ char *ip_addr)
+{
+ if (libnet.ip_changed_cb)
+ libnet.ip_changed_cb(addr_family, ip_addr);
+}
+
+static void __libnet_proxy_changed_cb(char *proxy_addr)
+{
+ if (libnet.proxy_changed_cb)
+ libnet.proxy_changed_cb(proxy_addr);
+}
+
static gboolean __libnet_state_changed_cb_idle(gpointer data)
{
struct _state_notify *notify = (struct _state_notify *)data;
CONNECTION_LOG(CONNECTION_INFO, "Got Ethernet cable detached Indication\n");
__libnet_ethernet_cable_state_changed_cb(CONNECTION_ETHERNET_CABLE_DETACHED);
break;
+ case NET_EVENT_NETWORK_TYPE_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Network Type Changed Indication");
+ int *state = (int *) event_cb->Data;
+ __libnet_type_changed_cb(*state);
+ break;
+ case NET_EVENT_IPV4_ADDRESS_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got IPv4 Address Changed Indication");
+ char *ipv4_addr = (char *)event_cb->Data;
+ __libnet_ip_changed_cb(CONNECTION_ADDRESS_FAMILY_IPV4, ipv4_addr);
+ break;
+ case NET_EVENT_IPV6_ADDRESS_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got IPv6 Address Changed Indication");
+ char *ipv6_addr = (char *)event_cb->Data;
+ __libnet_ip_changed_cb(CONNECTION_ADDRESS_FAMILY_IPV6, ipv6_addr);
+ break;
+ case NET_EVENT_PROXY_ADDRESS_CHANGED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Proxy Changed Indication");
+ char *proxy_addr = (char *)event_cb->Data;
+ __libnet_proxy_changed_cb(proxy_addr);
+ break;
default:
break;
}
//LCOV_EXCL_STOP
+int _connection_libnet_get_metered_state(bool* is_metered)
+{
+ int rv = 0;
+ int status = 0;
+
+ rv = net_get_metered_state(&status);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get metered state[%d]", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ if (status == 1)
+ *is_metered = true;
+ else
+ *is_metered = false;
+ return CONNECTION_ERROR_NONE;
+}
+
int _connection_libnet_get_wifi_state(connection_wifi_state_e *state)
{
int rv;
return CONNECTION_ERROR_NONE;
}
+void _connection_libnet_set_type_changed_cb(libnet_type_changed_cb callback)
+{
+ libnet.type_changed_cb = callback;
+}
+
+void _connection_libnet_set_ip_changed_cb(libnet_ip_changed_cb callback)
+{
+ libnet.ip_changed_cb = callback;
+}
+
+void _connection_libnet_set_proxy_changed_cb(libnet_proxy_changed_cb callback)
+{
+ libnet.proxy_changed_cb = callback;
+}
+
//LCOV_EXCL_START
int _connection_libnet_get_ethernet_state(connection_ethernet_state_e *state)
{
set_last_result(CONNECTION_ERROR_NONE);
return CONNECTION_ERROR_NONE;
}
+
+int _connection_libnet_start_tcpdump(void)
+{
+ connection_error_e result = CONNECTION_ERROR_NONE;
+ net_err_t ret = NET_ERR_NONE;
+
+ ret = net_start_tcpdump();
+ result = __libnet_convert_to_cp_error_type(ret);
+
+ return result;
+}
+
+int _connection_libnet_stop_tcpdump(void)
+{
+ connection_error_e result = CONNECTION_ERROR_NONE;
+ net_err_t ret = NET_ERR_NONE;
+
+ ret = net_stop_tcpdump();
+ result = __libnet_convert_to_cp_error_type(ret);
+
+ return result;
+}
+
+int _connection_libnet_get_tcpdump_state(gboolean *tcpdump_state)
+{
+ connection_error_e result = CONNECTION_ERROR_NONE;
+ net_err_t ret = NET_ERR_NONE;
+
+ ret = net_get_tcpdump_state(tcpdump_state);
+ result = __libnet_convert_to_cp_error_type(ret);
+
+ return result;
+}