+ if (modem->device)
+ connman_device_remove_network(modem->device, context->network);
+ connman_network_unref(context->network);
+ context->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;