#include <stdlib.h>
#include <stdint.h>
#include <cne_common.h>
Go to the source code of this file.
|
static uint32_t | cne_rib_depth_to_mask (uint8_t depth) |
|
CNDP_API struct cne_rib_node * | cne_rib_lookup (struct cne_rib *rib, uint32_t ip) |
|
CNDP_API struct cne_rib_node * | cne_rib_lookup_parent (struct cne_rib_node *ent) |
|
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_get_nxt (struct cne_rib *rib, uint32_t ip, uint8_t depth, struct cne_rib_node *last, int flag) |
|
CNDP_API void | cne_rib_remove (struct cne_rib *rib, uint32_t ip, 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_ip (const struct cne_rib_node *node, uint32_t *ip) |
|
CNDP_API int | cne_rib_get_depth (const struct cne_rib_node *node, uint8_t *depth) |
|
CNDP_API void * | cne_rib_get_ext (struct cne_rib_node *node) |
|
CNDP_API int | cne_rib_get_nh (const struct cne_rib_node *node, uint64_t *nh) |
|
CNDP_API int | cne_rib_set_nh (struct cne_rib_node *node, uint64_t nh) |
|
CNDP_API struct cne_rib * | cne_rib_create (const char *name, const struct cne_rib_conf *conf) |
|
CNDP_API void | cne_rib_free (struct cne_rib *rib) |
|
CNE RIB library.
Level compressed tree implementation for IPv4 Longest Prefix Match
Definition in file cne_rib.h.
◆ anonymous enum
cne_rib_get_nxt() flags
Enumerator |
---|
CNE_RIB_GET_NXT_ALL | flag to get all subroutes in a RIB tree
|
CNE_RIB_GET_NXT_COVER | flag to get first matched subroutes in a RIB tree
|
Definition at line 29 of file cne_rib.h.
◆ cne_rib_depth_to_mask()
static uint32_t cne_rib_depth_to_mask |
( |
uint8_t |
depth | ) |
|
|
inlinestatic |
Get an IPv4 mask from prefix length It is caller responsibility to make sure depth is not bigger than 32
- Parameters
-
- Returns
- IPv4 mask
Definition at line 60 of file cne_rib.h.
◆ cne_rib_lookup()
CNDP_API struct cne_rib_node* cne_rib_lookup |
( |
struct cne_rib * |
rib, |
|
|
uint32_t |
ip |
|
) |
| |
Lookup an IP into the RIB structure
- Parameters
-
rib | RIB object handle |
ip | IP to be looked up in the RIB |
- Returns
- pointer to struct cne_rib_node on success NULL otherwise
◆ cne_rib_lookup_parent()
CNDP_API struct cne_rib_node* cne_rib_lookup_parent |
( |
struct cne_rib_node * |
ent | ) |
|
Lookup less specific route into the RIB structure
- Parameters
-
ent | Pointer to struct cne_rib_node that represents target route |
- Returns
- pointer to struct cne_rib_node that represents less specific route on success NULL otherwise
◆ cne_rib_lookup_exact()
CNDP_API struct cne_rib_node* cne_rib_lookup_exact |
( |
struct cne_rib * |
rib, |
|
|
uint32_t |
ip, |
|
|
uint8_t |
depth |
|
) |
| |
Lookup prefix into the RIB structure
- Parameters
-
rib | RIB object handle |
ip | net to be looked up in the RIB |
depth | prefix length |
- Returns
- pointer to struct cne_rib_node on success NULL otherwise
◆ cne_rib_get_nxt()
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 |
|
) |
| |
Retrieve next more specific prefix from the RIB that is covered by ip/depth supernet in an ascending order
- Parameters
-
rib | RIB object handle |
ip | net address of supernet prefix that covers returned more specific prefixes |
depth | supernet prefix length |
last | pointer to the last returned prefix to get next prefix or NULL to get first more specific prefix |
flag | -CNE_RIB_GET_NXT_ALL get all prefixes from subtrie -CNE_RIB_GET_NXT_COVER get only first more specific prefix even if it have more specifics |
- Returns
- pointer to the next more specific prefix NULL if there is no prefixes left
◆ cne_rib_remove()
CNDP_API void cne_rib_remove |
( |
struct cne_rib * |
rib, |
|
|
uint32_t |
ip, |
|
|
uint8_t |
depth |
|
) |
| |
Remove prefix from the RIB
- Parameters
-
rib | RIB object handle |
ip | net to be removed from the RIB |
depth | prefix length |
◆ cne_rib_insert()
CNDP_API struct cne_rib_node* cne_rib_insert |
( |
struct cne_rib * |
rib, |
|
|
uint32_t |
ip, |
|
|
uint8_t |
depth |
|
) |
| |
Insert prefix into the RIB
- Parameters
-
rib | RIB object handle |
ip | net to be inserted to the RIB |
depth | prefix length |
- Returns
- pointer to new cne_rib_node on success NULL otherwise
◆ cne_rib_get_ip()
CNDP_API int cne_rib_get_ip |
( |
const struct cne_rib_node * |
node, |
|
|
uint32_t * |
ip |
|
) |
| |
Get an ip from cne_rib_node
- Parameters
-
node | pointer to the rib node |
ip | pointer to the ip to save |
- Returns
- 0 on success. -1 on failure with cne_errno indicating reason for failure.
◆ cne_rib_get_depth()
CNDP_API int cne_rib_get_depth |
( |
const struct cne_rib_node * |
node, |
|
|
uint8_t * |
depth |
|
) |
| |
Get a depth from cne_rib_node
- Parameters
-
node | pointer to the rib node |
depth | pointer to the depth to save |
- Returns
- 0 on success. -1 on failure with cne_errno indicating reason for failure.
◆ cne_rib_get_ext()
CNDP_API void* cne_rib_get_ext |
( |
struct cne_rib_node * |
node | ) |
|
Get ext field from the rib node It is caller responsibility to make sure there are necessary space for the ext field inside rib node.
- Parameters
-
node | pointer to the rib node |
- Returns
- pointer to the ext
◆ cne_rib_get_nh()
CNDP_API int cne_rib_get_nh |
( |
const struct cne_rib_node * |
node, |
|
|
uint64_t * |
nh |
|
) |
| |
Get nexthop from the rib node
- Parameters
-
node | pointer to the rib node |
nh | pointer to the nexthop to save |
- Returns
- 0 on success. -1 on failure with cne_errno indicating reason for failure.
◆ cne_rib_set_nh()
CNDP_API int cne_rib_set_nh |
( |
struct cne_rib_node * |
node, |
|
|
uint64_t |
nh |
|
) |
| |
Set nexthop into the rib node
- Parameters
-
node | pointer to the rib node |
nh | nexthop value to set to the rib node |
- Returns
- 0 on success. -1 on failure with cne_errno indicating reason for failure.
◆ cne_rib_create()
CNDP_API struct cne_rib* cne_rib_create |
( |
const char * |
name, |
|
|
const struct cne_rib_conf * |
conf |
|
) |
| |
Create RIB
- Parameters
-
name | RIB name |
conf | Structure containing the configuration |
- Returns
- Handle to RIB object on success NULL otherwise with cne_errno indicating reason for failure.
◆ cne_rib_free()
CNDP_API void cne_rib_free |
( |
struct cne_rib * |
rib | ) |
|
Free an RIB object.
- Parameters
-
- Returns
- None