Contiki-NG
routing.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, RISE SICS.
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 /**
34  * \file
35  * Routing driver header file
36  * \author
37  * Simon Duquennoy <simon.duquennoy@ri.se>
38  */
39 
40 #ifndef ROUTING_H_
41 #define ROUTING_H_
42 
43 #include "contiki.h"
44 #include "net/ipv6/uip.h"
45 #include "net/ipv6/uip-ds6-nbr.h"
46 #include "net/ipv6/uip-ds6-route.h"
47 #include "net/ipv6/uip-sr.h"
48 #include "net/linkaddr.h"
49 
50 /**
51  * The structure of a routing protocol driver.
52  */
54  char *name;
55  /** Initialize the routing protocol */
56  void (* init)(void);
57  /**
58  * Set the prefix, for nodes that will operate as root
59  *
60  * \param prefix The prefix. If NULL, UIP_DS6_DEFAULT_PREFIX is used instead
61  * \param iid The IID. If NULL, it will be built from uip_ds6_set_addr_iid.
62  */
63  void (* root_set_prefix)(uip_ipaddr_t *prefix, uip_ipaddr_t *iid);
64  /**
65  * Set the node as root and start a network
66  *
67  * \return 0 in case of success, -1 otherwise
68  */
69  int (* root_start)(void);
70  /**
71  * Tells whether the node is a network root or not
72  *
73  * \return 1 if we are root, 0 otherwise
74  */
75  int (* node_is_root)(void);
76  /**
77  * Returns the IPv6 address of the network root, if any
78  *
79  * \param ipaddr A pointer where to copy the IP address of the root
80  * \return 1 if the root address was copied, 0 otherwise
81  */
82  int (* get_root_ipaddr)(uip_ipaddr_t *ipaddr);
83  /**
84  * Returns the global IPv6 address of a source routing node
85  *
86  * \param ipaddr A pointer where to copy the IP address of the node
87  * \param node The source routing node
88  * \return 1 if the global node address was copied, 0 otherwise
89  */
90  int (* get_sr_node_ipaddr)(uip_ipaddr_t *addr, const uip_sr_node_t *node);
91  /**
92  * Leave the network the node is part of
93  *
94  */
95  void (* leave_network)(void);
96  /**
97  * Tells whether the node is currently part of a network
98  *
99  * \return 1 if we have joined a network, 0 otherwise.
100  */
101  int (* node_has_joined)(void);
102  /**
103  * Tells whether the node is currently reachable as part of the network
104  *
105  * \return 1 if we are reachable, 0 otherwise.
106  */
107  int (* node_is_reachable)(void);
108  /**
109  * Triggers a global topology repair
110  *
111  * \param str A textual description of the cause for triggering a repair
112  */
113  void (* global_repair)(const char *str);
114  /**
115  * Triggers a RPL local topology repair
116  *
117  * \param str A textual description of the cause for triggering a repair
118  */
119  void (* local_repair)(const char *str);
120  /**
121  * Removes all extension headers that pertain to the routing protocol.
122  */
123  void (* ext_header_remove)(void);
124  /**
125  * Adds/updates routing protocol extension headers to current uIP packet.
126  *
127  * \return 1 in case of success, 0 otherwise
128  */
129  int (* ext_header_update)(void);
130  /**
131  * Process and update the routing protocol hob-by-hop
132  * extention headers of the current uIP packet.
133  *
134  * \param uip_ext_opt_offset The offset within the uIP packet where
135  * extension headers start
136  * \return 1 in case the packet is valid and to be processed further,
137  * 0 in case the packet must be dropped.
138  */
140  /**
141  * Process and update SRH in-place,
142  * i.e. internal address swapping as per RFC6554
143  * \return 1 if SRH found, 0 otherwise
144  */
145  int (* ext_header_srh_update)(void);
146  /**
147  * Look for next hop from SRH of current uIP packet.
148  *
149  * \param ipaddr A pointer to the address where to store the next hop.
150  * \return 1 if a next hop was found, 0 otherwise
151  */
152  int (* ext_header_srh_get_next_hop)(uip_ipaddr_t *ipaddr);
153  /**
154  * Called by lower layers after every packet transmission
155  *
156  * \param addr The link-layer addrress of the packet destination
157  * \param status The transmission status (see os/net/mac/mac.h)
158  * \param numtx The total number of transmission attempts
159  */
160  void (* link_callback)(const linkaddr_t *addr, int status, int numtx);
161  /**
162  * Called by uIP to notify addition/removal of IPv6 neighbor entries
163  *
164  * \param addr The link-layer addrress of the packet destination
165  * \param status The transmission status (see os/net/mac/mac.h)
166  * \param numtx The total number of transmission attempts
167  */
169  /**
170  * Called by uIP if it has decided to drop a route because
171  *
172  * \param route The route that will be dropped after this function returns
173  */
174  void (* drop_route)(uip_ds6_route_t *route);
175 };
176 
177 #endif /* ROUTING_H_ */
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition: uip-nd6.c:125
int(* node_has_joined)(void)
Tells whether the node is currently part of a network.
Definition: routing.h:101
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
Definition: uip-nd6.c:115
void(* ext_header_remove)(void)
Removes all extension headers that pertain to the routing protocol.
Definition: routing.h:123
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition: uip-nd6.c:116
Header file for the link-layer address representation
void(* link_callback)(const linkaddr_t *addr, int status, int numtx)
Called by lower layers after every packet transmission.
Definition: routing.h:160
IPv6 Neighbor cache (link-layer/IPv6 address mapping)
void(* drop_route)(uip_ds6_route_t *route)
Called by uIP if it has decided to drop a route because.
Definition: routing.h:174
int(* root_start)(void)
Set the node as root and start a network.
Definition: routing.h:69
void(* global_repair)(const char *str)
Triggers a global topology repair.
Definition: routing.h:113
Source routing support.
void(* root_set_prefix)(uip_ipaddr_t *prefix, uip_ipaddr_t *iid)
Set the prefix, for nodes that will operate as root.
Definition: routing.h:63
void(* init)(void)
Initialize the routing protocol.
Definition: routing.h:56
An entry in the routing table.
void(* neighbor_state_changed)(uip_ds6_nbr_t *nbr)
Called by uIP to notify addition/removal of IPv6 neighbor entries.
Definition: routing.h:168
int(* node_is_root)(void)
Tells whether the node is a network root or not.
Definition: routing.h:75
uint8_t uip_ext_opt_offset
length of the header options read
Definition: uip6.c:134
int(* ext_header_srh_get_next_hop)(uip_ipaddr_t *ipaddr)
Look for next hop from SRH of current uIP packet.
Definition: routing.h:152
void(* leave_network)(void)
Leave the network the node is part of.
Definition: routing.h:95
Header file for the uIP TCP/IP stack.
int(* ext_header_srh_update)(void)
Process and update SRH in-place, i.e.
Definition: routing.h:145
Header file for routing table manipulation.
void(* local_repair)(const char *str)
Triggers a RPL local topology repair.
Definition: routing.h:119
int(* ext_header_hbh_update)(int uip_ext_opt_offset)
Process and update the routing protocol hob-by-hop extention headers of the current uIP packet...
Definition: routing.h:139
int(* get_sr_node_ipaddr)(uip_ipaddr_t *addr, const uip_sr_node_t *node)
Returns the global IPv6 address of a source routing node.
Definition: routing.h:90
int(* get_root_ipaddr)(uip_ipaddr_t *ipaddr)
Returns the IPv6 address of the network root, if any.
Definition: routing.h:82
int(* ext_header_update)(void)
Adds/updates routing protocol extension headers to current uIP packet.
Definition: routing.h:129
The structure of a routing protocol driver.
Definition: routing.h:53
A node in a source routing graph, stored at the root and representing all child-parent relationship...
Definition: uip-sr.h:92
int(* node_is_reachable)(void)
Tells whether the node is currently reachable as part of the network.
Definition: routing.h:107
An entry in the nbr cache.
Definition: uip-ds6-nbr.h:69