igmp_initialize.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /****************************************************************************
  2. * net/igmp/igmp_initialize.c
  3. * IGMP initialization logic
  4. *
  5. * Copyright (C) 2010, 2014 Gregory Nutt. All rights reserved.
  6. * Author: Gregory Nutt <gnutt@nuttx.org>
  7. *
  8. * The NuttX implementation of IGMP was inspired by the IGMP add-on for the
  9. * lwIP TCP/IP stack by Steve Reynolds:
  10. *
  11. * Copyright (c) 2002 CITEL Technologies Ltd.
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. *
  18. * 1. Redistributions of source code must retain the above copyright
  19. * notice, this list of conditions and the following disclaimer.
  20. * 2. Redistributions in binary form must reproduce the above copyright
  21. * notice, this list of conditions and the following disclaimer in the
  22. * documentation and/or other materials provided with the distribution.
  23. * 3. Neither the name of CITEL Technologies Ltd nor the names of its
  24. * contributors may be used to endorse or promote products derived from
  25. * this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
  28. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30. * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE
  31. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  32. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  33. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  35. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  36. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37. * POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. ****************************************************************************/
  40. /****************************************************************************
  41. * Included Files
  42. ****************************************************************************/
  43. #include <nuttx/config.h>
  44. #include <assert.h>
  45. #include <debug.h>
  46. #include <nuttx/net/ip.h>
  47. #include <nuttx/net/igmp.h>
  48. #include "devif/devif.h"
  49. #include "igmp/igmp.h"
  50. #ifdef CONFIG_NET_IGMP
  51. /****************************************************************************
  52. * Public Data
  53. ****************************************************************************/
  54. in_addr_t g_ipv4_allsystems;
  55. in_addr_t g_ipv4_allrouters;
  56. /****************************************************************************
  57. * Public Functions
  58. ****************************************************************************/
  59. /****************************************************************************
  60. * Name: igmp_initialize
  61. *
  62. * Description:
  63. * Perform one-time IGMP initialization.
  64. *
  65. ****************************************************************************/
  66. void igmp_initialize(void)
  67. {
  68. ninfo("IGMP initializing\n");
  69. net_ipaddr(g_ipv4_allrouters, 224, 0, 0, 2);
  70. net_ipaddr(g_ipv4_allsystems, 224, 0, 0, 1);
  71. }
  72. /****************************************************************************
  73. * Name: igmp_devinit
  74. *
  75. * Description:
  76. * Called when a new network device is registered to configure that device
  77. * for IGMP support.
  78. *
  79. ****************************************************************************/
  80. void igmp_devinit(struct net_driver_s *dev)
  81. {
  82. ninfo("IGMP initializing dev %p\n", dev);
  83. DEBUGASSERT(dev->d_igmp_grplist.head == NULL);
  84. /* Add the all systems address to the group */
  85. igmp_grpalloc(dev, &g_ipv4_allsystems);
  86. /* Allow the IGMP messages at the MAC level */
  87. igmp_addmcastmac(dev, &g_ipv4_allrouters);
  88. igmp_addmcastmac(dev, &g_ipv4_allsystems);
  89. }
  90. #endif /* CONFIG_NET_IGMP */