Contiki-NG
uip-mcast6.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Loughborough University - Computer Science
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  */
31 
32 /**
33  * \addtogroup uip
34  * @{
35  */
36 /**
37  * \defgroup uip-multicast IPv6 Multicast Forwarding
38  *
39  * We currently support 2 engines:
40  * - 'Stateless Multicast RPL Forwarding' (SMRF)
41  * RPL does group management as per the RPL docs, SMRF handles datagram
42  * forwarding
43  * - 'Multicast Forwarding with Trickle' according to the algorithm described
44  * in the internet draft:
45  * http://tools.ietf.org/html/draft-ietf-roll-trickle-mcast
46  *
47  * @{
48  */
49 
50 /**
51  * \file
52  * This header file contains configuration directives for uIPv6
53  * multicast support.
54  *
55  * \author
56  * George Oikonomou - <oikonomou@users.sourceforge.net>
57  */
58 
59 #ifndef UIP_MCAST6_H_
60 #define UIP_MCAST6_H_
61 
62 #include "contiki.h"
68 #include "net/ipv6/multicast/mpl.h"
69 
70 #include <string.h>
71 /*---------------------------------------------------------------------------*/
72 /* Constants */
73 /*---------------------------------------------------------------------------*/
74 #define UIP_MCAST6_DROP 0
75 #define UIP_MCAST6_ACCEPT 1
76 /*---------------------------------------------------------------------------*/
77 /* Multicast Address Scopes (RFC 4291 & draft-ietf-6man-multicast-scopes) */
78 #define UIP_MCAST6_SCOPE_INTERFACE 0x01
79 #define UIP_MCAST6_SCOPE_LINK_LOCAL 0x02
80 #define UIP_MCAST6_SCOPE_REALM_LOCAL 0x03 /* draft-ietf-6man-multicast-scopes */
81 #define UIP_MCAST6_SCOPE_ADMIN_LOCAL 0x04
82 #define UIP_MCAST6_SCOPE_SITE_LOCAL 0x05
83 #define UIP_MCAST6_SCOPE_ORG_LOCAL 0x08
84 #define UIP_MCAST6_SCOPE_GLOBAL 0x0E
85 /*---------------------------------------------------------------------------*/
86 /* Choose an engine or turn off based on user configuration */
87 /*---------------------------------------------------------------------------*/
88 #ifdef UIP_MCAST6_CONF_ENGINE
89 #define UIP_MCAST6_ENGINE UIP_MCAST6_CONF_ENGINE
90 #else
91 #define UIP_MCAST6_ENGINE UIP_MCAST6_ENGINE_NONE
92 #endif
93 /*---------------------------------------------------------------------------*/
94 /*
95  * Multicast API. Similar to NETSTACK, each engine must define a driver and
96  * populate the fields with suitable function pointers
97  */
98 /**
99  * \brief The data structure used to represent a multicast engine
100  */
102  /** The driver's name */
103  char *name;
104 
105  /** Initialize the multicast engine */
106  void (* init)(void);
107 
108  /**
109  * \brief Process an outgoing datagram with a multicast IPv6 destination
110  * address
111  *
112  * This may be needed if the multicast engine needs to, for example,
113  * add IPv6 extension headers to the datagram, cache it, decide it
114  * needs dropped etc.
115  *
116  * It is sometimes desirable to let the engine handle datagram
117  * dispatch instead of letting the networking core do it. If the
118  * engine decides to send the datagram itself, it must afterwards
119  * set uip_len = 0 to prevent the networking core from sending too
120  */
121  void (* out)(void);
122 
123  /**
124  * \brief Process an incoming multicast datagram and determine whether it
125  * should be delivered up the stack or not.
126  *
127  * \return 0: Drop, 1: Deliver
128  *
129  *
130  * When a datagram with a multicast destination address is received,
131  * the forwarding logic in core is bypassed. Instead, we let the
132  * multicast engine handle forwarding internally if and as necessary.
133  * This function is where forwarding logic must be hooked in.
134  *
135  * Once the engine is done with forwarding, it must signal via the
136  * return value whether the datagram needs delivered up the network
137  * stack.
138  */
139  uint8_t (* in)(void);
140 };
141 /*---------------------------------------------------------------------------*/
142 /**
143  * \brief Get a multicast address' scope.
144  * a is of type uip_ip6addr_t*
145  */
146 #define uip_mcast6_get_address_scope(a) ((a)->u8[1] & 0x0F)
147 /*---------------------------------------------------------------------------*/
148 /* Configure multicast and os/net to play nicely with the selected engine */
149 #if UIP_MCAST6_ENGINE
150 
151 /* Enable Multicast hooks in the uip6 core */
152 #define UIP_IPV6_MULTICAST 1
153 
154 #if UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_ROLL_TM
155 #define RPL_WITH_MULTICAST 0 /* Not used by trickle */
156 #define UIP_CONF_IPV6_ROLL_TM 1 /* ROLL Trickle ICMP type support */
157 
158 #define UIP_MCAST6 roll_tm_driver
159 
160 #elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_SMRF
161 #define RPL_WITH_MULTICAST 1
162 
163 #define UIP_MCAST6 smrf_driver
164 
165 #elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_ESMRF
166 #define RPL_WITH_MULTICAST 1
167 #define UIP_MCAST6 esmrf_driver
168 
169 #elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_MPL
170 #define RPL_WITH_MULTICAST 0
171 #define UIP_MCAST6 mpl_driver
172 
173 #else
174 #error "Multicast Enabled with an Unknown Engine."
175 #error "Check the value of UIP_MCAST6_CONF_ENGINE in conf files."
176 #endif
177 #endif /* UIP_MCAST6_ENGINE */
178 
179 extern const struct uip_mcast6_driver UIP_MCAST6;
180 /*---------------------------------------------------------------------------*/
181 /* Configuration Checks */
182 /*---------------------------------------------------------------------------*/
183 #if RPL_WITH_MULTICAST && (!UIP_CONF_IPV6_RPL)
184 #error "The selected Multicast mode requires UIP_CONF_IPV6_RPL != 0"
185 #error "Check the value of UIP_CONF_IPV6_RPL in conf files."
186 #endif
187 /*---------------------------------------------------------------------------*/
188 #endif /* UIP_MCAST6_H_ */
189 /*---------------------------------------------------------------------------*/
190 /** @} */
191 /** @} */
Header file for the implementation of the ROLL-TM multicast engine.
char * name
The driver&#39;s name.
Definition: uip-mcast6.h:103
The data structure used to represent a multicast engine.
Definition: uip-mcast6.h:101
Header file for the implementation of the MPL protocol.
Header file with definition of multicast engine constants.
uint8_t(* in)(void)
Process an incoming multicast datagram and determine whether it should be delivered up the stack or n...
Definition: uip-mcast6.h:139
Header file for multicast routing table manipulation.
void(* out)(void)
Process an outgoing datagram with a multicast IPv6 destination address.
Definition: uip-mcast6.h:121
void(* init)(void)
Initialize the multicast engine.
Definition: uip-mcast6.h:106
Header file for the SMRF forwarding engine.
Header file for the Enhanced Stateless Multicast RPL Forwarding (ESMRF)