command.h 22 KB

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