*
* Connection Manager
*
- * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2012 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
#include <config.h>
#endif
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
{
struct connman_wpad *wpad = data;
+ connman_service_unref(wpad->service);
+
g_resolv_unref(wpad->resolv);
g_strfreev(wpad->addrlist);
g_free(wpad->hostname);
- g_free(wpad);
+ g_free(wpad);
}
static void download_pac(struct connman_wpad *wpad, const char *target)
if (status == G_RESOLV_RESULT_STATUS_SUCCESS) {
char *url;
- if (results == NULL || g_strv_length(results) == 0)
+ if (!results || g_strv_length(results) == 0)
goto failed;
url = g_strdup_printf("http://%s/wpad.dat", wpad->hostname);
__connman_service_set_proxy_autoconfig(wpad->service, url);
wpad->addrlist = g_strdupv(results);
- if (wpad->addrlist != NULL)
+ if (wpad->addrlist)
download_pac(wpad, "wpad.dat");
g_free(url);
+ __connman_service_wispr_start(wpad->service,
+ CONNMAN_IPCONFIG_TYPE_IPV4);
+
return;
}
goto failed;
ptr = strchr(hostname + 5, '.');
- if (ptr == NULL || strlen(ptr) < 2)
+ if (!ptr || strlen(ptr) < 2)
goto failed;
- if (strchr(ptr + 1, '.') == NULL)
+ if (!strchr(ptr + 1, '.'))
goto failed;
wpad->hostname = g_strdup_printf("wpad.%s", ptr + 1);
failed:
connman_service_set_proxy_method(wpad->service,
CONNMAN_SERVICE_PROXY_METHOD_DIRECT);
+
+ __connman_service_wispr_start(wpad->service,
+ CONNMAN_IPCONFIG_TYPE_IPV4);
}
int __connman_wpad_start(struct connman_service *service)
{
struct connman_wpad *wpad;
- const char *domainname, *nameserver;
+ const char *domainname;
+ char **nameservers;
int index;
+ int i;
DBG("service %p", service);
- if (wpad_list == NULL)
+ if (!wpad_list)
return -EINVAL;
index = __connman_service_get_index(service);
return -EINVAL;
domainname = connman_service_get_domainname(service);
- if (domainname == NULL)
+ if (!domainname)
return -EINVAL;
- nameserver = connman_service_get_nameserver(service);
- if (nameserver == NULL)
+ nameservers = connman_service_get_nameservers(service);
+ if (!nameservers)
return -EINVAL;
wpad = g_try_new0(struct connman_wpad, 1);
- if (wpad == NULL)
+ if (!wpad) {
+ g_strfreev(nameservers);
return -ENOMEM;
+ }
- wpad->service = service;
wpad->resolv = g_resolv_new(index);
- if (wpad->resolv == NULL) {
+ if (!wpad->resolv) {
+ g_strfreev(nameservers);
g_free(wpad);
return -ENOMEM;
}
+#if !defined TIZEN_EXT
if (getenv("CONNMAN_RESOLV_DEBUG"))
+#endif
g_resolv_set_debug(wpad->resolv, resolv_debug, "RESOLV");
- g_resolv_add_nameserver(wpad->resolv, nameserver, 53, 0);
+ for (i = 0; nameservers[i]; i++)
+ g_resolv_add_nameserver(wpad->resolv, nameservers[i], 53, 0);
+
+ g_strfreev(nameservers);
wpad->hostname = g_strdup_printf("wpad.%s", domainname);
DBG("hostname %s", wpad->hostname);
+ wpad->service = connman_service_ref(service);
+
g_resolv_lookup_hostname(wpad->resolv, wpad->hostname,
wpad_result, wpad);
DBG("service %p", service);
- if (wpad_list == NULL)
+ if (!wpad_list)
return;
index = __connman_service_get_index(service);