xref: /openbsd/usr.sbin/bgpctl/parser.h (revision e3925e28)
1 /*	$OpenBSD: parser.h,v 1.46 2023/04/21 09:12:41 claudio Exp $ */
2 
3 /*
4  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #include <sys/types.h>
20 
21 #include "bgpd.h"
22 
23 enum actions {
24 	NONE,
25 	SHOW,
26 	SHOW_SUMMARY,
27 	SHOW_SUMMARY_TERSE,
28 	SHOW_NEIGHBOR,
29 	SHOW_NEIGHBOR_TIMERS,
30 	SHOW_NEIGHBOR_TERSE,
31 	SHOW_FIB,
32 	SHOW_FIB_TABLES,
33 	SHOW_RIB,
34 	SHOW_MRT,
35 	SHOW_SET,
36 	SHOW_RTR,
37 	SHOW_RIB_MEM,
38 	SHOW_NEXTHOP,
39 	SHOW_INTERFACE,
40 	SHOW_METRICS,
41 	RELOAD,
42 	FIB,
43 	FIB_COUPLE,
44 	FIB_DECOUPLE,
45 	LOG_VERBOSE,
46 	LOG_BRIEF,
47 	NEIGHBOR,
48 	NEIGHBOR_UP,
49 	NEIGHBOR_DOWN,
50 	NEIGHBOR_CLEAR,
51 	NEIGHBOR_RREFRESH,
52 	NEIGHBOR_DESTROY,
53 	NETWORK_ADD,
54 	NETWORK_REMOVE,
55 	NETWORK_FLUSH,
56 	NETWORK_SHOW,
57 	NETWORK_MRT,
58 	NETWORK_BULK_ADD,
59 	NETWORK_BULK_REMOVE,
60 	FLOWSPEC_ADD,
61 	FLOWSPEC_REMOVE,
62 	FLOWSPEC_FLUSH,
63 	FLOWSPEC_SHOW,
64 };
65 
66 struct parse_result {
67 	struct bgpd_addr	 addr;
68 	struct bgpd_addr	 peeraddr;
69 	struct filter_as	 as;
70 	struct filter_set_head	 set;
71 	struct community	 community;
72 	char			 peerdesc[PEER_DESCR_LEN];
73 	char			 rib[PEER_DESCR_LEN];
74 	char			 reason[REASON_LEN];
75 	const char		*ext_comm_subtype;
76 	uint64_t		 rd;
77 	int			 flags;
78 	int			 is_group;
79 	int			 mrtfd;
80 	u_int			 rtableid;
81 	uint32_t		 pathid;
82 	enum actions		 action;
83 	uint8_t			 validation_state;
84 	uint8_t			 prefixlen;
85 	uint8_t			 aid;
86 	struct flowstate	{
87 		struct bgpd_addr	src;
88 		struct bgpd_addr	dst;
89 		uint8_t			*components[FLOWSPEC_TYPE_MAX];
90 		uint16_t		complen[FLOWSPEC_TYPE_MAX];
91 		uint8_t			srclen;
92 		uint8_t			dstlen;
93 	}			flow;
94 };
95 
96 __dead void		 usage(void);
97 struct parse_result	*parse(int, char *[]);
98 int			 parse_prefix(const char *, size_t, struct bgpd_addr *,
99 			     uint8_t *);
100