RTRlib
 All Data Structures Functions Typedefs Enumerations Enumerator Groups Pages
Modules | Data Structures | Typedefs | Enumerations | Functions
Prefix validation table

Modules

 Longest prefix first search tree
 

Data Structures

struct  pfx_record
 

Typedefs

typedef void(* pfx_for_each_fp )(const struct pfx_record *pfx_record, void *data)
 
typedef void(* pfx_update_fp )(struct pfx_table *pfx_table, const struct pfx_record record, const bool added)
 

Enumerations

enum  pfx_rtvals { PFX_SUCCESS = 0, PFX_ERROR = -1, PFX_DUPLICATE_RECORD = -2, PFX_RECORD_NOT_FOUND = -3 }
 
enum  pfxv_state { BGP_PFXV_STATE_VALID, BGP_PFXV_STATE_NOT_FOUND, BGP_PFXV_STATE_INVALID }
 

Functions

int pfx_table_add (struct pfx_table *pfx_table, const struct pfx_record *pfx_record)
 
void pfx_table_for_each_ipv4_record (struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data)
 
void pfx_table_for_each_ipv6_record (struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data)
 
void pfx_table_free (struct pfx_table *pfx_table)
 
void pfx_table_init (struct pfx_table *pfx_table, pfx_update_fp update_fp)
 
int pfx_table_remove (struct pfx_table *pfx_table, const struct pfx_record *pfx_record)
 
int pfx_table_src_remove (struct pfx_table *pfx_table, const struct rtr_socket *socket)
 
int pfx_table_validate (struct pfx_table *pfx_table, const uint32_t asn, const struct lrtr_ip_addr *prefix, const uint8_t mask_len, enum pfxv_state *result)
 
int pfx_table_validate_r (struct pfx_table *pfx_table, struct pfx_record **reason, unsigned int *reason_len, const uint32_t asn, const struct lrtr_ip_addr *prefix, const uint8_t mask_len, enum pfxv_state *result)
 

Detailed Description

Typedef Documentation

typedef void(* pfx_for_each_fp)(const struct pfx_record *pfx_record, void *data)

A function pointer that is called for each record in the pfx_table.

Parameters
pfx_record
dataforwarded data which the user has passed to pfx_table_for_each_ipv4_record() or pfx_table_for_each_ipv6_record()
typedef void(* pfx_update_fp)(struct pfx_table *pfx_table, const struct pfx_record record, const bool added)

A function pointer that is called if an record was added to the pfx_table or was removed from the pfx_table.

Parameters
pfx_tablewhich was updated.
recordpfx_record that was modified.
addedTrue if the record was added, false if the record was removed.

Enumeration Type Documentation

enum pfx_rtvals

Possible return values for pfx_ functions.

Enumerator
PFX_SUCCESS 

Operation was successfull.

PFX_ERROR 

Error occured.

PFX_DUPLICATE_RECORD 

The supplied pfx_record already exists in the pfx_table.

PFX_RECORD_NOT_FOUND 

pfx_record wasn't found in the pfx_table.

enum pfxv_state

Validation states returned from pfx_validate_origin.

Enumerator
BGP_PFXV_STATE_VALID 

A valid certificate for the pfx_record exists.

BGP_PFXV_STATE_NOT_FOUND 

No certificate for the route exists.

BGP_PFXV_STATE_INVALID 

One or more records that match the input prefix exists in the pfx_table but the prefix max_len or ASN does'nt match.

Function Documentation

int pfx_table_add ( struct pfx_table pfx_table,
const struct pfx_record pfx_record 
)

Adds a pfx_record to a pfx_table.

Parameters
[in]pfx_tablepfx_table to use.
[in]pfx_recordpfx_record that will be added.
Returns
PFX_SUCCESS On success.
PFX_ERROR On error.
PFX_DUPLICATE_RECORD If the pfx_record already exists.

References PFX_DUPLICATE_RECORD, PFX_ERROR, and PFX_SUCCESS.

void pfx_table_for_each_ipv4_record ( struct pfx_table pfx_table,
pfx_for_each_fp  fp,
void *  data 
)

Iterates over all IPv4 records in the pfx_table.

For every pfx_record the function fp is called. The pfx_record and the data pointer is passed to the fp.

Parameters
[in]pfx_table
[in]fpA pointer to a callback function with the signature pfx_for_each_fp.
[in]dataThis parameter is forwarded to the callback function.
void pfx_table_for_each_ipv6_record ( struct pfx_table pfx_table,
pfx_for_each_fp  fp,
void *  data 
)

Iterates over all IPv6 records in the pfx_table.

For every pfx_record the function fp is called. The pfx_record and the data pointer is passed to the fp.

Parameters
[in]pfx_table
[in]fpA pointer to a callback function with the signature pfx_for_each_fp.
[in]dataThis parameter is forwarded to the callback function.
void pfx_table_free ( struct pfx_table pfx_table)

Frees all memory associcated with the pfx_table.

Parameters
[in]pfx_tablepfx_table that will be freed.

Referenced by rtr_mgr_free(), and rtr_mgr_init().

void pfx_table_init ( struct pfx_table pfx_table,
pfx_update_fp  update_fp 
)

Initializes the pfx_table struct.

Parameters
[in]pfx_tablepfx_table that will be initialized.
[in]update_fpAfunction pointers that will be called if a record was added or removed.

Referenced by rtr_mgr_init().

int pfx_table_remove ( struct pfx_table pfx_table,
const struct pfx_record pfx_record 
)

Removes a pfx_record from a pfx_table.

Parameters
[in]pfx_tablepfx_table to use.
[in]pfx_recordRecord that will be removed.
Returns
PFX_SUCCESS On success.
PFX_ERROR On error.
PFX_RECORD_NOT_FOUND If pfx_records could'nt be found.

References PFX_ERROR, PFX_RECORD_NOT_FOUND, and PFX_SUCCESS.

int pfx_table_src_remove ( struct pfx_table pfx_table,
const struct rtr_socket socket 
)

Removes all entries in the pfx_table that match the passed socket_id value from a pfx_table.

Parameters
[in]pfx_tablepfx_table to use.
[in]socketorigin socket of the record
Returns
PFX_SUCCESS On success.
PFX_ERROR On error.

References PFX_ERROR, and PFX_SUCCESS.

int pfx_table_validate ( struct pfx_table pfx_table,
const uint32_t  asn,
const struct lrtr_ip_addr prefix,
const uint8_t  mask_len,
enum pfxv_state result 
)

Validates the origin of a BGP-Route.

Parameters
[in]pfx_tablepfx_table to use.
[in]asnAutonomous system number of the Origin-AS of the route.
[in]prefixAnnouncend network Prefix.
[in]mask_lenLength of the network mask of the announced prefix.
[out]resultResult of the validation.
Returns
PFX_SUCCESS On success.
PFX_ERROR On error.

References pfx_table_validate_r().

Referenced by rtr_mgr_validate().

int pfx_table_validate_r ( struct pfx_table pfx_table,
struct pfx_record **  reason,
unsigned int *  reason_len,
const uint32_t  asn,
const struct lrtr_ip_addr prefix,
const uint8_t  mask_len,
enum pfxv_state result 
)

Validates the origin of a BGP-Route and returns a list of pfx_record that decided the result.

Parameters
[in]pfx_tablepfx_table to use.
[out]reasonPointer to a memory area that will be used as array of pfx_records. The memory area will be overwritten. Reason must point to NULL or an allocated memory area.
[out]reason_lenSize of the array reason.
[in]asnAutonomous system number of the Origin-AS of the route.
[in]prefixAnnouncend network Prefix
[in]mask_lenLength of the network mask of the announced prefix
[out]resultResult of the validation.
Returns
PFX_SUCCESS On success.
PFX_ERROR On error.

References BGP_PFXV_STATE_INVALID, BGP_PFXV_STATE_NOT_FOUND, BGP_PFXV_STATE_VALID, PFX_ERROR, and PFX_SUCCESS.

Referenced by pfx_table_validate().