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

Function check_lpm6_rule

dpdk/app/test/test_lpm6_data.h:1070–1093  ·  view source on GitHub ↗

check if IPv6 address ip[] match the rule with IPv6 address ip_rule[] * and depth. if matched, return 0, else return -1. */

Source from the content-addressed store, hash-verified

1068 * and depth. if matched, return 0, else return -1.
1069 */
1070static inline int check_lpm6_rule(uint8_t *ip,
1071 const uint8_t *ip_rule, uint8_t depth)
1072{
1073 int k;
1074 uint8_t mask;
1075
1076 for (k = 0; k < 16; k++) {
1077 if (depth >= 8) {
1078 if (ip[k] != ip_rule[k])
1079 return -1;
1080 } else if (depth > 0) {
1081 mask = (uint8_t)((unsigned int)(-1) << (8 - depth));
1082 if ((ip[k] & mask) == (ip_rule[k] & mask))
1083 return 0;
1084 else
1085 return -1;
1086 } else
1087 return 0;
1088
1089 depth -= 8;
1090 }
1091
1092 return 0;
1093}
1094
1095/* check input IPv6 address ip[] with each one in rule[] and
1096 * output the *next_hop from the matched item in rule[] with

Callers 1

get_next_hopFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected