Signed-off-by: Joe Hershberger <joe.hershber...@ni.com>
Cc: Joe Hershberger <joe.hershber...@gmail.com>
Cc: Wolfgang Denk <w...@denx.de>
---
 net/arp.c  |   13 ++++++++-----
 net/ping.c |    7 ++++---
 net/rarp.c |    6 ++++--
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/net/arp.c b/net/arp.c
index 456decd..60a1ded 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -52,12 +52,14 @@ void ArpRequest(void)
 {
        uchar *pkt;
        struct ARP_t *arp;
+       int eth_hdr_size;
 
        debug("ARP broadcast %d\n", NetArpWaitTry);
 
        pkt = NetTxPacket;
 
-       pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP);
+       eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_ARP);
+       pkt += eth_hdr_size;
 
        arp = (struct ARP_t *) pkt;
 
@@ -86,7 +88,7 @@ void ArpRequest(void)
        }
 
        NetWriteIP(&arp->ar_tpa, NetArpWaitReplyIP);
-       (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
+       (void) eth_send(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE);
 }
 
 void ArpTimeoutCheck(void)
@@ -118,6 +120,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, 
int len)
        struct ARP_t *arp;
        IPaddr_t reply_ip_addr;
        uchar *pkt;
+       int eth_hdr_size;
 
        /*
         * We have to deal with two types of ARP packets:
@@ -155,14 +158,14 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t 
*ip, int len)
                /* reply with our IP address */
                debug("Got ARP REQUEST, return our IP\n");
                pkt = (uchar *)et;
-               pkt += NetSetEther(pkt, et->et_src, PROT_ARP);
+               eth_hdr_size = NetSetEther(pkt, et->et_src, PROT_ARP);
+               pkt += eth_hdr_size;
                arp->ar_op = htons(ARPOP_REPLY);
                memcpy(&arp->ar_tha, &arp->ar_sha, ARP_HLEN);
                NetCopyIP(&arp->ar_tpa, &arp->ar_spa);
                memcpy(&arp->ar_sha, NetOurEther, ARP_HLEN);
                NetCopyIP(&arp->ar_spa, &NetOurIP);
-               (void) eth_send((uchar *)et,
-                               (pkt - (uchar *)et) + ARP_HDR_SIZE);
+               (void) eth_send((uchar *)et, eth_hdr_size + ARP_HDR_SIZE);
                return;
 
        case ARPOP_REPLY:               /* arp reply */
diff --git a/net/ping.c b/net/ping.c
index 356f107..12f9185 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -42,6 +42,7 @@ static int PingSend(void)
 {
        static uchar mac[6];
        uchar *pkt;
+       int eth_hdr_size;
 
        /* XXX always send arp request */
 
@@ -53,13 +54,13 @@ static int PingSend(void)
        NetArpWaitPacketMAC = mac;
 
        pkt = NetArpWaitTxPacket;
-       pkt += NetSetEther(pkt, mac, PROT_IP);
+       eth_hdr_size = NetSetEther(pkt, mac, PROT_IP);
+       pkt += eth_hdr_size;
 
        SetICMPHeader(pkt, NetPingIP);
 
        /* size of the waiting packet */
-       NetArpWaitTxPacketSize =
-               (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE + 8;
+       NetArpWaitTxPacketSize = eth_hdr_size + IP_ICMP_HDR_SIZE;
 
        /* and do the ARP request */
        NetArpWaitTry = 1;
diff --git a/net/rarp.c b/net/rarp.c
index 305b0a4..3097341 100644
--- a/net/rarp.c
+++ b/net/rarp.c
@@ -91,11 +91,13 @@ RarpRequest(void)
 {
        uchar *pkt;
        struct ARP_t *rarp;
+       int eth_hdr_size;
 
        printf("RARP broadcast %d\n", ++RarpTry);
        pkt = NetTxPacket;
 
-       pkt += NetSetEther(pkt, NetBcastAddr, PROT_RARP);
+       eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_RARP);
+       pkt += eth_hdr_size;
 
        rarp = (struct ARP_t *)pkt;
 
@@ -111,7 +113,7 @@ RarpRequest(void)
        /* dest IP addr set to broadcast */
        memset(&rarp->ar_data[16], 0xff,        4);
 
-       NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
+       NetSendPacket(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE);
 
        NetSetTimeout(TIMEOUT, RarpTimeout);
 }
-- 
1.6.0.2

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to