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