Lines Matching +full:address +full:- +full:0
1 /* main.c - Application main entry point */
6 * SPDX-License-Identifier: Apache-2.0
45 "Test 0x%s failed.\n", expected); \
46 } while (0)
53 "Test 0x%s failed.\n", expected); \
54 } while (0)
62 } while (0)
70 } while (0)
82 sizeof(out) - LL_ADDR_STR_SIZE, "%s", \
87 } while (0)
97 } while (0)
106 } while (0)
115 struct net_test_context *net_test_context = dev->data; in net_test_init()
119 return 0; in net_test_init()
124 struct net_test_context *context = dev->data; in net_test_get_mac()
126 if (context->mac_addr[2] == 0x00) { in net_test_get_mac()
127 /* 00-00-5E-00-53-xx Documentation RFC 7042 */ in net_test_get_mac()
128 context->mac_addr[0] = 0x00; in net_test_get_mac()
129 context->mac_addr[1] = 0x00; in net_test_get_mac()
130 context->mac_addr[2] = 0x5E; in net_test_get_mac()
131 context->mac_addr[3] = 0x00; in net_test_get_mac()
132 context->mac_addr[4] = 0x53; in net_test_get_mac()
133 context->mac_addr[5] = sys_rand8_get(); in net_test_get_mac()
136 return context->mac_addr; in net_test_get_mac()
148 return 0; in tester_send()
177 TEST_BYTE_1(0xde, "DE"); in ZTEST()
178 TEST_BYTE_1(0x09, "09"); in ZTEST()
179 TEST_BYTE_2(0xa9, "a9"); in ZTEST()
180 TEST_BYTE_2(0x80, "80"); in ZTEST()
182 TEST_LL_6(0x12, 0x9f, 0xe3, 0x01, 0x7f, 0x00, "12:9F:E3:01:7F:00"); in ZTEST()
183 TEST_LL_8(0x12, 0x9f, 0xe3, 0x01, 0x7f, 0x00, 0xff, 0x0f, \ in ZTEST()
184 "12:9F:E3:01:7F:00:FF:0F"); in ZTEST()
186 TEST_LL_6_TWO(0x12, 0x9f, 0xe3, 0x01, 0x7f, 0x00, \ in ZTEST()
189 TEST_IPV6(0x20, 1, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, \ in ZTEST()
192 TEST_IPV6(0x20, 0x01, 0x0d, 0xb8, 0x12, 0x34, 0x56, 0x78, \ in ZTEST()
193 0x9a, 0xbc, 0xde, 0xf0, 0x01, 0x02, 0x03, 0x04, \ in ZTEST()
196 TEST_IPV6(0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ in ZTEST()
197 0x0c, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, \ in ZTEST()
198 "fe80::cb8:0:0:2"); in ZTEST()
200 TEST_IPV6(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ in ZTEST()
201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, \ in ZTEST()
204 TEST_IPV6(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ in ZTEST()
205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ in ZTEST()
208 TEST_IPV4(192, 168, 0, 1, "192.168.0.1"); in ZTEST()
209 TEST_IPV4(0, 0, 0, 0, "0.0.0.0"); in ZTEST()
210 TEST_IPV4(127, 0, 0, 1, "127.0.0.1"); in ZTEST()
217 struct in6_addr mcast = { { { 0xff, 0x84, 0, 0, 0, 0, 0, 0, in ZTEST()
218 0, 0, 0, 0, 0, 0, 0, 0x2 } } }; in ZTEST()
219 struct in6_addr addr6 = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, in ZTEST()
220 0, 0, 0, 0, 0, 0, 0, 0x1 } } }; in ZTEST()
221 struct in6_addr addr6_pref1 = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, in ZTEST()
222 0, 0, 0, 0, 0, 0, 0, 0x1 } } }; in ZTEST()
223 struct in6_addr addr6_pref2 = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, in ZTEST()
224 0, 0, 0, 0, 0, 0, 0, 0x2 } } }; in ZTEST()
225 struct in6_addr addr6_pref3 = { { { 0x20, 0x01, 0x0d, 0xb8, 0x64, 0, 0, in ZTEST()
226 0, 0, 0, 0, 0, 0, 0, 0, 0x2 } } }; in ZTEST()
234 /**TESTPOINT: Check if the IPv6 address is a loopback address*/ in ZTEST()
236 "IPv6 loopback address check failed."); in ZTEST()
238 /**TESTPOINT: Check if the IPv6 address is a multicast address*/ in ZTEST()
240 "IPv6 multicast address check failed."); in ZTEST()
245 0); in ZTEST()
246 /**TESTPOINT: Check if IPv6 interface address is added*/ in ZTEST()
247 zassert_not_null(ifaddr1, "IPv6 interface address add failed"); in ZTEST()
253 "IPv6 interface address mismatch"); in ZTEST()
255 /**TESTPOINT: Check if the IPv6 address is a loopback address*/ in ZTEST()
257 "My IPv6 loopback address check failed"); in ZTEST()
259 /**TESTPOINT: Check IPv6 address*/ in ZTEST()
261 "My IPv6 address check failed"); in ZTEST()
283 zassert_not_null(ifmaddr1, "IPv6 multicast address add failed"); in ZTEST()
288 "IPv6 multicast address could be added failed"); in ZTEST()
291 "My IPv6 unspecified address check failed"); in ZTEST()
296 0); in ZTEST()
297 zassert_not_null(ifaddr2, "IPv6 ll address autoconf add failed"); in ZTEST()
299 ifaddr2->addr_state = NET_ADDR_PREFERRED; in ZTEST()
304 "IPv6 ll address fetch failed"); in ZTEST()
306 ifaddr2->addr_state = NET_ADDR_DEPRECATED; in ZTEST()
310 "IPv6 preferred ll address fetch failed"); in ZTEST()
315 0); in ZTEST()
316 zassert_not_null(ifaddr1, "IPv6 global address autoconf add failed"); in ZTEST()
318 ifaddr1->addr_state = NET_ADDR_PREFERRED; in ZTEST()
323 for (i = 0, iface = default_iface; i < 2; i++, iface = NULL) { in ZTEST()
324 ifaddr2->addr_state = NET_ADDR_DEPRECATED; in ZTEST()
331 DBG("Selected IPv6 address %s, iface %p\n", in ZTEST()
334 zassert_false(memcmp(out->s6_addr, &addr6_pref2.s6_addr, in ZTEST()
336 "IPv6 wrong src address selected, iface %p\n", in ZTEST()
339 /* Now we should get :: address */ in ZTEST()
344 DBG("Selected IPv6 address %s, iface %p\n", in ZTEST()
347 zassert_false(memcmp(out->s6_addr, &any.s6_addr, in ZTEST()
349 "IPv6 wrong src any address selected, iface %p\n", in ZTEST()
352 ifaddr2->addr_state = NET_ADDR_PREFERRED; in ZTEST()
354 /* Now we should get ll address */ in ZTEST()
359 DBG("Selected IPv6 address %s, iface %p\n", in ZTEST()
362 zassert_false(memcmp(out->s6_addr, &addr6.s6_addr, in ZTEST()
364 "IPv6 wrong src ll address selected, iface %p\n", in ZTEST()
369 "IPv6 removing address failed\n"); in ZTEST()
371 "IPv6 removing address failed\n"); in ZTEST()
379 struct in_addr lladdr4_1 = { { { 169, 254, 0, 1 } } }; in ZTEST()
380 struct in_addr lladdr4_2 = { { { 169, 254, 0, 3 } } }; in ZTEST()
381 struct in_addr netmask = { { { 255, 255, 0, 0 } } }; in ZTEST()
382 struct in_addr dst4 = { { { 169, 254, 0, 2 } } }; in ZTEST()
384 ifaddr = net_if_ipv4_addr_add(default_iface, &lladdr4_1, NET_ADDR_MANUAL, 0); in ZTEST()
385 zassert_not_null(ifaddr, "IPv4 interface address add failed"); in ZTEST()
387 "My IPv4 address check failed"); in ZTEST()
391 ifaddr = net_if_ipv4_addr_add(second_iface, &lladdr4_2, NET_ADDR_MANUAL, 0); in ZTEST()
392 zassert_not_null(ifaddr, "IPv4 interface address add failed"); in ZTEST()
394 "My IPv4 address check failed"); in ZTEST()
406 DBG("Selected IPv4 address %s, iface %p\n", net_sprint_ipv4_addr(out), in ZTEST()
410 zassert_equal(out->s_addr, lladdr4_1.s_addr, in ZTEST()
411 "IPv4 wrong src address selected, iface %p\n", iface); in ZTEST()
421 struct in_addr netmask_1 = { { { 255, 255, 255, 0 } } }; in ZTEST()
426 ifaddr = net_if_ipv4_addr_add(default_iface, &lladdr4_1, NET_ADDR_MANUAL, 0); in ZTEST()
427 zassert_not_null(ifaddr, "IPv4 interface address add failed"); in ZTEST()
429 "My IPv4 address check failed"); in ZTEST()
433 ifaddr = net_if_ipv4_addr_add(second_iface, &lladdr4_2, NET_ADDR_MANUAL, 0); in ZTEST()
434 zassert_not_null(ifaddr, "IPv4 interface address add failed"); in ZTEST()
436 "My IPv4 address check failed"); in ZTEST()
445 DBG("Selected IPv4 address %s, iface %p\n", net_sprint_ipv4_addr(out), in ZTEST()
448 zassert_equal(out->s_addr, lladdr4_1.s_addr, in ZTEST()
449 "IPv4 wrong src address selected, iface %p\n", iface); in ZTEST()
457 DBG("Selected IPv4 address %s, iface %p\n", net_sprint_ipv4_addr(out), in ZTEST()
460 zassert_equal(out->s_addr, lladdr4_2.s_addr, in ZTEST()
461 "IPv4 wrong src address selected, iface %p\n", iface); in ZTEST()
470 struct in_addr addr4 = { { { 192, 168, 0, 1 } } }; in ZTEST()
474 struct in_addr maddr4a = { { { 224, 0, 0, 1 } } }; in ZTEST()
475 struct in_addr maddr4b = { { { 224, 0, 0, 2 } } }; in ZTEST()
476 struct in_addr match_addr = { { { 192, 168, 0, 2 } } }; in ZTEST()
477 struct in_addr fail_addr = { { { 10, 1, 0, 2 } } }; in ZTEST()
478 struct in_addr netmask = { { { 255, 255, 255, 0 } } }; in ZTEST()
479 struct in_addr netmask2 = { { { 255, 255, 0, 0 } } }; in ZTEST()
480 struct in_addr gw = { { { 192, 168, 0, 42 } } }; in ZTEST()
481 struct in_addr loopback4 = { { { 127, 0, 0, 1 } } }; in ZTEST()
485 struct in_addr bcast_addr4 = { { { 192, 0, 2, 255 } } }; in ZTEST()
486 struct in_addr bcast_addr5 = { { { 192, 168, 0, 255 } } }; in ZTEST()
493 0); in ZTEST()
494 zassert_not_null(ifaddr1, "IPv4 interface address add failed"); in ZTEST()
497 "My IPv4 address check failed"); in ZTEST()
504 0); in ZTEST()
505 zassert_not_null(ifaddr1, "IPv4 interface address add failed"); in ZTEST()
510 "My IPv4 address check failed"); in ZTEST()
513 "My IPv4 loopback address check failed"); in ZTEST()
518 for (i = 0, iface = default_iface; i < 2; i++, iface = NULL) { in ZTEST()
523 DBG("Selected IPv4 address %s, iface %p\n", in ZTEST()
526 zassert_equal(out->s_addr, addr4.s_addr, in ZTEST()
527 "IPv4 wrong src address selected, iface %p\n", in ZTEST()
530 /* Now we should get ll address */ in ZTEST()
535 DBG("Selected IPv4 address %s, iface %p\n", in ZTEST()
538 zassert_equal(out->s_addr, lladdr4.s_addr, in ZTEST()
539 "IPv4 wrong src ll address selected, iface %p\n", in ZTEST()
542 /* Now we should get 192.168.0.1 address */ in ZTEST()
547 DBG("Selected IPv4 address %s, iface %p\n", in ZTEST()
550 zassert_equal(out->s_addr, addr4.s_addr, in ZTEST()
551 "IPv4 wrong src address selected, iface %p\n", in ZTEST()
554 /* Now we should get 192.168.0.1 address */ in ZTEST()
559 DBG("Selected IPv4 address %s, iface %p\n", in ZTEST()
562 zassert_equal(out->s_addr, addr4.s_addr, in ZTEST()
563 "IPv4 wrong src address selected, iface %p\n", in ZTEST()
578 "IPv4 multicast address"); in ZTEST()
581 "IPv4 multicast address"); in ZTEST()
583 zassert_false(net_ipv4_is_addr_mcast(&addr4), "IPv4 address"); in ZTEST()
585 zassert_false(net_ipv4_is_addr_mcast(&bcast_addr1), "IPv4 broadcast address"); in ZTEST()
588 zassert_not_null(ifmaddr1, "IPv4 multicast address add failed"); in ZTEST()
591 zassert_not_null(ifmaddr1, "IPv4 multicast address add failed"); in ZTEST()
599 zassert_not_null(ifmaddr1, "IPv4 multicast address lookup failed"); in ZTEST()
603 zassert_not_null(ifmaddr1, "IPv4 multicast address lookup failed"); in ZTEST()
607 zassert_is_null(ifmaddr1, "IPv4 multicast address lookup succeed"); in ZTEST()
616 zassert_is_null(ifmaddr1, "IPv4 multicast address lookup succeed"); in ZTEST()
622 zassert_is_null(ifmaddr1, "IPv4 multicast address lookup succeed"); in ZTEST()
625 zassert_true(ret, "IPv4 address 1 is not broadcast address"); in ZTEST()
628 zassert_false(ret, "IPv4 address 2 is broadcast address"); in ZTEST()
631 zassert_false(ret, "IPv4 address 4 is broadcast address"); in ZTEST()
634 zassert_false(ret, "IPv4 address is broadcast address"); in ZTEST()
637 zassert_true(ret, "IPv4 address 5 is not broadcast address"); in ZTEST()
640 zassert_false(ret, "IPv4 address 2 is broadcast address"); in ZTEST()
645 zassert_true(ret, "IPv4 address 3 is not broadcast address"); in ZTEST()
652 struct in6_addr lla = { { { 0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0x54, 0xdb, in ZTEST()
653 0x88, 0x1c, 0x38, 0x45, 0x57, 0xf4 } } }; in ZTEST()
654 struct in6_addr ml_eid = { { { 0xfd, 0xe5, 0x8d, 0xba, 0x82, 0xe1, 0, in ZTEST()
655 0x01, 0x40, 0x16, 0x99, 0x3c, 0x83, 0x99, in ZTEST()
656 0x35, 0xab } } }; in ZTEST()
657 struct in6_addr ll_mcast = { { { 0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, in ZTEST()
658 0, 0, 0, 0, 0x1 } } }; in ZTEST()
659 struct in6_addr ml_mcast = { { { 0xff, 0x03, 0, 0, 0, 0, 0, 0, 0, 0, 0, in ZTEST()
660 0, 0, 0, 0, 0x1 } } }; in ZTEST()
663 ifaddr = net_if_ipv6_addr_add(iface, &lla, NET_ADDR_AUTOCONF, 0); in ZTEST()
664 zassert_not_null(ifaddr, "IPv6 ll address autoconf add failed"); in ZTEST()
666 ifaddr = net_if_ipv6_addr_add(iface, &ml_eid, NET_ADDR_AUTOCONF, 0); in ZTEST()
667 zassert_not_null(ifaddr, "IPv6 ll address autoconf add failed"); in ZTEST()
669 ifaddr->is_mesh_local = true; in ZTEST()
672 "IPv6 multicast mesh address check failed"); in ZTEST()
677 DBG("IPv6: destination: %s - selected %s\n", in ZTEST()
680 zassert_false(memcmp(out->s6_addr, &lla.s6_addr, in ZTEST()
682 "IPv6 wrong src address selected\n"); in ZTEST()
687 DBG("IPv6: destination: %s - selected %s\n", in ZTEST()
690 zassert_false(memcmp(out->s6_addr, &ml_eid.s6_addr, in ZTEST()
692 "IPv6 wrong src address selected\n"); in ZTEST()
695 "IPv6 removing address failed\n"); in ZTEST()
697 "IPv6 removing address failed\n"); in ZTEST()
708 .addr = { { { 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, in ZTEST()
709 0, 0, 0, 0, 0, 0, 0x99, 0x1 } } }, in ZTEST()
713 .addr = { { { 0xfc, 0x01, 0, 0, 0, 0, 0, 0, in ZTEST()
714 0, 0, 0, 0, 0, 0, 0, 1 } } }, in ZTEST()
718 .addr = { { { 0xfc, 0, 0, 0, 0, 0, 0, 0, in ZTEST()
719 0, 0, 0, 0, 0, 0, 0, 2 } } }, in ZTEST()
723 .addr = { { { 0x20, 0x01, 0x1d, 0xb8, 0, 0, 0, 0, in ZTEST()
724 0, 0, 0, 0, 0, 0, 0x99, 0x1 } } }, in ZTEST()
729 for (int i = 0; i < ARRAY_SIZE(addrs); i++) { in ZTEST()
731 zassert_equal(ret, addrs[i].is_private, "Address %s check failed", in ZTEST()
745 .addr = { { { 192, 0, 2, 1 } } }, in ZTEST()
765 .addr = { { { 172, 16, 0, 0 } } }, in ZTEST()
777 .addr = { { { 203, 0, 113, 122 } } }, in ZTEST()
790 for (int i = 0; i < ARRAY_SIZE(addrs); i++) { in ZTEST()
792 zassert_equal(ret, addrs[i].is_private, "Address %s check failed", in ZTEST()
800 addr->is_used = false; in clear_addr4()