igmp.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2002 CITEL Technologies Ltd.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
  18. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * This file is a contribution to the lwIP TCP/IP stack.
  30. * The Swedish Institute of Computer Science and Adam Dunkels
  31. * are specifically granted permission to redistribute this
  32. * source code.
  33. */
  34. #ifndef __LWIP_IGMP_H__
  35. #define __LWIP_IGMP_H__
  36. #include "lwip/opt.h"
  37. #include "lwip/ip_addr.h"
  38. #include "lwip/netif.h"
  39. #include "lwip/pbuf.h"
  40. #if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /* IGMP timer */
  45. #define IGMP_TMR_INTERVAL 100 /* Milliseconds */
  46. #define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL)
  47. #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)
  48. /* MAC Filter Actions, these are passed to a netif's
  49. * igmp_mac_filter callback function. */
  50. #define IGMP_DEL_MAC_FILTER 0
  51. #define IGMP_ADD_MAC_FILTER 1
  52. /**
  53. * igmp group structure - there is
  54. * a list of groups for each interface
  55. * these should really be linked from the interface, but
  56. * if we keep them separate we will not affect the lwip original code
  57. * too much
  58. *
  59. * There will be a group for the all systems group address but this
  60. * will not run the state machine as it is used to kick off reports
  61. * from all the other groups
  62. */
  63. struct igmp_group {
  64. /** next link */
  65. struct igmp_group *next;
  66. /** interface on which the group is active */
  67. struct netif *netif;
  68. /** multicast address */
  69. ip_addr_t group_address;
  70. /** signifies we were the last person to report */
  71. u8_t last_reporter_flag;
  72. /** current state of the group */
  73. u8_t group_state;
  74. /** timer for reporting, negative is OFF */
  75. u16_t timer;
  76. /** counter of simultaneous uses */
  77. u8_t use;
  78. };
  79. /* Prototypes */
  80. void igmp_init(void)ICACHE_FLASH_ATTR;
  81. err_t igmp_start(struct netif *netif)ICACHE_FLASH_ATTR;
  82. err_t igmp_stop(struct netif *netif)ICACHE_FLASH_ATTR;
  83. void igmp_report_groups(struct netif *netif)ICACHE_FLASH_ATTR;
  84. struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr)ICACHE_FLASH_ATTR;
  85. void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest)ICACHE_FLASH_ATTR;
  86. err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)ICACHE_FLASH_ATTR;
  87. err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr)ICACHE_FLASH_ATTR;
  88. void igmp_tmr(void)ICACHE_FLASH_ATTR;
  89. #define LWIP_RAND() r_rand()
  90. #ifdef __cplusplus
  91. }
  92. #endif
  93. #endif /* LWIP_IGMP */
  94. #endif /* __LWIP_IGMP_H__ */