xref: /openbsd-src/usr.sbin/bgpctl/bgpctl.h (revision 25c4e8bd056e974b28f4a0ffd39d76c190a56013)
1 /*
2  * Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 struct parse_result;
18 
19 struct output {
20 	void	(*head)(struct parse_result *);
21 	void	(*neighbor)(struct peer *, struct parse_result *);
22 	void	(*timer)(struct ctl_timer *);
23 	void	(*fib)(struct kroute_full *);
24 	void	(*fib_table)(struct ktable *);
25 	void	(*nexthop)(struct ctl_show_nexthop *);
26 	void	(*interface)(struct ctl_show_interface *);
27 	void	(*attr)(u_char *, size_t, int, int);
28 	void	(*communities)(u_char *, size_t, struct parse_result *);
29 	void	(*rib)(struct ctl_show_rib *, u_char *, size_t,
30 		    struct parse_result *);
31 	void	(*rib_hash)(struct rde_hashstats *);
32 	void	(*rib_mem)(struct rde_memstats *);
33 	void	(*set)(struct ctl_show_set *);
34 	void	(*rtr)(struct ctl_show_rtr *);
35 	void	(*result)(u_int);
36 	void	(*tail)(void);
37 };
38 
39 extern const struct output show_output, json_output;
40 extern const size_t pt_sizes[];
41 
42 #define EOL0(flag)	((flag & F_CTL_SSV) ? ';' : '\n')
43 
44 time_t		 get_monotime(time_t);
45 char		*fmt_peer(const char *, const struct bgpd_addr *, int);
46 const char	*fmt_timeframe(time_t);
47 const char	*fmt_monotime(time_t);
48 const char	*fmt_fib_flags(uint16_t);
49 const char	*fmt_origin(uint8_t, int);
50 const char	*fmt_flags(uint32_t, int);
51 const char	*fmt_ovs(uint8_t, int);
52 const char	*fmt_auth_method(enum auth_method);
53 const char	*fmt_mem(long long);
54 const char	*fmt_errstr(uint8_t, uint8_t);
55 const char	*fmt_attr(uint8_t, int);
56 const char	*fmt_community(uint16_t, uint16_t);
57 const char	*fmt_large_community(uint32_t, uint32_t, uint32_t);
58 const char	*fmt_ext_community(uint8_t *);
59 const char	*fmt_set_type(struct ctl_show_set *);
60