xref: /openbsd-src/usr.sbin/bgpctl/bgpctl.h (revision dd147aaac087d3efcea9a38926f4fcaa6835723e)
1*dd147aaaSclaudio /*	$OpenBSD: bgpctl.h,v 1.24 2024/01/31 11:23:20 claudio Exp $ */
20c7a5c38Sclaudio 
36671ac0bSclaudio /*
46671ac0bSclaudio  * Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
56671ac0bSclaudio  *
66671ac0bSclaudio  * Permission to use, copy, modify, and distribute this software for any
76671ac0bSclaudio  * purpose with or without fee is hereby granted, provided that the above
86671ac0bSclaudio  * copyright notice and this permission notice appear in all copies.
96671ac0bSclaudio  *
106671ac0bSclaudio  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
116671ac0bSclaudio  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
126671ac0bSclaudio  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
136671ac0bSclaudio  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
146671ac0bSclaudio  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
156671ac0bSclaudio  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
166671ac0bSclaudio  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
176671ac0bSclaudio  */
186671ac0bSclaudio 
196671ac0bSclaudio struct parse_result;
206671ac0bSclaudio 
21d30a810dSclaudio struct output {
22d30a810dSclaudio 	void	(*head)(struct parse_result *);
23d30a810dSclaudio 	void	(*neighbor)(struct peer *, struct parse_result *);
24d30a810dSclaudio 	void	(*timer)(struct ctl_timer *);
25d30a810dSclaudio 	void	(*fib)(struct kroute_full *);
26d30a810dSclaudio 	void	(*fib_table)(struct ktable *);
275fed6b04Sclaudio 	void	(*flowspec)(struct flowspec *);
28d30a810dSclaudio 	void	(*nexthop)(struct ctl_show_nexthop *);
29d30a810dSclaudio 	void	(*interface)(struct ctl_show_interface *);
30*dd147aaaSclaudio 	void	(*attr)(struct ibuf *, int, int);
314b4c1963Sclaudio 	void	(*communities)(struct ibuf *, struct parse_result *);
3246d5331aSclaudio 	void	(*rib)(struct ctl_show_rib *, struct ibuf *,
33d30a810dSclaudio 		    struct parse_result *);
34d30a810dSclaudio 	void	(*rib_mem)(struct rde_memstats *);
35413f97b7Sclaudio 	void	(*set)(struct ctl_show_set *);
3669d2b5abSclaudio 	void	(*rtr)(struct ctl_show_rtr *);
37d30a810dSclaudio 	void	(*result)(u_int);
38d30a810dSclaudio 	void	(*tail)(void);
39d30a810dSclaudio };
40d30a810dSclaudio 
4177a10e6fSclaudio extern const struct output show_output, json_output, ometric_output;
426671ac0bSclaudio 
436671ac0bSclaudio #define EOL0(flag)	((flag & F_CTL_SSV) ? ';' : '\n')
446671ac0bSclaudio 
45fd18fec4Sclaudio time_t		 get_monotime(time_t);
4604d0a88fSclaudio char		*fmt_peer(const char *, const struct bgpd_addr *, int);
476671ac0bSclaudio const char	*fmt_timeframe(time_t);
48e67b1a58Sclaudio const char	*fmt_monotime(time_t);
4959154960Sclaudio const char	*fmt_fib_flags(uint16_t);
5059154960Sclaudio const char	*fmt_origin(uint8_t, int);
512953a2c1Sclaudio const char	*fmt_flags(uint32_t, int);
5259154960Sclaudio const char	*fmt_ovs(uint8_t, int);
5350d35cacSclaudio const char	*fmt_avs(uint8_t, int);
5404d0a88fSclaudio const char	*fmt_auth_method(enum auth_method);
5504d0a88fSclaudio const char	*fmt_mem(long long);
5659154960Sclaudio const char	*fmt_errstr(uint8_t, uint8_t);
5759154960Sclaudio const char	*fmt_attr(uint8_t, int);
5859154960Sclaudio const char	*fmt_community(uint16_t, uint16_t);
5959154960Sclaudio const char	*fmt_large_community(uint32_t, uint32_t, uint32_t);
604b4c1963Sclaudio const char	*fmt_ext_community(uint64_t);
61413f97b7Sclaudio const char	*fmt_set_type(struct ctl_show_set *);
621edf3470Sclaudio 
631edf3470Sclaudio #define MPLS_LABEL_OFFSET 12
64