Ejemplo n.º 1
0
/**
 * connman_resolver_append_lifetime:
 * @interface: network interface
 * @domain: domain limitation
 * @server: server address
 * @timeout: server lifetime in seconds
 *
 * Append resolver server address to current list
 */
int connman_resolver_append_lifetime(const char *interface, const char *domain,
				const char *server, unsigned int lifetime)
{
	GSList *list;

	DBG("interface %s domain %s server %s lifetime %d",
				interface, domain, server, lifetime);

	if (server == NULL)
		return -EINVAL;

	for (list = entry_list; list; list = list->next) {
		struct entry_data *entry = list->data;

		if (!entry->timeout ||
				g_strcmp0(entry->interface, interface) ||
				g_strcmp0(entry->domain, domain) ||
				g_strcmp0(entry->server, server))
			continue;

		g_source_remove(entry->timeout);
		entry->timeout = g_timeout_add_seconds(lifetime,
						resolver_expire_cb, entry);
		return 0;
	}

	return append_resolver(interface, domain, server, lifetime, 0);
}
Ejemplo n.º 2
0
/**
 * connman_resolver_append:
 * @interface: network interface
 * @domain: domain limitation
 * @server: server address
 *
 * Append resolver server address to current list
 */
int connman_resolver_append(const char *interface, const char *domain,
						const char *server)
{
	DBG("interface %s domain %s server %s", interface, domain, server);

	return append_resolver(interface, domain, server, 0, 0);
}
Ejemplo n.º 3
0
/**
 * connman_resolver_append:
 * @interface: network interface
 * @domain: domain limitation
 * @server: server address
 *
 * Append resolver server address to current list
 */
int connman_resolver_append(const char *interface, const char *domain,
						const char *server)
{
	GSList *list, *matches = NULL;

	DBG("interface %s domain %s server %s", interface, domain, server);

	if (server == NULL && domain == NULL)
		return -EINVAL;

	for (list = entry_list; list; list = list->next) {
		struct entry_data *entry = list->data;

		if (entry->timeout > 0 ||
				g_strcmp0(entry->interface, interface) != 0 ||
				g_strcmp0(entry->domain, domain) != 0 ||
				g_strcmp0(entry->server, server) != 0)
			continue;

		matches = g_slist_append(matches, entry);
	}

	if (matches != NULL)
		remove_entries(matches);

	return append_resolver(interface, domain, server, 0, 0);
}
Ejemplo n.º 4
0
int __connman_resolver_init(connman_bool_t dnsproxy)
{
	int i;
	char **ns;

	DBG("dnsproxy %d", dnsproxy);

	if (dnsproxy == FALSE)
		return 0;

	if (__connman_dnsproxy_init() < 0) {
		/* Fall back to resolv.conf */
		return 0;
	}

	dnsproxy_enabled = TRUE;

	ns = connman_setting_get_string_list("FallbackNameservers");
	for (i = 0; ns != NULL && ns[i] != NULL; i += 1) {
		DBG("server %s", ns[i]);
		append_resolver(NULL, NULL, ns[i], 0, RESOLVER_FLAG_PUBLIC);
	}

	return 0;
}
Ejemplo n.º 5
0
/**
 * connman_resolver_append_lifetime:
 * @interface: network interface
 * @domain: domain limitation
 * @server: server address
 * @timeout: server lifetime in seconds
 *
 * Append resolver server address to current list
 */
int connman_resolver_append_lifetime(const char *interface, const char *domain,
				const char *server, unsigned int lifetime)
{
	GSList *list;
	unsigned int interval;

	DBG("interface %s domain %s server %s lifetime %d",
				interface, domain, server, lifetime);

	if (server == NULL && domain == NULL)
		return -EINVAL;

	for (list = entry_list; list; list = list->next) {
		struct entry_data *entry = list->data;

		if (entry->timeout == 0 ||
				g_strcmp0(entry->interface, interface) != 0 ||
				g_strcmp0(entry->domain, domain) != 0 ||
				g_strcmp0(entry->server, server) != 0)
			continue;

		g_source_remove(entry->timeout);

		if (lifetime == 0) {
			resolver_expire_cb(entry);
			return 0;
		}

		interval = lifetime * RESOLVER_LIFETIME_REFRESH_THRESHOLD;

		DBG("RDNSS start interface %s domain %s "
				"server %s lifetime threshold %d",
				interface, domain, server, interval);

		entry->timeout = g_timeout_add_seconds(interval,
				resolver_refresh_cb, entry);
		return 0;
	}

	return append_resolver(interface, domain, server, lifetime, 0);
}
Ejemplo n.º 6
0
/**
 * connman_resolver_append:
 * @interface: network interface
 * @domain: domain limitation
 * @server: server address
 *
 * Append resolver server address to current list
 */
int connman_resolver_append(const char *interface, const char *domain,
						const char *server)
{
	GSList *list;

	DBG("interface %s domain %s server %s", interface, domain, server);

	if (server == NULL && domain == NULL)
		return -EINVAL;

	for (list = entry_list; list; list = list->next) {
		struct entry_data *entry = list->data;

		if (entry->timeout > 0)
			continue;

		if (g_strcmp0(entry->interface, interface) == 0 &&
				g_strcmp0(entry->domain, domain) == 0 &&
				g_strcmp0(entry->server, server) == 0)
			return -EEXIST;
	}

	return append_resolver(interface, domain, server, 0, 0);
}
Ejemplo n.º 7
0
/**
 * connman_resolver_append_public_server:
 * @server: server address
 *
 * Append public resolver server address to current list
 */
int connman_resolver_append_public_server(const char *server)
{
	DBG("server %s", server);

	return append_resolver(NULL, NULL, server, 0, RESOLVER_FLAG_PUBLIC);
}