xref: /openbsd-src/usr.sbin/bgpctl/parser.h (revision b99ef4df7fac99f3475b694d6cd4990521c99ae6)
1 /*	$OpenBSD: parser.h,v 1.39 2020/12/30 07:31:19 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_RIB_MEM,
37 	SHOW_NEXTHOP,
38 	SHOW_INTERFACE,
39 	RELOAD,
40 	FIB,
41 	FIB_COUPLE,
42 	FIB_DECOUPLE,
43 	LOG_VERBOSE,
44 	LOG_BRIEF,
45 	NEIGHBOR,
46 	NEIGHBOR_UP,
47 	NEIGHBOR_DOWN,
48 	NEIGHBOR_CLEAR,
49 	NEIGHBOR_RREFRESH,
50 	NEIGHBOR_DESTROY,
51 	NETWORK_ADD,
52 	NETWORK_REMOVE,
53 	NETWORK_FLUSH,
54 	NETWORK_SHOW,
55 	NETWORK_MRT,
56 	NETWORK_BULK_ADD,
57 	NETWORK_BULK_REMOVE
58 };
59 
60 struct parse_result {
61 	struct bgpd_addr	 addr;
62 	struct bgpd_addr	 peeraddr;
63 	struct filter_as	 as;
64 	struct filter_set_head	 set;
65 	struct community	 community;
66 	char			 peerdesc[PEER_DESCR_LEN];
67 	char			 rib[PEER_DESCR_LEN];
68 	char			 reason[REASON_LEN];
69 	const char		*ext_comm_subtype;
70 	u_int64_t		 rd;
71 	int			 flags;
72 	int			 is_group;
73 	u_int8_t		 validation_state;
74 	u_int			 rtableid;
75 	enum actions		 action;
76 	u_int8_t		 prefixlen;
77 	u_int8_t		 aid;
78 	int			 mrtfd;
79 };
80 
81 __dead void		 usage(void);
82 struct parse_result	*parse(int, char *[]);
83 int			 parse_prefix(const char *, size_t, struct bgpd_addr *,
84 			     u_int8_t *);
85