igmp_snooping.h
Go to the documentation of this file.
1 /**
2  * @file igmp_snooping.h
3  * @brief IGMP snooping switch
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.0
29  **/
30 
31 #ifndef _IGMP_SNOOPING_H
32 #define _IGMP_SNOOPING_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "igmp/igmp_common.h"
37 
38 //IGMP snooping support
39 #ifndef IGMP_SNOOPING_SUPPORT
40  #define IGMP_SNOOPING_SUPPORT DISABLED
41 #elif (IGMP_SNOOPING_SUPPORT != ENABLED && IGMP_SNOOPING_SUPPORT != DISABLED)
42  #error IGMP_SNOOPING_SUPPORT parameter is not valid
43 #endif
44 
45 //C++ guard
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 
51 /**
52  * @brief Multicast group states
53  **/
54 
55 typedef enum
56 {
61 
62 
63 /**
64  * @brief Snooping switch port
65  **/
66 
67 typedef struct
68 {
72 
73 
74 /**
75  * @brief Multicast group
76  **/
77 
78 typedef struct
79 {
80  IgmpSnoopingGroupState state; ///<Multicast group state
81  Ipv4Addr addr; ///<Multicast group address
82  uint8_t port;
85 
86 
87 /**
88  * @brief IGMP snooping settings
89  **/
90 
91 typedef struct
92 {
93  NetInterface *interface; ///<Underlying network interface
94  uint_t numPorts; ///<Number of ports
95  IgmpSnoopingPort *ports; ///<Ports
96  uint_t numGroups; ///<Maximum number of multicast groups
97  IgmpSnoopingGroup *groups; ///<Multicast groups
98  bool_t floodReports; ///<Flood IGMP report messages to all ports (not only to router ports)
99  bool_t floodUnknownMulticastPackets; ///<Flood unregistered multicast traffic to all ports
100  systime_t lastMemberQueryTime; ///<Leave latency
102 
103 
104 /**
105  * @brief IGMP snooping switch context
106  **/
107 
108 typedef struct
109 {
111  NetInterface *interface; ///<The primary interface on an attached network
112  uint_t numPorts; ///<Number of ports
114  uint_t numGroups; ///<Maximum number of multicast groups
115  IgmpSnoopingGroup *groups; ///<Multicast groups
116  bool_t floodReports; ///<Flood IGMP report messages to all ports (not only to router ports)
117  bool_t floodUnknownMulticastPackets; ///<Flood unregistered multicast traffic to all ports
118  systime_t lastMemberQueryTime; ///<Leave latency
120 
121 
122 //IGMP snooping related functions
124 
126  const IgmpSnoopingSettings *settings);
127 
130 
132 
133 //C++ guard
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif
unsigned int uint_t
Definition: compiler_port.h:50
int bool_t
Definition: compiler_port.h:53
error_t
Error codes.
Definition: error.h:43
Definitions common to IGMP host, router and snooping switch.
IgmpSnoopingGroupState
Multicast group states.
Definition: igmp_snooping.h:56
@ IGMP_SNOOPING_GROUP_STATE_MEMBERS_PRESENT
Definition: igmp_snooping.h:58
@ IGMP_SNOOPING_GROUP_STATE_NO_MEMBERS_PRESENT
Definition: igmp_snooping.h:57
@ IGMP_SNOOPING_GROUP_STATE_CHECKING_MEMBERSHIP
Definition: igmp_snooping.h:59
void igmpSnoopingTick(IgmpSnoopingContext *context)
IGMP snooping switch timer handler.
void igmpSnoopingGetDefaultSettings(IgmpSnoopingSettings *settings)
Initialize settings with default values.
Definition: igmp_snooping.c:62
error_t igmpSnoopingStop(IgmpSnoopingContext *context)
Stop IGMP snooping switch.
error_t igmpSnoopingInit(IgmpSnoopingContext *context, const IgmpSnoopingSettings *settings)
IGMP snooping switch initialization.
Definition: igmp_snooping.c:94
error_t igmpSnoopingStart(IgmpSnoopingContext *context)
Start IGMP snooping switch.
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:267
TCP/IP stack core.
#define NetInterface
Definition: net.h:36
uint32_t systime_t
System time.
IGMP snooping switch context.
IgmpSnoopingGroup * groups
Multicast groups.
systime_t lastMemberQueryTime
Leave latency.
uint_t numPorts
Number of ports.
bool_t floodReports
Flood IGMP report messages to all ports (not only to router ports)
IgmpSnoopingPort * ports
Ports.
uint_t numGroups
Maximum number of multicast groups.
bool_t floodUnknownMulticastPackets
Flood unregistered multicast traffic to all ports.
NetInterface * interface
The primary interface on an attached network.
Multicast group.
Definition: igmp_snooping.h:79
Ipv4Addr addr
Multicast group address.
Definition: igmp_snooping.h:81
IgmpSnoopingGroupState state
Multicast group state.
Definition: igmp_snooping.h:80
Snooping switch port.
Definition: igmp_snooping.h:68
IGMP snooping settings.
Definition: igmp_snooping.h:92
IgmpSnoopingGroup * groups
Multicast groups.
Definition: igmp_snooping.h:97
systime_t lastMemberQueryTime
Leave latency.
uint_t numPorts
Number of ports.
Definition: igmp_snooping.h:94
bool_t floodReports
Flood IGMP report messages to all ports (not only to router ports)
Definition: igmp_snooping.h:98
IgmpSnoopingPort * ports
Ports.
Definition: igmp_snooping.h:95
uint_t numGroups
Maximum number of multicast groups.
Definition: igmp_snooping.h:96
bool_t floodUnknownMulticastPackets
Flood unregistered multicast traffic to all ports.
Definition: igmp_snooping.h:99
NetInterface * interface
Underlying network interface.
Definition: igmp_snooping.h:93
Timer.
Definition: net_misc.h:172