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

@ -28,12 +28,12 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ctdma_mac.c,v 1.2 2008/02/24 22:10:30 adamdunkels Exp $
* $Id: ctdma_mac.c,v 1.3 2009/03/12 21:58:20 adamdunkels Exp $
*/
#include "contiki.h"
#include "net/mac/ctdma_mac.h"
#include "net/rime/rimebuf.h"
#include "net/rime/packetbuf.h"
#include "net/uip-fw.h"
#include "net/rime/ctimer.h"
#include "net/rime.h"
@ -165,7 +165,7 @@ send(void)
}
/* Allocate queue buf for packet */
data[freeslot] = queuebuf_new_from_rimebuf();
data[freeslot] = queuebuf_new_from_packetbuf();
id[freeslot] = id_counter;
if (data[freeslot] == NULL)
{
@ -196,9 +196,9 @@ static int
read(void)
{
int len;
rimebuf_clear();
len = radio->read(rimebuf_dataptr(), RIMEBUF_SIZE);
rimebuf_set_datalen(len);
packetbuf_clear();
len = radio->read(packetbuf_dataptr(), PACKETBUF_SIZE);
packetbuf_set_datalen(len);
return len;
}
/*---------------------------------------------------------------------------*/

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: cxmac.c,v 1.2 2008/02/24 22:10:30 adamdunkels Exp $
* $Id: cxmac.c,v 1.3 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -251,19 +251,19 @@ send(void)
/* printf("xmac_send\n");*/
#if !CHAMELEON
PRINTF("xmac: send() len %d to %d.%d\n", rimebuf_totlen(),
PRINTF("xmac: send() len %d to %d.%d\n", packetbuf_totlen(),
uc_receiver.u8[0], uc_receiver.u8[1]);
#endif
rimebuf_hdralloc(sizeof(struct xmac_hdr));
hdr = rimebuf_hdrptr();
packetbuf_hdralloc(sizeof(struct xmac_hdr));
hdr = packetbuf_hdrptr();
rimeaddr_copy(&hdr->sender, &rimeaddr_node_addr);
#if CHAMELEON
rimeaddr_copy(&hdr->receiver, packattr_aget(PACKATTR_RECEIVER));
#else
rimeaddr_copy(&hdr->receiver, &uc_receiver);
#endif
rimebuf_compact();
packetbuf_compact();
/* should_be_awake = 1;
while(!radio_is_on) {}*/
@ -325,7 +325,7 @@ send(void)
} while(clock_time() < t0 + OFF_TIME + ON_TIME);
/* } while(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + OFF_TIME + ON_TIME * 2));*/
radio->send(rimebuf_hdrptr(), rimebuf_totlen());
radio->send(packetbuf_hdrptr(), packetbuf_totlen());
/* printf("xmac send time %d\n", (rtimer_clock_t)(RTIMER_NOW() - t0));
if((rtimer_clock_t)(RTIMER_NOW() - t0) > 10000) {
@ -360,7 +360,7 @@ qsend(void)
return 0;
} else {
#if WITH_QUEUE
queued_packet = queuebuf_new_from_rimebuf();
queued_packet = queuebuf_new_from_packetbuf();
return 1;
#else
RIMESTATS_ADD(contentiondrop);
@ -377,7 +377,7 @@ qsend(void)
static void
send_queued(void *ptr)
{
queuebuf_to_rimebuf(queued_packet);
queuebuf_to_packetbuf(queued_packet);
queuebuf_free(queued_packet);
queued_packet = NULL;
qsend();
@ -405,10 +405,10 @@ read(void)
struct xmac_hdr *hdr;
uint8_t len;
rimebuf_clear();
packetbuf_clear();
PRINTF("xmac: input ");
len = radio->read(rimebuf_dataptr(), RIMEBUF_SIZE);
len = radio->read(packetbuf_dataptr(), PACKETBUF_SIZE);
PRINTF("%d bytes at %d.%d\n", len,
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
@ -417,16 +417,16 @@ read(void)
ctimer_set(&ctimer,
(OFF_TIME * 2),
reset_state, NULL);
rimebuf_set_datalen(len);
hdr = rimebuf_dataptr();
packetbuf_set_datalen(len);
hdr = packetbuf_dataptr();
rimebuf_hdrreduce(sizeof(struct xmac_hdr));
packetbuf_hdrreduce(sizeof(struct xmac_hdr));
if(rimeaddr_cmp(&hdr->receiver, &rimeaddr_node_addr)) {
should_be_awake = 1;
PRINTF("xmac: for us\n");
if(!rimeaddr_cmp(&hdr->sender, &rimeaddr_node_addr) &&
rimebuf_totlen() == 0) {
packetbuf_totlen() == 0) {
/* XXX Send an ACK and wait for packet . */
PRINTF("xmac: got sender %d.%d receiver %d.%d\n",
hdr->sender.u8[0],hdr->sender.u8[1],
@ -460,7 +460,7 @@ read(void)
/* PRINTF("xmac: not for us\n");*/
}
if(rimebuf_totlen() > 0) {
if(packetbuf_totlen() > 0) {
/* We have received the final packet, so we can go back to being
asleep. */
@ -475,7 +475,7 @@ read(void)
}
#endif
return rimebuf_totlen();
return packetbuf_totlen();
}
}
return 0;

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: lpp.c,v 1.9 2009/02/20 21:22:39 adamdunkels Exp $
* $Id: lpp.c,v 1.10 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -55,7 +55,7 @@
#include "net/rime.h"
#include "net/mac/mac.h"
#include "net/mac/lpp.h"
#include "net/rime/rimebuf.h"
#include "net/rime/packetbuf.h"
#include "net/rime/announcement.h"
#include <stdlib.h>
@ -147,12 +147,12 @@ send_probe(void)
struct announcement *a;
/* Set up the probe header. */
rimebuf_clear();
rimebuf_set_datalen(sizeof(struct lpp_hdr));
hdr = rimebuf_dataptr();
packetbuf_clear();
packetbuf_set_datalen(sizeof(struct lpp_hdr));
hdr = packetbuf_dataptr();
hdr->type = TYPE_PROBE;
rimeaddr_copy(&hdr->sender, &rimeaddr_node_addr);
rimeaddr_copy(&hdr->receiver, rimebuf_addr(RIMEBUF_ADDR_RECEIVER));
rimeaddr_copy(&hdr->receiver, packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
/* Construct the announcements */
@ -165,12 +165,12 @@ send_probe(void)
adata->num++;
}
rimebuf_set_datalen(sizeof(struct lpp_hdr) +
packetbuf_set_datalen(sizeof(struct lpp_hdr) +
ANNOUNCEMENT_MSG_HEADERLEN +
sizeof(struct announcement_data) * adata->num);
/* PRINTF("Sending probe\n");*/
radio->send(rimebuf_hdrptr(), rimebuf_totlen());
radio->send(packetbuf_hdrptr(), packetbuf_totlen());
}
/*---------------------------------------------------------------------------*/
/**
@ -237,24 +237,24 @@ send_packet(void)
{
struct lpp_hdr *hdr;
rimebuf_hdralloc(sizeof(struct lpp_hdr));
hdr = rimebuf_hdrptr();
packetbuf_hdralloc(sizeof(struct lpp_hdr));
hdr = packetbuf_hdrptr();
rimeaddr_copy(&hdr->sender, &rimeaddr_node_addr);
rimeaddr_copy(&hdr->receiver, rimebuf_addr(RIMEBUF_ADDR_RECEIVER));
rimeaddr_copy(&hdr->receiver, packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
hdr->type = TYPE_DATA;
rimebuf_compact();
packetbuf_compact();
PRINTF("%d.%d: queueing packet to %d.%d, channel %d\n",
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
hdr->receiver.u8[0], hdr->receiver.u8[1],
rimebuf_attr(RIMEBUF_ATTR_CHANNEL));
packetbuf_attr(PACKETBUF_ATTR_CHANNEL));
if(rimebuf_attr(RIMEBUF_ATTR_PACKET_TYPE) == RIMEBUF_ATTR_PACKET_TYPE_ACK) {
if(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) == PACKETBUF_ATTR_PACKET_TYPE_ACK) {
/* Immediately send ACKs - we're assuming that the other node is
listening. */
/* printf("Immediately sending ACK\n");*/
return radio->send(rimebuf_hdrptr(), rimebuf_totlen());
return radio->send(packetbuf_hdrptr(), packetbuf_totlen());
} else {
/* If a packet is already queued, the DUMP_QUEUED_PACKET option
@ -265,10 +265,10 @@ send_packet(void)
if(queued_packet != NULL) {
remove_queued_packet();
}
queued_packet = queuebuf_new_from_rimebuf();
queued_packet = queuebuf_new_from_packetbuf();
#else /* DUMP_QUEUED_PACKET */
if(queued_packet == NULL) {
queued_packet = queuebuf_new_from_rimebuf();
queued_packet = queuebuf_new_from_packetbuf();
}
#endif /* DUMP_QUEUED_PACKET */
@ -291,16 +291,16 @@ read_packet(void)
int len;
struct lpp_hdr *hdr, *qhdr;
rimebuf_clear();
len = radio->read(rimebuf_dataptr(), RIMEBUF_SIZE);
packetbuf_clear();
len = radio->read(packetbuf_dataptr(), PACKETBUF_SIZE);
if(len > 0) {
rimebuf_set_datalen(len);
hdr = rimebuf_dataptr();
rimebuf_hdrreduce(sizeof(struct lpp_hdr));
packetbuf_set_datalen(len);
hdr = packetbuf_dataptr();
packetbuf_hdrreduce(sizeof(struct lpp_hdr));
/* PRINTF("got packet type %d\n", hdr->type);*/
if(hdr->type == TYPE_PROBE) {
/* Parse incoming announcements */
struct announcement_msg *adata = rimebuf_dataptr();
struct announcement_msg *adata = packetbuf_dataptr();
int i;
/* PRINTF("%d.%d: probe from %d.%d with %d announcements\n",
@ -355,7 +355,7 @@ read_packet(void)
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
hdr->sender.u8[0], hdr->sender.u8[1]);
}
len = rimebuf_datalen();
len = packetbuf_datalen();
}
return len;
}

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: nullmac.c,v 1.8 2008/06/30 08:09:17 adamdunkels Exp $
* $Id: nullmac.c,v 1.9 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -39,7 +39,7 @@
*/
#include "net/mac/nullmac.h"
#include "net/rime/rimebuf.h"
#include "net/rime/packetbuf.h"
static const struct radio_driver *radio;
static void (* receiver_callback)(const struct mac_driver *);
@ -47,7 +47,7 @@ static void (* receiver_callback)(const struct mac_driver *);
static int
send_packet(void)
{
return radio->send(rimebuf_hdrptr(), rimebuf_totlen());
return radio->send(packetbuf_hdrptr(), packetbuf_totlen());
}
/*---------------------------------------------------------------------------*/
static void
@ -62,9 +62,9 @@ static int
read_packet(void)
{
int len;
rimebuf_clear();
len = radio->read(rimebuf_dataptr(), RIMEBUF_SIZE);
rimebuf_set_datalen(len);
packetbuf_clear();
len = radio->read(packetbuf_dataptr(), PACKETBUF_SIZE);
packetbuf_set_datalen(len);
return len;
}
/*---------------------------------------------------------------------------*/

View file

@ -28,12 +28,12 @@
*
* This file is part of the Contiki operating system.
*
* $Id: tdma_mac.c,v 1.5 2008/11/12 12:42:41 fros4943 Exp $
* $Id: tdma_mac.c,v 1.6 2009/03/12 21:58:20 adamdunkels Exp $
*/
#include "contiki.h"
#include "net/mac/tdma_mac.h"
#include "net/rime/rimebuf.h"
#include "net/rime/packetbuf.h"
#include "net/uip-fw.h"
#include "sys/rtimer.h"
#include "net/rime.h"
@ -168,7 +168,7 @@ send(void)
}
/* Allocate queue buf for packet */
data[freeslot] = queuebuf_new_from_rimebuf();
data[freeslot] = queuebuf_new_from_packetbuf();
id[freeslot] = id_counter;
if(data[freeslot] == NULL) {
PRINTF("BUFFER Queuebuffer full, dropping packet #%i\n", id[freeslot]);
@ -202,9 +202,9 @@ static int
read(void)
{
int len;
rimebuf_clear();
len = radio->read(rimebuf_dataptr(), RIMEBUF_SIZE);
rimebuf_set_datalen(len);
packetbuf_clear();
len = radio->read(packetbuf_dataptr(), PACKETBUF_SIZE);
packetbuf_set_datalen(len);
return len;
}
/*---------------------------------------------------------------------------*/

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: xmac.c,v 1.27 2009/03/05 19:37:52 adamdunkels Exp $
* $Id: xmac.c,v 1.28 2009/03/12 21:58:20 adamdunkels Exp $
*/
/**
@ -304,7 +304,7 @@ static int
parse_announcements(rimeaddr_t *from)
{
/* Parse incoming announcements */
struct announcement_msg *adata = rimebuf_dataptr();
struct announcement_msg *adata = packetbuf_dataptr();
int i;
PRINTF("%d.%d: probe from %d.%d with %d announcements\n",
@ -398,16 +398,16 @@ send_packet(void)
alignment of the header in the packet buffer. */
hdr.type = TYPE_DATA;
rimeaddr_copy(&hdr.sender, &rimeaddr_node_addr);
rimeaddr_copy(&hdr.receiver, rimebuf_addr(RIMEBUF_ADDR_RECEIVER));
rimeaddr_copy(&hdr.receiver, packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
if(rimeaddr_cmp(&hdr.receiver, &rimeaddr_null)) {
is_broadcast = 1;
}
/* Copy the X-MAC header to the header portion of the packet
buffer. */
rimebuf_hdralloc(sizeof(struct xmac_hdr));
memcpy(rimebuf_hdrptr(), &hdr, sizeof(struct xmac_hdr));
rimebuf_compact();
packetbuf_hdralloc(sizeof(struct xmac_hdr));
memcpy(packetbuf_hdrptr(), &hdr, sizeof(struct xmac_hdr));
packetbuf_compact();
t0 = RTIMER_NOW();
strobes = 0;
@ -431,7 +431,7 @@ send_packet(void)
t = RTIMER_NOW();
strobe.hdr.type = TYPE_STROBE;
rimeaddr_copy(&strobe.hdr.sender, &rimeaddr_node_addr);
rimeaddr_copy(&strobe.hdr.receiver, rimebuf_addr(RIMEBUF_ADDR_RECEIVER));
rimeaddr_copy(&strobe.hdr.receiver, packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
#if WITH_TIMETABLE
if(rimeaddr_cmp(&strobe.hdr.receiver, &rimeaddr_null)) {
@ -476,8 +476,8 @@ send_packet(void)
/* If we have received the strobe ACK, and we are sending a packet
that will need an upper layer ACK (as signified by the
RIMEBUF_ATTR_RELIABLE packet attribute), we keep the radio on. */
if(got_strobe_ack && rimebuf_attr(RIMEBUF_ATTR_RELIABLE)) {
PACKETBUF_ATTR_RELIABLE packet attribute), we keep the radio on. */
if(got_strobe_ack && packetbuf_attr(PACKETBUF_ATTR_RELIABLE)) {
#if WITH_TIMETABLE
TIMETABLE_TIMESTAMP(xmac_timetable, "send got ack");
#endif
@ -501,13 +501,13 @@ send_packet(void)
#if WITH_TIMETABLE
TIMETABLE_TIMESTAMP(xmac_timetable, "send packet");
#endif
radio->send(rimebuf_hdrptr(), rimebuf_totlen());
radio->send(packetbuf_hdrptr(), packetbuf_totlen());
CPRINTF("#");
}
watchdog_start();
PRINTF("xmac: send (strobes=%u,len=%u,%s), done\n", strobes,
rimebuf_totlen(), got_strobe_ack ? "ack" : "no ack");
packetbuf_totlen(), got_strobe_ack ? "ack" : "no ack");
#if XMAC_CONF_COMPOWER
/* Accumulate the power consumption for the packet transmission. */
@ -545,7 +545,7 @@ qsend_packet(void)
return 0;
} else {
#if WITH_QUEUE
queued_packet = queuebuf_new_from_rimebuf();
queued_packet = queuebuf_new_from_packetbuf();
return 1;
#else
RIMESTATS_ADD(sendingdrop);
@ -573,15 +573,15 @@ read_packet(void)
struct xmac_hdr *hdr;
uint8_t len;
rimebuf_clear();
packetbuf_clear();
len = radio->read(rimebuf_dataptr(), RIMEBUF_SIZE);
len = radio->read(packetbuf_dataptr(), PACKETBUF_SIZE);
if(len > 0) {
rimebuf_set_datalen(len);
hdr = rimebuf_dataptr();
packetbuf_set_datalen(len);
hdr = packetbuf_dataptr();
rimebuf_hdrreduce(sizeof(struct xmac_hdr));
packetbuf_hdrreduce(sizeof(struct xmac_hdr));
if(hdr->type == TYPE_STROBE) {
CPRINTF(".");
@ -626,7 +626,7 @@ read_packet(void)
}
/* Check for annoucements in the strobe */
/* if(rimebuf_datalen() > 0) {
/* if(packetbuf_datalen() > 0) {
parse_announcements(&hdr->sender);
}*/
/* We are done processing the strobe and we therefore return
@ -669,7 +669,7 @@ read_packet(void)
queued_packet = NULL;
}
return rimebuf_totlen();
return packetbuf_totlen();
}
#if XMAC_CONF_ANNOUNCEMENTS
} else if(hdr->type == TYPE_ANNOUNCEMENT) {
@ -688,9 +688,9 @@ send_announcement(void *ptr)
int announcement_len;
/* Set up the probe header. */
rimebuf_clear();
rimebuf_set_datalen(sizeof(struct xmac_hdr));
hdr = rimebuf_dataptr();
packetbuf_clear();
packetbuf_set_datalen(sizeof(struct xmac_hdr));
hdr = packetbuf_dataptr();
hdr->type = TYPE_ANNOUNCEMENT;
rimeaddr_copy(&hdr->sender, &rimeaddr_node_addr);
rimeaddr_copy(&hdr->receiver, &rimeaddr_null);
@ -698,10 +698,10 @@ send_announcement(void *ptr)
announcement_len = format_announcement((char *)hdr +
sizeof(struct xmac_hdr));
rimebuf_set_datalen(sizeof(struct xmac_hdr) + announcement_len);
packetbuf_set_datalen(sizeof(struct xmac_hdr) + announcement_len);
/* PRINTF("Sending probe\n");*/
radio->send(rimebuf_hdrptr(), rimebuf_totlen());
radio->send(packetbuf_hdrptr(), packetbuf_totlen());
}
/*---------------------------------------------------------------------------*/
static void