mld_node.h
Go to the documentation of this file.
1 /**
2  * @file mld_node.h
3  * @brief MLD node (Multicast Listener Discovery for IPv6)
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 _MLD_NODE_H
32 #define _MLD_NODE_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "mld/mld_common.h"
37 
38 //MLD node support
39 #ifndef MLD_NODE_SUPPORT
40  #define MLD_NODE_SUPPORT DISABLED
41 #elif (MLD_NODE_SUPPORT != ENABLED && MLD_NODE_SUPPORT != DISABLED)
42  #error MLD_NODE_SUPPORT parameter is not valid
43 #endif
44 
45 //C++ guard
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 
51 /**
52  * @brief MLD node group states
53  **/
54 
55 typedef enum
56 {
62 
63 
64 /**
65  * @brief Source address
66  **/
67 
68 typedef struct
69 {
70  Ipv6Addr 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 (IPV6_MAX_MULTICAST_SOURCES > 0)
83  MldNodeSrcAddr sources[IPV6_MAX_MULTICAST_SOURCES]; ///<List of source addresses
84 #endif
86 
87 
88 /**
89  * @brief Multicast group
90  **/
91 
92 typedef struct
93 {
94  MldNodeGroupState state; ///<Multicast group state
95  Ipv6Addr 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  Ipv6SrcAddrList filter; ///<Current-state record
101 #if (IPV6_MAX_MULTICAST_SOURCES > 0)
102  MldNodeSrcAddrList allow; ///<ALLOW group record
103  MldNodeSrcAddrList block; ///<BLOCK group record
104  Ipv6SrcAddrList queriedSources; ///<List of sources to be reported
105 #endif
106 } MldNodeGroup;
107 
108 
109 /**
110  * @brief MLD node context
111  **/
112 
113 typedef struct
114 {
115  NetInterface *interface; ///<Underlying network interface
116  MldVersion compatibilityMode; ///<Host compatibility mode
117  NetTimer olderVersionQuerierPresentTimer; ///<Older version querier present timer
118  NetTimer generalQueryTimer; ///<Timer for scheduling responses to general queries
119  NetTimer stateChangeReportTimer; ///<Retransmission timer for state-change reports
120  MldNodeGroup groups[IPV6_MULTICAST_FILTER_SIZE]; ///<Multicast groups
122 
123 
124 //MLD node related functions
125 error_t mldNodeInit(NetInterface *interface);
126 void mldNodeTick(MldNodeContext *context);
127 
129  IpFilterMode newFilterMode, const Ipv6SrcAddrList *newFilter);
130 
132 
133 //C++ guard
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif
uint_t numSources
Number of source address.
Definition: mld_node.h:81
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: ipv6.h:469
NetTimer stateChangeReportTimer
Retransmission timer for state-change reports.
Definition: mld_node.h:119
void mldNodeStateChangeEvent(MldNodeContext *context, const Ipv6Addr *groupAddr, IpFilterMode newFilterMode, const Ipv6SrcAddrList *newFilter)
Process multicast reception state change.
Definition: mld_node.c:306
Ipv6SrcAddrList filter
Current-state record.
Definition: mld_node.h:100
bool_t flag
We are the last host to send a report for this group.
Definition: mld_node.h:96
NetTimer timer
Report delay timer.
Definition: mld_node.h:98
error_t mldNodeInit(NetInterface *interface)
MLD node initialization.
Definition: mld_node.c:53
Ipv6Addr
Definition: ipv6.h:260
@ MLD_NODE_GROUP_STATE_DELAYING_LISTENER
Definition: mld_node.h:59
MLD node context.
Definition: mld_node.h:114
MldVersion compatibilityMode
Host compatibility mode.
Definition: mld_node.h:116
MldNodeGroupState
MLD node group states.
Definition: mld_node.h:56
uint_t retransmitCount
Retransmission counter.
Definition: mld_node.h:71
error_t
Error codes.
Definition: error.h:43
Definitions common to MLD node, router and snooping switch.
Ipv6Addr addr
Source address.
Definition: mld_node.h:70
IpFilterMode filterMode
Filter mode.
Definition: mld_node.h:99
Timer.
Definition: net_misc.h:175
#define IPV6_MAX_MULTICAST_SOURCES
Definition: ipv6.h:107
Source address.
Definition: mld_node.h:69
#define NetInterface
Definition: net.h:36
void mldNodeLinkChangeEvent(MldNodeContext *context)
Callback function for link change event.
Definition: mld_node.c:451
@ MLD_NODE_GROUP_STATE_IDLE_LISTENER
Definition: mld_node.h:60
#define IPV6_MULTICAST_FILTER_SIZE
Definition: ipv6.h:100
NetTimer olderVersionQuerierPresentTimer
Older version querier present timer.
Definition: mld_node.h:117
NetInterface * interface
Underlying network interface.
Definition: mld_node.h:115
Ipv6Addr addr
Multicast group address.
Definition: mld_node.h:95
uint_t retransmitCount
Filter mode retransmission counter.
Definition: mld_node.h:97
void mldNodeTick(MldNodeContext *context)
MLD node timer handler.
Definition: mld_node.c:92
Ipv4Addr groupAddr
Definition: igmp_common.h:214
MldVersion
MLD versions.
Definition: mld_common.h:93
@ MLD_NODE_GROUP_STATE_NON_LISTENER
Definition: mld_node.h:57
@ MLD_NODE_GROUP_STATE_INIT_LISTENER
Definition: mld_node.h:58
NetTimer generalQueryTimer
Timer for scheduling responses to general queries.
Definition: mld_node.h:118
Source address list.
Definition: mld_node.h:80
unsigned int uint_t
Definition: compiler_port.h:50
TCP/IP stack core.
Multicast group.
Definition: mld_node.h:93
MldNodeGroupState state
Multicast group state.
Definition: mld_node.h:94