xref: /openbsd/usr.sbin/bgpctl/bgpctl.h (revision 3bef86f7)
1 /*	$OpenBSD: bgpctl.h,v 1.22 2024/01/25 09:54:21 claudio Exp $ */
2 
3 /*
4  * Copyright (c) 2019 Claudio Jeker <claudio@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 struct parse_result;
20 
21 struct output {
22 	void	(*head)(struct parse_result *);
23 	void	(*neighbor)(struct peer *, struct parse_result *);
24 	void	(*timer)(struct ctl_timer *);
25 	void	(*fib)(struct kroute_full *);
26 	void	(*fib_table)(struct ktable *);
27 	void	(*flowspec)(struct flowspec *);
28 	void	(*nexthop)(struct ctl_show_nexthop *);
29 	void	(*interface)(struct ctl_show_interface *);
30 	void	(*attr)(u_char *, size_t, int, int);
31 	void	(*communities)(struct ibuf *, struct parse_result *);
32 	void	(*rib)(struct ctl_show_rib *, u_char *, size_t,
33 		    struct parse_result *);
34 	void	(*rib_mem)(struct rde_memstats *);
35 	void	(*set)(struct ctl_show_set *);
36 	void	(*rtr)(struct ctl_show_rtr *);
37 	void	(*result)(u_int);
38 	void	(*tail)(void);
39 };
40 
41 extern const struct output show_output, json_output, ometric_output;
42 
43 #define EOL0(flag)	((flag & F_CTL_SSV) ? ';' : '\n')
44 
45 time_t		 get_monotime(time_t);
46 char		*fmt_peer(const char *, const struct bgpd_addr *, int);
47 const char	*fmt_timeframe(time_t);
48 const char	*fmt_monotime(time_t);
49 const char	*fmt_fib_flags(uint16_t);
50 const char	*fmt_origin(uint8_t, int);
51 const char	*fmt_flags(uint32_t, int);
52 const char	*fmt_ovs(uint8_t, int);
53 const char	*fmt_avs(uint8_t, int);
54 const char	*fmt_auth_method(enum auth_method);
55 const char	*fmt_mem(long long);
56 const char	*fmt_errstr(uint8_t, uint8_t);
57 const char	*fmt_attr(uint8_t, int);
58 const char	*fmt_community(uint16_t, uint16_t);
59 const char	*fmt_large_community(uint32_t, uint32_t, uint32_t);
60 const char	*fmt_ext_community(uint64_t);
61 const char	*fmt_set_type(struct ctl_show_set *);
62 
63 #define MPLS_LABEL_OFFSET 12
64