xref: /openbsd-src/usr.bin/bgplg/bgplg.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /*	$OpenBSD: bgplg.h,v 1.10 2013/06/01 18:47:55 reyk 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 #define BRIEF		"a looking glass for OpenBGPD"
24 #define COPYRIGHT	"2005, 2006 Reyk Floeter (reyk@openbsd.org)"
25 
26 #define BGPLG_TIMEOUT	60	/* 60 seconds */
27 
28 struct cmd {
29 	const char *name;
30 	int minargs;
31 	int maxargs;
32 	const char *args;
33 	char *earg[255];
34 	int (*func)(struct cmd *, char **);
35 };
36 
37 #define CMDS	{							\
38 	{ "show ip bgp", 1, 1, "&lt;prefix&gt;",			\
39 	    { BGPCTL, "show", "ip", "bgp", NULL } },			\
40 	{ "show ip bgp as", 1, 1, "&lt;asnum&gt;",			\
41 	    { BGPCTL, "show", "ip", "bgp", "as", NULL } },		\
42 	{ "show ip bgp source-as", 1, 1, "&lt;asnum&gt;",		\
43 	    { BGPCTL, "show", "ip", "bgp", "source-as", NULL } },	\
44 	{ "show ip bgp transit-as", 1, 1, "&lt;asnum&gt;",		\
45 	    { BGPCTL, "show", "ip", "bgp", "transit-as", NULL } },	\
46 	{ "show ip bgp peer-as", 1, 1, "&lt;asnum&gt;",			\
47 	    { BGPCTL, "show", "ip", "bgp", "peer-as", NULL } },		\
48 	{ "show ip bgp empty-as", 0, 0, NULL,				\
49 	    { BGPCTL, "show", "ip", "bgp", "empty-as", NULL } },	\
50 	{ "show ip bgp summary", 0, 0, NULL,				\
51 	    { BGPCTL, "show", "ip", "bgp", "summary", NULL } },		\
52 	{ "show ip bgp detail", 1, 1, "&lt;prefix&gt;",			\
53 	    { BGPCTL, "show","ip", "bgp", "detail", NULL } },		\
54 	{ "show ip bgp in", 1, 1, "&lt;prefix&gt;",			\
55 	    { BGPCTL, "show","ip", "bgp", "in", NULL } },		\
56 	{ "show ip bgp out", 1, 1, "&lt;prefix&gt;",			\
57 	    { BGPCTL, "show","ip", "bgp", "out", NULL } },		\
58 	{ "show ip bgp memory", 0, 0, NULL,				\
59 	    { BGPCTL, "show", "ip", "bgp", "memory", NULL } },		\
60 	{ "show neighbor", 0, 1, NULL,					\
61 	    { BGPCTL, "show", "neighbor", NULL } },			\
62 	{ "show nexthop", 0, 0, NULL,					\
63 	    { BGPCTL, "show", "nexthop", NULL } },			\
64 	{ "show version", 0, 0, NULL, { NULL }, lg_show_version },	\
65 	{ "traceroute", 1, 1, "&lt;address&gt;",			\
66 	    { TRACEROUTE, "-ASl", NULL } },				\
67 	{ "ping", 1, 1, "&lt;address&gt;",				\
68 	    { PING, "-c4", "-w2", NULL } },				\
69 	{ "traceroute6", 1, 1, "&lt;address&gt;",			\
70 	    { TRACEROUTE6, "-Al", NULL } },				\
71 	{ "ping6", 1, 1, "&lt;address&gt;",				\
72 	    { PING6, "-c4", "-i2", NULL } },				\
73 	{ "help", 0, 0, NULL, { NULL }, lg_help },			\
74 	{ NULL }							\
75 }
76 
77 int	 lg_show_version(struct cmd *, char **);
78 int	 lg_help(struct cmd *, char **);
79 int	 lg_exec(const char *, char **);
80 int	 lg_checkperm(struct cmd *);
81 void	 lg_sig_alarm(int);
82 ssize_t	 lg_strip(char *);
83 
84 #endif /* _BGPLG_H */
85