tests: net: Add a IEEE 802.15.4 ACK replies test
- Parsing a proper ACK reply - Generating a ACK reply from a data packet requesting it, and comparing it to a proper one. Change-Id: I1717fedc899eafa0aa849e1e253f02cd3dc3d4fc Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
d82d96a93d
commit
4e7efd4bcb
1 changed files with 72 additions and 0 deletions
|
@ -60,6 +60,17 @@ struct ieee802154_pkt_test test_ns_pkt = {
|
|||
.mhr_check.src_addr = (struct ieee802154_address_field *)(ns_pkt + 7),
|
||||
};
|
||||
|
||||
uint8_t ack_pkt[] = { 0x02, 0x10, 0x16, 0xa2, 0x97 };
|
||||
|
||||
struct ieee802154_pkt_test test_ack_pkt = {
|
||||
.name = "ACK frame",
|
||||
.pkt = ack_pkt,
|
||||
.length = sizeof(ack_pkt),
|
||||
.mhr_check.fc_seq = (struct ieee802154_fcf_seq *)ack_pkt,
|
||||
.mhr_check.dst_addr = NULL,
|
||||
.mhr_check.src_addr = NULL,
|
||||
};
|
||||
|
||||
struct net_buf *current_buf;
|
||||
struct nano_sem driver_lock;
|
||||
struct net_if *iface;
|
||||
|
@ -158,6 +169,59 @@ static inline int test_ns_sending(struct ieee802154_pkt_test *t)
|
|||
return TC_PASS;
|
||||
}
|
||||
|
||||
static inline int test_ack_reply(struct ieee802154_pkt_test *t)
|
||||
{
|
||||
static uint8_t data_pkt[] = {
|
||||
0x61, 0xdc, 0x16, 0xcd, 0xab, 0x26, 0x11, 0x32, 0x00, 0x00, 0x4b,
|
||||
0x12, 0x00, 0x26, 0x18, 0x32, 0x00, 0x00, 0x4b, 0x12, 0x00, 0x7b,
|
||||
0x00, 0x3a, 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x20, 0x01, 0x0d, 0xb8,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x02, 0x87, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01,
|
||||
0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
|
||||
0x16, 0xf0, 0x02, 0xff, 0x16, 0xf0, 0x12, 0xff, 0x16, 0xf0, 0x32,
|
||||
0xff, 0x16, 0xf0, 0x00, 0xff, 0x16, 0xf0, 0x00, 0xff, 0x16
|
||||
};
|
||||
struct ieee802154_mpdu mpdu;
|
||||
struct net_buf *buf, *frag;
|
||||
|
||||
TC_PRINT("- Sending ACK reply to a data packet\n");
|
||||
|
||||
buf = net_nbuf_get_reserve_rx(0);
|
||||
frag = net_nbuf_get_reserve_rx(0);
|
||||
|
||||
memcpy(frag->data, data_pkt, sizeof(data_pkt));
|
||||
frag->len = sizeof(data_pkt);
|
||||
|
||||
net_buf_frag_add(buf, frag);
|
||||
|
||||
net_recv_data(iface, buf);
|
||||
|
||||
nano_sem_take(&driver_lock, MSEC(20));
|
||||
|
||||
/* an ACK packet should be in current_buf */
|
||||
if (!current_buf) {
|
||||
TC_ERROR("*** No ACK reply sent\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
pkt_hexdump(net_nbuf_ll(current_buf), net_buf_frags_len(current_buf));
|
||||
|
||||
if (!ieee802154_validate_frame(net_nbuf_ll(current_buf),
|
||||
net_buf_frags_len(current_buf), &mpdu)) {
|
||||
TC_ERROR("*** ACK Reply is invalid\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
if (memcmp(mpdu.mhr.fs, t->mhr_check.fc_seq,
|
||||
sizeof(struct ieee802154_fcf_seq))) {
|
||||
TC_ERROR("*** ACK Reply does not compare\n");
|
||||
return TC_FAIL;
|
||||
}
|
||||
|
||||
return TC_PASS;
|
||||
}
|
||||
|
||||
static inline int initialize_test_environment(void)
|
||||
{
|
||||
struct device *dev;
|
||||
|
@ -203,6 +267,14 @@ void main(void)
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (test_packet_parsing(&test_ack_pkt) != TC_PASS) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (test_ack_reply(&test_ack_pkt) != TC_PASS) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
status = TC_PASS;
|
||||
|
||||
end:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue