diff options
author | Chris Hall <chris.hall@highwayman.com> | 2011-02-13 22:53:14 +0000 |
---|---|---|
committer | Chris Hall <chris.hall@highwayman.com> | 2011-02-13 22:53:14 +0000 |
commit | 64be6d766a65dc0749d17f5023d714678e9c96a6 (patch) | |
tree | f97e04068600d0851687b58d25ff198d1eb6cc73 /lib/command_local.h | |
parent | 8443ca08672e0cf5b779f59db9d556dadf763de7 (diff) | |
download | quagga-ex10p.tar.bz2 quagga-ex10p.tar.xz |
Initial commit to seed the "pipework" branchex10p
This is a major revision of the command processing, in order to support
new lexical level for command lines, plus all the necessary I/O
redirection for the pipes.
This is version 0.99.15ex10p.
This supports:
< filename
<+ filename
.... > filename
.... >> filename
.... >*
Also contains all lexical level handling of '...', "...." and \x in order
to allow use of '>' et al if required.
Updated command line completion and help is a work in progress.
Diffstat (limited to 'lib/command_local.h')
-rw-r--r-- | lib/command_local.h | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/lib/command_local.h b/lib/command_local.h new file mode 100644 index 00000000..321ed33e --- /dev/null +++ b/lib/command_local.h @@ -0,0 +1,161 @@ +/* Command handler -- header for stuff used within command/vty + * Copyright (C) 1997, 98 Kunihiro Ishiguro + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _ZEBRA_COMMAND_LOCAL_H +#define _ZEBRA_COMMAND_LOCAL_H + +#include "command_common.h" /* First and foremost ! */ + +#include "vty_local.h" +#include "vector.h" + +/*============================================================================== + * This is for access to some things in command.c which are not required + * by external users, who use command.h. + * + * This is for use within the command/vty family. + * + * Should not be used with command.h ! (Except in command.c itself.) + * + * This may duplicate things published in command.h, but also includes things + * which are not intended for "external" use. + */ + +/*------------------------------------------------------------------------------ + * Host configuration variable + */ +typedef unsigned long int name_gen_t ; + +struct host +{ + /* Host name of this router. */ + char* name ; + bool name_set ; /* set by command */ + name_gen_t name_gen ; /* incremented each time name changes */ + + /* Password for vty interface. */ + char* password; + bool password_encrypted ; + + /* Enable password */ + char* enable; + bool enable_encrypted ; + + /* System wide terminal lines default */ + int lines; + + /* Log filename. */ + char* logfile; + + /* config file name of this host */ + char* config_file ; + + /* Flags for services */ + bool advanced; + bool encrypt; + + /* Banner configuration. */ + const char* motd; + char* motdfile; + + /* Someone has the config symbol of power */ + bool config ; + + /* Allow VTY to start without password */ + bool no_password_check ; + + /* Restrict unauthenticated logins? */ + bool restricted_mode ; + + /* Vty timeout value -- see "exec timeout" command */ + unsigned long vty_timeout_val ; + + /* Vty access-class command */ + char* vty_accesslist_name ; + + /* Vty access-class for IPv6. */ + char* vty_ipv6_accesslist_name ; + + /* Current directory -- initialised in vty_init() */ + char* vty_cwd ; +} ; + +enum +{ + restricted_mode_default = false, +} ; + +/* Structure declared in command.c */ +extern struct host host ; + +/*------------------------------------------------------------------------------ + * Command qualifiers + */ +enum cmd_do +{ + cmd_do_nothing = 0, /* no action required */ + + cmd_do_command = 1, /* dispatch the current command line */ + + cmd_do_ctrl_c, /* received ^c */ + cmd_do_ctrl_d, /* received ^d */ + cmd_do_ctrl_z, /* received ^z */ + + cmd_do_eof, /* hit "EOF" */ + + cmd_do_count, /* number of different cli_do_xxx */ + + cmd_do_mask = 0x0F, + cmd_do_auth = 0x10, + cmd_do_auth_enable = 0x20, +} ; + +CONFIRM(cmd_do_count <= (cmd_do_mask + 1)) ; + +typedef enum cmd_do cmd_do_t ; + +/*------------------------------------------------------------------------------ + * Vector of nodes -- defined in command.c, declared here so the parser can + * reach it. + */ +extern vector node_vector ; + +/*----------------------------------------------------------------------------*/ + +#define MSG_CMD_ERR_AMBIGUOUS "Ambiguous command" +#define MSG_CMD_ERR_NO_MATCH "Unrecognised command" +#define MSG_CMD_ERR_NO_MATCH_old "There is no matched command" + +/*============================================================================== + * Functions in command.c + */ + +extern const char* cmd_host_name(bool fresh) ; +extern char *host_config_file(void); +extern void host_config_set(const char* file_name); + +extern const char* cmd_prompt(node_type_t node) ; + +extern node_type_t cmd_node_parent(node_type_t node) ; +extern node_type_t cmd_node_exit_to(node_type_t node) ; +extern node_type_t cmd_node_end_to(node_type_t node) ; + +#endif /* _ZEBRA_COMMAND_LOCAL_H */ |