Example #1
0
static int append_resolver(const char *interface, const char *domain,
				const char *server, unsigned int lifetime,
							unsigned int flags)
{
	struct entry_data *entry;

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

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

	entry = g_try_new0(struct entry_data, 1);
	if (entry == NULL)
		return -ENOMEM;

	entry->interface = g_strdup(interface);
	entry->domain = g_strdup(domain);
	entry->server = g_strdup(server);
	entry->flags = flags;
	if (lifetime)
		entry->timeout = g_timeout_add_seconds(lifetime,
						resolver_expire_cb, entry);

	entry_list = g_slist_append(entry_list, entry);

	if (dnsproxy_enabled == TRUE)
		__connman_dnsproxy_append(interface, domain, server);
	else
		__connman_resolvfile_append(interface, domain, server);

	return 0;
}
Example #2
0
static int append_resolver(const char *interface, const char *domain,
				const char *server, unsigned int lifetime,
							unsigned int flags)
{
	struct entry_data *entry;
	unsigned int interval;

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

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

	entry = g_try_new0(struct entry_data, 1);
	if (entry == NULL)
		return -ENOMEM;

	entry->interface = g_strdup(interface);
	entry->domain = g_strdup(domain);
	entry->server = g_strdup(server);
	entry->flags = flags;
	entry->lifetime = lifetime;

	if (server != NULL)
		entry->family = connman_inet_check_ipaddress(server);

	if (lifetime) {
		int index;
		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);

		/*
		 * We update the service only for those nameservers
		 * that are automagically added via netlink (lifetime > 0)
		 */
		index = connman_inet_ifindex(interface);
		if (server != NULL && index >= 0) {
			struct connman_service *service;
			service = __connman_service_lookup_from_index(index);
			if (service != NULL)
				__connman_service_nameserver_append(service,
								server, TRUE);
		}
	}
	entry_list = g_slist_append(entry_list, entry);

	if (dnsproxy_enabled == TRUE)
		__connman_dnsproxy_append(interface, domain, server);
	else
		__connman_resolvfile_append(interface, domain, server);

	return 0;
}
Example #3
0
static int append_resolver(const char *interface, const char *domain,
				const char *server, unsigned int lifetime,
							unsigned int flags)
{
	struct entry_data *entry;

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

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

	entry = g_try_new0(struct entry_data, 1);
	if (entry == NULL)
		return -ENOMEM;

	entry->interface = g_strdup(interface);
	entry->domain = g_strdup(domain);
	entry->server = g_strdup(server);
	entry->flags = flags;
	if (lifetime) {
		int index;
		entry->timeout = g_timeout_add_seconds(lifetime,
						resolver_expire_cb, entry);

		/*
		 * We update the service only for those nameservers
		 * that are automagically added via netlink (lifetime > 0)
		 */
		index = connman_inet_ifindex(interface);
		if (index >= 0) {
			struct connman_service *service;
			service = __connman_service_lookup_from_index(index);
			if (service != NULL)
				__connman_service_nameserver_append(service,
								server, TRUE);
		}
	}
	entry_list = g_slist_append(entry_list, entry);

	if (dnsproxy_enabled == TRUE)
		__connman_dnsproxy_append(interface, domain, server);
	else
		__connman_resolvfile_append(interface, domain, server);

	return 0;
}