xref: /openbsd/usr.bin/bgplg/bgplg.h (revision 09467b48)
1 /*	$OpenBSD: bgplg.h,v 1.16 2018/10/24 13:18:52 denis Exp $	*/
2 
3 /*
4  * Copyright (c) 2005, 2006 Reyk Floeter <reyk@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 #ifndef _BGPLG_H
20 #define _BGPLG_H
21 
22 #define NAME		"bgplg"
23 
24 #define BGPLG_TIMEOUT	60	/* 60 seconds */
25 
26 struct cmd {
27 	const char *name;
28 	int minargs;
29 	int maxargs;
30 	const char *args;
31 	char *earg[255];
32 	int (*func)(struct cmd *, char **);
33 };
34 
35 #define CMDS	{							\
36 	{ "show ip bgp", 1, 1, "&lt;prefix&gt;",			\
37 	    { BGPCTL, "show", "ip", "bgp", NULL } },			\
38 	{ "show ip bgp as", 1, 1, "&lt;asnum&gt;",			\
39 	    { BGPCTL, "show", "ip", "bgp", "as", NULL } },		\
40 	{ "show ip bgp source-as", 1, 1, "&lt;asnum&gt;",		\
41 	    { BGPCTL, "show", "ip", "bgp", "source-as", NULL } },	\
42 	{ "show ip bgp transit-as", 1, 1, "&lt;asnum&gt;",		\
43 	    { BGPCTL, "show", "ip", "bgp", "transit-as", NULL } },	\
44 	{ "show ip bgp peer-as", 1, 1, "&lt;asnum&gt;",			\
45 	    { BGPCTL, "show", "ip", "bgp", "peer-as", NULL } },		\
46 	{ "show ip bgp empty-as", 0, 0, NULL,				\
47 	    { BGPCTL, "show", "ip", "bgp", "empty-as", NULL } },	\
48 	{ "show ip bgp summary", 0, 0, NULL,				\
49 	    { BGPCTL, "show", "ip", "bgp", "summary", NULL } },		\
50 	{ "show ip bgp community", 1, 1, "&lt;community&gt;",		\
51 	    { BGPCTL, "show","ip", "bgp", "community", NULL } },	\
52 	{ "show ip bgp detail community", 1, 1, "&lt;community&gt;",	\
53 	    { BGPCTL, "show","ip", "bgp", "detail", "community", NULL } },\
54 	{ "show ip bgp ext-community", 2, 2, "&lt;ext-community&gt;",	\
55 	    { BGPCTL, "show","ip", "bgp", "ext-community", NULL } },	\
56 	{ "show ip bgp detail ext-community", 2, 2, "&lt;ext-community&gt;",\
57 	    { BGPCTL, "show","ip", "bgp", "detail", "ext-community", NULL } },\
58 	{ "show ip bgp large-community", 1, 1, "&lt;large-community&gt;",\
59 	    { BGPCTL, "show","ip", "bgp", "large-community", NULL } },	\
60 	{ "show ip bgp detail large-community", 1, 1, "&lt;large-community&gt;",\
61 	    { BGPCTL, "show","ip", "bgp", "detail", "large-community", NULL } },\
62 	{ "show ip bgp detail", 1, 1, "&lt;prefix&gt;",			\
63 	    { BGPCTL, "show","ip", "bgp", "detail", NULL } },		\
64 	{ "show ip bgp detail as", 1, 1, "&lt;asnum&gt;",		\
65 	    { BGPCTL, "show","ip", "bgp", "detail", "as", NULL } },	\
66 	{ "show ip bgp in", 1, 1, "&lt;neighbor&gt;",			\
67 	    { BGPCTL, "show","ip", "bgp", "in", "neighbor", NULL } },	\
68 	{ "show ip bgp out", 1, 1, "&lt;neighbor&gt;",			\
69 	    { BGPCTL, "show","ip", "bgp", "out", "neighbor", NULL } },	\
70 	{ "show ip bgp ovs", 1, 1, "&lt;state&gt;",			\
71 	    { BGPCTL, "show","ip", "bgp", "ovs", NULL } },		\
72 	{ "show ip bgp memory", 0, 0, NULL,				\
73 	    { BGPCTL, "show", "ip", "bgp", "memory", NULL } },		\
74 	{ "show neighbor", 0, 1, NULL,					\
75 	    { BGPCTL, "show", "neighbor", NULL } },			\
76 	{ "show nexthop", 0, 0, NULL,					\
77 	    { BGPCTL, "show", "nexthop", NULL } },			\
78 	{ "traceroute", 1, 1, "&lt;address&gt;",			\
79 	    { TRACEROUTE, "-ASl", NULL } },				\
80 	{ "ping", 1, 1, "&lt;address&gt;",				\
81 	    { PING, "-c4", "-w2", NULL } },				\
82 	{ "traceroute6", 1, 1, "&lt;address&gt;",			\
83 	    { TRACEROUTE6, "-Al", NULL } },				\
84 	{ "ping6", 1, 1, "&lt;address&gt;",				\
85 	    { PING6, "-c4", "-i2", NULL } },				\
86 	{ "help", 0, 0, NULL, { NULL }, lg_help },			\
87 	{ NULL }							\
88 }
89 
90 int	 lg_help(struct cmd *, char **);
91 int	 lg_exec(const char *, char **);
92 int	 lg_checkperm(struct cmd *);
93 void	 lg_sig_alarm(int);
94 ssize_t	 lg_strip(char *);
95 
96 #endif /* _BGPLG_H */
97