]> git.proxmox.com Git - mirror_frr.git/blame - lib/command.h
vtysh: fix oversight in vtysh buffer rewrite
[mirror_frr.git] / lib / command.h
CommitLineData
718e3744 1/*
2 * Zebra configuration command interface routine
3 * Copyright (C) 1997, 98 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2, or (at your
10 * option) any later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23#ifndef _ZEBRA_COMMAND_H
24#define _ZEBRA_COMMAND_H
25
26#include "vector.h"
27#include "vty.h"
9c42a6eb 28#include "lib/route_types.h"
4a1ab8e4
DL
29#include "memory.h"
30
31DECLARE_MTYPE(HOST)
32
33/* for test-commands.c */
34DECLARE_MTYPE(STRVEC)
718e3744 35
36/* Host configuration variable */
37struct host
38{
39 /* Host name of this router. */
40 char *name;
41
42 /* Password for vty interface. */
43 char *password;
44 char *password_encrypt;
45
46 /* Enable password */
47 char *enable;
48 char *enable_encrypt;
49
50 /* System wide terminal lines. */
51 int lines;
52
53 /* Log filename. */
54 char *logfile;
55
718e3744 56 /* config file name of this host */
57 char *config;
58
59 /* Flags for services */
60 int advanced;
61 int encrypt;
62
63 /* Banner configuration. */
8c328f11 64 const char *motd;
3b0c5d9a 65 char *motdfile;
718e3744 66};
67
68/* There are some command levels which called from command node. */
69enum node_type
70{
71 AUTH_NODE, /* Authentication mode of vty interface. */
72 VIEW_NODE, /* View node. Default mode of vty interface. */
73 AUTH_ENABLE_NODE, /* Authentication mode for change enable. */
74 ENABLE_NODE, /* Enable node. */
75 CONFIG_NODE, /* Config node. Default mode of config file. */
e7168df4 76 SERVICE_NODE, /* Service node. */
718e3744 77 DEBUG_NODE, /* Debug node. */
19dc275e 78 VRF_DEBUG_NODE, /* Vrf Debug node. */
65efcfce 79 DEBUG_VNC_NODE, /* Debug VNC node. */
718e3744 80 AAA_NODE, /* AAA node. */
81 KEYCHAIN_NODE, /* Key-chain node. */
82 KEYCHAIN_KEY_NODE, /* Key-chain key node. */
13460c44 83 NS_NODE, /* Logical-Router node. */
f93e3f69 84 VRF_NODE, /* VRF mode node. */
dfa857a5 85 INTERFACE_NODE, /* Interface mode node. */
718e3744 86 ZEBRA_NODE, /* zebra connection node. */
87 TABLE_NODE, /* rtm_table selection node. */
88 RIP_NODE, /* RIP protocol mode node. */
89 RIPNG_NODE, /* RIPng protocol mode node. */
90 BGP_NODE, /* BGP protocol mode which includes BGP4+ */
91 BGP_VPNV4_NODE, /* BGP MPLS-VPN PE exchange. */
8ecd3266 92 BGP_VPNV6_NODE, /* BGP MPLS-VPN PE exchange. */
718e3744 93 BGP_IPV4_NODE, /* BGP IPv4 unicast address family. */
94 BGP_IPV4M_NODE, /* BGP IPv4 multicast address family. */
95 BGP_IPV6_NODE, /* BGP IPv6 address family */
1e836590 96 BGP_IPV6M_NODE, /* BGP IPv6 multicast address family. */
8b1fb8be
LB
97 BGP_ENCAP_NODE, /* BGP ENCAP SAFI */
98 BGP_ENCAPV6_NODE, /* BGP ENCAP SAFI */
65efcfce
LB
99 BGP_VNC_DEFAULTS_NODE, /* BGP VNC nve defaults */
100 BGP_VNC_NVE_GROUP_NODE, /* BGP VNC nve group */
101 BGP_VNC_L2_GROUP_NODE, /* BGP VNC L2 group */
102 RFP_DEFAULTS_NODE, /* RFP defaults node */
718e3744 103 OSPF_NODE, /* OSPF protocol mode */
104 OSPF6_NODE, /* OSPF protocol for IPv6 mode */
eac6e3f0
RW
105 LDP_NODE, /* LDP protocol mode */
106 LDP_IPV4_NODE, /* LDP IPv4 address family */
107 LDP_IPV6_NODE, /* LDP IPv6 address family */
108 LDP_IPV4_IFACE_NODE, /* LDP IPv4 Interface */
109 LDP_IPV6_IFACE_NODE, /* LDP IPv6 Interface */
110 LDP_L2VPN_NODE, /* LDP L2VPN node */
111 LDP_PSEUDOWIRE_NODE, /* LDP Pseudowire node */
9e867fe6 112 ISIS_NODE, /* ISIS protocol mode */
12e41d03 113 PIM_NODE, /* PIM protocol mode */
718e3744 114 MASC_NODE, /* MASC for multicast. */
115 IRDP_NODE, /* ICMP Router Discovery Protocol mode. */
116 IP_NODE, /* Static ip route node. */
117 ACCESS_NODE, /* Access list node. */
118 PREFIX_NODE, /* Prefix list node. */
119 ACCESS_IPV6_NODE, /* Access list node. */
120 PREFIX_IPV6_NODE, /* Prefix list node. */
121 AS_LIST_NODE, /* AS list node. */
122 COMMUNITY_LIST_NODE, /* Community list node. */
123 RMAP_NODE, /* Route map node. */
124 SMUX_NODE, /* SNMP configuration node. */
125 DUMP_NODE, /* Packet dump node. */
126 FORWARDING_NODE, /* IP forwarding node. */
7514fb77 127 PROTOCOL_NODE, /* protocol filtering node */
7758e3f3 128 MPLS_NODE, /* MPLS config node */
62687ff1 129 VTY_NODE, /* Vty node. */
16f1b9ee 130 LINK_PARAMS_NODE, /* Link-parameters node */
718e3744 131};
132
133/* Node which has some commands and prompt string and configuration
134 function pointer . */
135struct cmd_node
136{
137 /* Node index. */
138 enum node_type node;
139
140 /* Prompt character at vty interface. */
8c328f11 141 const char *prompt;
718e3744 142
143 /* Is this node's configuration goes to vtysh ? */
144 int vtysh;
145
146 /* Node's configuration write function */
147 int (*func) (struct vty *);
148
149 /* Vector of this node's command list. */
150 vector cmd_vector;
151};
152
406d6716 153enum
154{
9c5d8562 155 CMD_ATTR_DEPRECATED = 1,
406d6716 156 CMD_ATTR_HIDDEN,
157};
158
718e3744 159/* Structure of command element. */
160struct cmd_element
161{
8c328f11 162 const char *string; /* Command specification by string. */
9035efaa 163 int (*func) (struct cmd_element *, struct vty *, int, const char *[]);
8c328f11 164 const char *doc; /* Documentation of this command. */
718e3744 165 int daemon; /* Daemon to which this command belong. */
cd40b329 166 vector tokens; /* Vector of cmd_tokens */
406d6716 167 u_char attr; /* Command attributes */
718e3744 168};
169
cd40b329
CF
170
171enum cmd_token_type
172{
173 TOKEN_TERMINAL = 0,
174 TOKEN_MULTIPLE,
175 TOKEN_KEYWORD,
176};
177
c117e027
DL
178enum cmd_terminal_type
179{
180 _TERMINAL_BUG = 0,
181 TERMINAL_LITERAL,
182 TERMINAL_OPTION,
183 TERMINAL_VARIABLE,
184 TERMINAL_VARARG,
185 TERMINAL_RANGE,
186 TERMINAL_IPV4,
187 TERMINAL_IPV4_PREFIX,
188 TERMINAL_IPV6,
189 TERMINAL_IPV6_PREFIX,
190};
191
27e7f290
DL
192/* argument to be recorded on argv[] if it's not a literal */
193#define TERMINAL_RECORD(t) ((t) >= TERMINAL_OPTION)
194
718e3744 195/* Command description structure. */
cd40b329 196struct cmd_token
718e3744 197{
cd40b329 198 enum cmd_token_type type;
c117e027 199 enum cmd_terminal_type terminal;
cd40b329
CF
200
201 /* Used for type == MULTIPLE */
202 vector multiple; /* vector of cmd_token, type == FINAL */
203
204 /* Used for type == KEYWORD */
205 vector keyword; /* vector of vector of cmd_tokens */
206
207 /* Used for type == TERMINAL */
228da428 208 char *cmd; /* Command string. */
cd40b329 209 char *desc; /* Command's description. */
718e3744 210};
211
212/* Return value of the commands. */
213#define CMD_SUCCESS 0
214#define CMD_WARNING 1
215#define CMD_ERR_NO_MATCH 2
216#define CMD_ERR_AMBIGUOUS 3
217#define CMD_ERR_INCOMPLETE 4
218#define CMD_ERR_EXEED_ARGC_MAX 5
219#define CMD_ERR_NOTHING_TODO 6
220#define CMD_COMPLETE_FULL_MATCH 7
221#define CMD_COMPLETE_MATCH 8
222#define CMD_COMPLETE_LIST_MATCH 9
223#define CMD_SUCCESS_DAEMON 10
1db63918 224#define CMD_ERR_NO_FILE 11
718e3744 225
226/* Argc max counts. */
227#define CMD_ARGC_MAX 25
228
229/* Turn off these macros when uisng cpp with extract.pl */
230#ifndef VTYSH_EXTRACT_PL
231
406d6716 232/* helper defines for end-user DEFUN* macros */
233#define DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \
718e3744 234 struct cmd_element cmdname = \
235 { \
9035efaa 236 .string = cmdstr, \
237 .func = funcname, \
406d6716 238 .doc = helpstr, \
239 .attr = attrs, \
240 .daemon = dnum, \
241 };
242
243#define DEFUN_CMD_FUNC_DECL(funcname) \
34204aac 244 static int funcname (struct cmd_element *, struct vty *, int, const char *[]);
406d6716 245
246#define DEFUN_CMD_FUNC_TEXT(funcname) \
274a4a44 247 static int funcname \
6cf0cf0c
PJ
248 (struct cmd_element *self __attribute__ ((unused)), \
249 struct vty *vty __attribute__ ((unused)), \
250 int argc __attribute__ ((unused)), \
251 const char *argv[] __attribute__ ((unused)) )
406d6716 252
cd40b329
CF
253/* DEFUN for vty command interafce. Little bit hacky ;-).
254 *
255 * DEFUN(funcname, cmdname, cmdstr, helpstr)
256 *
257 * funcname
258 * ========
259 *
260 * Name of the function that will be defined.
261 *
262 * cmdname
263 * =======
264 *
265 * Name of the struct that will be defined for the command.
266 *
267 * cmdstr
268 * ======
269 *
270 * The cmdstr defines the command syntax. It is used by the vty subsystem
271 * and vtysh to perform matching and completion in the cli. So you have to take
272 * care to construct it adhering to the following grammar. The names used
273 * for the production rules losely represent the names used in lib/command.c
274 *
275 * cmdstr = cmd_token , { " " , cmd_token } ;
276 *
277 * cmd_token = cmd_terminal
278 * | cmd_multiple
279 * | cmd_keyword ;
280 *
281 * cmd_terminal_fixed = fixed_string
282 * | variable
283 * | range
284 * | ipv4
285 * | ipv4_prefix
286 * | ipv6
287 * | ipv6_prefix ;
288 *
289 * cmd_terminal = cmd_terminal_fixed
290 * | option
291 * | vararg ;
292 *
293 * multiple_part = cmd_terminal_fixed ;
294 * cmd_multiple = "(" , multiple_part , ( "|" | { "|" , multiple_part } ) , ")" ;
295 *
296 * keyword_part = fixed_string , { " " , ( cmd_terminal_fixed | cmd_multiple ) } ;
297 * cmd_keyword = "{" , keyword_part , { "|" , keyword_part } , "}" ;
298 *
299 * lowercase = "a" | ... | "z" ;
300 * uppercase = "A" | ... | "Z" ;
301 * digit = "0" | ... | "9" ;
302 * number = digit , { digit } ;
303 *
304 * fixed_string = (lowercase | digit) , { lowercase | digit | uppercase | "-" | "_" } ;
305 * variable = uppercase , { uppercase | "_" } ;
306 * range = "<" , number , "-" , number , ">" ;
307 * ipv4 = "A.B.C.D" ;
308 * ipv4_prefix = "A.B.C.D/M" ;
309 * ipv6 = "X:X::X:X" ;
310 * ipv6_prefix = "X:X::X:X/M" ;
311 * option = "[" , variable , "]" ;
312 * vararg = "." , variable ;
313 *
314 * To put that all in a textual description: A cmdstr is a sequence of tokens,
315 * separated by spaces.
316 *
317 * Terminal Tokens:
318 *
319 * A very simple cmdstring would be something like: "show ip bgp". It consists
320 * of three Terminal Tokens, each containing a fixed string. When this command
321 * is called, no arguments will be passed down to the function implementing it,
322 * as it only consists of fixed strings.
323 *
324 * Apart from fixed strings, Terminal Tokens can also contain variables:
325 * An example would be "show ip bgp A.B.C.D". This command expects an IPv4
326 * as argument. As this is a variable, the IP address entered by the user will
327 * be passed down as an argument. Apart from two exceptions, the other options
328 * for Terminal Tokens behave exactly as we just discussed and only make a
329 * difference for the CLI. The two exceptions will be discussed in the next
330 * paragraphs.
331 *
332 * A Terminal Token can contain a so called option match. This is a simple
333 * string variable that the user may omit. An example would be:
334 * "show interface [IFNAME]". If the user calls this without an interface as
335 * argument, no arguments will be passed down to the function implementing
336 * this command. Otherwise, the interface name will be provided to the function
337 * as a regular argument.
338
339 * Also, a Terminal Token can contain a so called vararg. This is used e.g. in
340 * "show ip bgp regexp .LINE". The last token is a vararg match and will
341 * consume all the arguments the user inputs on the command line and append
342 * those to the list of arguments passed down to the function implementing this
343 * command. (Therefore, it doesn't make much sense to have any tokens after a
344 * vararg because the vararg will already consume all the words the user entered
345 * in the CLI)
346 *
347 * Multiple Tokens:
348 *
349 * The Multiple Token type can be used if there are multiple possibilities what
350 * arguments may be used for a command, but it should map to the same function
351 * nonetheless. An example would be "ip route A.B.C.D/M (reject|blackhole)"
352 * In that case both "reject" and "blackhole" would be acceptable as last
353 * arguments. The words matched by Multiple Tokens are always added to the
354 * argument list, even if they are matched by fixed strings. Such a Multiple
355 * Token can contain almost any type of token that would also be acceptable
356 * for a Terminal Token, the exception are optional variables and varag.
357 *
358 * There is one special case that is used in some places of Quagga that should be
359 * pointed out here shortly. An example would be "password (8|) WORD". This
360 * construct is used to have fixed strings communicated as arguments. (The "8"
361 * will be passed down as an argument in this case) It does not mean that
362 * the "8" is optional. Another historic and possibly surprising property of
363 * this construct is that it consumes two parts of helpstr. (Help
364 * strings will be explained later)
365 *
366 * Keyword Tokens:
367 *
368 * There are commands that take a lot of different and possibly optional arguments.
369 * An example from ospf would be the "default-information originate" command. This
370 * command takes a lot of optional arguments that may be provided in any order.
371 * To accomodate such commands, the Keyword Token has been implemented.
372 * Using the keyword token, the "default-information originate" command and all
373 * its possible options can be represented using this single cmdstr:
374 * "default-information originate \
375 * {always|metric <0-16777214>|metric-type (1|2)|route-map WORD}"
376 *
377 * Keywords always start with a fixed string and may be followed by arguments.
378 * Except optional variables and vararg, everything is permitted here.
379 *
380 * For the special case of a keyword without arguments, either NULL or the
381 * keyword itself will be pushed as an argument, depending on whether the
382 * keyword is present.
383 * For the other keywords, arguments will be only pushed for
384 * variables/Multiple Tokens. If the keyword is not present, the arguments that
385 * would have been pushed will be substituted by NULL.
386 *
387 * A few examples:
388 * "default information originate metric-type 1 metric 1000"
389 * would yield the following arguments:
390 * { NULL, "1000", "1", NULL }
391 *
392 * "default information originate always route-map RMAP-DEFAULT"
393 * would yield the following arguments:
394 * { "always", NULL, NULL, "RMAP-DEFAULT" }
395 *
396 * helpstr
397 * =======
398 *
399 * The helpstr is used to show a short explantion for the commands that
400 * are available when the user presses '?' on the CLI. It is the concatenation
401 * of the helpstrings for all the tokens that make up the command.
402 *
403 * There should be one helpstring for each token in the cmdstr except those
404 * containing other tokens, like Multiple or Keyword Tokens. For those, there
405 * will only be the helpstrings of the contained tokens.
406 *
407 * The individual helpstrings are expected to be in the same order as their
408 * respective Tokens appear in the cmdstr. They should each be terminated with
409 * a linefeed. The last helpstring should be terminated with a linefeed as well.
410 *
411 * Care should also be taken to avoid having similar tokens with different
412 * helpstrings. Imagine e.g. the commands "show ip ospf" and "show ip bgp".
413 * they both contain a helpstring for "show", but only one will be displayed
414 * when the user enters "sh?". If those two helpstrings differ, it is not
415 * defined which one will be shown and the behavior is therefore unpredictable.
416 */
406d6716 417#define DEFUN(funcname, cmdname, cmdstr, helpstr) \
418 DEFUN_CMD_FUNC_DECL(funcname) \
419 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \
420 DEFUN_CMD_FUNC_TEXT(funcname)
421
422#define DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
423 DEFUN_CMD_FUNC_DECL(funcname) \
424 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \
425 DEFUN_CMD_FUNC_TEXT(funcname)
426
427#define DEFUN_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
428 DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN)
429
430#define DEFUN_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \
2557aed1 431 DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED) \
718e3744 432
433/* DEFUN_NOSH for commands that vtysh should ignore */
434#define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \
435 DEFUN(funcname, cmdname, cmdstr, helpstr)
436
437/* DEFSH for vtysh. */
438#define DEFSH(daemon, cmdname, cmdstr, helpstr) \
406d6716 439 DEFUN_CMD_ELEMENT(NULL, cmdname, cmdstr, helpstr, 0, daemon) \
718e3744 440
abaaab4e
DW
441#define DEFSH_HIDDEN(daemon, cmdname, cmdstr, helpstr) \
442 DEFUN_CMD_ELEMENT(NULL, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, daemon) \
443
718e3744 444/* DEFUN + DEFSH */
445#define DEFUNSH(daemon, funcname, cmdname, cmdstr, helpstr) \
406d6716 446 DEFUN_CMD_FUNC_DECL(funcname) \
447 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon) \
448 DEFUN_CMD_FUNC_TEXT(funcname)
718e3744 449
274a4a44 450/* DEFUN + DEFSH with attributes */
451#define DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, attr) \
452 DEFUN_CMD_FUNC_DECL(funcname) \
453 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, daemon) \
454 DEFUN_CMD_FUNC_TEXT(funcname)
455
456#define DEFUNSH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \
457 DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN)
458
459#define DEFUNSH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \
460 DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED)
461
718e3744 462/* ALIAS macro which define existing command's alias. */
463#define ALIAS(funcname, cmdname, cmdstr, helpstr) \
406d6716 464 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0)
465
466#define ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
274a4a44 467 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0)
406d6716 468
469#define ALIAS_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
470 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, 0)
471
472#define ALIAS_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \
473 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, 0)
718e3744 474
274a4a44 475#define ALIAS_SH(daemon, funcname, cmdname, cmdstr, helpstr) \
476 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon)
477
478#define ALIAS_SH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \
479 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, daemon)
480
481#define ALIAS_SH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \
482 DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, daemon)
483
718e3744 484#endif /* VTYSH_EXTRACT_PL */
485
486/* Some macroes */
ba6d273b
DS
487
488/*
489 * Sometimes #defines create maximum values that
490 * need to have strings created from them that
491 * allow the parser to match against them.
492 * These macros allow that.
493 */
494#define CMD_CREATE_STR(s) CMD_CREATE_STR_HELPER(s)
495#define CMD_CREATE_STR_HELPER(s) #s
496#define CMD_RANGE_STR(a,s) "<" CMD_CREATE_STR(a) "-" CMD_CREATE_STR(s) ">"
497
718e3744 498/* Common descriptions. */
499#define SHOW_STR "Show running system information\n"
500#define IP_STR "IP information\n"
501#define IPV6_STR "IPv6 information\n"
502#define NO_STR "Negate a command or set its defaults\n"
9c42a6eb 503#define REDIST_STR "Redistribute information from another routing protocol\n"
718e3744 504#define CLEAR_STR "Reset functions\n"
505#define RIP_STR "RIP information\n"
506#define BGP_STR "BGP information\n"
e0bce756
DS
507#define BGP_SOFT_STR "Soft reconfig inbound and outbound updates\n"
508#define BGP_SOFT_IN_STR "Send route-refresh unless using 'soft-reconfiguration inbound'\n"
509#define BGP_SOFT_OUT_STR "Resend all outbound updates\n"
510#define BGP_SOFT_RSCLIENT_RIB_STR "Soft reconfig for rsclient RIB\n"
718e3744 511#define OSPF_STR "OSPF information\n"
512#define NEIGHBOR_STR "Specify neighbor router\n"
513#define DEBUG_STR "Debugging functions (see also 'undebug')\n"
514#define UNDEBUG_STR "Disable debugging functions (see also 'debug')\n"
515#define ROUTER_STR "Enable a routing process\n"
516#define AS_STR "AS number\n"
517#define MBGP_STR "MBGP information\n"
518#define MATCH_STR "Match values from routing table\n"
519#define SET_STR "Set values in destination routing protocol\n"
520#define OUT_STR "Filter outgoing routing updates\n"
521#define IN_STR "Filter incoming routing updates\n"
522#define V4NOTATION_STR "specify by IPv4 address notation(e.g. 0.0.0.0)\n"
523#define OSPF6_NUMBER_STR "Specify by number\n"
524#define INTERFACE_STR "Interface infomation\n"
525#define IFNAME_STR "Interface name(e.g. ep0)\n"
526#define IP6_STR "IPv6 Information\n"
527#define OSPF6_STR "Open Shortest Path First (OSPF) for IPv6\n"
528#define OSPF6_ROUTER_STR "Enable a routing process\n"
529#define OSPF6_INSTANCE_STR "<1-65535> Instance ID\n"
530#define SECONDS_STR "<1-65535> Seconds\n"
531#define ROUTE_STR "Routing Table\n"
532#define PREFIX_LIST_STR "Build a prefix list\n"
533#define OSPF6_DUMP_TYPE_LIST \
534"(neighbor|interface|area|lsa|zebra|config|dbex|spf|route|lsdb|redistribute|hook|asbr|prefix|abr)"
9e867fe6 535#define ISIS_STR "IS-IS information\n"
536#define AREA_TAG_STR "[area tag]\n"
859d388e
DW
537#define COMMUNITY_AANN_STR "Community number where AA and NN are <0-65535>\n"
538#define COMMUNITY_VAL_STR "Community number in AA:NN format (where AA and NN are <0-65535>) or local-AS|no-advertise|no-export|internet or additive\n"
16f1b9ee
OD
539#define MPLS_TE_STR "MPLS-TE specific commands\n"
540#define LINK_PARAMS_STR "Configure interface link parameters\n"
541#define OSPF_RI_STR "OSPF Router Information specific commands\n"
542#define PCE_STR "PCE Router Information specific commands\n"
7758e3f3 543#define MPLS_STR "MPLS information\n"
718e3744 544
545#define CONF_BACKUP_EXT ".sav"
546
547/* IPv4 only machine should not accept IPv6 address for peer's IP
548 address. So we replace VTY command string like below. */
549#ifdef HAVE_IPV6
550#define NEIGHBOR_CMD "neighbor (A.B.C.D|X:X::X:X) "
551#define NO_NEIGHBOR_CMD "no neighbor (A.B.C.D|X:X::X:X) "
552#define NEIGHBOR_ADDR_STR "Neighbor address\nIPv6 address\n"
553#define NEIGHBOR_CMD2 "neighbor (A.B.C.D|X:X::X:X|WORD) "
554#define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|X:X::X:X|WORD) "
a80beece
DS
555#define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor IPv6 address\nInterface name or neighbor tag\n"
556#define NEIGHBOR_ADDR_STR3 "Neighbor address\nIPv6 address\nInterface name\n"
718e3744 557#else
558#define NEIGHBOR_CMD "neighbor A.B.C.D "
559#define NO_NEIGHBOR_CMD "no neighbor A.B.C.D "
560#define NEIGHBOR_ADDR_STR "Neighbor address\n"
561#define NEIGHBOR_CMD2 "neighbor (A.B.C.D|WORD) "
562#define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|WORD) "
563#define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor tag\n"
564#endif /* HAVE_IPV6 */
565
f14e6fdb
DS
566/* Dynamic neighbor (listen range) configuration */
567#ifdef HAVE_IPV6
568#define LISTEN_RANGE_CMD "bgp listen range (A.B.C.D/M|X:X::X:X/M) "
569#define LISTEN_RANGE_ADDR_STR "Neighbor address\nNeighbor IPv6 address\n"
570#else
571#define LISTEN_RANGE_CMD "bgp listen range A.B.C.D/M "
572#define LISTEN_RANGE_ADDR_STR "Neighbor address\n"
573#endif /* HAVE_IPV6 */
574
718e3744 575/* Prototypes. */
8cc4198f 576extern void install_node (struct cmd_node *, int (*) (struct vty *));
577extern void install_default (enum node_type);
578extern void install_element (enum node_type, struct cmd_element *);
718e3744 579
f6834d4c 580/* Concatenates argv[shift] through argv[argc-1] into a single NUL-terminated
581 string with a space between each element (allocated using
582 XMALLOC(MTYPE_TMP)). Returns NULL if shift >= argc. */
8cc4198f 583extern char *argv_concat (const char **argv, int argc, int shift);
584
585extern vector cmd_make_strvec (const char *);
586extern void cmd_free_strvec (vector);
587extern vector cmd_describe_command (vector, struct vty *, int *status);
588extern char **cmd_complete_command (vector, struct vty *, int *status);
cde9f101 589extern char **cmd_complete_command_lib (vector, struct vty *, int *status, int islib);
8cc4198f 590extern const char *cmd_prompt (enum node_type);
bed578b8 591extern int command_config_read_one_line (struct vty *vty, struct cmd_element **, int use_config_node);
13fbc82d 592extern int config_from_file (struct vty *, FILE *, unsigned int *line_num);
8cc4198f 593extern enum node_type node_parent (enum node_type);
594extern int cmd_execute_command (vector, struct vty *, struct cmd_element **, int);
595extern int cmd_execute_command_strict (vector, struct vty *, struct cmd_element **);
8cc4198f 596extern void cmd_init (int);
228da428 597extern void cmd_terminate (void);
718e3744 598
599/* Export typical functions. */
600extern struct cmd_element config_end_cmd;
601extern struct cmd_element config_exit_cmd;
602extern struct cmd_element config_quit_cmd;
603extern struct cmd_element config_help_cmd;
604extern struct cmd_element config_list_cmd;
57387fb2 605extern const char *host_config_get (void);
c0e8c16f 606extern void host_config_set (const char *);
6590f2c3 607
8cc4198f 608extern void print_version (const char *);
86228fde 609
7cfc61d3
DS
610extern int cmd_banner_motd_file (const char *);
611
86228fde
PJ
612/* struct host global, ick */
613extern struct host host;
228da428
CC
614
615/* "<cr>" global */
616extern char *command_cr;
718e3744 617#endif /* _ZEBRA_COMMAND_H */