-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrtrlib.cdef
763 lines (669 loc) · 24.9 KB
/
rtrlib.cdef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
typedef int... time_t;
/*
* 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/
*/
/**
* @defgroup mod_transport_h Transport sockets
* @brief The RTR transport sockets implement the communication channel
* (e.g., SSH, TCP, TCP-AO) between an RTR server and client.
* @details Before using the transport socket, a tr_socket must be
* initialized based on a protocol-dependent init function (e.g.,
* tr_tcp_init()).\n
* The tr_* functions call the corresponding function pointers, which are
* passed in the tr_socket struct, and forward the remaining arguments.
*
* @{
*/
struct pfx_table;
/**
* @brief The return values for tr_ functions.
*/
enum tr_rtvals {
/** @brief Operation was successfull. */
TR_SUCCESS = 0,
/** Error occured. */
TR_ERROR = -1,
/** No data is available on the socket. */
TR_WOULDBLOCK = -2,
/** Call was interrupted from a signal */
TR_INTR = -3,
/** Connection closed */
TR_CLOSED = -4
};
struct tr_socket;
/**
* @brief A function pointer to a technology specific close function.
* \sa tr_close
* */
typedef void (*tr_close_fp)(void *socket);
/**
* @brief A function pointer to a technology specific open function.
* \sa tr_open
* */
typedef int (*tr_open_fp)(void *socket);
/**
* @brief A function pointer to a technology specific free function. All memory associated with the tr_socket will be freed.
* \sa tr_free
* */
typedef void (*tr_free_fp)(struct tr_socket *tr_sock);
/**
* @brief A function pointer to a technology specific recv function.
* \sa tr_recv
* */
typedef int (*tr_recv_fp)(const void *socket, void *pdu, const size_t len, const time_t timeout);
/**
* @brief A function pointer to a technology specific send function.
* \sa tr_send
* */
typedef int (*tr_send_fp)(const void *socket, const void *pdu, const size_t len, const time_t timeout);
/**
* @brief A function pointer to a technology specific info function.
* \sa tr_send
* */
typedef const char *(*tr_ident_fp)(void *socket);
/**
* @brief A transport socket datastructure.
*
* @param socket A pointer to a technology specific socket.
* @param open_fp Pointer to a function that establishes the socket connection.
* @param close_fp Pointer to a function that closes the socket.
* @param free_fp Pointer to a function that frees all memory allocated with this socket.
* @param send_fp Pointer to a function that sends data through this socket.
* @param recv_fp Pointer to a function that receives data from this socket.
*/
struct tr_socket {
void *socket;
tr_open_fp open_fp;
tr_close_fp close_fp;
tr_free_fp free_fp;
tr_send_fp send_fp;
tr_recv_fp recv_fp;
tr_ident_fp ident_fp;
};
/**
* @brief A tr_tcp_config struct holds configuration for a TCP connection.
* @param host Hostname or IP address to connect to.
* @param port Port to connect to.
* @param bindaddr Hostname or IP address to connect from. NULL for
* determination by OS.
* to use the source address of the system's default route to the server
*/
struct tr_tcp_config {
char *host;
char *port;
char *bindaddr;
...;
};
/**
* @brief Initializes the tr_socket struct for a TCP connection.
* @param[in] config TCP configuration for the connection.
* @param[out] socket Initialized transport socket.
* @returns TR_SUCCESS On success.
* @returns TR_ERROR On error.
*/
int tr_tcp_init(const struct tr_tcp_config *config, struct tr_socket *socket);
/* @} */
/*
* 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/
*/
/**
* @defgroup mod_rtr_mgr_h RTR connection manager
* @brief The RTR connection manager maintains multiple groups of @ref
* rtr_socket "RTR sockets".
* @details The RTR connection manager is initialized with one or multiple
* groups of rtr_sockets. Each group is configured with a preference
* value and contains a set of rtr_socket RTR sockets. It connects to all
* sockets of the group with the lowest preference value.\n
* In case of failures, the connection manager establishes connections to
* RTR servers of another group with the next lowest preference value (see
* <a href="https://tools.ietf.org/html/rfc6810">IETF
* RFC 6810</a> for details about error handling).\n
* RTRlib also supports a Retry Interval (see
* <a href="https://tools.ietf.org/html/draft-ietf-sidr-rpki-rtr-rfc6810-bis">
* draft-ietf-sidr-rpki-rtr-rfc6810-bis</a>).
* If a more preferred group is online again, the RTR connection manager
* will switch back and close connections to the caches of the less
* preferred group.
*
* @{
* @example rtr_mgr.c
* Usage example of the RTR connection manager.
*/
/**
* @brief Version of the IP protocol.
*/
enum lrtr_ip_version {
/** IPV4 */
LRTR_IPV4,
/** LRTR_IPV6 */
LRTR_IPV6
};
/**
* @brief Struct storing an IPv4 address in host byte order.
* @param addr The IPv4 address.
*/
struct lrtr_ipv4_addr {
uint32_t addr;
};
/**
* @brief Struct holding an IPv6 address in host byte order.
*/
struct lrtr_ipv6_addr {
uint32_t addr[4]; /**< The IPv6 address. */
};
/**
* @brief The lrtr_ip_addr struct stores a IPv4 or IPv6 address in host byte order.
* @param ver Specifies the type of the stored address.
* @param u Union holding a lrtr_ipv4_addr or lrtr_ipv6_addr.
*/
struct lrtr_ip_addr {
enum lrtr_ip_version ver;
union {
struct lrtr_ipv4_addr addr4;
struct lrtr_ipv6_addr addr6;
} u;
};
/**
* @defgroup util_h Utility functions
* @{
*
* @brief Checks if two lrtr_ip_addr structs are equal.
* @param[in] a lrtr_ip_addr
* @param[in] b lrtr_ip_addr
* @return true If a == b.
* @return false If a != b.
*/
bool lrtr_ip_addr_equal(const struct lrtr_ip_addr a, const struct lrtr_ip_addr b);
/**
* Converts the passed lrtr_ip_addr struct to string representation.
* @param[in] ip lrtr_ip_addr
* @param[out] str Pointer to a char array. The array must be at least INET_ADDRSTRLEN bytes long if the passed lrtr_ip_addr stores
* an IPv4 address. If lrtr_ip_addr stores an IPv6 address, str must be at least INET6_ADDRSTRLEN bytes long.
* @param[in] len Length of the str array.
* @result 0 On success.
* @result -1 On error.
*/
int lrtr_ip_addr_to_str(const struct lrtr_ip_addr *ip, char *str, const unsigned int len);
/**
* Converts the passed IP address in string representation to an lrtr_ip_addr.
* @param[in] str Pointer to a Null terminated char array.
* @param[out] ip Pointer to a lrtr_ip_addr struct.
* @result 0 On success.
* @result -1 On error.
*/
int lrtr_ip_str_to_addr(const char *str, struct lrtr_ip_addr *ip);
/**
* Compares addr1 in the lrtr_ip_addr struct with addr2 in string representation.
* @param[in] addr1 lrtr_ip_addr
* @param[in] addr2 IP-address as string
* @return true If a == b
* @return false If a != b
*/
bool lrtr_ip_str_cmp(const struct lrtr_ip_addr *addr1, const char *addr2);
/* @} */
/*
* 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/
*/
/**
* @defgroup mod_rtr_h RTR socket
* @brief An RTR socket implements the RPKI-RTR protocol scheme.
* @details One rtr_socket communicates with a single RPKI-RTR server.
* @{
*/
/*
* 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/
*/
enum rtr_rtvals {
RTR_SUCCESS = 0,
RTR_ERROR = -1,
RTR_INVALID_PARAM = -2
};
/**
* @brief States of the RTR socket.
*/
enum rtr_socket_state {
/** Socket is establishing the transport connection. */
RTR_CONNECTING,
/** Connection is established, socket is waiting for a Serial Notify or expiration of the refresh_interval timer */
RTR_ESTABLISHED,
/** Resetting RTR connection. */
RTR_RESET,
/** Receiving validation records from the RTR server. */
RTR_SYNC,
/** Reconnect without any waiting period */
RTR_FAST_RECONNECT,
/** No validation records are available on the RTR server. */
RTR_ERROR_NO_DATA_AVAIL,
/** Server was unable to answer the last serial or reset query. */
RTR_ERROR_NO_INCR_UPDATE_AVAIL,
/** Fatal protocol error occurred. */
RTR_ERROR_FATAL,
/** Error on the transport socket occurred. */
RTR_ERROR_TRANSPORT,
/** RTR Socket is stopped. */
RTR_SHUTDOWN,
};
/**
* @brief A function pointer that is called if the state of the rtr socket has changed.
*/
typedef void (*rtr_connection_state_fp)(const struct rtr_socket *rtr_socket, const enum rtr_socket_state state, void *connection_state_fp_param_config, void *connection_state_fp_param_group);
/**
* @brief A RTR socket.
* @param tr_socket Pointer to an initialized tr_socket that will be used to communicate with the RTR server.
* @param refresh_interval Time period in seconds. Tells the router how long to wait before next attempting to poll the cache, using a Serial Query or
* Reset Query PDU.
* @param last_update Timestamp of the last validation record update. Is 0 if the pfx_table doesn't stores any
* validation reords from this rtr_socket.
* @param expire_interval Time period in seconds. Received records are deleted if the client was unable to refresh data for this time period.
* If 0 is specified, the expire_interval is twice the refresh_interval.
* @param retry_interval Time period in seconds between a faild quary and the next attempt.
* @param state Current state of the socket.
* @param session_id session_id of the RTR session.
* @param request_session_id True, if the rtr_client have to request a new none from the server.
* @param serial_number Last serial number of the obtained validation records.
* @param pfx_table pfx_table that stores the validation records obtained from the connected rtr server.
* @param connection_state_fp A callback function that is executed when the state of the socket changes.
* @param connection_state_fp_param Parameter that is passed to the connection_state_fp callback.
*/
struct rtr_socket {
struct tr_socket *tr_socket;
unsigned int refresh_interval;
time_t last_update;
unsigned int expire_interval;
unsigned int retry_interval;
enum rtr_socket_state state;
uint32_t session_id;
bool request_session_id;
uint32_t serial_number;
struct pfx_table *pfx_table;
rtr_connection_state_fp connection_state_fp;
void *connection_state_fp_param_config;
void *connection_state_fp_param_group;
unsigned int version;
bool has_received_pdus;
struct spki_table *spki_table;
...;
};
/**
* @brief Possible return values for pfx_ functions.
*/
enum pfx_rtvals {
/** Operation was successfull. */
PFX_SUCCESS = 0,
/** Error occured. */
PFX_ERROR = -1,
/** The supplied pfx_record already exists in the pfx_table. */
PFX_DUPLICATE_RECORD = -2,
/** pfx_record wasn't found in the pfx_table. */
PFX_RECORD_NOT_FOUND = -3
};
/**
* @brief Validation states returned from pfx_validate_origin.
*/
enum pfxv_state {
/** A valid certificate for the pfx_record exists. */
BGP_PFXV_STATE_VALID,
/** @brief No certificate for the route exists. */
BGP_PFXV_STATE_NOT_FOUND,
/** @brief One or more records that match the input prefix exists in the pfx_table but the prefix max_len or ASN does'nt match. */
BGP_PFXV_STATE_INVALID
};
/**
* @brief pfx_record.
* @param asn Origin AS number.
* @param prefix IP prefix.
* @param min_len Minimum prefix length.
* @param max_len Maximum prefix length.
* @param socket_id unique id of the rtr_socket that received this record.
*/
struct pfx_record {
uint32_t asn;
struct lrtr_ip_addr prefix;
uint8_t min_len;
uint8_t max_len;
const struct rtr_socket *socket;
};
/**
* @brief A function pointer that is called if an record was added to the pfx_table or was removed from the pfx_table.
* @param pfx_table which was updated.
* @param record pfx_record that was modified.
* @param added True if the record was added, false if the record was removed.
*/
typedef void (*pfx_update_fp)(struct pfx_table *pfx_table, const struct pfx_record record, const bool added);
/**
* @brief A function pointer that is called for each record in the pfx_table.
* @param pfx_record
* @param data forwarded data which the user has passed to pfx_table_for_each_ipv4_record() or
* pfx_table_for_each_ipv6_record()
*/
typedef void (*pfx_for_each_fp)(const struct pfx_record *pfx_record, void *data);
/**
* @brief pfx_table.
* @param ipv4
* @param ipv6
* @param update_fp
* @param lock
*/
struct pfx_table {
struct trie_node *ipv4;
struct trie_node *ipv6;
pfx_update_fp update_fp;
...;
};
/**
* @brief Initializes the pfx_table struct.
* @param[in] pfx_table pfx_table that will be initialized.
* @param[in] update_fp A function pointer that will be called if a record was added or removed.
*/
void pfx_table_init(struct pfx_table *pfx_table, pfx_update_fp update_fp);
/**
* @brief Frees all memory associated with the pfx_table.
* @param[in] pfx_table pfx_table that will be freed.
*/
void pfx_table_free(struct pfx_table *pfx_table);
/**
* @brief Adds a pfx_record to a pfx_table.
* @param[in] pfx_table pfx_table to use.
* @param[in] pfx_record pfx_record that will be added.
* @return PFX_SUCCESS On success.
* @return PFX_ERROR On error.
* @return PFX_DUPLICATE_RECORD If the pfx_record already exists.
*/
int pfx_table_add(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
/**
* @brief Removes a pfx_record from a pfx_table.
* @param[in] pfx_table pfx_table to use.
* @param[in] pfx_record Record that will be removed.
* @return PFX_SUCCESS On success.
* @return PFX_ERROR On error.
* @return PFX_RECORD_NOT_FOUND If pfx_records couldn't be found.
*/
int pfx_table_remove(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
/**
* @brief Validates the origin of a BGP-Route.
* @param[in] pfx_table pfx_table to use.
* @param[in] asn Autonomous system number of the Origin-AS of the route.
* @param[in] prefix Announced network Prefix.
* @param[in] mask_len Length of the network mask of the announced prefix.
* @param[out] result Result of the validation.
* @return PFX_SUCCESS On success.
* @return PFX_ERROR On error.
*/
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);
/**
* @brief Validates the origin of a BGP-Route and returns a list of pfx_record that decided the result.
* @param[in] pfx_table pfx_table to use.
* @param[out] reason Pointer to a memory area that will be used as array of pfx_records. The memory area will be overwritten. Reason must point to NULL or an allocated memory area.
* @param[out] reason_len Size of the array reason.
* @param[in] asn Autonomous system number of the Origin-AS of the route.
* @param[in] prefix Announcend network Prefix
* @param[in] mask_len Length of the network mask of the announced prefix
* @param[out] result Result of the validation.
* @return PFX_SUCCESS On success.
* @return PFX_ERROR On error.
*/
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);
/**
* @brief Iterates over all IPv4 records in the pfx_table.
* @details For every pfx_record the function fp is called. The pfx_record and
* the data pointer is passed to the fp.
* @param[in] pfx_table
* @param[in] fp A pointer to a callback function with the signature \c pfx_for_each_fp.
* @param[in] data This parameter is forwarded to the callback function.
*/
void pfx_table_for_each_ipv4_record(struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data);
/**
* @brief Iterates over all IPv6 records in the pfx_table.
* @details For every pfx_record the function fp is called. The pfx_record and
* the data pointer is passed to the fp.
* @param[in] pfx_table
* @param[in] fp A pointer to a callback function with the signature \c pfx_for_each_fp.
* @param[in] data This parameter is forwarded to the callback function.
*/
void pfx_table_for_each_ipv6_record(struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data);
/* @} */
/*
* 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/
*/
#define SKI_SIZE 20
#define SPKI_SIZE 91
struct spki_table;
/**
* @brief spki_record.
* @param ski Subject Key Identifier
* @param asn Origin AS number
* @param spki Subject public key info
* @param socket Pointer to the rtr_socket this spki_record was received in
*/
struct spki_record {
uint8_t ski[SKI_SIZE];
uint32_t asn;
uint8_t spki[SPKI_SIZE];
const struct rtr_socket *socket;
};
/**
* @brief A function pointer that is called if an record was added
* to the spki_table or was removed from the spki_table.
* @param spki_table which was updated.
* @param record spki_record that was modified.
* @param added True if the record was added, false if the record was removed.
*/
typedef void (*spki_update_fp)(struct spki_table *spki_table,
const struct spki_record record,
const bool added);
/**
* @brief Status of a rtr_mgr_group.
*/
enum rtr_mgr_status {
/** RTR sockets are disconnected */
RTR_MGR_CLOSED,
/** RTR sockets trying to establish a connection. */
RTR_MGR_CONNECTING,
/** All RTR sockets of the group are synchronized with rtr servers. */
RTR_MGR_ESTABLISHED,
/** Error occurred on at least one RTR socket. */
RTR_MGR_ERROR,
};
/**
* @brief A set of RTR sockets.
* @param sockets Array of rtr_socket pointer. The tr_socket element of
* the rtr_socket must be associated with an initialized #
* transport socket.
* @param sockets_len Number of elements in the sockets array.
* @param preference The preference value of this group.
* Groups with lower preference values are preferred.
* @param status Status of the group.
*/
struct rtr_mgr_group {
struct rtr_socket **sockets;
unsigned int sockets_len;
uint8_t preference;
enum rtr_mgr_status status;
};
typedef void (*rtr_mgr_status_fp)(const struct rtr_mgr_group *,
enum rtr_mgr_status,
const struct rtr_socket *,
void *);
struct rtr_mgr_config {
unsigned int len;
rtr_mgr_status_fp status_fp;
void *status_fp_data;
...;
};
/**
* @brief Initializes a rtr_mgr_config.
* @param[out] config_out The rtr_mgr_config that will be initialized by this
* function. On error, *config_out will be NULL!
* @param[in] groups Array of rtr_mgr_group. Every RTR socket in an
* rtr_mgr_group must be assoziated with an initialized
* transport socket. A Transport socket is only allowed to be
* associated with one rtr socket. The preference values must
* be unique in the group array. More than one rtr_mgr_group
* with the same preference value isn't allowed.
* @param[in] groups_len Number of elements in the groups array.
* @param[in] refresh_interval Interval in seconds between serial queries that
* are sent to the server. Must be >= 1 and <=
* 86400s (1d), recommended default is 3600s (1h).
* @param[in] expire_interval Stored validation records will be deleted if
* cache was unable to refresh data for this period.
* The value should be twice the refresh_interval
* and must be >= 600s (10min) and <= 172800s (2d).
* The recommended default is 7200s (2h).
* @param[in] retry_interval This parameter tells the router how long to wait
* (in seconds) before retrying a failed Serial Query
* or Reset Query.
* The value must be >= 1s and <= 7200s (2h).
* The recommended default is 600s (10min).
* @param[in] update_fp Pointer to pfx_update_fp callback, that is executed for
every added and removed pfx_record.
* @param[in] spki_update_fp Pointer to spki_update_fp callback, that is
executed for every added and removed spki_record.
* @param[in] status_fp Pointer to a function that is called if the connection
* status from one of the socket groups is changed.
* @param[in] status_fp_data Pointer to a memory area that is passed to the
* status_fp function. Memory area can be freely used
* to pass user-defined data to the status_fp
* callback.
* @return RTR_ERROR If an error occurred
* @return RTR_INVALID_PARAM If refresh_interval or expire_interval is invalid.
* @return RTR_SUCCESS On success.
*/
int rtr_mgr_init(struct rtr_mgr_config **config_out,
struct rtr_mgr_group groups[],
const unsigned int groups_len,
const unsigned int refresh_interval,
const unsigned int expire_interval,
const unsigned int retry_interval,
const pfx_update_fp update_fp,
const spki_update_fp spki_update_fp,
const rtr_mgr_status_fp status_fp,
void *status_fp_data);
/**
* @brief Frees all resources that were allocated from the rtr_mgr.
* @details rtr_mgr_stop must be called before, to shutdown all rtr_sockets.
* @param[in] config rtr_mgr_config.
*/
void rtr_mgr_free(struct rtr_mgr_config *config);
/**
* @brief Establishes rtr_socket connections
* @details Establishes the connection with the rtr_sockets of the group
* with the lowest preference value and handles errors as defined in the
* RPKI-RTR protocol.
* @param[in] config Pointer to an initialized rtr_mgr_config.
* @return RTR_SUCCESS On success
* @return RTR_ERROR On error
*/
int rtr_mgr_start(struct rtr_mgr_config *config);
/**
* @brief Terminates rtr_socket connections
* @details Terminates all rtr_socket connections defined in the config.
* All pfx_records received from these sockets will be purged.
* @param[in] config The rtr_mgr_config struct
*/
void rtr_mgr_stop(struct rtr_mgr_config *config);
/**
* @brief Check if rtr_mgr_group is fully synchronized with at least one group.
* @param[in] config The rtr_mgr_config.
* @return true If pfx_table stores non-outdated pfx_records
* @return false If pfx_table isn't fully synchronized with at least one group.
*/
bool rtr_mgr_conf_in_sync(struct rtr_mgr_config *config);
/**
* @brief Validates the origin of a BGP-Route.
* @param[in] config The rtr_mgr_config
* @param[in] asn Autonomous system number of the Origin-AS of the prefix
* @param[in] prefix Announced network prefix
* @param[in] mask_len Length of the network mask of the announced prefix
* @param[out] result Outcome of the validation
* @return PFX_SUCCESS On success.
* @return PFX_ERROR If an error occurred.
*/
int rtr_mgr_validate(struct rtr_mgr_config *config,
const uint32_t asn,
const struct lrtr_ip_addr *prefix,
const uint8_t mask_len,
enum pfxv_state *result);
/**
* @brief Returns all SPKI records which match the given ASN and SKI.
* @param[in] config
* @param[in] asn Autonomous system number of the Origin-AS
* @param[in] ski the SKI to search for
* @param[out] result a array of all matching spki_records
* @param[out] result_count number of returned spki_records
* @return SPKI_SUCCESS On success
* @return SPKI_ERROR If an error occurred
*/
int rtr_mgr_get_spki(struct rtr_mgr_config *config,
const uint32_t asn,
uint8_t *ski,
struct spki_record **result,
unsigned int *result_count);
/**
* @brief Converts a rtr_mgr_status to a String.
* @param[in] status state to convert to a string.
* @return NULL If status isn't a valid rtr_mgr_status.
* @return !=NULL The rtr_rtr_mgr_status as String.
*/
const char *rtr_mgr_status_to_str(enum rtr_mgr_status status);
/**
* @brief Iterates over all IPv4 records in the pfx_table.
* @details For every pfx_record the function fp is called. The pfx_record and
* the data pointer is passed to the fp.
* @param[in] config rtr_mgr_config
* @param[in] fp Pointer to callback function with signature \c pfx_for_each_fp.
* @param[in] data This parameter is forwarded to the callback function.
*/
void rtr_mgr_for_each_ipv4_record(struct rtr_mgr_config *config,
pfx_for_each_fp fp,
void *data);
/**
* @brief Iterates over all IPv6 records in the pfx_table.
* @details For every pfx_record the function fp is called. The pfx_record and
* the data pointer is passed to the fp.
* @param[in] config rtr_mgr_config
* @param[in] fp Pointer to callback function with signature \c pfx_for_each_fp.
* @param[in] data This parameter is forwarded to the callback function.
*/
void rtr_mgr_for_each_ipv6_record(struct rtr_mgr_config *config,
pfx_for_each_fp fp,
void *data);
/*
* custom function to determine availability of ssh support from python
* in a platform independent way
*/
int have_ssh(void);
struct tr_ssh_config {
char *host;
unsigned int port;
char *bindaddr;
char *username;
char *server_hostkey_path;
char *client_privkey_path;
...;
};