summaryrefslogtreecommitdiff
path: root/net/rarp.c
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-05-23 07:59:09 +0000
committerJoe Hershberger <joe.hershberger@ni.com>2012-05-23 17:46:19 -0500
commit00f33268ab02984a5fa8b3783b6096d4ce6c48c7 (patch)
tree1d2bf41e3a7f6512f2231d65335f95845885a380 /net/rarp.c
parent9214637a56abd27863824bd53e602b7721b3cda6 (diff)
net: Refactor packet length computations
Save the length when it is computed instead of forgetting it and subtracting pointers to figure it out again. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Simon Glass <sjg@chromium.org> Acked-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'net/rarp.c')
-rw-r--r--net/rarp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/rarp.c b/net/rarp.c
index da50961d63..a715c2c7fd 100644
--- a/net/rarp.c
+++ b/net/rarp.c
@@ -88,11 +88,13 @@ void RarpRequest(void)
{
uchar *pkt;
struct arp_hdr *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_hdr *)pkt;
@@ -108,7 +110,7 @@ void 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);
}