[PATCH 4/6] dhcp: set global domainname and nameserver

Sascha Hauer s.hauer at pengutronix.de
Sun Apr 15 09:26:18 EDT 2012


nameserver and domainname are now netdevice parameters. Use them.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 net/dhcp.c |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 0116ba4..82ab100 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -104,12 +104,21 @@ static void gateway_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen
 	net_set_gateway(ip);
 }
 
-static void env_ip_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
+static void nameserver_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
 {
 	IPaddr_t ip;
 
 	ip = net_read_ip(popt);
-	setenv_ip(opt->barebox_var_name, ip);
+	net_set_nameserver(ip);
+}
+
+static void domainname_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
+{
+	char str[256];
+
+	memcpy(str, popt, optlen);
+	str[optlen] = 0;
+	net_set_domainname(str);
 }
 
 static void env_str_handle(struct dhcp_opt *opt, unsigned char *popt, int optlen)
@@ -169,16 +178,14 @@ struct dhcp_opt dhcp_options[] = {
 		.handle = gateway_handle,
 	}, {
 		.option = 6,
-		.handle = env_ip_handle,
-		.barebox_var_name = "nameserver",
+		.handle = nameserver_handle,
 	}, {
 		.option = 12,
 		.handle = env_str_handle,
 		.barebox_var_name = "hostname",
 	}, {
 		.option = 15,
-		.handle = env_str_handle,
-		.barebox_var_name = "domainname",
+		.handle = domainname_handle,
 	}, {
 		.option = 17,
 		.handle = env_str_handle,
@@ -697,9 +704,7 @@ BAREBOX_CMD_START(dhcp)
 BAREBOX_CMD_END
 
 BAREBOX_MAGICVAR(bootfile, "bootfile returned from DHCP request");
-BAREBOX_MAGICVAR(nameserver, "Nameserver returned from DHCP request");
 BAREBOX_MAGICVAR(hostname, "hostname returned from DHCP request");
-BAREBOX_MAGICVAR(domainname, "domainname returned from DHCP request");
 BAREBOX_MAGICVAR(rootpath, "rootpath returned from DHCP request");
 BAREBOX_MAGICVAR(dhcp_vendor_id, "vendor id to send to the DHCP server");
 BAREBOX_MAGICVAR(dhcp_client_uuid, "cliend uuid to send to the DHCP server");
-- 
1.7.10




More information about the barebox mailing list