Renamed Rime module mh to multihop
This commit is contained in:
parent
d9b3097037
commit
4687c2c948
@ -33,7 +33,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rime.h,v 1.19 2008/07/03 22:02:09 adamdunkels Exp $
|
||||
* $Id: rime.h,v 1.20 2008/07/03 22:36:02 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -50,7 +50,7 @@
|
||||
#include "net/rime/ctimer.h"
|
||||
#include "net/rime/ipolite.h"
|
||||
#include "net/rime/mesh.h"
|
||||
#include "net/rime/mh.h"
|
||||
#include "net/rime/multihop.h"
|
||||
#include "net/rime/neighbor-discovery.h"
|
||||
#include "net/rime/neighbor.h"
|
||||
#include "net/rime/netflood.h"
|
||||
|
@ -4,7 +4,7 @@ RIME_BASE = rimebuf.c queuebuf.c rimeaddr.c ctimer.c rime.c timesynch.c \
|
||||
RIME_SINGLEHOP = broadcast.c stbroadcast.c unicast.c stunicast.c \
|
||||
runicast.c abc.c \
|
||||
rucb.c polite.c ipolite.c
|
||||
RIME_MULTIHOP = netflood.c mh.c rmh.c trickle.c
|
||||
RIME_MULTIHOP = netflood.c multihop.c rmh.c trickle.c
|
||||
RIME_MESH = mesh.c route.c route-discovery.c
|
||||
RIME_COLLECT = collect.c neighbor.c neighbor-discovery.c
|
||||
RIME_RUDOLPH = rudolph0.c rudolph1.c rudolph2.c
|
||||
|
@ -33,7 +33,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: mesh.c,v 1.13 2008/02/24 22:05:27 adamdunkels Exp $
|
||||
* $Id: mesh.c,v 1.14 2008/07/03 22:36:02 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -62,11 +62,11 @@
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
data_packet_received(struct mh_conn *mh, rimeaddr_t *from,
|
||||
data_packet_received(struct multihop_conn *multihop, rimeaddr_t *from,
|
||||
rimeaddr_t *prevhop, uint8_t hops)
|
||||
{
|
||||
struct mesh_conn *c = (struct mesh_conn *)
|
||||
((char *)mh - offsetof(struct mesh_conn, mh));
|
||||
((char *)multihop - offsetof(struct mesh_conn, multihop));
|
||||
|
||||
if(c->cb->recv) {
|
||||
c->cb->recv(c, from, hops);
|
||||
@ -74,7 +74,7 @@ data_packet_received(struct mh_conn *mh, rimeaddr_t *from,
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static rimeaddr_t *
|
||||
data_packet_forward(struct mh_conn *mh, rimeaddr_t *originator,
|
||||
data_packet_forward(struct multihop_conn *multihop, rimeaddr_t *originator,
|
||||
rimeaddr_t *dest, rimeaddr_t *prevhop, uint8_t hops)
|
||||
{
|
||||
struct route_entry *rt;
|
||||
@ -99,7 +99,7 @@ found_route(struct route_discovery_conn *rdc, rimeaddr_t *dest)
|
||||
queuebuf_to_rimebuf(c->queued_data);
|
||||
queuebuf_free(c->queued_data);
|
||||
c->queued_data = NULL;
|
||||
mh_send(&c->mh, dest);
|
||||
multihop_send(&c->multihop, dest);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -119,7 +119,7 @@ route_timed_out(struct route_discovery_conn *rdc)
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static const struct mh_callbacks data_callbacks = { data_packet_received,
|
||||
static const struct multihop_callbacks data_callbacks = { data_packet_received,
|
||||
data_packet_forward };
|
||||
static const struct route_discovery_callbacks route_discovery_callbacks =
|
||||
{ found_route, route_timed_out };
|
||||
@ -128,7 +128,7 @@ void
|
||||
mesh_open(struct mesh_conn *c, uint16_t channels,
|
||||
const struct mesh_callbacks *callbacks)
|
||||
{
|
||||
mh_open(&c->mh, channels, &data_callbacks);
|
||||
multihop_open(&c->multihop, channels, &data_callbacks);
|
||||
route_discovery_open(&c->route_discovery_conn,
|
||||
CLOCK_SECOND * 2,
|
||||
channels + 1,
|
||||
@ -139,7 +139,7 @@ mesh_open(struct mesh_conn *c, uint16_t channels,
|
||||
void
|
||||
mesh_close(struct mesh_conn *c)
|
||||
{
|
||||
mh_close(&c->mh);
|
||||
multihop_close(&c->multihop);
|
||||
route_discovery_close(&c->route_discovery_conn);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -148,7 +148,7 @@ mesh_send(struct mesh_conn *c, rimeaddr_t *to)
|
||||
{
|
||||
int could_send;
|
||||
|
||||
could_send = mh_send(&c->mh, to);
|
||||
could_send = multihop_send(&c->multihop, to);
|
||||
|
||||
if(!could_send) {
|
||||
if(c->queued_data != NULL) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
* \section channels Channels
|
||||
*
|
||||
* The mesh module uses 3 channel; one for the multi-hop forwarding
|
||||
* (\ref rimemh "mh") and two for the route disovery (\ref
|
||||
* (\ref rimemultihop "multihop") and two for the route disovery (\ref
|
||||
* routediscovery "route-discovery").
|
||||
*
|
||||
*/
|
||||
@ -49,7 +49,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: mesh.h,v 1.11 2008/02/24 22:05:27 adamdunkels Exp $
|
||||
* $Id: mesh.h,v 1.12 2008/07/03 22:36:02 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -63,7 +63,7 @@
|
||||
#define __MESH_H__
|
||||
|
||||
#include "net/rime/queuebuf.h"
|
||||
#include "net/rime/mh.h"
|
||||
#include "net/rime/multihop.h"
|
||||
#include "net/rime/route-discovery.h"
|
||||
|
||||
struct mesh_conn;
|
||||
@ -81,7 +81,7 @@ struct mesh_callbacks {
|
||||
};
|
||||
|
||||
struct mesh_conn {
|
||||
struct mh_conn mh;
|
||||
struct multihop_conn multihop;
|
||||
struct route_discovery_conn route_discovery_conn;
|
||||
struct queuebuf *queued_data;
|
||||
rimeaddr_t queued_data_dest;
|
||||
|
@ -33,7 +33,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: mh.c,v 1.11 2008/06/26 11:19:22 adamdunkels Exp $
|
||||
* $Id: multihop.c,v 1.1 2008/07/03 22:36:03 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/rime.h"
|
||||
#include "net/rime/mh.h"
|
||||
#include "net/rime/multihop.h"
|
||||
#include "net/rime/route.h"
|
||||
|
||||
#include <string.h>
|
||||
@ -69,7 +69,7 @@ struct data_hdr {
|
||||
void
|
||||
data_packet_received(struct unicast_conn *uc, rimeaddr_t *from)
|
||||
{
|
||||
struct mh_conn *c = (struct mh_conn *)uc;
|
||||
struct multihop_conn *c = (struct multihop_conn *)uc;
|
||||
struct data_hdr msg;
|
||||
rimeaddr_t *nexthop;
|
||||
|
||||
@ -106,21 +106,21 @@ data_packet_received(struct unicast_conn *uc, rimeaddr_t *from)
|
||||
static const struct unicast_callbacks data_callbacks = { data_packet_received };
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
mh_open(struct mh_conn *c, uint16_t channel,
|
||||
const struct mh_callbacks *callbacks)
|
||||
multihop_open(struct multihop_conn *c, uint16_t channel,
|
||||
const struct multihop_callbacks *callbacks)
|
||||
{
|
||||
unicast_open(&c->c, channel, &data_callbacks);
|
||||
c->cb = callbacks;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
mh_close(struct mh_conn *c)
|
||||
multihop_close(struct multihop_conn *c)
|
||||
{
|
||||
unicast_close(&c->c);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
mh_send(struct mh_conn *c, rimeaddr_t *to)
|
||||
multihop_send(struct multihop_conn *c, rimeaddr_t *to)
|
||||
{
|
||||
rimeaddr_t *nexthop;
|
||||
struct data_hdr *hdr;
|
||||
@ -132,10 +132,10 @@ mh_send(struct mh_conn *c, rimeaddr_t *to)
|
||||
nexthop = c->cb->forward(c, &rimeaddr_node_addr, to, NULL, 0);
|
||||
|
||||
if(nexthop == NULL) {
|
||||
PRINTF("mh_send: no route\n");
|
||||
PRINTF("multihop_send: no route\n");
|
||||
return 0;
|
||||
} else {
|
||||
PRINTF("mh_send: sending data towards %d.%d\n",
|
||||
PRINTF("multihop_send: sending data towards %d.%d\n",
|
||||
nexthop->u8[0], nexthop->u8[1]);
|
||||
if(rimebuf_hdralloc(sizeof(struct data_hdr))) {
|
||||
hdr = rimebuf_hdrptr();
|
@ -4,17 +4,17 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup rimemh Best-effort multihop forwarding
|
||||
* \defgroup rimemultihop Best-effort multihop forwarding
|
||||
* @{
|
||||
*
|
||||
* The mh module implements a multihop forwarding mechanism. Routes
|
||||
* The multihop module implements a multihop forwarding mechanism. Routes
|
||||
* must have already been setup with the route_add() function. Setting
|
||||
* up routes is done with another Rime module such as the \ref
|
||||
* routediscovery "route-discovery module".
|
||||
*
|
||||
* \section channels Channels
|
||||
*
|
||||
* The mh module uses 1 channel.
|
||||
* The multihop module uses 1 channel.
|
||||
*
|
||||
*/
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: mh.h,v 1.7 2008/06/26 11:19:22 adamdunkels Exp $
|
||||
* $Id: multihop.h,v 1.1 2008/07/03 22:36:03 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -58,36 +58,36 @@
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __MH_H__
|
||||
#define __MH_H__
|
||||
#ifndef __MULTIHOP_H__
|
||||
#define __MULTIHOP_H__
|
||||
|
||||
#include "net/rime/unicast.h"
|
||||
#include "net/rime/rimeaddr.h"
|
||||
|
||||
struct mh_conn;
|
||||
struct multihop_conn;
|
||||
|
||||
struct mh_callbacks {
|
||||
void (* recv)(struct mh_conn *ptr,
|
||||
struct multihop_callbacks {
|
||||
void (* recv)(struct multihop_conn *ptr,
|
||||
rimeaddr_t *sender,
|
||||
rimeaddr_t *prevhop,
|
||||
uint8_t hops);
|
||||
rimeaddr_t *(* forward)(struct mh_conn *ptr,
|
||||
rimeaddr_t *(* forward)(struct multihop_conn *ptr,
|
||||
rimeaddr_t *originator,
|
||||
rimeaddr_t *dest,
|
||||
rimeaddr_t *prevhop,
|
||||
uint8_t hops);
|
||||
};
|
||||
|
||||
struct mh_conn {
|
||||
struct multihop_conn {
|
||||
struct unicast_conn c;
|
||||
const struct mh_callbacks *cb;
|
||||
const struct multihop_callbacks *cb;
|
||||
};
|
||||
|
||||
void mh_open(struct mh_conn *c, uint16_t channel,
|
||||
const struct mh_callbacks *u);
|
||||
void mh_close(struct mh_conn *c);
|
||||
int mh_send(struct mh_conn *c, rimeaddr_t *to);
|
||||
void multihop_open(struct multihop_conn *c, uint16_t channel,
|
||||
const struct multihop_callbacks *u);
|
||||
void multihop_close(struct multihop_conn *c);
|
||||
int multihop_send(struct multihop_conn *c, rimeaddr_t *to);
|
||||
|
||||
#endif /* __MH_H__ */
|
||||
#endif /* __MULTIHOP_H__ */
|
||||
/** @} */
|
||||
/** @} */
|
@ -28,12 +28,12 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: example-mh.c,v 1.2 2008/02/24 22:15:46 adamdunkels Exp $
|
||||
* $Id: example-multihop.c,v 1.1 2008/07/03 22:36:02 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Testing the multihop forwarding layer (mh) in Rime
|
||||
* Testing the multihop forwarding layer (multihop) in Rime
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
@ -47,31 +47,31 @@
|
||||
|
||||
#include <stdio.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(example_mh_process, "mh example");
|
||||
AUTOSTART_PROCESSES(&example_mh_process);
|
||||
PROCESS(example_multihop_process, "multihop example");
|
||||
AUTOSTART_PROCESSES(&example_multihop_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
recv(struct mh_conn *c, rimeaddr_t *sender)
|
||||
recv(struct multihop_conn *c, rimeaddr_t *sender)
|
||||
{
|
||||
printf("mh message received '%s'\n", (char *)rimebuf_dataptr());
|
||||
printf("multihop message received '%s'\n", (char *)rimebuf_dataptr());
|
||||
}
|
||||
static rimeaddr_t *
|
||||
forward(struct mh_conn *c, rimeaddr_t *originator, rimeaddr_t *dest,
|
||||
forward(struct multihop_conn *c, rimeaddr_t *originator, rimeaddr_t *dest,
|
||||
rimeaddr_t *prevhop, uint8_t hops)
|
||||
{
|
||||
printf("Forwarding message '%s'\n", (char *)rimebuf_dataptr());
|
||||
return NULL;
|
||||
}
|
||||
static const struct mh_callbacks mh_call = {recv, forward};
|
||||
static struct mh_conn mh;
|
||||
static const struct multihop_callbacks multihop_call = {recv, forward};
|
||||
static struct multihop_conn multihop;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(example_mh_process, ev, data)
|
||||
PROCESS_THREAD(example_multihop_process, ev, data)
|
||||
{
|
||||
PROCESS_EXITHANDLER(mh_close(&mh);)
|
||||
PROCESS_EXITHANDLER(multihop_close(&multihop);)
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
mh_open(&mh, 128, &mh_call);
|
||||
multihop_open(&multihop, 128, &multihop_call);
|
||||
|
||||
while(1) {
|
||||
static struct etimer et;
|
||||
@ -84,7 +84,7 @@ PROCESS_THREAD(example_mh_process, ev, data)
|
||||
rimebuf_copyfrom("Hej", 4);
|
||||
to.u8[0] = 161;
|
||||
to.u8[1] = 161;
|
||||
mh_send(&mh, &to);
|
||||
multihop_send(&multihop, &to);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user