command.h 21 KB

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