2015-09-17 15:15:30 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- The Resource Public Key Infrastructure (RPKI) to Router Protocol
|
|
|
|
*
|
2015-10-07 13:50:43 +00:00
|
|
|
* Using RTRLib: http://rpki.realmv6.org/
|
|
|
|
*
|
2015-09-17 15:15:30 +00:00
|
|
|
* (c) 2015 CZ.NIC
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BIRD_RPKI_H_
|
|
|
|
#define _BIRD_RPKI_H_
|
|
|
|
|
2015-09-29 08:14:32 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2015-09-17 15:15:30 +00:00
|
|
|
#include "nest/bird.h"
|
|
|
|
#include "nest/protocol.h"
|
2015-09-29 08:14:32 +00:00
|
|
|
#include "lib/socket.h"
|
2015-10-05 14:25:48 +00:00
|
|
|
#include "proto/rpki/rtrlib-mockup.h"
|
|
|
|
|
2015-09-17 15:15:30 +00:00
|
|
|
|
2015-10-14 12:47:01 +00:00
|
|
|
#define RPKI_PORT "8282"
|
|
|
|
#define RPKI_SSH_PORT "22"
|
|
|
|
#define RPKI_PORT_MAX_LENGTH_STR 6
|
|
|
|
#define RPKI_LIBRTR_DEFAULT "librtr.so"
|
2015-10-07 13:50:43 +00:00
|
|
|
|
2015-10-14 12:47:01 +00:00
|
|
|
#define RPKI_DEFAULT_CACHE_PREFERENCE 0xff /* the least preference */
|
2015-09-27 22:15:52 +00:00
|
|
|
|
2015-09-29 08:14:32 +00:00
|
|
|
#define RPKI_LOG(log_level, p, msg, args...) \
|
2015-09-27 22:15:52 +00:00
|
|
|
do { \
|
2015-09-29 08:14:32 +00:00
|
|
|
log(log_level "%s: " msg, p->p.name , ## args); \
|
|
|
|
} while(0)
|
|
|
|
#define RPKI_TRACE(p, msg, args...) \
|
|
|
|
do { \
|
|
|
|
if (p->p.debug) \
|
|
|
|
RPKI_LOG(L_TRACE, p, msg, ## args); \
|
2015-09-27 22:15:52 +00:00
|
|
|
} while(0)
|
2015-10-14 12:47:01 +00:00
|
|
|
#define RPKI_WARN(p, msg, args...) RPKI_LOG(L_WARN, p, msg, ## args);
|
2015-09-29 08:14:32 +00:00
|
|
|
#define RPKI_ERROR(p, msg, args...) RPKI_LOG(L_ERR, p, msg, ## args);
|
|
|
|
#define RPKI_DIE(p, msg, args...) \
|
|
|
|
do { \
|
|
|
|
RPKI_LOG(L_FATAL, p, msg, ## args); \
|
|
|
|
exit(1); \
|
|
|
|
} while(0)
|
|
|
|
|
2015-10-14 12:47:01 +00:00
|
|
|
struct rpki_ssh_config {
|
|
|
|
char *bird_private_key;
|
|
|
|
char *cache_public_key;
|
|
|
|
char *user;
|
|
|
|
};
|
2015-10-07 13:50:43 +00:00
|
|
|
|
2015-09-27 22:15:52 +00:00
|
|
|
struct rpki_cache {
|
2015-10-14 12:47:01 +00:00
|
|
|
node n; /* in struct rpki_config.cache_list */
|
|
|
|
char *host; /* full domain name or ip address */
|
|
|
|
char port[RPKI_PORT_MAX_LENGTH_STR]; /* the highest port is "65535" */
|
|
|
|
u8 preference; /* the most prioritized are the lowest numbers, starts with 1 */
|
|
|
|
struct rpki_ssh_config *ssh; /* SSH config or NULL */
|
|
|
|
struct rtr_socket *rtrlib_sock;
|
2015-09-17 15:15:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rpki_config {
|
|
|
|
struct proto_config c;
|
2015-10-14 12:47:01 +00:00
|
|
|
list cache_list; /* struct rpki_cache * */
|
2015-09-29 08:14:32 +00:00
|
|
|
struct roa_table_config *roa_table_cf;
|
2015-09-17 15:15:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rpki_proto {
|
|
|
|
struct proto p;
|
2015-09-29 08:14:32 +00:00
|
|
|
struct rpki_config *cf;
|
2015-10-14 12:47:01 +00:00
|
|
|
node rpki_node; /* in rpki_proto_list */
|
|
|
|
|
2015-09-27 22:15:52 +00:00
|
|
|
struct rtr_mgr_config *rtr_conf;
|
|
|
|
struct rtr_mgr_group *rtr_groups;
|
2015-09-29 08:14:32 +00:00
|
|
|
struct rtr_socket **rtr_sockets;
|
|
|
|
uint rtr_sockets_len;
|
|
|
|
|
|
|
|
sock *notify_read_sk;
|
|
|
|
sock *notify_write_sk;
|
|
|
|
list notify_list;
|
2015-10-07 13:50:43 +00:00
|
|
|
pthread_mutex_t notify_lock;
|
2015-09-17 15:15:30 +00:00
|
|
|
};
|
|
|
|
|
2015-09-27 22:15:52 +00:00
|
|
|
struct rpki_cache *rpki_new_cache(void);
|
2015-09-17 15:15:30 +00:00
|
|
|
|
2015-10-07 13:50:43 +00:00
|
|
|
static inline void rpki_lock_notify(struct rpki_proto *p) { pthread_mutex_lock(&p->notify_lock); }
|
|
|
|
static inline void rpki_unlock_notify(struct rpki_proto *p) { pthread_mutex_unlock(&p->notify_lock); }
|
2015-09-29 08:14:32 +00:00
|
|
|
|
|
|
|
void rpki_init_all(void);
|
2015-10-07 13:50:43 +00:00
|
|
|
char *rpki_load_rtrlib(void);
|
2015-09-29 08:14:32 +00:00
|
|
|
|
2015-09-17 15:15:30 +00:00
|
|
|
#endif /* _BIRD_RPKI_H_ */
|