]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/Common/ethernet/lwIP_130/src/include/ipv4/lwip/igmp.h
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / Common / ethernet / lwIP_130 / src / include / ipv4 / lwip / igmp.h
1 /*\r
2  * Copyright (c) 2002 CITEL Technologies Ltd.\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  * 1. Redistributions of source code must retain the above copyright\r
9  *    notice, this list of conditions and the following disclaimer.\r
10  * 2. Redistributions in binary form must reproduce the above copyright\r
11  *    notice, this list of conditions and the following disclaimer in the\r
12  *    documentation and/or other materials provided with the distribution.\r
13  * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors\r
14  *    may be used to endorse or promote products derived from this software\r
15  *    without specific prior written permission.\r
16  *\r
17  * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''\r
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
20  * ARE DISCLAIMED.  IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE\r
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
27  * SUCH DAMAGE.\r
28  *\r
29  * This file is a contribution to the lwIP TCP/IP stack.\r
30  * The Swedish Institute of Computer Science and Adam Dunkels\r
31  * are specifically granted permission to redistribute this\r
32  * source code.\r
33 */\r
34 \r
35 #ifndef __LWIP_IGMP_H__\r
36 #define __LWIP_IGMP_H__\r
37 \r
38 #include "lwip/opt.h"\r
39 #include "lwip/ip_addr.h"\r
40 #include "lwip/netif.h"\r
41 #include "lwip/pbuf.h"\r
42 \r
43 #if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */\r
44 \r
45 #ifdef __cplusplus\r
46 extern "C" {\r
47 #endif\r
48 \r
49 /*\r
50  * IGMP constants\r
51  */\r
52 #define IP_PROTO_IGMP                  2\r
53 #define IGMP_TTL                       1\r
54 #define IGMP_MINLEN                    8\r
55 #define ROUTER_ALERT                   0x9404\r
56 #define ROUTER_ALERTLEN                4\r
57 \r
58 /*\r
59  * IGMP message types, including version number.\r
60  */\r
61 #define IGMP_MEMB_QUERY                0x11 /* Membership query         */\r
62 #define IGMP_V1_MEMB_REPORT            0x12 /* Ver. 1 membership report */\r
63 #define IGMP_V2_MEMB_REPORT            0x16 /* Ver. 2 membership report */\r
64 #define IGMP_LEAVE_GROUP               0x17 /* Leave-group message      */\r
65 \r
66 /* IGMP timer */\r
67 #define IGMP_TMR_INTERVAL              100 /* Milliseconds */\r
68 #define IGMP_V1_DELAYING_MEMBER_TMR   (1000/IGMP_TMR_INTERVAL)\r
69 #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)\r
70 \r
71 /* MAC Filter Actions */\r
72 #define IGMP_DEL_MAC_FILTER            0\r
73 #define IGMP_ADD_MAC_FILTER            1\r
74 \r
75 /* Group  membership states */\r
76 #define IGMP_GROUP_NON_MEMBER          0\r
77 #define IGMP_GROUP_DELAYING_MEMBER     1\r
78 #define IGMP_GROUP_IDLE_MEMBER         2\r
79 \r
80 /*\r
81  * IGMP packet format.\r
82  */\r
83 #ifdef PACK_STRUCT_USE_INCLUDES\r
84 #  include "arch/bpstruct.h"\r
85 #endif\r
86 PACK_STRUCT_BEGIN\r
87 #if (defined(__MWERKS__)  || defined(__CWCC__))\r
88         #pragma options align= packed\r
89 #endif\r
90 struct igmp_msg {\r
91  PACK_STRUCT_FIELD(u8_t           igmp_msgtype);\r
92  PACK_STRUCT_FIELD(u8_t           igmp_maxresp);\r
93  PACK_STRUCT_FIELD(u16_t          igmp_checksum);\r
94  PACK_STRUCT_FIELD(struct ip_addr igmp_group_address);\r
95 } PACK_STRUCT_STRUCT;\r
96 PACK_STRUCT_END\r
97 #ifdef PACK_STRUCT_USE_INCLUDES\r
98 #  include "arch/epstruct.h"\r
99 #endif\r
100 \r
101 /*\r
102  * now a group structure - there is\r
103  * a list of groups for each interface\r
104  * these should really be linked from the interface, but\r
105  * if we keep them separate we will not affect the lwip original code\r
106  * too much\r
107  *\r
108  * There will be a group for the all systems group address but this\r
109  * will not run the state machine as it is used to kick off reports\r
110  * from all the other groups\r
111  */\r
112 \r
113 struct igmp_group {\r
114   struct igmp_group *next;\r
115   struct netif      *interface;\r
116   struct ip_addr     group_address;\r
117   u8_t               last_reporter_flag; /* signifies we were the last person to report */\r
118   u8_t               group_state;\r
119   u16_t              timer;\r
120   u8_t               use; /* counter of simultaneous uses */\r
121 };\r
122 \r
123 \r
124 /*  Prototypes */\r
125 void   igmp_init(void);\r
126 \r
127 err_t  igmp_start( struct netif *netif);\r
128 \r
129 err_t  igmp_stop( struct netif *netif);\r
130 \r
131 void   igmp_report_groups( struct netif *netif);\r
132 \r
133 struct igmp_group *igmp_lookfor_group( struct netif *ifp, struct ip_addr *addr);\r
134 \r
135 struct igmp_group *igmp_lookup_group( struct netif *ifp, struct ip_addr *addr);\r
136 \r
137 err_t  igmp_remove_group( struct igmp_group *group);\r
138 \r
139 void   igmp_input( struct pbuf *p, struct netif *inp, struct ip_addr *dest);\r
140 \r
141 err_t  igmp_joingroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);\r
142 \r
143 err_t  igmp_leavegroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);\r
144 \r
145 void   igmp_tmr(void);\r
146 \r
147 void   igmp_timeout( struct igmp_group *group);\r
148 \r
149 void   igmp_start_timer( struct igmp_group *group, u8_t max_time);\r
150 \r
151 void   igmp_stop_timer( struct igmp_group *group);\r
152 \r
153 void   igmp_delaying_member( struct igmp_group *group, u8_t maxresp);\r
154 \r
155 err_t  igmp_ip_output_if( struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t proto, struct netif *netif);\r
156 \r
157 void   igmp_send( struct igmp_group *group, u8_t type);\r
158 \r
159 #ifdef __cplusplus\r
160 }\r
161 #endif\r
162 \r
163 #endif /* LWIP_IGMP */\r
164 \r
165 #endif /* __LWIP_IGMP_H__ */\r