CNDP  22.08.0
cne_rib6.h File Reference
#include <cne_common.h>
#include <stdint.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  cne_rib6_conf
 

Enumerations

enum  { CNE_RIB6_GET_NXT_ALL , CNE_RIB6_GET_NXT_COVER }
 

Functions

static void cne_rib6_copy_addr (uint8_t *dst, const uint8_t *src)
 
static int cne_rib6_is_equal (const uint8_t *ip1, const uint8_t *ip2)
 
static uint8_t get_msk_part (uint8_t depth, int byte)
 
CNDP_API struct cne_rib6_node * cne_rib6_lookup (struct cne_rib6 *rib, const uint8_t ip[CNE_RIB6_IPV6_ADDR_SIZE])
 
CNDP_API struct cne_rib6_node * cne_rib6_lookup_parent (struct cne_rib6_node *ent)
 
CNDP_API struct cne_rib6_node * cne_rib6_lookup_exact (struct cne_rib6 *rib, const uint8_t ip[CNE_RIB6_IPV6_ADDR_SIZE], uint8_t depth)
 
CNDP_API struct cne_rib6_node * cne_rib6_get_nxt (struct cne_rib6 *rib, const uint8_t ip[CNE_RIB6_IPV6_ADDR_SIZE], uint8_t depth, struct cne_rib6_node *last, int flag)
 
CNDP_API void cne_rib6_remove (struct cne_rib6 *rib, const uint8_t ip[CNE_RIB6_IPV6_ADDR_SIZE], uint8_t depth)
 
CNDP_API struct cne_rib6_node * cne_rib6_insert (struct cne_rib6 *rib, const uint8_t ip[CNE_RIB6_IPV6_ADDR_SIZE], uint8_t depth)
 
CNDP_API int cne_rib6_get_ip (const struct cne_rib6_node *node, uint8_t ip[CNE_RIB6_IPV6_ADDR_SIZE])
 
CNDP_API int cne_rib6_get_depth (const struct cne_rib6_node *node, uint8_t *depth)
 
CNDP_API void * cne_rib6_get_ext (struct cne_rib6_node *node)
 
CNDP_API int cne_rib6_get_nh (const struct cne_rib6_node *node, uint64_t *nh)
 
CNDP_API int cne_rib6_set_nh (struct cne_rib6_node *node, uint64_t nh)
 
CNDP_API struct cne_rib6 * cne_rib6_create (const char *name, const struct cne_rib6_conf *conf)
 
CNDP_API void cne_rib6_free (struct cne_rib6 *rib)
 

Detailed Description

CNE rib6 library.

Level compressed tree implementation for IPv6 Longest Prefix Match

Definition in file cne_rib6.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

cne_rib6_get_nxt() flags

Enumerator
CNE_RIB6_GET_NXT_ALL 

flag to get all subroutes in a RIB tree

CNE_RIB6_GET_NXT_COVER 

flag to get first matched subroutes in a RIB tree

Definition at line 30 of file cne_rib6.h.

Function Documentation

◆ cne_rib6_copy_addr()

static void cne_rib6_copy_addr ( uint8_t *  dst,
const uint8_t *  src 
)
inlinestatic

Copy IPv6 address from one location to another

Parameters
dstpointer to the place to copy
srcpointer from where to copy

Definition at line 60 of file cne_rib6.h.

◆ cne_rib6_is_equal()

static int cne_rib6_is_equal ( const uint8_t *  ip1,
const uint8_t *  ip2 
)
inlinestatic

Compare two IPv6 addresses

Parameters
ip1pointer to the first ipv6 address
ip2pointer to the second ipv6 address
Returns
1 if equal 0 otherwise

Definition at line 80 of file cne_rib6.h.

◆ get_msk_part()

static uint8_t get_msk_part ( uint8_t  depth,
int  byte 
)
inlinestatic

Get 8-bit part of 128-bit IPv6 mask

Parameters
depthipv6 prefix length
byteposition of a 8-bit chunk in the 128-bit mask
Returns
8-bit chunk of the 128-bit IPv6 mask

Definition at line 105 of file cne_rib6.h.

◆ cne_rib6_lookup()

CNDP_API struct cne_rib6_node* cne_rib6_lookup ( struct cne_rib6 *  rib,
const uint8_t  ip[CNE_RIB6_IPV6_ADDR_SIZE] 
)

Lookup an IP into the RIB structure

Parameters
ribRIB object handle
ipIP to be looked up in the RIB
Returns
pointer to struct cne_rib6_node on success NULL otherwise

◆ cne_rib6_lookup_parent()

CNDP_API struct cne_rib6_node* cne_rib6_lookup_parent ( struct cne_rib6_node *  ent)

Lookup less specific route into the RIB structure

Parameters
entPointer to struct cne_rib6_node that represents target route
Returns
pointer to struct cne_rib6_node that represents less specific route on success NULL otherwise

◆ cne_rib6_lookup_exact()

CNDP_API struct cne_rib6_node* cne_rib6_lookup_exact ( struct cne_rib6 *  rib,
const uint8_t  ip[CNE_RIB6_IPV6_ADDR_SIZE],
uint8_t  depth 
)

Provides exact mach lookup of the prefix into the RIB structure

Parameters
ribRIB object handle
ipnet to be looked up in the RIB
depthprefix length
Returns
pointer to struct cne_rib6_node on success NULL otherwise

◆ cne_rib6_get_nxt()

CNDP_API struct cne_rib6_node* cne_rib6_get_nxt ( struct cne_rib6 *  rib,
const uint8_t  ip[CNE_RIB6_IPV6_ADDR_SIZE],
uint8_t  depth,
struct cne_rib6_node *  last,
int  flag 
)

Retrieve next more specific prefix from the RIB that is covered by ip/depth supernet in an ascending order

Parameters
ribRIB object handle
ipnet address of supernet prefix that covers returned more specific prefixes
depthsupernet prefix length
lastpointer to the last returned prefix to get next prefix or NULL to get first more specific prefix
flag-CNE_RIB6_GET_NXT_ALL get all prefixes from subtrie -CNE_RIB6_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_rib6_remove()

CNDP_API void cne_rib6_remove ( struct cne_rib6 *  rib,
const uint8_t  ip[CNE_RIB6_IPV6_ADDR_SIZE],
uint8_t  depth 
)

Remove prefix from the RIB

Parameters
ribRIB object handle
ipnet to be removed from the RIB
depthprefix length

◆ cne_rib6_insert()

CNDP_API struct cne_rib6_node* cne_rib6_insert ( struct cne_rib6 *  rib,
const uint8_t  ip[CNE_RIB6_IPV6_ADDR_SIZE],
uint8_t  depth 
)

Insert prefix into the RIB

Parameters
ribRIB object handle
ipnet to be inserted to the RIB
depthprefix length
Returns
pointer to new cne_rib6_node on success NULL otherwise

◆ cne_rib6_get_ip()

CNDP_API int cne_rib6_get_ip ( const struct cne_rib6_node *  node,
uint8_t  ip[CNE_RIB6_IPV6_ADDR_SIZE] 
)

Get an ip from cne_rib6_node

Parameters
nodepointer to the rib6 node
ippointer to the ipv6 to save
Returns
0 on success -1 on failure with cne_errno indicating reason for failure.

◆ cne_rib6_get_depth()

CNDP_API int cne_rib6_get_depth ( const struct cne_rib6_node *  node,
uint8_t *  depth 
)

Get a depth from cne_rib6_node

Parameters
nodepointer to the rib6 node
depthpointer to the depth to save
Returns
0 on success -1 on failure with cne_errno indicating reason for failure.

◆ cne_rib6_get_ext()

CNDP_API void* cne_rib6_get_ext ( struct cne_rib6_node *  node)

Get ext field from the cne_rib6_node It is caller responsibility to make sure there are necessary space for the ext field inside rib6 node.

Parameters
nodepointer to the cne_rib6_node
Returns
pointer to the ext

◆ cne_rib6_get_nh()

CNDP_API int cne_rib6_get_nh ( const struct cne_rib6_node *  node,
uint64_t *  nh 
)

Get nexthop from the cne_rib6_node

Parameters
nodepointer to the rib6 node
nhpointer to the nexthop to save
Returns
0 on success -1 on failure, with cne_errno indicating reason for failure.

◆ cne_rib6_set_nh()

CNDP_API int cne_rib6_set_nh ( struct cne_rib6_node *  node,
uint64_t  nh 
)

Set nexthop into the cne_rib6_node

Parameters
nodepointer to the rib6 node
nhnexthop value to set to the rib6 node
Returns
0 on success -1 on failure, with cne_errno indicating reason for failure.

◆ cne_rib6_create()

CNDP_API struct cne_rib6* cne_rib6_create ( const char *  name,
const struct cne_rib6_conf conf 
)

Create RIB

Parameters
nameRIB name
confStructure containing the configuration
Returns
Pointer to RIB object on success NULL otherwise with cne_errno indicating reason for failure.

◆ cne_rib6_free()

CNDP_API void cne_rib6_free ( struct cne_rib6 *  rib)

Free an RIB object.

Parameters
ribRIB object handle
Returns
None