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-2023 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.2.4
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 //CodeWarrior or Win32 compiler?
80 #if defined(__CWCC__) || defined(_WIN32)
81  #pragma pack(push, 1)
82 #endif
83 
84 
85 /**
86  * @brief MLD message
87  **/
88 
89 typedef __start_packed struct
90 {
91  uint8_t type; //0
92  uint8_t code; //1
93  uint16_t checksum; //2-3
94  uint16_t maxRespDelay; //4-5
95  uint16_t reserved; //6-7
98 
99 
100 //CodeWarrior or Win32 compiler?
101 #if defined(__CWCC__) || defined(_WIN32)
102  #pragma pack(pop)
103 #endif
104 
105 //Tick counter to handle periodic operations
107 
108 //MLD related functions
109 error_t mldInit(NetInterface *interface);
112 
113 void mldTick(NetInterface *interface);
114 void mldLinkChangeEvent(NetInterface *interface);
115 
116 void mldProcessListenerQuery(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
117  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
118 
119 void mldProcessListenerReport(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
120  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
121 
124 
125 void mldDumpMessage(const MldMessage *message);
126 
127 //C++ guard
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif
@ MLD_STATE_IDLE_LISTENER
Definition: mld.h:75
uint16_t maxRespDelay
Definition: mld.h:94
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
systime_t mldTickCounter
Definition: mld.c:56
error_t mldInit(NetInterface *interface)
MLD initialization.
Definition: mld.c:65
void mldLinkChangeEvent(NetInterface *interface)
Callback function for link change event.
Definition: mld.c:198
@ MLD_STATE_DELAYING_LISTENER
Definition: mld.h:74
void mldDumpMessage(const MldMessage *message)
Dump MLD message for debugging purpose.
Definition: mld.c:608
error_t
Error codes.
Definition: error.h:43
#define Ipv6PseudoHeader
Definition: ipv6.h:42
void mldProcessListenerReport(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Process incoming Multicast Listener Report message.
Definition: mld.c:371
uint16_t checksum
Definition: mld.h:93
#define NetInterface
Definition: net.h:36
error_t mldSendListenerReport(NetInterface *interface, Ipv6Addr *ipAddr)
Send Multicast Listener Report message.
Definition: mld.c:438
__start_packed struct _Ipv4Header __end_packed
uint8_t type
Definition: mld.h:91
void mldTick(NetInterface *interface)
MLD timer handler.
Definition: mld.c:155
void mldProcessListenerQuery(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Process incoming Multicast Listener Query message.
Definition: mld.c:268
__start_packed struct @0 MldMessage
MLD message.
uint32_t systime_t
System time.
error_t mldStopListening(NetInterface *interface, Ipv6FilterEntry *entry)
Stop listening to the address on the interface.
Definition: mld.c:128
MldState
MLD node states.
Definition: mld.h:72
uint8_t message[]
Definition: chap.h:152
@ MLD_STATE_NON_LISTENER
Definition: mld.h:73
Ipv6Addr multicastAddr
Definition: mld.h:96
error_t mldSendListenerDone(NetInterface *interface, Ipv6Addr *ipAddr)
Send Multicast Listener Done message.
Definition: mld.c:524
TCP/IP stack core.
uint16_t reserved
Definition: mld.h:95
__start_packed struct @0 Ipv6Addr
IPv6 network address.
uint8_t ipAddr[4]
Definition: mib_common.h:187
error_t mldStartListening(NetInterface *interface, Ipv6FilterEntry *entry)
Start listening to the address on the interface.
Definition: mld.c:79
uint8_t code
Definition: mld.h:92
IPv6 multicast filter entry.
Definition: ipv6.h:445