Contiki 2.5
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  * $Id: rmh.h,v 1.8 2009/11/08 19:40:17 adamdunkels Exp $
57  */
58 
59 /**
60  * \file
61  * Multihop forwarding header file
62  * \author
63  * Adam Dunkels <adam@sics.se>
64  */
65 
66 #ifndef __RMH_H__
67 #define __RMH_H__
68 
69 #include "net/rime/runicast.h"
70 #include "net/rime/rimeaddr.h"
71 
72 struct rmh_conn;
73 
74 #define RMH_ATTRIBUTES { PACKET_ADDR_ESENDER, PACKET_ADDRSIZE }, \
75  { PACKET_ADDR_ERECEIVER, PACKET_ADDRSIZE }, \
76  { PACKET_ATTR_TTL, PACKET_ATTR_BIT * 5 }, \
77  { PACKET_ATTR_MAX_REXMIT, PACKET_ATTR_BIT * 5 }, \
78  RUC_ATTRIBUTES
79 
80 struct rmh_callbacks {
81  void (* recv)(struct rmh_conn *ptr, rimeaddr_t *sender, uint8_t hops);
82  rimeaddr_t *(* forward)(struct rmh_conn *ptr,
83  const rimeaddr_t *originator,
84  const rimeaddr_t *dest,
85  const rimeaddr_t *prevhop,
86  uint8_t hops);
87 };
88 
89 struct rmh_conn {
90  struct runicast_conn c;
91  const struct rmh_callbacks *cb;
92  uint8_t num_rexmit;
93 };
94 
95 void rmh_open(struct rmh_conn *c, uint16_t channel,
96  const struct rmh_callbacks *u);
97 void rmh_close(struct rmh_conn *c);
98 int rmh_send(struct rmh_conn *c, rimeaddr_t *to, uint8_t num_rexmit,
99  uint8_t max_hops);
100 
101 #endif /* __RMH_H__ */
102 /** @} */
103 /** @} */