00001
00002
00003
00004
00005
00006
00007
00008
00009
00017 #ifndef RTR_PFX_H
00018 #define RTR_PFX_H
00019
00020 #include <inttypes.h>
00021
00022 #include "rtrlib/lib/ip.h"
00023 #include "rtrlib/pfx/trie/trie-pfx.h"
00024
00025
00029 enum pfx_rtvals {
00031 PFX_SUCCESS = 0,
00032
00034 PFX_ERROR = -1,
00035
00037 PFX_DUPLICATE_RECORD = -2,
00038
00040 PFX_RECORD_NOT_FOUND = -3
00041 };
00042
00046 enum pfxv_state {
00048 BGP_PFXV_STATE_VALID,
00049
00051 BGP_PFXV_STATE_NOT_FOUND,
00052
00054 BGP_PFXV_STATE_INVALID
00055 };
00056
00057
00064 typedef void (*pfx_for_each_fp)(const struct pfx_record *pfx_record, void *data);
00065
00071 void pfx_table_init(struct pfx_table *pfx_table, pfx_update_fp update_fp);
00072
00077 void pfx_table_free(struct pfx_table *pfx_table);
00078
00087 int pfx_table_add(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
00088
00097 int pfx_table_remove(struct pfx_table *pfx_table, const struct pfx_record *pfx_record);
00098
00106 int pfx_table_src_remove(struct pfx_table *pfx_table, const struct rtr_socket *socket);
00107
00118 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);
00119
00132 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);
00133
00142 void pfx_table_for_each_ipv4_record(struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data);
00143
00152 void pfx_table_for_each_ipv6_record(struct pfx_table *pfx_table, pfx_for_each_fp fp, void *data);
00153
00154 #endif
00155