00001
00002
00003
00004
00005
00006
00007
00008
00009
00033 #ifndef RTR_MGR
00034 #define RTR_MGR
00035 #include <stdint.h>
00036 #include <pthread.h>
00037
00038 #include "rtrlib/pfx/pfx.h"
00039 #include "rtrlib/spki/spkitable.h"
00040
00044 enum rtr_mgr_status {
00046 RTR_MGR_CLOSED,
00048 RTR_MGR_CONNECTING,
00050 RTR_MGR_ESTABLISHED,
00052 RTR_MGR_ERROR,
00053 };
00054
00065 struct rtr_mgr_group {
00066 struct rtr_socket **sockets;
00067 unsigned int sockets_len;
00068 uint8_t preference;
00069 enum rtr_mgr_status status;
00070 };
00071
00072 typedef void (*rtr_mgr_status_fp)(const struct rtr_mgr_group *,
00073 enum rtr_mgr_status,
00074 const struct rtr_socket *,
00075 void *);
00076
00077 struct tommy_list_wrapper;
00078
00079
00080 struct rtr_mgr_config {
00081 struct tommy_list_wrapper *groups;
00082 unsigned int len;
00083 pthread_mutex_t mutex;
00084 rtr_mgr_status_fp status_fp;
00085 void *status_fp_data;
00086 struct pfx_table *pfx_table;
00087 struct spki_table *spki_table;
00088 };
00089
00128 int rtr_mgr_init(struct rtr_mgr_config **config_out,
00129 struct rtr_mgr_group groups[],
00130 const unsigned int groups_len,
00131 const unsigned int refresh_interval,
00132 const unsigned int expire_interval,
00133 const unsigned int retry_interval,
00134 const pfx_update_fp update_fp,
00135 const spki_update_fp spki_update_fp,
00136 const rtr_mgr_status_fp status_fp,
00137 void *status_fp_data);
00138
00157 int rtr_mgr_add_group(struct rtr_mgr_config *config,
00158 const struct rtr_mgr_group *group);
00171 int rtr_mgr_remove_group(struct rtr_mgr_config *config,
00172 unsigned int preference);
00178 void rtr_mgr_free(struct rtr_mgr_config *config);
00179
00189 int rtr_mgr_start(struct rtr_mgr_config *config);
00190
00197 void rtr_mgr_stop(struct rtr_mgr_config *config);
00198
00205 bool rtr_mgr_conf_in_sync(struct rtr_mgr_config *config);
00206
00217 int rtr_mgr_validate(struct rtr_mgr_config *config,
00218 const uint32_t asn,
00219 const struct lrtr_ip_addr *prefix,
00220 const uint8_t mask_len,
00221 enum pfxv_state *result);
00222
00233 int rtr_mgr_get_spki(struct rtr_mgr_config *config,
00234 const uint32_t asn,
00235 uint8_t *ski,
00236 struct spki_record **result,
00237 unsigned int *result_count);
00238
00245 const char *rtr_mgr_status_to_str(enum rtr_mgr_status status);
00246
00255 void rtr_mgr_for_each_ipv4_record(struct rtr_mgr_config *config,
00256 pfx_for_each_fp fp,
00257 void *data);
00258
00267 void rtr_mgr_for_each_ipv6_record(struct rtr_mgr_config *config,
00268 pfx_for_each_fp fp,
00269 void *data);
00270
00276 struct rtr_mgr_group *rtr_mgr_get_first_group(struct rtr_mgr_config *config);
00277
00278 int rtr_mgr_for_each_group(struct rtr_mgr_config *config,
00279 void (*fp)(const struct rtr_mgr_group *group,
00280 void *data),
00281 void *data);
00282 #endif
00283