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

Function mask_ip6_prefix

dpdk/app/test/test_lpm6_data.h:1046–1065  ·  view source on GitHub ↗

let the most significant depth bits of ip_out[] same as ip_in[] * in the same bit position. ip_out[] and ip_in[] are IPv6 address. */

Source from the content-addressed store, hash-verified

1044 * in the same bit position. ip_out[] and ip_in[] are IPv6 address.
1045 */
1046static inline void mask_ip6_prefix(uint8_t *ip_out,
1047 const uint8_t *ip_in, uint8_t depth)
1048{
1049 int k;
1050 uint8_t mask_in, mask_out;
1051
1052 for (k = 0; k < 16; k++) {
1053 if (depth >= 8)
1054 ip_out[k] = ip_in[k];
1055 else if (depth > 0) {
1056 mask_in = (uint8_t)((unsigned int)(-1) << (8 - depth));
1057 mask_out = ~mask_in;
1058 ip_out[k] = (ip_in[k] & mask_in)
1059 | (ip_out[k] & mask_out);
1060 } else
1061 return;
1062
1063 depth -= 8;
1064 }
1065}
1066
1067/* check if IPv6 address ip[] match the rule with IPv6 address ip_rule[]
1068 * and depth. if matched, return 0, else return -1.

Callers 1

generate_large_ips_tableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected