1
0
mirror of https://github.com/bgp/bgpq4.git synced 2024-05-11 05:55:05 +00:00
bgp-bgpq4/bgpq4.h

99 lines
2.2 KiB
C
Raw Normal View History

2019-12-14 14:37:59 +01:00
#ifndef BGPQ4_H_
#define BGPQ4_H_
2007-03-22 18:12:32 +00:00
#if HAVE_SYS_QUEUE_H && HAVE_STAILQ_IN_SYS_QUEUE
2015-07-10 20:57:30 +03:00
#include <sys/queue.h>
#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,
V_JSON,
V_BIRD,
2016-10-14 18:54:12 +03:00
V_OPENBGPD,
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,
T_ASSET,
2008-06-02 11:32:25 +00:00
T_PREFIXLIST,
T_EACL,
T_ROUTE_FILTER_LIST
2007-03-22 18:12:32 +00:00
} bgpq_gen_t;
struct bgpq_expander;
2015-07-10 20:57:30 +03:00
struct bgpq_request {
STAILQ_ENTRY(bgpq_request) next;
char* request;
int size, offset;
int (*callback)(char*, struct bgpq_expander*, struct bgpq_request*);
2008-05-19 13:33:32 +00:00
void *udata;
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;
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;
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;
int identify;
int sequence;
2015-07-10 16:01:22 +03:00
int maxdepth;
2018-09-05 14:47:30 +03:00
int validate_asns;
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;
char* port;
char* format;
unsigned maxlen;
2015-07-10 20:57:30 +03:00
STAILQ_HEAD(bgpq_requests, bgpq_request) wq, rq;
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);
int bgpq_expander_add_prefix_range(struct bgpq_expander* b, char* prefix);
int bgpq_expander_add_stop(struct bgpq_expander* b, char* object);
2007-03-22 18:12:32 +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);
#ifndef HAVE_STRLCPY
size_t strlcpy(char* dst, const char* src, size_t size);
#endif
2007-03-22 18:12:32 +00:00
#endif