24 ip6_address_t * ip6_src,
u8 ip6_src_len,
25 u8 ea_bits_len,
u8 psid_offset,
31 if (ea_bits_len > 0 && (ip6_prefix_len + ea_bits_len) > 64)
50 if (ip4_prefix_len + ea_bits_len < 32)
54 suffix_len = ea_bits_len;
59 suffix_len = 32 - ip4_prefix_len;
63 d->
psid_shift = 16 - psid_length - psid_offset;
66 if (ip6_prefix_len + suffix_len + d->
psid_length > 64)
90 ip6_address_t ip6_src;
92 ip4_prefix.
as_u32 = clib_host_to_net_u32(0x14000000);
93 ip6_prefix.as_u64[0] = clib_host_to_net_u64(0x20010db800000000);
94 ip6_prefix.as_u64[1] = 0;
95 ip6_src.as_u64[0] = clib_host_to_net_u64(0x20010db8ffff0000);
96 map_domain_t * d =
get_domain (&ip4_prefix, 8, &ip6_prefix, 40, &ip6_src, 96, 24, 0, 0, 0,
MAP_DOMAIN_TRANSLATION);
102 assert(dst6.as_u64[0] == 0x20010db800a9c9db);
103 assert(dst6.as_u64[1] == 0x000014a9c9db0000);
119 ip6_address_t ip6_src;
122 ip4_prefix.
as_u32 = clib_host_to_net_u32(0x14000000);
123 ip6_prefix.as_u64[0] = clib_host_to_net_u64(0x20010db800000000);
124 ip6_prefix.as_u64[1] = 0;
125 ip6_src.as_u64[0] = clib_host_to_net_u64(0x20010db8ffff0000);
126 ip6_src.as_u64[1] = clib_host_to_net_u64(0x0000000000000001);
128 128, 16, 6, 8, 0, 0);
132 d =
get_domain (&ip4_prefix, 8, &ip6_prefix, 32, &ip6_src,
136 assert(dst6.as_u64[0] == 0x20010db8a0000000);
137 assert(dst6.as_u64[1] == 0x000014a000000000);
140 d =
get_domain (&ip4_prefix, 8, &ip6_prefix, 32, &ip6_src,
144 assert(dst6.as_u64[0] == 0x20010db8a9000000);
145 assert(dst6.as_u64[1] == 0x000014a900000000);
148 d =
get_domain (&ip4_prefix, 8, &ip6_prefix, 32, &ip6_src,
149 128, 10, 0, 0, 0, 0);
152 assert(dst6.as_u64[0] == 0x20010db8a9c00000);
153 assert(dst6.as_u64[1] == 0x000014a9c0000000);
156 d =
get_domain (&ip4_prefix, 8, &ip6_prefix, 32, &ip6_src,
157 128, 16, 0, 0, 0, 0);
160 assert(dst6.as_u64[0] == 0x20010db8a9c90000);
161 assert(dst6.as_u64[1] == 0x000014a9c9000000);
164 d =
get_domain (&ip4_prefix, 8, &ip6_prefix, 32, &ip6_src,
165 128, 20, 0, 0, 0, 0);
168 assert(dst6.as_u64[0] == 0x20010db8a9c9d000);
169 assert(dst6.as_u64[1] == 0x000014a9c9d00000);
172 d =
get_domain (&ip4_prefix, 8, &ip6_prefix, 32, &ip6_src,
173 128, 23, 0, 0, 0, 0);
176 assert(dst6.as_u64[0] == 0x20010db8a9c9da00);
177 assert(dst6.as_u64[1] == 0x000014a9c9da0000);
180 d =
get_domain (&ip4_prefix, 8, &ip6_prefix, 32, &ip6_src,
184 assert(dst6.as_u64[0] == 0x20010db8a8000000);
185 assert(dst6.as_u64[1] == 0x000014a800000000);
188 #define foreach_test_case \ 195 #define _(_test_name) \ 196 test_ ## _test_name ();
vl_api_wireguard_peer_flags_t flags
static_always_inline u64 map_get_pfx(map_domain_t *d, u32 addr, u16 port)
manual_print typedef ip4_prefix
static void test_map_t_destaddr(void)
manual_print typedef ip6_prefix
static void test_map_eabits(void)
void * malloc(size_t size)
static map_domain_t * get_domain(ip4_address_t *ip4_prefix, u8 ip4_prefix_len, ip6_address_t *ip6_prefix, u8 ip6_prefix_len, ip6_address_t *ip6_src, u8 ip6_src_len, u8 ea_bits_len, u8 psid_offset, u8 psid_length, u16 mtu, u8 flags)
static void run_tests(void)
#define foreach_test_case
static_always_inline u64 map_get_sfx(map_domain_t *d, u32 addr, u16 port)