MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ip6_mask_addr

Function ip6_mask_addr

dpdk/lib/lpm/rte_lpm6.c:117–134  ·  view source on GitHub ↗

* Takes an array of uint8_t (IPv6 address) and masks it using the depth. * It leaves untouched one bit per unit in the depth variable * and set the rest to 0. */

Source from the content-addressed store, hash-verified

115 * and set the rest to 0.
116 */
117static inline void
118ip6_mask_addr(uint8_t *ip, uint8_t depth)
119{
120 int16_t part_depth, mask;
121 int i;
122
123 part_depth = depth;
124
125 for (i = 0; i < RTE_LPM6_IPV6_ADDR_SIZE; i++) {
126 if (part_depth < BYTE_SIZE && part_depth >= 0) {
127 mask = (uint16_t)(~(UINT8_MAX >> part_depth));
128 ip[i] = (uint8_t)(ip[i] & mask);
129 } else if (part_depth < 0)
130 ip[i] = 0;
131
132 part_depth -= BYTE_SIZE;
133 }
134}
135
136/* copy ipv6 address */
137static inline void

Callers 4

rte_lpm6_addFunction · 0.70
rte_lpm6_is_rule_presentFunction · 0.70
rte_lpm6_deleteFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected