[PATCH 9/9] gdhcp: Set domain-search names

Peter Meerwald pmeerw at pmeerw.net
Tue Sep 10 06:46:20 PDT 2013


---
 src/dhcp.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index c300357..27c7bef 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -301,7 +301,8 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
 	const char *c_address, *c_gateway;
 	char *domainname = NULL, *hostname = NULL;
 	char **nameservers, **timeservers, *pac = NULL;
-	int ns_entries;
+	char **searchdomains = NULL;
+	int ns_entries, ds_entries;
 	struct connman_ipconfig *ipconfig;
 	struct connman_service *service;
 	unsigned char prefixlen, c_prefixlen;
@@ -376,6 +377,15 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
 	if (option)
 		domainname = g_strdup(option->data);
 
+	option = g_dhcp_client_get_option(dhcp_client, G_DHCP_DOMAIN_SEARCH);
+	ds_entries = g_list_length(option);
+	searchdomains = g_try_new0(char *, ds_entries + 1);
+	if (searchdomains) {
+		for (i = 0, list = option; list; list = list->next, i++)
+			searchdomains[i] = g_strdup(list->data);
+		searchdomains[ds_entries] = NULL;
+	}
+
 	if (connman_setting_get_bool("AllowHostnameUpdates")) {
 		option = g_dhcp_client_get_option(dhcp_client,
 						G_DHCP_HOST_NAME);
-- 
1.7.9.5




More information about the connman mailing list