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:
parent
932fc9f748
commit
65eb5fd4e8
90 changed files with 690 additions and 687 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue