xref: /openbsd-src/usr.sbin/bgplgd/bgplgd.h (revision 5ffbcedbb1322a9a65053657189069e328d0b289)
1 /*	$OpenBSD: bgplgd.h,v 1.5 2024/12/03 10:38:06 claudio Exp $ */
2 /*
3  * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #define QS_NEIGHBOR		1
19 #define QS_GROUP		2
20 #define QS_AS			3
21 #define QS_PREFIX		4
22 #define QS_COMMUNITY		5
23 #define QS_EXTCOMMUNITY		6
24 #define QS_LARGECOMMUNITY	7
25 #define QS_AF			8
26 #define QS_RIB			9
27 #define QS_OVS			10
28 #define QS_BEST			11
29 #define QS_ALL			12
30 #define QS_SHORTER		13
31 #define QS_ERROR		14
32 #define QS_AVS			15
33 #define QS_INVALID		16
34 #define QS_LEAKED		17
35 #define QS_FILTERED		18
36 #define QS_MAX			19
37 
38 /* too add: empty-as, peer-as, source-as, transit-as */
39 
40 #define QS_MASK_NEIGHBOR	((1 << QS_NEIGHBOR) | (1 << QS_GROUP))
41 #define QS_MASK_ADJRIB						\
42 	((1 << QS_NEIGHBOR) | (1 << QS_GROUP) |	(1 << QS_AS) |	\
43 	(1 << QS_PREFIX) | (1 << QS_COMMUNITY) |		\
44 	(1 << QS_EXTCOMMUNITY) | (1 << QS_LARGECOMMUNITY) |	\
45 	(1 << QS_AF) | (1 << QS_OVS) | (1 << QS_BEST) |		\
46 	(1 << QS_ALL) | (1 << QS_SHORTER) | (1 << QS_ERROR) |	\
47 	(1 << QS_AVS) | (1 << QS_INVALID) | (1 << QS_LEAKED) |	\
48 	(1 << QS_FILTERED))
49 
50 #define QS_MASK_RIB	(QS_MASK_ADJRIB | (1 << QS_RIB))
51 
52 struct cmd;
53 struct lg_ctx {
54 	const struct cmd	*command;
55 	unsigned int		qs_mask;
56 	unsigned int		qs_set;
57 	union {
58 		char	*string;
59 		int	one;
60 	}			qs_args[QS_MAX];
61 };
62 
63 extern char	*bgpctlpath;
64 extern char	*bgpctlsock;
65 
66 /* qs.c - query string handling */
67 int	parse_querystring(const char *, struct lg_ctx *);
68 size_t	qs_argv(char **, size_t, size_t, struct lg_ctx *, int);
69 
70 /* main entry points for slowcgi */
71 int	prep_request(struct lg_ctx *, const char *, const char *, const char *);
72 void	bgpctl_call(struct lg_ctx *);
73