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

Function get_next_hop

dpdk/app/test/test_lpm6_data.h:1101–1122  ·  view source on GitHub ↗

check input IPv6 address ip[] with each one in rule[] and * output the *next_hop from the matched item in rule[] with * longest depth. The count of items in rule[ ] is rule_num. * if found that some item in rule[] is matched return 0, * else return -1; */

Source from the content-addressed store, hash-verified

1099 * else return -1;
1100 */
1101static int get_next_hop(uint8_t *ip, uint8_t *next_hop,
1102 const struct rules_tbl_entry *rule, int rule_num)
1103{
1104 int i;
1105 int result;
1106 uint8_t max_depth = 0;
1107
1108 for (i = 0; i < rule_num; i++) {
1109 if (rule[i].depth >= max_depth) {
1110 result = check_lpm6_rule(ip, rule[i].ip, rule[i].depth);
1111 if (result == 0) {
1112 *next_hop = rule[i].next_hop;
1113 max_depth = rule[i].depth;
1114 }
1115 }
1116 }
1117
1118 if (max_depth > 0)
1119 return 0;
1120 else
1121 return -1;
1122}
1123
1124/* the implementation of algorithm to generate large IPS table
1125 * at run time. if gen_expected_nex_hop is non-zero, the expected

Callers 1

generate_large_ips_tableFunction · 0.85

Calls 1

check_lpm6_ruleFunction · 0.85

Tested by

no test coverage detected