mld.h
Go to the documentation of this file.
1 /**
2  * @file mld.h
3  * @brief MLD (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.0
29  **/
30 
31 #ifndef _MLD_H
32 #define _MLD_H
33 
34 //Dependencies
35 #include "core/net.h"
36 
37 //MLD support
38 #ifndef MLD_SUPPORT
39  #define MLD_SUPPORT DISABLED
40 #elif (MLD_SUPPORT != ENABLED && MLD_SUPPORT != DISABLED)
41  #error MLD_SUPPORT parameter is not valid
42 #endif
43 
44 //MLD tick interval
45 #ifndef MLD_TICK_INTERVAL
46  #define MLD_TICK_INTERVAL 1000
47 #elif (MLD_TICK_INTERVAL < 10)
48  #error MLD_TICK_INTERVAL parameter is not valid
49 #endif
50 
51 //Unsolicited report interval
52 #ifndef MLD_UNSOLICITED_REPORT_INTERVAL
53  #define MLD_UNSOLICITED_REPORT_INTERVAL 10000
54 #elif (MLD_UNSOLICITED_REPORT_INTERVAL < 1000)
55  #error MLD_UNSOLICITED_REPORT_INTERVAL parameter is not valid
56 #endif
57 
58 //Hop Limit used by MLD messages
59 #define MLD_HOP_LIMIT 1
60 
61 //C++ guard
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 
67 /**
68  * @brief MLD node states
69  **/
70 
71 typedef enum
72 {
77 
78 
79 //CC-RX, CodeWarrior or Win32 compiler?
80 #if defined(__CCRX__)
81  #pragma pack
82 #elif defined(__CWCC__) || defined(_WIN32)
83  #pragma pack(push, 1)
84 #endif
85 
86 
87 /**
88  * @brief MLD message
89  **/
90 
92 {
93  uint8_t type; //0
94  uint8_t code; //1
95  uint16_t checksum; //2-3
96  uint16_t maxRespDelay; //4-5
97  uint16_t reserved; //6-7
100 
101 
102 //CC-RX, CodeWarrior or Win32 compiler?
103 #if defined(__CCRX__)
104  #pragma unpack
105 #elif defined(__CWCC__) || defined(_WIN32)
106  #pragma pack(pop)
107 #endif
108 
109 //Tick counter to handle periodic operations
111 
112 //MLD related functions
113 error_t mldInit(NetInterface *interface);
116 
117 void mldTick(NetInterface *interface);
118 void mldLinkChangeEvent(NetInterface *interface);
119 
120 void mldProcessListenerQuery(NetInterface *interface,
121  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
122  size_t offset, uint8_t hopLimit);
123 
124 void mldProcessListenerReport(NetInterface *interface,
125  const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer,
126  size_t offset, uint8_t hopLimit);
127 
130 
131 void mldDumpMessage(const MldMessage *message);
132 
133 //C++ guard
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif
uint8_t message[]
Definition: chap.h:154
uint8_t type
Definition: coap_common.h:176
error_t
Error codes.
Definition: error.h:43
Ipv4Addr ipAddr
Definition: ipcp.h:105
Ipv6Addr
Definition: ipv6.h:251
uint8_t hopLimit
Definition: ipv6.h:274
#define Ipv6PseudoHeader
Definition: ipv6.h:42
Ipv6Addr multicastAddr
Definition: mld.h:98
uint16_t maxRespDelay
Definition: mld.h:96
error_t mldSendListenerDone(NetInterface *interface, Ipv6Addr *ipAddr)
Send Multicast Listener Done message.
Definition: mld.c:526
error_t mldStartListening(NetInterface *interface, Ipv6FilterEntry *entry)
Start listening to the address on the interface.
Definition: mld.c:79
void mldProcessListenerQuery(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Process incoming Multicast Listener Query message.
Definition: mld.c:268
void mldLinkChangeEvent(NetInterface *interface)
Callback function for link change event.
Definition: mld.c:198
void mldTick(NetInterface *interface)
MLD timer handler.
Definition: mld.c:155
uint16_t reserved
Definition: mld.h:97
uint16_t checksum
Definition: mld.h:95
void mldProcessListenerReport(NetInterface *interface, const Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Process incoming Multicast Listener Report message.
Definition: mld.c:372
uint8_t code
Definition: mld.h:94
MldMessage
Definition: mld.h:99
error_t mldStopListening(NetInterface *interface, Ipv6FilterEntry *entry)
Stop listening to the address on the interface.
Definition: mld.c:128
error_t mldInit(NetInterface *interface)
MLD initialization.
Definition: mld.c:65
systime_t mldTickCounter
Definition: mld.c:56
void mldDumpMessage(const MldMessage *message)
Dump MLD message for debugging purpose.
Definition: mld.c:610
typedef __packed_struct
MLD message.
Definition: mld.h:92
error_t mldSendListenerReport(NetInterface *interface, Ipv6Addr *ipAddr)
Send Multicast Listener Report message.
Definition: mld.c:440
MldState
MLD node states.
Definition: mld.h:72
@ MLD_STATE_IDLE_LISTENER
Definition: mld.h:75
@ MLD_STATE_DELAYING_LISTENER
Definition: mld.h:74
@ MLD_STATE_NON_LISTENER
Definition: mld.h:73
TCP/IP stack core.
#define NetInterface
Definition: net.h:36
uint32_t systime_t
System time.
IPv6 multicast filter entry.
Definition: ipv6.h:448
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89