summaryrefslogtreecommitdiff
path: root/net/ping.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/ping.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/ping.c')
-rw-r--r--net/ping.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/ping.c b/net/ping.c
index c5256356690..939f8ff6fce 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -42,6 +42,7 @@ static int ping_send(void)
{
static uchar mac[6];
uchar *pkt;
+ int eth_hdr_size;
/* XXX always send arp request */
@@ -53,13 +54,13 @@ static int ping_send(void)
NetArpWaitPacketMAC = mac;
pkt = NetArpWaitTxPacket;
- pkt += NetSetEther(pkt, mac, PROT_IP);
+ eth_hdr_size = NetSetEther(pkt, mac, PROT_IP);
+ pkt += eth_hdr_size;
set_icmp_header(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;