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-2020 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 1.9.8
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 {
76 } MldState;
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 
106 //Tick counter to handle periodic operations
108 
109 //MLD related functions
110 error_t mldInit(NetInterface *interface);
113 
114 void mldTick(NetInterface *interface);
115 void mldLinkChangeEvent(NetInterface *interface);
116 
117 void mldProcessListenerQuery(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
118  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
119 
120 void mldProcessListenerReport(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
121  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
122 
125 
126 uint32_t mldRand(uint32_t max);
127 
128 void mldDumpMessage(const MldMessage *message);
129 
130 //C++ guard
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif
uint16_t maxRespDelay
Definition: mld.h:94
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:88
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
void mldDumpMessage(const MldMessage *message)
Dump MLD message for debugging purpose.
Definition: mld.c:617
error_t
Error codes.
Definition: error.h:42
#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 @87 MldMessage
MLD message.
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:71
uint8_t message[]
Definition: chap.h:152
__start_packed struct @77 Ipv6Addr
IPv6 network address.
Ipv6Addr multicastAddr
Definition: mld.h:96
error_t mldSendListenerDone(NetInterface *interface, Ipv6Addr *ipAddr)
Send Multicast Listener Done message.
Definition: mld.c:522
TCP/IP stack core.
uint16_t reserved
Definition: mld.h:95
uint32_t mldRand(uint32_t max)
Get a random value in the specified range.
Definition: mld.c:605
uint32_t systime_t
Definition: compiler_port.h:46
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:448