image: Add the concept of a phase to FIT
[platform/kernel/u-boot.git] / net / dns.c
index 7017bac..5b1fe5b 100644 (file)
--- a/net/dns.c
+++ b/net/dns.c
@@ -24,6 +24,8 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
+#include <log.h>
 #include <net.h>
 #include <asm/unaligned.h>
 
@@ -34,6 +36,16 @@ char *net_dns_env_var;       /* The envvar to store the answer in */
 
 static int dns_our_port;
 
+/*
+ * make port a little random (1024-17407)
+ * This keeps the math somewhat trivial to compute, and seems to work with
+ * all supported protocols/clients/servers
+ */
+static unsigned int random_port(void)
+{
+       return 1024 + (get_timer(0) % 0x4000);
+}
+
 static void dns_send(void)
 {
        struct header *header;
@@ -184,7 +196,7 @@ static void dns_handler(uchar *pkt, unsigned dest, struct in_addr sip,
                        ip_to_string(ip_addr, ip_str);
                        printf("%s\n", ip_str);
                        if (net_dns_env_var)
-                               setenv(net_dns_env_var, ip_str);
+                               env_set(net_dns_env_var, ip_str);
                } else {
                        puts("server responded with invalid IP number\n");
                }