* Look for a rule in the high-level rules table */
| 847 | * Look for a rule in the high-level rules table |
| 848 | */ |
| 849 | int |
| 850 | rte_lpm_is_rule_present(struct rte_lpm *lpm, uint32_t ip, uint8_t depth, |
| 851 | uint32_t *next_hop) |
| 852 | { |
| 853 | struct __rte_lpm *i_lpm; |
| 854 | uint32_t ip_masked; |
| 855 | int32_t rule_index; |
| 856 | |
| 857 | /* Check user arguments. */ |
| 858 | if ((lpm == NULL) || |
| 859 | (next_hop == NULL) || |
| 860 | (depth < 1) || (depth > RTE_LPM_MAX_DEPTH)) |
| 861 | return -EINVAL; |
| 862 | |
| 863 | /* Look for the rule using rule_find. */ |
| 864 | i_lpm = container_of(lpm, struct __rte_lpm, lpm); |
| 865 | ip_masked = ip & depth_to_mask(depth); |
| 866 | rule_index = rule_find(i_lpm, ip_masked, depth); |
| 867 | |
| 868 | if (rule_index >= 0) { |
| 869 | *next_hop = i_lpm->rules_tbl[rule_index].next_hop; |
| 870 | return 1; |
| 871 | } |
| 872 | |
| 873 | /* If rule is not found return 0. */ |
| 874 | return 0; |
| 875 | } |
| 876 | |
| 877 | static int32_t |
| 878 | find_previous_rule(struct __rte_lpm *i_lpm, uint32_t ip, uint8_t depth, |
no test coverage detected