summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-07-08 00:59:51 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-07-08 00:59:51 +0000
commita840b46208077e92bfeb30147aedc49d9c04aa8e (patch)
treec9bd9fda4b5432a681cbe6c2545fe446eee031e4
parentd5135803d4021ef6fb2d69394cd28fdd665a8bca (diff)
downloadpx4-nuttx-a840b46208077e92bfeb30147aedc49d9c04aa8e.tar.gz
px4-nuttx-a840b46208077e92bfeb30147aedc49d9c04aa8e.tar.bz2
px4-nuttx-a840b46208077e92bfeb30147aedc49d9c04aa8e.zip
More IGMP changes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2777 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/include/net/uip/uip-arch.h10
-rwxr-xr-xnuttx/include/net/uip/uip-igmp.h77
-rw-r--r--nuttx/net/uip/uip_initialize.c8
-rw-r--r--nuttx/net/uip/uip_input.c10
-rw-r--r--nuttx/net/uip/uip_internal.h4
5 files changed, 105 insertions, 4 deletions
diff --git a/nuttx/include/net/uip/uip-arch.h b/nuttx/include/net/uip/uip-arch.h
index 72288cba6..3184ac0f7 100644
--- a/nuttx/include/net/uip/uip-arch.h
+++ b/nuttx/include/net/uip/uip-arch.h
@@ -47,7 +47,11 @@
#include <sys/ioctl.h>
#include <stdint.h>
#include <net/if.h>
+
#include <net/uip/uip.h>
+#ifdef CONFIG_NET_IGMP
+# include <net/uip/uip-igmp.h>
+#endif
/****************************************************************************
* Included Files
@@ -169,6 +173,12 @@ struct uip_driver_s
uint16_t d_sndlen;
+ /* IGMP group list */
+
+#ifdef CONFIG_NET_IGMP
+ FAR struct igmp_group_s *grplist;
+#endif
+
/* Driver callbacks */
int (*d_ifup)(struct uip_driver_s *dev);
diff --git a/nuttx/include/net/uip/uip-igmp.h b/nuttx/include/net/uip/uip-igmp.h
index 7ad105ec3..8f80ac1f2 100755
--- a/nuttx/include/net/uip/uip-igmp.h
+++ b/nuttx/include/net/uip/uip-igmp.h
@@ -47,8 +47,15 @@
****************************************************************************/
#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
#include <netinet/in.h>
+#include <net/uip/uip.h>
+#include <net/uip/uip-arch.h>
+
#ifdef CONFIG_NET_IGMP
/****************************************************************************
@@ -67,10 +74,20 @@
#define IGMPv3_MEMBERSHIP_REPORT 0x22 /* IGMP Ver. 3 Membership Report */
#define IGMP_LEAVE_GROUP 0x17 /* Leave Group */
-/* Header sizes */
+/* Header sizes:
+ *
+ * UIP_IGMPH_LEN - Size of IGMP header in bytes
+ * UIP_IPIGMPH_LEN - Size of IP + IGMP header
+ */
+
+#define UIP_IGMPH_LEN 8
+#define UIP_IPIGMPH_LEN (UIP_IGMPH_LEN + UIP_IPH_LEN)
+
+/* Group membership states */
-#define UIP_IGMPH_LEN 4 /* Size of IGMP header */
-#define UIP_IPIGMPH_LEN (UIP_IGMPH_LEN + UIP_IPH_LEN) /* Size of IP + IGMP header */
+#define IGMP_NON_MEMBER 0
+#define IGMP_DELAYING_MEMBER 1
+#define IGMP_IDLE_MEMBER 2
/****************************************************************************
* Public Types
@@ -124,6 +141,43 @@ struct uip_igmphdr_s
uint16_t grpaddr[2]; /* 32-bit Group address */
};
+#ifdef CONFIG_NET_IGMP_STATS
+struct igmp_stats_s
+{
+ uint32_t length_errors;
+ uint32_t chksum_errors;
+ uint32_t v1_received;
+ uint32_t joins;
+ uint32_t leave_sent;
+ uint32_t ucast_query;
+ uint32_t report_sent;
+ uint32_t query_received;
+ uint32_t report_received;
+};
+
+# define IGMP_STATINCR(p) ((p)++)
+#else
+# define IGMP_STATINCR(p)
+#endif
+
+/* This structure represents one group member. There is a list of groups
+ * for each device interface structure.
+ *
+ * There will be a group for the all systems group address but this
+ * will not run the state machine as it is used to kick off reports
+ * from all the other groups
+ */
+
+struct igmp_group_s
+{
+ struct igmp_group_s *next; /* Implements a singly-linked list */
+ uip_ipaddr_t grpaddr; /* Group IP address */
+ WDOG_ID wdog; /* WDOG used to detect timeouts */
+ bool lastrpt; /* Indicates the last to report */
+ uint8_t state; /* State of the group */
+ uint8_t msgid; /* Pending message ID (if non-zero) */
+};
+
/****************************************************************************
* Public Data
****************************************************************************/
@@ -136,10 +190,27 @@ extern "C" {
#define EXTERN extern
#endif
+#ifdef CONFIG_NET_IGMP_STATS
+struct igmp_stats_s g_igmpstats;
+#endif
+
+extern uip_ipaddr_t g_allsystems;
+extern uip_ipaddr_t g_allrouters;
+
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
+/****************************************************************************
+ * Name: uip_igmpdevinit
+ *
+ * Description:
+ * Called when a new network device is registered to configure that device
+ * for IGMP support.
+ *
+ ****************************************************************************/
+
+EXTERN void uip_igmpdevinit(struct uip_driver_s *dev);
#undef EXTERN
#if defined(__cplusplus)
diff --git a/nuttx/net/uip/uip_initialize.c b/nuttx/net/uip/uip_initialize.c
index 867e7d66a..8c05765bc 100644
--- a/nuttx/net/uip/uip_initialize.c
+++ b/nuttx/net/uip/uip_initialize.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/uip/uip_initialize.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Adapted for NuttX from logic in uIP which also has a BSD-like license:
@@ -140,6 +140,12 @@ void uip_initialize(void)
#ifdef CONFIG_NET_UDP
uip_udpinit();
#endif
+
+ /* Initialize IGMP support */
+
+#ifdef CONFIG_NET_IGMP
+ uip_udpinit();
+#endif
}
#endif /* CONFIG_NET */
diff --git a/nuttx/net/uip/uip_input.c b/nuttx/net/uip/uip_input.c
index 893fa3b0a..6a8963f38 100644
--- a/nuttx/net/uip/uip_input.c
+++ b/nuttx/net/uip/uip_input.c
@@ -510,6 +510,16 @@ void uip_input(struct uip_driver_s *dev)
break;
#endif
+ /* Check for ICMP input */
+
+#ifdef CONFIG_NET_IGMP
+#ifndef CONFIG_NET_IPv6
+ case UIP_PROTO_IGMP: /* IGMP input */
+ uip_igmpinput(dev);
+ break;
+#endif
+#endif
+
default: /* Unrecognized/unsupported protocol */
#ifdef CONFIG_NET_STATISTICS
uip_stat.ip.drop++;
diff --git a/nuttx/net/uip/uip_internal.h b/nuttx/net/uip/uip_internal.h
index 487563c81..990a08e6f 100644
--- a/nuttx/net/uip/uip_internal.h
+++ b/nuttx/net/uip/uip_internal.h
@@ -210,6 +210,10 @@ EXTERN void uip_icmpsend(struct uip_driver_s *dev, uip_ipaddr_t *destaddr);
#endif /* CONFIG_NET_ICMP */
#ifdef CONFIG_NET_IGMP
+/* Defined in uip_igmpinit.c ************************************************/
+
+EXTERN void uip_igmpinit(void);
+
/* Defined in uip_igmpinput.c ***********************************************/
EXTERN void uip_igmpinput(struct uip_driver_s *dev);