#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
-#include <ITapiSim.h>
-#include <TapiUtility.h>
-#include <bundle.h>
-#include <bundle_internal.h>
-#include <eventsystem.h>
#include "log.h"
#include "util.h"
#include "network-dpm.h"
#include "network-monitor.h"
#include "netsupplicant.h"
-#include "wifi-tel-intf.h"
-#include "clatd-handler.h"
#include "generated-code.h"
/* Define TCP buffer sizes for various networks */
#define ROUTE_EXEC_PATH "/sbin/route"
+#define TELEPHONY_SERVICE "com.tcore.ps"
+#define TELEPHONY_MASTER_INTERFACE TELEPHONY_SERVICE ".master"
+#define TELEPHONY_MODEM_INTERFACE TELEPHONY_SERVICE ".modem"
+#define TELEPHONY_PROFILE_INTERFACE TELEPHONY_SERVICE ".context"
+#define TELEPHONY_MASTER_PATH "/"
+#define NET_PROFILE_NAME_LEN_MAX 512
+
+typedef struct {
+ char profile_name[NET_PROFILE_NAME_LEN_MAX];
+} net_profile_name_t;
+
static Network *netconfigstate = NULL;
struct netconfig_default_connection {
char *proxy;
char *essid;
unsigned int freq;
+ gboolean is_metered;
};
static struct netconfig_default_connection
return default_profile;
}
+static int __netconfig_telephony_get_modem_object_path(GSList **modem_path_list)
+{
+ GVariant *result;
+ GVariantIter *iter_modem = NULL;
+ GVariantIter *modem_properties = NULL;
+ const char *modem_path;
+
+ result = netconfig_invoke_dbus_method(TELEPHONY_SERVICE, TELEPHONY_MASTER_PATH,
+ TELEPHONY_MASTER_INTERFACE, "GetModems", NULL);
+ if (result == NULL) {
+ ERR("Failed to get modem path list");
+ return -1;
+ }
+
+ g_variant_get(result, "(a{sa{ss}})", &iter_modem);
+ while (g_variant_iter_loop(iter_modem, "{sa{ss}}", &modem_path, &modem_properties)) {
+ *modem_path_list = g_slist_append(*modem_path_list, g_strdup(modem_path));
+ DBG("modem object path: %s", modem_path);
+ }
+
+ g_variant_iter_free(iter_modem);
+ g_variant_unref(result);
+
+ return 0;
+}
+
+static int __netconfig_telephony_get_profile_list(net_profile_name_t **profile_list,
+ int *profile_count)
+{
+ int ret = 0;
+ int count = 0, i = 0;
+ const char *str = NULL;
+ GVariant *result;
+ GVariantIter *iter = NULL;
+ GSList *profiles = NULL, *list = NULL;
+ net_profile_name_t *plist = NULL;
+
+ GSList *modem_path_list = NULL;
+ const char *path = NULL;
+
+ ret = __netconfig_telephony_get_modem_object_path(&modem_path_list);
+ if (ret < 0) {
+ ERR("Failed to get modems path list");
+
+ g_slist_free_full(modem_path_list, g_free);
+ return ret;
+ }
+
+ for (list = modem_path_list; list != NULL; list = list->next) {
+ path = (const char *)list->data;
+
+ DBG("path: %s", path);
+ result = netconfig_invoke_dbus_method(TELEPHONY_SERVICE, path,
+ TELEPHONY_MODEM_INTERFACE, "GetProfileList", NULL);
+ if (result == NULL) {
+ DBG("Failed to get profiles: %s", path);
+ continue;
+ }
+
+ g_variant_get(result, "(as)", &iter);
+ while (g_variant_iter_loop(iter, "s", &str))
+ profiles = g_slist_append(profiles, g_strdup(str));
+
+ g_variant_iter_free(iter);
+ g_variant_unref(result);
+ }
+
+ g_slist_free_full(modem_path_list, g_free);
+
+ count = g_slist_length(profiles);
+ if (count > 0) {
+ plist = (net_profile_name_t*)malloc(sizeof(net_profile_name_t) * count);
+ } else {
+ *profile_count = 0;
+ goto out;
+ }
+
+ if (plist == NULL) {
+ ERR("Failed to allocate memory");
+ *profile_count = 0;
+ ret = -1;
+ goto out;
+ }
+
+ for (list = profiles, i = 0; list != NULL; list = list->next, i++)
+ g_strlcpy(plist[i].profile_name,
+ (const char *)list->data, NET_PROFILE_NAME_LEN_MAX);
+
+ *profile_list = plist;
+ *profile_count = count;
+
+out:
+ g_slist_free_full(profiles, g_free);
+
+ return ret;
+}
+
+static int __netconfig_telephony_search_pdp_profile(const char* profile_name, net_profile_name_t* pdp_name)
+{
+ int ret;
+ net_profile_name_t* profile_list = NULL;
+ char* prof_name = NULL;
+ char* tel_prof_name = NULL;
+ char* found_ptr = NULL;
+ int profile_count = 0;
+ int i;
+
+ /* Get pdp profile list from telephony service */
+ ret = __netconfig_telephony_get_profile_list(&profile_list, &profile_count);
+ if (ret < 0) {
+ ERR("Failed to get profile list from telephony service");
+ g_free(profile_list);
+ return ret;
+ }
+
+ if (profile_list == NULL || profile_count <= 0) {
+ ERR("There is no PDP profiles");
+ g_free(profile_list);
+ return -1;
+ }
+
+ /* Find matching profile */
+ prof_name = strrchr(profile_name, '/') + 1;
+ for (i = 0; i < profile_count; i++) {
+ tel_prof_name = strrchr(profile_list[i].profile_name, '/') + 1;
+ found_ptr = strstr(prof_name, tel_prof_name);
+
+ if (found_ptr != NULL && g_strcmp0(found_ptr, tel_prof_name) == 0) {
+ g_strlcpy(pdp_name->profile_name,
+ profile_list[i].profile_name, NET_PROFILE_NAME_LEN_MAX);
+
+ DBG("PDP profile name found in cellular profile: %s", pdp_name->profile_name);
+ break;
+ }
+ }
+
+ if (i >= profile_count) {
+ ERR("There is no matching PDP profiles");
+ g_free(profile_list);
+ return -1;
+ }
+
+ g_free(profile_list);
+
+ return ret;
+}
+
+static gboolean __netconfig_telephony_get_metered_info(net_profile_name_t* pdp_name)
+{
+ GVariant *result;
+ GVariantIter *iter;
+ const gchar *key = NULL;
+ const gchar *value = NULL;
+ gboolean ret = FALSE;
+
+ if (pdp_name == NULL) {
+ ERR("Invalid parameter!");
+ return ret;
+ }
+
+ result = netconfig_invoke_dbus_method(TELEPHONY_SERVICE, pdp_name->profile_name,
+ TELEPHONY_PROFILE_INTERFACE, "GetProfile", NULL);
+ if (result == NULL) {
+ ERR("_net_invoke_dbus_method failed");
+ return ret;
+ }
+
+ g_variant_get(result, "(a{ss})", &iter);
+ while (g_variant_iter_next(iter, "{ss}", &key, &value)) {
+ if (g_strcmp0(key, "is_metered") == 0) {
+ if (value == NULL)
+ continue;
+
+ if (g_strcmp0(value, "TRUE") == 0)
+ ret = TRUE;
+ }
+ }
+
+ g_variant_iter_free(iter);
+ g_variant_unref(result);
+
+ DBG("is_metered = %s", ret ? "TRUE" : "FALSE");
+
+ return ret;
+}
+
static void __netconfig_get_default_connection_info(const char *profile)
{
GVariant *message = NULL, *variant = NULL, *variant2 = NULL;
- GVariantIter *iter = NULL, *iter1 = NULL;
+ GVariantIter *iter = NULL, *iter1 = NULL, *service = NULL;
GVariant *next = NULL;
+ gchar *obj_path;
gchar *key = NULL;
gchar *key1 = NULL;
gchar *key2 = NULL;
+ gboolean found_profile = 0;
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, profile,
- CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetServices", NULL);
if (message == NULL) {
- ERR("Failed to get service properties");
+ ERR("Failed to get services informations");
+ goto done;
+ }
+
+ g_variant_get(message, "(a(oa{sv}))", &service);
+ if (service == NULL) {
+ ERR("Failed to get services iter");
+ goto done;
+ }
+
+ while (g_variant_iter_loop(service, "(oa{sv})", &obj_path, &iter)) {
+ if (g_strcmp0(obj_path, profile) == 0) {
+ g_free(obj_path);
+ found_profile = 1;
+ break;
+ }
+ }
+
+ if (iter == NULL || found_profile == 0) {
+ ERR("Profile %s doesn't exist", profile);
goto done;
}
- g_variant_get(message, "(a{sv})", &iter);
while (g_variant_iter_loop(iter, "{sv}", &key, &next)) {
const gchar *value = NULL;
guint16 freq = 0;
}
} else if (g_strcmp0(key, "Ethernet") == 0) {
g_variant_get(next, "a{sv}", &iter1);
+ if (iter1 == NULL)
+ continue;
while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) {
if (g_strcmp0(key1, "Interface") == 0) {
value = g_variant_get_string(variant, NULL);
netconfig_default_connection_info.ifname = g_strdup(value);
}
}
- if (iter1)
- g_variant_iter_free(iter1);
+ g_variant_iter_free(iter1);
} else if (g_strcmp0(key, "IPv4") == 0) {
g_variant_get(next, "a{sv}", &iter1);
+ if (iter1 == NULL)
+ continue;
while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) {
if (g_strcmp0(key1, "Address") == 0) {
value = g_variant_get_string(variant, NULL);
netconfig_default_connection_info.ipaddress = g_strdup(value);
}
}
- if (iter1)
- g_variant_iter_free(iter1);
+ g_variant_iter_free(iter1);
} else if (g_strcmp0(key, "IPv6") == 0) {
g_variant_get(next, "a{sv}", &iter1);
+ if (iter1 == NULL)
+ continue;
while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) {
if (g_strcmp0(key1, "Address") == 0) {
value = g_variant_get_string(variant, NULL);
netconfig_default_connection_info.ipaddress6 = g_strdup(value);
}
}
- if (iter1)
- g_variant_iter_free(iter1);
+ g_variant_iter_free(iter1);
+
} else if (g_strcmp0(key, "Proxy") == 0) {
g_variant_get(next, "a{sv}", &iter1);
+ if (iter1 == NULL)
+ continue;
while (g_variant_iter_loop(iter1, "{sv}", &key2, &variant2)) {
GVariantIter *iter_sub = NULL;
}
}
}
- if (iter1)
- g_variant_iter_free(iter1);
+ g_variant_iter_free(iter1);
} else if (g_strcmp0(key, "Frequency") == 0) {
if (g_variant_is_of_type(next, G_VARIANT_TYPE_UINT16)) {
freq = g_variant_get_uint16(next);
}
}
+ if (netconfig_is_cellular_profile(profile) == TRUE) {
+ net_profile_name_t pdp_name;
+ int ret;
+
+ ret = __netconfig_telephony_search_pdp_profile(profile, &pdp_name);
+ if (ret >= 0 && strlen(pdp_name.profile_name) > 0)
+ if (__netconfig_telephony_get_metered_info(&pdp_name))
+ netconfig_default_connection_info.is_metered = TRUE;
+ }
+
done:
if (message)
g_variant_unref(message);
if (iter)
g_variant_iter_free(iter);
- if (iter1)
- g_variant_iter_free(iter1);
+ if (service)
+ g_variant_iter_free(service);
return;
}
+static char *__netconfig_get_preferred_ipv6_address(char *profile)
+{
+ GVariant *message = NULL, *variant = NULL, *next = NULL;
+ GVariantIter *iter = NULL, *sub_iter = NULL, *service = NULL;
+ gchar *obj_path;
+ gchar *key = NULL;
+ gchar *sub_key = NULL;
+ gchar *preferred_address6 = NULL;
+ gboolean found_profile = 0;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetServices", NULL);
+ if (message == NULL) {
+ ERR("Failed to get service informations");
+ goto done;
+ }
+
+ g_variant_get(message, "(a(oa{sv}))", &service);
+ if (service == NULL) {
+ ERR("Failed to get services iter");
+ goto done;
+ }
+
+ while (g_variant_iter_loop(service, "(oa{sv})", &obj_path, &iter)) {
+ if (g_strcmp0(obj_path, profile) == 0) {
+ g_free(obj_path);
+ found_profile = 1;
+ break;
+ }
+ }
+
+ if (iter == NULL || found_profile == 0) {
+ ERR("Profile %s doesn't exist", profile);
+ goto done;
+ }
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &next)) {
+ const gchar *value = NULL;
+ if (g_strcmp0(key, "IPv6") == 0) {
+ g_variant_get(next, "a{sv}", &sub_iter);
+ if (sub_iter == NULL)
+ continue;
+ while (g_variant_iter_loop(sub_iter, "{sv}", &sub_key, &variant)) {
+ if (g_strcmp0(sub_key, "Address") == 0) {
+ value = g_variant_get_string(variant, NULL);
+ preferred_address6 = g_strdup(value);
+ }
+ }
+ g_variant_iter_free(sub_iter);
+ }
+ }
+
+done:
+ if (message)
+ g_variant_unref(message);
+
+ if (iter)
+ g_variant_iter_free(iter);
+
+ if (service)
+ g_variant_iter_free(service);
+
+ return preferred_address6;
+}
+
static void __netconfig_adjust_tcp_buffer_size(void)
{
int fdr = 0, fdw = 0;
rmax_size = NET_TCP_BUFFERSIZE_WIFI_RMEM_MAX;
wmax_size = NET_TCP_BUFFERSIZE_WIFI_WMEM_MAX;
} else if (netconfig_is_cellular_profile(profile) == TRUE) {
- TapiHandle *tapi_handle = NULL;
int telephony_svctype = 0, telephony_pstype = 0;
- tapi_handle = (TapiHandle *)netconfig_tel_init();
- if (NULL != tapi_handle) {
- tel_get_property_int(tapi_handle,
- TAPI_PROP_NETWORK_SERVICE_TYPE,
- &telephony_svctype);
- tel_get_property_int(tapi_handle, TAPI_PROP_NETWORK_PS_TYPE,
- &telephony_pstype);
- netconfig_tel_deinit();
- }
-
+ netconfig_get_telephony_network_type(&telephony_svctype, &telephony_pstype);
DBG("Default cellular %d, %d", telephony_svctype, telephony_pstype);
switch (telephony_pstype) {
const char *proxy_addr = netconfig_get_default_proxy();
unsigned int freq = netconfig_get_default_frequency();
- if (emulator_is_emulated() == TRUE)
+ if (emulator_is_emulated() == TRUE) {
+ if (ip_addr != NULL)
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, ip_addr);
+ else
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, "");
+
+ if (ip_addr6 != NULL)
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP6, ip_addr6);
+ else
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP6, "");
+
return;
+ }
if (profile == NULL)
DBG("Reset network state configuration");
else
- DBG("%s: ip(%s) proxy(%s)", profile, ip_addr, proxy_addr);
+ DBG("profile[%s] ipv4(%s) ipv6(%s) proxy(%s)", profile, ip_addr, ip_addr6, proxy_addr);
netconfig_vconf_get_int(VCONFKEY_NETWORK_STATUS, &old_network_status);
netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, "");
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP6, "");
netconfig_set_vconf_str(VCONFKEY_NETWORK_PROXY, "");
netconfig_set_vconf_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 0);
DBG("Successfully clear IP and PROXY up");
- /* Disable clatd if it is in running state */
- netconfig_clatd_disable();
} else if (profile != NULL) {
char *old_ip = vconf_get_str(VCONFKEY_NETWORK_IP);
+ char *old_ip6 = vconf_get_str(VCONFKEY_NETWORK_IP6);
char *old_proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
if (netconfig_is_wifi_profile(profile) == TRUE) {
netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_WIFI);
netconfig_set_vconf_int("memory/private/wifi/frequency", freq);
- netconfig_set_system_event(SYS_EVENT_NETWORK_STATUS,
- EVT_KEY_NETWORK_STATUS, EVT_VAL_NETWORK_WIFI);
+ netconfig_set_system_event(SYS_EVT_NETWORK_STATUS,
+ EKEY_NETWORK_STATUS, EVAL_NETWORK_WIFI);
} else if (netconfig_is_cellular_profile(profile)) {
if (!netconfig_is_cellular_internet_profile(profile)) {
DBG("connection is not a internet profile - stop to update the cellular state");
+ if (old_ip)
+ free(old_ip);
+ if (old_ip6)
+ free(old_ip6);
+ if (old_proxy)
+ free(old_proxy);
return;
}
netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
- netconfig_set_system_event(SYS_EVENT_NETWORK_STATUS,
- EVT_KEY_NETWORK_STATUS, EVT_VAL_NETWORK_CELLULAR);
-
- /* Enable clatd if IPv6 is set and no IPv4 address */
- if (!ip_addr && ip_addr6)
- netconfig_clatd_enable();
+ netconfig_set_system_event(SYS_EVT_NETWORK_STATUS,
+ EKEY_NETWORK_STATUS, EVAL_NETWORK_CELLULAR);
} else if (netconfig_is_ethernet_profile(profile) == TRUE) {
netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_ETHERNET);
- netconfig_set_system_event(SYS_EVENT_NETWORK_STATUS,
- EVT_KEY_NETWORK_STATUS, EVT_VAL_NETWORK_ETHERNET);
+ netconfig_set_system_event(SYS_EVT_NETWORK_STATUS,
+ EKEY_NETWORK_STATUS, EVAL_NETWORK_ETHERNET);
} else if (netconfig_is_bluetooth_profile(profile) == TRUE) {
netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_BLUETOOTH);
- netconfig_set_system_event(SYS_EVENT_NETWORK_STATUS,
- EVT_KEY_NETWORK_STATUS, EVT_VAL_NETWORK_BT);
+ netconfig_set_system_event(SYS_EVT_NETWORK_STATUS,
+ EKEY_NETWORK_STATUS, EVAL_NETWORK_BT);
} else{
netconfig_set_vconf_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
- netconfig_set_system_event(SYS_EVENT_NETWORK_STATUS,
- EVT_KEY_NETWORK_STATUS, EVT_VAL_NETWORK_DISCONNECTED);
+ netconfig_set_system_event(SYS_EVT_NETWORK_STATUS,
+ EKEY_NETWORK_STATUS, EVAL_NETWORK_DISCONNECTED);
}
if (g_strcmp0(old_ip, ip_addr) != 0 || old_ip == NULL) {
if (ip_addr != NULL)
netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, ip_addr);
- else if (ip_addr6 != NULL)
- netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, ip_addr6);
- else
+ else if (old_ip != NULL && strlen(old_ip) > 0)
netconfig_set_vconf_str(VCONFKEY_NETWORK_IP, "");
}
- g_free(old_ip);
+ if (old_ip)
+ free(old_ip);
+
+ if (g_strcmp0(old_ip6, ip_addr6) != 0 || old_ip6 == NULL) {
+ if (ip_addr6 != NULL)
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP6, ip_addr6);
+ else if (old_ip6 != NULL && strlen(old_ip6) > 0)
+ netconfig_set_vconf_str(VCONFKEY_NETWORK_IP6, "");
+ }
+ if (old_ip6)
+ free(old_ip6);
if (g_strcmp0(old_proxy, proxy_addr) != 0) {
if (proxy_addr == NULL)
else
netconfig_set_vconf_str(VCONFKEY_NETWORK_PROXY, proxy_addr);
}
- g_free(old_proxy);
+ if (old_proxy)
+ free(old_proxy);
netconfig_set_vconf_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
DBG("Successfully update default network configuration");
-
- /* Disable clatd if it is in running state */
- if (netconfig_is_cellular_profile(profile) != TRUE)
- netconfig_clatd_disable();
}
__netconfig_adjust_tcp_buffer_size();
return netconfig_default_connection_info.essid;
}
+gboolean netconfig_get_default_is_metered(void)
+{
+ return netconfig_default_connection_info.is_metered;
+}
+
static int __netconfig_reset_ipv4_socket(void)
{
int ret;
netconfig_default_connection_info.proxy = NULL;
netconfig_default_connection_info.freq = 0;
+ netconfig_default_connection_info.is_metered = FALSE;
- if (wifi_state_get_service_state() != NETCONFIG_WIFI_CONNECTED) {
- g_free(netconfig_default_connection_info.essid);
- netconfig_default_connection_info.essid = NULL;
- }
+ g_free(netconfig_default_connection_info.essid);
+ netconfig_default_connection_info.essid = NULL;
}
/* default profile is NULL and new connected profile is NULL */
if (!profile) {
- profile = __netconfig_get_default_profile();
+ char *tmp_profile = __netconfig_get_default_profile();
- if (profile && netconfig_is_cellular_profile(profile) &&
- !netconfig_is_cellular_internet_profile(profile)) {
+ if (tmp_profile && netconfig_is_cellular_profile(tmp_profile) &&
+ !netconfig_is_cellular_internet_profile(tmp_profile)) {
DBG("not a default cellular profile");
- profile = NULL;
+ g_free(tmp_profile);
+ tmp_profile = NULL;
}
- if (!profile) {
+ if (!tmp_profile) {
__netconfig_update_default_connection_info();
return;
}
+
+ netconfig_default_connection_info.profile = g_strdup(tmp_profile);
+ __netconfig_get_default_connection_info(tmp_profile);
+ __netconfig_update_default_connection_info();
+ g_free(tmp_profile);
+ return;
}
netconfig_default_connection_info.profile = g_strdup(profile);
__netconfig_get_default_connection_info(profile);
__netconfig_update_default_connection_info();
-
}
void netconfig_update_default(void)
char *netconfig_get_ifname(const char *profile)
{
GVariant *message = NULL, *variant;
- GVariantIter *iter, *next;
+ GVariantIter *iter, *next, *service;
+ gchar *obj_path;
gchar *key;
gchar *key1;
const gchar *value = NULL;
gchar *ifname = NULL;
+ gboolean found_profile = 0;
if (profile == NULL)
return NULL;
- message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, profile,
- CONNMAN_SERVICE_INTERFACE, "GetProperties", NULL);
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE,
+ "GetServices", NULL);
if (message == NULL) {
- ERR("Failed to get service properties");
+ ERR("Failed to get services informations");
+ return NULL;
+ }
+
+ g_variant_get(message, "(a(oa{sv}))", &service);
+ while (g_variant_iter_loop(service, "(oa{sv})", &obj_path, &iter)) {
+ if (g_strcmp0(obj_path, profile) == 0) {
+ g_free(obj_path);
+ found_profile = 1;
+ break;
+ }
+ }
+
+ if (found_profile == 0) {
+ ERR("Profile %s doesn't exist", profile);
+ g_variant_iter_free(service);
+ g_variant_unref(message);
return NULL;
}
- g_variant_get(message, "(a{sv})", &iter);
while (g_variant_iter_loop(iter, "{sv}", &key, &next)) {
if (g_strcmp0(key, "Ethernet") == 0) {
while (g_variant_iter_loop(next, "{sv}", &key1, &variant)) {
if (g_strcmp0(key1, "Interface") == 0) {
value = g_variant_get_string(variant, NULL);
ifname = g_strdup(value);
+ g_free(key1);
+ g_variant_unref(variant);
+ break;
}
}
}
g_variant_unref(message);
+ g_variant_iter_free(service);
g_variant_iter_free(iter);
return ifname;
return TRUE;
}
+gboolean handle_get_metered_info(Network *object,
+ GDBusMethodInvocation *context)
+{
+ gboolean state = 0;
+
+ state = netconfig_get_default_is_metered();
+
+ DBG("Default metered state [%s]", state ? "TRUE" : "FALSE");
+ network_complete_get_metered_info(object, context, state);
+ return TRUE;
+}
+
+gboolean handle_preferred_ipv6_address(Network *object,
+ GDBusMethodInvocation *context, gchar *profile)
+{
+ char *address = NULL;
+
+ address = __netconfig_get_preferred_ipv6_address(profile);
+ if (address == NULL) {
+ DBG("Failed to get preferred IPv6 address");
+ netconfig_error_fail_preferred_ipv6_address(context);
+ return FALSE;
+ }
+
+ DBG("Successfully get preferred IPv6 address[%s]", address);
+ network_complete_preferred_ipv6_address(object, context, address);
+ return TRUE;
+}
+
void state_object_create_and_init(void)
{
DBG("Creating network state object");
G_CALLBACK(handle_check_internet_privilege), NULL);
g_signal_connect(netconfigstate, "handle-ethernet-cable-state",
G_CALLBACK(handle_ethernet_cable_state), NULL);
+ g_signal_connect(netconfigstate, "handle-preferred-ipv6-address",
+ G_CALLBACK(handle_preferred_ipv6_address), NULL);
g_signal_connect(netconfigstate, "handle-remove-route",
G_CALLBACK(handle_remove_route), NULL);
g_signal_connect(netconfigstate, "handle-launch-mdns",
G_CALLBACK(handle_launch_mdns), NULL);
- g_signal_connect(netconfigstate, "handle-ref-mdns",
- G_CALLBACK(handle_ref_mdns), NULL);
- g_signal_connect(netconfigstate, "handle-unref-mdns",
- G_CALLBACK(handle_unref_mdns), NULL);
g_signal_connect(netconfigstate, "handle-device-policy-set-wifi",
G_CALLBACK(handle_device_policy_set_wifi), NULL);
g_signal_connect(netconfigstate, "handle-device-policy-get-wifi",
G_CALLBACK(handle_device_policy_set_wifi_profile), NULL);
g_signal_connect(netconfigstate, "handle-device-policy-get-wifi-profile",
G_CALLBACK(handle_device_policy_get_wifi_profile), NULL);
+ g_signal_connect(netconfigstate, "handle-get-metered-info",
+ G_CALLBACK(handle_get_metered_info), NULL);
if (!g_dbus_interface_skeleton_export(interface_network, connection,
NETCONFIG_NETWORK_STATE_PATH, NULL)) {