igmp_router.h
Go to the documentation of this file.
1 /**
2  * @file igmp_router.h
3  * @brief IGMP router
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _IGMP_ROUTER_H
32 #define _IGMP_ROUTER_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "igmp/igmp_common.h"
37 
38 //IGMP router support
39 #ifndef IGMP_ROUTER_SUPPORT
40  #define IGMP_ROUTER_SUPPORT DISABLED
41 #elif (IGMP_ROUTER_SUPPORT != ENABLED && IGMP_ROUTER_SUPPORT != DISABLED)
42  #error IGMP_ROUTER_SUPPORT parameter is not valid
43 #endif
44 
45 //Forward declaration of DhcpClientContext structure
46 struct _IgmpRouterContext;
47 #define IgmpRouterContext struct _IgmpRouterContext
48 
49 //C++ guard
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 
55 /**
56  * @brief IGMP router states
57  **/
58 
59 typedef enum
60 {
65 
66 
67 /**
68  * @brief Multicast group states
69  **/
70 
71 typedef enum
72 {
78 
79 
80 /**
81  * @brief Add multicast route callback
82  **/
83 
86 
87 
88 /**
89  * @brief Delete multicast route callback
90  **/
91 
94 
95 
96 /**
97  * @brief Multicast group
98  **/
99 
100 typedef struct
101 {
102  IgmpRouterGroupState state; ///<Multicast group state
103  Ipv4Addr addr; ///<Multicast group address
104  uint_t lastMemberQueryCount; ///<Number of Group-Specific Queries to be sent
105  NetTimer timer; ///<Timer for the group membership
106  NetTimer v1HostTimer; ///<IGMPv1 Host timer
107  NetTimer retransmitTimer; ///<Retransmit timer for the group membership
109 
110 
111 /**
112  * @brief IGMP router settings
113  **/
114 
115 typedef struct
116 {
117  NetInterface *interface; ///<Underlying network interface
118  IgmpVersion version; ///<IGMP version
119  uint_t numGroups; ///<Maximum number of multicast groups
120  IgmpRouterGroup *groups; ///<Multicast groups
121  IgmpRouterAddMcastRouteCallback addMcastRouteCallback; ///<Add multicast route callback
124 
125 
126 /**
127  * @brief IGMP router context
128  **/
129 
131 {
132  NetInterface *interface; ///<The primary interface on an attached network
133  IgmpVersion version; ///<IGMP version
134  uint_t numGroups; ///<Maximum number of multicast groups
135  IgmpRouterGroup *groups; ///<Multicast groups
136  IgmpRouterAddMcastRouteCallback addMcastRouteCallback; ///<Add multicast route callback
138  bool_t running; ///<IGMP router operation state
139  IgmpRouterState state; ///<IGMP router state
140  uint_t startupQueryCount; ///<Number of General Queries to be sent on startup
141  NetTimer generalQueryTimer; ///<General Query timer
142  NetTimer otherQuerierPresentTimer; ///<Other Querier Present timer
143 };
144 
145 
146 //IGMP router related functions
148 
150  const IgmpRouterSettings *settings);
151 
154 
155 void igmpRouterTick(IgmpRouterContext *context);
156 void igmpRouterFsm(IgmpRouterContext *context);
158 
159 //C++ guard
160 #ifdef __cplusplus
161 }
162 #endif
163 
164 #endif
IgmpRouterGroupState
Multicast group states.
Definition: igmp_router.h:72
uint_t startupQueryCount
Number of General Queries to be sent on startup.
Definition: igmp_router.h:140
IgmpVersion version
IGMP version.
Definition: igmp_router.h:118
void igmpRouterFsm(IgmpRouterContext *context)
IGMP router state machine.
Definition: igmp_router.c:245
@ IGMP_ROUTER_GROUP_STATE_NO_MEMBERS_PRESENT
Definition: igmp_router.h:73
IGMP router context.
Definition: igmp_router.h:131
int bool_t
Definition: compiler_port.h:53
IgmpVersion
IGMP versions.
Definition: igmp_common.h:161
Ipv4Addr addr
Multicast group address.
Definition: igmp_router.h:103
void(* IgmpRouterDeleteMcastRouteCallback)(IgmpRouterContext *context, Ipv4Addr groupAddr, NetInterface *interface)
Delete multicast route callback.
Definition: igmp_router.h:92
IGMP router settings.
Definition: igmp_router.h:116
uint_t lastMemberQueryCount
Number of Group-Specific Queries to be sent.
Definition: igmp_router.h:104
@ IGMP_ROUTER_GROUP_STATE_MEMBERS_PRESENT
Definition: igmp_router.h:74
@ IGMP_ROUTER_GROUP_STATE_CHECKING_MEMBERSHIP
Definition: igmp_router.h:76
IgmpVersion version
IGMP version.
Definition: igmp_router.h:133
uint_t numGroups
Maximum number of multicast groups.
Definition: igmp_router.h:119
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:297
@ IGMP_ROUTER_GROUP_STATE_V1_MEMBERS_PRESENT
Definition: igmp_router.h:75
IgmpRouterState
IGMP router states.
Definition: igmp_router.h:60
IgmpRouterDeleteMcastRouteCallback deleteMcastRouteCallback
Delete multicast route callback.
Definition: igmp_router.h:122
void(* IgmpRouterAddMcastRouteCallback)(IgmpRouterContext *context, Ipv4Addr groupAddr, NetInterface *interface)
Add multicast route callback.
Definition: igmp_router.h:84
void igmpRouterTick(IgmpRouterContext *context)
IGMP router timer handler.
Definition: igmp_router.c:220
@ IGMP_ROUTER_STATE_QUERIER
Definition: igmp_router.h:62
error_t
Error codes.
Definition: error.h:43
bool_t running
IGMP router operation state.
Definition: igmp_router.h:138
IgmpRouterState state
IGMP router state.
Definition: igmp_router.h:139
NetTimer retransmitTimer
Retransmit timer for the group membership.
Definition: igmp_router.h:107
NetInterface * interface
Underlying network interface.
Definition: igmp_router.h:117
Timer.
Definition: net_misc.h:175
NetTimer generalQueryTimer
General Query timer.
Definition: igmp_router.h:141
#define NetInterface
Definition: net.h:36
@ IGMP_ROUTER_STATE_INIT
Definition: igmp_router.h:61
IgmpRouterGroupState state
Multicast group state.
Definition: igmp_router.h:102
IgmpRouterGroup * groups
Multicast groups.
Definition: igmp_router.h:120
IgmpRouterDeleteMcastRouteCallback deleteMcastRouteCallback
Delete multicast route callback.
Definition: igmp_router.h:137
error_t igmpRouterStart(IgmpRouterContext *context)
Start IGMP router.
Definition: igmp_router.c:149
NetTimer v1HostTimer
IGMPv1 Host timer.
Definition: igmp_router.h:106
NetTimer timer
Timer for the group membership.
Definition: igmp_router.h:105
IgmpRouterGroup * groups
Multicast groups.
Definition: igmp_router.h:135
@ IGMP_ROUTER_STATE_NON_QUERIER
Definition: igmp_router.h:63
void igmpRouterGetDefaultSettings(IgmpRouterSettings *settings)
Initialize settings with default values.
Definition: igmp_router.c:58
NetTimer otherQuerierPresentTimer
Other Querier Present timer.
Definition: igmp_router.h:142
Ipv4Addr groupAddr
Definition: igmp_common.h:214
error_t igmpRouterInit(IgmpRouterContext *context, const IgmpRouterSettings *settings)
IGMP router initialization.
Definition: igmp_router.c:87
error_t igmpRouterStop(IgmpRouterContext *context)
Stop IGMP router.
Definition: igmp_router.c:183
NetInterface * interface
The primary interface on an attached network.
Definition: igmp_router.h:132
#define IgmpRouterContext
Definition: igmp_router.h:47
IgmpRouterAddMcastRouteCallback addMcastRouteCallback
Add multicast route callback.
Definition: igmp_router.h:136
uint_t numGroups
Maximum number of multicast groups.
Definition: igmp_router.h:134
IgmpRouterAddMcastRouteCallback addMcastRouteCallback
Add multicast route callback.
Definition: igmp_router.h:121
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
Multicast group.
Definition: igmp_router.h:101
void igmpRouterGroupFsm(IgmpRouterContext *context, IgmpRouterGroup *group)
IGMP group state machine.
Definition: igmp_router.c:316
Definitions common to IGMP host, router and snooping switch.