Skip to content

Commit

Permalink
Feature update: Improved MAC TX queue purge
Browse files Browse the repository at this point in the history
lowpan_adaptation_free_messages_from_queues_by_address() clear also now buffered directTX queue messages.
  • Loading branch information
Juha Heiuskanen committed Nov 12, 2020
1 parent 6926442 commit d9874ed
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
8 changes: 8 additions & 0 deletions source/6LoWPAN/adaptation_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,14 @@ int8_t lowpan_adaptation_free_messages_from_queues_by_address(struct protocol_in
}
}

//Check next directTxQueue there may be pending packets also
ns_list_foreach_safe(buffer_t, entry, &interface_ptr->directTxQueue) {
if (lowpan_tx_buffer_address_compare(&entry->dst_sa, address_ptr, adr_type)) {
ns_list_remove(&interface_ptr->directTxQueue, entry);
socket_tx_buffer_event_and_free(entry, SOCKET_TX_FAIL);
}
}

return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,43 @@ bool test_lowpan_adaptation_indirect_purge()
return false;
}

//Test to call 2 direct buffer with same address
sockaddr_t temp_address;
memset(&temp_address, 0, sizeof(sockaddr_t));
temp_address.addr_type = ADDR_802_15_4_LONG;
temp_address.address[0] = 0;
buffer_t *test_buffer[4];
for (int i = 0; i < 4; i++) {
test_buffer[i] = malloc(sizeof(buffer_t) + 2100);
if (!test_buffer[i]) {
return false;
}
memset(test_buffer[i], 0, sizeof(buffer_t));
test_buffer[i]->buf_ptr = 10;
test_buffer[i]->buf_end = 70;

test_buffer[i]->dst_sa = temp_address;
test_buffer[i]->link_specific.ieee802_15_4.indirectTxProcess = false;
test_buffer[i]->link_specific.ieee802_15_4.requestAck = true;
nsdynmemlib_stub.returnCounter = 2;
if (0 != lowpan_adaptation_interface_tx(&entry, test_buffer[i])) {
return false;
}
}
socket_stub.socket_buffer_free_cnt = 0;
if (-0
!= lowpan_adaptation_free_messages_from_queues_by_address(
&entry, temp_address.address, temp_address.addr_type)) {
return false;
}
if (socket_stub.socket_buffer_free_cnt < 4) {
return false;
}
for (int i = 0; i < 4; i++) {
//Verify That buffer is freed
free(test_buffer[i]);
}

lowpan_adaptation_interface_free(0);

nsdynmemlib_stub.returnCounter = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/nanostack/unittest/stub/socket_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ socket_t *socket_pointer_get(int8_t socket)

void socket_tx_buffer_event_and_free(buffer_t *buf, uint8_t status)
{

socket_stub.socket_buffer_free_cnt++;
}

buffer_t *socket_tx_buffer_event(buffer_t *buf, uint8_t status)
Expand Down
1 change: 1 addition & 0 deletions test/nanostack/unittest/stub/socket_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct {
socket_t *socket_structure;
int8_t socket_read_cnt;
inet_pcb_t *inet_pcb;
int socket_buffer_free_cnt;
} socket_stub_def;

extern socket_stub_def socket_stub;
Expand Down

0 comments on commit d9874ed

Please sign in to comment.