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 
69 #include <string.h>
70 /*---------------------------------------------------------------------------*/
71 /* Constants */
72 /*---------------------------------------------------------------------------*/
73 #define UIP_MCAST6_DROP 0
74 #define UIP_MCAST6_ACCEPT 1
75 /*---------------------------------------------------------------------------*/
76 /* Multicast Address Scopes (RFC 4291 & draft-ietf-6man-multicast-scopes) */
77 #define UIP_MCAST6_SCOPE_INTERFACE 0x01
78 #define UIP_MCAST6_SCOPE_LINK_LOCAL 0x02
79 #define UIP_MCAST6_SCOPE_REALM_LOCAL 0x03 /* draft-ietf-6man-multicast-scopes */
80 #define UIP_MCAST6_SCOPE_ADMIN_LOCAL 0x04
81 #define UIP_MCAST6_SCOPE_SITE_LOCAL 0x05
82 #define UIP_MCAST6_SCOPE_ORG_LOCAL 0x08
83 #define UIP_MCAST6_SCOPE_GLOBAL 0x0E
84 /*---------------------------------------------------------------------------*/
85 /* Choose an engine or turn off based on user configuration */
86 /*---------------------------------------------------------------------------*/
87 #ifdef UIP_MCAST6_CONF_ENGINE
88 #define UIP_MCAST6_ENGINE UIP_MCAST6_CONF_ENGINE
89 #else
90 #define UIP_MCAST6_ENGINE UIP_MCAST6_ENGINE_NONE
91 #endif
92 /*---------------------------------------------------------------------------*/
93 /*
94  * Multicast API. Similar to NETSTACK, each engine must define a driver and
95  * populate the fields with suitable function pointers
96  */
97 /**
98  * \brief The data structure used to represent a multicast engine
99  */
101  /** The driver's name */
102  char *name;
103 
104  /** Initialize the multicast engine */
105  void (* init)(void);
106 
107  /**
108  * \brief Process an outgoing datagram with a multicast IPv6 destination
109  * address
110  *
111  * This may be needed if the multicast engine needs to, for example,
112  * add IPv6 extension headers to the datagram, cache it, decide it
113  * needs dropped etc.
114  *
115  * It is sometimes desirable to let the engine handle datagram
116  * dispatch instead of letting the networking core do it. If the
117  * engine decides to send the datagram itself, it must afterwards
118  * set uip_len = 0 to prevent the networking core from sending too
119  */
120  void (* out)(void);
121 
122  /**
123  * \brief Process an incoming multicast datagram and determine whether it
124  * should be delivered up the stack or not.
125  *
126  * \return 0: Drop, 1: Deliver
127  *
128  *
129  * When a datagram with a multicast destination address is received,
130  * the forwarding logic in core is bypassed. Instead, we let the
131  * multicast engine handle forwarding internally if and as necessary.
132  * This function is where forwarding logic must be hooked in.
133  *
134  * Once the engine is done with forwarding, it must signal via the
135  * return value whether the datagram needs delivered up the network
136  * stack.
137  */
138  uint8_t (* in)(void);
139 };
140 /*---------------------------------------------------------------------------*/
141 /**
142  * \brief Get a multicast address' scope.
143  * a is of type uip_ip6addr_t*
144  */
145 #define uip_mcast6_get_address_scope(a) ((a)->u8[1] & 0x0F)
146 /*---------------------------------------------------------------------------*/
147 /* Configure multicast and os/net to play nicely with the selected engine */
148 #if UIP_MCAST6_ENGINE
149 
150 /* Enable Multicast hooks in the uip6 core */
151 #define UIP_IPV6_MULTICAST 1
152 
153 #if UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_ROLL_TM
154 #define RPL_WITH_MULTICAST 0 /* Not used by trickle */
155 #define UIP_CONF_IPV6_ROLL_TM 1 /* ROLL Trickle ICMP type support */
156 
157 #define UIP_MCAST6 roll_tm_driver
158 
159 #elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_SMRF
160 #define RPL_WITH_MULTICAST 1
161 
162 #define UIP_MCAST6 smrf_driver
163 
164 #elif UIP_MCAST6_ENGINE == UIP_MCAST6_ENGINE_ESMRF
165 #define RPL_WITH_MULTICAST 1
166 #define UIP_MCAST6 esmrf_driver
167 
168 #else
169 #error "Multicast Enabled with an Unknown Engine."
170 #error "Check the value of UIP_MCAST6_CONF_ENGINE in conf files."
171 #endif
172 #endif /* UIP_MCAST6_ENGINE */
173 
174 extern const struct uip_mcast6_driver UIP_MCAST6;
175 /*---------------------------------------------------------------------------*/
176 /* Configuration Checks */
177 /*---------------------------------------------------------------------------*/
178 #if RPL_WITH_MULTICAST && (!UIP_CONF_IPV6_RPL)
179 #error "The selected Multicast mode requires UIP_CONF_IPV6_RPL != 0"
180 #error "Check the value of UIP_CONF_IPV6_RPL in conf files."
181 #endif
182 /*---------------------------------------------------------------------------*/
183 #endif /* UIP_MCAST6_H_ */
184 /*---------------------------------------------------------------------------*/
185 /** @} */
186 /** @} */
Header file for the implementation of the ROLL-TM multicast engine.
char * name
The driver&#39;s name.
Definition: uip-mcast6.h:102
The data structure used to represent a multicast engine.
Definition: uip-mcast6.h:100
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:138
Header file for multicast routing table manipulation.
void(* out)(void)
Process an outgoing datagram with a multicast IPv6 destination address.
Definition: uip-mcast6.h:120
void(* init)(void)
Initialize the multicast engine.
Definition: uip-mcast6.h:105
Header file for the SMRF forwarding engine.
Header file for the Enhanced Stateless Multicast RPL Forwarding (ESMRF)