RTRlib
 All Data Structures Functions Typedefs Enumerations Enumerator Groups Pages
spkitable.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  * written by Andreas Reuter and Nils Bars, in cooperation with:
18  * INET group, Hamburg University of Applied Sciences,
19  * CST group, Freie Universitaet Berlin
20  * Website: http://rpki.realmv6.org/
21  */
22 
30 #ifndef RTR_SPKI_H
31 #define RTR_SPKI_H
32 
33 #include <stdint.h>
34 #include <sys/types.h>
35 #include "rtrlib/lib/ip.h"
36 #include "rtrlib/rtr/rtr.h"
37 
38 #define SKI_SIZE 20
39 #define SPKI_SIZE 91
40 
47 
49  SPKI_ERROR = -1,
50 
53 
56 };
57 
58 struct spki_table;
59 
67 struct spki_record {
68  uint8_t ski[SKI_SIZE];
69  uint32_t asn;
70  uint8_t spki[SPKI_SIZE];
71  const struct rtr_socket *socket;
72 };
73 
81 typedef void (*spki_update_fp)(struct spki_table *spki_table,
82  const struct spki_record record,
83  const bool added);
84 
90 void spki_table_init(struct spki_table *spki_table, spki_update_fp update_fp);
91 
96 void spki_table_free(struct spki_table *spki_table);
97 
106 int spki_table_add_entry(struct spki_table *spki_table,
107  struct spki_record *spki_record);
108 
119 int spki_table_get_all(struct spki_table *spki_table, uint32_t asn,
120  uint8_t *ski, struct spki_record **result,
121  unsigned int *result_size);
122 
132 int spki_table_search_by_ski(struct spki_table *spki_table, uint8_t *ski,
133  struct spki_record **result,
134  unsigned int *result_size);
135 
144 int spki_table_remove_entry(struct spki_table *spki_table,
145  struct spki_record *spki_record);
146 
154 int spki_table_src_remove(struct spki_table *spki_table,
155  const struct rtr_socket *socket);
156 
157 #endif
158 /* @} */
Definition: spkitable.h:49
void spki_table_init(struct spki_table *spki_table, spki_update_fp update_fp)
Initializes the spki_table struct.
Definition: spkitable.h:52
spki_rtvals
Possible return values for some spki_table_ functions.
Definition: spkitable.h:44
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:67
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:55
Definition: spkitable.h:46
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:113
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:81