Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openstack: add mac interfaces #525

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions openstack/02a-MAClow/IEEE802154E.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,6 @@ port_INLINE void activity_synchronize_endOfFrame(PORT_TIMER_WIDTH capturedTime)

// declare synchronized
changeIsSync(TRUE);
// log the info
LOG_SUCCESS(COMPONENT_IEEE802154E, ERR_SYNCHRONIZED,
(errorparameter_t) ieee154e_vars.slotOffset,
(errorparameter_t) 0);

// send received EB up the stack so RES can update statistics (synchronizing)
notif_receive(ieee154e_vars.dataReceived);
Expand Down Expand Up @@ -926,11 +922,6 @@ port_INLINE void activity_ti1ORri1(void) {
// declare myself desynchronized
changeIsSync(FALSE);

// log the error
LOG_ERROR(COMPONENT_IEEE802154E, ERR_DESYNCHRONIZED,
(errorparameter_t)ieee154e_vars.slotOffset,
(errorparameter_t)0);

// update the statistics
ieee154e_stats.numDeSync++;

Expand Down Expand Up @@ -2665,9 +2656,26 @@ void synchronizeAck(PORT_SIGNED_INT_WIDTH timeCorrection) {
#endif
}

void __attribute__((weak)) ieee154e_indicate_sync(bool isSync)
{
if(isSync) {
// log the info
LOG_SUCCESS(COMPONENT_IEEE802154E, ERR_SYNCHRONIZED,
(errorparameter_t) ieee154e_vars.slotOffset,
(errorparameter_t) 0);
}
else {
// log the error
LOG_ERROR(COMPONENT_IEEE802154E, ERR_DESYNCHRONIZED,
(errorparameter_t)ieee154e_vars.slotOffset,
(errorparameter_t)0);

}
}

void changeIsSync(bool newIsSync) {
ieee154e_vars.isSync = newIsSync;

ieee154e_indicate_sync(newIsSync);
if (ieee154e_vars.isSync == TRUE) {
leds_sync_on();
resetStats();
Expand Down
3 changes: 3 additions & 0 deletions openstack/02a-MAClow/IEEE802154E.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ void ieee154e_startOfFrame(PORT_TIMER_WIDTH capturedTime);

void ieee154e_endOfFrame(PORT_TIMER_WIDTH capturedTime);

// weak declaration
void ieee154e_indicate_sync(bool isSync);

// misc
bool debugPrint_asn(void);

Expand Down
45 changes: 20 additions & 25 deletions openstack/02b-MAChigh/sixtop.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,7 @@ void task_sixtopNotifSendDone(void) {
break;
default:
// send the rest up the stack
#if OPENWSN_6LO_FRAGMENTATION_C
frag_sendDone(msg, msg->l2_sendDoneError);
#else
iphc_sendDone(msg, msg->l2_sendDoneError);
#endif
upper_sendDone(msg, msg->l2_sendDoneError);
break;
}
}
Expand Down Expand Up @@ -502,11 +498,7 @@ void task_sixtopNotifReceive(void) {
break;
}
// send to upper layer
#if OPENWSN_6LO_FRAGMENTATION_C
frag_receive(msg);
#else
iphc_receive(msg);
#endif
upper_receive(msg);
} else {
// free up the RAM
openqueue_freePacketBuffer(msg);
Expand Down Expand Up @@ -1074,6 +1066,23 @@ port_INLINE bool sixtop_processIEs(OpenQueueEntry_t* pkt, uint16_t* lenIE) {
return TRUE;
}

void __attribute__((weak)) sixtop_indicate_recv(uint8_t code)
{
if (code == IANA_6TOP_RC_SUCCESS) {
LOG_SUCCESS(COMPONENT_SIXTOP, ERR_SIXTOP_RETURNCODE,
(errorparameter_t) code,
(errorparameter_t) sixtop_vars.six2six_state);
} else if (code == IANA_6TOP_RC_EOL || code == IANA_6TOP_RC_BUSY || code == IANA_6TOP_RC_LOCKED) {
LOG_INFO(COMPONENT_SIXTOP, ERR_SIXTOP_RETURNCODE,
(errorparameter_t) code,
(errorparameter_t) sixtop_vars.six2six_state);
} else {
LOG_ERROR(COMPONENT_SIXTOP, ERR_SIXTOP_RETURNCODE,
(errorparameter_t) code,
(errorparameter_t) sixtop_vars.six2six_state);
}
}

void sixtop_six2six_notifyReceive(
uint8_t version,
uint8_t type,
Expand Down Expand Up @@ -1586,21 +1595,7 @@ void sixtop_six2six_notifyReceive(
sixtop_vars.cb_sf_handleRCError(code, &(pkt->l2_nextORpreviousHop));
}

if (code == IANA_6TOP_RC_SUCCESS) {
LOG_SUCCESS(COMPONENT_SIXTOP, ERR_SIXTOP_RETURNCODE,
(errorparameter_t)
code,
(errorparameter_t)
sixtop_vars.six2six_state);
} else if (code == IANA_6TOP_RC_EOL || code == IANA_6TOP_RC_BUSY || code == IANA_6TOP_RC_LOCKED) {
LOG_INFO(COMPONENT_SIXTOP, ERR_SIXTOP_RETURNCODE,
(errorparameter_t) code,
(errorparameter_t) sixtop_vars.six2six_state);
} else {
LOG_ERROR(COMPONENT_SIXTOP, ERR_SIXTOP_RETURNCODE,
(errorparameter_t) code,
(errorparameter_t) sixtop_vars.six2six_state);
}
sixtop_indicate_recv(code);

memset(&sixtop_vars.neighborToClearCells, 0, sizeof(open_addr_t));
sixtop_vars.six2six_state = SIX_STATE_IDLE;
Expand Down
8 changes: 6 additions & 2 deletions openstack/02b-MAChigh/sixtop.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ owerror_t sixtop_request(
// from upper layer
owerror_t sixtop_send(OpenQueueEntry_t *msg);

// to upper layer
void upper_sendDone(OpenQueueEntry_t *msg, owerror_t error);
void upper_receive(OpenQueueEntry_t *msg);

void sixtop_indicate_recv(uint8_t code);

// from lower layer
void task_sixtopNotifSendDone(void);

Expand All @@ -163,5 +169,3 @@ bool debugPrint_kaPeriod(void);
*/

#endif /* OPENWSN_SIXTOP_H */


22 changes: 16 additions & 6 deletions openstack/03a-IPHC/frag.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ owerror_t frag_timerq_remove(opentimers_id_t id);
opentimers_id_t frag_timerq_dequeue(void);
//============================= public ========================================

void upper_sendDone(OpenQueueEntry_t *msg, owerror_t error)
{
iphc_sendDone(msg, error);
}

void upper_receive(OpenQueueEntry_t *msg)
{
iphc_receive(msg);
}

void frag_init() {
memset(&frag_vars, 0, sizeof(frag_vars_t));

Expand Down Expand Up @@ -251,13 +261,13 @@ void frag_sendDone(OpenQueueEntry_t *msg, owerror_t sendError) {
}

if (frags_queued == FALSE) {
iphc_sendDone(original_msg, sendError);
upper_sendDone(original_msg, sendError);
}

} else if (sendError == E_FAIL && upward_relay == FALSE) {
// transmission failed, remove the other fragments that are not locked in for transmission
cleanup_fragments(datagram_tag);
iphc_sendDone(original_msg, sendError);
upper_sendDone(original_msg, sendError);
} else {
openqueue_freePacketBuffer(msg);
}
Expand All @@ -280,7 +290,7 @@ void frag_sendDone(OpenQueueEntry_t *msg, owerror_t sendError) {

} else {
// if the sent msg is not a fragment, just pass along to higher layer
iphc_sendDone(msg, sendError);
upper_sendDone(msg, sendError);
}
}

Expand Down Expand Up @@ -335,7 +345,7 @@ void frag_receive(OpenQueueEntry_t *msg) {
// fast forwarding / source routing
msg->creator = COMPONENT_FRAG;
allocate_vrb(msg, size, tag);
iphc_receive(msg);
upper_receive(msg);
}
}
} else if (dispatch == DISPATCH_FRAG_SUBSEQ) {
Expand Down Expand Up @@ -406,7 +416,7 @@ void frag_receive(OpenQueueEntry_t *msg) {
}
} else {
// not a fragment
iphc_receive(msg);
upper_receive(msg);
}
}

Expand Down Expand Up @@ -530,7 +540,7 @@ static void store_fragment(OpenQueueEntry_t *msg, uint16_t size, uint16_t tag, u
if (reassembled_msg == NULL) {
return;
} else {
iphc_receive(reassembled_msg);
upper_receive(reassembled_msg);
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions openstack/03a-IPHC/iphc.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ uint8_t iphc_getAsnLen(uint8_t* asn);

//=========================== public ==========================================

#if !OPENWSN_6LO_FRAGMENTATION_C
void upper_sendDone(OpenQueueEntry_t *msg, owerror_t error)
{
iphc_sendDone(msg, error);
}

void upper_receive(OpenQueueEntry_t *msg)
{
iphc_receive(msg);
}
#endif

void iphc_init(void) {
}

Expand Down