IGMP debug fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2791 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
f5cb4c9d30
commit
a3910e4b02
@ -55,6 +55,20 @@
|
|||||||
* Definitions
|
* 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
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -78,11 +78,11 @@
|
|||||||
/* Header sizes:
|
/* Header sizes:
|
||||||
*
|
*
|
||||||
* UIP_IGMPH_LEN - Size of IGMP header in bytes
|
* 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_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 */
|
/* Group flags */
|
||||||
|
|
||||||
@ -157,6 +157,10 @@ struct uip_igmphdr_s
|
|||||||
|
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
/* Router alerted IP header option */
|
||||||
|
|
||||||
|
uint16_t ra[2];
|
||||||
|
|
||||||
/* IGMP header:
|
/* IGMP header:
|
||||||
*
|
*
|
||||||
* 0 1 2 3
|
* 0 1 2 3
|
||||||
|
@ -158,6 +158,8 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd, struct ifreq *req)
|
|||||||
FAR struct uip_driver_s *dev;
|
FAR struct uip_driver_s *dev;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
|
nvdbg("cmd: %d\n", cmd);
|
||||||
|
|
||||||
/* Find the network device associated with the device name
|
/* Find the network device associated with the device name
|
||||||
* in the request data.
|
* 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;
|
FAR struct uip_driver_s *dev;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
|
||||||
|
nvdbg("cmd: %d\n", cmd);
|
||||||
|
|
||||||
/* Find the network device associated with the device name
|
/* Find the network device associated with the device name
|
||||||
* in the request data.
|
* in the request data.
|
||||||
*/
|
*/
|
||||||
|
@ -64,9 +64,6 @@
|
|||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
#include <net/uip/uip-arch.h>
|
#include <net/uip/uip-arch.h>
|
||||||
#include <net/uip/uip-arp.h>
|
#include <net/uip/uip-arp.h>
|
||||||
#ifdef CONFIG_NET_IGMP
|
|
||||||
# include <net/uip/uip-igmp.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
@ -83,11 +80,6 @@
|
|||||||
#define ARPBUF ((struct arp_hdr *)&dev->d_buf[UIP_LLH_LEN])
|
#define ARPBUF ((struct arp_hdr *)&dev->d_buf[UIP_LLH_LEN])
|
||||||
#define IPBUF ((struct ethip_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
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -298,28 +290,10 @@ void uip_arp_out(struct uip_driver_s *dev)
|
|||||||
const struct arp_entry *tabptr = NULL;
|
const struct arp_entry *tabptr = NULL;
|
||||||
struct arp_hdr *parp = ARPBUF;
|
struct arp_hdr *parp = ARPBUF;
|
||||||
struct uip_eth_hdr *peth = ETHBUF;
|
struct uip_eth_hdr *peth = ETHBUF;
|
||||||
struct ethip_hdr *pip;
|
struct ethip_hdr *pip = IPBUF;
|
||||||
in_addr_t ipaddr;
|
in_addr_t ipaddr;
|
||||||
in_addr_t destipaddr;
|
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
|
/* Find the destination IP address in the ARP table and construct
|
||||||
* the Ethernet header. If the destination IP addres isn't on the
|
* the Ethernet header. If the destination IP addres isn't on the
|
||||||
* local network, we use the default router's IP address instead.
|
* local network, we use the default router's IP address instead.
|
||||||
|
@ -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 */
|
/* 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);
|
sem_init(&group->sem, 0, 0);
|
||||||
|
|
||||||
/* Interrupts must be disabled in order to modify the group list */
|
/* 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();
|
flags = irqsave();
|
||||||
for (group = (FAR struct igmp_group_s *)dev->grplist.head; group; group = group->next)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
|
|||||||
{
|
{
|
||||||
/* No... allocate a new entry */
|
/* 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);
|
group = uip_grpalloc(dev, &grpaddr->s_addr);
|
||||||
IGMP_STATINCR(uip_stat.igmp.joins);
|
IGMP_STATINCR(uip_stat.igmp.joins);
|
||||||
|
|
||||||
|
@ -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 */
|
/* Find the entry corresponding to the address leaving the group */
|
||||||
|
|
||||||
group = uip_grpfind(dev, &grpaddr->s_addr);
|
group = uip_grpfind(dev, &grpaddr->s_addr);
|
||||||
|
ndbg("Leaving group: %p\n", group);
|
||||||
if (group)
|
if (group)
|
||||||
{
|
{
|
||||||
/* Cancel the timer and discard any queued Membership Reports. Canceling
|
/* 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))
|
if (IS_LASTREPORT(group->flags))
|
||||||
{
|
{
|
||||||
ndbg("Leaving group\n");
|
ndbg("Schedul Leave Group message\n");
|
||||||
IGMP_STATINCR(uip_stat.igmp.leave_sched);
|
IGMP_STATINCR(uip_stat.igmp.leave_sched);
|
||||||
uip_igmpwaitmsg(group, IGMP_LEAVE_GROUP);
|
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);
|
uip_removemcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvdbg("Return -ENOENT\n");
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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)
|
if (group->msgid == IGMPv2_MEMBERSHIP_REPORT)
|
||||||
{
|
{
|
||||||
nllvdbg("Send IGMPv2_MEMBERSHIP_REPORT\n");
|
|
||||||
dest = &group->grpaddr;
|
dest = &group->grpaddr;
|
||||||
|
nllvdbg("Send IGMPv2_MEMBERSHIP_REPORT, dest=%08x flags=%02x\n",
|
||||||
|
*dest, group->flags);
|
||||||
IGMP_STATINCR(uip_stat.igmp.report_sched);
|
IGMP_STATINCR(uip_stat.igmp.report_sched);
|
||||||
SET_LASTREPORT(group->flags); /* Remember we were the last to report */
|
SET_LASTREPORT(group->flags); /* Remember we were the last to report */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nllvdbg("Send IGMP_LEAVE_GROUP\n");
|
|
||||||
DEBUGASSERT(group->msgid == IGMP_LEAVE_GROUP);
|
DEBUGASSERT(group->msgid == IGMP_LEAVE_GROUP);
|
||||||
dest = &g_allrouters;
|
dest = &g_allrouters;
|
||||||
|
nllvdbg("Send IGMP_LEAVE_GROUP, dest=%08x flags=%02x\n",
|
||||||
|
*dest, group->flags);
|
||||||
IGMP_STATINCR(uip_stat.igmp.leave_sched);
|
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))
|
if (IS_WAITMSG(group->flags))
|
||||||
{
|
{
|
||||||
|
nllvdbg("Awakening waiter\n");
|
||||||
sem_post(&group->sem);
|
sem_post(&group->sem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,6 +144,8 @@ void uip_igmppoll(FAR struct uip_driver_s *dev)
|
|||||||
{
|
{
|
||||||
FAR struct igmp_group_s *group;
|
FAR struct igmp_group_s *group;
|
||||||
|
|
||||||
|
nllvdbg("Entry\n");
|
||||||
|
|
||||||
/* Setup the poll operation */
|
/* Setup the poll operation */
|
||||||
|
|
||||||
dev->d_appdata = &dev->d_buf[UIP_LLH_LEN + UIP_IPIGMPH_LEN];
|
dev->d_appdata = &dev->d_buf[UIP_LLH_LEN + UIP_IPIGMPH_LEN];
|
||||||
|
@ -72,9 +72,7 @@
|
|||||||
/* Buffer layout */
|
/* Buffer layout */
|
||||||
|
|
||||||
#define RASIZE (4)
|
#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])
|
||||||
#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])
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Variables
|
* 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,
|
void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
|
||||||
FAR uip_ipaddr_t *destipaddr)
|
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)
|
* 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 */
|
/* 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 */
|
/* Add the router alert option */
|
||||||
|
|
||||||
RA[0] = HTONS(ROUTER_ALERT >> 16);
|
IGMPBUF->ra[0] = HTONS(ROUTER_ALERT >> 16);
|
||||||
RA[1] = HTONS(ROUTER_ALERT & 0xffff);
|
IGMPBUF->ra[1] = HTONS(ROUTER_ALERT & 0xffff);
|
||||||
|
|
||||||
/* Initialize the IPv4 header */
|
/* Initialize the IPv4 header */
|
||||||
|
|
||||||
IGMPBUF->vhl = 0x45;
|
IGMPBUF->vhl = 0x46; /* 4->IP; 6->24 bytes */
|
||||||
IGMPBUF->tos = 0;
|
IGMPBUF->tos = 0;
|
||||||
IGMPBUF->len[0] = (dev->d_len >> 8);
|
IGMPBUF->len[0] = (dev->d_len >> 8);
|
||||||
IGMPBUF->len[1] = (dev->d_len & 0xff);
|
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. */
|
/* Calculate IP checksum. */
|
||||||
|
|
||||||
IGMPBUF->ipchksum = 0;
|
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 */
|
/* 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. */
|
/* Calculate the IGMP checksum. */
|
||||||
|
|
||||||
IGMPBUF->chksum = 0;
|
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.igmp.poll_send);
|
||||||
IGMP_STATINCR(uip_stats.ip.sent);
|
IGMP_STATINCR(uip_stats.ip.sent);
|
||||||
|
@ -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 */
|
/* 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;
|
group = (FAR struct igmp_group_s *)arg;
|
||||||
DEBUGASSERT(argc == 1 && group);
|
DEBUGASSERT(argc == 1 && group);
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ static void uip_mcastmac(uip_ipaddr_t *ip, FAR uint8_t *mac)
|
|||||||
mac[4] = ip4_addr3(*ip);
|
mac[4] = ip4_addr3(*ip);
|
||||||
mac[5] = ip4_addr4(*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]);
|
*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];
|
uint8_t mcastmac[6];
|
||||||
|
|
||||||
nvdbg("Adding: IP %04x\n");
|
nvdbg("Adding: IP %08x\n", *ip);
|
||||||
if (dev->d_addmac)
|
if (dev->d_addmac)
|
||||||
{
|
{
|
||||||
uip_mcastmac(ip, mcastmac);
|
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];
|
uint8_t mcastmac[6];
|
||||||
|
|
||||||
nvdbg("Removing: IP %04x\n");
|
nvdbg("Removing: IP %08x\n", *ip);
|
||||||
if (dev->d_rmmac)
|
if (dev->d_rmmac)
|
||||||
{
|
{
|
||||||
uip_mcastmac(ip, mcastmac);
|
uip_mcastmac(ip, mcastmac);
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
@ -83,6 +84,8 @@ int ipmsfilter(FAR const char *ifname, FAR const struct in_addr *multiaddr,
|
|||||||
uint32_t fmode)
|
uint32_t fmode)
|
||||||
{
|
{
|
||||||
int ret = ERROR;
|
int ret = ERROR;
|
||||||
|
|
||||||
|
nvdbg("ifname: %s muliaddr: %08x fmode: %ld\n", ifname, *multiaddr, fmode);
|
||||||
if (ifname && multiaddr)
|
if (ifname && multiaddr)
|
||||||
{
|
{
|
||||||
/* Get a socket (only so that we get access to the INET subsystem) */
|
/* Get a socket (only so that we get access to the INET subsystem) */
|
||||||
|
Loading…
Reference in New Issue
Block a user