Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 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 | |
Sylvain Munaut | 12ba778 | 2014-06-16 10:13:40 +0200 | [diff] [blame] | 23 | #pragma once |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <sys/types.h> |
| 27 | #include "vector.h" |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 28 | |
Harald Welte | e881b1b | 2011-08-17 18:52:30 +0200 | [diff] [blame] | 29 | /*! \defgroup command VTY Command |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 30 | * @{ |
| 31 | */ |
| 32 | /*! \file command.h */ |
| 33 | |
| 34 | /*! \brief Host configuration variable */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 35 | struct host { |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 36 | /*! \brief Host name of this router. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 37 | char *name; |
| 38 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 39 | /*! \brief Password for vty interface. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 40 | char *password; |
| 41 | char *password_encrypt; |
| 42 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 43 | /*! \brief Enable password */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 44 | char *enable; |
| 45 | char *enable_encrypt; |
| 46 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 47 | /*! \brief System wide terminal lines. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 48 | int lines; |
| 49 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 50 | /*! \brief Log filename. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 51 | char *logfile; |
| 52 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 53 | /*! \brief config file name of this host */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 54 | char *config; |
| 55 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 56 | /*! \brief Flags for services */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 57 | int advanced; |
| 58 | int encrypt; |
| 59 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 60 | /*! \brief Banner configuration. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 61 | const char *motd; |
| 62 | char *motdfile; |
| 63 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 64 | /*! \brief VTY application information */ |
Harald Welte | 237f624 | 2010-05-25 23:00:45 +0200 | [diff] [blame] | 65 | const struct vty_app_info *app_info; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 66 | }; |
| 67 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 68 | /*! \brief There are some command levels which called from command node. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 69 | enum node_type { |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 70 | AUTH_NODE, /*!< \brief Authentication mode of vty interface. */ |
| 71 | VIEW_NODE, /*!< \brief View node. Default mode of vty interface. */ |
| 72 | AUTH_ENABLE_NODE, /*!< \brief Authentication mode for change enable. */ |
| 73 | ENABLE_NODE, /*!< \brief Enable node. */ |
| 74 | CONFIG_NODE, /*!< \brief Config node. Default mode of config file. */ |
| 75 | SERVICE_NODE, /*!< \brief Service node. */ |
| 76 | DEBUG_NODE, /*!< \brief Debug node. */ |
| 77 | CFG_LOG_NODE, /*!< \brief Configure the logging */ |
Harald Welte | 4c05301 | 2010-05-31 16:01:59 +0200 | [diff] [blame] | 78 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 79 | VTY_NODE, /*!< \brief Vty node. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 80 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 81 | L_E1INP_NODE, /*!< \brief E1 line in libosmo-abis. */ |
| 82 | L_IPA_NODE, /*!< \brief IPA proxying commands in libosmo-abis. */ |
Harald Welte | d85d015 | 2012-06-16 16:54:19 +0800 | [diff] [blame] | 83 | L_NS_NODE, /*!< \brief NS node in libosmo-gb. */ |
| 84 | L_BSSGP_NODE, /*!< \brief BSSGP node in libosmo-gb. */ |
Pablo Neira Ayuso | 2ade3a0 | 2011-07-07 19:46:50 +0200 | [diff] [blame] | 85 | |
Harald Welte | 4c05301 | 2010-05-31 16:01:59 +0200 | [diff] [blame] | 86 | _LAST_OSMOVTY_NODE |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 87 | }; |
| 88 | |
Andreas Eversberg | 3c6a2ce | 2012-07-12 09:22:56 +0200 | [diff] [blame] | 89 | #include "vty.h" |
| 90 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 91 | /*! \brief Node which has some commands and prompt string and |
| 92 | * configuration function pointer . */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 93 | struct cmd_node { |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 94 | /*! \brief Node index */ |
Holger Hans Peter Freyther | a9e5252 | 2015-08-02 02:14:07 +0000 | [diff] [blame] | 95 | int node; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 96 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 97 | /*! \brief Prompt character at vty interface. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 98 | const char *prompt; |
| 99 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 100 | /*! \brief Is this node's configuration goes to vtysh ? */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 101 | int vtysh; |
| 102 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 103 | /*! \brief Node's configuration write function */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 104 | int (*func) (struct vty *); |
| 105 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 106 | /*! \brief Vector of this node's command list. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 107 | vector cmd_vector; |
| 108 | }; |
| 109 | |
| 110 | enum { |
| 111 | CMD_ATTR_DEPRECATED = 1, |
| 112 | CMD_ATTR_HIDDEN, |
| 113 | }; |
| 114 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 115 | /*! \brief Structure of a command element */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 116 | struct cmd_element { |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 117 | const char *string; /*!< \brief Command specification by string. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 118 | int (*func) (struct cmd_element *, struct vty *, int, const char *[]); |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 119 | const char *doc; /*!< \brief Documentation of this command. */ |
| 120 | int daemon; /*!< \brief Daemon to which this command belong. */ |
| 121 | vector strvec; /*!< \brief Pointing out each description vector. */ |
| 122 | unsigned int cmdsize; /*!< \brief Command index count. */ |
| 123 | char *config; /*!< \brief Configuration string */ |
| 124 | vector subconfig; /*!< \brief Sub configuration string */ |
Harald Welte | 7b74dda | 2014-03-11 10:31:19 +0100 | [diff] [blame] | 125 | unsigned char attr; /*!< \brief Command attributes */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 126 | }; |
| 127 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 128 | /*! \brief Command description structure. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 129 | struct desc { |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 130 | const char *cmd; /*!< \brief Command string. */ |
| 131 | const char *str; /*!< \brief Command's description. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 132 | }; |
| 133 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 134 | /*! \brief Return value of the commands. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 135 | #define CMD_SUCCESS 0 |
| 136 | #define CMD_WARNING 1 |
| 137 | #define CMD_ERR_NO_MATCH 2 |
| 138 | #define CMD_ERR_AMBIGUOUS 3 |
| 139 | #define CMD_ERR_INCOMPLETE 4 |
| 140 | #define CMD_ERR_EXEED_ARGC_MAX 5 |
| 141 | #define CMD_ERR_NOTHING_TODO 6 |
| 142 | #define CMD_COMPLETE_FULL_MATCH 7 |
| 143 | #define CMD_COMPLETE_MATCH 8 |
| 144 | #define CMD_COMPLETE_LIST_MATCH 9 |
| 145 | #define CMD_SUCCESS_DAEMON 10 |
| 146 | |
| 147 | /* Argc max counts. */ |
Holger Hans Peter Freyther | c0dbe0b | 2011-07-24 19:58:06 +0200 | [diff] [blame] | 148 | #define CMD_ARGC_MAX 256 |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 149 | |
| 150 | /* Turn off these macros when uisng cpp with extract.pl */ |
| 151 | #ifndef VTYSH_EXTRACT_PL |
| 152 | |
| 153 | /* helper defines for end-user DEFUN* macros */ |
| 154 | #define DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \ |
| 155 | static struct cmd_element cmdname = \ |
| 156 | { \ |
| 157 | .string = cmdstr, \ |
| 158 | .func = funcname, \ |
| 159 | .doc = helpstr, \ |
| 160 | .attr = attrs, \ |
| 161 | .daemon = dnum, \ |
| 162 | }; |
| 163 | |
| 164 | /* global (non static) cmd_element */ |
| 165 | #define gDEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attrs, dnum) \ |
| 166 | struct cmd_element cmdname = \ |
| 167 | { \ |
| 168 | .string = cmdstr, \ |
| 169 | .func = funcname, \ |
| 170 | .doc = helpstr, \ |
| 171 | .attr = attrs, \ |
| 172 | .daemon = dnum, \ |
| 173 | }; |
| 174 | |
| 175 | #define DEFUN_CMD_FUNC_DECL(funcname) \ |
| 176 | static int funcname (struct cmd_element *, struct vty *, int, const char *[]); \ |
| 177 | |
| 178 | #define DEFUN_CMD_FUNC_TEXT(funcname) \ |
| 179 | static int funcname \ |
| 180 | (struct cmd_element *self, struct vty *vty, int argc, const char *argv[]) |
| 181 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 182 | /*! \brief Macro for defining a VTY node and function |
| 183 | * \param[in] funcname Name of the function implementing the node |
| 184 | * \param[in] cmdname Name of the command node |
| 185 | * \param[in] cmdstr String with syntax of node |
| 186 | * \param[in] helpstr String with help message of node |
| 187 | */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 188 | #define DEFUN(funcname, cmdname, cmdstr, helpstr) \ |
| 189 | DEFUN_CMD_FUNC_DECL(funcname) \ |
| 190 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \ |
| 191 | DEFUN_CMD_FUNC_TEXT(funcname) |
| 192 | |
Harald Welte | 7acb30c | 2011-08-17 17:13:48 +0200 | [diff] [blame] | 193 | /*! \brief Macro for defining a non-static (global) VTY node and function |
| 194 | * \param[in] funcname Name of the function implementing the node |
| 195 | * \param[in] cmdname Name of the command node |
| 196 | * \param[in] cmdstr String with syntax of node |
| 197 | * \param[in] helpstr String with help message of node |
| 198 | */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 199 | #define gDEFUN(funcname, cmdname, cmdstr, helpstr) \ |
| 200 | DEFUN_CMD_FUNC_DECL(funcname) \ |
| 201 | gDEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \ |
| 202 | DEFUN_CMD_FUNC_TEXT(funcname) |
| 203 | |
| 204 | #define DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \ |
| 205 | DEFUN_CMD_FUNC_DECL(funcname) \ |
| 206 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \ |
| 207 | DEFUN_CMD_FUNC_TEXT(funcname) |
| 208 | |
| 209 | #define DEFUN_HIDDEN(funcname, cmdname, cmdstr, helpstr) \ |
| 210 | DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN) |
| 211 | |
| 212 | #define DEFUN_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \ |
| 213 | DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED) \ |
| 214 | |
| 215 | /* DEFUN_NOSH for commands that vtysh should ignore */ |
| 216 | #define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \ |
| 217 | DEFUN(funcname, cmdname, cmdstr, helpstr) |
| 218 | |
| 219 | /* DEFSH for vtysh. */ |
| 220 | #define DEFSH(daemon, cmdname, cmdstr, helpstr) \ |
| 221 | DEFUN_CMD_ELEMENT(NULL, cmdname, cmdstr, helpstr, 0, daemon) \ |
| 222 | |
| 223 | /* DEFUN + DEFSH */ |
| 224 | #define DEFUNSH(daemon, funcname, cmdname, cmdstr, helpstr) \ |
| 225 | DEFUN_CMD_FUNC_DECL(funcname) \ |
| 226 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon) \ |
| 227 | DEFUN_CMD_FUNC_TEXT(funcname) |
| 228 | |
| 229 | /* DEFUN + DEFSH with attributes */ |
| 230 | #define DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, attr) \ |
| 231 | DEFUN_CMD_FUNC_DECL(funcname) \ |
| 232 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, daemon) \ |
| 233 | DEFUN_CMD_FUNC_TEXT(funcname) |
| 234 | |
| 235 | #define DEFUNSH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \ |
| 236 | DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN) |
| 237 | |
| 238 | #define DEFUNSH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \ |
| 239 | DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED) |
| 240 | |
| 241 | /* ALIAS macro which define existing command's alias. */ |
| 242 | #define ALIAS(funcname, cmdname, cmdstr, helpstr) \ |
| 243 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) |
| 244 | |
| 245 | /* global (non static) cmd_element */ |
| 246 | #define gALIAS(funcname, cmdname, cmdstr, helpstr) \ |
| 247 | gDEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) |
| 248 | |
| 249 | #define ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \ |
| 250 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) |
| 251 | |
| 252 | #define ALIAS_HIDDEN(funcname, cmdname, cmdstr, helpstr) \ |
| 253 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, 0) |
| 254 | |
| 255 | #define ALIAS_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \ |
| 256 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, 0) |
| 257 | |
| 258 | #define ALIAS_SH(daemon, funcname, cmdname, cmdstr, helpstr) \ |
| 259 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon) |
| 260 | |
| 261 | #define ALIAS_SH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \ |
| 262 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, daemon) |
| 263 | |
| 264 | #define ALIAS_SH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \ |
| 265 | DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, daemon) |
| 266 | |
| 267 | #endif /* VTYSH_EXTRACT_PL */ |
| 268 | |
| 269 | /* Some macroes */ |
| 270 | #define CMD_OPTION(S) ((S[0]) == '[') |
| 271 | #define CMD_VARIABLE(S) (((S[0]) >= 'A' && (S[0]) <= 'Z') || ((S[0]) == '<')) |
| 272 | #define CMD_VARARG(S) ((S[0]) == '.') |
| 273 | #define CMD_RANGE(S) ((S[0] == '<')) |
| 274 | |
| 275 | #define CMD_IPV4(S) ((strcmp ((S), "A.B.C.D") == 0)) |
| 276 | #define CMD_IPV4_PREFIX(S) ((strcmp ((S), "A.B.C.D/M") == 0)) |
| 277 | #define CMD_IPV6(S) ((strcmp ((S), "X:X::X:X") == 0)) |
| 278 | #define CMD_IPV6_PREFIX(S) ((strcmp ((S), "X:X::X:X/M") == 0)) |
| 279 | |
| 280 | /* Common descriptions. */ |
| 281 | #define SHOW_STR "Show running system information\n" |
| 282 | #define IP_STR "IP information\n" |
| 283 | #define IPV6_STR "IPv6 information\n" |
| 284 | #define NO_STR "Negate a command or set its defaults\n" |
| 285 | #define CLEAR_STR "Reset functions\n" |
| 286 | #define RIP_STR "RIP information\n" |
| 287 | #define BGP_STR "BGP information\n" |
| 288 | #define OSPF_STR "OSPF information\n" |
| 289 | #define NEIGHBOR_STR "Specify neighbor router\n" |
| 290 | #define DEBUG_STR "Debugging functions (see also 'undebug')\n" |
| 291 | #define UNDEBUG_STR "Disable debugging functions (see also 'debug')\n" |
| 292 | #define ROUTER_STR "Enable a routing process\n" |
| 293 | #define AS_STR "AS number\n" |
| 294 | #define MBGP_STR "MBGP information\n" |
| 295 | #define MATCH_STR "Match values from routing table\n" |
| 296 | #define SET_STR "Set values in destination routing protocol\n" |
| 297 | #define OUT_STR "Filter outgoing routing updates\n" |
| 298 | #define IN_STR "Filter incoming routing updates\n" |
| 299 | #define V4NOTATION_STR "specify by IPv4 address notation(e.g. 0.0.0.0)\n" |
| 300 | #define OSPF6_NUMBER_STR "Specify by number\n" |
| 301 | #define INTERFACE_STR "Interface infomation\n" |
| 302 | #define IFNAME_STR "Interface name(e.g. ep0)\n" |
| 303 | #define IP6_STR "IPv6 Information\n" |
| 304 | #define OSPF6_STR "Open Shortest Path First (OSPF) for IPv6\n" |
| 305 | #define OSPF6_ROUTER_STR "Enable a routing process\n" |
| 306 | #define OSPF6_INSTANCE_STR "<1-65535> Instance ID\n" |
| 307 | #define SECONDS_STR "<1-65535> Seconds\n" |
| 308 | #define ROUTE_STR "Routing Table\n" |
| 309 | #define PREFIX_LIST_STR "Build a prefix list\n" |
| 310 | #define OSPF6_DUMP_TYPE_LIST \ |
| 311 | "(neighbor|interface|area|lsa|zebra|config|dbex|spf|route|lsdb|redistribute|hook|asbr|prefix|abr)" |
| 312 | #define ISIS_STR "IS-IS information\n" |
| 313 | #define AREA_TAG_STR "[area tag]\n" |
| 314 | |
| 315 | #define CONF_BACKUP_EXT ".sav" |
| 316 | |
| 317 | /* IPv4 only machine should not accept IPv6 address for peer's IP |
| 318 | address. So we replace VTY command string like below. */ |
| 319 | #ifdef HAVE_IPV6 |
| 320 | #define NEIGHBOR_CMD "neighbor (A.B.C.D|X:X::X:X) " |
| 321 | #define NO_NEIGHBOR_CMD "no neighbor (A.B.C.D|X:X::X:X) " |
| 322 | #define NEIGHBOR_ADDR_STR "Neighbor address\nIPv6 address\n" |
| 323 | #define NEIGHBOR_CMD2 "neighbor (A.B.C.D|X:X::X:X|WORD) " |
| 324 | #define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|X:X::X:X|WORD) " |
| 325 | #define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor IPv6 address\nNeighbor tag\n" |
| 326 | #else |
| 327 | #define NEIGHBOR_CMD "neighbor A.B.C.D " |
| 328 | #define NO_NEIGHBOR_CMD "no neighbor A.B.C.D " |
| 329 | #define NEIGHBOR_ADDR_STR "Neighbor address\n" |
| 330 | #define NEIGHBOR_CMD2 "neighbor (A.B.C.D|WORD) " |
| 331 | #define NO_NEIGHBOR_CMD2 "no neighbor (A.B.C.D|WORD) " |
| 332 | #define NEIGHBOR_ADDR_STR2 "Neighbor address\nNeighbor tag\n" |
| 333 | #endif /* HAVE_IPV6 */ |
| 334 | |
| 335 | /* Prototypes. */ |
| 336 | void install_node(struct cmd_node *, int (*)(struct vty *)); |
Holger Hans Peter Freyther | a9e5252 | 2015-08-02 02:14:07 +0000 | [diff] [blame] | 337 | void install_default(int node_type); |
| 338 | void install_element(int node_type, struct cmd_element *); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 339 | void install_element_ve(struct cmd_element *cmd); |
Harald Welte | 95b2b47 | 2011-07-16 11:58:09 +0200 | [diff] [blame] | 340 | void sort_node(void); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 341 | |
Jacob Erlbeck | 0c987bd | 2013-09-06 16:52:00 +0200 | [diff] [blame] | 342 | /* This is similar to install_default() but it also creates |
| 343 | * 'exit' and 'end' commands. |
| 344 | */ |
Holger Hans Peter Freyther | a9e5252 | 2015-08-02 02:14:07 +0000 | [diff] [blame] | 345 | void vty_install_default(int node_type); |
Jacob Erlbeck | 0c987bd | 2013-09-06 16:52:00 +0200 | [diff] [blame] | 346 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 347 | /* Concatenates argv[shift] through argv[argc-1] into a single NUL-terminated |
| 348 | string with a space between each element (allocated using |
| 349 | XMALLOC(MTYPE_TMP)). Returns NULL if shift >= argc. */ |
| 350 | char *argv_concat(const char **argv, int argc, int shift); |
| 351 | |
| 352 | vector cmd_make_strvec(const char *); |
| 353 | void cmd_free_strvec(vector); |
| 354 | vector cmd_describe_command(); |
| 355 | char **cmd_complete_command(); |
| 356 | const char *cmd_prompt(enum node_type); |
| 357 | int config_from_file(struct vty *, FILE *); |
| 358 | enum node_type node_parent(enum node_type); |
| 359 | int cmd_execute_command(vector, struct vty *, struct cmd_element **, int); |
| 360 | int cmd_execute_command_strict(vector, struct vty *, struct cmd_element **); |
| 361 | void config_replace_string(struct cmd_element *, char *, ...); |
| 362 | void cmd_init(int); |
| 363 | |
| 364 | /* Export typical functions. */ |
| 365 | extern struct cmd_element config_exit_cmd; |
| 366 | extern struct cmd_element config_help_cmd; |
| 367 | extern struct cmd_element config_list_cmd; |
Harald Welte | 8ec7f90 | 2012-10-22 19:43:26 +0200 | [diff] [blame] | 368 | extern struct cmd_element config_end_cmd; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 369 | char *host_config_file(); |
| 370 | void host_config_set(const char *); |
| 371 | |
| 372 | /* This is called from main when a daemon is invoked with -v or --version. */ |
| 373 | void print_version(int print_copyright); |
| 374 | |
| 375 | extern void *tall_vty_cmd_ctx; |
| 376 | |
Sylvain Munaut | dca7d2c | 2012-04-18 21:53:23 +0200 | [diff] [blame] | 377 | /*! @} */ |