igmp_host.h
Go to the documentation of this file.
1 /**
2  * @file igmp_host.h
3  * @brief IGMP host
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_HOST_H
32 #define _IGMP_HOST_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "igmp/igmp_common.h"
37 
38 //IGMP host support
39 #ifndef IGMP_HOST_SUPPORT
40  #define IGMP_HOST_SUPPORT ENABLED
41 #elif (IGMP_HOST_SUPPORT != ENABLED && IGMP_HOST_SUPPORT != DISABLED)
42  #error IGMP_HOST_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 {
62 
63 
64 /**
65  * @brief Source address
66  **/
67 
68 typedef struct
69 {
70  Ipv4Addr addr; ///<Source address
71  uint_t retransmitCount; ///<Retransmission counter
73 
74 
75 /**
76  * @brief Source address list
77  **/
78 
79 typedef struct
80 {
81  uint_t numSources; ///<Number of source address
82 #if (IPV4_MAX_MULTICAST_SOURCES > 0)
83  IgmpHostSrcAddr sources[IPV4_MAX_MULTICAST_SOURCES]; ///<List of source addresses
84 #endif
86 
87 
88 /**
89  * @brief Multicast group
90  **/
91 
92 typedef struct
93 {
94  IgmpHostGroupState state; ///<Multicast group state
95  Ipv4Addr addr; ///<Multicast group address
96  bool_t flag; ///<We are the last host to send a report for this group
97  uint_t retransmitCount; ///<Filter mode retransmission counter
98  NetTimer timer; ///<Report delay timer
99  IpFilterMode filterMode; ///<Filter mode
100  Ipv4SrcAddrList filter; ///<Current-state record
101 #if (IPV4_MAX_MULTICAST_SOURCES > 0)
102  IgmpHostSrcAddrList allow; ///<ALLOW group record
103  IgmpHostSrcAddrList block; ///<BLOCK group record
104  Ipv4SrcAddrList queriedSources; ///<List of sources to be reported
105 #endif
106 } IgmpHostGroup;
107 
108 
109 /**
110  * @brief IGMP host context
111  **/
112 
113 typedef struct
114 {
115  NetInterface *interface; ///<Underlying network interface
116  IgmpVersion compatibilityMode; ///<Host compatibility mode
117  NetTimer igmpv1QuerierPresentTimer; ///<IGMPv1 querier present timer
118  NetTimer igmpv2QuerierPresentTimer; ///<IGMPv2 querier present timer
119  NetTimer generalQueryTimer; ///<Timer for scheduling responses to general queries
120  NetTimer stateChangeReportTimer; ///<Retransmission timer for state-change reports
121  IgmpHostGroup groups[IPV4_MULTICAST_FILTER_SIZE]; ///<Multicast groups
123 
124 
125 //IGMP host related functions
126 error_t igmpHostInit(NetInterface *interface);
127 void igmpHostTick(IgmpHostContext *context);
128 
130  IpFilterMode newFilterMode, const Ipv4SrcAddrList *newFilter);
131 
133 
134 //C++ guard
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif
Ipv4Addr addr
Source address.
Definition: igmp_host.h:70
Multicast group.
Definition: igmp_host.h:93
uint16_t block
Definition: tftp_common.h:115
IpFilterMode
Multicast filter mode.
Definition: ip.h:67
int bool_t
Definition: compiler_port.h:53
Source address list.
Definition: ipv4.h:399
IgmpHostGroupState state
Multicast group state.
Definition: igmp_host.h:94
IgmpVersion
IGMP versions.
Definition: igmp_common.h:161
NetInterface * interface
Underlying network interface.
Definition: igmp_host.h:115
void igmpHostStateChangeEvent(IgmpHostContext *context, Ipv4Addr groupAddr, IpFilterMode newFilterMode, const Ipv4SrcAddrList *newFilter)
Process multicast reception state change.
Definition: igmp_host.c:346
error_t igmpHostInit(NetInterface *interface)
IGMP host initialization.
Definition: igmp_host.c:61
#define IPV4_MAX_MULTICAST_SOURCES
Definition: ipv4.h:90
IgmpHostGroupState
Multicast group states.
Definition: igmp_host.h:56
uint32_t Ipv4Addr
IPv4 network address.
Definition: ipv4.h:297
Source address list.
Definition: igmp_host.h:80
NetTimer stateChangeReportTimer
Retransmission timer for state-change reports.
Definition: igmp_host.h:120
Source address.
Definition: igmp_host.h:69
IpFilterMode filterMode
Filter mode.
Definition: igmp_host.h:99
IGMP host context.
Definition: igmp_host.h:114
error_t
Error codes.
Definition: error.h:43
@ IGMP_HOST_GROUP_STATE_DELAYING_MEMBER
Definition: igmp_host.h:59
Timer.
Definition: net_misc.h:175
void igmpHostTick(IgmpHostContext *context)
IGMP host timer handler.
Definition: igmp_host.c:102
#define NetInterface
Definition: net.h:36
Ipv4Addr addr
Multicast group address.
Definition: igmp_host.h:95
uint_t retransmitCount
Retransmission counter.
Definition: igmp_host.h:71
@ IGMP_HOST_GROUP_STATE_NON_MEMBER
Definition: igmp_host.h:57
uint_t numSources
Number of source address.
Definition: igmp_host.h:81
NetTimer generalQueryTimer
Timer for scheduling responses to general queries.
Definition: igmp_host.h:119
NetTimer igmpv2QuerierPresentTimer
IGMPv2 querier present timer.
Definition: igmp_host.h:118
bool_t flag
We are the last host to send a report for this group.
Definition: igmp_host.h:96
Ipv4Addr groupAddr
Definition: igmp_common.h:214
NetTimer igmpv1QuerierPresentTimer
IGMPv1 querier present timer.
Definition: igmp_host.h:117
NetTimer timer
Report delay timer.
Definition: igmp_host.h:98
@ IGMP_HOST_GROUP_STATE_INIT_MEMBER
Definition: igmp_host.h:58
IgmpVersion compatibilityMode
Host compatibility mode.
Definition: igmp_host.h:116
void igmpHostLinkChangeEvent(IgmpHostContext *context)
Process link state change.
Definition: igmp_host.c:489
uint_t retransmitCount
Filter mode retransmission counter.
Definition: igmp_host.h:97
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
Definitions common to IGMP host, router and snooping switch.
@ IGMP_HOST_GROUP_STATE_IDLE_MEMBER
Definition: igmp_host.h:60
Ipv4SrcAddrList filter
Current-state record.
Definition: igmp_host.h:100
#define IPV4_MULTICAST_FILTER_SIZE
Definition: ipv4.h:83