2019-12-14 14:37:59 +01:00
|
|
|
#ifndef BGPQ4_H_
|
|
|
|
#define BGPQ4_H_
|
2007-03-22 18:12:32 +00:00
|
|
|
|
2015-08-30 15:21:17 +03:00
|
|
|
#if HAVE_SYS_QUEUE_H && HAVE_STAILQ_IN_SYS_QUEUE
|
2015-07-10 20:57:30 +03:00
|
|
|
#include <sys/queue.h>
|
2015-07-12 17:31:09 +03:00
|
|
|
#else
|
|
|
|
#include "sys_queue.h"
|
|
|
|
#endif
|
2015-07-10 20:57:30 +03:00
|
|
|
|
2007-03-22 18:12:32 +00:00
|
|
|
#include "sx_prefix.h"
|
|
|
|
#include "sx_slentry.h"
|
|
|
|
|
2015-07-10 20:57:30 +03:00
|
|
|
typedef enum {
|
2007-03-22 18:12:32 +00:00
|
|
|
V_CISCO = 0,
|
2011-07-15 11:48:34 +00:00
|
|
|
V_JUNIPER,
|
2013-01-08 12:21:14 +00:00
|
|
|
V_CISCO_XR,
|
2014-06-04 18:10:59 +02:00
|
|
|
V_JSON,
|
2015-07-01 20:03:41 +03:00
|
|
|
V_BIRD,
|
2016-10-14 18:54:12 +03:00
|
|
|
V_OPENBGPD,
|
2017-03-01 10:02:04 +02:00
|
|
|
V_FORMAT,
|
2018-08-10 15:02:08 +03:00
|
|
|
V_NOKIA,
|
2018-11-11 19:50:44 +03:00
|
|
|
V_HUAWEI,
|
2019-12-14 14:48:01 +01:00
|
|
|
V_MIKROTIK,
|
2018-11-11 19:50:44 +03:00
|
|
|
V_NOKIA_MD
|
2007-03-22 18:12:32 +00:00
|
|
|
} bgpq_vendor_t;
|
|
|
|
|
2015-07-10 20:57:30 +03:00
|
|
|
typedef enum {
|
2007-03-22 18:12:32 +00:00
|
|
|
T_NONE = 0,
|
|
|
|
T_ASPATH,
|
|
|
|
T_OASPATH,
|
2018-10-03 19:16:34 +03:00
|
|
|
T_ASSET,
|
2008-06-02 11:32:25 +00:00
|
|
|
T_PREFIXLIST,
|
2017-09-08 19:40:25 +03:00
|
|
|
T_EACL,
|
|
|
|
T_ROUTE_FILTER_LIST
|
2007-03-22 18:12:32 +00:00
|
|
|
} bgpq_gen_t;
|
|
|
|
|
2015-07-12 17:31:09 +03:00
|
|
|
struct bgpq_expander;
|
|
|
|
|
2015-07-10 20:57:30 +03:00
|
|
|
struct bgpq_request {
|
|
|
|
STAILQ_ENTRY(bgpq_request) next;
|
|
|
|
char* request;
|
|
|
|
int size, offset;
|
2015-07-12 17:31:09 +03:00
|
|
|
int (*callback)(char*, struct bgpq_expander*, struct bgpq_request*);
|
2008-05-19 13:33:32 +00:00
|
|
|
void *udata;
|
2015-07-12 17:31:09 +03:00
|
|
|
unsigned depth;
|
2008-05-19 13:33:32 +00:00
|
|
|
};
|
|
|
|
|
2015-07-10 20:57:30 +03:00
|
|
|
struct bgpq_expander {
|
2007-03-22 18:12:32 +00:00
|
|
|
struct sx_radix_tree* tree;
|
2015-07-12 17:31:09 +03:00
|
|
|
STAILQ_HEAD(sx_slentries, sx_slentry) macroses, rsets;
|
|
|
|
RB_HEAD(tentree, sx_tentry) already, stoplist;
|
2007-03-22 18:12:32 +00:00
|
|
|
int family;
|
|
|
|
char* sources;
|
2009-03-27 13:57:18 +00:00
|
|
|
uint32_t asnumber;
|
2019-12-14 15:09:30 +01:00
|
|
|
int aswidth;
|
2007-03-22 18:12:32 +00:00
|
|
|
char* name;
|
|
|
|
bgpq_vendor_t vendor;
|
|
|
|
bgpq_gen_t generation;
|
2008-05-14 15:09:13 +00:00
|
|
|
int identify;
|
2015-07-01 18:29:50 +03:00
|
|
|
int sequence;
|
2015-07-10 16:01:22 +03:00
|
|
|
int maxdepth;
|
2018-09-05 14:47:30 +03:00
|
|
|
int validate_asns;
|
2008-05-16 15:19:09 +00:00
|
|
|
unsigned char asn32;
|
|
|
|
unsigned char* asn32s[65536];
|
2008-05-19 13:33:32 +00:00
|
|
|
struct bgpq_prequest* firstpipe, *lastpipe;
|
|
|
|
int piped;
|
2008-08-08 09:29:53 +00:00
|
|
|
char* match;
|
2008-12-19 17:39:15 +00:00
|
|
|
char* server;
|
2015-08-30 14:38:18 +03:00
|
|
|
char* port;
|
2015-07-01 20:03:41 +03:00
|
|
|
char* format;
|
2012-05-18 15:52:06 +00:00
|
|
|
unsigned maxlen;
|
2015-07-10 20:57:30 +03:00
|
|
|
STAILQ_HEAD(bgpq_requests, bgpq_request) wq, rq;
|
2015-07-12 17:31:09 +03:00
|
|
|
int fd, cdepth;
|
2007-03-22 18:12:32 +00:00
|
|
|
};
|
|
|
|
|
2008-05-19 13:33:32 +00:00
|
|
|
|
2007-03-22 18:12:32 +00:00
|
|
|
int bgpq_expander_init(struct bgpq_expander* b, int af);
|
|
|
|
int bgpq_expander_add_asset(struct bgpq_expander* b, char* set);
|
2008-06-02 11:32:25 +00:00
|
|
|
int bgpq_expander_add_rset(struct bgpq_expander* b, char* set);
|
2007-03-22 18:12:32 +00:00
|
|
|
int bgpq_expander_add_as(struct bgpq_expander* b, char* as);
|
|
|
|
int bgpq_expander_add_prefix(struct bgpq_expander* b, char* prefix);
|
2015-02-19 16:41:38 +03:00
|
|
|
int bgpq_expander_add_prefix_range(struct bgpq_expander* b, char* prefix);
|
2015-07-12 17:31:09 +03:00
|
|
|
int bgpq_expander_add_stop(struct bgpq_expander* b, char* object);
|
2007-03-22 18:12:32 +00:00
|
|
|
|
2007-03-23 12:47:28 +00:00
|
|
|
int bgpq_expand(struct bgpq_expander* b);
|
|
|
|
|
2019-12-14 14:37:59 +01:00
|
|
|
int bgpq4_print_prefixlist(FILE* f, struct bgpq_expander* b);
|
|
|
|
int bgpq4_print_eacl(FILE* f, struct bgpq_expander* b);
|
|
|
|
int bgpq4_print_aspath(FILE* f, struct bgpq_expander* b);
|
|
|
|
int bgpq4_print_asset(FILE* f, struct bgpq_expander* b);
|
|
|
|
int bgpq4_print_oaspath(FILE* f, struct bgpq_expander* b);
|
|
|
|
int bgpq4_print_route_filter_list(FILE* f, struct bgpq_expander* b);
|
2007-03-23 12:47:28 +00:00
|
|
|
|
2008-05-20 15:31:56 +00:00
|
|
|
#ifndef HAVE_STRLCPY
|
|
|
|
size_t strlcpy(char* dst, const char* src, size_t size);
|
|
|
|
#endif
|
2007-03-23 12:47:28 +00:00
|
|
|
|
2007-03-22 18:12:32 +00:00
|
|
|
#endif
|