* Made Chameleon header processing module configurable (CHAMELEON_CONF_MODULE)
* Removed the unused init function from header processing modules * Added option CHAMELEON_CONF_WITH_MAC_LINK_ADDRESSES to specify that MAC link addresses should be used instead of Chameleon's own encoding of sender and receiver. This avoids encoding the link addresses twice when the MAC RDC has its own addresses.
This commit is contained in:
parent
b7b2c8fcde
commit
f6e0b46f38
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: chameleon-bitopt.c,v 1.8 2009/09/09 21:09:42 adamdunkels Exp $
|
* $Id: chameleon-bitopt.c,v 1.9 2010/05/28 06:18:39 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +44,17 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* This option enables an optimization where the link addresses are
|
||||||
|
left to the MAC RDC and not encoded in the Chameleon header.
|
||||||
|
Note: this requires that the underlying MAC layer to add link
|
||||||
|
addresses and will not work together with for example nullrdc.
|
||||||
|
*/
|
||||||
|
#ifdef CHAMELEON_CONF_WITH_MAC_LINK_ADDRESSES
|
||||||
|
#define CHAMELEON_WITH_MAC_LINK_ADDRESSES CHAMELEON_CONF_WITH_MAC_LINK_ADDRESSES
|
||||||
|
#else /* !CHAMELEON_CONF_WITH_MAC_LINK_ADDRESSES */
|
||||||
|
#define CHAMELEON_WITH_MAC_LINK_ADDRESSES 0
|
||||||
|
#endif /* !CHAMELEON_CONF_WITH_MAC_LINK_ADDRESSES */
|
||||||
|
|
||||||
struct bitopt_hdr {
|
struct bitopt_hdr {
|
||||||
uint8_t channel[2];
|
uint8_t channel[2];
|
||||||
};
|
};
|
||||||
|
@ -119,6 +130,13 @@ header_size(const struct packetbuf_attrlist *a)
|
||||||
|
|
||||||
size = 0;
|
size = 0;
|
||||||
for(; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
for(; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
||||||
|
#if CHAMELEON_WITH_MAC_LINK_ADDRESSES
|
||||||
|
if(a->type == PACKETBUF_ADDR_SENDER ||
|
||||||
|
a->type == PACKETBUF_ADDR_RECEIVER) {
|
||||||
|
/* Let the link layer handle sender and receiver */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* CHAMELEON_WITH_MAC_LINK_ADDRESSES */
|
||||||
/* PRINTF("chameleon header_size: header type %s (%d) len %d\n",
|
/* PRINTF("chameleon header_size: header type %s (%d) len %d\n",
|
||||||
packetbuf_attr_strings[a->type],
|
packetbuf_attr_strings[a->type],
|
||||||
a->type,
|
a->type,
|
||||||
|
@ -229,23 +247,35 @@ pack_header(struct channel *c)
|
||||||
all attributes that are used on this channel. */
|
all attributes that are used on this channel. */
|
||||||
|
|
||||||
hdrbytesize = c->hdrsize / 8 + ((c->hdrsize & 7) == 0? 0: 1);
|
hdrbytesize = c->hdrsize / 8 + ((c->hdrsize & 7) == 0? 0: 1);
|
||||||
packetbuf_hdralloc(hdrbytesize);
|
if(packetbuf_hdralloc(hdrbytesize + sizeof(struct bitopt_hdr)) == 0) {
|
||||||
hdrptr = packetbuf_hdrptr();
|
PRINTF("chameleon-bitopt: insufficient space for headers\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
hdr = (struct bitopt_hdr *)packetbuf_hdrptr();
|
||||||
|
hdr->channel[0] = c->channelno & 0xff;
|
||||||
|
hdr->channel[1] = (c->channelno >> 8) & 0xff;
|
||||||
|
|
||||||
|
hdrptr = ((uint8_t *)packetbuf_hdrptr()) + sizeof(struct bitopt_hdr);
|
||||||
memset(hdrptr, 0, hdrbytesize);
|
memset(hdrptr, 0, hdrbytesize);
|
||||||
|
|
||||||
byteptr = bitptr = 0;
|
byteptr = bitptr = 0;
|
||||||
|
|
||||||
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
||||||
|
#if CHAMELEON_WITH_MAC_LINK_ADDRESSES
|
||||||
|
if(a->type == PACKETBUF_ADDR_SENDER ||
|
||||||
|
a->type == PACKETBUF_ADDR_RECEIVER) {
|
||||||
|
/* Let the link layer handle sender and receiver */
|
||||||
|
PRINTF("%d.%d: pack_header leaving sender/receiver to link layer\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* CHAMELEON_WITH_MAC_LINK_ADDRESSES */
|
||||||
PRINTF("%d.%d: pack_header type %s, len %d, bitptr %d, ",
|
PRINTF("%d.%d: pack_header type %s, len %d, bitptr %d, ",
|
||||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||||
packetbuf_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 & 0xf8) + ((a->len & 7) ? 8: 0);*/
|
||||||
len = a->len;
|
len = a->len;
|
||||||
byteptr = bitptr / 8;
|
byteptr = bitptr / 8;
|
||||||
if(a->type == PACKETBUF_ADDR_SENDER ||
|
if(PACKETBUF_IS_ADDR(a->type)) {
|
||||||
a->type == PACKETBUF_ADDR_RECEIVER ||
|
|
||||||
a->type == PACKETBUF_ADDR_ESENDER ||
|
|
||||||
a->type == PACKETBUF_ADDR_ERECEIVER) {
|
|
||||||
set_bits(&hdrptr[byteptr], bitptr & 7,
|
set_bits(&hdrptr[byteptr], bitptr & 7,
|
||||||
(uint8_t *)packetbuf_addr(a->type), len);
|
(uint8_t *)packetbuf_addr(a->type), len);
|
||||||
PRINTF("address %d.%d\n",
|
PRINTF("address %d.%d\n",
|
||||||
|
@ -266,11 +296,6 @@ pack_header(struct channel *c)
|
||||||
}
|
}
|
||||||
/* printhdr(hdrptr, hdrbytesize);*/
|
/* printhdr(hdrptr, hdrbytesize);*/
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
return 1; /* Send out packet */
|
return 1; /* Send out packet */
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -288,28 +313,39 @@ unpack_header(void)
|
||||||
/* The packet has a header that tells us what channel the packet is
|
/* The packet has a header that tells us what channel the packet is
|
||||||
for. */
|
for. */
|
||||||
hdr = (struct bitopt_hdr *)packetbuf_dataptr();
|
hdr = (struct bitopt_hdr *)packetbuf_dataptr();
|
||||||
packetbuf_hdrreduce(sizeof(struct bitopt_hdr));
|
if(packetbuf_hdrreduce(sizeof(struct bitopt_hdr)) == 0) {
|
||||||
|
PRINTF("chameleon-bitopt: too short packet\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
c = channel_lookup((hdr->channel[1] << 8) + hdr->channel[0]);
|
c = channel_lookup((hdr->channel[1] << 8) + hdr->channel[0]);
|
||||||
if(c == NULL) {
|
if(c == NULL) {
|
||||||
PRINTF("chameleon-bitopt: input: channel %d not found\n", hdr->channel);
|
PRINTF("chameleon-bitopt: input: channel %u not found\n",
|
||||||
|
(hdr->channel[1] << 8) + hdr->channel[0]);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
hdrptr = packetbuf_dataptr();
|
hdrptr = packetbuf_dataptr();
|
||||||
hdrbytesize = c->hdrsize / 8 + ((c->hdrsize & 7) == 0? 0: 1);
|
hdrbytesize = c->hdrsize / 8 + ((c->hdrsize & 7) == 0? 0: 1);
|
||||||
packetbuf_hdrreduce(hdrbytesize);
|
if(packetbuf_hdrreduce(hdrbytesize) == 0) {
|
||||||
|
PRINTF("chameleon-bitopt: too short packet\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
byteptr = bitptr = 0;
|
byteptr = bitptr = 0;
|
||||||
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
||||||
|
#if CHAMELEON_WITH_MAC_LINK_ADDRESSES
|
||||||
|
if(a->type == PACKETBUF_ADDR_SENDER ||
|
||||||
|
a->type == PACKETBUF_ADDR_RECEIVER) {
|
||||||
|
/* Let the link layer handle sender and receiver */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* CHAMELEON_WITH_MAC_LINK_ADDRESSES */
|
||||||
PRINTF("%d.%d: unpack_header type %s, len %d, bitptr %d\n",
|
PRINTF("%d.%d: unpack_header type %s, len %d, bitptr %d\n",
|
||||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||||
packetbuf_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 & 0xf8) + ((a->len & 7) ? 8: 0);*/
|
||||||
len = a->len;
|
len = a->len;
|
||||||
byteptr = bitptr / 8;
|
byteptr = bitptr / 8;
|
||||||
if(a->type == PACKETBUF_ADDR_SENDER ||
|
if(PACKETBUF_IS_ADDR(a->type)) {
|
||||||
a->type == PACKETBUF_ADDR_RECEIVER ||
|
|
||||||
a->type == PACKETBUF_ADDR_ESENDER ||
|
|
||||||
a->type == PACKETBUF_ADDR_ERECEIVER) {
|
|
||||||
rimeaddr_t addr;
|
rimeaddr_t addr;
|
||||||
get_bits((uint8_t *)&addr, &hdrptr[byteptr], bitptr & 7, len);
|
get_bits((uint8_t *)&addr, &hdrptr[byteptr], bitptr & 7, len);
|
||||||
PRINTF("%d.%d: unpack_header type %s, addr %d.%d\n",
|
PRINTF("%d.%d: unpack_header type %s, addr %d.%d\n",
|
||||||
|
@ -331,18 +367,11 @@ unpack_header(void)
|
||||||
bitptr += len;
|
bitptr += len;
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
init(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
CC_CONST_FUNCTION struct chameleon_module chameleon_bitopt = {
|
CC_CONST_FUNCTION struct chameleon_module chameleon_bitopt = {
|
||||||
unpack_header,
|
unpack_header,
|
||||||
pack_header,
|
pack_header,
|
||||||
header_size,
|
header_size
|
||||||
init
|
|
||||||
};
|
};
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: chameleon-raw.c,v 1.7 2009/09/09 21:09:42 adamdunkels Exp $
|
* $Id: chameleon-raw.c,v 1.8 2010/05/28 06:18:39 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,6 +43,17 @@
|
||||||
#include "net/rime/chameleon.h"
|
#include "net/rime/chameleon.h"
|
||||||
#include "net/rime.h"
|
#include "net/rime.h"
|
||||||
|
|
||||||
|
/* This option enables an optimization where the link addresses are
|
||||||
|
left to the MAC RDC and not encoded in the Chameleon header.
|
||||||
|
Note: this requires that the underlying MAC layer to add link
|
||||||
|
addresses and will not work together with for example nullrdc.
|
||||||
|
*/
|
||||||
|
#ifdef CHAMELEON_CONF_WITH_MAC_LINK_ADDRESSES
|
||||||
|
#define CHAMELEON_WITH_MAC_LINK_ADDRESSES CHAMELEON_CONF_WITH_MAC_LINK_ADDRESSES
|
||||||
|
#else /* !CHAMELEON_CONF_WITH_MAC_LINK_ADDRESSES */
|
||||||
|
#define CHAMELEON_WITH_MAC_LINK_ADDRESSES 0
|
||||||
|
#endif /* !CHAMELEON_CONF_WITH_MAC_LINK_ADDRESSES */
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -52,7 +63,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct raw_hdr {
|
struct raw_hdr {
|
||||||
uint16_t channel;
|
uint8_t channel[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -68,25 +79,36 @@ input(void)
|
||||||
/* The packet has a header that tells us what channel the packet is
|
/* The packet has a header that tells us what channel the packet is
|
||||||
for. */
|
for. */
|
||||||
hdr = (struct raw_hdr *)packetbuf_dataptr();
|
hdr = (struct raw_hdr *)packetbuf_dataptr();
|
||||||
packetbuf_hdrreduce(sizeof(struct raw_hdr));
|
if(packetbuf_hdrreduce(sizeof(struct raw_hdr)) == 0) {
|
||||||
c = channel_lookup(hdr->channel);
|
PRINTF("chameleon-raw: too short packet\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
c = channel_lookup((hdr->channel[1] << 8) + hdr->channel[0]);
|
||||||
if(c == NULL) {
|
if(c == NULL) {
|
||||||
PRINTF("chameleon-raw: input: channel %d not found\n", hdr->channel);
|
PRINTF("chameleon-raw: input: channel %u not found\n",
|
||||||
|
(hdr->channel[1] << 8) + hdr->channel[0]);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
hdrptr = packetbuf_dataptr();
|
hdrptr = packetbuf_dataptr();
|
||||||
packetbuf_hdrreduce(c->hdrsize);
|
if(packetbuf_hdrreduce(c->hdrsize) == 0) {
|
||||||
|
PRINTF("chameleon-raw: too short packet\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
byteptr = bitptr = 0;
|
byteptr = bitptr = 0;
|
||||||
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
||||||
|
#if CHAMELEON_WITH_MAC_LINK_ADDRESSES
|
||||||
|
if(a->type == PACKETBUF_ADDR_SENDER ||
|
||||||
|
a->type == PACKETBUF_ADDR_RECEIVER) {
|
||||||
|
/* Let the link layer handle sender and receiver */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* CHAMELEON_WITH_MAC_LINK_ADDRESSES */
|
||||||
PRINTF("%d.%d: unpack_header type %s, len %d\n",
|
PRINTF("%d.%d: unpack_header type %s, len %d\n",
|
||||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||||
packetbuf_attr_strings[a->type], a->len);
|
packetbuf_attr_strings[a->type], a->len);
|
||||||
len = (a->len & 0xf8) + ((a->len & 7) ? 8: 0);
|
len = (a->len & 0xf8) + ((a->len & 7) ? 8: 0);
|
||||||
if(a->type == PACKETBUF_ADDR_SENDER ||
|
if(PACKETBUF_IS_ADDR(a->type)) {
|
||||||
a->type == PACKETBUF_ADDR_RECEIVER ||
|
|
||||||
a->type == PACKETBUF_ADDR_ESENDER ||
|
|
||||||
a->type == PACKETBUF_ADDR_ERECEIVER) {
|
|
||||||
const rimeaddr_t addr;
|
const rimeaddr_t addr;
|
||||||
memcpy((uint8_t *)&addr, &hdrptr[byteptr], len / 8);
|
memcpy((uint8_t *)&addr, &hdrptr[byteptr], len / 8);
|
||||||
PRINTF("%d.%d: unpack_header type %s, addr %d.%d\n",
|
PRINTF("%d.%d: unpack_header type %s, addr %d.%d\n",
|
||||||
|
@ -119,18 +141,30 @@ output(struct channel *c)
|
||||||
|
|
||||||
/* Compute the total size of the final header by summing the size of
|
/* Compute the total size of the final header by summing the size of
|
||||||
all attributes that are used on this channel. */
|
all attributes that are used on this channel. */
|
||||||
packetbuf_hdralloc(c->hdrsize);
|
if(packetbuf_hdralloc(c->hdrsize + sizeof(struct raw_hdr)) == 0) {
|
||||||
hdrptr = packetbuf_hdrptr();
|
PRINTF("chameleon-raw: insufficient space for headers\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
hdr = (struct raw_hdr *)packetbuf_hdrptr();
|
||||||
|
hdr->channel[0] = c->channelno & 0xff;
|
||||||
|
hdr->channel[1] = (c->channelno >> 8) & 0xff;
|
||||||
|
|
||||||
|
hdrptr = ((uint8_t *)packetbuf_hdrptr()) + sizeof(struct raw_hdr);
|
||||||
byteptr = 0;
|
byteptr = 0;
|
||||||
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
for(a = c->attrlist; a->type != PACKETBUF_ATTR_NONE; ++a) {
|
||||||
|
#if CHAMELEON_WITH_MAC_LINK_ADDRESSES
|
||||||
|
if(a->type == PACKETBUF_ADDR_SENDER ||
|
||||||
|
a->type == PACKETBUF_ADDR_RECEIVER) {
|
||||||
|
/* Let the link layer handle sender and receiver */
|
||||||
|
PRINTF("%d.%d: pack_header leaving sender/receiver to link layer\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* CHAMELEON_WITH_MAC_LINK_ADDRESSES */
|
||||||
PRINTF("%d.%d: pack_header type %s, len %d\n",
|
PRINTF("%d.%d: pack_header type %s, len %d\n",
|
||||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||||
packetbuf_attr_strings[a->type], a->len);
|
packetbuf_attr_strings[a->type], a->len);
|
||||||
len = (a->len & 0xf8) + ((a->len & 7) ? 8: 0);
|
len = (a->len & 0xf8) + ((a->len & 7) ? 8: 0);
|
||||||
if(a->type == PACKETBUF_ADDR_SENDER ||
|
if(PACKETBUF_IS_ADDR(a->type)) {
|
||||||
a->type == PACKETBUF_ADDR_RECEIVER ||
|
|
||||||
a->type == PACKETBUF_ADDR_ESENDER ||
|
|
||||||
a->type == PACKETBUF_ADDR_ERECEIVER) {
|
|
||||||
const rimeaddr_t *rimeaddr;
|
const rimeaddr_t *rimeaddr;
|
||||||
/* memcpy(&hdrptr[byteptr], (uint8_t *)packetbuf_attr_aget(a->type), len / 8);*/
|
/* memcpy(&hdrptr[byteptr], (uint8_t *)packetbuf_attr_aget(a->type), len / 8);*/
|
||||||
rimeaddr = packetbuf_addr(a->type);
|
rimeaddr = packetbuf_addr(a->type);
|
||||||
|
@ -152,10 +186,6 @@ output(struct channel *c)
|
||||||
byteptr += len / 8;
|
byteptr += len / 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
packetbuf_hdralloc(sizeof(struct raw_hdr));
|
|
||||||
hdr = (struct raw_hdr *)packetbuf_hdrptr();
|
|
||||||
hdr->channel = c->channelno;
|
|
||||||
|
|
||||||
return 1; /* Send out packet */
|
return 1; /* Send out packet */
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -173,6 +203,13 @@ hdrsize(const struct packetbuf_attrlist *a)
|
||||||
packetbuf_attr_strings[a->type],
|
packetbuf_attr_strings[a->type],
|
||||||
a->type,
|
a->type,
|
||||||
a->len);*/
|
a->len);*/
|
||||||
|
#if CHAMELEON_WITH_MAC_LINK_ADDRESSES
|
||||||
|
if(a->type == PACKETBUF_ADDR_SENDER ||
|
||||||
|
a->type == PACKETBUF_ADDR_RECEIVER) {
|
||||||
|
/* Let the mac layer handle the sender and receiver */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif /* CHAMELEON_WITH_MAC_LINK_ADDRESSES */
|
||||||
len = a->len;
|
len = a->len;
|
||||||
if(len < 8) {
|
if(len < 8) {
|
||||||
len = 8;
|
len = 8;
|
||||||
|
@ -180,13 +217,7 @@ hdrsize(const struct packetbuf_attrlist *a)
|
||||||
size += len;
|
size += len;
|
||||||
}
|
}
|
||||||
return size / 8;
|
return size / 8;
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
static void
|
|
||||||
init(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
CC_CONST_FUNCTION struct chameleon_module chameleon_raw = { input, output,
|
CC_CONST_FUNCTION struct chameleon_module chameleon_raw = { input, output,
|
||||||
hdrsize, init };
|
hdrsize };
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: chameleon.c,v 1.9 2010/02/23 18:29:53 adamdunkels Exp $
|
* $Id: chameleon.c,v 1.10 2010/05/28 06:18:39 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +45,15 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static const struct chameleon_module *header_module;
|
#ifndef CHAMELEON_MODULE
|
||||||
|
#ifdef CHAMELEON_CONF_MODULE
|
||||||
|
#define CHAMELEON_MODULE CHAMELEON_CONF_MODULE
|
||||||
|
#else /* CHAMELEON_CONF_MODULE */
|
||||||
|
#define CHAMELEON_MODULE chameleon_bitopt
|
||||||
|
#endif /* CHAMELEON_CONF_MODULE */
|
||||||
|
#endif /* CHAMELEON_MODULE */
|
||||||
|
|
||||||
|
extern const struct chameleon_module CHAMELEON_MODULE;
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -57,9 +65,8 @@ static const struct chameleon_module *header_module;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
chameleon_init(const struct chameleon_module *m)
|
chameleon_init(void)
|
||||||
{
|
{
|
||||||
header_module = m;
|
|
||||||
channel_init();
|
channel_init();
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
@ -110,17 +117,15 @@ chameleon_parse(void)
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
printhdr(packetbuf_dataptr(), packetbuf_datalen());
|
printhdr(packetbuf_dataptr(), packetbuf_datalen());
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
if(header_module) {
|
c = CHAMELEON_MODULE.input();
|
||||||
c = header_module->input();
|
if(c != NULL) {
|
||||||
if(c != NULL) {
|
PRINTF("%d.%d: chameleon_input channel %d\n",
|
||||||
PRINTF("%d.%d: chameleon_input channel %d\n",
|
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
||||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
c->channelno);
|
||||||
c->channelno);
|
packetbuf_set_attr(PACKETBUF_ATTR_CHANNEL, c->channelno);
|
||||||
packetbuf_set_attr(PACKETBUF_ATTR_CHANNEL, c->channelno);
|
} else {
|
||||||
} else {
|
PRINTF("%d.%d: chameleon_input channel not found for incoming packet\n",
|
||||||
PRINTF("%d.%d: chameleon_input channel not found for incoming packet\n",
|
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
|
||||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -134,15 +139,13 @@ chameleon_create(struct channel *c)
|
||||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
||||||
c->channelno);
|
c->channelno);
|
||||||
|
|
||||||
if(header_module) {
|
ret = CHAMELEON_MODULE.output(c);
|
||||||
ret = header_module->output(c);
|
packetbuf_set_attr(PACKETBUF_ATTR_CHANNEL, c->channelno);
|
||||||
packetbuf_set_attr(PACKETBUF_ATTR_CHANNEL, c->channelno);
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
printhdr(packetbuf_hdrptr(), packetbuf_hdrlen());
|
printhdr(packetbuf_hdrptr(), packetbuf_hdrlen());
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
if(ret) {
|
if(ret) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -150,11 +153,6 @@ chameleon_create(struct channel *c)
|
||||||
int
|
int
|
||||||
chameleon_hdrsize(const struct packetbuf_attrlist attrlist[])
|
chameleon_hdrsize(const struct packetbuf_attrlist attrlist[])
|
||||||
{
|
{
|
||||||
if(header_module != NULL &&
|
return CHAMELEON_MODULE.hdrsize(attrlist);
|
||||||
header_module->hdrsize != NULL) {
|
|
||||||
return header_module->hdrsize(attrlist);
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: chameleon.h,v 1.3 2010/02/23 18:29:53 adamdunkels Exp $
|
* $Id: chameleon.h,v 1.4 2010/05/28 06:18:39 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,19 +41,15 @@
|
||||||
#ifndef __CHAMELEON_H__
|
#ifndef __CHAMELEON_H__
|
||||||
#define __CHAMELEON_H__
|
#define __CHAMELEON_H__
|
||||||
|
|
||||||
|
|
||||||
#include "net/rime/channel.h"
|
#include "net/rime/channel.h"
|
||||||
#include "net/rime/chameleon-bitopt.h"
|
|
||||||
#include "net/rime/chameleon-raw.h"
|
|
||||||
|
|
||||||
struct chameleon_module {
|
struct chameleon_module {
|
||||||
struct channel *(* input)(void);
|
struct channel *(* input)(void);
|
||||||
int (* output)(struct channel *);
|
int (* output)(struct channel *);
|
||||||
int (* hdrsize)(const struct packetbuf_attrlist *);
|
int (* hdrsize)(const struct packetbuf_attrlist *);
|
||||||
void (* init)(void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void chameleon_init(const struct chameleon_module *header_processing_module);
|
void chameleon_init(void);
|
||||||
|
|
||||||
int chameleon_hdrsize(const struct packetbuf_attrlist attrlist[]);
|
int chameleon_hdrsize(const struct packetbuf_attrlist attrlist[]);
|
||||||
struct channel *chameleon_parse(void);
|
struct channel *chameleon_parse(void);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: rime.c,v 1.28 2010/03/19 13:17:55 adamdunkels Exp $
|
* $Id: rime.c,v 1.29 2010/05/28 06:18:39 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,7 +152,7 @@ init(void)
|
||||||
announcement_init();
|
announcement_init();
|
||||||
|
|
||||||
rime_mac = &NETSTACK_MAC;
|
rime_mac = &NETSTACK_MAC;
|
||||||
chameleon_init(&chameleon_bitopt);
|
chameleon_init();
|
||||||
#if ! RIME_CONF_NO_POLITE_ANNOUCEMENTS
|
#if ! RIME_CONF_NO_POLITE_ANNOUCEMENTS
|
||||||
/* XXX This is initializes the transmission of announcements but it
|
/* XXX This is initializes the transmission of announcements but it
|
||||||
* is not currently certain where this initialization is supposed to
|
* is not currently certain where this initialization is supposed to
|
||||||
|
|
Loading…
Reference in a new issue