Contiki 3.x
rmh.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006, Swedish Institute of 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 /**
34  * \file
35  * Multihop forwarding header file
36  * \author
37  * Adam Dunkels <adam@sics.se>
38  */
39 
40 /**
41  * \addtogroup rime
42  * @{
43  */
44 
45 /**
46  * \defgroup rimermh Reliable multihop forwarding
47  * @{
48  *
49  * The rmh module implements a multihop forwarding mechanism. Routes
50  * must have already been setup with the route_add() function. Setting
51  * up routes is done with another Rime module such as the \ref
52  * routediscovery "route-discovery module".
53  *
54  * The hop-by-hop reliable multi-hop unciast primitive is similar to
55  * the best-effot multi-hop unicast primitive except that it uses the
56  * reliable single-hop primitive for the communication between two
57  * single-hop neighbors.
58  *
59  * \section channels Channels
60  *
61  * The rmh module uses 1 channel.
62  *
63  */
64 
65 #ifndef RMH_H_
66 #define RMH_H_
67 
68 #include "net/rime/runicast.h"
69 #include "net/linkaddr.h"
70 
71 struct rmh_conn;
72 
73 #define RMH_ATTRIBUTES { PACKET_ADDR_ESENDER, PACKET_ADDRSIZE }, \
74  { PACKET_ADDR_ERECEIVER, PACKET_ADDRSIZE }, \
75  { PACKET_ATTR_TTL, PACKET_ATTR_BIT * 5 }, \
76  { PACKET_ATTR_MAX_REXMIT, PACKET_ATTR_BIT * 5 }, \
77  RUC_ATTRIBUTES
78 
79 struct rmh_callbacks {
80  void (* recv)(struct rmh_conn *ptr, linkaddr_t *sender, uint8_t hops);
81  linkaddr_t *(* forward)(struct rmh_conn *ptr,
82  const linkaddr_t *originator,
83  const linkaddr_t *dest,
84  const linkaddr_t *prevhop,
85  uint8_t hops);
86 };
87 
88 struct rmh_conn {
89  struct runicast_conn c;
90  const struct rmh_callbacks *cb;
91  uint8_t num_rexmit;
92 };
93 
94 void rmh_open(struct rmh_conn *c, uint16_t channel,
95  const struct rmh_callbacks *u);
96 void rmh_close(struct rmh_conn *c);
97 int rmh_send(struct rmh_conn *c, linkaddr_t *to, uint8_t num_rexmit,
98  uint8_t max_hops);
99 
100 #endif /* RMH_H_ */
101 /** @} */
102 /** @} */
Reliable unicast header file
Header file for the Rime address representation