Changed the 'ibc' and 'uc' Rime modules into the more descriptive names 'broadcast' and 'unicast'

This commit is contained in:
adamdunkels 2008-06-26 11:19:22 +00:00
parent 9d7c81d4ed
commit 63c620303a
21 changed files with 172 additions and 162 deletions

View file

@ -1,7 +1,7 @@
CHAMELEON=chameleon.c channel.c chameleon-raw.c chameleon-bitopt.c
CONTIKI_SOURCEFILES += rimebuf.c queuebuf.c rimeaddr.c ctimer.c rime.c timesynch.c \
rimestats.c ibc.c uc.c suc.c ruc.c sibc.c sabc.c abc.c nf.c \
rimestats.c broadcast.c unicast.c suc.c ruc.c sibc.c sabc.c abc.c nf.c \
mh.c rmh.c rucb.c polite.c ipolite.c neighbor-discovery.c \
mesh.c route.c route-discovery.c \
collect.c neighbor.c \

View file

@ -1,5 +1,5 @@
/**
* \addtogroup rimeibc
* \addtogroup rimebroadcast
* @{
*/
@ -33,12 +33,12 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ibc.c,v 1.14 2008/02/25 02:14:34 adamdunkels Exp $
* $Id: broadcast.c,v 1.1 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
* \file
* Identified best-effort local area broadcast (ibc)
* Identified best-effort local area broadcast (broadcast)
* \author
* Adam Dunkels <adam@sics.se>
*/
@ -48,7 +48,7 @@
static const struct rimebuf_attrlist attributes[] =
{
IBC_ATTRIBUTES RIMEBUF_ATTR_LAST
BROADCAST_ATTRIBUTES RIMEBUF_ATTR_LAST
};
#define DEBUG 0
@ -64,37 +64,37 @@ static void
recv_from_abc(struct abc_conn *bc)
{
rimeaddr_t sender;
struct ibc_conn *c = (struct ibc_conn *)bc;
struct broadcast_conn *c = (struct broadcast_conn *)bc;
rimeaddr_copy(&sender, rimebuf_addr(RIMEBUF_ADDR_SENDER));
PRINTF("%d.%d: ibc: from %d.%d\n",
PRINTF("%d.%d: broadcast: from %d.%d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
sender.u8[0], sender.u8[1]);
c->u->recv(c, &sender);
}
/*---------------------------------------------------------------------------*/
static const struct abc_callbacks ibc = {recv_from_abc};
static const struct abc_callbacks broadcast = {recv_from_abc};
/*---------------------------------------------------------------------------*/
void
ibc_open(struct ibc_conn *c, uint16_t channel,
const struct ibc_callbacks *u)
broadcast_open(struct broadcast_conn *c, uint16_t channel,
const struct broadcast_callbacks *u)
{
abc_open(&c->c, channel, &ibc);
abc_open(&c->c, channel, &broadcast);
c->u = u;
channel_set_attributes(channel, attributes);
}
/*---------------------------------------------------------------------------*/
void
ibc_close(struct ibc_conn *c)
broadcast_close(struct broadcast_conn *c)
{
abc_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int
ibc_send(struct ibc_conn *c)
broadcast_send(struct broadcast_conn *c)
{
PRINTF("%d.%d: ibc_send\n",
PRINTF("%d.%d: broadcast_send\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
rimebuf_set_addr(RIMEBUF_ADDR_SENDER, &rimeaddr_node_addr);
return abc_send(&c->c);

View file

@ -7,12 +7,12 @@
* \defgroup rimeibc Identified best-effort local area broadcast
* @{
*
* The ibc module sends packets to all local area neighbors with an a
* The broadcast module sends packets to all local area neighbors with an a
* header that identifies the sender.
*
* \section channels Channels
*
* The ibc module uses 1 channel.
* The broadcast module uses 1 channel.
*
*/
@ -46,7 +46,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ibc.h,v 1.11 2008/02/25 02:14:34 adamdunkels Exp $
* $Id: broadcast.h,v 1.1 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -56,77 +56,77 @@
* Adam Dunkels <adam@sics.se>
*/
#ifndef __IBC_H__
#define __IBC_H__
#ifndef __BROADCAST_H__
#define __BROADCAST_H__
#include "net/rime/abc.h"
#include "net/rime/rimeaddr.h"
struct ibc_conn;
struct broadcast_conn;
#define IBC_ATTRIBUTES { RIMEBUF_ADDR_SENDER, RIMEBUF_ADDRSIZE }, \
#define BROADCAST_ATTRIBUTES { RIMEBUF_ADDR_SENDER, RIMEBUF_ADDRSIZE }, \
ABC_ATTRIBUTES
/**
* \brief Callback structure for ibc
* \brief Callback structure for broadcast
*
*/
struct ibc_callbacks {
/** Called when a packet has been received by the ibc module. */
void (* recv)(struct ibc_conn *ptr, rimeaddr_t *sender);
struct broadcast_callbacks {
/** Called when a packet has been received by the broadcast module. */
void (* recv)(struct broadcast_conn *ptr, rimeaddr_t *sender);
};
struct ibc_conn {
struct broadcast_conn {
struct abc_conn c;
const struct ibc_callbacks *u;
const struct broadcast_callbacks *u;
};
/**
* \brief Set up an identified best-effort broadcast connection
* \param c A pointer to a struct ibc_conn
* \param c A pointer to a struct broadcast_conn
* \param channel The channel on which the connection will operate
* \param u A struct ibc_callbacks with function pointers to functions that will be called when a packet has been received
* \param u A struct broadcast_callbacks with function pointers to functions that will be called when a packet has been received
*
* This function sets up an ibc connection on the
* This function sets up a broadcast connection on the
* specified channel. The caller must have allocated the
* memory for the struct ibc_conn, usually by declaring it
* memory for the struct broadcast_conn, usually by declaring it
* as a static variable.
*
* The struct ibc_callbacks pointer must point to a structure
* The struct broadcast_callbacks pointer must point to a structure
* containing a pointer to a function that will be called
* when a packet arrives on the channel.
*
*/
void ibc_open(struct ibc_conn *c, uint16_t channel,
const struct ibc_callbacks *u);
void broadcast_open(struct broadcast_conn *c, uint16_t channel,
const struct broadcast_callbacks *u);
/**
* \brief Close an ibc connection
* \param c A pointer to a struct ibc_conn
* \brief Close a broadcast connection
* \param c A pointer to a struct broadcast_conn
*
* This function closes an ibc connection that has
* previously been opened with ibc_open().
* This function closes a broadcast connection that has
* previously been opened with broadcast_open().
*
* This function typically is called as an exit handler.
*
*/
void ibc_close(struct ibc_conn *c);
void broadcast_close(struct broadcast_conn *c);
/**
* \brief Send an identified best-effort broadcast packet
* \param c The ibc connection on which the packet should be sent
* \param c The broadcast connection on which the packet should be sent
* \retval Non-zero if the packet could be sent, zero otherwise
*
* This function sends an identified best-effort broadcast
* packet. The packet must be present in the rimebuf
* before this function is called.
*
* The parameter c must point to an ibc connection that
* must have previously been set up with ibc_open().
* The parameter c must point to a broadcast connection that
* must have previously been set up with broadcast_open().
*
*/
int ibc_send(struct ibc_conn *c);
int broadcast_send(struct broadcast_conn *c);
#endif /* __IBC_H__ */
#endif /* __BROADCAST_H__ */
/** @} */
/** @} */

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ipolite.c,v 1.7 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: ipolite.c,v 1.8 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -63,9 +63,9 @@
/*---------------------------------------------------------------------------*/
static void
recv(struct ibc_conn *ibc, rimeaddr_t *from)
recv(struct broadcast_conn *broadcast, rimeaddr_t *from)
{
struct ipolite_conn *c = (struct ipolite_conn *)ibc;
struct ipolite_conn *c = (struct ipolite_conn *)broadcast;
if(c->q != NULL &&
rimebuf_datalen() == queuebuf_datalen(c->q) &&
memcmp(rimebuf_dataptr(), queuebuf_dataptr(c->q),
@ -97,27 +97,27 @@ send(void *ptr)
queuebuf_to_rimebuf(c->q);
queuebuf_free(c->q);
c->q = NULL;
ibc_send(&c->c);
broadcast_send(&c->c);
if(c->cb->sent) {
c->cb->sent(c);
}
}
}
/*---------------------------------------------------------------------------*/
static const struct ibc_callbacks ibc = { recv };
static const struct broadcast_callbacks broadcast = { recv };
/*---------------------------------------------------------------------------*/
void
ipolite_open(struct ipolite_conn *c, uint16_t channel,
const struct ipolite_callbacks *cb)
{
ibc_open(&c->c, channel, &ibc);
broadcast_open(&c->c, channel, &broadcast);
c->cb = cb;
}
/*---------------------------------------------------------------------------*/
void
ipolite_close(struct ipolite_conn *c)
{
ibc_close(&c->c);
broadcast_close(&c->c);
ctimer_stop(&c->t);
if(c->q != NULL) {
queuebuf_free(c->q);
@ -138,7 +138,7 @@ ipolite_send(struct ipolite_conn *c, clock_time_t interval, uint8_t hdrsize)
if(interval == 0) {
PRINTF("%d.%d: ipolite_send: interval 0\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
ibc_send(&c->c);
broadcast_send(&c->c);
if(c->cb->sent) {
c->cb->sent(c);
}

View file

@ -46,7 +46,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ipolite.h,v 1.3 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: ipolite.h,v 1.4 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -59,7 +59,7 @@
#ifndef __IPOLITE_H__
#define __IPOLITE_H__
#include "net/rime/ibc.h"
#include "net/rime/broadcast.h"
#include "net/rime/ctimer.h"
#include "net/rime/queuebuf.h"
@ -72,7 +72,7 @@ struct ipolite_callbacks {
};
struct ipolite_conn {
struct ibc_conn c;
struct broadcast_conn c;
const struct ipolite_callbacks *cb;
struct ctimer t;
struct queuebuf *q;

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: mh.c,v 1.10 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: mh.c,v 1.11 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -67,7 +67,7 @@ struct data_hdr {
/*---------------------------------------------------------------------------*/
void
data_packet_received(struct uc_conn *uc, rimeaddr_t *from)
data_packet_received(struct unicast_conn *uc, rimeaddr_t *from)
{
struct mh_conn *c = (struct mh_conn *)uc;
struct data_hdr msg;
@ -98,25 +98,25 @@ data_packet_received(struct uc_conn *uc, rimeaddr_t *from)
}
if(nexthop) {
PRINTF("forwarding to %d.%d\n", nexthop->u8[0], nexthop->u8[1]);
uc_send(&c->c, nexthop);
unicast_send(&c->c, nexthop);
}
}
}
/*---------------------------------------------------------------------------*/
static const struct uc_callbacks data_callbacks = { data_packet_received };
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)
{
uc_open(&c->c, channel, &data_callbacks);
unicast_open(&c->c, channel, &data_callbacks);
c->cb = callbacks;
}
/*---------------------------------------------------------------------------*/
void
mh_close(struct mh_conn *c)
{
uc_close(&c->c);
unicast_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int
@ -142,7 +142,7 @@ mh_send(struct mh_conn *c, rimeaddr_t *to)
rimeaddr_copy(&hdr->dest, to);
rimeaddr_copy(&hdr->originator, &rimeaddr_node_addr);
hdr->hops = 1;
uc_send(&c->c, nexthop);
unicast_send(&c->c, nexthop);
}
return 1;
}

View file

@ -48,7 +48,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: mh.h,v 1.6 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: mh.h,v 1.7 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -61,7 +61,7 @@
#ifndef __MH_H__
#define __MH_H__
#include "net/rime/uc.h"
#include "net/rime/unicast.h"
#include "net/rime/rimeaddr.h"
struct mh_conn;
@ -79,7 +79,7 @@ struct mh_callbacks {
};
struct mh_conn {
struct uc_conn c;
struct unicast_conn c;
const struct mh_callbacks *cb;
};

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: neighbor-discovery.c,v 1.5 2008/02/25 02:14:34 adamdunkels Exp $
* $Id: neighbor-discovery.c,v 1.6 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -71,9 +71,9 @@ struct adv_msg {
#define MAX_HOPLIM 10
#define MAX_INTERVAL CLOCK_SECOND * 60
/*#define MAX_INTERVAL CLOCK_SECOND * 60
#define MIN_INTERVAL CLOCK_SECOND * 10
#define NEW_VAL_INTERVAL CLOCK_SECOND * 2
#define NEW_VAL_INTERVAL CLOCK_SECOND * 2*/
#define DEBUG 0
#if DEBUG
@ -125,12 +125,12 @@ send_timer(void *ptr)
{
struct neighbor_discovery_conn *tc = ptr;
send_adv(tc, MAX_INTERVAL);
send_adv(tc, tc->max_interval);
/* ctimer_set(&tc->t,
MIN_INTERVAL + random_rand() % (MAX_INTERVAL - MIN_INTERVAL),
send_timer, tc);*/
ctimer_set(&tc->t,
MAX_INTERVAL,
tc->max_interval,
send_timer, tc);
}
/*---------------------------------------------------------------------------*/
@ -141,11 +141,17 @@ static const struct ipolite_callbacks ipolite_callbacks =
/*---------------------------------------------------------------------------*/
void
neighbor_discovery_open(struct neighbor_discovery_conn *c, uint16_t channel,
const struct neighbor_discovery_callbacks *cb)
clock_time_t initial,
clock_time_t min,
clock_time_t max,
const struct neighbor_discovery_callbacks *cb)
{
/* ibc_open(&c->c, channel, &ibc_callbacks);*/
ipolite_open(&c->c, channel, &ipolite_callbacks);
c->u = cb;
c->initial_interval = initial;
c->min_interval = min;
c->max_interval = max;
}
/*---------------------------------------------------------------------------*/
void
@ -161,12 +167,12 @@ neighbor_discovery_start(struct neighbor_discovery_conn *c, uint16_t val)
{
if(val < c->val) {
c->val = val;
send_adv(c, NEW_VAL_INTERVAL);
ctimer_set(&c->t, NEW_VAL_INTERVAL, send_timer, c);
send_adv(c, c->initial_interval);
ctimer_set(&c->t, c->initial_interval, send_timer, c);
} else {
c->val = val;
send_adv(c, MIN_INTERVAL);
ctimer_set(&c->t, MIN_INTERVAL, send_timer, c);
send_adv(c, c->min_interval);
ctimer_set(&c->t, c->min_interval, send_timer, c);
}
}
/*---------------------------------------------------------------------------*/

View file

@ -47,7 +47,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: neighbor-discovery.h,v 1.4 2008/02/03 21:12:44 adamdunkels Exp $
* $Id: neighbor-discovery.h,v 1.5 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -60,7 +60,7 @@
#ifndef __NEIGHBOR_DISCOVERY_H__
#define __NEIGHBOR_DISCOVERY_H__
#include "net/rime/ibc.h"
#include "net/rime/broadcast.h"
#include "net/rime/ipolite.h"
struct neighbor_discovery_conn;
@ -72,15 +72,19 @@ struct neighbor_discovery_callbacks {
};
struct neighbor_discovery_conn {
/* struct ibc_conn c;*/
/* struct broadcast_conn c;*/
struct ipolite_conn c;
const struct neighbor_discovery_callbacks *u;
struct ctimer t;
clock_time_t initial_interval, min_interval, max_interval;
uint16_t val;
};
void neighbor_discovery_open(struct neighbor_discovery_conn *c,
uint16_t channel,
clock_time_t initial,
clock_time_t min,
clock_time_t max,
const struct neighbor_discovery_callbacks *u);
void neighbor_discovery_close(struct neighbor_discovery_conn *c);

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: route-discovery.c,v 1.9 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: route-discovery.c,v 1.10 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -112,7 +112,7 @@ send_rrep(struct route_discovery_conn *c, rimeaddr_t *dest)
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
dest->u8[0],dest->u8[1],
rt->nexthop.u8[0],rt->nexthop.u8[1]);
uc_send(&c->rrepconn, &rt->nexthop);
unicast_send(&c->rrepconn, &rt->nexthop);
}
}
/*---------------------------------------------------------------------------*/
@ -137,7 +137,7 @@ insert_route(rimeaddr_t *originator, rimeaddr_t *last_hop, uint8_t hops)
}
/*---------------------------------------------------------------------------*/
static void
rrep_packet_received(struct uc_conn *uc, rimeaddr_t *from)
rrep_packet_received(struct unicast_conn *uc, rimeaddr_t *from)
{
struct rrep_hdr *msg = rimebuf_dataptr();
struct route_entry *rt;
@ -166,7 +166,7 @@ rrep_packet_received(struct uc_conn *uc, rimeaddr_t *from)
if(rt != NULL) {
PRINTF("forwarding to %d\n", rt->nexthop.u16[0]);
msg->hops++;
uc_send(&c->rrepconn, &rt->nexthop);
unicast_send(&c->rrepconn, &rt->nexthop);
} else {
PRINTF("%d: no route to %d\n", rimeaddr_node_addr.u16[0], msg->dest.u16[0]);
}
@ -218,7 +218,7 @@ rreq_packet_received(struct nf_conn *nf, rimeaddr_t *from,
return 0; /* Don't forward packet. */
}
/*---------------------------------------------------------------------------*/
static const struct uc_callbacks rrep_callbacks = {rrep_packet_received};
static const struct unicast_callbacks rrep_callbacks = {rrep_packet_received};
static const struct nf_callbacks rreq_callbacks = {rreq_packet_received, NULL, NULL};
/*---------------------------------------------------------------------------*/
void
@ -228,14 +228,14 @@ route_discovery_open(struct route_discovery_conn *c,
const struct route_discovery_callbacks *callbacks)
{
nf_open(&c->rreqconn, time, channels + 0, &rreq_callbacks);
uc_open(&c->rrepconn, channels + 1, &rrep_callbacks);
unicast_open(&c->rrepconn, channels + 1, &rrep_callbacks);
c->cb = callbacks;
}
/*---------------------------------------------------------------------------*/
void
route_discovery_close(struct route_discovery_conn *c)
{
uc_close(&c->rrepconn);
unicast_close(&c->rrepconn);
nf_close(&c->rreqconn);
ctimer_stop(&c->t);
}

View file

@ -45,7 +45,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: route-discovery.h,v 1.5 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: route-discovery.h,v 1.6 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -58,7 +58,7 @@
#ifndef __ROUTE_DISCOVERY_H__
#define __ROUTE_DISCOVERY_H__
#include "net/rime/uc.h"
#include "net/rime/unicast.h"
#include "net/rime/nf.h"
struct route_discovery_conn;
@ -72,7 +72,7 @@ struct route_discovery_callbacks {
struct route_discovery_conn {
struct nf_conn rreqconn;
struct uc_conn rrepconn;
struct unicast_conn rrepconn;
struct ctimer t;
rimeaddr_t last_rreq_originator;
uint16_t last_rreq_id;

View file

@ -48,7 +48,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: sabc.h,v 1.8 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: sabc.h,v 1.9 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -61,7 +61,7 @@
#ifndef __SABC_H__
#define __SABC_H__
#include "net/rime/uc.h"
#include "net/rime/abc.h"
#include "net/rime/ctimer.h"
#include "net/rime/queuebuf.h"

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: sibc.c,v 1.7 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: sibc.c,v 1.8 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -49,29 +49,29 @@
/*---------------------------------------------------------------------------*/
static void
recv_from_ibc(struct ibc_conn *ibc, rimeaddr_t *from)
recv_from_broadcast(struct broadcast_conn *ibc, rimeaddr_t *from)
{
register struct sibc_conn *c = (struct sibc_conn *)ibc;
/* DEBUGF(3, "sibc: recv_from_ibc from %d\n", from_id);*/
/* DEBUGF(3, "sibc: recv_from_broadcast from %d\n", from_id);*/
if(c->u->recv != NULL) {
c->u->recv(c, from);
}
}
/*---------------------------------------------------------------------------*/
static const struct ibc_callbacks sibc = {recv_from_ibc};
static const struct broadcast_callbacks sibc = {recv_from_broadcast};
/*---------------------------------------------------------------------------*/
void
sibc_open(struct sibc_conn *c, uint16_t channel,
const struct sibc_callbacks *u)
{
ibc_open(&c->c, channel, &sibc);
broadcast_open(&c->c, channel, &sibc);
c->u = u;
}
/*---------------------------------------------------------------------------*/
void
sibc_close(struct sibc_conn *c)
{
ibc_close(&c->c);
broadcast_close(&c->c);
ctimer_stop(&c->t);
}
/*---------------------------------------------------------------------------*/
@ -82,7 +82,7 @@ send(void *ptr)
/* DEBUGF(3, "sibc: send()\n");*/
queuebuf_to_rimebuf(c->buf);
ibc_send(&c->c);
broadcast_send(&c->c);
ctimer_reset(&c->t);
if(c->u->sent != NULL) {
c->u->sent(c);

View file

@ -48,7 +48,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: sibc.h,v 1.7 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: sibc.h,v 1.8 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -61,7 +61,7 @@
#ifndef __SIBC_H__
#define __SIBC_H__
#include "net/rime/uc.h"
#include "net/rime/broadcast.h"
#include "net/rime/ctimer.h"
#include "net/rime/queuebuf.h"
@ -73,7 +73,7 @@ struct sibc_callbacks {
};
struct sibc_conn {
struct ibc_conn c;
struct broadcast_conn c;
struct ctimer t;
struct queuebuf *buf;
const struct sibc_callbacks *u;

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: suc.c,v 1.12 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: suc.c,v 1.13 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -57,7 +57,7 @@
/*---------------------------------------------------------------------------*/
static void
recv_from_uc(struct uc_conn *uc, rimeaddr_t *from)
recv_from_uc(struct unicast_conn *uc, rimeaddr_t *from)
{
register struct suc_conn *c = (struct suc_conn *)uc;
PRINTF("%d.%d: suc: recv_from_uc from %d.%d\n",
@ -68,20 +68,20 @@ recv_from_uc(struct uc_conn *uc, rimeaddr_t *from)
}
}
/*---------------------------------------------------------------------------*/
static const struct uc_callbacks suc = {recv_from_uc};
static const struct unicast_callbacks suc = {recv_from_uc};
/*---------------------------------------------------------------------------*/
void
suc_open(struct suc_conn *c, uint16_t channel,
const struct suc_callbacks *u)
{
uc_open(&c->c, channel, &suc);
unicast_open(&c->c, channel, &suc);
c->u = u;
}
/*---------------------------------------------------------------------------*/
void
suc_close(struct suc_conn *c)
{
uc_close(&c->c);
unicast_close(&c->c);
ctimer_stop(&c->t);
if(c->buf != NULL) {
queuebuf_free(c->buf);
@ -103,7 +103,7 @@ send(void *ptr)
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->receiver.u8[0], c->receiver.u8[1]);
queuebuf_to_rimebuf(c->buf);
uc_send(&c->c, &c->receiver);
unicast_send(&c->c, &c->receiver);
suc_set_timer(c, CLOCK_SECOND);
if(c->u->sent != NULL) {
c->u->sent(c);
@ -133,7 +133,7 @@ suc_send_stubborn(struct suc_conn *c, rimeaddr_t *receiver,
PRINTF("%d.%d: suc_send_stubborn to %d.%d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->receiver.u8[0],c->receiver.u8[1]);
uc_send(&c->c, &c->receiver);
unicast_send(&c->c, &c->receiver);
if(c->u->sent != NULL) {
c->u->sent(c);
}
@ -148,7 +148,7 @@ suc_send(struct suc_conn *c, rimeaddr_t *receiver)
PRINTF("%d.%d: suc_send to %d.%d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
receiver->u8[0], receiver->u8[1]);
return uc_send(&c->c, receiver);
return unicast_send(&c->c, receiver);
}
/*---------------------------------------------------------------------------*/
void

View file

@ -45,7 +45,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: suc.h,v 1.11 2008/02/25 02:14:35 adamdunkels Exp $
* $Id: suc.h,v 1.12 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -58,13 +58,13 @@
#ifndef __SUC_H__
#define __SUC_H__
#include "net/rime/uc.h"
#include "net/rime/unicast.h"
#include "net/rime/ctimer.h"
#include "net/rime/queuebuf.h"
struct suc_conn;
#define SUC_ATTRIBUTES UC_ATTRIBUTES
#define SUC_ATTRIBUTES UNICAST_ATTRIBUTES
struct suc_callbacks {
void (* recv)(struct suc_conn *c, rimeaddr_t *from);
@ -72,7 +72,7 @@ struct suc_callbacks {
};
struct suc_conn {
struct uc_conn c;
struct unicast_conn c;
struct ctimer t;
struct queuebuf *buf;
const struct suc_callbacks *u;

View file

@ -34,7 +34,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: uc.c,v 1.14 2008/02/25 02:14:35 adamdunkels Exp $
* $Id: unicast.c,v 1.1 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -45,12 +45,12 @@
*/
#include "net/rime.h"
#include "net/rime/uc.h"
#include "net/rime/unicast.h"
#include <string.h>
static const struct rimebuf_attrlist attributes[] =
{
UC_ATTRIBUTES
UNICAST_ATTRIBUTES
RIMEBUF_ATTR_LAST
};
@ -64,11 +64,11 @@ static const struct rimebuf_attrlist attributes[] =
/*---------------------------------------------------------------------------*/
static void
recv_from_ibc(struct ibc_conn *ibc, rimeaddr_t *from)
recv_from_broadcast(struct broadcast_conn *broadcast, rimeaddr_t *from)
{
struct uc_conn *c = (struct uc_conn *)ibc;
struct unicast_conn *c = (struct unicast_conn *)broadcast;
PRINTF("%d.%d: uc: recv_from_ibc, receiver %d.%d\n",
PRINTF("%d.%d: uc: recv_from_broadcast, receiver %d.%d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_addr(RIMEBUF_ADDR_RECEIVER)->u8[0],
rimebuf_addr(RIMEBUF_ADDR_RECEIVER)->u8[1]);
@ -77,31 +77,31 @@ recv_from_ibc(struct ibc_conn *ibc, rimeaddr_t *from)
}
}
/*---------------------------------------------------------------------------*/
static const struct ibc_callbacks uc = {recv_from_ibc};
static const struct broadcast_callbacks uc = {recv_from_broadcast};
/*---------------------------------------------------------------------------*/
void
uc_open(struct uc_conn *c, uint16_t channel,
const struct uc_callbacks *u)
unicast_open(struct unicast_conn *c, uint16_t channel,
const struct unicast_callbacks *u)
{
ibc_open(&c->c, channel, &uc);
broadcast_open(&c->c, channel, &uc);
c->u = u;
channel_set_attributes(channel, attributes);
}
/*---------------------------------------------------------------------------*/
void
uc_close(struct uc_conn *c)
unicast_close(struct unicast_conn *c)
{
ibc_close(&c->c);
broadcast_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int
uc_send(struct uc_conn *c, const rimeaddr_t *receiver)
unicast_send(struct unicast_conn *c, const rimeaddr_t *receiver)
{
PRINTF("%d.%d: uc_send to %d.%d\n",
PRINTF("%d.%d: unicast_send to %d.%d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
receiver->u8[0], receiver->u8[1]);
rimebuf_set_addr(RIMEBUF_ADDR_RECEIVER, receiver);
return ibc_send(&c->c);
return broadcast_send(&c->c);
}
/*---------------------------------------------------------------------------*/
/** @} */

View file

@ -45,7 +45,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: uc.h,v 1.8 2008/02/25 02:14:35 adamdunkels Exp $
* $Id: unicast.h,v 1.1 2008/06/26 11:19:22 adamdunkels Exp $
*/
/**
@ -55,31 +55,31 @@
* Adam Dunkels <adam@sics.se>
*/
#ifndef __UC_H__
#define __UC_H__
#ifndef __UNICAST_H__
#define __UNICAST_H__
#include "net/rime/ibc.h"
#include "net/rime/broadcast.h"
struct uc_conn;
struct unicast_conn;
#define UC_ATTRIBUTES { RIMEBUF_ADDR_RECEIVER, RIMEBUF_ADDRSIZE }, \
IBC_ATTRIBUTES
#define UNICAST_ATTRIBUTES { RIMEBUF_ADDR_RECEIVER, RIMEBUF_ADDRSIZE }, \
BROADCAST_ATTRIBUTES
struct uc_callbacks {
void (* recv)(struct uc_conn *c, rimeaddr_t *from);
struct unicast_callbacks {
void (* recv)(struct unicast_conn *c, rimeaddr_t *from);
};
struct uc_conn {
struct ibc_conn c;
const struct uc_callbacks *u;
struct unicast_conn {
struct broadcast_conn c;
const struct unicast_callbacks *u;
};
void uc_open(struct uc_conn *c, uint16_t channel,
const struct uc_callbacks *u);
void uc_close(struct uc_conn *c);
void unicast_open(struct unicast_conn *c, uint16_t channel,
const struct unicast_callbacks *u);
void unicast_close(struct unicast_conn *c);
int uc_send(struct uc_conn *c, const rimeaddr_t *receiver);
int unicast_send(struct unicast_conn *c, const rimeaddr_t *receiver);
#endif /* __UC_H__ */
#endif /* __UNICAST_H__ */
/** @} */
/** @} */

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: uip-over-mesh.c,v 1.8 2008/05/14 19:20:28 adamdunkels Exp $
* $Id: uip-over-mesh.c,v 1.9 2008/06/26 11:19:40 adamdunkels Exp $
*/
/**
@ -50,7 +50,7 @@
static struct queuebuf *queued_packet;
static rimeaddr_t queued_receiver;
static struct route_discovery_conn route_discovery;
static struct uc_conn dataconn;
static struct unicast_conn dataconn;
#define DEBUG 0
#if DEBUG
@ -68,7 +68,7 @@ static uip_ipaddr_t netaddr, netmask;
/*---------------------------------------------------------------------------*/
static void
recv_data(struct uc_conn *c, rimeaddr_t *from)
recv_data(struct unicast_conn *c, rimeaddr_t *from)
{
uip_len = rimebuf_copyto(&uip_buf[UIP_LLH_LEN]);
@ -85,7 +85,7 @@ send_data(rimeaddr_t *next)
PRINTF("uip-over-mesh: %d.%d: send_data with len %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_totlen());
uc_send(&dataconn, next);
unicast_send(&dataconn, next);
}
/*---------------------------------------------------------------------------*/
static void
@ -118,7 +118,7 @@ timedout(struct route_discovery_conn *c)
}
}
/*---------------------------------------------------------------------------*/
static const struct uc_callbacks data_callbacks = { recv_data };
static const struct unicast_callbacks data_callbacks = { recv_data };
static const struct route_discovery_callbacks rdc = { new_route, timedout };
/*---------------------------------------------------------------------------*/
void
@ -130,7 +130,7 @@ uip_over_mesh_init(u16_t channels)
uip_hostaddr.u8[0], uip_hostaddr.u8[1],
uip_hostaddr.u8[2], uip_hostaddr.u8[3]);
uc_open(&dataconn, channels, &data_callbacks);
unicast_open(&dataconn, channels, &data_callbacks);
route_discovery_open(&route_discovery, CLOCK_SECOND / 4,
channels + 1, &rdc);
/* tcpip_set_forwarding(1);*/

View file

@ -4,6 +4,6 @@ TARGET=netsim
endif
all: example-abc example-mesh example-collect example-trickle example-polite \
example-rudolph0 example-rudolph1 example-rudolph2 example-rucb \
example-ruc example-uc
example-ruc example-unicast
include $(CONTIKI)/Makefile.include

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: example-uc.c,v 1.1 2008/01/25 18:00:51 adamdunkels Exp $
* $Id: example-unicast.c,v 1.1 2008/06/26 11:20:22 adamdunkels Exp $
*/
/**
@ -48,25 +48,25 @@
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(test_uc_process, "uc test");
AUTOSTART_PROCESSES(&test_uc_process);
PROCESS(example_unicast_process, "Example unicast");
AUTOSTART_PROCESSES(&example_unicast_process);
/*---------------------------------------------------------------------------*/
static void
recv_uc(struct uc_conn *c, rimeaddr_t *from)
recv_uc(struct unicast_conn *c, rimeaddr_t *from)
{
printf("uc message received from %d.%d\n",
printf("unicast message received from %d.%d\n",
from->u8[0], from->u8[1]);
}
static const struct uc_callbacks uc_callbacks = {recv_uc};
static struct uc_conn uc;
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
static struct unicast_conn uc;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_uc_process, ev, data)
PROCESS_THREAD(example_unicast_process, ev, data)
{
PROCESS_EXITHANDLER(uc_close(&uc);)
PROCESS_EXITHANDLER(unicast_close(&uc);)
PROCESS_BEGIN();
uc_open(&uc, 128, &uc_callbacks);
unicast_open(&uc, 128, &unicast_callbacks);
while(1) {
static struct etimer et;
@ -79,7 +79,7 @@ PROCESS_THREAD(test_uc_process, ev, data)
rimebuf_copyfrom("Hello", 5);
addr.u8[0] = 41;
addr.u8[1] = 41;
uc_send(&uc, &addr);
unicast_send(&uc, &addr);
}