]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
net: Separate ArpRequest() into lower-level func
authorJoe Hershberger <joe.hershberger@ni.com>
Wed, 23 May 2012 08:00:11 +0000 (08:00 +0000)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 23 May 2012 22:53:07 +0000 (17:53 -0500)
Link-local support will need to send ARP packets, but needs more
fine-grained control over the contents.  Split the implementation
into 2 parts so link-local can share the code.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
net/arp.c
net/arp.h

index 4a73a0fb35f63b9825a9b00f3c90a371703ac384..908ebf53165a334e25096be1719241db138700e0 100644 (file)
--- a/net/arp.c
+++ b/net/arp.c
@@ -48,7 +48,8 @@ void ArpInit(void)
        NetArpTxPacket -= (ulong)NetArpTxPacket % PKTALIGN;
 }
 
-void ArpRequest(void)
+void arp_raw_request(IPaddr_t sourceIP, const uchar *targetEther,
+       IPaddr_t targetIP)
 {
        uchar *pkt;
        struct arp_hdr *arp;
@@ -69,12 +70,16 @@ void ArpRequest(void)
        arp->ar_pln = ARP_PLEN;
        arp->ar_op = htons(ARPOP_REQUEST);
 
-       /* source ET addr */
-       memcpy(&arp->ar_sha, NetOurEther, ARP_HLEN);
-       /* source IP addr */
-       NetWriteIP(&arp->ar_spa, NetOurIP);
-       /* dest ET addr = 0 */
-       memset(&arp->ar_tha, 0, ARP_HLEN);
+       memcpy(&arp->ar_sha, NetOurEther, ARP_HLEN);    /* source ET addr */
+       NetWriteIP(&arp->ar_spa, sourceIP);             /* source IP addr */
+       memcpy(&arp->ar_tha, targetEther, ARP_HLEN);    /* target ET addr */
+       NetWriteIP(&arp->ar_tpa, targetIP);             /* target IP addr */
+
+       NetSendPacket(NetArpTxPacket, eth_hdr_size + ARP_HDR_SIZE);
+}
+
+void ArpRequest(void)
+{
        if ((NetArpWaitPacketIP & NetOurSubnetMask) !=
            (NetOurIP & NetOurSubnetMask)) {
                if (NetOurGatewayIP == 0) {
@@ -87,8 +92,7 @@ void ArpRequest(void)
                NetArpWaitReplyIP = NetArpWaitPacketIP;
        }
 
-       NetWriteIP(&arp->ar_tpa, NetArpWaitReplyIP);
-       NetSendPacket(NetArpTxPacket, eth_hdr_size + ARP_HDR_SIZE);
+       arp_raw_request(NetOurIP, NetEtherNullAddr, NetArpWaitReplyIP);
 }
 
 void ArpTimeoutCheck(void)
index 956fc5e570f1800dba6bde2d2c29fdc2e37456b5..bfd57e0105391bb21f00bb643fdb2a80f607c54b 100644 (file)
--- a/net/arp.h
+++ b/net/arp.h
@@ -22,6 +22,8 @@ extern int NetArpWaitTry;
 
 void ArpInit(void);
 void ArpRequest(void);
+void arp_raw_request(IPaddr_t sourceIP, const uchar *targetEther,
+       IPaddr_t targetIP);
 void ArpTimeoutCheck(void);
 void ArpReceive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len);