blob: 5156dbf13436c3969a4779575527375a769e4e30 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
2 * Zebra configuration command interface routine
3 * Copyright (C) 1997, 98 Kunihiro Ishiguro
Everton Marques871dbcf2009-08-11 15:43:05 -03004 * Portions Copyright (c) 2008 Everton da Silva Marques <everton.marques@gmail.com>
paul718e3742002-12-13 20:15:29 +00005 *
6 * This file is part of GNU Zebra.
7 *
8 * GNU Zebra is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2, or (at your
11 * option) any later version.
12 *
13 * GNU Zebra is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with GNU Zebra; see the file COPYING. If not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
22 */
23
24#ifndef _ZEBRA_COMMAND_H
25#define _ZEBRA_COMMAND_H
26
27#include "vector.h"
28#include "vty.h"
Paul Jakma9c42a6e2006-06-27 07:52:03 +000029#include "lib/route_types.h"
paul718e3742002-12-13 20:15:29 +000030
31/* Host configuration variable */
32struct host
33{
34 /* Host name of this router. */
35 char *name;
36
37 /* Password for vty interface. */
38 char *password;
39 char *password_encrypt;
40
41 /* Enable password */
42 char *enable;
43 char *enable_encrypt;
44
45 /* System wide terminal lines. */
46 int lines;
47
48 /* Log filename. */
49 char *logfile;
50
paul718e3742002-12-13 20:15:29 +000051 /* config file name of this host */
52 char *config;
53
54 /* Flags for services */
55 int advanced;
56 int encrypt;
57
58 /* Banner configuration. */
hasso8c328f12004-10-05 21:01:23 +000059 const char *motd;
paul3b0c5d92005-03-08 10:43:43 +000060 char *motdfile;
paul718e3742002-12-13 20:15:29 +000061};
62
63/* There are some command levels which called from command node. */
64enum node_type
65{
66 AUTH_NODE, /* Authentication mode of vty interface. */
Paul Jakma62687ff2008-08-23 14:27:06 +010067 RESTRICTED_NODE, /* Restricted view mode */
paul718e3742002-12-13 20:15:29 +000068 VIEW_NODE, /* View node. Default mode of vty interface. */
69 AUTH_ENABLE_NODE, /* Authentication mode for change enable. */
70 ENABLE_NODE, /* Enable node. */
71 CONFIG_NODE, /* Config node. Default mode of config file. */
hassoe7168df2004-10-03 20:11:32 +000072 SERVICE_NODE, /* Service node. */
paul718e3742002-12-13 20:15:29 +000073 DEBUG_NODE, /* Debug node. */
74 AAA_NODE, /* AAA node. */
75 KEYCHAIN_NODE, /* Key-chain node. */
76 KEYCHAIN_KEY_NODE, /* Key-chain key node. */
77 INTERFACE_NODE, /* Interface mode node. */
78 ZEBRA_NODE, /* zebra connection node. */
79 TABLE_NODE, /* rtm_table selection node. */
80 RIP_NODE, /* RIP protocol mode node. */
81 RIPNG_NODE, /* RIPng protocol mode node. */
Paul Jakma57345092011-12-25 17:52:09 +010082 BABEL_NODE, /* Babel protocol mode node. */
paul718e3742002-12-13 20:15:29 +000083 BGP_NODE, /* BGP protocol mode which includes BGP4+ */
84 BGP_VPNV4_NODE, /* BGP MPLS-VPN PE exchange. */
85 BGP_IPV4_NODE, /* BGP IPv4 unicast address family. */
86 BGP_IPV4M_NODE, /* BGP IPv4 multicast address family. */
87 BGP_IPV6_NODE, /* BGP IPv6 address family */
paul1e836592005-08-22 22:39:56 +000088 BGP_IPV6M_NODE, /* BGP IPv6 multicast address family. */
paul718e3742002-12-13 20:15:29 +000089 OSPF_NODE, /* OSPF protocol mode */
90 OSPF6_NODE, /* OSPF protocol for IPv6 mode */
jardin9e867fe2003-12-23 08:56:18 +000091 ISIS_NODE, /* ISIS protocol mode */
Everton Marques871dbcf2009-08-11 15:43:05 -030092 PIM_NODE, /* PIM protocol mode */
paul718e3742002-12-13 20:15:29 +000093 MASC_NODE, /* MASC for multicast. */
94 IRDP_NODE, /* ICMP Router Discovery Protocol mode. */
95 IP_NODE, /* Static ip route node. */
96 ACCESS_NODE, /* Access list node. */
97 PREFIX_NODE, /* Prefix list node. */
98 ACCESS_IPV6_NODE, /* Access list node. */
99 PREFIX_IPV6_NODE, /* Prefix list node. */
100 AS_LIST_NODE, /* AS list node. */
101 COMMUNITY_LIST_NODE, /* Community list node. */
102 RMAP_NODE, /* Route map node. */
103 SMUX_NODE, /* SNMP configuration node. */
104 DUMP_NODE, /* Packet dump node. */
105 FORWARDING_NODE, /* IP forwarding node. */
Paul Jakma7514fb72007-05-02 16:05:35 +0000106 PROTOCOL_NODE, /* protocol filtering node */
Paul Jakma62687ff2008-08-23 14:27:06 +0100107 VTY_NODE, /* Vty node. */
paul718e3742002-12-13 20:15:29 +0000108};
109
110/* Node which has some commands and prompt string and configuration
111 function pointer . */
112struct cmd_node
113{
114 /* Node index. */
115 enum node_type node;
116
117 /* Prompt character at vty interface. */
hasso8c328f12004-10-05 21:01:23 +0000118 const char *prompt;
paul718e3742002-12-13 20:15:29 +0000119
120 /* Is this node's configuration goes to vtysh ? */
121 int vtysh;
122
123 /* Node's configuration write function */
124 int (*func) (struct vty *);
125
126 /* Vector of this node's command list. */
127 vector cmd_vector;
128};
129
paul406d6712004-10-22 12:27:44 +0000130enum
131{
paul9c5d8562005-03-08 15:56:42 +0000132 CMD_ATTR_DEPRECATED = 1,
paul406d6712004-10-22 12:27:44 +0000133 CMD_ATTR_HIDDEN,
134};
135
paul718e3742002-12-13 20:15:29 +0000136/* Structure of command element. */
137struct cmd_element
138{
hasso8c328f12004-10-05 21:01:23 +0000139 const char *string; /* Command specification by string. */
paul9035efa2004-10-10 11:56:56 +0000140 int (*func) (struct cmd_element *, struct vty *, int, const char *[]);
hasso8c328f12004-10-05 21:01:23 +0000141 const char *doc; /* Documentation of this command. */
paul718e3742002-12-13 20:15:29 +0000142 int daemon; /* Daemon to which this command belong. */
Christian Frankecd40b322013-09-30 12:27:51 +0000143 vector tokens; /* Vector of cmd_tokens */
paul406d6712004-10-22 12:27:44 +0000144 u_char attr; /* Command attributes */
paul718e3742002-12-13 20:15:29 +0000145};
146
Christian Frankecd40b322013-09-30 12:27:51 +0000147
148enum cmd_token_type
paul718e3742002-12-13 20:15:29 +0000149{
Christian Frankecd40b322013-09-30 12:27:51 +0000150 TOKEN_TERMINAL = 0,
151 TOKEN_MULTIPLE,
152 TOKEN_KEYWORD,
153};
154
155/* Command description structure. */
156struct cmd_token
157{
158 enum cmd_token_type type;
159
160 /* Used for type == MULTIPLE */
161 vector multiple; /* vector of cmd_token, type == FINAL */
162
163 /* Used for type == KEYWORD */
164 vector keyword; /* vector of vector of cmd_tokens */
165
166 /* Used for type == TERMINAL */
Chris Caputo228da422009-07-18 05:44:03 +0000167 char *cmd; /* Command string. */
Christian Frankecd40b322013-09-30 12:27:51 +0000168 char *desc; /* Command's description. */
paul718e3742002-12-13 20:15:29 +0000169};
170
171/* Return value of the commands. */
172#define CMD_SUCCESS 0
173#define CMD_WARNING 1
174#define CMD_ERR_NO_MATCH 2
175#define CMD_ERR_AMBIGUOUS 3
176#define CMD_ERR_INCOMPLETE 4
177#define CMD_ERR_EXEED_ARGC_MAX 5
178#define CMD_ERR_NOTHING_TODO 6
179#define CMD_COMPLETE_FULL_MATCH 7
180#define CMD_COMPLETE_MATCH 8
181#define CMD_COMPLETE_LIST_MATCH 9
182#define CMD_SUCCESS_DAEMON 10
183
184/* Argc max counts. */
185#define CMD_ARGC_MAX 25
186
187/* Turn off these macros when uisng cpp with extract.pl */
188#ifndef VTYSH_EXTRACT_PL
189
paul406d6712004-10-22 12:27:44 +0000190/* helper defines for end-user DEFUN* macros */
191#define DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \
paul718e3742002-12-13 20:15:29 +0000192 struct cmd_element cmdname = \
193 { \
paul9035efa2004-10-10 11:56:56 +0000194 .string = cmdstr, \
195 .func = funcname, \
paul406d6712004-10-22 12:27:44 +0000196 .doc = helpstr, \
197 .attr = attrs, \
198 .daemon = dnum, \
199 };
200
201#define DEFUN_CMD_FUNC_DECL(funcname) \
paul34204aa2005-11-03 09:00:23 +0000202 static int funcname (struct cmd_element *, struct vty *, int, const char *[]);
paul406d6712004-10-22 12:27:44 +0000203
204#define DEFUN_CMD_FUNC_TEXT(funcname) \
ajs274a4a42004-12-07 15:39:31 +0000205 static int funcname \
Paul Jakma6cf0cf02006-03-30 14:43:17 +0000206 (struct cmd_element *self __attribute__ ((unused)), \
207 struct vty *vty __attribute__ ((unused)), \
208 int argc __attribute__ ((unused)), \
209 const char *argv[] __attribute__ ((unused)) )
paul406d6712004-10-22 12:27:44 +0000210
Christian Frankecd40b322013-09-30 12:27:51 +0000211/* DEFUN for vty command interafce. Little bit hacky ;-).
212 *
213 * DEFUN(funcname, cmdname, cmdstr, helpstr)
214 *
215 * funcname
216 * ========
217 *
218 * Name of the function that will be defined.
219 *
220 * cmdname
221 * =======
222 *
223 * Name of the struct that will be defined for the command.
224 *
225 * cmdstr
226 * ======
227 *
228 * The cmdstr defines the command syntax. It is used by the vty subsystem
229 * and vtysh to perform matching and completion in the cli. So you have to take
230 * care to construct it adhering to the following grammar. The names used
231 * for the production rules losely represent the names used in lib/command.c
232 *
233 * cmdstr = cmd_token , { " " , cmd_token } ;
234 *
235 * cmd_token = cmd_terminal
236 * | cmd_multiple
237 * | cmd_keyword ;
238 *
239 * cmd_terminal_fixed = fixed_string
240 * | variable
241 * | range
242 * | ipv4
243 * | ipv4_prefix
244 * | ipv6
245 * | ipv6_prefix ;
246 *
247 * cmd_terminal = cmd_terminal_fixed
248 * | option
249 * | vararg ;
250 *
251 * multiple_part = cmd_terminal_fixed ;
252 * cmd_multiple = "(" , multiple_part , ( "|" | { "|" , multiple_part } ) , ")" ;
253 *
254 * keyword_part = fixed_string , { " " , ( cmd_terminal_fixed | cmd_multiple ) } ;
255 * cmd_keyword = "{" , keyword_part , { "|" , keyword_part } , "}" ;
256 *
257 * lowercase = "a" | ... | "z" ;
258 * uppercase = "A" | ... | "Z" ;
259 * digit = "0" | ... | "9" ;
260 * number = digit , { digit } ;
261 *
262 * fixed_string = (lowercase | digit) , { lowercase | digit | uppercase | "-" | "_" } ;
263 * variable = uppercase , { uppercase | "_" } ;
264 * range = "<" , number , "-" , number , ">" ;
265 * ipv4 = "A.B.C.D" ;
266 * ipv4_prefix = "A.B.C.D/M" ;
267 * ipv6 = "X:X::X:X" ;
268 * ipv6_prefix = "X:X::X:X/M" ;
269 * option = "[" , variable , "]" ;
270 * vararg = "." , variable ;
271 *
272 * To put that all in a textual description: A cmdstr is a sequence of tokens,
273 * separated by spaces.
274 *
275 * Terminal Tokens:
276 *
277 * A very simple cmdstring would be something like: "show ip bgp". It consists
278 * of three Terminal Tokens, each containing a fixed string. When this command
279 * is called, no arguments will be passed down to the function implementing it,
280 * as it only consists of fixed strings.
281 *
282 * Apart from fixed strings, Terminal Tokens can also contain variables:
283 * An example would be "show ip bgp A.B.C.D". This command expects an IPv4
284 * as argument. As this is a variable, the IP address entered by the user will
285 * be passed down as an argument. Apart from two exceptions, the other options
286 * for Terminal Tokens behave exactly as we just discussed and only make a
287 * difference for the CLI. The two exceptions will be discussed in the next
288 * paragraphs.
289 *
290 * A Terminal Token can contain a so called option match. This is a simple
291 * string variable that the user may omit. An example would be:
292 * "show interface [IFNAME]". If the user calls this without an interface as
293 * argument, no arguments will be passed down to the function implementing
294 * this command. Otherwise, the interface name will be provided to the function
295 * as a regular argument.
296
297 * Also, a Terminal Token can contain a so called vararg. This is used e.g. in
298 * "show ip bgp regexp .LINE". The last token is a vararg match and will
299 * consume all the arguments the user inputs on the command line and append
300 * those to the list of arguments passed down to the function implementing this
301 * command. (Therefore, it doesn't make much sense to have any tokens after a
302 * vararg because the vararg will already consume all the words the user entered
303 * in the CLI)
304 *
305 * Multiple Tokens:
306 *
307 * The Multiple Token type can be used if there are multiple possibilities what
308 * arguments may be used for a command, but it should map to the same function
309 * nonetheless. An example would be "ip route A.B.C.D/M (reject|blackhole)"
310 * In that case both "reject" and "blackhole" would be acceptable as last
311 * arguments. The words matched by Multiple Tokens are always added to the
312 * argument list, even if they are matched by fixed strings. Such a Multiple
313 * Token can contain almost any type of token that would also be acceptable
314 * for a Terminal Token, the exception are optional variables and varag.
315 *
316 * There is one special case that is used in some places of Quagga that should be
317 * pointed out here shortly. An example would be "password (8|) WORD". This
318 * construct is used to have fixed strings communicated as arguments. (The "8"
319 * will be passed down as an argument in this case) It does not mean that
320 * the "8" is optional. Another historic and possibly surprising property of
321 * this construct is that it consumes two parts of helpstr. (Help
322 * strings will be explained later)
323 *
324 * Keyword Tokens:
325 *
326 * There are commands that take a lot of different and possibly optional arguments.
327 * An example from ospf would be the "default-information originate" command. This
328 * command takes a lot of optional arguments that may be provided in any order.
329 * To accomodate such commands, the Keyword Token has been implemented.
330 * Using the keyword token, the "default-information originate" command and all
331 * its possible options can be represented using this single cmdstr:
332 * "default-information originate \
333 * {always|metric <0-16777214>|metric-type (1|2)|route-map WORD}"
334 *
335 * Keywords always start with a fixed string and may be followed by arguments.
336 * Except optional variables and vararg, everything is permitted here.
337 *
338 * For the special case of a keyword without arguments, either NULL or the
339 * keyword itself will be pushed as an argument, depending on whether the
340 * keyword is present.
341 * For the other keywords, arguments will be only pushed for
342 * variables/Multiple Tokens. If the keyword is not present, the arguments that
343 * would have been pushed will be substituted by NULL.
344 *
345 * A few examples:
346 * "default information originate metric-type 1 metric 1000"
347 * would yield the following arguments:
348 * { NULL, "1000", "1", NULL }
349 *
350 * "default information originate always route-map RMAP-DEFAULT"
351 * would yield the following arguments:
352 * { "always", NULL, NULL, "RMAP-DEFAULT" }
353 *
354 * helpstr
355 * =======
356 *
357 * The helpstr is used to show a short explantion for the commands that
358 * are available when the user presses '?' on the CLI. It is the concatenation
359 * of the helpstrings for all the tokens that make up the command.
360 *
361 * There should be one helpstring for each token in the cmdstr except those
362 * containing other tokens, like Multiple or Keyword Tokens. For those, there
363 * will only be the helpstrings of the contained tokens.
364 *
365 * The individual helpstrings are expected to be in the same order as their
366 * respective Tokens appear in the cmdstr. They should each be terminated with
367 * a linefeed. The last helpstring should be terminated with a linefeed as well.
368 *
369 * Care should also be taken to avoid having similar tokens with different
370 * helpstrings. Imagine e.g. the commands "show ip ospf" and "show ip bgp".
371 * they both contain a helpstring for "show", but only one will be displayed
372 * when the user enters "sh?". If those two helpstrings differ, it is not
373 * defined which one will be shown and the behavior is therefore unpredictable.
374 */
paul406d6712004-10-22 12:27:44 +0000375#define DEFUN(funcname, cmdname, cmdstr, helpstr) \
376 DEFUN_CMD_FUNC_DECL(funcname) \
377 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \
378 DEFUN_CMD_FUNC_TEXT(funcname)
379
380#define DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
381 DEFUN_CMD_FUNC_DECL(funcname) \
382 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \
383 DEFUN_CMD_FUNC_TEXT(funcname)
384
385#define DEFUN_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
386 DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN)
387
388#define DEFUN_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \
hasso2557aed2004-11-28 21:16:20 +0000389 DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED) \
paul718e3742002-12-13 20:15:29 +0000390
391/* DEFUN_NOSH for commands that vtysh should ignore */
392#define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \
393 DEFUN(funcname, cmdname, cmdstr, helpstr)
394
395/* DEFSH for vtysh. */
396#define DEFSH(daemon, cmdname, cmdstr, helpstr) \
paul406d6712004-10-22 12:27:44 +0000397 DEFUN_CMD_ELEMENT(NULL, cmdname, cmdstr, helpstr, 0, daemon) \
paul718e3742002-12-13 20:15:29 +0000398
399/* DEFUN + DEFSH */
400#define DEFUNSH(daemon, funcname, cmdname, cmdstr, helpstr) \
paul406d6712004-10-22 12:27:44 +0000401 DEFUN_CMD_FUNC_DECL(funcname) \
402 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon) \
403 DEFUN_CMD_FUNC_TEXT(funcname)
paul718e3742002-12-13 20:15:29 +0000404
ajs274a4a42004-12-07 15:39:31 +0000405/* DEFUN + DEFSH with attributes */
406#define DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, attr) \
407 DEFUN_CMD_FUNC_DECL(funcname) \
408 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, daemon) \
409 DEFUN_CMD_FUNC_TEXT(funcname)
410
411#define DEFUNSH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \
412 DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN)
413
414#define DEFUNSH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \
415 DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED)
416
paul718e3742002-12-13 20:15:29 +0000417/* ALIAS macro which define existing command's alias. */
418#define ALIAS(funcname, cmdname, cmdstr, helpstr) \
paul406d6712004-10-22 12:27:44 +0000419 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0)
420
421#define ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
ajs274a4a42004-12-07 15:39:31 +0000422 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0)
paul406d6712004-10-22 12:27:44 +0000423
424#define ALIAS_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
425 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, 0)
426
427#define ALIAS_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \
428 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, 0)
paul718e3742002-12-13 20:15:29 +0000429
ajs274a4a42004-12-07 15:39:31 +0000430#define ALIAS_SH(daemon, funcname, cmdname, cmdstr, helpstr) \
431 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon)
432
433#define ALIAS_SH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \
434 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, daemon)
435
436#define ALIAS_SH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \
437 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, daemon)
438
paul718e3742002-12-13 20:15:29 +0000439#endif /* VTYSH_EXTRACT_PL */
440
441/* Some macroes */
442#define CMD_OPTION(S) ((S[0]) == '[')
443#define CMD_VARIABLE(S) (((S[0]) >= 'A' && (S[0]) <= 'Z') || ((S[0]) == '<'))
444#define CMD_VARARG(S) ((S[0]) == '.')
445#define CMD_RANGE(S) ((S[0] == '<'))
446
447#define CMD_IPV4(S) ((strcmp ((S), "A.B.C.D") == 0))
448#define CMD_IPV4_PREFIX(S) ((strcmp ((S), "A.B.C.D/M") == 0))
449#define CMD_IPV6(S) ((strcmp ((S), "X:X::X:X") == 0))
450#define CMD_IPV6_PREFIX(S) ((strcmp ((S), "X:X::X:X/M") == 0))
451
452/* Common descriptions. */
453#define SHOW_STR "Show running system information\n"
454#define IP_STR "IP information\n"
455#define IPV6_STR "IPv6 information\n"
456#define NO_STR "Negate a command or set its defaults\n"
Paul Jakma9c42a6e2006-06-27 07:52:03 +0000457#define REDIST_STR "Redistribute information from another routing protocol\n"
paul718e3742002-12-13 20:15:29 +0000458#define CLEAR_STR "Reset functions\n"
459#define RIP_STR "RIP information\n"
460#define BGP_STR "BGP information\n"
461#define OSPF_STR "OSPF information\n"
462#define NEIGHBOR_STR "Specify neighbor router\n"
463#define DEBUG_STR "Debugging functions (see also 'undebug')\n"
464#define UNDEBUG_STR "Disable debugging functions (see also 'debug')\n"
465#define ROUTER_STR "Enable a routing process\n"
466#define AS_STR "AS number\n"
467#define MBGP_STR "MBGP information\n"
468#define MATCH_STR "Match values from routing table\n"
469#define SET_STR "Set values in destination routing protocol\n"
470#define OUT_STR "Filter outgoing routing updates\n"
471#define IN_STR "Filter incoming routing updates\n"
472#define V4NOTATION_STR "specify by IPv4 address notation(e.g. 0.0.0.0)\n"
473#define OSPF6_NUMBER_STR "Specify by number\n"
474#define INTERFACE_STR "Interface infomation\n"
475#define IFNAME_STR "Interface name(e.g. ep0)\n"
476#define IP6_STR "IPv6 Information\n"
477#define OSPF6_STR "Open Shortest Path First (OSPF) for IPv6\n"
478#define OSPF6_ROUTER_STR "Enable a routing process\n"
479#define OSPF6_INSTANCE_STR "<1-65535> Instance ID\n"
480#define SECONDS_STR "<1-65535> Seconds\n"
481#define ROUTE_STR "Routing Table\n"
482#define PREFIX_LIST_STR "Build a prefix list\n"
483#define OSPF6_DUMP_TYPE_LIST \
484"(neighbor|interface|area|lsa|zebra|config|dbex|spf|route|lsdb|redistribute|hook|asbr|prefix|abr)"
jardin9e867fe2003-12-23 08:56:18 +0000485#define ISIS_STR "IS-IS information\n"
486#define AREA_TAG_STR "[area tag]\n"
paul718e3742002-12-13 20:15:29 +0000487
488#define CONF_BACKUP_EXT ".sav"
489
490/* IPv4 only machine should not accept IPv6 address for peer's IP
491 address. So we replace VTY command string like below. */
492#ifdef HAVE_IPV6
493#define NEIGHBOR_CMD "neighbor (A.B.C.D|X:X::X:X) "
494#define NO_NEIGHBOR_CMD "no neighbor (A.B.C.D|X:X::X:X) "
495#define NEIGHBOR_ADDR_STR "Neighbor address\nIPv6 address\n"
496#define NEIGHBOR_CMD2 "neighbor (A.B.C.D|X:X::X:X|WORD) "
497#define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|X:X::X:X|WORD) "
498#define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor IPv6 address\nNeighbor tag\n"
499#else
500#define NEIGHBOR_CMD "neighbor A.B.C.D "
501#define NO_NEIGHBOR_CMD "no neighbor A.B.C.D "
502#define NEIGHBOR_ADDR_STR "Neighbor address\n"
503#define NEIGHBOR_CMD2 "neighbor (A.B.C.D|WORD) "
504#define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|WORD) "
505#define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor tag\n"
506#endif /* HAVE_IPV6 */
507
508/* Prototypes. */
paul8cc41982005-05-06 21:25:49 +0000509extern void install_node (struct cmd_node *, int (*) (struct vty *));
510extern void install_default (enum node_type);
511extern void install_element (enum node_type, struct cmd_element *);
paul718e3742002-12-13 20:15:29 +0000512
ajsf6834d42005-01-28 20:28:35 +0000513/* Concatenates argv[shift] through argv[argc-1] into a single NUL-terminated
514 string with a space between each element (allocated using
515 XMALLOC(MTYPE_TMP)). Returns NULL if shift >= argc. */
paul8cc41982005-05-06 21:25:49 +0000516extern char *argv_concat (const char **argv, int argc, int shift);
ajsf6834d42005-01-28 20:28:35 +0000517
paul8cc41982005-05-06 21:25:49 +0000518extern vector cmd_make_strvec (const char *);
519extern void cmd_free_strvec (vector);
520extern vector cmd_describe_command (vector, struct vty *, int *status);
521extern char **cmd_complete_command (vector, struct vty *, int *status);
522extern const char *cmd_prompt (enum node_type);
Steve Hillea555002009-07-28 16:36:14 -0400523extern int config_from_file (struct vty *, FILE *, unsigned int *line_num);
paul8cc41982005-05-06 21:25:49 +0000524extern enum node_type node_parent (enum node_type);
525extern int cmd_execute_command (vector, struct vty *, struct cmd_element **, int);
526extern int cmd_execute_command_strict (vector, struct vty *, struct cmd_element **);
paul8cc41982005-05-06 21:25:49 +0000527extern void cmd_init (int);
Chris Caputo228da422009-07-18 05:44:03 +0000528extern void cmd_terminate (void);
paul718e3742002-12-13 20:15:29 +0000529
530/* Export typical functions. */
531extern struct cmd_element config_end_cmd;
532extern struct cmd_element config_exit_cmd;
533extern struct cmd_element config_quit_cmd;
534extern struct cmd_element config_help_cmd;
535extern struct cmd_element config_list_cmd;
paul8cc41982005-05-06 21:25:49 +0000536extern char *host_config_file (void);
537extern void host_config_set (char *);
paul718e3742002-12-13 20:15:29 +0000538
paul8cc41982005-05-06 21:25:49 +0000539extern void print_version (const char *);
Paul Jakma86228fd2006-03-30 15:00:30 +0000540
541/* struct host global, ick */
542extern struct host host;
Chris Caputo228da422009-07-18 05:44:03 +0000543
544/* "<cr>" global */
545extern char *command_cr;
paul718e3742002-12-13 20:15:29 +0000546#endif /* _ZEBRA_COMMAND_H */