[PATCH 2/8] net: dhcp: reset env variable before do a dhcp request

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Mon Apr 2 10:19:04 EDT 2012


Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 net/dhcp.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/net/dhcp.c b/net/dhcp.c
index 3b035d7..3c48aaa 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -536,11 +536,27 @@ static void dhcp_handler(void *ctx, char *packet, unsigned int len)
 	}
 }
 
+static void dhcp_reset_env(void)
+{
+	struct dhcp_opt *opt;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(dhcp_options); i++) {
+		opt = &dhcp_options[i];
+		if (!opt->barebox_var_name)
+			continue;
+
+		setenv(opt->barebox_var_name,"");
+	}
+}
+
 static int do_dhcp(int argc, char *argv[])
 {
 	int ret, opt;
 	char *vendor_id = (char*)getenv("dhcp_vendor_id");
 
+	dhcp_reset_env();
+
 	while((opt = getopt(argc, argv, "v:")) > 0) {
 		switch(opt) {
 		case 'v':
-- 
1.7.9.1




More information about the barebox mailing list