xref: /openbsd-src/usr.sbin/bgpctl/parser.h (revision e3925e28cbf61bb78e9144808b109285054a9ab4)
1*e3925e28Sclaudio /*	$OpenBSD: parser.h,v 1.46 2023/04/21 09:12:41 claudio Exp $ */
2acd8015aShenning 
3acd8015aShenning /*
4acd8015aShenning  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
5acd8015aShenning  *
6acd8015aShenning  * Permission to use, copy, modify, and distribute this software for any
7acd8015aShenning  * purpose with or without fee is hereby granted, provided that the above
8acd8015aShenning  * copyright notice and this permission notice appear in all copies.
9acd8015aShenning  *
10acd8015aShenning  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11acd8015aShenning  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12acd8015aShenning  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13acd8015aShenning  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14acd8015aShenning  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15acd8015aShenning  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16acd8015aShenning  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17acd8015aShenning  */
18acd8015aShenning 
19acd8015aShenning #include <sys/types.h>
20acd8015aShenning 
21acd8015aShenning #include "bgpd.h"
22acd8015aShenning 
23acd8015aShenning enum actions {
24acd8015aShenning 	NONE,
25acd8015aShenning 	SHOW,
26acd8015aShenning 	SHOW_SUMMARY,
2716fcf8d2Shenning 	SHOW_SUMMARY_TERSE,
28acd8015aShenning 	SHOW_NEIGHBOR,
29acd8015aShenning 	SHOW_NEIGHBOR_TIMERS,
305901a216Sclaudio 	SHOW_NEIGHBOR_TERSE,
31acd8015aShenning 	SHOW_FIB,
327f410e5eSclaudio 	SHOW_FIB_TABLES,
337b6c56a0Sclaudio 	SHOW_RIB,
34a20554fdSclaudio 	SHOW_MRT,
35413f97b7Sclaudio 	SHOW_SET,
3669d2b5abSclaudio 	SHOW_RTR,
376c34dfd1Sclaudio 	SHOW_RIB_MEM,
38acd8015aShenning 	SHOW_NEXTHOP,
39acd8015aShenning 	SHOW_INTERFACE,
40cbe08412Sclaudio 	SHOW_METRICS,
41acd8015aShenning 	RELOAD,
42acd8015aShenning 	FIB,
43acd8015aShenning 	FIB_COUPLE,
44acd8015aShenning 	FIB_DECOUPLE,
45c3319070Sclaudio 	LOG_VERBOSE,
46c3319070Sclaudio 	LOG_BRIEF,
47acd8015aShenning 	NEIGHBOR,
48acd8015aShenning 	NEIGHBOR_UP,
49a4cb7d77Sclaudio 	NEIGHBOR_DOWN,
50e5f05614Shenning 	NEIGHBOR_CLEAR,
51846ad25aShenning 	NEIGHBOR_RREFRESH,
5207820ff6Sclaudio 	NEIGHBOR_DESTROY,
53a4cb7d77Sclaudio 	NETWORK_ADD,
54a4cb7d77Sclaudio 	NETWORK_REMOVE,
55a4cb7d77Sclaudio 	NETWORK_FLUSH,
563503d06eShenning 	NETWORK_SHOW,
57f486926aSclaudio 	NETWORK_MRT,
580ac5a32aSphessler 	NETWORK_BULK_ADD,
595fed6b04Sclaudio 	NETWORK_BULK_REMOVE,
605fed6b04Sclaudio 	FLOWSPEC_ADD,
615fed6b04Sclaudio 	FLOWSPEC_REMOVE,
625fed6b04Sclaudio 	FLOWSPEC_FLUSH,
635fed6b04Sclaudio 	FLOWSPEC_SHOW,
64acd8015aShenning };
65acd8015aShenning 
66acd8015aShenning struct parse_result {
67fd71c51dShenning 	struct bgpd_addr	 addr;
68f72661b1Sclaudio 	struct bgpd_addr	 peeraddr;
69fd71c51dShenning 	struct filter_as	 as;
709caec0aeSclaudio 	struct filter_set_head	 set;
710ca99656Sclaudio 	struct community	 community;
72d936e96dSclaudio 	char			 peerdesc[PEER_DESCR_LEN];
73a9a0337fSclaudio 	char			 rib[PEER_DESCR_LEN];
74a78f83ceSderaadt 	char			 reason[REASON_LEN];
75a73789d3Sclaudio 	const char		*ext_comm_subtype;
7659154960Sclaudio 	uint64_t		 rd;
77d936e96dSclaudio 	int			 flags;
78903de74aSclaudio 	int			 is_group;
79*e3925e28Sclaudio 	int			 mrtfd;
807f410e5eSclaudio 	u_int			 rtableid;
8159154960Sclaudio 	uint32_t		 pathid;
82d936e96dSclaudio 	enum actions		 action;
8359154960Sclaudio 	uint8_t			 validation_state;
8459154960Sclaudio 	uint8_t			 prefixlen;
8559154960Sclaudio 	uint8_t			 aid;
86*e3925e28Sclaudio 	struct flowstate	{
87*e3925e28Sclaudio 		struct bgpd_addr	src;
88*e3925e28Sclaudio 		struct bgpd_addr	dst;
89*e3925e28Sclaudio 		uint8_t			*components[FLOWSPEC_TYPE_MAX];
90*e3925e28Sclaudio 		uint16_t		complen[FLOWSPEC_TYPE_MAX];
91*e3925e28Sclaudio 		uint8_t			srclen;
92*e3925e28Sclaudio 		uint8_t			dstlen;
93*e3925e28Sclaudio 	}			flow;
94acd8015aShenning };
95acd8015aShenning 
962302052bShenning __dead void		 usage(void);
97acd8015aShenning struct parse_result	*parse(int, char *[]);
989fef0798Sphessler int			 parse_prefix(const char *, size_t, struct bgpd_addr *,
9959154960Sclaudio 			     uint8_t *);
100