Contiki 2.6

multihop.h

Go to the documentation of this file.
00001 /**
00002  * \addtogroup rime
00003  * @{
00004  */
00005 
00006 /**
00007  * \defgroup rimemultihop Best-effort multihop forwarding
00008  * @{
00009  *
00010  * The multihop module implements a multihop forwarding mechanism. Routes
00011  * must have already been setup with the route_add() function. Setting
00012  * up routes is done with another Rime module such as the \ref
00013  * routediscovery "route-discovery module".
00014  *
00015  * The multihop sends a packet to an identified node in the network by
00016  * using multi-hop forwarding at each node in the network.  The
00017  * application or protocol that uses the multihop primitive supplies a
00018  * routing function for selecting the next-hop neighbor.  If the
00019  * multihop primitive is requested to send a packet for which no
00020  * suitable next hop neighbor is found, the caller is immediately
00021  * notified of this and may choose to initiate a route discovery
00022  * process.
00023  *
00024  *
00025  * \section channels Channels
00026  *
00027  * The multihop module uses 1 channel.
00028  *
00029  */
00030 
00031 /*
00032  * Copyright (c) 2006, Swedish Institute of Computer Science.
00033  * All rights reserved.
00034  *
00035  * Redistribution and use in source and binary forms, with or without
00036  * modification, are permitted provided that the following conditions
00037  * are met:
00038  * 1. Redistributions of source code must retain the above copyright
00039  *    notice, this list of conditions and the following disclaimer.
00040  * 2. Redistributions in binary form must reproduce the above copyright
00041  *    notice, this list of conditions and the following disclaimer in the
00042  *    documentation and/or other materials provided with the distribution.
00043  * 3. Neither the name of the Institute nor the names of its contributors
00044  *    may be used to endorse or promote products derived from this software
00045  *    without specific prior written permission.
00046  *
00047  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00048  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00049  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00050  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00051  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00052  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00053  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00054  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00055  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00056  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00057  * SUCH DAMAGE.
00058  *
00059  * This file is part of the Contiki operating system.
00060  *
00061  * $Id: multihop.h,v 1.6 2009/03/24 07:15:04 adamdunkels Exp $
00062  */
00063 
00064 /**
00065  * \file
00066  *         Multihop forwarding header file
00067  * \author
00068  *         Adam Dunkels <adam@sics.se>
00069  */
00070 
00071 #ifndef __MULTIHOP_H__
00072 #define __MULTIHOP_H__
00073 
00074 #include "net/rime/unicast.h"
00075 #include "net/rime/rimeaddr.h"
00076 
00077 struct multihop_conn;
00078 
00079 #define MULTIHOP_ATTRIBUTES   { PACKETBUF_ADDR_ESENDER, PACKETBUF_ADDRSIZE }, \
00080                               { PACKETBUF_ADDR_ERECEIVER, PACKETBUF_ADDRSIZE }, \
00081                               { PACKETBUF_ATTR_HOPS, PACKETBUF_ATTR_BIT * 5 }, \
00082                                 UNICAST_ATTRIBUTES
00083 
00084 
00085 
00086 struct multihop_callbacks {
00087   void (* recv)(struct multihop_conn *ptr,
00088                 const rimeaddr_t *sender,
00089                 const rimeaddr_t *prevhop,
00090                 uint8_t hops);
00091   rimeaddr_t *(* forward)(struct multihop_conn *ptr,
00092                           const rimeaddr_t *originator,
00093                           const rimeaddr_t *dest,
00094                           const rimeaddr_t *prevhop,
00095                           uint8_t hops);
00096 };
00097 
00098 struct multihop_conn {
00099   struct unicast_conn c;
00100   const struct multihop_callbacks *cb;
00101 };
00102 
00103 void multihop_open(struct multihop_conn *c, uint16_t channel,
00104              const struct multihop_callbacks *u);
00105 void multihop_close(struct multihop_conn *c);
00106 int multihop_send(struct multihop_conn *c, const rimeaddr_t *to);
00107 void multihop_resend(struct multihop_conn *c, const rimeaddr_t *nexthop);
00108 
00109 #endif /* __MULTIHOP_H__ */
00110 /** @} */
00111 /** @} */