Renamed the rimebuf module to packetbuf to signal that the module is used outside of a pure Rime context (e.g., the sicslowpan code uses it).

This commit is contained in:
adamdunkels 2009-03-12 21:58:20 +00:00
parent 932fc9f748
commit 65eb5fd4e8
90 changed files with 690 additions and 687 deletions

View file

@ -1,5 +1,5 @@
RIME_CHAMELEON = chameleon.c channel.c chameleon-raw.c chameleon-bitopt.c
RIME_BASE = rimebuf.c queuebuf.c rimeaddr.c ctimer.c rime.c timesynch.c \
RIME_BASE = packetbuf.c queuebuf.c rimeaddr.c ctimer.c rime.c timesynch.c \
rimestats.c announcement.c polite-announcement.c
RIME_SINGLEHOP = broadcast.c stbroadcast.c unicast.c stunicast.c \
runicast.c abc.c \

View file

@ -36,7 +36,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: abc.c,v 1.18 2008/02/25 02:14:34 adamdunkels Exp $
* $Id: abc.c,v 1.19 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -58,8 +58,8 @@
#define PRINTF(...)
#endif
static const struct rimebuf_attrlist attributes[] =
{ ABC_ATTRIBUTES RIMEBUF_ATTR_LAST };
static const struct packetbuf_attrlist attributes[] =
{ ABC_ATTRIBUTES PACKETBUF_ATTR_LAST };
/*---------------------------------------------------------------------------*/
void

View file

@ -46,7 +46,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: abc.h,v 1.14 2008/02/25 02:14:34 adamdunkels Exp $
* $Id: abc.h,v 1.15 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
* \file
@ -58,7 +58,7 @@
#ifndef __ABC_H__
#define __ABC_H__
#include "net/rime/rimebuf.h"
#include "net/rime/packetbuf.h"
#include "net/rime/channel.h"
struct abc_conn;
@ -116,7 +116,7 @@ void abc_close(struct abc_conn *c);
* \retval Non-zero if the packet could be sent, zero otherwise
*
* This function sends an anonymous best-effort broadcast
* packet. The packet must be present in the rimebuf
* packet. The packet must be present in the packetbuf
* before this function is called.
*
* The parameter c must point to an abc connection that

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: broadcast.c,v 1.1 2008/06/26 11:19:22 adamdunkels Exp $
* $Id: broadcast.c,v 1.2 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -46,9 +46,9 @@
#include "contiki-net.h"
#include <string.h>
static const struct rimebuf_attrlist attributes[] =
static const struct packetbuf_attrlist attributes[] =
{
BROADCAST_ATTRIBUTES RIMEBUF_ATTR_LAST
BROADCAST_ATTRIBUTES PACKETBUF_ATTR_LAST
};
#define DEBUG 0
@ -66,7 +66,7 @@ recv_from_abc(struct abc_conn *bc)
rimeaddr_t sender;
struct broadcast_conn *c = (struct broadcast_conn *)bc;
rimeaddr_copy(&sender, rimebuf_addr(RIMEBUF_ADDR_SENDER));
rimeaddr_copy(&sender, packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTF("%d.%d: broadcast: from %d.%d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
@ -96,7 +96,7 @@ broadcast_send(struct broadcast_conn *c)
{
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);
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &rimeaddr_node_addr);
return abc_send(&c->c);
}
/*---------------------------------------------------------------------------*/

View file

@ -53,7 +53,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: broadcast.h,v 1.2 2009/03/07 11:15:46 adamdunkels Exp $
* $Id: broadcast.h,v 1.3 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -71,7 +71,7 @@
struct broadcast_conn;
#define BROADCAST_ATTRIBUTES { RIMEBUF_ADDR_SENDER, RIMEBUF_ADDRSIZE }, \
#define BROADCAST_ATTRIBUTES { PACKETBUF_ADDR_SENDER, PACKETBUF_ADDRSIZE }, \
ABC_ATTRIBUTES
/**
@ -125,7 +125,7 @@ void broadcast_close(struct broadcast_conn *c);
* \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
* packet. The packet must be present in the packetbuf
* before this function is called.
*
* The parameter c must point to a broadcast connection that

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: chameleon-bitopt.c,v 1.6 2009/02/10 23:49:58 adamdunkels Exp $
* $Id: chameleon-bitopt.c,v 1.7 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -110,7 +110,7 @@ get_bits(uint8_t *to, uint8_t *from, int bitpos, int vallen)
}
/*---------------------------------------------------------------------------*/
static int
header_size(const struct rimebuf_attrlist *a)
header_size(const struct packetbuf_attrlist *a)
{
int size, len;
@ -118,9 +118,9 @@ header_size(const struct rimebuf_attrlist *a)
all attributes that are used on this channel. */
size = 0;
for(; a->type != RIMEBUF_ATTR_NONE; ++a) {
for(; a->type != PACKETBUF_ATTR_NONE; ++a) {
/* PRINTF("chameleon header_size: header type %s (%d) len %d\n",
rimebuf_attr_strings[a->type],
packetbuf_attr_strings[a->type],
a->type,
a->len);*/
len = a->len;
@ -219,7 +219,7 @@ printhdr(uint8_t *hdr, int len)
static int
pack_header(struct channel *c)
{
const struct rimebuf_attrlist *a;
const struct packetbuf_attrlist *a;
int hdrbytesize;
int byteptr, bitptr, len;
uint8_t *hdrptr;
@ -229,32 +229,32 @@ pack_header(struct channel *c)
all attributes that are used on this channel. */
hdrbytesize = c->hdrsize / 8 + ((c->hdrsize & 7) == 0? 0: 1);
rimebuf_hdralloc(hdrbytesize);
hdrptr = rimebuf_hdrptr();
packetbuf_hdralloc(hdrbytesize);
hdrptr = packetbuf_hdrptr();
memset(hdrptr, 0, hdrbytesize);
byteptr = bitptr = 0;
for(a = c->attrlist; a->type != RIMEBUF_ATTR_NONE; ++a) {
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
PRINTF("%d.%d: pack_header type %s, len %d, bitptr %d, ",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr_strings[a->type], a->len, bitptr);
packetbuf_attr_strings[a->type], a->len, bitptr);
/* len = (a->len & 0xf8) + ((a->len & 7) ? 8: 0);*/
len = a->len;
byteptr = bitptr / 8;
if(a->type == RIMEBUF_ADDR_SENDER ||
a->type == RIMEBUF_ADDR_RECEIVER ||
a->type == RIMEBUF_ADDR_ESENDER ||
a->type == RIMEBUF_ADDR_ERECEIVER) {
if(a->type == PACKETBUF_ADDR_SENDER ||
a->type == PACKETBUF_ADDR_RECEIVER ||
a->type == PACKETBUF_ADDR_ESENDER ||
a->type == PACKETBUF_ADDR_ERECEIVER) {
set_bits(&hdrptr[byteptr], bitptr & 7,
(uint8_t *)rimebuf_addr(a->type), len);
(uint8_t *)packetbuf_addr(a->type), len);
PRINTF("address %d.%d\n",
/* rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],*/
((uint8_t *)rimebuf_addr(a->type))[0],
((uint8_t *)rimebuf_addr(a->type))[1]);
((uint8_t *)packetbuf_addr(a->type))[0],
((uint8_t *)packetbuf_addr(a->type))[1]);
} else {
rimebuf_attr_t val;
val = rimebuf_attr(a->type);
packetbuf_attr_t val;
val = packetbuf_attr(a->type);
set_bits(&hdrptr[byteptr], bitptr & 7,
(uint8_t *)&val, len);
PRINTF("value %d\n",
@ -266,8 +266,8 @@ pack_header(struct channel *c)
}
/* printhdr(hdrptr, hdrbytesize);*/
rimebuf_hdralloc(sizeof(struct bitopt_hdr));
hdr = (struct bitopt_hdr *)rimebuf_hdrptr();
packetbuf_hdralloc(sizeof(struct bitopt_hdr));
hdr = (struct bitopt_hdr *)packetbuf_hdrptr();
hdr->channel[0] = c->channelno & 0xff;
hdr->channel[1] = (c->channelno >> 8) & 0xff;
@ -277,7 +277,7 @@ pack_header(struct channel *c)
static struct channel *
unpack_header(void)
{
const struct rimebuf_attrlist *a;
const struct packetbuf_attrlist *a;
int byteptr, bitptr, len;
int hdrbytesize;
uint8_t *hdrptr;
@ -287,44 +287,44 @@ unpack_header(void)
/* The packet has a header that tells us what channel the packet is
for. */
hdr = (struct bitopt_hdr *)rimebuf_dataptr();
rimebuf_hdrreduce(sizeof(struct bitopt_hdr));
hdr = (struct bitopt_hdr *)packetbuf_dataptr();
packetbuf_hdrreduce(sizeof(struct bitopt_hdr));
c = channel_lookup((hdr->channel[1] << 8) + hdr->channel[0]);
if(c == NULL) {
PRINTF("chameleon-bitopt: input: channel %d not found\n", hdr->channel);
return NULL;
}
hdrptr = rimebuf_dataptr();
hdrptr = packetbuf_dataptr();
hdrbytesize = c->hdrsize / 8 + ((c->hdrsize & 7) == 0? 0: 1);
rimebuf_hdrreduce(hdrbytesize);
packetbuf_hdrreduce(hdrbytesize);
byteptr = bitptr = 0;
for(a = c->attrlist; a->type != RIMEBUF_ATTR_NONE; ++a) {
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
PRINTF("%d.%d: unpack_header type %s, len %d, bitptr %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr_strings[a->type], a->len, bitptr);
packetbuf_attr_strings[a->type], a->len, bitptr);
/* len = (a->len & 0xf8) + ((a->len & 7) ? 8: 0);*/
len = a->len;
byteptr = bitptr / 8;
if(a->type == RIMEBUF_ADDR_SENDER ||
a->type == RIMEBUF_ADDR_RECEIVER ||
a->type == RIMEBUF_ADDR_ESENDER ||
a->type == RIMEBUF_ADDR_ERECEIVER) {
if(a->type == PACKETBUF_ADDR_SENDER ||
a->type == PACKETBUF_ADDR_RECEIVER ||
a->type == PACKETBUF_ADDR_ESENDER ||
a->type == PACKETBUF_ADDR_ERECEIVER) {
rimeaddr_t addr;
get_bits((uint8_t *)&addr, &hdrptr[byteptr], bitptr & 7, len);
PRINTF("%d.%d: unpack_header type %s, addr %d.%d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr_strings[a->type],
packetbuf_attr_strings[a->type],
addr.u8[0], addr.u8[1]);
rimebuf_set_addr(a->type, &addr);
packetbuf_set_addr(a->type, &addr);
} else {
rimebuf_attr_t val = 0;
packetbuf_attr_t val = 0;
get_bits((uint8_t *)&val, &hdrptr[byteptr], bitptr & 7, len);
rimebuf_set_attr(a->type, val);
packetbuf_set_attr(a->type, val);
PRINTF("%d.%d: unpack_header type %s, val %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr_strings[a->type],
packetbuf_attr_strings[a->type],
val);
}
/* byteptr += len / 8;*/

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: chameleon-raw.c,v 1.5 2009/03/05 13:51:28 zhitao Exp $
* $Id: chameleon-raw.c,v 1.6 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -59,7 +59,7 @@ struct raw_hdr {
static struct channel *
input(void)
{
const struct rimebuf_attrlist *a;
const struct packetbuf_attrlist *a;
int byteptr, bitptr, len;
uint8_t *hdrptr;
struct raw_hdr *hdr;
@ -67,41 +67,41 @@ input(void)
/* The packet has a header that tells us what channel the packet is
for. */
hdr = (struct raw_hdr *)rimebuf_dataptr();
rimebuf_hdrreduce(sizeof(struct raw_hdr));
hdr = (struct raw_hdr *)packetbuf_dataptr();
packetbuf_hdrreduce(sizeof(struct raw_hdr));
c = channel_lookup(hdr->channel);
if(c == NULL) {
PRINTF("chameleon-raw: input: channel %d not found\n", hdr->channel);
return NULL;
}
hdrptr = rimebuf_dataptr();
rimebuf_hdrreduce(c->hdrsize);
hdrptr = packetbuf_dataptr();
packetbuf_hdrreduce(c->hdrsize);
byteptr = bitptr = 0;
for(a = c->attrlist; a->type != RIMEBUF_ATTR_NONE; ++a) {
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
PRINTF("%d.%d: unpack_header type %s, len %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr_strings[a->type], a->len);
packetbuf_attr_strings[a->type], a->len);
len = (a->len & 0xf8) + ((a->len & 7) ? 8: 0);
if(a->type == RIMEBUF_ADDR_SENDER ||
a->type == RIMEBUF_ADDR_RECEIVER ||
a->type == RIMEBUF_ADDR_ESENDER ||
a->type == RIMEBUF_ADDR_ERECEIVER) {
if(a->type == PACKETBUF_ADDR_SENDER ||
a->type == PACKETBUF_ADDR_RECEIVER ||
a->type == PACKETBUF_ADDR_ESENDER ||
a->type == PACKETBUF_ADDR_ERECEIVER) {
const rimeaddr_t addr;
memcpy((uint8_t *)&addr, &hdrptr[byteptr], len / 8);
PRINTF("%d.%d: unpack_header type %s, addr %d.%d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr_strings[a->type],
packetbuf_attr_strings[a->type],
addr.u8[0], addr.u8[1]);
rimebuf_set_addr(a->type, &addr);
packetbuf_set_addr(a->type, &addr);
} else {
rimebuf_attr_t val = 0;
packetbuf_attr_t val = 0;
memcpy((uint8_t *)&val, &hdrptr[byteptr], len / 8);
rimebuf_set_attr(a->type, val);
packetbuf_set_attr(a->type, val);
PRINTF("%d.%d: unpack_header type %s, val %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr_strings[a->type],
packetbuf_attr_strings[a->type],
val);
}
byteptr += len / 8;
@ -112,38 +112,38 @@ input(void)
static int
output(struct channel *c)
{
const struct rimebuf_attrlist *a;
const struct packetbuf_attrlist *a;
int byteptr, len;
uint8_t *hdrptr;
struct raw_hdr *hdr;
/* Compute the total size of the final header by summing the size of
all attributes that are used on this channel. */
rimebuf_hdralloc(c->hdrsize);
hdrptr = rimebuf_hdrptr();
packetbuf_hdralloc(c->hdrsize);
hdrptr = packetbuf_hdrptr();
byteptr = 0;
for(a = c->attrlist; a->type != RIMEBUF_ATTR_NONE; ++a) {
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
PRINTF("%d.%d: pack_header type %s, len %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr_strings[a->type], a->len);
packetbuf_attr_strings[a->type], a->len);
len = (a->len & 0xf8) + ((a->len & 7) ? 8: 0);
if(a->type == RIMEBUF_ADDR_SENDER ||
a->type == RIMEBUF_ADDR_RECEIVER ||
a->type == RIMEBUF_ADDR_ESENDER ||
a->type == RIMEBUF_ADDR_ERECEIVER) {
if(a->type == PACKETBUF_ADDR_SENDER ||
a->type == PACKETBUF_ADDR_RECEIVER ||
a->type == PACKETBUF_ADDR_ESENDER ||
a->type == PACKETBUF_ADDR_ERECEIVER) {
const rimeaddr_t *rimeaddr;
/* memcpy(&hdrptr[byteptr], (uint8_t *)rimebuf_attr_aget(a->type), len / 8);*/
rimeaddr = rimebuf_addr(a->type);
/* memcpy(&hdrptr[byteptr], (uint8_t *)packetbuf_attr_aget(a->type), len / 8);*/
rimeaddr = packetbuf_addr(a->type);
hdrptr[byteptr] = rimeaddr->u8[0];
hdrptr[byteptr + 1] = rimeaddr->u8[1];
PRINTF("%d.%d: address %d.%d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
((uint8_t *)rimebuf_addr(a->type))[0],
((uint8_t *)rimebuf_addr(a->type))[1]);
((uint8_t *)packetbuf_addr(a->type))[0],
((uint8_t *)packetbuf_addr(a->type))[1]);
} else {
rimebuf_attr_t val;
val = rimebuf_attr(a->type);
packetbuf_attr_t val;
val = packetbuf_attr(a->type);
memcpy(&hdrptr[byteptr], &val, len / 8);
PRINTF("%d.%d: value %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
@ -152,15 +152,15 @@ output(struct channel *c)
byteptr += len / 8;
}
rimebuf_hdralloc(sizeof(struct raw_hdr));
hdr = (struct raw_hdr *)rimebuf_hdrptr();
packetbuf_hdralloc(sizeof(struct raw_hdr));
hdr = (struct raw_hdr *)packetbuf_hdrptr();
hdr->channel = c->channelno;
return 1; /* Send out packet */
}
/*---------------------------------------------------------------------------*/
static int
hdrsize(const struct rimebuf_attrlist *a)
hdrsize(const struct packetbuf_attrlist *a)
{
int size, len;
@ -168,9 +168,9 @@ hdrsize(const struct rimebuf_attrlist *a)
all attributes that are used on this channel. */
size = 0;
for(; a->type != RIMEBUF_ATTR_NONE; ++a) {
for(; a->type != PACKETBUF_ATTR_NONE; ++a) {
/* PRINTF("chameleon header_size: header type %s (%d) len %d\n",
rimebuf_attr_strings[a->type],
packetbuf_attr_strings[a->type],
a->type,
a->len);*/
len = a->len;

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: chameleon.c,v 1.5 2008/08/15 18:59:22 adamdunkels Exp $
* $Id: chameleon.c,v 1.6 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -108,7 +108,7 @@ chameleon_input(void)
PRINTF("%d.%d: chameleon_input\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
#if DEBUG
printhdr(rimebuf_dataptr(), rimebuf_datalen());
printhdr(packetbuf_dataptr(), packetbuf_datalen());
#endif /* DEBUG */
if(header_module) {
c = header_module->input();
@ -116,7 +116,7 @@ chameleon_input(void)
PRINTF("%d.%d: chameleon_input channel %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->channelno);
rimebuf_set_attr(RIMEBUF_ATTR_CHANNEL, c->channelno);
packetbuf_set_attr(PACKETBUF_ATTR_CHANNEL, c->channelno);
abc_input(c);
} else {
PRINTF("%d.%d: chameleon_input channel not found for incoming packet\n",
@ -136,9 +136,9 @@ chameleon_output(struct channel *c)
if(header_module) {
ret = header_module->output(c);
rimebuf_set_attr(RIMEBUF_ATTR_CHANNEL, c->channelno);
packetbuf_set_attr(PACKETBUF_ATTR_CHANNEL, c->channelno);
#if DEBUG
printhdr(rimebuf_hdrptr(), rimebuf_hdrlen());
printhdr(packetbuf_hdrptr(), packetbuf_hdrlen());
#endif /* DEBUG */
if(ret) {
rime_output();
@ -149,7 +149,7 @@ chameleon_output(struct channel *c)
}
/*---------------------------------------------------------------------------*/
int
chameleon_hdrsize(const struct rimebuf_attrlist attrlist[])
chameleon_hdrsize(const struct packetbuf_attrlist attrlist[])
{
if(header_module != NULL &&
header_module->hdrsize != NULL) {

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: chameleon.h,v 1.1 2008/02/25 02:14:34 adamdunkels Exp $
* $Id: chameleon.h,v 1.2 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -49,13 +49,13 @@
struct chameleon_module {
struct channel *(* input)(void);
int (* output)(struct channel *);
int (* hdrsize)(const struct rimebuf_attrlist *);
int (* hdrsize)(const struct packetbuf_attrlist *);
void (* init)(void);
};
void chameleon_init(const struct chameleon_module *header_processing_module);
int chameleon_hdrsize(const struct rimebuf_attrlist attrlist[]);
int chameleon_hdrsize(const struct packetbuf_attrlist attrlist[]);
void chameleon_input(void);
int chameleon_output(struct channel *c);

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: channel.c,v 1.1 2008/02/25 02:14:34 adamdunkels Exp $
* $Id: channel.c,v 1.2 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -53,7 +53,7 @@ channel_init(void)
/*---------------------------------------------------------------------------*/
void
channel_set_attributes(uint16_t channelno,
const struct rimebuf_attrlist attrlist[])
const struct packetbuf_attrlist attrlist[])
{
struct channel *c;
c = channel_lookup(channelno);

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: channel.h,v 1.1 2008/02/25 02:14:34 adamdunkels Exp $
* $Id: channel.h,v 1.2 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -44,20 +44,20 @@
struct channel;
#include "contiki-conf.h"
#include "net/rime/rimebuf.h"
#include "net/rime/packetbuf.h"
#include "net/rime/chameleon.h"
struct channel {
struct channel *next;
uint16_t channelno;
const struct rimebuf_attrlist *attrlist;
const struct packetbuf_attrlist *attrlist;
uint8_t hdrsize;
};
struct channel *channel_lookup(uint16_t channelno);
void channel_set_attributes(uint16_t channelno,
const struct rimebuf_attrlist attrlist[]);
const struct packetbuf_attrlist attrlist[]);
void channel_open(struct channel *c, uint16_t channelno);
void channel_close(struct channel *c);
void channel_init(void);

View file

@ -36,7 +36,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: collect.c,v 1.22 2009/03/10 14:07:41 zhitao Exp $
* $Id: collect.c,v 1.23 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -62,10 +62,10 @@
#include <stdio.h>
#include <stddef.h>
static const struct rimebuf_attrlist attributes[] =
static const struct packetbuf_attrlist attributes[] =
{
COLLECT_ATTRIBUTES
RIMEBUF_ATTR_LAST
PACKETBUF_ATTR_LAST
};
#define NUM_RECENT_PACKETS 2
@ -157,18 +157,18 @@ node_packet_received(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno)
packet exists in the list, we drop the packet. */
for(i = 0; i < NUM_RECENT_PACKETS; i++) {
if(recent_packets[i].seqno == rimebuf_attr(RIMEBUF_ATTR_EPACKET_ID) &&
if(recent_packets[i].seqno == packetbuf_attr(PACKETBUF_ATTR_EPACKET_ID) &&
rimeaddr_cmp(&recent_packets[i].originator,
rimebuf_addr(RIMEBUF_ADDR_ESENDER))) {
packetbuf_addr(PACKETBUF_ADDR_ESENDER))) {
PRINTF("%d.%d: dropping duplicate packet with seqno %d\n",
rimebuf_attr(RIMEBUF_ATTR_EPACKET_ID));
packetbuf_attr(PACKETBUF_ATTR_EPACKET_ID));
/* Drop the packet. */
return;
}
}
recent_packets[recent_packet_ptr].seqno = rimebuf_attr(RIMEBUF_ATTR_EPACKET_ID);
recent_packets[recent_packet_ptr].seqno = packetbuf_attr(PACKETBUF_ATTR_EPACKET_ID);
rimeaddr_copy(&recent_packets[recent_packet_ptr].originator,
rimebuf_addr(RIMEBUF_ADDR_ESENDER));
packetbuf_addr(PACKETBUF_ADDR_ESENDER));
recent_packet_ptr = (recent_packet_ptr + 1) % NUM_RECENT_PACKETS;
if(tc->rtmetric == SINK) {
@ -177,29 +177,29 @@ node_packet_received(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno)
PRINTF("%d.%d: sink received packet from %d.%d via %d.%d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_addr(RIMEBUF_ADDR_ESENDER)->u8[0],
rimebuf_addr(RIMEBUF_ADDR_ESENDER)->u8[1],
packetbuf_addr(PACKETBUF_ADDR_ESENDER)->u8[0],
packetbuf_addr(PACKETBUF_ADDR_ESENDER)->u8[1],
from->u8[0], from->u8[1]);
if(tc->cb->recv != NULL) {
tc->cb->recv(rimebuf_addr(RIMEBUF_ADDR_ESENDER),
rimebuf_attr(RIMEBUF_ATTR_EPACKET_ID),
rimebuf_attr(RIMEBUF_ATTR_HOPS));
tc->cb->recv(packetbuf_addr(PACKETBUF_ADDR_ESENDER),
packetbuf_attr(PACKETBUF_ATTR_EPACKET_ID),
packetbuf_attr(PACKETBUF_ATTR_HOPS));
}
return;
} else if(rimebuf_attr(RIMEBUF_ATTR_TTL) > 1 &&
} else if(packetbuf_attr(PACKETBUF_ATTR_TTL) > 1 &&
tc->rtmetric != RTMETRIC_MAX) {
/* If we are not the sink, we forward the packet to the best
neighbor. */
rimebuf_set_attr(RIMEBUF_ATTR_HOPS, rimebuf_attr(RIMEBUF_ATTR_HOPS) + 1);
rimebuf_set_attr(RIMEBUF_ATTR_TTL, rimebuf_attr(RIMEBUF_ATTR_TTL) - 1);
packetbuf_set_attr(PACKETBUF_ATTR_HOPS, packetbuf_attr(PACKETBUF_ATTR_HOPS) + 1);
packetbuf_set_attr(PACKETBUF_ATTR_TTL, packetbuf_attr(PACKETBUF_ATTR_TTL) - 1);
PRINTF("%d.%d: packet received from %d.%d via %d.%d, forwarding %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_addr(RIMEBUF_ADDR_ESENDER)->u8[0],
rimebuf_addr(RIMEBUF_ADDR_ESENDER)->u8[1],
packetbuf_addr(PACKETBUF_ADDR_ESENDER)->u8[0],
packetbuf_addr(PACKETBUF_ADDR_ESENDER)->u8[1],
from->u8[0], from->u8[1], tc->forwarding);
if(!tc->forwarding) {
@ -209,7 +209,7 @@ node_packet_received(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno)
ether_set_line(n->addr.u8[0], n->addr.u8[1]);
#endif /* CONTIKI_TARGET_NETSIM */
tc->forwarding = 1;
runicast_send(c, &n->addr, rimebuf_attr(RIMEBUF_ATTR_MAX_REXMIT));
runicast_send(c, &n->addr, packetbuf_attr(PACKETBUF_ATTR_MAX_REXMIT));
} else {
PRINTF("%d.%d: did not find any neighbor to forward to\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
@ -341,18 +341,18 @@ collect_send(struct collect_conn *tc, int rexmits)
{
struct neighbor *n;
rimebuf_set_attr(RIMEBUF_ATTR_EPACKET_ID, tc->seqno++);
rimebuf_set_addr(RIMEBUF_ADDR_ESENDER, &rimeaddr_node_addr);
rimebuf_set_attr(RIMEBUF_ATTR_HOPS, 1);
rimebuf_set_attr(RIMEBUF_ATTR_TTL, MAX_HOPLIM);
rimebuf_set_attr(RIMEBUF_ATTR_MAX_REXMIT, rexmits);
packetbuf_set_attr(PACKETBUF_ATTR_EPACKET_ID, tc->seqno++);
packetbuf_set_addr(PACKETBUF_ADDR_ESENDER, &rimeaddr_node_addr);
packetbuf_set_attr(PACKETBUF_ATTR_HOPS, 1);
packetbuf_set_attr(PACKETBUF_ATTR_TTL, MAX_HOPLIM);
packetbuf_set_attr(PACKETBUF_ATTR_MAX_REXMIT, rexmits);
if(tc->rtmetric == 0) {
rimebuf_set_attr(RIMEBUF_ATTR_HOPS, 0);
packetbuf_set_attr(PACKETBUF_ATTR_HOPS, 0);
if(tc->cb->recv != NULL) {
tc->cb->recv(rimebuf_addr(RIMEBUF_ADDR_ESENDER),
rimebuf_attr(RIMEBUF_ATTR_EPACKET_ID),
rimebuf_attr(RIMEBUF_ATTR_HOPS));
tc->cb->recv(packetbuf_addr(PACKETBUF_ADDR_ESENDER),
packetbuf_attr(PACKETBUF_ATTR_EPACKET_ID),
packetbuf_attr(PACKETBUF_ATTR_HOPS));
}
return 1;
} else {

View file

@ -47,7 +47,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: collect.h,v 1.9 2009/02/09 20:58:25 adamdunkels Exp $
* $Id: collect.h,v 1.10 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -63,11 +63,11 @@
#include "net/rime/announcement.h"
#include "net/rime/runicast.h"
#define COLLECT_ATTRIBUTES { RIMEBUF_ADDR_ESENDER, RIMEBUF_ADDRSIZE }, \
{ RIMEBUF_ATTR_EPACKET_ID, RIMEBUF_ATTR_BIT * 2 }, \
{ RIMEBUF_ATTR_TTL, RIMEBUF_ATTR_BIT * 4 }, \
{ RIMEBUF_ATTR_HOPS, RIMEBUF_ATTR_BIT * 4 }, \
{ RIMEBUF_ATTR_MAX_REXMIT, RIMEBUF_ATTR_BIT * 3 }, \
#define COLLECT_ATTRIBUTES { PACKETBUF_ADDR_ESENDER, PACKETBUF_ADDRSIZE }, \
{ PACKETBUF_ATTR_EPACKET_ID, PACKETBUF_ATTR_BIT * 2 }, \
{ PACKETBUF_ATTR_TTL, PACKETBUF_ATTR_BIT * 4 }, \
{ PACKETBUF_ATTR_HOPS, PACKETBUF_ATTR_BIT * 4 }, \
{ PACKETBUF_ATTR_MAX_REXMIT, PACKETBUF_ATTR_BIT * 3 }, \
RUNICAST_ATTRIBUTES
struct collect_callbacks {

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ipolite.c,v 1.13 2009/03/02 11:22:09 adamdunkels Exp $
* $Id: ipolite.c,v 1.14 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -71,9 +71,9 @@ recv(struct broadcast_conn *broadcast, rimeaddr_t *from)
{
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),
MIN(c->hdrsize, rimebuf_datalen())) == 0) {
packetbuf_datalen() == queuebuf_datalen(c->q) &&
memcmp(packetbuf_dataptr(), queuebuf_dataptr(c->q),
MIN(c->hdrsize, packetbuf_datalen())) == 0) {
/* We received a copy of our own packet, so we do not send out
packet. */
queuebuf_free(c->q);
@ -98,7 +98,7 @@ send(void *ptr)
c->q);
if(c->q != NULL) {
queuebuf_to_rimebuf(c->q);
queuebuf_to_packetbuf(c->q);
queuebuf_free(c->q);
c->q = NULL;
broadcast_send(&c->c);
@ -150,7 +150,7 @@ ipolite_send(struct ipolite_conn *c, clock_time_t interval, uint8_t hdrsize)
}
} else {
c->q = queuebuf_new_from_rimebuf();
c->q = queuebuf_new_from_packetbuf();
if(c->q != NULL) {
ctimer_set(&c->t,
interval / 2 + (random_rand() % (interval / 2)),

View file

@ -81,7 +81,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ipolite.h,v 1.7 2009/03/07 11:15:46 adamdunkels Exp $
* $Id: ipolite.h,v 1.8 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -170,7 +170,7 @@ void ipolite_close(struct ipolite_conn *c);
* \param interval The timer interval in which the packet should be sent.
* \param hdrsize The size of the header that should be unique within the time interval.
*
* This function sends a packet from the rimebuf on the
* This function sends a packet from the packetbuf on the
* ipolite connection. The packet is sent some time during
* the time interval, but only if no other packet is
* received with the same header.

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: mesh.c,v 1.14 2008/07/03 22:36:02 adamdunkels Exp $
* $Id: mesh.c,v 1.15 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -96,7 +96,7 @@ found_route(struct route_discovery_conn *rdc, rimeaddr_t *dest)
if(c->queued_data != NULL &&
rimeaddr_cmp(dest, &c->queued_data_dest)) {
queuebuf_to_rimebuf(c->queued_data);
queuebuf_to_packetbuf(c->queued_data);
queuebuf_free(c->queued_data);
c->queued_data = NULL;
multihop_send(&c->multihop, dest);
@ -156,7 +156,7 @@ mesh_send(struct mesh_conn *c, rimeaddr_t *to)
}
PRINTF("mesh_send: queueing data, sending rreq\n");
c->queued_data = queuebuf_new_from_rimebuf();
c->queued_data = queuebuf_new_from_packetbuf();
rimeaddr_copy(&c->queued_data_dest, to);
route_discovery_discover(&c->route_discovery_conn, to,
PACKET_TIMEOUT);

View file

@ -49,7 +49,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: mesh.h,v 1.12 2008/07/03 22:36:02 adamdunkels Exp $
* $Id: mesh.h,v 1.13 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -126,7 +126,7 @@ void mesh_close(struct mesh_conn *c);
* \retval Non-zero if the packet could be queued for sending, zero otherwise
*
* This function sends a mesh packet. The packet must be
* present in the rimebuf before this function is called.
* present in the packetbuf before this function is called.
*
* The parameter c must point to an abc connection that
* must have previously been set up with mesh_open().

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: multihop.c,v 1.1 2008/07/03 22:36:03 adamdunkels Exp $
* $Id: multihop.c,v 1.2 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -73,28 +73,28 @@ data_packet_received(struct unicast_conn *uc, rimeaddr_t *from)
struct data_hdr msg;
rimeaddr_t *nexthop;
memcpy(&msg, rimebuf_dataptr(), sizeof(struct data_hdr));
memcpy(&msg, packetbuf_dataptr(), sizeof(struct data_hdr));
PRINTF("data_packet_received from %d.%d towards %d.%d len %d\n",
from->u8[0], from->u8[1],
msg.dest.u8[0], msg.dest.u8[1],
rimebuf_datalen());
packetbuf_datalen());
if(rimeaddr_cmp(&msg.dest, &rimeaddr_node_addr)) {
PRINTF("for us!\n");
rimebuf_hdrreduce(sizeof(struct data_hdr));
packetbuf_hdrreduce(sizeof(struct data_hdr));
if(c->cb->recv) {
c->cb->recv(c, &msg.originator, from, msg.hops);
}
} else {
nexthop = NULL;
if(c->cb->forward) {
rimebuf_hdrreduce(sizeof(struct data_hdr));
packetbuf_hdrreduce(sizeof(struct data_hdr));
nexthop = c->cb->forward(c, &msg.originator,
&msg.dest, from, msg.hops);
rimebuf_hdralloc(sizeof(struct data_hdr));
packetbuf_hdralloc(sizeof(struct data_hdr));
msg.hops++;
memcpy(rimebuf_hdrptr(), &msg, sizeof(struct data_hdr));
memcpy(packetbuf_hdrptr(), &msg, sizeof(struct data_hdr));
}
if(nexthop) {
PRINTF("forwarding to %d.%d\n", nexthop->u8[0], nexthop->u8[1]);
@ -128,7 +128,7 @@ multihop_send(struct multihop_conn *c, rimeaddr_t *to)
if(c->cb->forward == NULL) {
return 0;
}
rimebuf_compact();
packetbuf_compact();
nexthop = c->cb->forward(c, &rimeaddr_node_addr, to, NULL, 0);
if(nexthop == NULL) {
@ -137,8 +137,8 @@ multihop_send(struct multihop_conn *c, rimeaddr_t *to)
} else {
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();
if(packetbuf_hdralloc(sizeof(struct data_hdr))) {
hdr = packetbuf_hdrptr();
rimeaddr_copy(&hdr->dest, to);
rimeaddr_copy(&hdr->originator, &rimeaddr_node_addr);
hdr->hops = 1;

View file

@ -58,7 +58,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: multihop.h,v 1.3 2009/03/07 11:15:46 adamdunkels Exp $
* $Id: multihop.h,v 1.4 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -76,9 +76,9 @@
struct multihop_conn;
#define MULTIHOP_ATTRIBUTES { RIMEBUF_ADDR_ESENDER, RIMEBUF_ADDRSIZE }, \
{ RIMEBUF_ADDR_ERECEIVER, RIMEBUF_ADDRSIZE }, \
{ RIMEBUF_ATTR_TTL, RIMEBUF_ATTR_BIT * 5 }, \
#define MULTIHOP_ATTRIBUTES { PACKETBUF_ADDR_ESENDER, PACKETBUF_ADDRSIZE }, \
{ PACKETBUF_ADDR_ERECEIVER, PACKETBUF_ADDRSIZE }, \
{ PACKETBUF_ATTR_TTL, PACKETBUF_ATTR_BIT * 5 }, \
UNICAST_ATTRIBUTES

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: neighbor-discovery.c,v 1.13 2009/02/11 11:08:56 adamdunkels Exp $
* $Id: neighbor-discovery.c,v 1.14 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -89,9 +89,9 @@ send_adv(void *ptr)
struct neighbor_discovery_conn *c = ptr;
struct adv_msg *hdr;
rimebuf_clear();
rimebuf_set_datalen(sizeof(struct adv_msg));
hdr = rimebuf_dataptr();
packetbuf_clear();
packetbuf_set_datalen(sizeof(struct adv_msg));
hdr = packetbuf_dataptr();
hdr->val = c->val;
broadcast_send(&c->c);
if(c->u->sent) {
@ -106,7 +106,7 @@ static void
adv_packet_received(struct broadcast_conn *ibc, rimeaddr_t *from)
{
struct neighbor_discovery_conn *c = (struct neighbor_discovery_conn *)ibc;
struct adv_msg *msg = rimebuf_dataptr();
struct adv_msg *msg = packetbuf_dataptr();
PRINTF("%d.%d: adv_packet_received from %d.%d with val %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: netflood.c,v 1.2 2009/02/11 11:08:56 adamdunkels Exp $
* $Id: netflood.c,v 1.3 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -76,16 +76,16 @@ static void
recv_from_ipolite(struct ipolite_conn *ipolite, rimeaddr_t *from)
{
struct netflood_conn *c = (struct netflood_conn *)ipolite;
struct netflood_hdr *hdr = rimebuf_dataptr();
struct netflood_hdr *hdr = packetbuf_dataptr();
uint8_t hops;
struct queuebuf *queuebuf;
hops = hdr->hops;
/* Remember packet if we need to forward it. */
queuebuf = queuebuf_new_from_rimebuf();
queuebuf = queuebuf_new_from_packetbuf();
rimebuf_hdrreduce(sizeof(struct netflood_hdr));
packetbuf_hdrreduce(sizeof(struct netflood_hdr));
if(c->u->recv != NULL) {
if(!(rimeaddr_cmp(&hdr->originator, &c->last_originator) &&
hdr->originator_seqno <= c->last_originator_seqno)) {
@ -94,10 +94,10 @@ recv_from_ipolite(struct ipolite_conn *ipolite, rimeaddr_t *from)
hops)) {
if(queuebuf != NULL) {
queuebuf_to_rimebuf(queuebuf);
queuebuf_to_packetbuf(queuebuf);
queuebuf_free(queuebuf);
queuebuf = NULL;
hdr = rimebuf_dataptr();
hdr = packetbuf_dataptr();
/* Rebroadcast received packet. */
if(hops < HOPS_MAX) {
@ -160,15 +160,15 @@ netflood_close(struct netflood_conn *c)
int
netflood_send(struct netflood_conn *c, uint8_t seqno)
{
if(rimebuf_hdralloc(sizeof(struct netflood_hdr))) {
struct netflood_hdr *hdr = rimebuf_hdrptr();
if(packetbuf_hdralloc(sizeof(struct netflood_hdr))) {
struct netflood_hdr *hdr = packetbuf_hdrptr();
rimeaddr_copy(&hdr->originator, &rimeaddr_node_addr);
rimeaddr_copy(&c->last_originator, &hdr->originator);
c->last_originator_seqno = hdr->originator_seqno = seqno;
hdr->hops = 0;
PRINTF("%d.%d: netflood sending '%s'\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
(char *)rimebuf_dataptr());
(char *)packetbuf_dataptr());
return ipolite_send(&c->c, 0, 4);
}
return 0;

View file

@ -62,7 +62,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: netflood.h,v 1.3 2009/03/07 11:15:46 adamdunkels Exp $
* $Id: netflood.h,v 1.4 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -82,9 +82,9 @@
struct netflood_conn;
#define NETFLOOD_ATTRIBUTES { RIMEBUF_ADDR_ESENDER, RIMEBUF_ADDRSIZE }, \
{ RIMEBUF_ATTR_HOPS, RIMEBUF_ATTR_BIT * 5 }, \
{ RIMEBUF_ATTR_EPACKET_ID, RIMEBUF_ATTR_BIT * 4 }, \
#define NETFLOOD_ATTRIBUTES { PACKETBUF_ADDR_ESENDER, PACKETBUF_ADDRSIZE }, \
{ PACKETBUF_ATTR_HOPS, PACKETBUF_ATTR_BIT * 5 }, \
{ PACKETBUF_ATTR_EPACKET_ID, PACKETBUF_ATTR_BIT * 4 }, \
IPOLITE_ATTRIBUTES
struct netflood_callbacks {

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: polite-announcement.c,v 1.1 2009/02/05 19:32:01 adamdunkels Exp $
* $Id: polite-announcement.c,v 1.2 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -93,8 +93,8 @@ send_adv(clock_time_t interval)
struct announcement_msg *adata;
struct announcement *a;
rimebuf_clear();
adata = rimebuf_dataptr();
packetbuf_clear();
adata = packetbuf_dataptr();
adata->num = 0;
for(a = announcement_list(); a != NULL; a = a->next) {
adata->data[adata->num].id = a->id;
@ -102,19 +102,19 @@ send_adv(clock_time_t interval)
adata->num++;
}
rimebuf_set_datalen(ANNOUNCEMENT_MSG_HEADERLEN +
packetbuf_set_datalen(ANNOUNCEMENT_MSG_HEADERLEN +
sizeof(struct announcement_data) * adata->num);
PRINTF("%d.%d: sending neighbor advertisement with %d announcements\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], adata->num);
ipolite_send(&c.c, interval, rimebuf_datalen());
ipolite_send(&c.c, interval, packetbuf_datalen());
}
/*---------------------------------------------------------------------------*/
static void
adv_packet_received(struct ipolite_conn *ipolite, rimeaddr_t *from)
{
struct announcement_msg *adata = rimebuf_dataptr();
struct announcement_msg *adata = packetbuf_dataptr();
int i;
PRINTF("%d.%d: adv_packet_received from %d.%d with %d announcements\n",

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: polite.c,v 1.8 2009/03/02 11:22:09 adamdunkels Exp $
* $Id: polite.c,v 1.9 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -64,9 +64,9 @@ recv(struct abc_conn *abc)
{
struct polite_conn *c = (struct polite_conn *)abc;
if(c->q != NULL &&
rimebuf_datalen() == queuebuf_datalen(c->q) &&
memcmp(rimebuf_dataptr(), queuebuf_dataptr(c->q),
MIN(c->hdrsize, rimebuf_datalen())) == 0) {
packetbuf_datalen() == queuebuf_datalen(c->q) &&
memcmp(packetbuf_dataptr(), queuebuf_dataptr(c->q),
MIN(c->hdrsize, packetbuf_datalen())) == 0) {
/* We received a copy of our own packet, so we do not send out
packet. */
queuebuf_free(c->q);
@ -87,7 +87,7 @@ send(void *ptr)
struct polite_conn *c = ptr;
if(c->q != NULL) {
queuebuf_to_rimebuf(c->q);
queuebuf_to_packetbuf(c->q);
queuebuf_free(c->q);
c->q = NULL;
abc_send(&c->c);
@ -126,7 +126,7 @@ polite_send(struct polite_conn *c, clock_time_t interval, uint8_t hdrsize)
queuebuf_free(c->q);
}
c->hdrsize = hdrsize;
c->q = queuebuf_new_from_rimebuf();
c->q = queuebuf_new_from_packetbuf();
if(c->q != NULL) {
ctimer_set(&c->t, interval / 2 + (random_rand() % (interval / 2)), send, c);
return 1;

View file

@ -81,7 +81,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: polite.h,v 1.6 2009/03/07 11:15:46 adamdunkels Exp $
* $Id: polite.h,v 1.7 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -170,7 +170,7 @@ void polite_close(struct polite_conn *c);
* \param interval The timer interval in which the packet should be sent.
* \param hdrsize The size of the header that should be unique within the time interval.
*
* This function sends a packet from the rimebuf on the
* This function sends a packet from the packetbuf on the
* polite connection. The packet is sent some time during
* the time interval, but only if no other packet is
* received with the same header.

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: queuebuf.c,v 1.13 2008/11/17 22:52:10 oliverschmidt Exp $
* $Id: queuebuf.c,v 1.14 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -61,15 +61,15 @@
struct queuebuf {
uint16_t len;
uint8_t data[RIMEBUF_SIZE + RIMEBUF_HDR_SIZE];
struct rimebuf_attr attrs[RIMEBUF_NUM_ATTRS];
struct rimebuf_addr addrs[RIMEBUF_NUM_ADDRS];
uint8_t data[PACKETBUF_SIZE + PACKETBUF_HDR_SIZE];
struct packetbuf_attr attrs[PACKETBUF_NUM_ATTRS];
struct packetbuf_addr addrs[PACKETBUF_NUM_ADDRS];
};
struct queuebuf_ref {
uint16_t len;
uint8_t *ref;
uint8_t hdr[RIMEBUF_HDR_SIZE];
uint8_t hdr[PACKETBUF_HDR_SIZE];
uint8_t hdrlen;
};
@ -101,12 +101,12 @@ queuebuf_init(void)
}
/*---------------------------------------------------------------------------*/
struct queuebuf *
queuebuf_new_from_rimebuf(void)
queuebuf_new_from_packetbuf(void)
{
struct queuebuf *buf;
struct queuebuf_ref *rbuf;
if(rimebuf_is_reference()) {
if(packetbuf_is_reference()) {
rbuf = memb_alloc(&refbufmem);
if(rbuf != NULL) {
#if QUEUEBUF_STATS
@ -117,11 +117,11 @@ queuebuf_new_from_rimebuf(void)
queuebuf_ref_len);*/
#endif /* CONTIKI_TARGET_NETSIM */
#endif /* QUEUEBUF_STATS */
rbuf->len = rimebuf_datalen();
rbuf->ref = rimebuf_reference_ptr();
rbuf->hdrlen = rimebuf_copyto_hdr(rbuf->hdr);
rbuf->len = packetbuf_datalen();
rbuf->ref = packetbuf_reference_ptr();
rbuf->hdrlen = packetbuf_copyto_hdr(rbuf->hdr);
} else {
PRINTF("queuebuf_new_from_rimebuf: could not allocate a reference queuebuf\n");
PRINTF("queuebuf_new_from_packetbuf: could not allocate a reference queuebuf\n");
}
return (struct queuebuf *)rbuf;
} else {
@ -140,10 +140,10 @@ queuebuf_new_from_rimebuf(void)
queuebuf_ref_len);*/
#endif /* CONTIKI_TARGET_NETSIM */
#endif /* QUEUEBUF_STATS */
buf->len = rimebuf_copyto(buf->data);
rimebuf_attr_copyto(buf->attrs, buf->addrs);
buf->len = packetbuf_copyto(buf->data);
packetbuf_attr_copyto(buf->attrs, buf->addrs);
} else {
PRINTF("queuebuf_new_from_rimebuf: could not allocate a queuebuf\n");
PRINTF("queuebuf_new_from_packetbuf: could not allocate a queuebuf\n");
}
return buf;
}
@ -176,19 +176,19 @@ queuebuf_free(struct queuebuf *buf)
}
/*---------------------------------------------------------------------------*/
void
queuebuf_to_rimebuf(struct queuebuf *b)
queuebuf_to_packetbuf(struct queuebuf *b)
{
struct queuebuf_ref *r;
if(memb_inmemb(&bufmem, b)) {
rimebuf_copyfrom(b->data, b->len);
rimebuf_attr_copyfrom(b->attrs, b->addrs);
packetbuf_copyfrom(b->data, b->len);
packetbuf_attr_copyfrom(b->attrs, b->addrs);
} else if(memb_inmemb(&refbufmem, b)) {
r = (struct queuebuf_ref *)b;
rimebuf_clear();
rimebuf_copyfrom(r->ref, r->len);
rimebuf_hdralloc(r->hdrlen);
memcpy(rimebuf_hdrptr(), r->hdr, r->hdrlen);
packetbuf_clear();
packetbuf_copyfrom(r->ref, r->len);
packetbuf_hdralloc(r->hdrlen);
memcpy(packetbuf_hdrptr(), r->hdr, r->hdrlen);
}
}
/*---------------------------------------------------------------------------*/

View file

@ -41,7 +41,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: queuebuf.h,v 1.5 2007/03/31 18:31:28 adamdunkels Exp $
* $Id: queuebuf.h,v 1.6 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -54,15 +54,15 @@
#ifndef __QUEUEBUF_H__
#define __QUEUEBUF_H__
#include "net/rime/rimebuf.h"
#include "net/rime/packetbuf.h"
struct queuebuf;
void queuebuf_init(void);
struct queuebuf *queuebuf_new_from_rimebuf(void);
struct queuebuf *queuebuf_new_from_packetbuf(void);
void queuebuf_free(struct queuebuf *b);
void queuebuf_to_rimebuf(struct queuebuf *b);
void queuebuf_to_packetbuf(struct queuebuf *b);
void *queuebuf_dataptr(struct queuebuf *b);
int queuebuf_datalen(struct queuebuf *b);

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rime.c,v 1.20 2009/03/01 10:43:57 adamdunkels Exp $
* $Id: rime.c,v 1.21 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -111,7 +111,7 @@ rime_init(const struct mac_driver *m)
{
queuebuf_init();
route_init();
rimebuf_clear();
packetbuf_clear();
neighbor_init();
announcement_init();
rime_mac = m;
@ -139,7 +139,7 @@ rime_output(void)
struct rime_sniffer *s;
RIMESTATS_ADD(tx);
rimebuf_compact();
packetbuf_compact();
if(rime_mac) {
if(rime_mac->send()) {

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rmh.c,v 1.7 2008/07/03 21:52:25 adamdunkels Exp $
* $Id: rmh.c,v 1.8 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -67,16 +67,16 @@ static void
received(struct runicast_conn *uc, rimeaddr_t *from, uint8_t seqno)
{
struct rmh_conn *c = (struct rmh_conn *)uc;
struct data_hdr *msg = rimebuf_dataptr();
struct data_hdr *msg = packetbuf_dataptr();
rimeaddr_t *nexthop;
PRINTF("data_packet_received from %d towards %d len %d\n", from->u16[0],
msg->dest.u16[0],
rimebuf_datalen());
packetbuf_datalen());
if(rimeaddr_cmp(&msg->dest, &rimeaddr_node_addr)) {
PRINTF("for us!\n");
rimebuf_hdrreduce(sizeof(struct data_hdr));
packetbuf_hdrreduce(sizeof(struct data_hdr));
if(c->cb->recv) {
c->cb->recv(c, &msg->originator, msg->hops);
}
@ -144,8 +144,8 @@ rmh_send(struct rmh_conn *c, rimeaddr_t *to, uint8_t num_rexmit, uint8_t max_hop
PRINTF("rmh_send: sending data\n");
if(rimebuf_hdralloc(sizeof(struct data_hdr))) {
hdr = rimebuf_hdrptr();
if(packetbuf_hdralloc(sizeof(struct data_hdr))) {
hdr = packetbuf_hdrptr();
rimeaddr_copy(&hdr->dest, to);
rimeaddr_copy(&hdr->originator, &rimeaddr_node_addr);
hdr->hops = 1;

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: route-discovery.c,v 1.13 2009/01/21 14:29:24 fros4943 Exp $
* $Id: route-discovery.c,v 1.14 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -82,9 +82,9 @@ send_rreq(struct route_discovery_conn *c, rimeaddr_t *dest)
{
struct route_msg *msg;
rimebuf_clear();
msg = rimebuf_dataptr();
rimebuf_set_datalen(sizeof(struct route_msg));
packetbuf_clear();
msg = packetbuf_dataptr();
packetbuf_set_datalen(sizeof(struct route_msg));
msg->pad = 0;
msg->rreq_id = c->rreq_id;
@ -100,9 +100,9 @@ send_rrep(struct route_discovery_conn *c, rimeaddr_t *dest)
struct rrep_hdr *rrepmsg;
struct route_entry *rt;
rimebuf_clear();
rrepmsg = rimebuf_dataptr();
rimebuf_set_datalen(sizeof(struct rrep_hdr));
packetbuf_clear();
rrepmsg = packetbuf_dataptr();
packetbuf_set_datalen(sizeof(struct rrep_hdr));
rrepmsg->hops = 0;
rimeaddr_copy(&rrepmsg->dest, dest);
rimeaddr_copy(&rrepmsg->originator, &rimeaddr_node_addr);
@ -139,7 +139,7 @@ insert_route(rimeaddr_t *originator, rimeaddr_t *last_hop, uint8_t hops)
static void
rrep_packet_received(struct unicast_conn *uc, rimeaddr_t *from)
{
struct rrep_hdr *msg = rimebuf_dataptr();
struct rrep_hdr *msg = packetbuf_dataptr();
struct route_entry *rt;
rimeaddr_t dest;
struct route_discovery_conn *c = (struct route_discovery_conn *)
@ -149,7 +149,7 @@ rrep_packet_received(struct unicast_conn *uc, rimeaddr_t *from)
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
from->u8[0],from->u8[1],
msg->dest.u8[0],msg->dest.u8[1],
rimebuf_datalen());
packetbuf_datalen());
insert_route(&msg->originator, from, msg->hops);
@ -178,7 +178,7 @@ static int
rreq_packet_received(struct netflood_conn *nf, rimeaddr_t *from,
rimeaddr_t *originator, uint8_t seqno, uint8_t hops)
{
struct route_msg *msg = rimebuf_dataptr();
struct route_msg *msg = packetbuf_dataptr();
struct route_discovery_conn *c = (struct route_discovery_conn *)
((char *)nf - offsetof(struct route_discovery_conn, rreqconn));

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rucb.c,v 1.8 2008/07/03 21:52:25 adamdunkels Exp $
* $Id: rucb.c,v 1.9 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -59,12 +59,12 @@ read_data(struct rucb_conn *c)
{
int len = 0;
rimebuf_clear();
packetbuf_clear();
if(c->u->read_chunk) {
len = c->u->read_chunk(c, c->chunk * RUCB_DATASIZE,
rimebuf_dataptr(), RUCB_DATASIZE);
packetbuf_dataptr(), RUCB_DATASIZE);
}
rimebuf_set_datalen(len);
packetbuf_set_datalen(len);
return len;
}
/*---------------------------------------------------------------------------*/
@ -102,7 +102,7 @@ recv(struct runicast_conn *ruc, rimeaddr_t *from, uint8_t seqno)
PRINTF("%d.%d: rucb: recv from %d.%d len %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
from->u8[0], from->u8[1], rimebuf_totlen());
from->u8[0], from->u8[1], packetbuf_totlen());
if(seqno == c->last_seqno) {
return;
@ -111,28 +111,28 @@ recv(struct runicast_conn *ruc, rimeaddr_t *from, uint8_t seqno)
if(rimeaddr_cmp(&c->sender, &rimeaddr_null)) {
rimeaddr_copy(&c->sender, from);
c->u->write_chunk(c, 0, RUCB_FLAG_NEWFILE, rimebuf_dataptr(), 0);
c->u->write_chunk(c, 0, RUCB_FLAG_NEWFILE, packetbuf_dataptr(), 0);
c->chunk = 0;
}
if(rimeaddr_cmp(&c->sender, from)) {
int datalen = rimebuf_datalen();
int datalen = packetbuf_datalen();
if(datalen < RUCB_DATASIZE) {
PRINTF("%d.%d: get %d bytes, file complete\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
datalen);
c->u->write_chunk(c, c->chunk * RUCB_DATASIZE,
RUCB_FLAG_LASTCHUNK, rimebuf_dataptr(), datalen);
RUCB_FLAG_LASTCHUNK, packetbuf_dataptr(), datalen);
} else {
c->u->write_chunk(c, c->chunk * RUCB_DATASIZE,
RUCB_FLAG_NONE, rimebuf_dataptr(), datalen);
RUCB_FLAG_NONE, packetbuf_dataptr(), datalen);
}
c->chunk++;
}
if(rimebuf_datalen() < RUCB_DATASIZE) {
if(packetbuf_datalen() < RUCB_DATASIZE) {
rimeaddr_copy(&c->sender, &rimeaddr_null);
}
}

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rudolph0.c,v 1.10 2008/06/30 08:28:53 adamdunkels Exp $
* $Id: rudolph0.c,v 1.11 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -90,9 +90,9 @@ static void
send_nack(struct rudolph0_conn *c)
{
struct rudolph0_hdr *hdr;
rimebuf_clear();
rimebuf_hdralloc(sizeof(struct rudolph0_hdr));
hdr = rimebuf_hdrptr();
packetbuf_clear();
packetbuf_hdralloc(sizeof(struct rudolph0_hdr));
hdr = packetbuf_hdrptr();
hdr->type = TYPE_NACK;
hdr->version = c->current.h.version;
@ -122,7 +122,7 @@ static void
recv(struct stbroadcast_conn *stbroadcast)
{
struct rudolph0_conn *c = (struct rudolph0_conn *)stbroadcast;
struct rudolph0_datapacket *p = rimebuf_dataptr();
struct rudolph0_datapacket *p = packetbuf_dataptr();
if(p->h.type == TYPE_DATA) {
if(c->current.h.version != p->h.version) {
@ -164,7 +164,7 @@ recv_nack(struct polite_conn *polite)
struct rudolph0_conn *c = (struct rudolph0_conn *)
((char *)polite - offsetof(struct rudolph0_conn,
nackc));
struct rudolph0_datapacket *p = rimebuf_dataptr();
struct rudolph0_datapacket *p = packetbuf_dataptr();
if(p->h.type == TYPE_NACK && c->state == STATE_SENDER) {
if(p->h.version == c->current.h.version) {
@ -210,7 +210,7 @@ rudolph0_send(struct rudolph0_conn *c, clock_time_t send_interval)
c->current.h.chunk = 0;
c->current.h.type = TYPE_DATA;
read_new_datapacket(c);
rimebuf_reference(&c->current, sizeof(struct rudolph0_datapacket));
packetbuf_reference(&c->current, sizeof(struct rudolph0_datapacket));
c->send_interval = send_interval;
stbroadcast_send_stubborn(&c->c, c->send_interval);
}

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rudolph1.c,v 1.11 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: rudolph1.c,v 1.12 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -102,13 +102,13 @@ format_data(struct rudolph1_conn *c, int chunk)
{
struct rudolph1_datapacket *p;
rimebuf_clear();
p = rimebuf_dataptr();
packetbuf_clear();
p = packetbuf_dataptr();
p->h.type = TYPE_DATA;
p->h.version = c->version;
p->h.chunk = chunk;
p->datalen = read_data(c, p->data, chunk);
rimebuf_set_datalen(sizeof(struct rudolph1_datapacket) -
packetbuf_set_datalen(sizeof(struct rudolph1_datapacket) -
(RUDOLPH1_DATASIZE - p->datalen));
return p->datalen;
@ -137,9 +137,9 @@ static void
send_nack(struct rudolph1_conn *c)
{
struct rudolph1_hdr *hdr;
rimebuf_clear();
rimebuf_hdralloc(sizeof(struct rudolph1_hdr));
hdr = rimebuf_hdrptr();
packetbuf_clear();
packetbuf_hdralloc(sizeof(struct rudolph1_hdr));
hdr = packetbuf_hdrptr();
hdr->type = TYPE_NACK;
hdr->version = c->version;
@ -207,7 +207,7 @@ static void
recv_trickle(struct trickle_conn *trickle)
{
struct rudolph1_conn *c = (struct rudolph1_conn *)trickle;
struct rudolph1_datapacket *p = rimebuf_dataptr();
struct rudolph1_datapacket *p = packetbuf_dataptr();
if(p->h.type == TYPE_DATA) {
PRINTF("%d.%d: received trickle with chunk %d\n",
@ -236,7 +236,7 @@ recv_ipolite(struct ipolite_conn *ipolite, rimeaddr_t *from)
{
struct rudolph1_conn *c = (struct rudolph1_conn *)
((char *)ipolite - offsetof(struct rudolph1_conn, ipolite));
struct rudolph1_datapacket *p = rimebuf_dataptr();
struct rudolph1_datapacket *p = packetbuf_dataptr();
PRINTF("%d.%d: Got ipolite type %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],

View file

@ -39,7 +39,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rudolph2.c,v 1.6 2008/11/09 12:16:33 adamdunkels Exp $
* $Id: rudolph2.c,v 1.7 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -111,14 +111,14 @@ format_data(struct rudolph2_conn *c, int chunk)
struct rudolph2_hdr *hdr;
int len;
rimebuf_clear();
hdr = rimebuf_dataptr();
packetbuf_clear();
hdr = packetbuf_dataptr();
hdr->type = TYPE_DATA;
hdr->hops_from_base = c->hops_from_base;
hdr->version = c->version;
hdr->chunk = chunk;
len = read_data(c, (uint8_t *)hdr + sizeof(struct rudolph2_hdr), chunk);
rimebuf_set_datalen(sizeof(struct rudolph2_hdr) + len);
packetbuf_set_datalen(sizeof(struct rudolph2_hdr) + len);
return len;
}
@ -170,9 +170,9 @@ static void
send_nack(struct rudolph2_conn *c)
{
struct rudolph2_hdr *hdr;
rimebuf_clear();
rimebuf_hdralloc(sizeof(struct rudolph2_hdr));
hdr = rimebuf_hdrptr();
packetbuf_clear();
packetbuf_hdralloc(sizeof(struct rudolph2_hdr));
hdr = packetbuf_hdrptr();
hdr->hops_from_base = c->hops_from_base;
hdr->type = TYPE_NACK;
@ -290,7 +290,7 @@ static void
recv(struct polite_conn *polite)
{
struct rudolph2_conn *c = (struct rudolph2_conn *)polite;
struct rudolph2_hdr *hdr = rimebuf_dataptr();
struct rudolph2_hdr *hdr = packetbuf_dataptr();
/* Only accept NACKs from nodes that are farther away from the base
than us. */
@ -326,8 +326,8 @@ recv(struct polite_conn *polite)
if(hdr->chunk != 0) {
send_nack(c);
} else {
rimebuf_hdrreduce(sizeof(struct rudolph2_hdr));
write_data(c, 0, rimebuf_dataptr(), rimebuf_totlen());
packetbuf_hdrreduce(sizeof(struct rudolph2_hdr));
write_data(c, 0, packetbuf_dataptr(), packetbuf_totlen());
}
} else if(hdr->version == c->version) {
PRINTF("%d.%d: got chunk %d snd_nxt %d rcv_nxt %d\n",
@ -336,12 +336,12 @@ recv(struct polite_conn *polite)
if(hdr->chunk == c->rcv_nxt) {
int len;
rimebuf_hdrreduce(sizeof(struct rudolph2_hdr));
packetbuf_hdrreduce(sizeof(struct rudolph2_hdr));
PRINTF("%d.%d: received chunk %d len %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
hdr->chunk, rimebuf_totlen());
len = rimebuf_totlen();
write_data(c, hdr->chunk, rimebuf_dataptr(), rimebuf_totlen());
hdr->chunk, packetbuf_totlen());
len = packetbuf_totlen();
write_data(c, hdr->chunk, packetbuf_dataptr(), packetbuf_totlen());
c->rcv_nxt++;
if(len < RUDOLPH2_DATASIZE) {
c->flags |= FLAG_LAST_RECEIVED;
@ -388,9 +388,9 @@ rudolph2_send(struct rudolph2_conn *c, clock_time_t send_interval)
c->version++;
c->snd_nxt = 0;
len = RUDOLPH2_DATASIZE;
rimebuf_clear();
packetbuf_clear();
for(c->rcv_nxt = 0; len == RUDOLPH2_DATASIZE; c->rcv_nxt++) {
len = read_data(c, rimebuf_dataptr(), c->rcv_nxt);
len = read_data(c, packetbuf_dataptr(), c->rcv_nxt);
}
c->flags = FLAG_LAST_RECEIVED;
/* printf("Highest chunk %d\n", c->rcv_nxt);*/

View file

@ -34,7 +34,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: runicast.c,v 1.4 2009/03/03 12:19:46 fros4943 Exp $
* $Id: runicast.c,v 1.5 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -53,10 +53,10 @@
#define REXMIT_TIME CLOCK_SECOND
static const struct rimebuf_attrlist attributes[] =
static const struct packetbuf_attrlist attributes[] =
{
RUNICAST_ATTRIBUTES
RIMEBUF_ATTR_LAST
PACKETBUF_ATTR_LAST
};
#define DEBUG 0
@ -77,7 +77,7 @@ sent_by_stunicast(struct stunicast_conn *stunicast)
RIMESTATS_ADD(rexmit);
PRINTF("%d.%d: runicast: packet %u resent %u\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_ID), c->rxmit);
packetbuf_attr(PACKETBUF_ATTR_PACKET_ID), c->rxmit);
}
c->rxmit++;
@ -103,21 +103,21 @@ static void
recv_from_stunicast(struct stunicast_conn *stunicast, rimeaddr_t *from)
{
struct runicast_conn *c = (struct runicast_conn *)stunicast;
/* struct runicast_hdr *hdr = rimebuf_dataptr();*/
/* struct runicast_hdr *hdr = packetbuf_dataptr();*/
PRINTF("%d.%d: runicast: recv_from_stunicast from %d.%d type %d seqno %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
from->u8[0], from->u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_TYPE),
rimebuf_attr(RIMEBUF_ATTR_PACKET_ID));
packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE),
packetbuf_attr(PACKETBUF_ATTR_PACKET_ID));
if(rimebuf_attr(RIMEBUF_ATTR_PACKET_TYPE) ==
RIMEBUF_ATTR_PACKET_TYPE_ACK) {
if(rimebuf_attr(RIMEBUF_ATTR_PACKET_ID) == c->sndnxt) {
if(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) ==
PACKETBUF_ATTR_PACKET_TYPE_ACK) {
if(packetbuf_attr(PACKETBUF_ATTR_PACKET_ID) == c->sndnxt) {
RIMESTATS_ADD(ackrx);
PRINTF("%d.%d: runicast: ACKed %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_ID));
packetbuf_attr(PACKETBUF_ATTR_PACKET_ID));
c->sndnxt = (c->sndnxt + 1) % (1 << RUNICAST_PACKET_ID_BITS);
c->is_tx = 0;
stunicast_cancel(&c->c);
@ -127,12 +127,12 @@ recv_from_stunicast(struct stunicast_conn *stunicast, rimeaddr_t *from)
} else {
PRINTF("%d.%d: runicast: received bad ACK %d for %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_ID),
packetbuf_attr(PACKETBUF_ATTR_PACKET_ID),
c->sndnxt);
RIMESTATS_ADD(badackrx);
}
} else if(rimebuf_attr(RIMEBUF_ATTR_PACKET_TYPE) ==
RIMEBUF_ATTR_PACKET_TYPE_DATA) {
} else if(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) ==
PACKETBUF_ATTR_PACKET_TYPE_DATA) {
/* int send_ack = 1;*/
uint16_t packet_seqno;
struct queuebuf *q;
@ -141,29 +141,29 @@ recv_from_stunicast(struct stunicast_conn *stunicast, rimeaddr_t *from)
PRINTF("%d.%d: runicast: got packet %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
rimebuf_attr(RIMEBUF_ATTR_PACKET_ID));
packetbuf_attr(PACKETBUF_ATTR_PACKET_ID));
packet_seqno = rimebuf_attr(RIMEBUF_ATTR_PACKET_ID);
packet_seqno = packetbuf_attr(PACKETBUF_ATTR_PACKET_ID);
/* rimebuf_hdrreduce(sizeof(struct runicast_hdr));*/
/* packetbuf_hdrreduce(sizeof(struct runicast_hdr));*/
q = queuebuf_new_from_rimebuf();
q = queuebuf_new_from_packetbuf();
if(q != NULL) {
PRINTF("%d.%d: runicast: Sending ACK to %d.%d for %d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
from->u8[0], from->u8[1],
packet_seqno);
rimebuf_clear();
/* rimebuf_hdralloc(sizeof(struct runicast_hdr));
hdr = rimebuf_hdrptr();
packetbuf_clear();
/* packetbuf_hdralloc(sizeof(struct runicast_hdr));
hdr = packetbuf_hdrptr();
hdr->type = TYPE_ACK;
hdr->seqno = packet_seqno;*/
rimebuf_set_attr(RIMEBUF_ATTR_PACKET_TYPE, RIMEBUF_ATTR_PACKET_TYPE_ACK);
rimebuf_set_attr(RIMEBUF_ATTR_PACKET_ID, packet_seqno);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE, PACKETBUF_ATTR_PACKET_TYPE_ACK);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, packet_seqno);
stunicast_send(&c->c, from);
RIMESTATS_ADD(acktx);
queuebuf_to_rimebuf(q);
queuebuf_to_packetbuf(q);
queuebuf_free(q);
}
if(c->u->recv != NULL) {
@ -206,9 +206,9 @@ runicast_send(struct runicast_conn *c, rimeaddr_t *receiver, uint8_t max_retrans
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
return 0;
}
rimebuf_set_attr(RIMEBUF_ATTR_RELIABLE, 1);
rimebuf_set_attr(RIMEBUF_ATTR_PACKET_TYPE, RIMEBUF_ATTR_PACKET_TYPE_DATA);
rimebuf_set_attr(RIMEBUF_ATTR_PACKET_ID, c->sndnxt);
packetbuf_set_attr(PACKETBUF_ATTR_RELIABLE, 1);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE, PACKETBUF_ATTR_PACKET_TYPE_DATA);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, c->sndnxt);
c->max_rxmit = max_retransmissions;
c->rxmit = 0;
c->is_tx = 1;

View file

@ -66,7 +66,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: runicast.h,v 1.4 2009/03/07 11:15:46 adamdunkels Exp $
* $Id: runicast.h,v 1.5 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -83,8 +83,8 @@
struct runicast_conn;
#define RUNICAST_ATTRIBUTES { RIMEBUF_ATTR_PACKET_TYPE, RIMEBUF_ATTR_BIT }, \
{ RIMEBUF_ATTR_PACKET_ID, RIMEBUF_ATTR_BIT * 2 }, \
#define RUNICAST_ATTRIBUTES { PACKETBUF_ATTR_PACKET_TYPE, PACKETBUF_ATTR_BIT }, \
{ PACKETBUF_ATTR_PACKET_ID, PACKETBUF_ATTR_BIT * 2 }, \
STUNICAST_ATTRIBUTES
struct runicast_callbacks {
void (* recv)(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno);

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: stbroadcast.c,v 1.1 2008/06/30 08:28:53 adamdunkels Exp $
* $Id: stbroadcast.c,v 1.2 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -82,7 +82,7 @@ send(void *ptr)
struct stbroadcast_conn *c = ptr;
/* DEBUGF(3, "stbroadcast: send()\n");*/
queuebuf_to_rimebuf(c->buf);
queuebuf_to_packetbuf(c->buf);
broadcast_send(&c->c);
ctimer_reset(&c->t);
if(c->u->sent != NULL) {
@ -102,7 +102,7 @@ stbroadcast_send_stubborn(struct stbroadcast_conn *c, clock_time_t t)
if(c->buf != NULL) {
queuebuf_free(c->buf);
}
c->buf = queuebuf_new_from_rimebuf();
c->buf = queuebuf_new_from_packetbuf();
if(c->buf == NULL) {
return 0;
}

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: stunicast.c,v 1.1 2008/07/03 21:35:46 adamdunkels Exp $
* $Id: stunicast.c,v 1.2 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -102,7 +102,7 @@ send(void *ptr)
PRINTF("%d.%d: stunicast: resend to %d.%d\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
c->receiver.u8[0], c->receiver.u8[1]);
queuebuf_to_rimebuf(c->buf);
queuebuf_to_packetbuf(c->buf);
unicast_send(&c->c, &c->receiver);
stunicast_set_timer(c, CLOCK_SECOND);
if(c->u->sent != NULL) {
@ -123,7 +123,7 @@ stunicast_send_stubborn(struct stunicast_conn *c, rimeaddr_t *receiver,
if(c->buf != NULL) {
queuebuf_free(c->buf);
}
c->buf = queuebuf_new_from_rimebuf();
c->buf = queuebuf_new_from_packetbuf();
if(c->buf == NULL) {
return 0;
}

View file

@ -34,7 +34,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: timesynch.c,v 1.6 2009/02/20 21:23:22 adamdunkels Exp $
* $Id: timesynch.c,v 1.7 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -45,7 +45,7 @@
*/
#include "net/rime/timesynch.h"
#include "net/rime/rimebuf.h"
#include "net/rime/packetbuf.h"
#include "net/rime.h"
#include "dev/cc2420.h"
@ -102,7 +102,7 @@ adjust_offset(rtimer_clock_t authoritative_time, rtimer_clock_t local_time)
static void
incoming_packet(void)
{
if(rimebuf_totlen() != 0) {
if(packetbuf_totlen() != 0) {
/* We check the authority level of the sender of the incoming
packet. If the sending node has a lower authority level than we
have, we synchronize to the time of the sending node and set our

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: trickle.c,v 1.15 2009/02/11 11:08:56 adamdunkels Exp $
* $Id: trickle.c,v 1.16 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -57,9 +57,9 @@
#define SEQNO_LT(a, b) ((signed char)((a) - (b)) < 0)
static const struct rimebuf_attrlist attributes[] =
static const struct packetbuf_attrlist attributes[] =
{
TRICKLE_ATTRIBUTES RIMEBUF_ATTR_LAST
TRICKLE_ATTRIBUTES PACKETBUF_ATTR_LAST
};
@ -79,7 +79,7 @@ send(void *ptr)
struct trickle_conn *c = ptr;
if(c->q != NULL) {
queuebuf_to_rimebuf(c->q);
queuebuf_to_packetbuf(c->q);
broadcast_send(&c->c);
} else {
PRINTF("%d.%d: trickle send but c->q == NULL\n",
@ -136,15 +136,15 @@ static void
recv(struct broadcast_conn *bc, rimeaddr_t *from)
{
struct trickle_conn *c = (struct trickle_conn *)bc;
uint16_t seqno = rimebuf_attr(RIMEBUF_ATTR_EPACKET_ID);
uint16_t seqno = packetbuf_attr(PACKETBUF_ATTR_EPACKET_ID);
PRINTF("%d.%d: trickle recv seqno %d from %d.%d our %d data len %d channel %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
seqno,
from->u8[0], from->u8[1],
c->seqno,
rimebuf_datalen(),
rimebuf_attr(RIMEBUF_ATTR_CHANNEL));
packetbuf_datalen(),
packetbuf_attr(PACKETBUF_ATTR_CHANNEL));
if(seqno == c->seqno) {
/* c->cb->recv(c);*/
@ -161,7 +161,7 @@ recv(struct broadcast_conn *bc, rimeaddr_t *from)
if(c->q != NULL) {
queuebuf_free(c->q);
}
c->q = queuebuf_new_from_rimebuf();
c->q = queuebuf_new_from_packetbuf();
c->interval_scaling = 0;
reset_interval(c);
send(c);
@ -198,8 +198,8 @@ trickle_send(struct trickle_conn *c)
queuebuf_free(c->q);
}
c->seqno++;
rimebuf_set_attr(RIMEBUF_ATTR_EPACKET_ID, c->seqno);
c->q = queuebuf_new_from_rimebuf();
packetbuf_set_attr(PACKETBUF_ATTR_EPACKET_ID, c->seqno);
c->q = queuebuf_new_from_packetbuf();
PRINTF("%d.%d: trickle send seqno %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
c->seqno);

View file

@ -45,7 +45,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: trickle.h,v 1.9 2008/07/07 23:29:30 adamdunkels Exp $
* $Id: trickle.h,v 1.10 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -62,7 +62,7 @@
#include "net/rime/ctimer.h"
#include "net/rime/queuebuf.h"
#define TRICKLE_ATTRIBUTES { RIMEBUF_ATTR_EPACKET_ID, RIMEBUF_ATTR_BIT * 8 },\
#define TRICKLE_ATTRIBUTES { PACKETBUF_ATTR_EPACKET_ID, PACKETBUF_ATTR_BIT * 8 },\
BROADCAST_ATTRIBUTES
struct trickle_conn;

View file

@ -34,7 +34,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: unicast.c,v 1.1 2008/06/26 11:19:22 adamdunkels Exp $
* $Id: unicast.c,v 1.2 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -48,10 +48,10 @@
#include "net/rime/unicast.h"
#include <string.h>
static const struct rimebuf_attrlist attributes[] =
static const struct packetbuf_attrlist attributes[] =
{
UNICAST_ATTRIBUTES
RIMEBUF_ATTR_LAST
PACKETBUF_ATTR_LAST
};
#define DEBUG 0
@ -70,9 +70,9 @@ recv_from_broadcast(struct broadcast_conn *broadcast, rimeaddr_t *from)
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]);
if(rimeaddr_cmp(rimebuf_addr(RIMEBUF_ADDR_RECEIVER), &rimeaddr_node_addr)) {
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[1]);
if(rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &rimeaddr_node_addr)) {
c->u->recv(c, from);
}
}
@ -100,7 +100,7 @@ unicast_send(struct unicast_conn *c, const rimeaddr_t *receiver)
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);
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, receiver);
return broadcast_send(&c->c);
}
/*---------------------------------------------------------------------------*/

View file

@ -50,7 +50,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: unicast.h,v 1.3 2009/03/08 21:43:24 adamdunkels Exp $
* $Id: unicast.h,v 1.4 2009/03/12 21:58:21 adamdunkels Exp $
*/
/**
@ -67,7 +67,7 @@
struct unicast_conn;
#define UNICAST_ATTRIBUTES { RIMEBUF_ADDR_RECEIVER, RIMEBUF_ADDRSIZE }, \
#define UNICAST_ATTRIBUTES { PACKETBUF_ADDR_RECEIVER, PACKETBUF_ADDRSIZE }, \
BROADCAST_ATTRIBUTES
struct unicast_callbacks {