]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - net/bootme.c
net: cosmetic: Name ethaddr variables consistently
[karo-tx-uboot.git] / net / bootme.c
index af2ab9f57ec4a021cddf506ba171bfd9d8c13d8c..f56f7acd79f2b578d56e1a49ee9e8ed437db15da 100644 (file)
@@ -33,7 +33,7 @@ static enum bootme_state bootme_state;
 static int bootme_src_port = 0xdeadface;
 static int bootme_dst_port = 0xdeadbeef;
 static uchar bootme_ether[ETH_ALEN];
-static IPaddr_t bootme_ip;
+static struct in_addr bootme_ip;
 static int bootme_timed_out;
 static const char *output_packet; /* used by first send udp */
 static int output_packet_len;
@@ -93,10 +93,10 @@ static inline int env_changed(int *id)
 
 static int env_id;
 
-static int is_broadcast(IPaddr_t ip)
+static int is_broadcast(struct in_addr ip)
 {
-       static IPaddr_t netmask;
-       static IPaddr_t our_ip;
+       static struct in_addr netmask;
+       static struct in_addr our_ip;
 
        return (ip == ~0 ||                             /* 255.255.255.255 */
            ((netmask & our_ip) == (netmask & ip) &&    /* on the same net */
@@ -141,13 +141,13 @@ static int check_net_config(void)
                        memset(bootme_ether, 0, sizeof(bootme_ether));
 
                net_init();
-               NetServerIP = bootme_ip;
+               net_copy_ip(&net_server_ip, &bootme_ip);
        }
        return 0;
 }
 
 static void bootme_wait_arp_handler(uchar *pkt, unsigned dest,
-                               IPaddr_t sip, unsigned src,
+                               struct in_addr sip, unsigned src,
                                unsigned len)
 {
        net_set_state(NETLOOP_SUCCESS); /* got arp reply - quit net loop */
@@ -168,7 +168,7 @@ static inline char next_cursor(char c)
        return 0;
 }
 
-static void bootme_handler(uchar *pkt, unsigned dest_port, IPaddr_t src_ip,
+static void bootme_handler(uchar *pkt, unsigned dest_port, struct in_addr src_ip,
                        unsigned src_port, unsigned len)
 {
        uchar *eth_pkt = pkt;
@@ -202,7 +202,7 @@ static void bootme_handler(uchar *pkt, unsigned dest_port, IPaddr_t src_ip,
                printf("Target MAC address set to %pM\n", bootme_ether);
 
                if (is_broadcast(bootme_ip)) {
-                       NetCopyIP(&bootme_ip, &src_ip);
+                       net_copy_ip(&bootme_ip, &src_ip);
                }
        }
        if (bootme_state == BOOTME_INIT) {
@@ -225,7 +225,7 @@ static void bootme_handler(uchar *pkt, unsigned dest_port, IPaddr_t src_ip,
 
        case BOOTME_DOWNLOAD:
                if (last_state != BOOTME_INIT)
-                       NetBootFileXferSize += len - 4;
+                       net_boot_file_size += len - 4;
                /* fallthru */
        case BOOTME_DEBUG:
                if (last_state == BOOTME_INIT ||
@@ -251,7 +251,7 @@ void BootmeStart(void)
                check_net_config();
 
        if (output_packet_len == 0 ||
-               memcmp(bootme_ether, NetEtherNullAddr, ETH_ALEN) != 0) {
+               is_valid_ethaddr(bootme_ether)) {
                /* wait for incoming packet */
                net_set_udp_handler(bootme_handler);
                bootme_timed_out = 0;
@@ -289,7 +289,7 @@ int bootme_send_frame(const void *buf, size_t len)
                __func__, buf, len, &NetOurIP, bootme_src_port, &bootme_ip,
                bootme_dst_port);
 
-       if (memcmp(bootme_ether, NetEtherNullAddr, ETH_ALEN) == 0) {
+       if (is_zero_ether_addr(bootme_ether)) {
                output_packet = buf;
                output_packet_len = len;
                /* wait for arp reply and send packet */
@@ -304,6 +304,17 @@ int bootme_send_frame(const void *buf, size_t len)
                return 0;
        }
 
+       if (eth->state != ETH_STATE_ACTIVE) {
+               if (eth_is_on_demand_init()) {
+                       ret = eth_init(gd->bd);
+                       if (ret < 0)
+                               return ret;
+                       eth_set_last_protocol(BOOTME);
+               } else {
+                       eth_init_state_only(gd->bd);
+               }
+       }
+
        assert(NetTxPacket != NULL);
        pkt = (uchar *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE;
        memcpy(pkt, buf, len);
@@ -316,12 +327,12 @@ int bootme_send_frame(const void *buf, size_t len)
        return ret;
 }
 
-static void bootme_init(IPaddr_t server_ip)
+static void bootme_init(struct in_addr server_ip)
 {
        debug("%s@%d: bootme_state: %d -> %d\n", __func__, __LINE__,
                bootme_state, BOOTME_INIT);
        bootme_state = BOOTME_INIT;
-       bootme_ip = server_ip;
+       net_copy_ip(&bootme_ip, &server_ip);
        /* force reconfiguration in check_net_config() */
        env_id = 0;
 }
@@ -363,7 +374,7 @@ int BootMeDebugStart(bootme_hand_f *handler)
        return bootme_state;
 }
 
-int BootMeRequest(IPaddr_t server_ip, const void *buf, size_t len, int timeout)
+int BootMeRequest(struct in_addr server_ip, const void *buf, size_t len, int timeout)
 {
        bootme_init(server_ip);
        bootme_timeout = timeout * 1000;