diff --git a/tests/net/arp/src/main.c b/tests/net/arp/src/main.c index b5bcf8d26c..7996581228 100644 --- a/tests/net/arp/src/main.c +++ b/tests/net/arp/src/main.c @@ -41,7 +41,7 @@ static struct net_eth_addr *expected_hwaddr; static struct net_pkt *pending_pkt; -static struct net_eth_addr hwaddr = { { 0x42, 0x11, 0x69, 0xde, 0xfa, 0xec } }; +static struct net_eth_addr eth_hwaddr = { { 0x42, 0x11, 0x69, 0xde, 0xfa, 0xec } }; static int send_status = -EINVAL; @@ -107,7 +107,7 @@ static int tester_send(const struct device *dev, struct net_pkt *pkt) return -EINVAL; } - if (!req_test && memcmp(&hdr->dst, &hwaddr, + if (!req_test && memcmp(&hdr->dst, ð_hwaddr, sizeof(struct net_eth_addr))) { char out[sizeof("xx:xx:xx:xx:xx:xx")]; @@ -118,14 +118,14 @@ static int tester_send(const struct device *dev, struct net_pkt *pkt) printk("Invalid dst hwaddr %s, should be %s\n", out, net_sprint_ll_addr( - (uint8_t *)&hwaddr, + (uint8_t *)ð_hwaddr, sizeof(struct net_eth_addr))); send_status = -EINVAL; return send_status; } } else if (ntohs(arp_hdr->opcode) == NET_ARP_REQUEST) { - if (memcmp(&hdr->src, &hwaddr, + if (memcmp(&hdr->src, ð_hwaddr, sizeof(struct net_eth_addr))) { char out[sizeof("xx:xx:xx:xx:xx:xx")]; @@ -136,7 +136,7 @@ static int tester_send(const struct device *dev, struct net_pkt *pkt) printk("Invalid src hwaddr %s, should be %s\n", out, net_sprint_ll_addr( - (uint8_t *)&hwaddr, + (uint8_t *)ð_hwaddr, sizeof(struct net_eth_addr))); send_status = -EINVAL; return send_status; @@ -529,7 +529,7 @@ ZTEST(arp_fn_tests, test_arp) net_ipv4_addr_copy_raw(arp_hdr->dst_ipaddr, (uint8_t *)&dst); net_ipv4_addr_copy_raw(arp_hdr->src_ipaddr, (uint8_t *)&src); - pkt2 = prepare_arp_reply(iface, pkt, &hwaddr, ð_hdr); + pkt2 = prepare_arp_reply(iface, pkt, ð_hwaddr, ð_hdr); zassert_not_null(pkt2, "ARP reply generation failed."); @@ -561,7 +561,7 @@ ZTEST(arp_fn_tests, test_arp) send_status = -EINVAL; - setup_eth_header(iface, pkt, &hwaddr, NET_ETH_PTYPE_ARP); + setup_eth_header(iface, pkt, ð_hwaddr, NET_ETH_PTYPE_ARP); arp_hdr = (struct net_arp_hdr *)(pkt->buffer->data + (sizeof(struct net_eth_hdr))); @@ -570,7 +570,7 @@ ZTEST(arp_fn_tests, test_arp) net_ipv4_addr_copy_raw(arp_hdr->dst_ipaddr, (uint8_t *)&src); net_ipv4_addr_copy_raw(arp_hdr->src_ipaddr, (uint8_t *)&dst); - pkt2 = prepare_arp_request(iface, pkt, &hwaddr, ð_hdr); + pkt2 = prepare_arp_request(iface, pkt, ð_hwaddr, ð_hdr); /**TESTPOINT: Check if ARP request generation failed*/ zassert_not_null(pkt2, "ARP request generation failed."); @@ -602,7 +602,7 @@ ZTEST(arp_fn_tests, test_arp) /* First make sure that we have an entry in cache */ entry_found = false; - expected_hwaddr = &hwaddr; + expected_hwaddr = ð_hwaddr; net_arp_foreach(arp_cb, &dst); zassert_true(entry_found, "Entry not found"); diff --git a/tests/net/buf/src/main.c b/tests/net/buf/src/main.c index 2456587094..88ec644d4e 100644 --- a/tests/net/buf/src/main.c +++ b/tests/net/buf/src/main.c @@ -270,10 +270,10 @@ ZTEST(net_buf_tests, test_net_buf_4) removed = 0; while (buf->frags) { - struct net_buf *frag = buf->frags; + struct net_buf *frag2 = buf->frags; - net_buf_frag_del(buf, frag); - net_buf_unref(frag); + net_buf_frag_del(buf, frag2); + net_buf_unref(frag2); removed++; } diff --git a/tests/net/icmpv4/src/main.c b/tests/net/icmpv4/src/main.c index fbca726fdb..b063b75246 100644 --- a/tests/net/icmpv4/src/main.c +++ b/tests/net/icmpv4/src/main.c @@ -112,7 +112,7 @@ static const unsigned char icmpv4_echo_req_opt_bad[] = { static uint8_t current = TEST_ICMPV4_UNKNOWN; static struct in_addr my_addr = { { { 192, 0, 2, 1 } } }; -static struct net_if *iface; +static struct net_if *net_iface; static enum net_verdict handle_reply_msg(struct net_pkt *pkt, struct net_ipv4_hdr *ip_hdr, @@ -418,12 +418,12 @@ static void *icmpv4_setup(void) { struct net_if_addr *ifaddr; - iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); - if (!iface) { + net_iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); + if (!net_iface) { zassert_true(false, "Interface not available"); } - ifaddr = net_if_ipv4_addr_add(iface, &my_addr, NET_ADDR_MANUAL, 0); + ifaddr = net_if_ipv4_addr_add(net_iface, &my_addr, NET_ADDR_MANUAL, 0); if (!ifaddr) { zassert_true(false, "Failed to add address"); } @@ -434,9 +434,9 @@ static void icmpv4_teardown(void *dummy) { ARG_UNUSED(dummy); - iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); + net_iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); - net_if_ipv4_addr_rm(iface, &my_addr); + net_if_ipv4_addr_rm(net_iface, &my_addr); } static void icmpv4_send_echo_req(void) @@ -445,7 +445,7 @@ static void icmpv4_send_echo_req(void) current = TEST_ICMPV4_ECHO_REQ; - pkt = prepare_echo_request(iface); + pkt = prepare_echo_request(net_iface); if (!pkt) { zassert_true(false, "EchoRequest packet prep failed"); } @@ -462,7 +462,7 @@ static void icmpv4_send_echo_rep(void) net_icmpv4_register_handler(&echo_rep_handler); - pkt = prepare_echo_reply(iface); + pkt = prepare_echo_reply(net_iface); if (!pkt) { zassert_true(false, "EchoReply packet prep failed"); } @@ -480,7 +480,7 @@ ZTEST(net_icmpv4, test_icmpv4_send_echo_req_opt) current = TEST_ICMPV4_ECHO_REQ_OPTS; - pkt = prepare_echo_request_with_options(iface); + pkt = prepare_echo_request_with_options(net_iface); if (!pkt) { zassert_true(false, "EchoRequest with opts packet prep failed"); } @@ -495,7 +495,7 @@ ZTEST(net_icmpv4, test_send_echo_req_bad_opt) { struct net_pkt *pkt; - pkt = prepare_echo_request_with_bad_options(iface); + pkt = prepare_echo_request_with_bad_options(net_iface); if (!pkt) { zassert_true(false, "EchoRequest with bad opts packet prep failed"); diff --git a/tests/net/ieee802154/l2/src/ieee802154_shell_test.c b/tests/net/ieee802154/l2/src/ieee802154_shell_test.c index 910848c7a7..e4d0fa4cef 100644 --- a/tests/net/ieee802154/l2/src/ieee802154_shell_test.c +++ b/tests/net/ieee802154/l2/src/ieee802154_shell_test.c @@ -25,7 +25,7 @@ extern struct net_pkt *current_pkt; extern struct k_sem driver_lock; extern uint8_t mock_ext_addr_be[8]; -static struct net_if *iface; +static struct net_if *net_iface; static struct net_mgmt_event_callback scan_cb; K_SEM_DEFINE(scan_lock, 0, 1); @@ -205,7 +205,7 @@ ZTEST(ieee802154_l2_shell, test_active_scan) }; struct net_pkt *pkt; - pkt = net_pkt_rx_alloc_with_buffer(iface, sizeof(beacon_pkt), AF_UNSPEC, 0, K_FOREVER); + pkt = net_pkt_rx_alloc_with_buffer(net_iface, sizeof(beacon_pkt), AF_UNSPEC, 0, K_FOREVER); if (!pkt) { NET_ERR("*** No buffer to allocate\n"); goto fail; @@ -215,7 +215,7 @@ ZTEST(ieee802154_l2_shell, test_active_scan) net_buf_add_mem(pkt->buffer, beacon_pkt, sizeof(beacon_pkt)); /* The packet will be placed in the RX queue but not yet handled. */ - if (net_recv_data(iface, pkt) < 0) { + if (net_recv_data(net_iface, pkt) < 0) { NET_ERR("Recv data failed"); net_pkt_unref(pkt); goto fail; @@ -236,7 +236,7 @@ fail: ZTEST(ieee802154_l2_shell, test_associate) { uint8_t coord_addr_le[] = {EXPECTED_COORDINATOR_ADDR_LE}; - struct ieee802154_context *ctx = net_if_l2_data(iface); + struct ieee802154_context *ctx = net_if_l2_data(net_iface); struct ieee802154_frame_params params = { .dst = { .len = IEEE802154_EXT_ADDR_LENGTH, @@ -250,7 +250,8 @@ ZTEST(ieee802154_l2_shell, test_associate) /* Simulate a packet from the coordinator. */ memcpy(ctx->ext_addr, coord_addr_le, sizeof(ctx->ext_addr)); - pkt = ieee802154_create_mac_cmd_frame(iface, IEEE802154_CFI_ASSOCIATION_RESPONSE, ¶ms); + pkt = ieee802154_create_mac_cmd_frame(net_iface, IEEE802154_CFI_ASSOCIATION_RESPONSE, + ¶ms); if (!pkt) { NET_ERR("*** Could not create association response\n"); goto fail; @@ -262,7 +263,7 @@ ZTEST(ieee802154_l2_shell, test_associate) ieee802154_mac_cmd_finalize(pkt, IEEE802154_CFI_ASSOCIATION_RESPONSE); /* The packet will be placed in the RX queue but not yet handled. */ - if (net_recv_data(iface, pkt) < 0) { + if (net_recv_data(net_iface, pkt) < 0) { NET_ERR("Recv assoc resp pkt failed"); net_pkt_unref(pkt); goto fail; @@ -283,7 +284,7 @@ ZTEST(ieee802154_l2_shell, test_initiate_disassociation_from_enddevice) { uint8_t expected_coord_addr_le[] = {EXPECTED_COORDINATOR_ADDR_LE}; uint8_t empty_coord_addr[IEEE802154_EXT_ADDR_LENGTH] = {0}; - struct ieee802154_context *ctx = net_if_l2_data(iface); + struct ieee802154_context *ctx = net_if_l2_data(net_iface); uint8_t mock_ext_addr_le[IEEE802154_EXT_ADDR_LENGTH]; struct ieee802154_mpdu mpdu = {0}; int ret; @@ -328,7 +329,7 @@ ZTEST(ieee802154_l2_shell, test_initiate_disassociation_from_coordinator) { uint8_t expected_coord_addr_le[] = {EXPECTED_COORDINATOR_ADDR_LE}; uint8_t empty_coord_addr[IEEE802154_EXT_ADDR_LENGTH] = {0}; - struct ieee802154_context *ctx = net_if_l2_data(iface); + struct ieee802154_context *ctx = net_if_l2_data(net_iface); uint8_t mock_ext_addr_le[IEEE802154_EXT_ADDR_LENGTH]; struct ieee802154_frame_params params = { .dst = { @@ -349,7 +350,7 @@ ZTEST(ieee802154_l2_shell, test_initiate_disassociation_from_coordinator) memcpy(ctx->ext_addr, expected_coord_addr_le, sizeof(ctx->ext_addr)); /* Create and send an incoming disassociation notification. */ - pkt = ieee802154_create_mac_cmd_frame(iface, IEEE802154_CFI_DISASSOCIATION_NOTIFICATION, + pkt = ieee802154_create_mac_cmd_frame(net_iface, IEEE802154_CFI_DISASSOCIATION_NOTIFICATION, ¶ms); if (!pkt) { NET_ERR("*** Could not create association response\n"); @@ -367,7 +368,7 @@ ZTEST(ieee802154_l2_shell, test_initiate_disassociation_from_coordinator) ctx->coord_short_addr = EXPECTED_COORDINATOR_SHORT_ADDR; memcpy(ctx->coord_ext_addr, expected_coord_addr_le, sizeof(ctx->coord_ext_addr)); - if (net_recv_data(iface, pkt) < 0) { + if (net_recv_data(net_iface, pkt) < 0) { NET_ERR("Recv assoc resp pkt failed"); net_pkt_unref(pkt); goto fail; @@ -405,7 +406,7 @@ fail: ZTEST(ieee802154_l2_shell, test_set_ext_addr) { uint8_t expected_ext_addr_le[] = {EXPECTED_ENDDEVICE_EXT_ADDR_LE}; - struct ieee802154_context *ctx = net_if_l2_data(iface); + struct ieee802154_context *ctx = net_if_l2_data(net_iface); uint8_t initial_ext_addr_le[sizeof(mock_ext_addr_be)]; int ret; @@ -433,10 +434,10 @@ static void reset_fake_driver(void *test_fixture) ARG_UNUSED(test_fixture); - __ASSERT_NO_MSG(iface); + __ASSERT_NO_MSG(net_iface); /* Set initial conditions. */ - ctx = net_if_l2_data(iface); + ctx = net_if_l2_data(net_iface); ctx->pan_id = IEEE802154_PAN_ID_NOT_ASSOCIATED; ctx->short_addr = IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED; ctx->coord_short_addr = IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED; @@ -454,8 +455,8 @@ static void *test_setup(void) return NULL; } - iface = net_if_lookup_by_dev(dev); - if (!iface) { + net_iface = net_if_lookup_by_dev(dev); + if (!net_iface) { NET_ERR("*** Could not get fake iface\n"); return NULL; } diff --git a/tests/net/ieee802154/l2/src/ieee802154_test.c b/tests/net/ieee802154/l2/src/ieee802154_test.c index 71cd07959d..7347969d21 100644 --- a/tests/net/ieee802154/l2/src/ieee802154_test.c +++ b/tests/net/ieee802154/l2/src/ieee802154_test.c @@ -167,7 +167,7 @@ uint8_t raw_payload[] = { extern struct net_pkt *current_pkt; extern struct k_sem driver_lock; -static struct net_if *iface; +static struct net_if *net_iface; static void pkt_hexdump(uint8_t *pkt, uint8_t length) { @@ -212,7 +212,8 @@ static int disassociate(struct net_if *iface, struct ieee802154_context *ctx) return 0; } - ret = net_mgmt(NET_REQUEST_IEEE802154_SET_SHORT_ADDR, iface, &short_addr_not_associated, + ret = net_mgmt(NET_REQUEST_IEEE802154_SET_SHORT_ADDR, iface, + &short_addr_not_associated, sizeof(short_addr_not_associated)); if (ret) { NET_ERR("*** Failed to %s.\n", __func__); @@ -316,7 +317,7 @@ static struct net_pkt *get_data_pkt_with_ar(void) }; struct net_pkt *pkt; - pkt = net_pkt_rx_alloc_with_buffer(iface, sizeof(data_pkt_with_ar), AF_UNSPEC, 0, + 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"); @@ -331,7 +332,7 @@ static struct net_pkt *get_data_pkt_with_ar(void) #ifdef CONFIG_NET_SOCKETS static bool set_up_security(uint8_t security_level) { - struct ieee802154_context *ctx = net_if_l2_data(iface); + struct ieee802154_context *ctx = net_if_l2_data(net_iface); uint16_t saved_short_addr = ctx->short_addr; struct ieee802154_security_params params; @@ -339,7 +340,7 @@ static bool set_up_security(uint8_t security_level) return true; } - if (disassociate(iface, ctx) != 0) { + if (disassociate(net_iface, ctx) != 0) { return false; } @@ -351,14 +352,14 @@ static bool set_up_security(uint8_t security_level) .level = security_level, }; - if (net_mgmt(NET_REQUEST_IEEE802154_SET_SECURITY_SETTINGS, iface, ¶ms, + 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"); return false; } if (saved_short_addr != IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED && - associate(iface, ctx, saved_short_addr) != 0) { + associate(net_iface, ctx, saved_short_addr) != 0) { return false; } @@ -367,24 +368,24 @@ static bool set_up_security(uint8_t security_level) static bool tear_down_security(void) { - struct ieee802154_context *ctx = net_if_l2_data(iface); + struct ieee802154_context *ctx = net_if_l2_data(net_iface); uint16_t saved_short_addr = ctx->short_addr; struct ieee802154_security_params params = { .level = IEEE802154_SECURITY_LEVEL_NONE, }; - if (disassociate(iface, ctx) != 0) { + if (disassociate(net_iface, ctx) != 0) { return false; } - if (net_mgmt(NET_REQUEST_IEEE802154_SET_SECURITY_SETTINGS, iface, ¶ms, + 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"); return false; } if (saved_short_addr != IEEE802154_SHORT_ADDRESS_NOT_ASSOCIATED && - associate(iface, ctx, saved_short_addr) != 0) { + associate(net_iface, ctx, saved_short_addr) != 0) { return false; } @@ -394,7 +395,7 @@ static bool tear_down_security(void) static int set_up_recv_socket(enum net_sock_type socket_type) { struct sockaddr_ll socket_sll = { - .sll_ifindex = net_if_get_by_iface(iface), + .sll_ifindex = net_if_get_by_iface(net_iface), .sll_family = AF_PACKET, .sll_protocol = ETH_P_IEEE802154, }; @@ -466,7 +467,7 @@ static bool test_packet_parsing(struct ieee802154_pkt_test *t) static bool test_ns_sending(struct ieee802154_pkt_test *t, bool with_short_addr) { - struct ieee802154_context *ctx = net_if_l2_data(iface); + struct ieee802154_context *ctx = net_if_l2_data(net_iface); struct ieee802154_mpdu mpdu; bool result = false; @@ -475,17 +476,17 @@ static bool test_ns_sending(struct ieee802154_pkt_test *t, bool with_short_addr) /* ensure reproducible results */ ctx->sequence = t->sequence; - if (with_short_addr && set_up_short_addr(iface, ctx)) { + if (with_short_addr && set_up_short_addr(net_iface, ctx)) { goto out; } - if (net_ipv6_send_ns(iface, NULL, &t->src, &t->dst, &t->dst, false)) { + if (net_ipv6_send_ns(net_iface, NULL, &t->src, &t->dst, &t->dst, false)) { NET_ERR("*** Could not create IPv6 NS packet\n"); - tear_down_short_addr(iface, ctx); + tear_down_short_addr(net_iface, ctx); goto out; } - tear_down_short_addr(iface, ctx); + tear_down_short_addr(net_iface, ctx); k_yield(); k_sem_take(&driver_lock, K_SECONDS(1)); @@ -523,7 +524,7 @@ out: static bool test_wait_for_ack(struct ieee802154_pkt_test *t) { struct ieee802154_mpdu mpdu; - struct net_pkt *ack_pkt; + struct net_pkt *one_ack_pkt; struct net_pkt *tx_pkt; bool result = false; bool ack_required; @@ -535,7 +536,7 @@ static bool test_wait_for_ack(struct ieee802154_pkt_test *t) goto out; } - ack_required = ieee802154_prepare_for_ack(iface, tx_pkt, tx_pkt->frags); + 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"); goto release_tx_pkt; @@ -546,26 +547,26 @@ static bool test_wait_for_ack(struct ieee802154_pkt_test *t) goto release_tx_pkt; } - ack_pkt = net_pkt_rx_alloc_with_buffer(iface, IEEE802154_ACK_PKT_LENGTH, AF_UNSPEC, 0, - K_FOREVER); - if (!ack_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"); goto release_tx_pkt; } - if (!ieee802154_create_ack_frame(iface, ack_pkt, mpdu.mhr.fs->sequence)) { + if (!ieee802154_create_ack_frame(net_iface, one_ack_pkt, mpdu.mhr.fs->sequence)) { NET_ERR("*** Could not create ack frame.\n"); goto release_tx_pkt; } - pkt_hexdump(net_pkt_data(ack_pkt), net_pkt_get_len(ack_pkt)); + pkt_hexdump(net_pkt_data(one_ack_pkt), net_pkt_get_len(one_ack_pkt)); - if (ieee802154_handle_ack(iface, ack_pkt) != NET_OK) { + if (ieee802154_handle_ack(net_iface, one_ack_pkt) != NET_OK) { NET_ERR("*** Ack frame was not handled.\n"); goto release_ack_pkt; } - if (ieee802154_wait_for_ack(iface, ack_required) != 0) { + if (ieee802154_wait_for_ack(net_iface, ack_required) != 0) { NET_ERR("*** Ack frame was not recorded.\n"); goto release_ack_pkt; } @@ -573,7 +574,7 @@ static bool test_wait_for_ack(struct ieee802154_pkt_test *t) result = true; release_ack_pkt: - net_pkt_unref(ack_pkt); + net_pkt_unref(one_ack_pkt); release_tx_pkt: net_pkt_unref(tx_pkt); out: @@ -587,7 +588,7 @@ static bool test_packet_cloning_with_cb(void) NET_INFO("- Cloning packet\n"); - pkt = net_pkt_rx_alloc_with_buffer(iface, 64, AF_UNSPEC, 0, K_NO_WAIT); + 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"); return false; @@ -622,7 +623,7 @@ static bool test_packet_rssi_conversion(void) NET_INFO("- RSSI conversion between unsigned and signed representation\n"); - pkt = net_pkt_rx_alloc_on_iface(iface, K_NO_WAIT); + pkt = net_pkt_rx_alloc_on_iface(net_iface, K_NO_WAIT); if (!pkt) { NET_ERR("*** No pkt to allocate\n"); return false; @@ -680,8 +681,8 @@ static bool test_packet_rssi_conversion(void) static bool test_dgram_packet_sending(void *dst_sll, uint8_t dst_sll_halen, uint32_t security_level) { /* tests should be run sequentially, so no need for context locking */ - struct ieee802154_context *ctx = net_if_l2_data(iface); - struct sockaddr_ll socket_sll = {.sll_ifindex = net_if_get_by_iface(iface), + struct ieee802154_context *ctx = net_if_l2_data(net_iface); + struct sockaddr_ll socket_sll = {.sll_ifindex = net_if_get_by_iface(net_iface), .sll_family = AF_PACKET, .sll_protocol = ETH_P_IEEE802154}; struct sockaddr_ll pkt_dst_sll = { @@ -712,7 +713,7 @@ static bool test_dgram_packet_sending(void *dst_sll, uint8_t dst_sll_halen, uint bool bind_short_address = pkt_dst_sll.sll_halen == IEEE802154_SHORT_ADDR_LENGTH && security_level == IEEE802154_SECURITY_LEVEL_NONE; - if (bind_short_address && set_up_short_addr(iface, ctx)) { + if (bind_short_address && set_up_short_addr(net_iface, ctx)) { goto release_fd; } @@ -743,10 +744,10 @@ static bool test_dgram_packet_sending(void *dst_sll, uint8_t dst_sll_halen, uint goto release_frag; } - net_pkt_lladdr_src(current_pkt)->addr = net_if_get_link_addr(iface)->addr; - net_pkt_lladdr_src(current_pkt)->len = net_if_get_link_addr(iface)->len; + net_pkt_lladdr_src(current_pkt)->addr = net_if_get_link_addr(net_iface)->addr; + net_pkt_lladdr_src(current_pkt)->len = net_if_get_link_addr(net_iface)->len; - if (!ieee802154_decipher_data_frame(iface, current_pkt, &mpdu)) { + if (!ieee802154_decipher_data_frame(net_iface, current_pkt, &mpdu)) { NET_ERR("*** Cannot decipher/authenticate packet\n"); goto release_frag; } @@ -762,7 +763,7 @@ release_frag: net_pkt_frag_unref(current_pkt->frags); current_pkt->frags = NULL; release_fd: - tear_down_short_addr(iface, ctx); + tear_down_short_addr(net_iface, ctx); close(fd); reset_security: tear_down_security(); @@ -774,7 +775,7 @@ out: static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_len, uint32_t security_level, bool is_broadcast) { - struct ieee802154_context *ctx = net_if_l2_data(iface); + struct ieee802154_context *ctx = net_if_l2_data(net_iface); uint8_t our_ext_addr[IEEE802154_EXT_ADDR_LENGTH]; /* big endian */ uint8_t payload[] = {0x01, 0x02, 0x03, 0x04}; uint16_t our_short_addr = ctx->short_addr; /* CPU byte order */ @@ -830,7 +831,8 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l } ieee802154_compute_header_and_authtag_len( - iface, net_pkt_lladdr_dst(pkt), net_pkt_lladdr_src(pkt), &ll_hdr_len, &authtag_len); + net_iface, net_pkt_lladdr_dst(pkt), net_pkt_lladdr_src(pkt), + &ll_hdr_len, &authtag_len); net_buf_add(frame_buf, ll_hdr_len); net_buf_add_mem(frame_buf, payload, sizeof(payload)); @@ -864,7 +866,7 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l net_pkt_frag_add(pkt, frame_buf); - if (net_recv_data(iface, pkt)) { + if (net_recv_data(net_iface, pkt)) { NET_ERR("*** Error while processing packet.\n"); goto release_pkt; } @@ -893,7 +895,7 @@ static bool test_dgram_packet_reception(void *src_ll_addr, uint8_t src_ll_addr_l if (recv_src_sll_len != sizeof(struct sockaddr_ll) || recv_src_sll.sll_family != AF_PACKET || recv_src_sll.sll_protocol != ETH_P_IEEE802154 || - recv_src_sll.sll_ifindex != net_if_get_by_iface(iface) || + 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"); @@ -930,7 +932,7 @@ static bool test_raw_packet_sending(void) goto out; } - socket_sll.sll_ifindex = net_if_get_by_iface(iface); + socket_sll.sll_ifindex = net_if_get_by_iface(net_iface); socket_sll.sll_family = AF_PACKET; socket_sll.sll_protocol = ETH_P_IEEE802154; @@ -1015,7 +1017,7 @@ static bool test_raw_packet_reception(void) net_buf_add_mem(frame_buf, raw_payload, sizeof(raw_payload)); net_pkt_frag_add(pkt, frame_buf); - if (net_recv_data(iface, pkt)) { + if (net_recv_data(net_iface, pkt)) { NET_ERR("*** Error while processing packet.\n"); goto release_pkt; } @@ -1086,10 +1088,10 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t) 0xe5, 0xac, 0xa1, 0x1c, 0x00, 0x4b, 0x12, 0x00, /* LL address */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Padding */ }; - struct ieee802154_context *ctx = net_if_l2_data(iface); + struct ieee802154_context *ctx = net_if_l2_data(net_iface); struct sockaddr_ll recv_src_sll = {0}; struct sockaddr_ll socket_sll = { - .sll_ifindex = net_if_get_by_iface(iface), + .sll_ifindex = net_if_get_by_iface(net_iface), .sll_family = AF_PACKET, .sll_protocol = ETH_P_IEEE802154, }; @@ -1124,7 +1126,7 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t) goto release_fd; } - if (set_up_short_addr(iface, ctx)) { + if (set_up_short_addr(net_iface, ctx)) { goto release_fd; } @@ -1133,7 +1135,7 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t) goto reset_short_addr; } - if (net_recv_data(iface, rx_pkt) < 0) { + if (net_recv_data(net_iface, rx_pkt) < 0) { NET_ERR("Recv data failed"); goto release_rx_pkt; } @@ -1148,7 +1150,7 @@ static bool test_recv_and_send_ack_reply(struct ieee802154_pkt_test *t) sys_memcpy_swap(mac_be, ctx->ext_addr, IEEE802154_EXT_ADDR_LENGTH); if (recv_src_sll_len != sizeof(struct sockaddr_ll) || - recv_src_sll.sll_ifindex != net_if_get_by_iface(iface) || + recv_src_sll.sll_ifindex != net_if_get_by_iface(net_iface) || 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)) { @@ -1200,7 +1202,7 @@ release_tx_frag: release_rx_pkt: net_pkt_unref(rx_pkt); reset_short_addr: - tear_down_short_addr(iface, ctx); + tear_down_short_addr(net_iface, ctx); release_fd: close(fd); out: @@ -1227,20 +1229,21 @@ static bool initialize_test_environment(void) goto release_pkt; } - iface = net_if_lookup_by_dev(dev); - if (!iface) { + net_iface = net_if_lookup_by_dev(dev); + if (!net_iface) { NET_ERR("*** Could not get fake iface\n"); goto release_pkt; } - if (net_mgmt(NET_REQUEST_IEEE802154_SET_PAN_ID, iface, &mock_pan_id, sizeof(mock_pan_id))) { + 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__); goto release_pkt; } NET_INFO("Fake IEEE 802.15.4 network interface ready\n"); - ieee_addr_hexdump(net_if_get_link_addr(iface)->addr, 8); + ieee_addr_hexdump(net_if_get_link_addr(net_iface)->addr, 8); return true; diff --git a/tests/net/igmp/src/main.c b/tests/net/igmp/src/main.c index f4f9c755e6..99e591e1d8 100644 --- a/tests/net/igmp/src/main.c +++ b/tests/net/igmp/src/main.c @@ -46,7 +46,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_IPV4_LOG_LEVEL); static struct in_addr my_addr = { { { 192, 0, 2, 1 } } }; static struct in_addr mcast_addr = { { { 224, 0, 2, 63 } } }; -static struct net_if *iface; +static struct net_if *net_iface; static bool is_group_joined; static bool is_group_left; static bool is_join_msg_ok; @@ -206,11 +206,11 @@ static void *igmp_setup(void) setup_mgmt_events(); - iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); + net_iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); - zassert_not_null(iface, "Interface is NULL"); + zassert_not_null(net_iface, "Interface is NULL"); - ifaddr = net_if_ipv4_addr_add(iface, &my_addr, NET_ADDR_MANUAL, 0); + ifaddr = net_if_ipv4_addr_add(net_iface, &my_addr, NET_ADDR_MANUAL, 0); zassert_not_null(ifaddr, "Cannot add IPv4 address"); @@ -227,16 +227,16 @@ static void igmp_teardown(void *dummy) net_mgmt_del_event_callback(&mgmt_events[i].cb); } - iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); + net_iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); - net_if_ipv4_addr_rm(iface, &my_addr); + net_if_ipv4_addr_rm(net_iface, &my_addr); } static void join_group(void) { int ret; - ret = net_ipv4_igmp_join(iface, &mcast_addr); + ret = net_ipv4_igmp_join(net_iface, &mcast_addr); if (ignore_already) { zassert_true(ret == 0 || ret == -EALREADY, @@ -253,7 +253,7 @@ static void leave_group(void) { int ret; - ret = net_ipv4_igmp_leave(iface, &mcast_addr); + ret = net_ipv4_igmp_leave(net_iface, &mcast_addr); zassert_equal(ret, 0, "Cannot leave IPv4 multicast group"); diff --git a/tests/net/ipv4_fragment/src/main.c b/tests/net/ipv4_fragment/src/main.c index 8988416878..5ebe381733 100644 --- a/tests/net/ipv4_fragment/src/main.c +++ b/tests/net/ipv4_fragment/src/main.c @@ -147,7 +147,7 @@ static uint8_t upper_layer_packet_count; static uint16_t lower_layer_total_size; static uint16_t upper_layer_total_size; -static uint8_t tmp_buf[256]; +static uint8_t test_tmp_buf[256]; static uint8_t net_iface_dummy_data; static void net_iface_init(struct net_if *iface); @@ -590,7 +590,7 @@ static void *test_setup(void) setup_tcp_handler(&my_addr1, &my_addr2, 4092, 19551); /* Generate test data */ - generate_dummy_data(tmp_buf, sizeof(tmp_buf)); + generate_dummy_data(test_tmp_buf, sizeof(test_tmp_buf)); return NULL; } @@ -618,9 +618,9 @@ ZTEST(net_ipv4_fragment, test_udp) /* Add enough data until we have 4 packets */ i = 0; while (i < IPV4_TEST_PACKET_SIZE) { - ret = net_pkt_write(pkt, tmp_buf, sizeof(tmp_buf)); + ret = net_pkt_write(pkt, test_tmp_buf, sizeof(test_tmp_buf)); zassert_equal(ret, 0, "IPv4 data append failed"); - i += sizeof(tmp_buf); + i += sizeof(test_tmp_buf); } /* Setup packet for insertion */ diff --git a/tests/net/ipv6/src/main.c b/tests/net/ipv6/src/main.c index 82133a5b67..f9dd456cdc 100644 --- a/tests/net/ipv6/src/main.c +++ b/tests/net/ipv6/src/main.c @@ -42,7 +42,7 @@ static struct in6_addr my_addr = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }; static struct in6_addr peer_addr = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } }; -static struct in6_addr mcast_addr = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, +static struct in6_addr multicast_addr = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }; /* ICMPv6 NS frame (74 bytes) */ @@ -501,11 +501,11 @@ static void *ipv6_setup(void) ifaddr2 = net_if_ipv6_addr_lookup(&my_addr, &iface2); zassert_true(ifaddr2 == ifaddr, "Invalid ifaddr (%p vs %p)\n", ifaddr, ifaddr2); - net_ipv6_addr_create(&mcast_addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001); + net_ipv6_addr_create(&multicast_addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001); - maddr = net_if_ipv6_maddr_add(iface, &mcast_addr); + maddr = net_if_ipv6_maddr_add(iface, &multicast_addr); zassert_not_null(maddr, "Cannot add multicast IPv6 address %s\n", - net_sprint_ipv6_addr(&mcast_addr)); + net_sprint_ipv6_addr(&multicast_addr)); /* The semaphore is there to wait the data to be received. */ k_sem_init(&wait_data, 0, UINT_MAX); @@ -528,8 +528,8 @@ static void ipv6_teardown(void *dummy) rm_max_neighbors(); rm_neighbor(); - net_ipv6_addr_create(&mcast_addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001); - net_if_ipv6_maddr_rm(iface, &mcast_addr); + net_ipv6_addr_create(&multicast_addr, 0xff02, 0, 0, 0, 0, 0, 0, 0x0001); + net_if_ipv6_maddr_rm(iface, &multicast_addr); ifaddr_record->is_used = false; } diff --git a/tests/net/lib/dns_packet/src/main.c b/tests/net/lib/dns_packet/src/main.c index 95ded79342..e48477d0b0 100644 --- a/tests/net/lib/dns_packet/src/main.c +++ b/tests/net/lib/dns_packet/src/main.c @@ -14,8 +14,8 @@ /* RFC 1035, 4.1.1. Header section format */ #define DNS_HEADER_SIZE 12 -static uint8_t buf[MAX_BUF_SIZE]; -static uint16_t buf_len; +static uint8_t dns_buf[MAX_BUF_SIZE]; +static uint16_t dns_buf_len; static uint8_t qname[MAX_BUF_SIZE]; static uint16_t qname_len; @@ -61,90 +61,90 @@ static int eval_query(const char *dname, uint16_t tid, enum dns_rr_type type, goto lb_exit; } - rc = dns_msg_pack_query(buf, &buf_len, MAX_BUF_SIZE, qname, qname_len, + rc = dns_msg_pack_query(dns_buf, &dns_buf_len, MAX_BUF_SIZE, qname, qname_len, tid, type); if (rc != 0) { goto lb_exit; } - if (dns_unpack_header_id(buf) != tid) { + if (dns_unpack_header_id(dns_buf) != tid) { rc = -EINVAL; goto lb_exit; } /* This is a query */ - if (dns_header_qr(buf) != DNS_QUERY) { + if (dns_header_qr(dns_buf) != DNS_QUERY) { rc = -EINVAL; goto lb_exit; } /* This is a query (standard query) */ - if (dns_header_opcode(buf) != DNS_QUERY) { + if (dns_header_opcode(dns_buf) != DNS_QUERY) { rc = -EINVAL; goto lb_exit; } /* Authoritative Answer must be 0 for a Query */ - if (dns_header_aa(buf) != 0) { + if (dns_header_aa(dns_buf) != 0) { rc = -EINVAL; goto lb_exit; } /* TrunCation is always 0 */ - if (dns_header_tc(buf) != 0) { + if (dns_header_tc(dns_buf) != 0) { rc = -EINVAL; goto lb_exit; } /* Recursion Desired is always 1 */ - if (dns_header_rd(buf) != 1) { + if (dns_header_rd(dns_buf) != 1) { rc = -EINVAL; goto lb_exit; } /* Recursion Available is always 0 */ - if (dns_header_ra(buf) != 0) { + if (dns_header_ra(dns_buf) != 0) { rc = -EINVAL; goto lb_exit; } /* Z is always 0 */ - if (dns_header_z(buf) != 0) { + if (dns_header_z(dns_buf) != 0) { rc = -EINVAL; goto lb_exit; } /* Response code must be 0 (no error) */ - if (dns_header_rcode(buf) != DNS_HEADER_NOERROR) { + if (dns_header_rcode(dns_buf) != DNS_HEADER_NOERROR) { rc = -EINVAL; goto lb_exit; } /* Question counter must be 1 */ - if (dns_header_qdcount(buf) != 1) { + if (dns_header_qdcount(dns_buf) != 1) { rc = -EINVAL; goto lb_exit; } /* Answer counter must be 0 */ - if (dns_header_ancount(buf) != 0) { + if (dns_header_ancount(dns_buf) != 0) { rc = -EINVAL; goto lb_exit; } /* Name server resource records counter must be 0 */ - if (dns_header_nscount(buf) != 0) { + if (dns_header_nscount(dns_buf) != 0) { rc = -EINVAL; goto lb_exit; } /* Additional records counter must be 0 */ - if (dns_header_arcount(buf) != 0) { + if (dns_header_arcount(dns_buf) != 0) { rc = -EINVAL; goto lb_exit; } - question = buf + DNS_HEADER_SIZE; + question = dns_buf + DNS_HEADER_SIZE; /* QClass */ if (dns_unpack_query_qclass(question + qname_len) != DNS_CLASS_IN) { @@ -159,12 +159,12 @@ static int eval_query(const char *dname, uint16_t tid, enum dns_rr_type type, } /* compare with the expected result */ - if (buf_len != expected_len) { + if (dns_buf_len != expected_len) { rc = -EINVAL; goto lb_exit; } - if (memcmp(expected, buf, buf_len) != 0) { + if (memcmp(expected, dns_buf, dns_buf_len) != 0) { rc = -EINVAL; goto lb_exit; } diff --git a/tests/net/lib/lwm2m/content_plain_text/src/main.c b/tests/net/lib/lwm2m/content_plain_text/src/main.c index 419a37cdc0..c7cc857224 100644 --- a/tests/net/lib/lwm2m/content_plain_text/src/main.c +++ b/tests/net/lib/lwm2m/content_plain_text/src/main.c @@ -473,19 +473,19 @@ ZTEST(net_content_plain_text_nodata, test_get_bool_nodata) ZTEST(net_content_plain_text, test_get_opaque) { int ret; - const char *test_payload = "test_payload"; + const char *payload = "test_payload"; uint8_t buf[16]; bool last_block; struct lwm2m_opaque_context ctx = { 0 }; - test_payload_set(test_payload); + test_payload_set(payload); ret = plain_text_reader.get_opaque(&test_in, buf, sizeof(buf), &ctx, &last_block); - zassert_equal(ret, strlen(test_payload), "Invalid length returned"); - zassert_mem_equal(buf, test_payload, strlen(test_payload), + zassert_equal(ret, strlen(payload), "Invalid length returned"); + zassert_mem_equal(buf, payload, strlen(payload), "Invalid value parsed"); - zassert_equal(test_in.offset, strlen(test_payload) + 1, + zassert_equal(test_in.offset, strlen(payload) + 1, "Invalid packet offset"); } diff --git a/tests/net/lib/mqtt_sn_client/src/mqtt_sn_client.c b/tests/net/lib/mqtt_sn_client/src/mqtt_sn_client.c index ad21d9a66c..2ae8fd88e9 100644 --- a/tests/net/lib/mqtt_sn_client/src/mqtt_sn_client.c +++ b/tests/net/lib/mqtt_sn_client/src/mqtt_sn_client.c @@ -84,15 +84,15 @@ int tp_poll(struct mqtt_sn_client *client) return recv_data.sz; } -static ZTEST_BMEM struct mqtt_sn_client clients[3]; -static ZTEST_BMEM struct mqtt_sn_client *client; +static ZTEST_BMEM struct mqtt_sn_client mqtt_clients[3]; +static ZTEST_BMEM struct mqtt_sn_client *mqtt_client; static void setup(void *f) { ARG_UNUSED(f); static ZTEST_BMEM size_t i; - client = &clients[i++]; + mqtt_client = &mqtt_clients[i++]; transport = (struct mqtt_sn_transport){ .init = tp_init, .msg_send = msg_send, .recv = tp_recv, .poll = tp_poll}; @@ -139,7 +139,7 @@ static void mqtt_sn_connect_no_will(struct mqtt_sn_client *client) static ZTEST(mqtt_sn_client, test_mqtt_sn_connect_no_will) { - mqtt_sn_connect_no_will(client); + mqtt_sn_connect_no_will(mqtt_client); } static ZTEST(mqtt_sn_client, test_mqtt_sn_connect_will) @@ -150,32 +150,32 @@ static ZTEST(mqtt_sn_client, test_mqtt_sn_connect_will) int err; - err = mqtt_sn_client_init(client, &client_id, &transport, evt_cb, tx, sizeof(tx), rx, + err = mqtt_sn_client_init(mqtt_client, &client_id, &transport, evt_cb, tx, sizeof(tx), rx, sizeof(rx)); zassert_equal(err, 0, "unexpected error %d"); - client->will_topic = MQTT_SN_DATA_STRING_LITERAL("topic"); - client->will_msg = MQTT_SN_DATA_STRING_LITERAL("msg"); + mqtt_client->will_topic = MQTT_SN_DATA_STRING_LITERAL("topic"); + mqtt_client->will_msg = MQTT_SN_DATA_STRING_LITERAL("msg"); - err = mqtt_sn_connect(client, true, false); + err = mqtt_sn_connect(mqtt_client, true, false); zassert_equal(err, 0, "unexpected error %d"); assert_msg_send(1, 12); - zassert_equal(client->state, 0, "Wrong state"); + zassert_equal(mqtt_client->state, 0, "Wrong state"); - err = input(client, willtopicreq, sizeof(willtopicreq)); + err = input(mqtt_client, willtopicreq, sizeof(willtopicreq)); zassert_equal(err, 0, "unexpected error %d"); - zassert_equal(client->state, 0, "Wrong state"); + zassert_equal(mqtt_client->state, 0, "Wrong state"); assert_msg_send(1, 8); - err = input(client, willmsgreq, sizeof(willmsgreq)); + err = input(mqtt_client, willmsgreq, sizeof(willmsgreq)); zassert_equal(err, 0, "unexpected error %d"); - zassert_equal(client->state, 0, "Wrong state"); + zassert_equal(mqtt_client->state, 0, "Wrong state"); zassert_equal(evt_cb_data.called, 0, "Unexpected event"); assert_msg_send(1, 5); - err = input(client, connack, sizeof(connack)); + err = input(mqtt_client, connack, sizeof(connack)); zassert_equal(err, 0, "unexpected error %d"); - zassert_equal(client->state, 1, "Wrong state"); + zassert_equal(mqtt_client->state, 1, "Wrong state"); zassert_equal(evt_cb_data.called, 1, "NO event"); zassert_equal(evt_cb_data.last_evt.type, MQTT_SN_EVT_CONNECTED, "Wrong event"); k_sleep(K_MSEC(10)); @@ -189,22 +189,22 @@ static ZTEST(mqtt_sn_client, test_mqtt_sn_publish_qos0) uint8_t regack[] = {7, 0x0B, 0x1A, 0x1B, 0x00, 0x01, 0}; int err; - mqtt_sn_connect_no_will(client); - err = mqtt_sn_publish(client, MQTT_SN_QOS_0, &topic, false, &data); + mqtt_sn_connect_no_will(mqtt_client); + err = mqtt_sn_publish(mqtt_client, MQTT_SN_QOS_0, &topic, false, &data); zassert_equal(err, 0, "Unexpected error %d", err); assert_msg_send(0, 0); k_sleep(K_MSEC(10)); /* Expect a REGISTER to be sent */ assert_msg_send(1, 12); - err = input(client, regack, sizeof(regack)); + err = input(mqtt_client, regack, sizeof(regack)); zassert_equal(err, 0, "unexpected error %d"); assert_msg_send(0, 0); k_sleep(K_MSEC(10)); assert_msg_send(1, 20); - zassert_true(sys_slist_is_empty(&client->publish), "Publish not empty"); - zassert_false(sys_slist_is_empty(&client->topic), "Topic empty"); + zassert_true(sys_slist_is_empty(&mqtt_client->publish), "Publish not empty"); + zassert_false(sys_slist_is_empty(&mqtt_client->topic), "Topic empty"); } ZTEST_SUITE(mqtt_sn_client, NULL, NULL, setup, NULL, NULL); diff --git a/tests/net/mld/src/main.c b/tests/net/mld/src/main.c index 1b3a64de16..513fc3107c 100644 --- a/tests/net/mld/src/main.c +++ b/tests/net/mld/src/main.c @@ -50,7 +50,7 @@ static struct in6_addr peer_addr = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, static struct in6_addr mcast_addr = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 } } }; -static struct net_if *iface; +static struct net_if *net_iface; static bool is_group_joined; static bool is_group_left; static bool is_join_msg_ok; @@ -206,11 +206,11 @@ static void *test_mld_setup(void) setup_mgmt_events(); - iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); + net_iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); - zassert_not_null(iface, "Interface is NULL"); + zassert_not_null(net_iface, "Interface is NULL"); - ifaddr = net_if_ipv6_addr_add(iface, &my_addr, + ifaddr = net_if_ipv6_addr_add(net_iface, &my_addr, NET_ADDR_MANUAL, 0); zassert_not_null(ifaddr, "Cannot add IPv6 address"); @@ -225,7 +225,7 @@ static void test_join_group(void) /* Using adhoc multicast group outside standard range */ net_ipv6_addr_create(&mcast_addr, 0xff10, 0, 0, 0, 0, 0, 0, 0x0001); - ret = net_ipv6_mld_join(iface, &mcast_addr); + ret = net_ipv6_mld_join(net_iface, &mcast_addr); if (ignore_already) { zassert_true(ret == 0 || ret == -EALREADY, @@ -244,7 +244,7 @@ static void test_leave_group(void) net_ipv6_addr_create(&mcast_addr, 0xff10, 0, 0, 0, 0, 0, 0, 0x0001); - ret = net_ipv6_mld_leave(iface, &mcast_addr); + ret = net_ipv6_mld_leave(net_iface, &mcast_addr); zassert_equal(ret, 0, "Cannot leave IPv6 multicast group"); @@ -557,12 +557,12 @@ ZTEST(net_mld_test_suite, test_no_mld_flag) is_join_msg_ok = false; is_leave_msg_ok = false; - net_if_flag_set(iface, NET_IF_IPV6_NO_MLD); + net_if_flag_set(net_iface, NET_IF_IPV6_NO_MLD); /* Using adhoc multicast group outside standard range */ net_ipv6_addr_create(&mcast_addr, 0xff10, 0, 0, 0, 0, 0, 0, 0x0001); - ret = net_ipv6_mld_join(iface, &mcast_addr); + ret = net_ipv6_mld_join(net_iface, &mcast_addr); zassert_equal(ret, 0, "Cannot add multicast address"); /* Let the network stack to proceed */ @@ -570,7 +570,7 @@ ZTEST(net_mld_test_suite, test_no_mld_flag) zassert_false(is_join_msg_ok, "Received join message when not expected"); - ret = net_ipv6_mld_leave(iface, &mcast_addr); + ret = net_ipv6_mld_leave(net_iface, &mcast_addr); zassert_equal(ret, 0, "Cannot remove multicast address"); /* Let the network stack to proceed */ @@ -578,7 +578,7 @@ ZTEST(net_mld_test_suite, test_no_mld_flag) zassert_false(is_leave_msg_ok, "Received leave message when not expected"); - net_if_flag_clear(iface, NET_IF_IPV6_NO_MLD); + net_if_flag_clear(net_iface, NET_IF_IPV6_NO_MLD); } ZTEST_SUITE(net_mld_test_suite, NULL, test_mld_setup, NULL, NULL, NULL); diff --git a/tests/net/ppp/driver/src/main.c b/tests/net/ppp/driver/src/main.c index 2e61b64370..1c7cad29c3 100644 --- a/tests/net/ppp/driver/src/main.c +++ b/tests/net/ppp/driver/src/main.c @@ -35,7 +35,7 @@ typedef enum net_verdict (*ppp_l2_callback_t)(struct net_if *iface, void ppp_l2_register_pkt_cb(ppp_l2_callback_t cb); /* found in ppp_l2.c */ void ppp_driver_feed_data(uint8_t *data, int data_len); -static struct net_if *iface; +static struct net_if *net_iface; static bool test_failed; static bool test_started; @@ -208,15 +208,15 @@ static enum net_verdict ppp_l2_recv(struct net_if *iface, struct net_pkt *pkt) static void test_iface_setup(void) { - iface = net_if_get_first_by_type(&NET_L2_GET_NAME(PPP)); - zassert_not_null(iface, "PPP interface not found!"); + net_iface = net_if_get_first_by_type(&NET_L2_GET_NAME(PPP)); + zassert_not_null(net_iface, "PPP interface not found!"); /* The semaphore is there to wait the data to be received. */ k_sem_init(&wait_data, 0, UINT_MAX); ppp_l2_register_pkt_cb(ppp_l2_recv); - net_if_up(iface); + net_if_up(net_iface); test_failed = false; test_started = true; @@ -245,9 +245,9 @@ static void test_send_ppp_pkt_with_escapes(void) { bool ret; - NET_DBG("Sending data to iface %p", iface); + NET_DBG("Sending data to iface %p", net_iface); - ret = send_iface(iface, ppp_recv_data1, sizeof(ppp_recv_data1), + ret = send_iface(net_iface, ppp_recv_data1, sizeof(ppp_recv_data1), ppp_expect_data1, sizeof(ppp_expect_data1)); zassert_true(ret, "iface"); @@ -257,9 +257,9 @@ static void test_send_ppp_pkt_with_full_and_partial(void) { bool ret; - NET_DBG("Sending data to iface %p", iface); + NET_DBG("Sending data to iface %p", net_iface); - ret = send_iface(iface, ppp_recv_data2, sizeof(ppp_recv_data2), + ret = send_iface(net_iface, ppp_recv_data2, sizeof(ppp_recv_data2), ppp_expect_data1, sizeof(ppp_expect_data1)); zassert_true(ret, "iface"); @@ -320,7 +320,7 @@ static void ppp_verify_fcs(uint8_t *buf, int len) uint8_t *ptr; bool ret; - pkt = net_pkt_alloc_with_buffer(iface, len, AF_UNSPEC, 0, K_NO_WAIT); + pkt = net_pkt_alloc_with_buffer(net_iface, len, AF_UNSPEC, 0, K_NO_WAIT); zassert_not_null(pkt, "Cannot create pkt"); ptr = buf; @@ -391,7 +391,7 @@ static void ppp_calc_fcs(uint8_t *buf, int len) uint8_t *ptr; bool ret; - pkt = net_pkt_alloc_with_buffer(iface, len, AF_UNSPEC, 0, K_NO_WAIT); + pkt = net_pkt_alloc_with_buffer(net_iface, len, AF_UNSPEC, 0, K_NO_WAIT); zassert_not_null(pkt, "Cannot create pkt"); ptr = buf; @@ -445,9 +445,9 @@ static void test_send_ppp_3(void) { bool ret; - NET_DBG("Sending data to iface %p", iface); + NET_DBG("Sending data to iface %p", net_iface); - ret = send_iface(iface, ppp_recv_data3, sizeof(ppp_recv_data3), + ret = send_iface(net_iface, ppp_recv_data3, sizeof(ppp_recv_data3), ppp_expect_data3, sizeof(ppp_expect_data3)); zassert_true(ret, "iface"); @@ -461,9 +461,9 @@ static void test_send_ppp_4(void) { bool ret; - NET_DBG("Sending data to iface %p", iface); + NET_DBG("Sending data to iface %p", net_iface); - ret = send_iface(iface, ppp_recv_data4, sizeof(ppp_recv_data4), + ret = send_iface(net_iface, ppp_recv_data4, sizeof(ppp_recv_data4), ppp_expect_data4, sizeof(ppp_expect_data4)); zassert_true(ret, "iface"); @@ -477,9 +477,9 @@ static void test_send_ppp_5(void) { bool ret; - NET_DBG("Sending data to iface %p", iface); + NET_DBG("Sending data to iface %p", net_iface); - ret = send_iface(iface, ppp_recv_data5, sizeof(ppp_recv_data5), + ret = send_iface(net_iface, ppp_recv_data5, sizeof(ppp_recv_data5), ppp_expect_data5, sizeof(ppp_expect_data5)); zassert_true(ret, "iface"); @@ -493,9 +493,9 @@ static void test_send_ppp_6(void) { bool ret; - NET_DBG("Sending data to iface %p", iface); + NET_DBG("Sending data to iface %p", net_iface); - ret = send_iface(iface, ppp_recv_data6, sizeof(ppp_recv_data6), + ret = send_iface(net_iface, ppp_recv_data6, sizeof(ppp_recv_data6), ppp_expect_data6, sizeof(ppp_expect_data6)); zassert_true(ret, "iface"); @@ -509,9 +509,9 @@ static void test_send_ppp_7(void) { bool ret; - NET_DBG("Sending data to iface %p", iface); + NET_DBG("Sending data to iface %p", net_iface); - ret = send_iface(iface, ppp_recv_data7, sizeof(ppp_recv_data7), + ret = send_iface(net_iface, ppp_recv_data7, sizeof(ppp_recv_data7), ppp_expect_data7, sizeof(ppp_expect_data7)); zassert_true(ret, "iface"); @@ -525,9 +525,9 @@ static void test_send_ppp_8(void) { bool ret; - NET_DBG("Sending data to iface %p", iface); + NET_DBG("Sending data to iface %p", net_iface); - ret = send_iface(iface, ppp_recv_data8, sizeof(ppp_recv_data8), + ret = send_iface(net_iface, ppp_recv_data8, sizeof(ppp_recv_data8), ppp_expect_data8, sizeof(ppp_expect_data8)); zassert_true(ret, "iface"); diff --git a/tests/net/route/src/main.c b/tests/net/route/src/main.c index 8797fbe862..da0c8d64d5 100644 --- a/tests/net/route/src/main.c +++ b/tests/net/route/src/main.c @@ -75,7 +75,7 @@ static struct net_if *recipient; static struct net_if *my_iface; static struct net_if *peer_iface; -static struct net_route_entry *entry; +static struct net_route_entry *route_entry; #define MAX_ROUTES CONFIG_NET_MAX_ROUTES static const int max_routes = MAX_ROUTES; @@ -374,13 +374,13 @@ static void test_populate_nbr_cache(void) static void test_route_add(void) { - entry = net_route_add(my_iface, - &dest_addr, 128, - &peer_addr, - NET_IPV6_ND_INFINITE_LIFETIME, - NET_ROUTE_PREFERENCE_LOW); + route_entry = net_route_add(my_iface, + &dest_addr, 128, + &peer_addr, + NET_IPV6_ND_INFINITE_LIFETIME, + NET_ROUTE_PREFERENCE_LOW); - zassert_not_null(entry, "Route add failed"); + zassert_not_null(route_entry, "Route add failed"); } static void test_route_update(void) @@ -392,7 +392,7 @@ static void test_route_update(void) &peer_addr, NET_IPV6_ND_INFINITE_LIFETIME, NET_ROUTE_PREFERENCE_LOW); - zassert_equal_ptr(update_entry, entry, + zassert_equal_ptr(update_entry, route_entry, "Route add again failed"); } @@ -400,7 +400,7 @@ static void test_route_del(void) { int ret; - ret = net_route_del(entry); + ret = net_route_del(route_entry); if (ret < 0) { zassert_true(0, "Route del failed"); } @@ -410,7 +410,7 @@ static void test_route_del_again(void) { int ret; - ret = net_route_del(entry); + ret = net_route_del(route_entry); if (ret >= 0) { zassert_true(0, "Route del again failed"); } @@ -420,7 +420,7 @@ static void test_route_get_nexthop(void) { struct in6_addr *nexthop; - nexthop = net_route_get_nexthop(entry); + nexthop = net_route_get_nexthop(route_entry); zassert_not_null(nexthop, "Route get nexthop failed"); @@ -494,23 +494,23 @@ static void test_route_del_many(void) static void test_route_lifetime(void) { - entry = net_route_add(my_iface, - &dest_addr, 128, - &peer_addr, - NET_IPV6_ND_INFINITE_LIFETIME, - NET_ROUTE_PREFERENCE_LOW); + route_entry = net_route_add(my_iface, + &dest_addr, 128, + &peer_addr, + NET_IPV6_ND_INFINITE_LIFETIME, + NET_ROUTE_PREFERENCE_LOW); - zassert_not_null(entry, "Route add failed"); + zassert_not_null(route_entry, "Route add failed"); - entry = net_route_lookup(my_iface, &dest_addr); - zassert_not_null(entry, "Route not found"); + route_entry = net_route_lookup(my_iface, &dest_addr); + zassert_not_null(route_entry, "Route not found"); - net_route_update_lifetime(entry, 1); + net_route_update_lifetime(route_entry, 1); k_sleep(K_MSEC(1200)); - entry = net_route_lookup(my_iface, &dest_addr); - zassert_is_null(entry, "Route did not expire"); + route_entry = net_route_lookup(my_iface, &dest_addr); + zassert_is_null(route_entry, "Route did not expire"); } @@ -518,19 +518,19 @@ static void test_route_preference(void) { struct net_route_entry *update_entry; - entry = net_route_add(my_iface, - &dest_addr, 128, - &peer_addr, - NET_IPV6_ND_INFINITE_LIFETIME, - NET_ROUTE_PREFERENCE_LOW); - zassert_not_null(entry, "Route add failed"); + route_entry = net_route_add(my_iface, + &dest_addr, 128, + &peer_addr, + NET_IPV6_ND_INFINITE_LIFETIME, + NET_ROUTE_PREFERENCE_LOW); + zassert_not_null(route_entry, "Route add failed"); update_entry = net_route_add(my_iface, &dest_addr, 128, &peer_addr_alt, NET_IPV6_ND_INFINITE_LIFETIME, NET_ROUTE_PREFERENCE_MEDIUM); - zassert_equal_ptr(update_entry, entry, + zassert_equal_ptr(update_entry, route_entry, "Route add again failed"); update_entry = net_route_add(my_iface, @@ -541,7 +541,7 @@ static void test_route_preference(void) zassert_is_null(update_entry, "Low preference route overwritten medium one"); - net_route_del(entry); + net_route_del(route_entry); } diff --git a/tests/net/shell/src/main.c b/tests/net/shell/src/main.c index 362859b79b..86d3ba1b45 100644 --- a/tests/net/shell/src/main.c +++ b/tests/net/shell/src/main.c @@ -147,7 +147,7 @@ static void *test_setup(void) struct net_if_addr *ifaddr; struct sockaddr_in6 any_addr6; - const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; + const struct in6_addr in6addr_anyaddr = IN6ADDR_ANY_INIT; struct sockaddr_in6 my_addr6; struct in6_addr in6addr_my = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, @@ -169,7 +169,7 @@ static void *test_setup(void) iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); test_failed = false; - net_ipaddr_copy(&any_addr6.sin6_addr, &in6addr_any); + net_ipaddr_copy(&any_addr6.sin6_addr, &in6addr_anyaddr); any_addr6.sin6_family = AF_INET6; net_ipaddr_copy(&my_addr6.sin6_addr, &in6addr_my); diff --git a/tests/net/socket/socketpair/src/block.c b/tests/net/socket/socketpair/src/block.c index e388a79002..f059d68763 100644 --- a/tests/net/socket/socketpair/src/block.c +++ b/tests/net/socket/socketpair/src/block.c @@ -17,11 +17,13 @@ struct ctx { static ZTEST_BMEM struct ctx ctx; static ZTEST_BMEM struct k_work work; -static void work_handler(struct k_work *work) +static void work_handler(struct k_work *w) { int res; char c = '\0'; + (void)w; + LOG_DBG("doing work"); while (true) { diff --git a/tests/net/socket/socketpair/src/poll.c b/tests/net/socket/socketpair/src/poll.c index 71765dee6b..e9ab9ae3f4 100644 --- a/tests/net/socket/socketpair/src/poll.c +++ b/tests/net/socket/socketpair/src/poll.c @@ -80,9 +80,9 @@ ZTEST_USER(net_socketpair, test_poll_timeout_nonblocking) test_socketpair_poll_timeout_common(sv); } -static void close_fun(struct k_work *work) +static void close_fun(struct k_work *w) { - (void)work; + (void)w; if (!(K_TIMEOUT_EQ(ctx.delay, K_NO_WAIT) || K_TIMEOUT_EQ(ctx.delay, K_FOREVER))) { @@ -233,9 +233,9 @@ ZTEST_USER(net_socketpair, test_poll_immediate_data) close(sv[1]); } -static void rw_fun(struct k_work *work) +static void rw_fun(struct k_work *w) { - (void)work; + (void)w; int res; char c; diff --git a/tests/net/socket/udp/src/main.c b/tests/net/socket/udp/src/main.c index f1affe5852..ea53c43367 100644 --- a/tests/net/socket/udp/src/main.c +++ b/tests/net/socket/udp/src/main.c @@ -921,7 +921,7 @@ struct eth_fake_context { }; static struct eth_fake_context eth_fake_data; -static ZTEST_BMEM struct sockaddr_in6 server_addr; +static ZTEST_BMEM struct sockaddr_in6 udp_server_addr; /* The semaphore is there to wait the data to be received. */ static ZTEST_BMEM SYS_MUTEX_DEFINE(wait_data); @@ -1016,14 +1016,14 @@ ZTEST(net_socket_udp, test_17_setup_eth) net_if_up(eth_iface); - (void)memset(&server_addr, 0, sizeof(server_addr)); - server_addr.sin6_family = AF_INET6; - server_addr.sin6_port = htons(1234); - ret = inet_pton(AF_INET6, PEER_IPV6_ADDR_ETH, &server_addr.sin6_addr); + (void)memset(&udp_server_addr, 0, sizeof(udp_server_addr)); + udp_server_addr.sin6_family = AF_INET6; + udp_server_addr.sin6_port = htons(1234); + ret = inet_pton(AF_INET6, PEER_IPV6_ADDR_ETH, &udp_server_addr.sin6_addr); zassert_equal(ret, 1, "inet_pton failed"); /* In order to avoid neighbor discovery, populate neighbor cache */ - net_ipv6_nbr_add(eth_iface, &server_addr.sin6_addr, &server_link_addr, + net_ipv6_nbr_add(eth_iface, &udp_server_addr.sin6_addr, &server_link_addr, true, NET_IPV6_NBR_STATE_REACHABLE); } @@ -1057,8 +1057,8 @@ ZTEST_USER(net_socket_udp, test_18_v6_sendmsg_with_txtime) msg.msg_controllen = sizeof(cmsgbuf.buf); msg.msg_iov = io_vector; msg.msg_iovlen = 1; - msg.msg_name = &server_addr; - msg.msg_namelen = sizeof(server_addr); + msg.msg_name = &udp_server_addr; + msg.msg_namelen = sizeof(udp_server_addr); txtime = TEST_TXTIME; @@ -1096,7 +1096,7 @@ void test_msg_trunc(int sock_c, int sock_s, struct sockaddr *addr_c, socklen_t addrlen_s) { int rv; - uint8_t rx_buf[sizeof(TEST_STR_SMALL) - 1]; + uint8_t str_buf[sizeof(TEST_STR_SMALL) - 1]; rv = bind(sock_s, addr_s, addrlen_s); zassert_equal(rv, 0, "server bind failed"); @@ -1112,14 +1112,14 @@ void test_msg_trunc(int sock_c, int sock_s, struct sockaddr *addr_c, rv = send(sock_c, BUF_AND_SIZE(TEST_STR_SMALL), 0); zassert_equal(rv, sizeof(TEST_STR_SMALL) - 1, "send failed"); - memset(rx_buf, 0, sizeof(rx_buf)); - rv = recv(sock_s, rx_buf, 2, ZSOCK_MSG_TRUNC); + memset(str_buf, 0, sizeof(str_buf)); + rv = recv(sock_s, str_buf, 2, ZSOCK_MSG_TRUNC); zassert_equal(rv, sizeof(TEST_STR_SMALL) - 1, "MSG_TRUNC flag failed"); - zassert_mem_equal(rx_buf, TEST_STR_SMALL, 2, "invalid rx data"); - zassert_equal(rx_buf[2], 0, "received more than requested"); + zassert_mem_equal(str_buf, TEST_STR_SMALL, 2, "invalid rx data"); + zassert_equal(str_buf[2], 0, "received more than requested"); /* The remaining data should've been discarded */ - rv = recv(sock_s, rx_buf, sizeof(rx_buf), ZSOCK_MSG_DONTWAIT); + rv = recv(sock_s, str_buf, sizeof(str_buf), ZSOCK_MSG_DONTWAIT); zassert_equal(rv, -1, "consecutive recv should've failed"); zassert_equal(errno, EAGAIN, "incorrect errno value"); @@ -1128,15 +1128,15 @@ void test_msg_trunc(int sock_c, int sock_s, struct sockaddr *addr_c, rv = send(sock_c, BUF_AND_SIZE(TEST_STR_SMALL), 0); zassert_equal(rv, sizeof(TEST_STR_SMALL) - 1, "send failed"); - memset(rx_buf, 0, sizeof(rx_buf)); - rv = recv(sock_s, rx_buf, 2, ZSOCK_MSG_TRUNC | ZSOCK_MSG_PEEK); + memset(str_buf, 0, sizeof(str_buf)); + rv = recv(sock_s, str_buf, 2, ZSOCK_MSG_TRUNC | ZSOCK_MSG_PEEK); zassert_equal(rv, sizeof(TEST_STR_SMALL) - 1, "MSG_TRUNC flag failed"); /* The packet should still be available due to MSG_PEEK */ - rv = recv(sock_s, rx_buf, sizeof(rx_buf), ZSOCK_MSG_TRUNC); + rv = recv(sock_s, str_buf, sizeof(str_buf), ZSOCK_MSG_TRUNC); zassert_equal(rv, sizeof(TEST_STR_SMALL) - 1, "recv after MSG_PEEK failed"); - zassert_mem_equal(rx_buf, BUF_AND_SIZE(TEST_STR_SMALL), + zassert_mem_equal(str_buf, BUF_AND_SIZE(TEST_STR_SMALL), "invalid rx data"); rv = close(sock_c); diff --git a/tests/net/socket/websocket/src/main.c b/tests/net/socket/websocket/src/main.c index 68528a07bf..b3ed112851 100644 --- a/tests/net/socket/websocket/src/main.c +++ b/tests/net/socket/websocket/src/main.c @@ -64,22 +64,22 @@ static int test_fd_alloc(void *obj) return fd; } -static int test_recv_buf(uint8_t *feed_buf, size_t feed_len, +static int test_recv_buf(uint8_t *input_buf, size_t input_len, struct websocket_context *ctx, uint32_t *msg_type, uint64_t *remaining, - uint8_t *recv_buf, size_t recv_len) + uint8_t *recv_buffer, size_t recv_len) { static struct test_data test_data; int fd, ret; test_data.ctx = ctx; - test_data.input_buf = feed_buf; - test_data.input_len = feed_len; + test_data.input_buf = input_buf; + test_data.input_len = input_len; test_data.input_pos = 0; fd = test_fd_alloc(&test_data); - ret = websocket_recv_msg(fd, recv_buf, recv_len, + ret = websocket_recv_msg(fd, recv_buffer, recv_len, msg_type, remaining, 0); z_free_fd(fd); diff --git a/tests/net/tcp/src/main.c b/tests/net/tcp/src/main.c index a0426e7af0..f2e9244ad2 100644 --- a/tests/net/tcp/src/main.c +++ b/tests/net/tcp/src/main.c @@ -93,7 +93,7 @@ static struct sockaddr_in6 peer_addr_v6_s = { 0, 0, 0, 0, 0, 0, 0, 0x2 } } }, }; -static struct net_if *iface; +static struct net_if *net_iface; static uint8_t test_case_no; static uint32_t seq; static uint32_t ack; @@ -231,7 +231,7 @@ static struct net_pkt *tester_prepare_tcp_pkt(sa_family_t af, } /* Allocate buffer */ - pkt = net_pkt_alloc_with_buffer(iface, + pkt = net_pkt_alloc_with_buffer(net_iface, sizeof(struct tcphdr) + len + opts_len, af, IPPROTO_TCP, K_NO_WAIT); if (!pkt) { @@ -438,17 +438,17 @@ static void *presetup(void) { struct net_if_addr *ifaddr; - iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); - if (!iface) { + net_iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); + if (!net_iface) { zassert_true(false, "Interface not available"); } - ifaddr = net_if_ipv4_addr_add(iface, &my_addr, NET_ADDR_MANUAL, 0); + ifaddr = net_if_ipv4_addr_add(net_iface, &my_addr, NET_ADDR_MANUAL, 0); if (!ifaddr) { zassert_true(false, "Failed to add IPv4 address"); } - ifaddr = net_if_ipv6_addr_add(iface, &my_addr_v6, NET_ADDR_MANUAL, 0); + ifaddr = net_if_ipv6_addr_add(net_iface, &my_addr_v6, NET_ADDR_MANUAL, 0); if (!ifaddr) { zassert_true(false, "Failed to add IPv6 address"); } @@ -501,7 +501,7 @@ static void handle_client_test(sa_family_t af, struct tcphdr *th) return; } - ret = net_recv_data(iface, reply); + ret = net_recv_data(net_iface, reply); if (ret < 0) { goto fail; } @@ -681,7 +681,7 @@ static void handle_server_test(sa_family_t af, struct tcphdr *th) return; } - ret = net_recv_data(iface, reply); + ret = net_recv_data(net_iface, reply); if (ret < 0) { goto fail; } @@ -1041,7 +1041,7 @@ send_next: return; } - ret = net_recv_data(iface, reply); + ret = net_recv_data(net_iface, reply); if (ret < 0) { goto fail; } @@ -1163,7 +1163,7 @@ static void handle_client_closing_test(sa_family_t af, struct tcphdr *th) return; } - ret = net_recv_data(iface, reply); + ret = net_recv_data(net_iface, reply); if (ret < 0) { goto fail; } @@ -1291,20 +1291,20 @@ static void check_rst_fail(uint32_t seq_value) int rsterr_before, rsterr_after; int ret; - rsterr_before = GET_STAT(iface, tcp.rsterr); + rsterr_before = GET_STAT(net_iface, tcp.rsterr); /* Invalid seq in the RST packet */ seq = seq_value; reply = prepare_rst_packet(AF_INET6, htons(MY_PORT), htons(PEER_PORT)); - ret = net_recv_data(iface, reply); + ret = net_recv_data(net_iface, reply); zassert_true(ret == 0, "recv data failed (%d)", ret); /* Let the receiving thread run */ k_msleep(50); - rsterr_after = GET_STAT(iface, tcp.rsterr); + rsterr_after = GET_STAT(net_iface, tcp.rsterr); zassert_equal(rsterr_before + 1, rsterr_after, "RST packet not skipped (before %d, after %d)", @@ -1328,15 +1328,15 @@ static void check_rst_succeed(struct net_context *ctx, reply = prepare_rst_packet(AF_INET6, htons(MY_PORT), htons(PEER_PORT)); - rsterr_before = GET_STAT(iface, tcp.rsterr); + rsterr_before = GET_STAT(net_iface, tcp.rsterr); - ret = net_recv_data(iface, reply); + ret = net_recv_data(net_iface, reply); zassert_true(ret == 0, "recv data failed (%d)", ret); /* Let the receiving thread run */ k_msleep(50); - rsterr_after = GET_STAT(iface, tcp.rsterr); + rsterr_after = GET_STAT(net_iface, tcp.rsterr); zassert_equal(rsterr_before, rsterr_after, "RST packet skipped (before %d, after %d)", @@ -1447,7 +1447,7 @@ static void checklist_based_out_of_order_test(struct out_of_order_check_struct * /* Initial ack for the last correctly received byte = SYN flag */ expected_ack = sequence_base + check_ptr->ack_offset; - ret = net_recv_data(iface, pkt); + ret = net_recv_data(net_iface, pkt); zassert_true(ret == 0, "recv data failed (%d)", ret); /* Let the IP stack to process the packet properly */ @@ -1523,7 +1523,7 @@ static void test_server_timeout_out_of_order_data(void) seq = expected_ack + 1; rst = prepare_rst_packet(AF_INET6, htons(MY_PORT), htons(PEER_PORT)); - ret = net_recv_data(iface, rst); + ret = net_recv_data(net_iface, rst); zassert_true(ret == 0, "recv data failed (%d)", ret); /* Let the receiving thread run */ diff --git a/tests/net/udp/src/main.c b/tests/net/udp/src/main.c index 735ec1eb70..0457d38828 100644 --- a/tests/net/udp/src/main.c +++ b/tests/net/udp/src/main.c @@ -438,7 +438,7 @@ ZTEST(udp_fn_tests, test_udp) bool st; struct sockaddr_in6 any_addr6; - const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; + const struct in6_addr in6addr_anyaddr = IN6ADDR_ANY_INIT; struct sockaddr_in6 my_addr6; struct in6_addr in6addr_my = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, @@ -459,7 +459,7 @@ ZTEST(udp_fn_tests, test_udp) iface = net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)); - net_ipaddr_copy(&any_addr6.sin6_addr, &in6addr_any); + net_ipaddr_copy(&any_addr6.sin6_addr, &in6addr_anyaddr); any_addr6.sin6_family = AF_INET6; net_ipaddr_copy(&my_addr6.sin6_addr, &in6addr_my); diff --git a/tests/posix/eventfd/src/_main.c b/tests/posix/eventfd/src/_main.c index 5da8d18ad5..cf4e9e6ad6 100644 --- a/tests/posix/eventfd/src/_main.c +++ b/tests/posix/eventfd/src/_main.c @@ -81,12 +81,12 @@ void eventfd_poll_set_common(int fd) zassert_equal(ret, 1, "eventfd is not blocked after read"); } -static struct eventfd_fixture fixture; +static struct eventfd_fixture efd_fixture; static void *setup(void) { - fixture.fd = -1; - return &fixture; + efd_fixture.fd = -1; + return &efd_fixture; } static void before(void *arg)