RTRlib
 All Data Structures Functions Typedefs Enumerations Enumerator Groups Pages
pfx.h
1 /*
2  * This file is part of RTRlib.
3  *
4  * RTRlib is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or (at your
7  * option) any later version.
8  *
9  * RTRlib is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12  * License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with RTRlib; see the file COPYING.LESSER.
16  *
17  * INET group, Hamburg University of Applied Sciences,
18  * CST group, Freie Universitaet Berlin
19  * Website: http://rpki.realmv6.org/
20  */
21 
29 #ifndef RTR_PFX_H
30 #define RTR_PFX_H
31 #include <stdint.h>
32 #include <sys/types.h>
33 #include "rtrlib/lib/ip.h"
34 #include "rtrlib/rtr/rtr.h"
35 
39 enum pfx_rtvals {
42 
44  PFX_ERROR = -1,
45 
48 
51 };
52 
53 struct pfx_table;
54 
58 enum pfxv_state {
61 
64 
67 };
68 
69 
78 struct pfx_record {
79  uint32_t asn;
80  struct ip_addr prefix;
81  uint8_t min_len;
82  uint8_t max_len;
83  const struct rtr_socket *socket;
84 };
85 
92 typedef void (*pfx_update_fp)(struct pfx_table *pfx_table, const struct pfx_record record, const bool added);
93 
100 typedef void (*pfx_for_each_fp)(const struct pfx_record *pfx_record, void *data);
101 
107 void pfx_table_init(struct pfx_table *pfx_table, pfx_update_fp update_fp);
108 
113 void pfx_table_free(struct pfx_table *pfx_table);
114 
123 int pfx_table_add(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
124 
133 int pfx_table_remove(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
134 
142 int pfx_table_src_remove(struct pfx_table *pfx_table, const struct rtr_socket *socket);
143 
154 int pfx_table_validate(struct pfx_table *pfx_table, const uint32_t asn, const struct ip_addr *prefix, const uint8_t mask_len, enum pfxv_state *result);
155 
168 int pfx_table_validate_r(struct pfx_table *pfx_table, struct pfx_record **reason, unsigned int *reason_len, const uint32_t asn, const struct ip_addr *prefix, const uint8_t mask_len, enum pfxv_state *result);
169 
178 void pfx_table_for_each_ipv4_record(struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data);
179 
188 void pfx_table_for_each_ipv6_record(struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data);
189 
190 #endif
191 /* @} */
int pfx_table_remove(struct pfx_table *pfx_table, const struct pfx_record *pfx_record)
Removes a pfx_record from a pfx_table.
Definition: lpfst-pfx.c:212
One or more records that match the input prefix exists in the pfx_table but the prefix max_len or ASN...
Definition: pfx.h:66
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: lpfst-pfx.c:459
Definition: pfx.h:60
The ip_addr struct stores a IPv4 or IPv6 address in host byte order.
Definition: ip.h:44
pfx_rtvals
Possible return values for pfx_ functions.
Definition: pfx.h:39
Definition: pfx.h:44
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:100
Definition: pfx.h:41
void pfx_table_init(struct pfx_table *pfx_table, pfx_update_fp update_fp)
Initializes the pfx_table struct.
Definition: lpfst-pfx.c:57
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:92
Definition: pfx.h:50
Definition: pfx.h:47
void pfx_table_free(struct pfx_table *pfx_table)
Frees all memory associcated with the pfx_table.
Definition: lpfst-pfx.c:65
int pfx_table_add(struct pfx_table *pfx_table, const struct pfx_record *pfx_record)
Adds a pfx_record to a pfx_table.
Definition: lpfst-pfx.c:163
pfx_table.
Definition: lpfst-pfx.h:51
pfxv_state
Validation states returned from pfx_validate_origin.
Definition: pfx.h:58
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: lpfst-pfx.c:373
A RTR socket.
Definition: rtr.h:113
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: lpfst-pfx.c:471
pfx_record.
Definition: pfx.h:78
No certificate for the route exists.
Definition: pfx.h:63
int pfx_table_validate_r(struct pfx_table *pfx_table, struct pfx_record **reason, unsigned int *reason_len, const uint32_t asn, const struct 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: lpfst-pfx.c:295
int pfx_table_validate(struct pfx_table *pfx_table, const uint32_t asn, const struct ip_addr *prefix, const uint8_t mask_len, enum pfxv_state *result)
Validates the origin of a BGP-Route.
Definition: lpfst-pfx.c:368