tests: ieee802154: Remove double new line from logs
NET_XXX() functions already add newline. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
cde428cbca
commit
a4a4e6872c
|
@ -216,7 +216,7 @@ static int disassociate(struct net_if *iface, struct ieee802154_context *ctx)
|
|||
&short_addr_not_associated,
|
||||
sizeof(short_addr_not_associated));
|
||||
if (ret) {
|
||||
NET_ERR("*** Failed to %s.\n", __func__);
|
||||
NET_ERR("*** Failed to %s.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -235,14 +235,14 @@ static int associate(struct net_if *iface, struct ieee802154_context *ctx, uint1
|
|||
ret = net_mgmt(NET_REQUEST_IEEE802154_SET_PAN_ID, iface, &mock_pan_id,
|
||||
sizeof(mock_pan_id));
|
||||
if (ret) {
|
||||
NET_ERR("*** Failed to set PAN ID in %s.\n", __func__);
|
||||
NET_ERR("*** Failed to set PAN ID in %s.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = net_mgmt(NET_REQUEST_IEEE802154_SET_SHORT_ADDR, iface, &short_addr,
|
||||
sizeof(short_addr));
|
||||
if (ret) {
|
||||
NET_ERR("*** Failed to set short addr in %s.\n", __func__);
|
||||
NET_ERR("*** Failed to set short addr in %s.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ static struct net_pkt *get_data_pkt_with_ar(void)
|
|||
pkt = net_pkt_rx_alloc_with_buffer(net_iface, sizeof(data_pkt_with_ar), AF_UNSPEC, 0,
|
||||
K_FOREVER);
|
||||
if (!pkt) {
|
||||
NET_ERR("*** No buffer to allocate\n");
|
||||
NET_ERR("*** No buffer to allocate");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,7 @@ static bool set_up_security(uint8_t security_level)
|
|||
|
||||
if (net_mgmt(NET_REQUEST_IEEE802154_SET_SECURITY_SETTINGS, net_iface, ¶ms,
|
||||
sizeof(struct ieee802154_security_params))) {
|
||||
NET_ERR("*** Failed to set security settings\n");
|
||||
NET_ERR("*** Failed to set security settings");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ static bool tear_down_security(void)
|
|||
|
||||
if (net_mgmt(NET_REQUEST_IEEE802154_SET_SECURITY_SETTINGS, net_iface, ¶ms,
|
||||
sizeof(struct ieee802154_security_params))) {
|
||||
NET_ERR("*** Failed to tear down security settings\n");
|
||||
NET_ERR("*** Failed to tear down security settings");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -407,17 +407,17 @@ static int set_up_recv_socket(enum net_sock_type socket_type)
|
|||
|
||||
fd = socket(AF_PACKET, socket_type, ETH_P_IEEE802154);
|
||||
if (fd < 0) {
|
||||
NET_ERR("*** Failed to create recv socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to create recv socket : %d", errno);
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (bind(fd, (const struct sockaddr *)&socket_sll, sizeof(struct sockaddr_ll))) {
|
||||
NET_ERR("*** Failed to bind packet socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to bind packet socket : %d", errno);
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeo_optval, sizeof(timeo_optval))) {
|
||||
NET_ERR("*** Failed to set reception timeout on packet socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to set reception timeout on packet socket : %d", errno);
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
|
@ -433,31 +433,31 @@ static bool test_packet_parsing(struct ieee802154_pkt_test *t)
|
|||
{
|
||||
struct ieee802154_mpdu mpdu = {0};
|
||||
|
||||
NET_INFO("- Parsing packet 0x%p of frame %s\n", t->pkt, t->name);
|
||||
NET_INFO("- Parsing packet 0x%p of frame %s", t->pkt, t->name);
|
||||
|
||||
if (!ieee802154_validate_frame(t->pkt, t->length, &mpdu)) {
|
||||
NET_ERR("*** Could not validate frame %s\n", t->name);
|
||||
NET_ERR("*** Could not validate frame %s", t->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mpdu.mhr.fs != t->mhr_check.fc_seq ||
|
||||
mpdu.mhr.dst_addr != t->mhr_check.dst_addr ||
|
||||
mpdu.mhr.src_addr != t->mhr_check.src_addr) {
|
||||
NET_INFO("d: %p vs %p -- s: %p vs %p\n",
|
||||
NET_INFO("d: %p vs %p -- s: %p vs %p",
|
||||
mpdu.mhr.dst_addr, t->mhr_check.dst_addr,
|
||||
mpdu.mhr.src_addr, t->mhr_check.src_addr);
|
||||
NET_ERR("*** Wrong MPDU information on frame %s\n", t->name);
|
||||
NET_ERR("*** Wrong MPDU information on frame %s", t->name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mpdu.mhr.fs->sequence != t->sequence) {
|
||||
NET_ERR("*** Invalid sequence number for frame %s\n", t->name);
|
||||
NET_ERR("*** Invalid sequence number for frame %s", t->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mpdu.payload_length != t->payload_length) {
|
||||
NET_ERR("*** Invalid payload length for frame %s\n", t->name);
|
||||
NET_ERR("*** Invalid payload length for frame %s", t->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -470,7 +470,7 @@ static bool test_ns_sending(struct ieee802154_pkt_test *t, bool with_short_addr)
|
|||
struct ieee802154_mpdu mpdu;
|
||||
bool result = false;
|
||||
|
||||
NET_INFO("- Sending NS packet\n");
|
||||
NET_INFO("- Sending NS packet");
|
||||
|
||||
/* ensure reproducible results */
|
||||
ctx->sequence = t->sequence;
|
||||
|
@ -480,7 +480,7 @@ static bool test_ns_sending(struct ieee802154_pkt_test *t, bool with_short_addr)
|
|||
}
|
||||
|
||||
if (net_ipv6_send_ns(net_iface, NULL, &t->src, &t->dst, &t->dst, false)) {
|
||||
NET_ERR("*** Could not create IPv6 NS packet\n");
|
||||
NET_ERR("*** Could not create IPv6 NS packet");
|
||||
tear_down_short_addr(net_iface, ctx);
|
||||
goto out;
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ static bool test_ns_sending(struct ieee802154_pkt_test *t, bool with_short_addr)
|
|||
k_sem_take(&driver_lock, K_SECONDS(1));
|
||||
|
||||
if (!current_pkt->frags) {
|
||||
NET_ERR("*** Could not send IPv6 NS packet\n");
|
||||
NET_ERR("*** Could not send IPv6 NS packet");
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -500,14 +500,14 @@ static bool test_ns_sending(struct ieee802154_pkt_test *t, bool with_short_addr)
|
|||
if (!with_short_addr) {
|
||||
if (net_pkt_get_len(current_pkt) != t->length ||
|
||||
memcmp(net_pkt_data(current_pkt), t->pkt, t->length)) {
|
||||
NET_ERR("*** Sent packet deviates from expected packet\n");
|
||||
NET_ERR("*** Sent packet deviates from expected packet");
|
||||
goto release_frag;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ieee802154_validate_frame(net_pkt_data(current_pkt),
|
||||
net_pkt_get_len(current_pkt), &mpdu)) {
|
||||
NET_ERR("*** Sent packet is not valid\n");
|
||||
NET_ERR("*** Sent packet is not valid");
|
||||
goto release_frag;
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ static bool test_wait_for_ack(struct ieee802154_pkt_test *t)
|
|||
bool result = false;
|
||||
bool ack_required;
|
||||
|
||||
NET_INFO("- Waiting for ACK reply when sending a data packet\n");
|
||||
NET_INFO("- Waiting for ACK reply when sending a data packet");
|
||||
|
||||
tx_pkt = get_data_pkt_with_ar();
|
||||
if (!tx_pkt) {
|
||||
|
@ -537,36 +537,36 @@ static bool test_wait_for_ack(struct ieee802154_pkt_test *t)
|
|||
|
||||
ack_required = ieee802154_prepare_for_ack(net_iface, tx_pkt, tx_pkt->frags);
|
||||
if (!ack_required) {
|
||||
NET_ERR("*** Expected AR flag to be set\n");
|
||||
NET_ERR("*** Expected AR flag to be set");
|
||||
goto release_tx_pkt;
|
||||
}
|
||||
|
||||
if (!ieee802154_validate_frame(net_pkt_data(tx_pkt), net_pkt_get_len(tx_pkt), &mpdu)) {
|
||||
NET_ERR("*** Could not parse data pkt.\n");
|
||||
NET_ERR("*** Could not parse data pkt.");
|
||||
goto release_tx_pkt;
|
||||
}
|
||||
|
||||
one_ack_pkt = net_pkt_rx_alloc_with_buffer(net_iface, IEEE802154_ACK_PKT_LENGTH,
|
||||
AF_UNSPEC, 0, K_FOREVER);
|
||||
if (!one_ack_pkt) {
|
||||
NET_ERR("*** Could not allocate ack pkt.\n");
|
||||
NET_ERR("*** Could not allocate ack pkt.");
|
||||
goto release_tx_pkt;
|
||||
}
|
||||
|
||||
if (!ieee802154_create_ack_frame(net_iface, one_ack_pkt, mpdu.mhr.fs->sequence)) {
|
||||
NET_ERR("*** Could not create ack frame.\n");
|
||||
NET_ERR("*** Could not create ack frame.");
|
||||
goto release_tx_pkt;
|
||||
}
|
||||
|
||||
pkt_hexdump(net_pkt_data(one_ack_pkt), net_pkt_get_len(one_ack_pkt));
|
||||
|
||||
if (ieee802154_handle_ack(net_iface, one_ack_pkt) != NET_OK) {
|
||||
NET_ERR("*** Ack frame was not handled.\n");
|
||||
NET_ERR("*** Ack frame was not handled.");
|
||||
goto release_ack_pkt;
|
||||
}
|
||||
|
||||
if (ieee802154_wait_for_ack(net_iface, ack_required) != 0) {
|
||||
NET_ERR("*** Ack frame was not recorded.\n");
|
||||
NET_ERR("*** Ack frame was not recorded.");
|
||||
goto release_ack_pkt;
|
||||
}
|
||||
|
||||
|
@ -585,11 +585,11 @@ static bool test_packet_cloning_with_cb(void)
|
|||
struct net_pkt *pkt;
|
||||
struct net_pkt *cloned_pkt;
|
||||
|
||||
NET_INFO("- Cloning packet\n");
|
||||
NET_INFO("- Cloning packet");
|
||||
|
||||
pkt = net_pkt_rx_alloc_with_buffer(net_iface, 64, AF_UNSPEC, 0, K_NO_WAIT);
|
||||
if (!pkt) {
|
||||
NET_ERR("*** No buffer to allocate\n");
|
||||
NET_ERR("*** No buffer to allocate");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -619,11 +619,11 @@ static bool test_packet_rssi_conversion(void)
|
|||
int8_t signed_rssi_dbm;
|
||||
struct net_pkt *pkt;
|
||||
|
||||
NET_INFO("- RSSI conversion between unsigned and signed representation\n");
|
||||
NET_INFO("- RSSI conversion between unsigned and signed representation");
|
||||
|
||||
pkt = net_pkt_rx_alloc_on_iface(net_iface, K_NO_WAIT);
|
||||
if (!pkt) {
|
||||
NET_ERR("*** No pkt to allocate\n");
|
||||
NET_ERR("*** No pkt to allocate");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -696,10 +696,10 @@ static bool test_dgram_packet_sending(void *dst_sll, uint8_t dst_sll_halen, uint
|
|||
goto out;
|
||||
}
|
||||
|
||||
NET_INFO("- Sending DGRAM packet via AF_PACKET socket\n");
|
||||
NET_INFO("- Sending DGRAM packet via AF_PACKET socket");
|
||||
fd = socket(AF_PACKET, SOCK_DGRAM, ETH_P_IEEE802154);
|
||||
if (fd < 0) {
|
||||
NET_ERR("*** Failed to create DGRAM socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to create DGRAM socket : %d", errno);
|
||||
goto reset_security;
|
||||
}
|
||||
|
||||
|
@ -716,13 +716,13 @@ static bool test_dgram_packet_sending(void *dst_sll, uint8_t dst_sll_halen, uint
|
|||
}
|
||||
|
||||
if (bind(fd, (const struct sockaddr *)&socket_sll, sizeof(struct sockaddr_ll))) {
|
||||
NET_ERR("*** Failed to bind packet socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to bind packet socket : %d", errno);
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
if (sendto(fd, payload, sizeof(payload), 0, (const struct sockaddr *)&pkt_dst_sll,
|
||||
sizeof(struct sockaddr_ll)) != sizeof(payload)) {
|
||||
NET_ERR("*** Failed to send, errno %d\n", errno);
|
||||
NET_ERR("*** Failed to send, errno %d", errno);
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
|
@ -730,7 +730,7 @@ static bool test_dgram_packet_sending(void *dst_sll, uint8_t dst_sll_halen, uint
|
|||
k_sem_take(&driver_lock, K_SECONDS(1));
|
||||
|
||||
if (!current_pkt->frags) {
|
||||
NET_ERR("*** Could not send DGRAM packet\n");
|
||||
NET_ERR("*** Could not send DGRAM packet");
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
|
@ -738,7 +738,7 @@ static bool test_dgram_packet_sending(void *dst_sll, uint8_t dst_sll_halen, uint
|
|||
|
||||
if (!ieee802154_validate_frame(net_pkt_data(current_pkt),
|
||||
net_pkt_get_len(current_pkt), &mpdu)) {
|
||||
NET_ERR("*** Sent packet is not valid\n");
|
||||
NET_ERR("*** Sent packet is not valid");
|
||||
goto release_frag;
|
||||
}
|
||||
|
||||
|
@ -746,12 +746,12 @@ static bool test_dgram_packet_sending(void *dst_sll, uint8_t dst_sll_halen, uint
|
|||
net_pkt_lladdr_src(current_pkt)->len = net_if_get_link_addr(net_iface)->len;
|
||||
|
||||
if (!ieee802154_decipher_data_frame(net_iface, current_pkt, &mpdu)) {
|
||||
NET_ERR("*** Cannot decipher/authenticate packet\n");
|
||||
NET_ERR("*** Cannot decipher/authenticate packet");
|
||||
goto release_frag;
|
||||
}
|
||||
|
||||
if (memcmp(mpdu.payload, payload, sizeof(payload)) != 0) {
|
||||
NET_ERR("*** Payload of sent packet is incorrect\n");
|
||||
NET_ERR("*** Payload of sent packet is incorrect");
|
||||
goto release_frag;
|
||||
}
|
||||
|
||||
|
@ -796,7 +796,7 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l
|
|||
goto out;
|
||||
}
|
||||
|
||||
NET_INFO("- Receiving DGRAM packet via AF_PACKET socket\n");
|
||||
NET_INFO("- Receiving DGRAM packet via AF_PACKET socket");
|
||||
|
||||
fd = set_up_recv_socket(SOCK_DGRAM);
|
||||
if (fd < 0) {
|
||||
|
@ -805,7 +805,7 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l
|
|||
|
||||
pkt = net_pkt_rx_alloc(K_FOREVER);
|
||||
if (!pkt) {
|
||||
NET_ERR("*** Failed to allocate net pkt.\n");
|
||||
NET_ERR("*** Failed to allocate net pkt.");
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
|
@ -817,14 +817,14 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l
|
|||
src_ll_addr_len == IEEE802154_EXT_ADDR_LENGTH) {
|
||||
pkt->lladdr_src.addr = src_ll_addr;
|
||||
} else {
|
||||
NET_ERR("*** Illegal L2 source address length.\n");
|
||||
NET_ERR("*** Illegal L2 source address length.");
|
||||
goto release_pkt;
|
||||
}
|
||||
pkt->lladdr_src.len = src_ll_addr_len;
|
||||
|
||||
frame_buf = net_pkt_get_frag(pkt, IEEE802154_MTU, K_FOREVER);
|
||||
if (!frame_buf) {
|
||||
NET_ERR("*** Failed to allocate net pkt frag.\n");
|
||||
NET_ERR("*** Failed to allocate net pkt frag.");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
|
@ -844,7 +844,7 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l
|
|||
} else if (src_ll_addr_len == IEEE802154_EXT_ADDR_LENGTH) {
|
||||
sys_memcpy_swap(ctx->ext_addr, src_ll_addr, sizeof(ctx->ext_addr));
|
||||
} else {
|
||||
NET_ERR("*** Illegal L2 source address length.\n");
|
||||
NET_ERR("*** Illegal L2 source address length.");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
|
@ -858,19 +858,19 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l
|
|||
}
|
||||
|
||||
if (!frame_result) {
|
||||
NET_ERR("*** Error while creating data frame.\n");
|
||||
NET_ERR("*** Error while creating data frame.");
|
||||
goto release_pkt;
|
||||
};
|
||||
|
||||
net_pkt_frag_add(pkt, frame_buf);
|
||||
|
||||
if (net_recv_data(net_iface, pkt)) {
|
||||
NET_ERR("*** Error while processing packet.\n");
|
||||
NET_ERR("*** Error while processing packet.");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
if (current_pkt->frags) {
|
||||
NET_ERR("*** Generated unexpected (ACK?) packet when processing packet.\n");
|
||||
NET_ERR("*** Generated unexpected (ACK?) packet when processing packet.");
|
||||
net_pkt_frag_unref(current_pkt->frags);
|
||||
current_pkt->frags = NULL;
|
||||
goto release_pkt;
|
||||
|
@ -880,14 +880,14 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l
|
|||
received_len = recvfrom(fd, received_payload, sizeof(received_payload), 0,
|
||||
(struct sockaddr *)&recv_src_sll, &recv_src_sll_len);
|
||||
if (received_len < 0) {
|
||||
NET_ERR("*** Failed to receive packet, errno %d\n", errno);
|
||||
NET_ERR("*** Failed to receive packet, errno %d", errno);
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
pkt_hexdump(received_payload, received_len);
|
||||
|
||||
if (received_len != sizeof(payload) || memcmp(received_payload, payload, sizeof(payload))) {
|
||||
NET_ERR("*** Payload of received packet is incorrect\n");
|
||||
NET_ERR("*** Payload of received packet is incorrect");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
|
@ -896,7 +896,7 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l
|
|||
recv_src_sll.sll_ifindex != net_if_get_by_iface(net_iface) ||
|
||||
recv_src_sll.sll_halen != src_ll_addr_len ||
|
||||
memcmp(recv_src_sll.sll_addr, src_ll_addr, src_ll_addr_len)) {
|
||||
NET_ERR("*** Source L2 address of received packet is incorrect\n");
|
||||
NET_ERR("*** Source L2 address of received packet is incorrect");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
|
@ -922,11 +922,11 @@ static bool test_raw_packet_sending(void)
|
|||
bool result = false;
|
||||
int fd;
|
||||
|
||||
NET_INFO("- Sending RAW packet via AF_PACKET socket\n");
|
||||
NET_INFO("- Sending RAW packet via AF_PACKET socket");
|
||||
|
||||
fd = socket(AF_PACKET, SOCK_RAW, ETH_P_IEEE802154);
|
||||
if (fd < 0) {
|
||||
NET_ERR("*** Failed to create RAW socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to create RAW socket : %d", errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -935,7 +935,7 @@ static bool test_raw_packet_sending(void)
|
|||
socket_sll.sll_protocol = ETH_P_IEEE802154;
|
||||
|
||||
if (bind(fd, (const struct sockaddr *)&socket_sll, sizeof(struct sockaddr_ll))) {
|
||||
NET_ERR("*** Failed to bind packet socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to bind packet socket : %d", errno);
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
|
@ -945,7 +945,7 @@ static bool test_raw_packet_sending(void)
|
|||
msg.msg_iovlen = 1;
|
||||
|
||||
if (sendmsg(fd, &msg, 0) != sizeof(raw_payload)) {
|
||||
NET_ERR("*** Failed to send, errno %d\n", errno);
|
||||
NET_ERR("*** Failed to send, errno %d", errno);
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
|
@ -953,7 +953,7 @@ static bool test_raw_packet_sending(void)
|
|||
k_sem_take(&driver_lock, K_SECONDS(1));
|
||||
|
||||
if (!current_pkt->frags) {
|
||||
NET_ERR("*** Could not send RAW packet\n");
|
||||
NET_ERR("*** Could not send RAW packet");
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
|
@ -961,13 +961,13 @@ static bool test_raw_packet_sending(void)
|
|||
|
||||
if (!ieee802154_validate_frame(net_pkt_data(current_pkt),
|
||||
net_pkt_get_len(current_pkt), &mpdu)) {
|
||||
NET_ERR("*** Sent packet is not valid\n");
|
||||
NET_ERR("*** Sent packet is not valid");
|
||||
goto release_frag;
|
||||
}
|
||||
|
||||
if (memcmp(mpdu.payload, &raw_payload[RAW_MAC_PAYLOAD_START_INDEX],
|
||||
RAW_MAC_PAYLOAD_LENGTH) != 0) {
|
||||
NET_ERR("*** Payload of sent packet is incorrect\n");
|
||||
NET_ERR("*** Payload of sent packet is incorrect");
|
||||
goto release_frag;
|
||||
}
|
||||
|
||||
|
@ -993,7 +993,7 @@ static bool test_raw_packet_reception(void)
|
|||
|
||||
result = false;
|
||||
|
||||
NET_INFO("- Receiving RAW packet via AF_PACKET socket\n");
|
||||
NET_INFO("- Receiving RAW packet via AF_PACKET socket");
|
||||
|
||||
fd = set_up_recv_socket(SOCK_RAW);
|
||||
if (fd < 0) {
|
||||
|
@ -1002,13 +1002,13 @@ static bool test_raw_packet_reception(void)
|
|||
|
||||
pkt = net_pkt_rx_alloc(K_FOREVER);
|
||||
if (!pkt) {
|
||||
NET_ERR("*** Failed to allocate net pkt.\n");
|
||||
NET_ERR("*** Failed to allocate net pkt.");
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
frame_buf = net_pkt_get_frag(pkt, sizeof(raw_payload), K_FOREVER);
|
||||
if (!frame_buf) {
|
||||
NET_ERR("*** Failed to allocate net pkt frag.\n");
|
||||
NET_ERR("*** Failed to allocate net pkt frag.");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
|
@ -1016,12 +1016,12 @@ static bool test_raw_packet_reception(void)
|
|||
net_pkt_frag_add(pkt, frame_buf);
|
||||
|
||||
if (net_recv_data(net_iface, pkt)) {
|
||||
NET_ERR("*** Error while processing packet.\n");
|
||||
NET_ERR("*** Error while processing packet.");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
if (current_pkt->frags) {
|
||||
NET_ERR("*** Generated unexpected packet when processing packet.\n");
|
||||
NET_ERR("*** Generated unexpected packet when processing packet.");
|
||||
net_pkt_frag_unref(current_pkt->frags);
|
||||
current_pkt->frags = NULL;
|
||||
goto release_pkt;
|
||||
|
@ -1033,7 +1033,7 @@ static bool test_raw_packet_reception(void)
|
|||
*/
|
||||
received_len = recv(fd, received_payload, sizeof(received_payload), 0);
|
||||
if (received_len < 0) {
|
||||
NET_ERR("*** Failed to receive packet, errno %d\n", errno);
|
||||
NET_ERR("*** Failed to receive packet, errno %d", errno);
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
|
@ -1049,7 +1049,7 @@ static bool test_raw_packet_reception(void)
|
|||
*/
|
||||
if (received_len != sizeof(raw_payload) ||
|
||||
memcmp(received_payload, raw_payload, sizeof(raw_payload))) {
|
||||
NET_ERR("*** Payload of received packet is incorrect\n");
|
||||
NET_ERR("*** Payload of received packet is incorrect");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
|
@ -1106,21 +1106,21 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t)
|
|||
int received_len;
|
||||
int fd;
|
||||
|
||||
NET_INFO("- Sending ACK reply to a data packet\n");
|
||||
NET_INFO("- Sending ACK reply to a data packet");
|
||||
|
||||
fd = socket(AF_PACKET, SOCK_DGRAM, ETH_P_IEEE802154);
|
||||
if (fd < 0) {
|
||||
NET_ERR("*** Failed to create DGRAM socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to create DGRAM socket : %d", errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (bind(fd, (const struct sockaddr *)&socket_sll, sizeof(struct sockaddr_ll))) {
|
||||
NET_ERR("*** Failed to bind packet socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to bind packet socket : %d", errno);
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeo_optval, sizeof(timeo_optval))) {
|
||||
NET_ERR("*** Failed to set reception timeout on packet socket : %d\n", errno);
|
||||
NET_ERR("*** Failed to set reception timeout on packet socket : %d", errno);
|
||||
goto release_fd;
|
||||
}
|
||||
|
||||
|
@ -1142,7 +1142,7 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t)
|
|||
received_len = recvfrom(fd, received_payload, sizeof(received_payload), 0,
|
||||
(struct sockaddr *)&recv_src_sll, &recv_src_sll_len);
|
||||
if (received_len < 0) {
|
||||
NET_ERR("*** Failed to receive packet, errno %d\n", errno);
|
||||
NET_ERR("*** Failed to receive packet, errno %d", errno);
|
||||
goto release_rx_pkt;
|
||||
}
|
||||
|
||||
|
@ -1152,7 +1152,7 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t)
|
|||
recv_src_sll.sll_family != AF_PACKET || recv_src_sll.sll_protocol != ETH_P_IEEE802154 ||
|
||||
recv_src_sll.sll_halen != IEEE802154_EXT_ADDR_LENGTH ||
|
||||
memcmp(recv_src_sll.sll_addr, mac_be, IEEE802154_EXT_ADDR_LENGTH)) {
|
||||
NET_ERR("*** Received socket address does not compare\n", errno);
|
||||
NET_ERR("*** Received socket address does not compare", errno);
|
||||
goto release_rx_pkt;
|
||||
}
|
||||
|
||||
|
@ -1160,7 +1160,7 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t)
|
|||
|
||||
if (memcmp(expected_rx_pkt, received_payload,
|
||||
sizeof(expected_rx_pkt))) {
|
||||
NET_ERR("*** Received uncompressed IPv6 payload does not compare\n");
|
||||
NET_ERR("*** Received uncompressed IPv6 payload does not compare");
|
||||
goto release_rx_pkt;
|
||||
}
|
||||
|
||||
|
@ -1169,7 +1169,7 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t)
|
|||
|
||||
/* an ACK packet should be in current_pkt */
|
||||
if (!current_pkt->frags) {
|
||||
NET_ERR("*** No ACK reply sent\n");
|
||||
NET_ERR("*** No ACK reply sent");
|
||||
goto release_rx_pkt;
|
||||
}
|
||||
|
||||
|
@ -1177,18 +1177,18 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t)
|
|||
|
||||
if (!ieee802154_validate_frame(net_pkt_data(current_pkt),
|
||||
net_pkt_get_len(current_pkt), &mpdu)) {
|
||||
NET_ERR("*** ACK Reply is invalid\n");
|
||||
NET_ERR("*** ACK Reply is invalid");
|
||||
goto release_tx_frag;
|
||||
}
|
||||
|
||||
if (memcmp(mpdu.mhr.fs, t->mhr_check.fc_seq,
|
||||
sizeof(struct ieee802154_fcf_seq))) {
|
||||
NET_ERR("*** ACK Reply does not compare\n");
|
||||
NET_ERR("*** ACK Reply does not compare");
|
||||
goto release_tx_frag;
|
||||
}
|
||||
|
||||
if (mpdu.mhr.fs->sequence != t->sequence) {
|
||||
NET_ERR("*** Sequence number invalid\n");
|
||||
NET_ERR("*** Sequence number invalid");
|
||||
goto release_tx_frag;
|
||||
}
|
||||
|
||||
|
@ -1217,29 +1217,29 @@ static bool initialize_test_environment(void)
|
|||
|
||||
current_pkt = net_pkt_rx_alloc(K_FOREVER);
|
||||
if (!current_pkt) {
|
||||
NET_ERR("*** No buffer to allocate\n");
|
||||
NET_ERR("*** No buffer to allocate");
|
||||
return false;
|
||||
}
|
||||
|
||||
dev = device_get_binding("fake_ieee802154");
|
||||
if (!dev) {
|
||||
NET_ERR("*** Could not get fake device\n");
|
||||
NET_ERR("*** Could not get fake device");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
net_iface = net_if_lookup_by_dev(dev);
|
||||
if (!net_iface) {
|
||||
NET_ERR("*** Could not get fake iface\n");
|
||||
NET_ERR("*** Could not get fake iface");
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
if (net_mgmt(NET_REQUEST_IEEE802154_SET_PAN_ID, net_iface,
|
||||
&mock_pan_id, sizeof(mock_pan_id))) {
|
||||
NET_ERR("*** Failed to set PAN ID in %s.\n", __func__);
|
||||
NET_ERR("*** Failed to set PAN ID in %s.", __func__);
|
||||
goto release_pkt;
|
||||
}
|
||||
|
||||
NET_INFO("Fake IEEE 802.15.4 network interface ready\n");
|
||||
NET_INFO("Fake IEEE 802.15.4 network interface ready");
|
||||
|
||||
ieee_addr_hexdump(net_if_get_link_addr(net_iface)->addr, 8);
|
||||
|
||||
|
|
Loading…
Reference in a new issue