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