Merge branch '2020-06-25-tidy-up-bd-command' into next
[oweals/u-boot.git] / net / net.c
index 5199d679a1fbfc9c3d24d3d0577d7e5a375fe4f4..1e7f633cb69c903f3d8d183f6aa13ef2fc686892 100644 (file)
--- a/net/net.c
+++ b/net/net.c
 
 
 #include <common.h>
+#include <bootstage.h>
 #include <command.h>
 #include <console.h>
 #include <env.h>
 #include <env_internal.h>
 #include <errno.h>
+#include <image.h>
+#include <log.h>
 #include <net.h>
 #include <net/fastboot.h>
 #include <net/tftp.h>
@@ -453,6 +456,7 @@ restart:
                net_dev_exists = 1;
                net_boot_file_size = 0;
                switch (protocol) {
+#ifdef CONFIG_CMD_TFTPBOOT
                case TFTPGET:
 #ifdef CONFIG_CMD_TFTPPUT
                case TFTPPUT:
@@ -460,6 +464,7 @@ restart:
                        /* always use ARP to get server ethernet address */
                        tftp_start(protocol);
                        break;
+#endif
 #ifdef CONFIG_CMD_TFTPSRV
                case TFTPSRV:
                        tftp_start_server();
@@ -477,13 +482,13 @@ restart:
                        dhcp_request();         /* Basically same as BOOTP */
                        break;
 #endif
-
+#if defined(CONFIG_CMD_BOOTP)
                case BOOTP:
                        bootp_reset();
                        net_ip.s_addr = 0;
                        bootp_request();
                        break;
-
+#endif
 #if defined(CONFIG_CMD_RARP)
                case RARP:
                        rarp_try = 0;
@@ -636,7 +641,7 @@ restart:
                                printf("Bytes transferred = %d (%x hex)\n",
                                       net_boot_file_size, net_boot_file_size);
                                env_set_hex("filesize", net_boot_file_size);
-                               env_set_hex("fileaddr", load_addr);
+                               env_set_hex("fileaddr", image_load_addr);
                        }
                        if (protocol != NETCONS)
                                eth_halt();
@@ -882,9 +887,6 @@ int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int sport,
  * to the algorithm in RFC815. It returns NULL or the pointer to
  * a complete packet, in static storage
  */
-#ifndef CONFIG_NET_MAXDEFRAG
-#define CONFIG_NET_MAXDEFRAG 16384
-#endif
 #define IP_PKTSIZE (CONFIG_NET_MAXDEFRAG)
 
 #define IP_MAXUDP (IP_PKTSIZE - IP_HDR_SIZE)
@@ -1562,20 +1564,6 @@ int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len)
        return 1;
 }
 
-#if    defined(CONFIG_CMD_NFS)         || \
-       defined(CONFIG_CMD_SNTP)        || \
-       defined(CONFIG_CMD_DNS)
-/*
- * 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
- */
-unsigned int random_port(void)
-{
-       return 1024 + (get_timer(0) % 0x4000);
-}
-#endif
-
 void ip_to_string(struct in_addr x, char *s)
 {
        x.s_addr = ntohl(x.s_addr);