mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
105 lines
3.9 KiB
Diff
105 lines
3.9 KiB
Diff
|
*** stock_iot-lab_M3/openwsn/03a-IPHC/openbridge.c Thu Apr 24 11:01:36 2014
|
||
|
--- riot-openwsn-wip/openwsn/03a-IPHC/openbridge.c Thu Apr 24 16:55:54 2014
|
||
|
***************
|
||
|
*** 9,41 ****
|
||
|
//=========================== variables =======================================
|
||
|
|
||
|
//=========================== prototypes ======================================
|
||
|
-
|
||
|
//=========================== public ==========================================
|
||
|
|
||
|
! void openbridge_init() {
|
||
|
}
|
||
|
|
||
|
! void openbridge_triggerData() {
|
||
|
uint8_t input_buffer[136];//worst case: 8B of next hop + 128B of data
|
||
|
OpenQueueEntry_t* pkt;
|
||
|
uint8_t numDataBytes;
|
||
|
!
|
||
|
numDataBytes = openserial_getNumDataBytes();
|
||
|
! openserial_getInputBuffer(&(input_buffer[0]),numDataBytes);
|
||
|
!
|
||
|
//poipoi xv
|
||
|
//this is a temporal workaround as we are never supposed to get chunks of data
|
||
|
//longer than input buffer size.. I assume that HDLC will solve that.
|
||
|
!
|
||
|
! if (numDataBytes>136){
|
||
|
openserial_printError(COMPONENT_OPENBRIDGE,ERR_INPUTBUFFER_LENGTH,
|
||
|
! (errorparameter_t)0,
|
||
|
! (errorparameter_t)numDataBytes);
|
||
|
! //return;
|
||
|
! //poipoi xv test that..
|
||
|
! numDataBytes=sizeof(input_buffer);
|
||
|
}
|
||
|
!
|
||
|
if (idmanager_getIsBridge()==TRUE && numDataBytes>0) {
|
||
|
pkt = openqueue_getFreePacketBuffer(COMPONENT_OPENBRIDGE);
|
||
|
if (pkt==NULL) {
|
||
|
--- 9,41 ----
|
||
|
//=========================== variables =======================================
|
||
|
|
||
|
//=========================== prototypes ======================================
|
||
|
//=========================== public ==========================================
|
||
|
|
||
|
! void openbridge_init(void) {
|
||
|
}
|
||
|
|
||
|
! void openbridge_triggerData(void) {
|
||
|
uint8_t input_buffer[136];//worst case: 8B of next hop + 128B of data
|
||
|
OpenQueueEntry_t* pkt;
|
||
|
uint8_t numDataBytes;
|
||
|
!
|
||
|
numDataBytes = openserial_getNumDataBytes();
|
||
|
!
|
||
|
//poipoi xv
|
||
|
//this is a temporal workaround as we are never supposed to get chunks of data
|
||
|
//longer than input buffer size.. I assume that HDLC will solve that.
|
||
|
! // MAC header is 13B + 8 next hop so we cannot accept packets that are longer than 118B
|
||
|
! if (numDataBytes>(136 - 21) || numDataBytes<8){
|
||
|
! //to prevent too short or too long serial frames to kill the stack
|
||
|
openserial_printError(COMPONENT_OPENBRIDGE,ERR_INPUTBUFFER_LENGTH,
|
||
|
! (errorparameter_t)numDataBytes,
|
||
|
! (errorparameter_t)0);
|
||
|
! return;
|
||
|
}
|
||
|
!
|
||
|
! //copying the buffer once we know it is not too big
|
||
|
! openserial_getInputBuffer(&(input_buffer[0]),numDataBytes);
|
||
|
!
|
||
|
if (idmanager_getIsBridge()==TRUE && numDataBytes>0) {
|
||
|
pkt = openqueue_getFreePacketBuffer(COMPONENT_OPENBRIDGE);
|
||
|
if (pkt==NULL) {
|
||
|
***************
|
||
|
*** 53,58 ****
|
||
|
--- 53,65 ----
|
||
|
//payload
|
||
|
packetfunctions_reserveHeaderSize(pkt,numDataBytes-8);
|
||
|
memcpy(pkt->payload,&(input_buffer[8]),numDataBytes-8);
|
||
|
+
|
||
|
+ //this is to catch the too short packet. remove it after fw-103 is solved.
|
||
|
+ if (numDataBytes<16){
|
||
|
+ openserial_printError(COMPONENT_OPENBRIDGE,ERR_INVALIDSERIALFRAME,
|
||
|
+ (errorparameter_t)0,
|
||
|
+ (errorparameter_t)0);
|
||
|
+ }
|
||
|
//send
|
||
|
if ((iphc_sendFromBridge(pkt))==E_FAIL) {
|
||
|
openqueue_freePacketBuffer(pkt);
|
||
|
***************
|
||
|
*** 60,66 ****
|
||
|
}
|
||
|
}
|
||
|
|
||
|
! void openbridge_sendDone(OpenQueueEntry_t* msg, error_t error) {
|
||
|
msg->owner = COMPONENT_OPENBRIDGE;
|
||
|
if (msg->creator!=COMPONENT_OPENBRIDGE) {
|
||
|
openserial_printError(COMPONENT_OPENBRIDGE,ERR_UNEXPECTED_SENDDONE,
|
||
|
--- 67,73 ----
|
||
|
}
|
||
|
}
|
||
|
|
||
|
! void openbridge_sendDone(OpenQueueEntry_t* msg, owerror_t error) {
|
||
|
msg->owner = COMPONENT_OPENBRIDGE;
|
||
|
if (msg->creator!=COMPONENT_OPENBRIDGE) {
|
||
|
openserial_printError(COMPONENT_OPENBRIDGE,ERR_UNEXPECTED_SENDDONE,
|