summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-30 23:12:11 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-30 23:12:11 +0000
commitf2475599fef8877dadbec64887131e5c7d99834b (patch)
tree6d1f2cb2d60f8e6c405318a3f5026b46a670499a /nuttx
parent09d3b9f21b39de8406ce8a58be8e39e0aa7d52ca (diff)
downloadpx4-nuttx-f2475599fef8877dadbec64887131e5c7d99834b.tar.gz
px4-nuttx-f2475599fef8877dadbec64887131e5c7d99834b.tar.bz2
px4-nuttx-f2475599fef8877dadbec64887131e5c7d99834b.zip
correct handling of UDP broadcast
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@418 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/net/uip/uip-input.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/nuttx/net/uip/uip-input.c b/nuttx/net/uip/uip-input.c
index 1decffba5..acb18990b 100644
--- a/nuttx/net/uip/uip-input.c
+++ b/nuttx/net/uip/uip-input.c
@@ -382,6 +382,31 @@ void uip_input(struct uip_driver_s *dev)
}
#endif /* CONFIG_NET_IPv6 */
+ /* If IP broadcast support is configured, we check for a broadcast
+ * UDP packet, which may be destined to us (even if there is no IP
+ * address yet assigned to the device as is the case when we are
+ * negotiating over DHCP for an address).
+ */
+
+#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
+ if (BUF->proto == UIP_PROTO_UDP &&
+#ifndef CONFIG_NET_IPv6
+ uip_ipaddr_cmp(uip_ip4addr_conv(BUF->destipaddr), g_alloneaddr))
+#else
+ uip_ipaddr_cmp(BUF->destipaddr, g_alloneaddr))
+#endif
+ {
+ uip_udpinput(dev);
+ return;
+ }
+
+ /* In most other cases, the device must be assigned a non-zero IP
+ * address. Another exception is when CONFIG_NET_PINGADDRCONF is
+ * enabled...
+ */
+
+ else
+#endif
if (uip_ipaddr_cmp(dev->d_ipaddr, g_allzeroaddr))
{
/* If we are configured to use ping IP address configuration and
@@ -403,20 +428,10 @@ void uip_input(struct uip_driver_s *dev)
goto drop;
}
}
+
+ /* Check if the pack is destined for out IP address */
else
{
- /* If IP broadcast support is configured, we check for a broadcast
- * UDP packet, which may be destined to us.
- */
-
-#ifdef CONFIG_NET_BROADCAST
- if (BUF->proto == UIP_PROTO_UDP && uip_ipaddr_cmp(BUF->destipaddr, g_alloneaddr))
- {
- uip_udpinput(dev);
- return;
- }
-#endif
-
/* Check if the packet is destined for our IP address. */
#ifndef CONFIG_NET_IPv6
if (!uip_ipaddr_cmp(uip_ip4addr_conv(BUF->destipaddr), dev->d_ipaddr))