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  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _MLD_H
30 #define _MLD_H
31 
32 //Dependencies
33 #include "core/net.h"
34 
35 //MLD support
36 #ifndef MLD_SUPPORT
37  #define MLD_SUPPORT DISABLED
38 #elif (MLD_SUPPORT != ENABLED && MLD_SUPPORT != DISABLED)
39  #error MLD_SUPPORT parameter is not valid
40 #endif
41 
42 //MLD tick interval
43 #ifndef MLD_TICK_INTERVAL
44  #define MLD_TICK_INTERVAL 1000
45 #elif (MLD_TICK_INTERVAL < 10)
46  #error MLD_TICK_INTERVAL parameter is not valid
47 #endif
48 
49 //Unsolicited report interval
50 #ifndef MLD_UNSOLICITED_REPORT_INTERVAL
51  #define MLD_UNSOLICITED_REPORT_INTERVAL 10000
52 #elif (MLD_UNSOLICITED_REPORT_INTERVAL < 1000)
53  #error MLD_UNSOLICITED_REPORT_INTERVAL parameter is not valid
54 #endif
55 
56 //Hop Limit used by MLD messages
57 #define MLD_HOP_LIMIT 1
58 
59 //C++ guard
60 #ifdef __cplusplus
61  extern "C" {
62 #endif
63 
64 
65 /**
66  * @brief MLD node states
67  **/
68 
69 typedef enum
70 {
74 } MldState;
75 
76 
77 //CodeWarrior or Win32 compiler?
78 #if defined(__CWCC__) || defined(_WIN32)
79  #pragma pack(push, 1)
80 #endif
81 
82 
83 /**
84  * @brief MLD message
85  **/
86 
87 typedef __start_packed struct
88 {
89  uint8_t type; //0
90  uint8_t code; //1
91  uint16_t checksum; //2-3
92  uint16_t maxRespDelay; //4-5
93  uint16_t reserved; //6-7
96 
97 
98 //CodeWarrior or Win32 compiler?
99 #if defined(__CWCC__) || defined(_WIN32)
100  #pragma pack(pop)
101 #endif
102 
103 
104 //Tick counter to handle periodic operations
106 
107 //MLD related functions
108 error_t mldInit(NetInterface *interface);
111 
112 void mldTick(NetInterface *interface);
113 void mldLinkChangeEvent(NetInterface *interface);
114 
115 void mldProcessListenerQuery(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
116  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
117 
118 void mldProcessListenerReport(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader,
119  const NetBuffer *buffer, size_t offset, uint8_t hopLimit);
120 
123 
124 uint32_t mldRand(uint32_t max);
125 
126 void mldDumpMessage(const MldMessage *message);
127 
128 //C++ guard
129 #ifdef __cplusplus
130  }
131 #endif
132 
133 #endif
uint32_t systime_t
Definition: compiler_port.h:44
void mldDumpMessage(const MldMessage *message)
Dump MLD message for debugging purpose.
Definition: mld.c:595
TCP/IP stack core.
uint8_t message[]
Definition: chap.h:150
uint8_t code
Definition: mld.h:90
__start_packed struct @183 Ipv6Addr
IPv6 network address.
systime_t mldTickCounter
Definition: mld.c:54
void mldTick(NetInterface *interface)
MLD timer handler.
Definition: mld.c:153
void mldProcessListenerQuery(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Process incoming Multicast Listener Query message.
Definition: mld.c:266
uint16_t maxRespDelay
Definition: mld.h:92
error_t mldSendListenerDone(NetInterface *interface, Ipv6Addr *ipAddr)
Send Multicast Listener Done message.
Definition: mld.c:510
uint16_t reserved
Definition: mld.h:93
uint8_t type
Definition: mld.h:89
uint8_t ipAddr[4]
Definition: mib_common.h:185
uint16_t checksum
Definition: mld.h:91
MldState
MLD node states.
Definition: mld.h:69
void mldProcessListenerReport(NetInterface *interface, Ipv6PseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, uint8_t hopLimit)
Process incoming Multicast Listener Report message.
Definition: mld.c:369
error_t mldStopListening(NetInterface *interface, Ipv6FilterEntry *entry)
Stop listening to the address on the interface.
Definition: mld.c:126
#define Ipv6PseudoHeader
Definition: ipv6.h:40
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:86
error_t mldSendListenerReport(NetInterface *interface, Ipv6Addr *ipAddr)
Send Multicast Listener Report message.
Definition: mld.c:436
Ipv6Addr multicastAddr
Definition: mld.h:94
error_t mldInit(NetInterface *interface)
MLD initialization.
Definition: mld.c:63
__start_packed struct _Ipv4Header __end_packed
error_t
Error codes.
Definition: error.h:40
#define NetInterface
Definition: net.h:34
void mldLinkChangeEvent(NetInterface *interface)
Callback function for link change event.
Definition: mld.c:196
IPv6 multicast filter entry.
Definition: ipv6.h:446
__start_packed struct @193 MldMessage
MLD message.
uint32_t mldRand(uint32_t max)
Get a random value in the specified range.
Definition: mld.c:583
error_t mldStartListening(NetInterface *interface, Ipv6FilterEntry *entry)
Start listening to the address on the interface.
Definition: mld.c:77