summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-11-25 20:32:51 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-11-25 20:32:51 +0000
commitbc2bd8db0a30ec061da8bbe6f2cb66ba1f18823a (patch)
tree9e87c53b7243b0242a04eccdae348d119e0032dd
parent4868b089980d89f0704b230a11508ae74b0e2601 (diff)
downloadnuttx-bc2bd8db0a30ec061da8bbe6f2cb66ba1f18823a.tar.gz
nuttx-bc2bd8db0a30ec061da8bbe6f2cb66ba1f18823a.tar.bz2
nuttx-bc2bd8db0a30ec061da8bbe6f2cb66ba1f18823a.zip
Restore uip_arp_ipin()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3131 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html3
-rw-r--r--nuttx/TODO8
-rw-r--r--nuttx/configs/README.txt2
-rw-r--r--nuttx/include/net/uip/uip-arp.h10
-rw-r--r--nuttx/net/uip/uip_arp.c30
5 files changed, 44 insertions, 9 deletions
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index a750a04a2..9cf518cb5 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -2922,6 +2922,9 @@ build
<code>CONFIG_NET_ARPTAB_SIZE</code>: The size of the ARP table
</li>
<li>
+ <code>CONFIG_NET_ARP_IPIN</code>: Harvest IP/MAC address mappings for the ARP table from incoming IP packets.
+ </li>
+ <li>
<code>CONFIG_NET_BROADCAST</code>: Incoming UDP broadcast support
</li>
<li>
diff --git a/nuttx/TODO b/nuttx/TODO
index 52ba42407..99e5600d9 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -214,11 +214,9 @@ o Network (net/, drivers/net)
Description: Outgoing packets are dropped and overwritten by ARP packets
if the destination IP has not been mapped to a MAC. Could
improve send() performance by explicitly performing ARP before
- sending the packet.
- ---
- Or by enabling arpin() logic. NOTE: From the uIP forum: "You
- can use the function but it has a bug. You'll need to comment
- this line: uip_len -= sizeof(struct uip_eth_hdr);"
+ sending the packet (or by enabling CONFIG_NET_ARP_IPIN logic.
+ This could, however have negative impacts on busy networks and
+ could require a large value for CONFIG_NET_ARPTAB_SIZE).
Status: Open
Priority: Medium
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index 2f393d853..bda94884e 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -595,6 +595,8 @@ defconfig -- This is a configuration file similar to the Linux
CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's
window
CONFIG_NET_ARPTAB_SIZE - The size of the ARP table
+ CONFIG_NET_ARP_IPIN - Harvest IP/MAC address mappings from the ARP table
+ from incoming IP packets.
CONFIG_NET_BROADCAST - Incoming UDP broadcast support
CONFIG_NET_MULTICAST - Outgoing multi-cast address support
CONFIG_NET_LLH_LEN - The link level header length
diff --git a/nuttx/include/net/uip/uip-arp.h b/nuttx/include/net/uip/uip-arp.h
index 47b5b9992..b77addde5 100644
--- a/nuttx/include/net/uip/uip-arp.h
+++ b/nuttx/include/net/uip/uip-arp.h
@@ -2,7 +2,7 @@
* include/net/uip/uip-arch.h
* Macros and definitions for the ARP module.
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Derived from uIP with has a similar BSD-styple license:
@@ -114,7 +114,7 @@ extern "C" {
EXTERN void uip_arp_init(void);
/****************************************************************************
- * Name: uip_arp_init
+ * Name: uip_arp_ipin
*
* Description:
* The uip_arp_ipin() function should be called whenever an IP packet
@@ -125,7 +125,11 @@ EXTERN void uip_arp_init(void);
*
****************************************************************************/
-#define uip_arp_ipin()
+#ifdef CONFIG_NET_ARP_IPIN
+EXTERN void uip_arp_ipin(void);
+#else
+# define uip_arp_ipin()
+#endif
/****************************************************************************
* Name: uip_arp_arpin
diff --git a/nuttx/net/uip/uip_arp.c b/nuttx/net/uip/uip_arp.c
index 270bddd64..90f1ef2d3 100644
--- a/nuttx/net/uip/uip_arp.c
+++ b/nuttx/net/uip/uip_arp.c
@@ -176,6 +176,34 @@ static void uip_arp_dump(struct arp_hdr *arp)
* Public Functions
****************************************************************************/
+/* ARP processing for incoming IP packets
+ *
+ * This function should be called by the device driver when an IP packet has
+ * been received. The function will check if the address is in the ARP cache,
+ * and if so the ARP cache entry will be refreshed. If no ARP cache entry was
+ * found, a new one is created.
+ *
+ * This function expects an IP packet with a prepended Ethernet header in the
+ * d_buf[] buffer, and the length of the packet in the variable d_len.
+ */
+
+#ifdef CONFIG_NET_ARP_IPIN
+void uip_arp_ipin(void)
+{
+ in_addr_t srcipaddr;
+
+ /* Only insert/update an entry if the source IP address of the incoming IP
+ * packet comes from a host on the local network.
+ */
+
+ srcipaddr = uip_ip4addr_conv(IPBUF->srcipaddr);
+ if (!uip_ipaddr_maskcmp(ipaddr, dev->d_ipaddr, dev->d_netmask))
+ {
+ uip_arp_update(IPBUF->srcipaddr, ETHBUF->src);
+ }
+}
+#endif /* CONFIG_NET_ARP_IPIN */
+
/* ARP processing for incoming ARP packets.
*
* This function should be called by the device driver when an ARP
@@ -194,7 +222,7 @@ static void uip_arp_dump(struct arp_hdr *arp)
*
* This function expects an ARP packet with a prepended Ethernet
* header in the d_buf[] buffer, and the length of the packet in the
- * global variable d_len.
+ * variable d_len.
*/
void uip_arp_arpin(struct uip_driver_s *dev)