CNDP  22.08.0
cne_rib.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
3  * Copyright (c) 2019-2022 Intel Corporation
4  */
5 
6 #ifndef _CNE_RIB_H_
7 #define _CNE_RIB_H_
8 
17 #include <stdlib.h>
18 #include <stdint.h>
19 
20 #include <cne_common.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
29 enum {
34 };
35 
36 struct cne_rib;
37 struct cne_rib_node;
38 
40 struct cne_rib_conf {
46  size_t ext_sz; /* size of cne_rib_node's pool */
47  int max_nodes;
48 };
49 
59 static inline uint32_t
60 cne_rib_depth_to_mask(uint8_t depth)
61 {
62  return (uint32_t)(UINT64_MAX << (32 - depth));
63 }
64 
76 CNDP_API struct cne_rib_node *cne_rib_lookup(struct cne_rib *rib, uint32_t ip);
77 
88 CNDP_API struct cne_rib_node *cne_rib_lookup_parent(struct cne_rib_node *ent);
89 
103 CNDP_API struct cne_rib_node *cne_rib_lookup_exact(struct cne_rib *rib, uint32_t ip, uint8_t depth);
104 
128 CNDP_API struct cne_rib_node *cne_rib_get_nxt(struct cne_rib *rib, uint32_t ip, uint8_t depth,
129  struct cne_rib_node *last, int flag);
130 
141 CNDP_API void cne_rib_remove(struct cne_rib *rib, uint32_t ip, uint8_t depth);
142 
156 CNDP_API struct cne_rib_node *cne_rib_insert(struct cne_rib *rib, uint32_t ip, uint8_t depth);
157 
169 CNDP_API int cne_rib_get_ip(const struct cne_rib_node *node, uint32_t *ip);
170 
182 CNDP_API int cne_rib_get_depth(const struct cne_rib_node *node, uint8_t *depth);
183 
194 CNDP_API void *cne_rib_get_ext(struct cne_rib_node *node);
195 
207 CNDP_API int cne_rib_get_nh(const struct cne_rib_node *node, uint64_t *nh);
208 
220 CNDP_API int cne_rib_set_nh(struct cne_rib_node *node, uint64_t nh);
221 
233 CNDP_API struct cne_rib *cne_rib_create(const char *name, const struct cne_rib_conf *conf);
234 
243 CNDP_API void cne_rib_free(struct cne_rib *rib);
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 
249 #endif /* _CNE_RIB_H_ */
CNDP_API struct cne_rib_node * cne_rib_lookup_parent(struct cne_rib_node *ent)
@ CNE_RIB_GET_NXT_ALL
Definition: cne_rib.h:31
@ CNE_RIB_GET_NXT_COVER
Definition: cne_rib.h:33
CNDP_API int cne_rib_get_depth(const struct cne_rib_node *node, uint8_t *depth)
CNDP_API struct cne_rib_node * cne_rib_insert(struct cne_rib *rib, uint32_t ip, uint8_t depth)
CNDP_API int cne_rib_get_nh(const struct cne_rib_node *node, uint64_t *nh)
CNDP_API int cne_rib_get_ip(const struct cne_rib_node *node, uint32_t *ip)
CNDP_API void * cne_rib_get_ext(struct cne_rib_node *node)
CNDP_API struct cne_rib_node * cne_rib_get_nxt(struct cne_rib *rib, uint32_t ip, uint8_t depth, struct cne_rib_node *last, int flag)
CNDP_API struct cne_rib * cne_rib_create(const char *name, const struct cne_rib_conf *conf)
CNDP_API int cne_rib_set_nh(struct cne_rib_node *node, uint64_t nh)
static uint32_t cne_rib_depth_to_mask(uint8_t depth)
Definition: cne_rib.h:60
CNDP_API void cne_rib_free(struct cne_rib *rib)
CNDP_API void cne_rib_remove(struct cne_rib *rib, uint32_t ip, uint8_t depth)
CNDP_API struct cne_rib_node * cne_rib_lookup_exact(struct cne_rib *rib, uint32_t ip, uint8_t depth)
CNDP_API struct cne_rib_node * cne_rib_lookup(struct cne_rib *rib, uint32_t ip)
size_t ext_sz
Definition: cne_rib.h:46