command.h 22 KB

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