summaryrefslogtreecommitdiff
path: root/plugins/ofono.c
diff options
context:
space:
mode:
authorhyunuktak <hyunuk.tak@samsung.com>2015-08-07 08:11:34 (GMT)
committerhyunuktak <hyunuk.tak@samsung.com>2015-08-07 08:11:56 (GMT)
commit6aa4055ef0544ae85457c25c510fe3db04949c43 (patch)
tree94018be3cef92c33b60650c488dc15536c8f978a /plugins/ofono.c
parentbc55a3df0d4d2d97964ce2fadc9fe3ffc4953f4e (diff)
downloadconnman-6aa4055ef0544ae85457c25c510fe3db04949c43.zip
connman-6aa4055ef0544ae85457c25c510fe3db04949c43.tar.gz
connman-6aa4055ef0544ae85457c25c510fe3db04949c43.tar.bz2
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com> Change-Id: I84a42375b5c59739e4caca1f726699ea7647ef17
Diffstat (limited to 'plugins/ofono.c')
-rwxr-xr-x[-rw-r--r--]plugins/ofono.c108
1 files changed, 93 insertions, 15 deletions
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 7af551b..5cd8302 100644..100755
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -277,13 +277,11 @@ static void set_connected(struct modem_data *modem)
if (!service)
return;
+ connman_service_create_ip4config(service, index);
+ connman_network_set_ipv4_method(modem->network, method);
+
if (method == CONNMAN_IPCONFIG_METHOD_FIXED ||
method == CONNMAN_IPCONFIG_METHOD_DHCP) {
- connman_service_create_ip4config(service, index);
- connman_network_set_index(modem->network, index);
-
- connman_network_set_ipv4_method(modem->network, method);
-
setip = true;
}
@@ -293,11 +291,10 @@ static void set_connected(struct modem_data *modem)
}
method = modem->context->ipv6_method;
- if (method == CONNMAN_IPCONFIG_METHOD_FIXED) {
- connman_service_create_ip6config(service, index);
- connman_network_set_ipv6_method(modem->network, method);
- connman_network_set_ipaddress(modem->network,
- modem->context->ipv6_address);
+ connman_service_create_ip6config(service, index);
+ connman_network_set_ipv6_method(modem->network, method);
+
+ if (method == CONNMAN_IPCONFIG_METHOD_AUTO) {
setip = true;
}
@@ -317,18 +314,32 @@ static void set_connected(struct modem_data *modem)
modem->context->ipv6_nameservers);
}
- if (setip)
+ if (setip) {
+ connman_network_set_index(modem->network, index);
connman_network_set_connected(modem->network, true);
+ }
}
static void set_disconnected(struct modem_data *modem)
{
DBG("%s", modem->path);
- if (!modem->network)
- return;
+ if (modem->network)
+ connman_network_set_connected(modem->network, false);
- connman_network_set_connected(modem->network, false);
+ if (modem->context) {
+ g_free(modem->context->ipv4_nameservers);
+ modem->context->ipv4_nameservers = NULL;
+ if (modem->context->ipv4_method != CONNMAN_IPCONFIG_METHOD_OFF)
+ modem->context->ipv4_method =
+ CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+
+ g_free(modem->context->ipv6_nameservers);
+ modem->context->ipv6_nameservers = NULL;
+ if (modem->context->ipv6_method != CONNMAN_IPCONFIG_METHOD_OFF)
+ modem->context->ipv6_method =
+ CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+ }
}
typedef void (*set_property_cb)(struct modem_data *data,
@@ -755,6 +766,10 @@ static void extract_ipv4_settings(DBusMessageIter *array,
const char *interface = NULL;
int index = -1;
+ connman_ipaddress_free(context->ipv4_address);
+ context->ipv4_address = NULL;
+ context->index = -1;
+
if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
return;
@@ -854,6 +869,10 @@ static void extract_ipv6_settings(DBusMessageIter *array,
const char *interface = NULL;
int index = -1;
+ connman_ipaddress_free(context->ipv6_address);
+ context->ipv6_address = NULL;
+ context->index = -1;
+
if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
return;
@@ -905,7 +924,7 @@ static void extract_ipv6_settings(DBusMessageIter *array,
if (index < 0)
goto out;
- context->ipv6_method = CONNMAN_IPCONFIG_METHOD_FIXED;
+ context->ipv6_method = CONNMAN_IPCONFIG_METHOD_AUTO;
context->ipv6_address =
connman_ipaddress_alloc(CONNMAN_IPCONFIG_TYPE_IPV6);
@@ -1065,12 +1084,53 @@ static void remove_network(struct modem_data *modem)
modem->network = NULL;
}
+static int set_context_ipconfig(struct network_context *context,
+ const char *protocol)
+{
+ DBG("context %p protocol %s", context, protocol);
+
+ if (!context || !protocol)
+ return -EINVAL;
+
+ if (g_str_equal(protocol, "ip")) {
+ if (context->ipv4_method == CONNMAN_IPCONFIG_METHOD_OFF)
+ context->ipv4_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+
+ context->ipv6_method = CONNMAN_IPCONFIG_METHOD_OFF;
+
+ connman_ipaddress_free(context->ipv6_address);
+ context->ipv6_address = NULL;
+
+ } else if (g_str_equal(protocol, "ipv6")) {
+ if (context->ipv6_method == CONNMAN_IPCONFIG_METHOD_OFF)
+ context->ipv6_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+
+ context->ipv4_method = CONNMAN_IPCONFIG_METHOD_OFF;
+
+ connman_ipaddress_free(context->ipv4_address);
+ context->ipv4_address = NULL;
+
+ } else if (g_str_equal(protocol, "dual")) {
+ if (context->ipv4_method == CONNMAN_IPCONFIG_METHOD_OFF)
+ context->ipv4_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+
+ if (context->ipv6_method == CONNMAN_IPCONFIG_METHOD_OFF)
+ context->ipv6_method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
+ }
+
+ DBG("ipv4 method %d ipv6 method %d", context->ipv4_method,
+ context->ipv6_method);
+
+ return 0;
+}
+
static int add_cm_context(struct modem_data *modem, const char *context_path,
DBusMessageIter *dict)
{
const char *context_type = NULL;
struct network_context *context = NULL;
dbus_bool_t active = FALSE;
+ const char *ip_protocol = NULL;
DBG("%s context path %s", modem->path, context_path);
@@ -1123,7 +1183,14 @@ static int add_cm_context(struct modem_data *modem, const char *context_path,
modem->valid_apn = false;
DBG("%s AccessPointName '%s'", modem->path, apn);
+ } else if (g_str_equal(key, "Protocol") &&
+ dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING ) {
+
+ dbus_message_iter_get_basic(&value, &ip_protocol);
+
+ DBG("%s Protocol %s", modem->path, ip_protocol);
}
+
dbus_message_iter_next(dict);
}
@@ -1132,6 +1199,9 @@ static int add_cm_context(struct modem_data *modem, const char *context_path,
return -EINVAL;
}
+ if (ip_protocol)
+ set_context_ipconfig(context, ip_protocol);
+
modem->context = context;
modem->active = active;
@@ -1246,6 +1316,14 @@ static gboolean context_changed(DBusConnection *conn,
remove_network(modem);
}
+
+ } else if (g_str_equal(key, "Protocol") &&
+ dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING ) {
+ const char *ip_protocol;
+
+ dbus_message_iter_get_basic(&value, &ip_protocol);
+
+ set_context_ipconfig(modem->context, ip_protocol);
}
return TRUE;