summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9214637)
raw | patch | inline | side by side (parent: 9214637)
author | Joe Hershberger <joe.hershberger@ni.com> | |
Wed, 23 May 2012 07:59:09 +0000 (07:59 +0000) | ||
committer | Joe Hershberger <joe.hershberger@ni.com> | |
Wed, 23 May 2012 22:46:19 +0000 (17:46 -0500) |
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>
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>
net/arp.c | patch | blob | history | |
net/ping.c | patch | blob | history | |
net/rarp.c | patch | blob | history |
diff --git a/net/arp.c b/net/arp.c
index 5ed875ca707cfbe0ca5d5cb3dad6d983e51c58cb..e58a074512d62d2e6f602fee18d729daab453697 100644 (file)
--- a/net/arp.c
+++ b/net/arp.c
{
uchar *pkt;
struct arp_hdr *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_hdr *) pkt;
}
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)
struct arp_hdr *arp;
IPaddr_t reply_ip_addr;
uchar *pkt;
+ int eth_hdr_size;
/*
* We have to deal with two types of ARP packets:
/* 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 c52563566900e01f336019d18878c97da36f0a9f..939f8ff6fcea85a2f5598c63640dda12e02e06cb 100644 (file)
--- a/net/ping.c
+++ b/net/ping.c
{
static uchar mac[6];
uchar *pkt;
+ int eth_hdr_size;
/* XXX always send arp request */
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;
diff --git a/net/rarp.c b/net/rarp.c
index da50961d630353a637baa08a1fbaa88e1443c940..a715c2c7fd6420d5c157fce073ede337adb2c582 100644 (file)
--- a/net/rarp.c
+++ b/net/rarp.c
{
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;
/* 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);
}