RTRlib
 All Data Structures Functions Typedefs Enumerations Enumerator Groups Pages
spkitable.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_SPKI_H
18 #define RTR_SPKI_H
19 
20 #include <stdint.h>
21 #include <sys/types.h>
22 #include "rtrlib/lib/ip.h"
23 #include "rtrlib/rtr/rtr.h"
24 
25 #define SKI_SIZE 20
26 #define SPKI_SIZE 91
27 
34 
36  SPKI_ERROR = -1,
37 
40 
43 };
44 
45 struct spki_table;
46 
54 struct spki_record {
55  uint8_t ski[SKI_SIZE];
56  uint32_t asn;
57  uint8_t spki[SPKI_SIZE];
58  const struct rtr_socket *socket;
59 };
60 
68 typedef void (*spki_update_fp)(struct spki_table *spki_table,
69  const struct spki_record record,
70  const bool added);
71 
77 void spki_table_init(struct spki_table *spki_table, spki_update_fp update_fp);
78 
83 void spki_table_free(struct spki_table *spki_table);
84 
93 int spki_table_add_entry(struct spki_table *spki_table,
94  struct spki_record *spki_record);
95 
106 int spki_table_get_all(struct spki_table *spki_table, uint32_t asn,
107  uint8_t *ski, struct spki_record **result,
108  unsigned int *result_size);
109 
119 int spki_table_search_by_ski(struct spki_table *spki_table, uint8_t *ski,
120  struct spki_record **result,
121  unsigned int *result_size);
122 
131 int spki_table_remove_entry(struct spki_table *spki_table,
132  struct spki_record *spki_record);
133 
141 int spki_table_src_remove(struct spki_table *spki_table,
142  const struct rtr_socket *socket);
143 
144 #endif
145 /* @} */
Definition: spkitable.h:36
void spki_table_init(struct spki_table *spki_table, spki_update_fp update_fp)
Initializes the spki_table struct.
Definition: spkitable.h:39
spki_rtvals
Possible return values for some spki_table_ functions.
Definition: spkitable.h:31
int spki_table_src_remove(struct spki_table *spki_table, const struct rtr_socket *socket)
Removes all entries in the spki_table that match the passed socket_id.
spki_record.
Definition: spkitable.h:54
void spki_table_free(struct spki_table *spki_table)
Frees the memory associcated with the spki_table.
int spki_table_remove_entry(struct spki_table *spki_table, struct spki_record *spki_record)
Removes spki_record from spki_table.
Definition: spkitable.h:42
Definition: spkitable.h:33
int spki_table_add_entry(struct spki_table *spki_table, struct spki_record *spki_record)
Adds a spki_record to a spki_table.
A RTR socket.
Definition: rtr.h:102
int spki_table_get_all(struct spki_table *spki_table, uint32_t asn, uint8_t *ski, struct spki_record **result, unsigned int *result_size)
Returns all spki_record whose ASN and SKI matches.
int spki_table_search_by_ski(struct spki_table *spki_table, uint8_t *ski, struct spki_record **result, unsigned int *result_size)
Returns all spki_record whose SKI number matches the given one.
void(* spki_update_fp)(struct spki_table *spki_table, const struct spki_record record, const bool added)
A function pointer that is called if an record was added to the spki_table or was removed from the sp...
Definition: spkitable.h:68