summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-01-03 18:47:21 -0800
committerMarcel Holtmann <marcel@holtmann.org>2010-01-03 18:47:21 -0800
commit2f217e25d799ef351d4e8e06b0da83e72b2183f0 (patch)
treef02802519be4ec12fec9d5fdb30e546f2ef30cc8
parent3bac66a29d5e87874bfcd298a1a161805f3104db (diff)
downloadconnman-2f217e25d799ef351d4e8e06b0da83e72b2183f0.tar.gz
connman-2f217e25d799ef351d4e8e06b0da83e72b2183f0.tar.bz2
connman-2f217e25d799ef351d4e8e06b0da83e72b2183f0.zip
Add basic interfaces for automatic proxy configuration
-rw-r--r--doc/service-api.txt22
-rw-r--r--plugins/dhclient.c2
-rw-r--r--plugins/openconnect.c3
-rw-r--r--scripts/dhclient.conf4
-rw-r--r--src/connman.h4
-rw-r--r--src/dhcp.c1
-rw-r--r--src/ipconfig.c13
-rw-r--r--src/provider.c8
-rw-r--r--src/service.c22
9 files changed, 73 insertions, 6 deletions
diff --git a/doc/service-api.txt b/doc/service-api.txt
index 1fe37ea4..0f22f39c 100644
--- a/doc/service-api.txt
+++ b/doc/service-api.txt
@@ -302,6 +302,28 @@ Properties string State [readonly]
the actual system configuration while this allows
user configuration.
+ dict Proxy [readonly]
+
+ string Method [readonly]
+
+ Possible values are "direct", "auto",
+ "manual" and "auto-config".
+
+ If the DHCP server provides an automatic
+ configuration URL, then this value is set
+ to "auto-config". The PAC file will be
+ referenced by the URL value.
+
+ If no automatic configuration is available,
+ then "direct" is set.
+
+ The values "auto" and "manual" are not yet
+ supported.
+
+ string URL [readonly]
+
+ Automatic proxy configuration URL.
+
dict Ethernet [readonly]
string Method [readonly]
diff --git a/plugins/dhclient.c b/plugins/dhclient.c
index 1a86fa4a..ed170ed7 100644
--- a/plugins/dhclient.c
+++ b/plugins/dhclient.c
@@ -87,6 +87,8 @@ static void dhclient_notify(struct connman_task *task,
connman_dhcp_set_value(dhcp, "Timeserver", value);
} else if (g_ascii_strcasecmp(key, "new_interface_mtu") == 0) {
connman_dhcp_set_value(dhcp, "MTU", value);
+ } else if (g_ascii_strcasecmp(key, "new_proxy_auto_config") == 0) {
+ connman_dhcp_set_value(dhcp, "PAC", value);
}
dbus_message_iter_next(&dict);
diff --git a/plugins/openconnect.c b/plugins/openconnect.c
index bbe8bb84..891aa876 100644
--- a/plugins/openconnect.c
+++ b/plugins/openconnect.c
@@ -188,6 +188,9 @@ static void openconnect_task_notify(struct connman_task *task,
if (!strcmp(key, "INTERNAL_IP4_DNS"))
connman_provider_set_string(provider, "DNS", value);
+ if (!strcmp(key, "CISCO_PROXY_PAC"))
+ connman_provider_set_string(provider, "PAC", value);
+
if (domain == NULL && !strcmp(key, "CISCO_DEF_DOMAIN"))
domain = value;
diff --git a/scripts/dhclient.conf b/scripts/dhclient.conf
index dc116ef1..3ed1829a 100644
--- a/scripts/dhclient.conf
+++ b/scripts/dhclient.conf
@@ -1,5 +1,7 @@
send host-name "<hostname>";
+option proxy-auto-config code 252 = text;
request subnet-mask, broadcast-address, routers, host-name,
domain-search, domain-name, domain-name-servers,
- time-offset, time-servers, ntp-servers, interface-mtu;
+ time-offset, time-servers, ntp-servers, interface-mtu,
+ proxy-auto-config;
require subnet-mask, domain-name-servers;
diff --git a/src/connman.h b/src/connman.h
index 38b3251a..72e3bae1 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -134,7 +134,9 @@ void __connman_ipconfig_append_ipv4config(struct connman_ipconfig *ipconfig,
DBusMessageIter *iter);
int __connman_ipconfig_set_ipv4config(struct connman_ipconfig *ipconfig,
DBusMessageIter *value);
-int __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
+void __connman_ipconfig_append_proxy(struct connman_ipconfig *ipconfig,
+ DBusMessageIter *iter);
+void __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
DBusMessageIter *iter);
int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
diff --git a/src/dhcp.c b/src/dhcp.c
index 7a301f67..0e890c2d 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -122,6 +122,7 @@ void connman_dhcp_set_value(struct connman_dhcp *dhcp,
g_free(dhcp->element->ipv4.timeserver);
dhcp->element->ipv4.timeserver = g_strdup(value);
} else if (g_strcmp0(key, "MTU") == 0) {
+ } else if (g_strcmp0(key, "PAC") == 0) {
}
}
diff --git a/src/ipconfig.c b/src/ipconfig.c
index a731a9a7..07fa7703 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1118,7 +1118,16 @@ int __connman_ipconfig_set_ipv4config(struct connman_ipconfig *ipconfig,
return 0;
}
-int __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
+void __connman_ipconfig_append_proxy(struct connman_ipconfig *ipconfig,
+ DBusMessageIter *iter)
+{
+ const char *method = "direct";
+
+ connman_dbus_dict_append_basic(iter, "Method",
+ DBUS_TYPE_STRING, &method);
+}
+
+void __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
DBusMessageIter *iter)
{
const char *method = "auto";
@@ -1133,8 +1142,6 @@ int __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
if (ipconfig->mtu > 0)
connman_dbus_dict_append_basic(iter, "MTU",
DBUS_TYPE_UINT16, &ipconfig->mtu);
-
- return 0;
}
int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
diff --git a/src/provider.c b/src/provider.c
index 7fb6701d..e33f02e1 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -43,6 +43,7 @@ struct connman_provider {
enum connman_provider_error error;
char *name;
char *type;
+ char *pac;
char *dns;
char *domain;
DBusMessage *pending;
@@ -538,6 +539,7 @@ 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)
@@ -577,6 +579,7 @@ static void __connman_provider_initialize(struct connman_provider *provider)
provider->name = NULL;
provider->type = NULL;
+ provider->pac = NULL;
provider->dns = NULL;
provider->domain = NULL;
provider->identifier = NULL;
@@ -793,10 +796,13 @@ int connman_provider_set_string(struct connman_provider *provider,
} else if (g_str_equal(key, "Netmask") == TRUE) {
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);
} else if (g_str_equal(key, "DNS") == TRUE) {
g_free(provider->dns);
provider->dns = g_strdup(value);
- } else if (g_str_equal(key, "Domain")) {
+ } else if (g_str_equal(key, "Domain") == TRUE) {
g_free(provider->domain);
provider->domain = g_strdup(value);
}
diff --git a/src/service.c b/src/service.c
index ddb9fcb5..2970ad07 100644
--- a/src/service.c
+++ b/src/service.c
@@ -440,6 +440,26 @@ static void append_ipv4config(DBusMessageIter *iter, void *user_data)
__connman_ipconfig_append_ipv4config(service->ipconfig, iter);
}
+static void append_proxy(DBusMessageIter *iter, void *user_data)
+{
+ struct connman_service *service = user_data;
+
+ switch (service->state) {
+ case CONNMAN_SERVICE_STATE_UNKNOWN:
+ case CONNMAN_SERVICE_STATE_IDLE:
+ case CONNMAN_SERVICE_STATE_FAILURE:
+ case CONNMAN_SERVICE_STATE_DISCONNECT:
+ case CONNMAN_SERVICE_STATE_ASSOCIATION:
+ case CONNMAN_SERVICE_STATE_CONFIGURATION:
+ return;
+ case CONNMAN_SERVICE_STATE_READY:
+ break;
+ }
+
+ if (service->ipconfig != NULL)
+ __connman_ipconfig_append_proxy(service->ipconfig, iter);
+}
+
static void settings_changed(struct connman_service *service)
{
connman_dbus_property_changed_dict(service->path,
@@ -597,6 +617,8 @@ static DBusMessage *get_properties(DBusConnection *conn,
connman_dbus_dict_append_dict(&dict, "IPv4.Configuration",
append_ipv4config, service);
+ connman_dbus_dict_append_dict(&dict, "Proxy", append_proxy, service);
+
connman_dbus_dict_close(&array, &dict);
return reply;