RTRlib
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
pfx.h
1 /*
2  * This file is part of RTRlib.
3  *
4  * This file is subject to the terms and conditions of the MIT license.
5  * See the file LICENSE in the top level directory for more details.
6  *
7  * Website: http://rtrlib.realmv6.org/
8  */
9 
17 #ifndef RTR_PFX_H
18 #define RTR_PFX_H
19 #include <stdint.h>
20 #include <sys/types.h>
21 #include "rtrlib/lib/ip.h"
22 #include "rtrlib/rtr/rtr.h"
23 
27 enum pfx_rtvals {
30 
32  PFX_ERROR = -1,
33 
36 
39 };
40 
41 struct pfx_table;
42 
46 enum pfxv_state {
49 
52 
55 };
56 
57 
66 struct pfx_record {
67  uint32_t asn;
68  struct lrtr_ip_addr prefix;
69  uint8_t min_len;
70  uint8_t max_len;
71  const struct rtr_socket *socket;
72 };
73 
80 typedef void (*pfx_update_fp)(struct pfx_table *pfx_table, const struct pfx_record record, const bool added);
81 
88 typedef void (*pfx_for_each_fp)(const struct pfx_record *pfx_record, void *data);
89 
95 void pfx_table_init(struct pfx_table *pfx_table, pfx_update_fp update_fp);
96 
101 void pfx_table_free(struct pfx_table *pfx_table);
102 
111 int pfx_table_add(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
112 
121 int pfx_table_remove(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
122 
130 int pfx_table_src_remove(struct pfx_table *pfx_table, const struct rtr_socket *socket);
131 
142 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);
143 
156 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);
157 
166 void pfx_table_for_each_ipv4_record(struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data);
167 
176 void pfx_table_for_each_ipv6_record(struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data);
177 
178 #endif
179 /* @} */
int pfx_table_remove(struct pfx_table *pfx_table, const struct pfx_record *pfx_record)
Removes a pfx_record from a pfx_table.
Definition: trie-pfx.c:235
One or more records that match the input prefix exists in the pfx_table but the prefix max_len or ASN...
Definition: pfx.h:54
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.
Definition: trie-pfx.c:484
Definition: pfx.h:48
pfx_rtvals
Possible return values for pfx_ functions.
Definition: pfx.h:27
Definition: pfx.h:32
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:88
Definition: pfx.h:29
void pfx_table_init(struct pfx_table *pfx_table, pfx_update_fp update_fp)
Initializes the pfx_table struct.
Definition: trie-pfx.c:45
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: pfx.h:80
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.
Definition: trie-pfx.c:391
Definition: pfx.h:38
Definition: pfx.h:35
void pfx_table_free(struct pfx_table *pfx_table)
Frees all memory associcated with the pfx_table.
Definition: trie-pfx.c:53
int pfx_table_add(struct pfx_table *pfx_table, const struct pfx_record *pfx_record)
Adds a pfx_record to a pfx_table.
Definition: trie-pfx.c:185
pfx_table.
Definition: trie-pfx.h:35
pfxv_state
Validation states returned from pfx_validate_origin.
Definition: pfx.h:46
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...
Definition: trie-pfx.c:318
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...
Definition: trie-pfx.c:396
The lrtr_ip_addr struct stores a IPv4 or IPv6 address in host byte order.
Definition: ip.h:32
A RTR socket.
Definition: rtr.h:106
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.
Definition: trie-pfx.c:496
pfx_record.
Definition: pfx.h:66
No certificate for the route exists.
Definition: pfx.h:51