aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav Mitrofanov <v.v.mitrofanov@yadro.com>2022-12-02 12:18:11 +0300
committerTom Rini <trini@konsulko.com>2022-12-05 12:47:17 -0500
commit8576dcdf0036be116a3424505984a9b2de7c9bf8 (patch)
treeed51a863ea99f9760e59021782222cc345983562
parentd9f5c41e9ac64c255a88832488a425d6d4f275ae (diff)
downloadu-boot-8576dcdf0036be116a3424505984a9b2de7c9bf8.zip
u-boot-8576dcdf0036be116a3424505984a9b2de7c9bf8.tar.gz
u-boot-8576dcdf0036be116a3424505984a9b2de7c9bf8.tar.bz2
test: dm: eth: Add ip6_addr_in_subnet test
Add a test if two address are in the same subnet. Use in sandbox Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com> Reviewed-by: Ramon Fried <rfried.dev@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--test/dm/eth.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/dm/eth.c b/test/dm/eth.c
index 5ffa0c4..4c50258 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -104,6 +104,31 @@ static int dm_test_csum_ipv6_magic(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_csum_ipv6_magic, 0);
+
+static int dm_test_ip6_addr_in_subnet(struct unit_test_state *uts)
+{
+ struct in6_addr our = {.s6_addr32[0] = 0x000080fe,
+ .s6_addr32[1] = 0x00000000,
+ .s6_addr32[2] = 0xffe9f242,
+ .s6_addr32[3] = 0xe8f66dfe};
+ struct in6_addr neigh1 = {.s6_addr32[0] = 0x000080fe,
+ .s6_addr32[1] = 0x00000000,
+ .s6_addr32[2] = 0xffd5b372,
+ .s6_addr32[3] = 0x3ef692fe};
+ struct in6_addr neigh2 = {.s6_addr32[0] = 0x60480120,
+ .s6_addr32[1] = 0x00006048,
+ .s6_addr32[2] = 0x00000000,
+ .s6_addr32[3] = 0x00008888};
+
+ /* in */
+ ut_assert(ip6_addr_in_subnet(&our, &neigh1, 64));
+ /* outside */
+ ut_assert(!ip6_addr_in_subnet(&our, &neigh2, 64));
+ ut_assert(!ip6_addr_in_subnet(&our, &neigh1, 128));
+
+ return 0;
+}
+DM_TEST(dm_test_ip6_addr_in_subnet, 0);
#endif
static int dm_test_eth(struct unit_test_state *uts)