From 7569e53f92cc6c313c8642a8cc53dfacea63382b Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 13 Jul 2010 03:43:06 +0000 Subject: IGMP debug fixes git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2791 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/net/netdev_ioctl.c | 4 ++++ nuttx/net/uip/uip_arp.c | 28 +--------------------------- nuttx/net/uip/uip_igmpgroup.c | 4 ++-- nuttx/net/uip/uip_igmpjoin.c | 2 +- nuttx/net/uip/uip_igmpleave.c | 5 ++++- nuttx/net/uip/uip_igmppoll.c | 9 +++++++-- nuttx/net/uip/uip_igmpsend.c | 20 +++++++++----------- nuttx/net/uip/uip_igmptimer.c | 2 +- nuttx/net/uip/uip_mcastmac.c | 6 +++--- 9 files changed, 32 insertions(+), 48 deletions(-) (limited to 'nuttx/net') 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 #include #include -#ifdef CONFIG_NET_IGMP -# include -#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); -- cgit v1.2.3