Пример #1
0
FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev,
                                          FAR const uip_ipaddr_t *addr)
{
  FAR struct igmp_group_s *group = uip_grpfind(dev, addr);

  grplldbg("group: %p addr: %08x\n", group, (int)*addr);
  if (!group)
    {
      group = uip_grpalloc(dev, addr);
    }
  grplldbg("group: %p\n", group);
  return group;
}
Пример #2
0
int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
{
  struct igmp_group_s *group;

  DEBUGASSERT(dev && grpaddr);

  /* Check if a this address is already in the group */
 
  group = uip_grpfind(dev, &grpaddr->s_addr);
  if (!group)
    {
       /* No... allocate a new entry */
 
       nvdbg("Join to new group: %08x\n", grpaddr->s_addr);
       group = uip_grpalloc(dev, &grpaddr->s_addr);
       IGMP_STATINCR(uip_stat.igmp.joins);

       /* Send the Membership Report */
 
       IGMP_STATINCR(uip_stat.igmp.report_sched);
       uip_igmpwaitmsg(group, IGMPv2_MEMBERSHIP_REPORT);

       /* And start the timer at 10*100 msec */

       uip_igmpstarttimer(group, 10);

       /* Add the group (MAC) address to the ether drivers MAC filter list */

       uip_addmcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
       return OK;
    }

  /* Return EEXIST if the address is already a member of the group */

  return -EEXIST;
}