diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-01-04 13:36:08 -0800 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-01-04 13:36:08 -0800 |
commit | 9e0c50af585c167eaf7768802b4d015a502108a6 (patch) | |
tree | 322a6f150309dd4d9e71a2dc4025edead7b18dd8 | |
parent | 9f5bab2bdc8ea8164f47597f066d560840b953b1 (diff) | |
download | connman-9e0c50af585c167eaf7768802b4d015a502108a6.tar.gz connman-9e0c50af585c167eaf7768802b4d015a502108a6.tar.bz2 connman-9e0c50af585c167eaf7768802b4d015a502108a6.zip |
Store PAC URL configuration in DHCP and provider elements
-rw-r--r-- | include/element.h | 1 | ||||
-rw-r--r-- | include/property.h | 1 | ||||
-rw-r--r-- | src/dhcp.c | 2 | ||||
-rw-r--r-- | src/element.c | 31 | ||||
-rw-r--r-- | src/provider.c | 13 |
5 files changed, 41 insertions, 7 deletions
diff --git a/include/element.h b/include/element.h index b6491cd0..1d9aa69d 100644 --- a/include/element.h +++ b/include/element.h @@ -107,6 +107,7 @@ struct connman_element { gchar *broadcast; gchar *nameserver; gchar *timeserver; + gchar *pac; } ipv4; }; diff --git a/include/property.h b/include/property.h index a0fa6a00..c7f2a7b1 100644 --- a/include/property.h +++ b/include/property.h @@ -47,6 +47,7 @@ enum connman_property_id { CONNMAN_PROPERTY_ID_IPV4_BROADCAST, CONNMAN_PROPERTY_ID_IPV4_NAMESERVER, CONNMAN_PROPERTY_ID_IPV4_TIMESERVER, + CONNMAN_PROPERTY_ID_IPV4_PAC, }; enum connman_property_type { @@ -123,6 +123,8 @@ void connman_dhcp_set_value(struct connman_dhcp *dhcp, dhcp->element->ipv4.timeserver = g_strdup(value); } else if (g_strcmp0(key, "MTU") == 0) { } else if (g_strcmp0(key, "PAC") == 0) { + g_free(dhcp->element->ipv4.pac); + dhcp->element->ipv4.pac = g_strdup(value); } } diff --git a/src/element.c b/src/element.c index f81b0b3a..e0c4c002 100644 --- a/src/element.c +++ b/src/element.c @@ -683,6 +683,7 @@ void connman_element_unref(struct connman_element *element) g_free(element->ipv4.broadcast); g_free(element->ipv4.nameserver); g_free(element->ipv4.timeserver); + g_free(element->ipv4.pac); g_free(element->devname); g_free(element->path); g_free(element->name); @@ -876,6 +877,14 @@ int connman_element_get_value(struct connman_element *element, *((char **) value) = element->ipv4.timeserver; __connman_element_unlock(element); break; + case CONNMAN_PROPERTY_ID_IPV4_PAC: + if (element->ipv4.pac == NULL) + return connman_element_get_value(element->parent, + id, value); + __connman_element_lock(element); + *((char **) value) = element->ipv4.pac; + __connman_element_unlock(element); + break; default: return -EINVAL; } @@ -1099,7 +1108,7 @@ int __connman_element_append_ipv4(struct connman_element *element, const char *method = NULL; const char *address = NULL, *netmask = NULL, *gateway = NULL; const char *broadcast = NULL, *nameserver = NULL; - const char *timeserver = NULL; + const char *timeserver = NULL, *pac = NULL; connman_element_get_value(element, CONNMAN_PROPERTY_ID_IPV4_METHOD, &method); @@ -1116,6 +1125,8 @@ int __connman_element_append_ipv4(struct connman_element *element, CONNMAN_PROPERTY_ID_IPV4_NAMESERVER, &nameserver); connman_element_get_value(element, CONNMAN_PROPERTY_ID_IPV4_TIMESERVER, ×erver); + connman_element_get_value(element, + CONNMAN_PROPERTY_ID_IPV4_PAC, &pac); if (method != NULL) connman_dbus_dict_append_basic(dict, "IPv4.Method", @@ -1145,6 +1156,10 @@ int __connman_element_append_ipv4(struct connman_element *element, connman_dbus_dict_append_basic(dict, "IPv4.Timeserver", DBUS_TYPE_STRING, ×erver); + if (pac != NULL) + connman_dbus_dict_append_basic(dict, "IPv4.PAC", + DBUS_TYPE_STRING, &pac); + return 0; } @@ -1242,7 +1257,19 @@ int __connman_element_set_ipv4(struct connman_element *element, dbus_message_iter_get_basic(value, ×erver); g_free(element->ipv4.timeserver); - element->ipv4.nameserver = g_strdup(timeserver); + element->ipv4.timeserver = g_strdup(timeserver); + + connman_element_update(element); + } else if (g_str_equal(name, "IPv4.PAC") == TRUE) { + const char *pac; + + if (type != DBUS_TYPE_STRING) + return -EINVAL; + + dbus_message_iter_get_basic(value, &pac); + + g_free(element->ipv4.pac); + element->ipv4.pac = g_strdup(pac); connman_element_update(element); } diff --git a/src/provider.c b/src/provider.c index e33f02e1..81c7b4dc 100644 --- a/src/provider.c +++ b/src/provider.c @@ -43,7 +43,6 @@ struct connman_provider { enum connman_provider_error error; char *name; char *type; - char *pac; char *dns; char *domain; DBusMessage *pending; @@ -133,6 +132,9 @@ static void connman_provider_setup_vpn_ipv4(struct connman_provider *provider, g_free(element->ipv4.broadcast); element->ipv4.broadcast = g_strdup(provider->element.ipv4.broadcast); + g_free(element->ipv4.pac); + element->ipv4.pac = g_strdup(provider->element.ipv4.pac); + DBG("VPN exist"); } @@ -361,11 +363,13 @@ static int connman_provider_connect(struct connman_provider *provider) g_free(provider->element.ipv4.netmask); g_free(provider->element.ipv4.gateway); g_free(provider->element.ipv4.broadcast); + g_free(provider->element.ipv4.pac); provider->element.ipv4.address = NULL; provider->element.ipv4.netmask = NULL; provider->element.ipv4.gateway = NULL; provider->element.ipv4.broadcast = NULL; + provider->element.ipv4.pac = NULL; if (provider->driver != NULL && provider->driver->connect != NULL) err = provider->driver->connect(provider); @@ -539,7 +543,6 @@ static void provider_free(gpointer user_data) g_free(provider->domain); g_free(provider->identifier); g_free(provider->dns); - g_free(provider->pac); } static void unregister_provider(gpointer data) @@ -576,10 +579,10 @@ static void __connman_provider_initialize(struct connman_provider *provider) provider->element.ipv4.netmask = NULL; provider->element.ipv4.gateway = NULL; provider->element.ipv4.broadcast = NULL; + provider->element.ipv4.pac = NULL; provider->name = NULL; provider->type = NULL; - provider->pac = NULL; provider->dns = NULL; provider->domain = NULL; provider->identifier = NULL; @@ -797,8 +800,8 @@ int connman_provider_set_string(struct connman_provider *provider, g_free(provider->element.ipv4.netmask); provider->element.ipv4.netmask = g_strdup(value); } else if (g_str_equal(key, "PAC") == TRUE) { - g_free(provider->pac); - provider->pac = g_strdup(value); + g_free(provider->element.ipv4.pac); + provider->element.ipv4.pac = g_strdup(value); } else if (g_str_equal(key, "DNS") == TRUE) { g_free(provider->dns); provider->dns = g_strdup(value); |