Lines Matching defs:bits
13 static void swap_endian(u8 *dst, const u8 *src, u8 bits)
15 if (bits == 32) {
17 } else if (bits == 128) {
24 u8 cidr, u8 bits)
29 node->bit_at_a ^= (bits / 8U - 1U) % 8U;
32 node->bitlen = bits;
33 memcpy(node->bits, src, bits / 8U);
88 u8 bits)
90 if (bits == 32)
91 return 32U - fls(*(const u32 *)node->bits ^ *(const u32 *)key);
92 else if (bits == 128)
94 *(const u64 *)&node->bits[0] ^ *(const u64 *)&key[0],
95 *(const u64 *)&node->bits[8] ^ *(const u64 *)&key[8]);
100 u8 bits)
103 * bits properly, by precomputing a mask bswap(~0 << (32 - cidr)), and
108 return common_bits(node, key, bits) >= node->cidr;
111 static struct allowedips_node *find_node(struct allowedips_node *trie, u8 bits,
116 while (node && prefix_matches(node, key, bits)) {
119 if (node->cidr == bits)
127 static struct wg_peer *lookup(struct allowedips_node __rcu *root, u8 bits,
135 swap_endian(ip, be_ip, bits);
139 node = find_node(rcu_dereference_bh(root), bits, ip);
150 u8 cidr, u8 bits, struct allowedips_node **rnode,
157 while (node && node->cidr <= cidr && prefix_matches(node, key, bits)) {
177 u8 bit = choose(parent, node->bits);
181 static int add(struct allowedips_node __rcu **trie, u8 bits, const u8 *key,
186 if (unlikely(cidr > bits || !peer))
195 copy_and_assign_cidr(node, key, cidr, bits);
199 if (node_placement(*trie, key, cidr, bits, &node, lock)) {
210 copy_and_assign_cidr(newnode, key, cidr, bits);
222 cidr = min(cidr, common_bits(down, key, bits));
241 copy_and_assign_cidr(node, newnode->bits, cidr, bits);
346 swap_endian(ip, node->bits, node->bitlen);