Contiki-Inga 3.x
rmh.h
Go to the documentation of this file.
1 /**
2  * \addtogroup rime
3  * @{
4  */
5 
6 /**
7  * \defgroup rimermh Best-effort multihop forwarding
8  * @{
9  *
10  * The rmh module implements a multihop forwarding mechanism. Routes
11  * must have already been setup with the route_add() function. Setting
12  * up routes is done with another Rime module such as the \ref
13  * routediscovery "route-discovery module".
14  *
15  * The hop-by-hop reliable multi-hop unciast primitive is similar to
16  * the best-effot multi-hop unicast primitive except that it uses the
17  * reliable single-hop primitive for the communication between two
18  * single-hop neighbors.
19  *
20  * \section channels Channels
21  *
22  * The rmh module uses 1 channel.
23  *
24  */
25 
26 /*
27  * Copyright (c) 2006, Swedish Institute of Computer Science.
28  * All rights reserved.
29  *
30  * Redistribution and use in source and binary forms, with or without
31  * modification, are permitted provided that the following conditions
32  * are met:
33  * 1. Redistributions of source code must retain the above copyright
34  * notice, this list of conditions and the following disclaimer.
35  * 2. Redistributions in binary form must reproduce the above copyright
36  * notice, this list of conditions and the following disclaimer in the
37  * documentation and/or other materials provided with the distribution.
38  * 3. Neither the name of the Institute nor the names of its contributors
39  * may be used to endorse or promote products derived from this software
40  * without specific prior written permission.
41  *
42  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
43  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
46  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52  * SUCH DAMAGE.
53  *
54  * This file is part of the Contiki operating system.
55  *
56  */
57 
58 /**
59  * \file
60  * Multihop forwarding header file
61  * \author
62  * Adam Dunkels <adam@sics.se>
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 /** @} */