summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-07-13 03:43:06 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-07-13 03:43:06 +0000
commit7569e53f92cc6c313c8642a8cc53dfacea63382b (patch)
tree50917f724a6a70b33050502c1b4bc395528fd460
parent35a4b3030e7548e6aace209ef8e92a5e2b495d1e (diff)
downloadnuttx-7569e53f92cc6c313c8642a8cc53dfacea63382b.tar.gz
nuttx-7569e53f92cc6c313c8642a8cc53dfacea63382b.tar.bz2
nuttx-7569e53f92cc6c313c8642a8cc53dfacea63382b.zip
IGMP debug fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2791 42af7a65-404d-4744-a932-0658087f49c3
-rwxr-xr-xnuttx/examples/igmp/igmp.c14
-rwxr-xr-xnuttx/include/net/uip/uip-igmp.h8
-rw-r--r--nuttx/net/netdev_ioctl.c4
-rw-r--r--nuttx/net/uip/uip_arp.c28
-rwxr-xr-xnuttx/net/uip/uip_igmpgroup.c4
-rwxr-xr-xnuttx/net/uip/uip_igmpjoin.c2
-rwxr-xr-xnuttx/net/uip/uip_igmpleave.c5
-rwxr-xr-xnuttx/net/uip/uip_igmppoll.c9
-rwxr-xr-xnuttx/net/uip/uip_igmpsend.c20
-rwxr-xr-xnuttx/net/uip/uip_igmptimer.c2
-rwxr-xr-xnuttx/net/uip/uip_mcastmac.c6
-rwxr-xr-xnuttx/netutils/uiplib/uip_ipmsfilter.c3
12 files changed, 55 insertions, 50 deletions
diff --git a/nuttx/examples/igmp/igmp.c b/nuttx/examples/igmp/igmp.c
index c341e4c1d..8bca7fa4e 100755
--- a/nuttx/examples/igmp/igmp.c
+++ b/nuttx/examples/igmp/igmp.c
@@ -55,6 +55,20 @@
* Definitions
****************************************************************************/
+/* Check if the destination address is a multicast address
+ *
+ * - IPv4: multicast addresses lie in the class D group -- The address range
+ * 224.0.0.0 to 239.255.255.255 (224.0.0.0/4)
+ *
+ * - IPv6 multicast addresses are have the high-order octet of the
+ * addresses=0xff (ff00::/8.)
+ */
+
+#if ((CONFIG_EXAMPLE_IGMP_GRPADDR & 0xffff0000) < 0xe0000000ul) || \
+ ((CONFIG_EXAMPLE_IGMP_GRPADDR & 0xffff0000) > 0xeffffffful)
+# error "Bad range for IGMP group address"
+#endif
+
/****************************************************************************
* Private Data
****************************************************************************/
diff --git a/nuttx/include/net/uip/uip-igmp.h b/nuttx/include/net/uip/uip-igmp.h
index 184153a84..b2448627c 100755
--- a/nuttx/include/net/uip/uip-igmp.h
+++ b/nuttx/include/net/uip/uip-igmp.h
@@ -78,11 +78,11 @@
/* Header sizes:
*
* UIP_IGMPH_LEN - Size of IGMP header in bytes
- * UIP_IPIGMPH_LEN - Size of IP + IGMP header
+ * UIP_IPIGMPH_LEN - Size of IP + Size of IGMP header + Size of router alert
*/
#define UIP_IGMPH_LEN 8
-#define UIP_IPIGMPH_LEN (UIP_IGMPH_LEN + UIP_IPH_LEN)
+#define UIP_IPIGMPH_LEN (UIP_IGMPH_LEN + UIP_IPH_LEN + 4)
/* Group flags */
@@ -157,6 +157,10 @@ struct uip_igmphdr_s
#endif /* CONFIG_NET_IPv6 */
+ /* Router alerted IP header option */
+
+ uint16_t ra[2];
+
/* IGMP header:
*
* 0 1 2 3
diff --git a/nuttx/net/netdev_ioctl.c b/nuttx/net/netdev_ioctl.c
index b5828ed3f..d4be2b64a 100644
--- a/nuttx/net/netdev_ioctl.c
+++ b/nuttx/net/netdev_ioctl.c
@@ -158,6 +158,8 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd, struct ifreq *req)
FAR struct uip_driver_s *dev;
int ret = OK;
+ nvdbg("cmd: %d\n", cmd);
+
/* Find the network device associated with the device name
* in the request data.
*/
@@ -268,6 +270,8 @@ static int netdev_imsfioctl(FAR struct socket *psock, int cmd, struct ip_msfilte
FAR struct uip_driver_s *dev;
int ret = OK;
+ nvdbg("cmd: %d\n", cmd);
+
/* Find the network device associated with the device name
* in the request data.
*/
diff --git a/nuttx/net/uip/uip_arp.c b/nuttx/net/uip/uip_arp.c
index 6e00a6b63..270bddd64 100644
--- a/nuttx/net/uip/uip_arp.c
+++ b/nuttx/net/uip/uip_arp.c
@@ -64,9 +64,6 @@
#include <net/ethernet.h>
#include <net/uip/uip-arch.h>
#include <net/uip/uip-arp.h>
-#ifdef CONFIG_NET_IGMP
-# include <net/uip/uip-igmp.h>
-#endif
/****************************************************************************
* Pre-processor Definitions
@@ -83,11 +80,6 @@
#define ARPBUF ((struct arp_hdr *)&dev->d_buf[UIP_LLH_LEN])
#define IPBUF ((struct ethip_hdr *)&dev->d_buf[UIP_LLH_LEN])
-#ifdef CONFIG_NET_IGMP
-# define RA ((uint16_t *)&dev->d_buf[UIP_LLH_LEN])
-# define RAIPBUF ((struct ethip_hdr *)&dev->d_buf[UIP_LLH_LEN+RASIZE])
-#endif
-
/****************************************************************************
* Private Types
****************************************************************************/
@@ -298,28 +290,10 @@ void uip_arp_out(struct uip_driver_s *dev)
const struct arp_entry *tabptr = NULL;
struct arp_hdr *parp = ARPBUF;
struct uip_eth_hdr *peth = ETHBUF;
- struct ethip_hdr *pip;
+ struct ethip_hdr *pip = IPBUF;
in_addr_t ipaddr;
in_addr_t destipaddr;
- /* Check for the router alert option */
-
-#if CONFIG_NET_IGMP
- if (RA[0] == HTONS(ROUTER_ALERT >> 16) && RA[1] == HTONS(ROUTER_ALERT & 0xffff))
- {
- /* Yes... there is a router alert. This must be an IGMP packet.
- * bump up the IP header address to index around the router alert.
- */
-
- pip = RAIPBUF;
- }
- else
-#else
- {
- pip = IPBUF;
- }
-#endif
-
/* Find the destination IP address in the ARP table and construct
* the Ethernet header. If the destination IP addres isn't on the
* local network, we use the default router's IP address instead.
diff --git a/nuttx/net/uip/uip_igmpgroup.c b/nuttx/net/uip/uip_igmpgroup.c
index d0fa820a3..4b169cf92 100755
--- a/nuttx/net/uip/uip_igmpgroup.c
+++ b/nuttx/net/uip/uip_igmpgroup.c
@@ -191,7 +191,7 @@ FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,
{
/* Initialize the non-zero elements of the group structure */
- uip_ipaddr_copy(group->grpaddr, addr);
+ uip_ipaddr_copy(group->grpaddr, *addr);
sem_init(&group->sem, 0, 0);
/* Interrupts must be disabled in order to modify the group list */
@@ -230,7 +230,7 @@ FAR struct igmp_group_s *uip_grpfind(FAR struct uip_driver_s *dev,
flags = irqsave();
for (group = (FAR struct igmp_group_s *)dev->grplist.head; group; group = group->next)
{
- if (uip_ipaddr_cmp(&group->grpaddr, addr))
+ if (uip_ipaddr_cmp(&group->grpaddr, *addr))
{
break;
}
diff --git a/nuttx/net/uip/uip_igmpjoin.c b/nuttx/net/uip/uip_igmpjoin.c
index b9e538c15..0b193544b 100755
--- a/nuttx/net/uip/uip_igmpjoin.c
+++ b/nuttx/net/uip/uip_igmpjoin.c
@@ -133,7 +133,7 @@ int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
{
/* No... allocate a new entry */
- nvdbg("Join to new group\n");
+ nvdbg("Join to new group: %08x\n", grpaddr->s_addr);
group = uip_grpalloc(dev, &grpaddr->s_addr);
IGMP_STATINCR(uip_stat.igmp.joins);
diff --git a/nuttx/net/uip/uip_igmpleave.c b/nuttx/net/uip/uip_igmpleave.c
index 5665081b5..af546dd54 100755
--- a/nuttx/net/uip/uip_igmpleave.c
+++ b/nuttx/net/uip/uip_igmpleave.c
@@ -137,6 +137,7 @@ int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
/* Find the entry corresponding to the address leaving the group */
group = uip_grpfind(dev, &grpaddr->s_addr);
+ ndbg("Leaving group: %p\n", group);
if (group)
{
/* Cancel the timer and discard any queued Membership Reports. Canceling
@@ -157,7 +158,7 @@ int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
if (IS_LASTREPORT(group->flags))
{
- ndbg("Leaving group\n");
+ ndbg("Schedul Leave Group message\n");
IGMP_STATINCR(uip_stat.igmp.leave_sched);
uip_igmpwaitmsg(group, IGMP_LEAVE_GROUP);
}
@@ -171,6 +172,8 @@ int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
uip_removemcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
return OK;
}
+
+ nvdbg("Return -ENOENT\n");
return -ENOENT;
}
diff --git a/nuttx/net/uip/uip_igmppoll.c b/nuttx/net/uip/uip_igmppoll.c
index 9cc9a4384..b31f2d82c 100755
--- a/nuttx/net/uip/uip_igmppoll.c
+++ b/nuttx/net/uip/uip_igmppoll.c
@@ -87,16 +87,18 @@ static inline void uip_schedsend(FAR struct uip_driver_s *dev, FAR struct igmp_g
if (group->msgid == IGMPv2_MEMBERSHIP_REPORT)
{
- nllvdbg("Send IGMPv2_MEMBERSHIP_REPORT\n");
dest = &group->grpaddr;
+ nllvdbg("Send IGMPv2_MEMBERSHIP_REPORT, dest=%08x flags=%02x\n",
+ *dest, group->flags);
IGMP_STATINCR(uip_stat.igmp.report_sched);
SET_LASTREPORT(group->flags); /* Remember we were the last to report */
}
else
{
- nllvdbg("Send IGMP_LEAVE_GROUP\n");
DEBUGASSERT(group->msgid == IGMP_LEAVE_GROUP);
dest = &g_allrouters;
+ nllvdbg("Send IGMP_LEAVE_GROUP, dest=%08x flags=%02x\n",
+ *dest, group->flags);
IGMP_STATINCR(uip_stat.igmp.leave_sched);
}
@@ -113,6 +115,7 @@ static inline void uip_schedsend(FAR struct uip_driver_s *dev, FAR struct igmp_g
if (IS_WAITMSG(group->flags))
{
+ nllvdbg("Awakening waiter\n");
sem_post(&group->sem);
}
}
@@ -141,6 +144,8 @@ void uip_igmppoll(FAR struct uip_driver_s *dev)
{
FAR struct igmp_group_s *group;
+ nllvdbg("Entry\n");
+
/* Setup the poll operation */
dev->d_appdata = &dev->d_buf[UIP_LLH_LEN + UIP_IPIGMPH_LEN];
diff --git a/nuttx/net/uip/uip_igmpsend.c b/nuttx/net/uip/uip_igmpsend.c
index 33b3fd2d9..c4d5b58c8 100755
--- a/nuttx/net/uip/uip_igmpsend.c
+++ b/nuttx/net/uip/uip_igmpsend.c
@@ -72,9 +72,7 @@
/* Buffer layout */
#define RASIZE (4)
-#define RA ((uint16_t*)&dev->d_buf[UIP_LLH_LEN])
-#define IGMPBUF ((struct uip_igmphdr_s *)&dev->d_buf[UIP_LLH_LEN + RASIZE])
-#define IGMPPAYLOAD (&dev->d_buf[UIP_LLH_LEN + RASIZE + UIP_IPH_LEN])
+#define IGMPBUF ((struct uip_igmphdr_s *)&dev->d_buf[UIP_LLH_LEN])
/****************************************************************************
* Public Variables
@@ -122,13 +120,13 @@ static uint16_t uip_igmpchksum(FAR uint8_t *buffer, int buflen)
void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
FAR uip_ipaddr_t *destipaddr)
{
- nllvdbg("msgid: %02x destipaddr: %08x\n", group->msgid, (int)destipaddr);
+ nllvdbg("msgid: %02x destipaddr: %08x\n", group->msgid, (int)*destipaddr);
- /* The total length to send is the size of the IP and IGMP headers and 8
+ /* The total length to send is the size of the IP and IGMP headers and 4
* bytes for the ROUTER ALERT (and, eventually, the ethernet header)
*/
- dev->d_len = UIP_IPIGMPH_LEN + RASIZE;
+ dev->d_len = UIP_IPIGMPH_LEN;
/* The total size of the data is the size of the IGMP header */
@@ -136,12 +134,12 @@ void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
/* Add the router alert option */
- RA[0] = HTONS(ROUTER_ALERT >> 16);
- RA[1] = HTONS(ROUTER_ALERT & 0xffff);
+ IGMPBUF->ra[0] = HTONS(ROUTER_ALERT >> 16);
+ IGMPBUF->ra[1] = HTONS(ROUTER_ALERT & 0xffff);
/* Initialize the IPv4 header */
- IGMPBUF->vhl = 0x45;
+ IGMPBUF->vhl = 0x46; /* 4->IP; 6->24 bytes */
IGMPBUF->tos = 0;
IGMPBUF->len[0] = (dev->d_len >> 8);
IGMPBUF->len[1] = (dev->d_len & 0xff);
@@ -159,7 +157,7 @@ void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
/* Calculate IP checksum. */
IGMPBUF->ipchksum = 0;
- IGMPBUF->ipchksum = ~uip_igmpchksum((FAR uint8_t *)RA, UIP_IPH_LEN + RASIZE);
+ IGMPBUF->ipchksum = ~uip_igmpchksum((FAR uint8_t *)IGMPBUF, UIP_IPH_LEN + RASIZE);
/* Set up the IGMP message */
@@ -170,7 +168,7 @@ void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
/* Calculate the IGMP checksum. */
IGMPBUF->chksum = 0;
- IGMPBUF->chksum = ~uip_igmpchksum(IGMPPAYLOAD, UIP_IPIGMPH_LEN);
+ IGMPBUF->chksum = ~uip_igmpchksum(&IGMPBUF->type, UIP_IPIGMPH_LEN);
IGMP_STATINCR(uip_stats.igmp.poll_send);
IGMP_STATINCR(uip_stats.ip.sent);
diff --git a/nuttx/net/uip/uip_igmptimer.c b/nuttx/net/uip/uip_igmptimer.c
index 2e2c3cbb1..216b4b4e8 100755
--- a/nuttx/net/uip/uip_igmptimer.c
+++ b/nuttx/net/uip/uip_igmptimer.c
@@ -81,7 +81,7 @@ static void uip_igmptimeout(int argc, uint32_t arg, ...)
/* If the state is DELAYING_MEMBER then we send a report for this group */
- nvdbg("Timeout!\n");
+ nllvdbg("Timeout!\n");
group = (FAR struct igmp_group_s *)arg;
DEBUGASSERT(argc == 1 && group);
diff --git a/nuttx/net/uip/uip_mcastmac.c b/nuttx/net/uip/uip_mcastmac.c
index 72927f740..ebe97f75f 100755
--- a/nuttx/net/uip/uip_mcastmac.c
+++ b/nuttx/net/uip/uip_mcastmac.c
@@ -81,7 +81,7 @@ static void uip_mcastmac(uip_ipaddr_t *ip, FAR uint8_t *mac)
mac[4] = ip4_addr3(*ip);
mac[5] = ip4_addr4(*ip);
- nvdbg("IP: %04x -> MAC: %02x%02x%02x%02x%02x%02x\n",
+ nvdbg("IP: %08x -> MAC: %02x%02x%02x%02x%02x%02x\n",
*ip, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
@@ -101,7 +101,7 @@ void uip_addmcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip)
{
uint8_t mcastmac[6];
- nvdbg("Adding: IP %04x\n");
+ nvdbg("Adding: IP %08x\n", *ip);
if (dev->d_addmac)
{
uip_mcastmac(ip, mcastmac);
@@ -121,7 +121,7 @@ void uip_removemcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip)
{
uint8_t mcastmac[6];
- nvdbg("Removing: IP %04x\n");
+ nvdbg("Removing: IP %08x\n", *ip);
if (dev->d_rmmac)
{
uip_mcastmac(ip, mcastmac);
diff --git a/nuttx/netutils/uiplib/uip_ipmsfilter.c b/nuttx/netutils/uiplib/uip_ipmsfilter.c
index 28ed2fd2d..11f15a180 100755
--- a/nuttx/netutils/uiplib/uip_ipmsfilter.c
+++ b/nuttx/netutils/uiplib/uip_ipmsfilter.c
@@ -45,6 +45,7 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include <debug.h>
#include <netinet/in.h>
#include <sys/sockio.h>
@@ -83,6 +84,8 @@ int ipmsfilter(FAR const char *ifname, FAR const struct in_addr *multiaddr,
uint32_t fmode)
{
int ret = ERROR;
+
+ nvdbg("ifname: %s muliaddr: %08x fmode: %ld\n", ifname, *multiaddr, fmode);
if (ifname && multiaddr)
{
/* Get a socket (only so that we get access to the INET subsystem) */