Loading...
Searching...
No Matches
pfx.h
/*
* This file is part of RTRlib.
*
* This file is subject to the terms and conditions of the MIT license.
* See the file LICENSE in the top level directory for more details.
*
* Website: http://rtrlib.realmv6.org/
*/
#ifndef RTR_PFX_H
#define RTR_PFX_H
#include "rtrlib/lib/ip.h"
#include "rtrlib/pfx/trie/trie-pfx.h"
#include <inttypes.h>
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
};
typedef void (*pfx_for_each_fp)(const struct pfx_record *pfx_record, void *data);
void pfx_table_init(struct pfx_table *pfx_table, pfx_update_fp update_fp);
void pfx_table_free(struct pfx_table *pfx_table);
int pfx_table_add(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
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);
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);
#endif
pfx_table_for_each_ipv6_record
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.
pfx_table_init
void pfx_table_init(struct pfx_table *pfx_table, pfx_update_fp update_fp)
Initializes the pfx_table struct.
pfx_table_validate
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.
pfx_table_remove
int pfx_table_remove(struct pfx_table *pfx_table, const struct pfx_record *pfx_record)
Removes a pfx_record from a pfx_table.
pfx_for_each_fp
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.
Definition pfx.h:65
pfxv_state
pfxv_state
Validation states returned from pfx_validate_origin.
Definition pfx.h:46
pfx_table_add
int pfx_table_add(struct pfx_table *pfx_table, const struct pfx_record *pfx_record)
Adds a pfx_record to a pfx_table.
pfx_table_src_remove
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.
pfx_table_for_each_ipv4_record
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.
pfx_rtvals
pfx_rtvals
Possible return values for pfx_ functions.
Definition pfx.h:29
pfx_table_validate_r
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.
pfx_table_free
void pfx_table_free(struct pfx_table *pfx_table)
Frees all memory associated with the pfx_table.
BGP_PFXV_STATE_VALID
@ BGP_PFXV_STATE_VALID
Definition pfx.h:48
BGP_PFXV_STATE_INVALID
@ 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...
Definition pfx.h:56
BGP_PFXV_STATE_NOT_FOUND
@ BGP_PFXV_STATE_NOT_FOUND
No certificate for the route exists.
Definition pfx.h:51
PFX_ERROR
@ PFX_ERROR
Definition pfx.h:34
PFX_SUCCESS
@ PFX_SUCCESS
Definition pfx.h:31
PFX_DUPLICATE_RECORD
@ PFX_DUPLICATE_RECORD
Definition pfx.h:37
PFX_RECORD_NOT_FOUND
@ PFX_RECORD_NOT_FOUND
Definition pfx.h:40
pfx_update_fp
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...
Definition trie-pfx.h:56
lrtr_ip_addr
The lrtr_ip_addr struct stores a IPv4 or IPv6 address in host byte order.
Definition ip.h:38
pfx_record
pfx_record.
Definition trie-pfx.h:42
pfx_table
pfx_table.
Definition trie-pfx.h:65
rtr_socket
A RTR socket.
Definition rtr.h:116