summaryrefslogtreecommitdiff
path: root/lib/command.c
AgeCommit message (Collapse)Author
2009-06-12[cleanup] Make command nodes staticStephen Hemminger
The cmd_nodes used to configure vty, can mostly be static so (basic data hiding 101).
2008-08-23[vty] Add support for a 'restricted mode' with anonymous vty connectionsPaul Jakma
* lib/command.h: Add a RESTRICTED_NODE, intended for use with anonymous, 'no login' vtys, to provide a subset of 'view' mode commands. * lib/command.c: Add RESTRICTED_NODE bits, nothing special, just following VIEW_NODE. * lib/vty.c: (vty_auth) enable authentication should fall back to restricted/view node as appropriate. (vty_create) init vty's to restricted/view node as appropriate, for the 'no login' case. (vty_{no_,}restricted_mode_cmd) config commands to enable 'anonymous restricted' in vty configuration. (vty_config_write) 'anonymous restricted' config. (vty_init) Install some commands to restricted mode, and the 'anonymous restricted' config commands into VTY_NODE. * bgpd/*.c: Install some of the safe(r) BGP commands into 'restricted mode', i.e. lookup commands of non-sensitive data. Useful with looking-glass route-servers.
2007-04-28[logging] Add new "log timestamp precision" command for subsecond timestampsAndrew J. Schorr
2007-04-28 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * command.c: (config_write_host) Save "log timestamp precision" if not default value. (show_logging) Show configured timestamp precision. (config_log_timestamp_precision) Enable configuration of timestamp precision. (no_config_log_timestamp_precision) Restore default timestamp precision. (cmd_init) Install new timestamp precision commands. * log.h: (struct zlog) New timestamp_precision field. (quagga_timestamp) New function to generate a timestamp with the desired precision. (struct timestamp_control) Declare a structure for use in avoiding repeated duplicate calls to quagga_timestamp. * log.c: (quagga_timestamp) New function to generate a timestamp of the desired precision. (time_print) Call quagga_timestamp if the time hasn't already been calculated. (vzlog) Initialize a timestamp_control structure and pass it to time_print and vty_log. (zlog_backtrace) Fix 64-bit problem: cannot print size_t with %u. * vty.h: Must now include "log.h". (vty_log) Takes an additional struct timestamp_control argument. * vty.c: (vty_log_out) Use new struct timestamp_control and new quagga_timestamp function to print timestamps of the desired precision. (vty_time_print) Use new quagga_timestamp function. (vty_log) Accept new struct timestamp_control argument and pass it down to vty_log_out.
2006-06-15[lib] Fix vector leak in error path in command.c, CID #38Paul Jakma
2006-06-15 Paul Jakma <paul.jakma@sun.com> * command.c: (cmd_describe_command_real) Fix leak, CID #38.
2006-05-12[lib] CID #55, fix return of freed pointer, cmd_describe_command_realPaul Jakma
2006-05-12 Paul Jakma <paul.jakma@sun.com> * command.c: (cmd_describe_command_real) Fix return of freed pointer when no-match, CID #55.
2006-05-12[lib] CID #37, fix error case leak, cmd_complete_command_realPaul Jakma
2006-05-12 Paul Jakma <paul.jakma@sun.com> * command.c: (cmd_complete_command_real) Fix leak of cmd_vector in error case, Coverity CID #37.
2005-10-262005-10-26 Paul Jakma <paul.jakma@sun.com>paul
* command.c: Use MTYPE_HOST, MTYPE_STRVEC. Some other fixups, including fixing some likely leaks in config_write_file. * vty.c: memory macro usage fixes. (vty_read_config) fix leak where relative config file is specified.
2005-09-052005-09-05 Paul Jakma <paul.jakma@sun.com>paul
* command.c: (install_element) be more robust. Eg, cmd_init need not have been called, some applications may use other library subsystems, which call install_element, without the application wanting commands and hence not calling cmd_init.
2005-08-222005-08-22 Hugo Santos <hsantos@av.it.pt>paul
* command.h: (enum node_type) Add BGP_IPV6M_NODE * command.c: (node_parent) Handle BGP_IPV6M_NODE node (config_exit, config_end) ditto * vty.c: (vty_end_config) Handle BGP_IPV6M_NODE node
2005-05-062005-05-06 Paul Jakma <paul@dishone.st>paul
* (general) extern and static'ification of functions in code and header. Cleanup any definitions with unspecified arguments. Add casts for callback assignments where the callback is defined, typically, as passing void *, but the function being assigned has some other pointer type defined as its argument, as gcc complains about casts from void * to X* via function arguments. Fix some old K&R style function argument definitions. Add noreturn gcc attribute to some functions, as appropriate. Add unused gcc attribute to some functions (eg ones meant to help while debugging) Add guard defines to headers which were missing them. * command.c: (install_node) add const qualifier, still doesnt shut up the warning though, because of the double pointer. (cmp_node) ditto * keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived fromn vty.h ones to fix some of the (long) < 0 warnings. * thread.c: (various) use thread_empty (cpu_record_hash_key) should cast to uintptr_t, a stdint.h type * vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they removed from ospfd/ospf_vty.h * zebra.h: Move definition of ZEBRA_PORT to here, to remove dependence of lib on zebra/zserv.h
2005-04-252005-04-25 Paul Jakma <paul.jakma@sun.com>paul
* workqueue.{c,h}: Helper API for setting up and running queues via background threads. * command.c: install the 'show workqueues' command * memtypes.c: Add work queue mtypes, and a rib-queue type for a zebra rib work queue. * memtypes.h: Updated to match memtypes.c * Makefile.am: Add new workqueue files to build.
2005-03-142005-03-14 Paul Jakma <paul.jakma@sun.com>paul
* (global) update all c files to match the lib/vector.h rename of (struct vector).active to max, and vector_max macro to vector_active. * lib/vector.h: Rename to (struct vector).max to slightly less confusing active, for the number of active slots, distinct from allocated or active-and-not-empty. Rename vector_max to vector_active for same reason.
2005-03-142005-03-14 Paul Jakma <paul.jakma@sun.com>paul
* command.c: (various) Fix indentation and other whitespace.
2005-03-142005-03-14 Paul Jakma <paul.jakma@sun.com>paul
* command.c: (sort_node) use vector_max instead of referencing (struct vector *)->max directly. Test that vector_max is > 0 before using it to calculate an index. Fixup vector loop to make main body conditional on vector slot not being empty. (cmd_cmdsize) Fixup vector loop to make main body conditional on vector slot not being empty. (cmd_filter_by_completion) ditto (cmd_filter_by_string) ditto (is_cmd_ambiguous) ditto (cmd_describe_command_real) Change index integers to unsigned. Test that vector_max is > 0 before using it to calculate an index. Return immediately with CMD_ERR_NO_MATCH if vline has no active slots. Fixup vector loop to make main body conditional on vector slot not being empty. (cmd_complete_command_real) ditto. (cmd_execute_command_strict) Fixup vector loop to be conditional on non-null slot.
2005-03-092005-03-09 Paul Jakma <paul.jakma@sun.com>paul
* command.c: (config_list_cmd) Don't list hidden or deprecated commands, hiding these from tab completion is still to be done.
2005-03-092005-03-09 Paul Jakma <paul.jakma@sun.com>paul
* command.c: Undo commit of sign warning fix and hidden command in list_cmd. Sign warning is more subtle. list_cmd on its own will be committed after.
2005-03-082005-03-08 Paul Jakma <paul.jakma@sun.com>paul
* command.c: (no_banner_motd_cmd) use XFREE. * vty.c: (vty_hello) fix the indentation and comment.
2005-03-082005-03-08 Paul Jakma <paul.jakma@sun.com>paul
* command.c: (cmd_describe_command_real) sign compile warning fix (cmd_complete_command_real) ditto. (config_list_cmd) Don't list hidden or deprecated commands, hiding these from tab completion is still to be done. * command.h: cmd attr enum should start at 1.
2005-03-082005-03-08 Paul Jakma <paul.jakma@sun.com>paul
* command.c: (banner_motd_file_cmd) use XSTRDUP/XFREE * vty.c: (vty_hello) suggestions from Andrew, read by line and stub out trailling non-printable characters on each line thus allowing us to specify VTY_NEWLINE to vty_out.
2005-03-082005-03-08 Jeroen Massar <jeroen@unfix.org>paul
* vty.c: (vty_hello) display motd file, if set * command.h: add char *motdfile to struct host * command.c: (config_write_host) write out motdfile config (banner_motd_file_cmd) new command, allow motd to be read from file. (no_banner_motd_cmd) free motdfile string, if needs be. (cmd_init) init (struct host).motdfile. Add new motd file commands.
2005-03-07 * command.c: host.name might be NULL.hasso
* vty.c: Fix fd leak. [backport candidate]
2005-01-282005-01-28 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* lib/command.h: Document behavior of argv_concat function. * lib/command.c: (argv_concat) Calculate total string length first so we can call malloc just once (instead of realloc'ing to add each string element). (do_echo,config_logmsg) Allow for possible NULL return value from argv_concat.
2005-01-23 * lib/command.[ch]: Make node_parent() function nonstatic. vtyh.c willhasso
use it as well. * vtysh/vtysh.c: Implement walkup in node tree for vtysh as it already works in vty.
2005-01-16 * command.[ch], vty.c: cmd_execute_command() function must not attempthasso
to walk up in the node tree if called from vtysh. Different daemons might have commands with same syntax in different nodes (for example "router-id x.x.x.x" commands in zebra/ospfd/ospf6d daemons). * vtysh.c: Reflect changes in lib. cmd_execute_command() should know now that it's called from vtysh and must not attempt to walk up in the node tree. [pullup candidate]
2005-01-142005-01-14 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* command.c (print_version): Do not bother even to examine host.name, since it is always NULL when this function is called from main.
2005-01-142005-01-14 Greg Troxel <gdt@fnord.ir.bbn.com>gdt
* command.c (print_version): Don't print host.name if it is NULL. Fixes segfault on Solaris reported by Goetz von Escher <goetz@open.ch> (pullup candidate)
2005-01-02Reverting some int -> unsigned int fixes in command.c for now. Fixes crashhasso
described in [quagga-dev 2292].
2004-12-172004-12-17 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* command.c: (do_echo) Added new "echo" command, useful for watchdog pinging to make sure the daemon is responsive.
2004-12-072004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* command.c: (config_write_host) Note that "log trap" is deprecated when writing out the config.
2004-12-072004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* bgp_main.c: (main) The 2nd argument to openzlog has been removed. * isis_main.c: (main) The 2nd argument to openzlog has been removed. * ospf6_main.c: (main) The 2nd argument to openzlog has been removed. Note that stdout logging will no longer be enabled by default when not running as a daemon. * ospf_main.c: (main) The 2nd argument to openzlog has been removed. * rip_main.c: (main) The 2nd argument to openzlog has been removed. * ripng_main.c: (main) The 2nd argument to openzlog has been removed. * main.c: (main) The 2nd argument to openzlog has been removed. So stdout logging will no longer be enabled by default. * irdp_main.c: (irdp_finish) Reduce severity of shutdown message from LOG_WARNING to LOG_INFO. * vtysh.c: Make several functions static instead of global. Added several commands to support destination-specific logging levels. (vtysh_completion) This function is unused, so comment it out. * basic.texi: Document new logging features. Separate basic config commands from basic VTY commands. * log.h: Replace struct zlog flags and maskpri fields with maxlvl array to support individual logging levels for each destination. Remove the 2nd argument to openzlog since the default logging config should be standardized inside the library. Replaced the zlog_set_flag and zlog_reset_flag functions with zlog_set_level. And zlog_set_file now requires an additional log_level argument. Declare zlog_proto_names for use inside command.c in the "show logging" command. Added defines useful for command construction. * log.c: (vzlog) Decide where to send the message based on the individual logging levels configured for each destination. Remove support for ZLOG_STDERR since it was never actually used. Support record-priority for terminal monitors. (zlog_signal,zlog_backtrace_sigsafe) Support destination-specific logging levels. Remove stderr support (was never used). Added support for terminal monitor logging. (_zlog_assert_failed) Increase message severity to LOG_EMERG. (openzlog) Remove 2nd argument since default config should be standardized in library. By default, terminal monitoring is set to debug, and all other logging is disabled. (zlog_set_flag,zlog_reset_flag) Removed. (zlog_set_level) New function to replace zlog_set_flag and zlog_reset_flag. Supports destination-specific logging levels. (zlog_set_file,zlog_reset_file) Support file-specific logging level. (zlog_rotate) Log an error message if fopen fails, and support new file-specific logging level. * command.h: Change DEFUN_CMD_FUNC_DECL and DEFUN_CMD_FUNC_TEXT so that command functions will be static instead of global. Remove declarations for config_exit and config_help. Define new macros DEFUNSH_ATTR, DEFUNSH_HIDDEN, and DEFUNSH_DEPRECATED so we can have deprecated commands in vtysh. Similarly, for completeness, define macros ALIAS_SH, ALIAS_SH_HIDDEN, and ALIAS_SH_DEPRECATED. Also, fix bug in ALIAS_ATTR macro (didn't matter because it was never used). * command.c: Make many functions static instead of global. (facility_name,facility_match,level_match) New functions to support enhanced destination-specific logging levels. (config_write_host) Support new destination-specific logging levels. (config_logmsg) Added new "logmsg" command to help test logging system. (show_logging) Added "show logging" command to show the current configuration of the logging system. (config_log_stdout_level) Support explicit stdout logging level. (no_config_log_stdout) Now takes optional LEVEL arg. (config_log_monitor,config_log_monitor_level,no_config_log_monitor) New commands creating new "log monitor" commands to set terminal monitoring log level. (config_log_file_level) Support explicit file logging level. (config_log_syslog_level) Support explicit syslog logging level. (config_log_facility,no_config_log_facility) Implement new "log facility" command. (cmd_init) Add hooks for new commands: "show logging", "logmsg", "log stdout <level>", "log monitor", "log monitor <level>", "no log monitor", "log file <filename> <level>", "no log file <filename> <level>", "log syslog <level>", "log facility", and "no log facility". * vty.h: Added a "level" argument to vty_log so it can support "log record-priority". Declare new function vty_log_fixed for use in signal handlers. * vty.c: (vty_log,vty_log_out) Added a "level" argument to support "log record-priority" for vty terminal monitors. (vty_down_level) Use config_exit_cmd.func instead of calling config_exit directly (since command functions will now be static instead of global). (vty_log_fixed) New function to send terminal monitor messages from inside a signal handler.
2004-12-032004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* command.h: Remove fields log_stdout and log_syslog from struct host, since they are just trying to duplicate information in the zlog_default structure. Note that this fixes a bug since those fields were not registering any logging that was established in the initial call to openzlog (this affects only the zebra and ospf6d daemons). It is probably a bug to turn on any logging by default in the call to openzlog. * command.c: (config_write_host) Get logging info from zlog_default instead of now-removed fields host.log_stdout and host.log_syslog. (config_log_stdout,no_config_log_stdout) Do not set now-removed field host.log_stdout, since this info is recorded in zlog_default. (config_log_file) Use XSTRDUP (instead of strdup) to set host.logfile. (config_log_syslog,config_log_syslog_facility,no_config_log_syslog) Do not set now-removed field host.log_syslog, since this info is recorded in zlog_default.
2004-11-232004-11-23 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* log.c: (vzlog) Take a single va_list argument and use va_copy as necessary for multiple traversals. (zlog) Pass only one va_list to vzlog. (zlog_*,plog_*) Use a macro for boilerplate code; pass only one va_list to vzlog. (zlog_set_file) Remove unused 2nd argument (flags). (zlog_save_cwd,zlog_get_cwd,zlog_free_cwd) Remove unused functions. * log.h: Remove ZLOG_*_INDEX defines (no longer used). Remove unused 2nd argument from zlog_set_file prototype. Fix prototype for zlog_rotate. * command.c: (config_log_file) Remove unused 2nd arg to zlog_set_file. * vty.c: (vty_out) Fix stdarg usage to perform multiple traversals properly. (vty_log) Must use va_copy for multiple traversals of va_list arg.
2004-11-202004-11-19 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* global: Replace strerror with safe_strerror. And vtysh/vtysh.c needs to include "log.h" to pick up the declaration.
2004-10-19Small copyright string and hostname related cleanup.hasso
2004-10-13Fix critical bugzilla #113. Make CMD_ERR_NOTHING_TODO nonfatal.hasso
2004-10-132004-10-13 Paul Jakma <paul@dishone.st>paul
* (global) more const'ification. * sockunion.c: (sockunion_su2str) buffer should be sized SU_ADDRSTRLEN. (sockunion_log) do not return stack variables, strdup buf before return. * vty.h: Fix up the VTY_GET_INTEGER macros. Testing caller supplied values against ULONG_MAX is daft, when caller probably has passed a type that can not hold ULONG_MAX. use a temporary long instead. Add VTY_GET_LONG, make VTY_GET_INTEGER_RANGE use it, make VTY_GET_INTEGER a define for VTY_GET_INTEGER_RANGE.
2004-10-102004-10-10 Paul Jakma <paul@dishone.st>paul
* version.h.in: (pid_output*) add const qualifier. * command.h: Change DEFUN func to take const char *[] rather than char **, to begin process of fixing compile warnings in lib/. Nearly all other changes in this commit follow from this change. * buffer.{c,h}: (buffer_write) pointer-arithmetic is gccism, take const void * and cast an automatic const char *p to it. (buffer_putstr) add const * command.c: (zencrypt) const qualifier (cmd_execute_command_real) ditto (cmd_execute_command_strict) ditto (config_log_file) ditto. Fix leak of getcwd() returned string. * memory.{c,h}: Add MTYPE_DISTRIBUTE_IFNAME for struct dist ifname. * distribute.{c,h}: Update with const qualifier. (distribute_free) use MTYPE_DISTRIBUTE_IFNAME (distribute_lookup) Cast to char *, note that it's ok. (distribute_hash_alloc) use MTYPE_DISTRIBUTE_IFNAME. (distribute_get) Cast to char *, note that it's ok. * filter.c: Update with const qualifier. * if.{c,h}: ditto. * if_rmap.{c,h}: ditto. (if_rmap_lookup) Cast to char *, note that it's ok. (if_rmap_get) ditto. * log.{c,h}: Update with const qualifier. * plist.{c,h}: ditto. * routemap.{c,h}: ditto. * smux.{c,h}: ditto. Fix some signed/unsigned comparisons. * sockopt.c: (getsockopt_cmsg_data) add return for error case. * vty.c: Update with const qualifier.
2004-10-07Even more const strings and fix to bugfix.hasso
2004-10-07Make more strings const.hasso
2004-10-05Number of warnings is down to 3 again in lib directory. A lot of const'shasso
added to strings and a lot of int -> unsigned int changes.
2004-10-03Big vtysh cleanup. See changelogs for details.hasso
2004-09-132004-09-13 Paul Jakma <paul@dishone.st>paul
* configure.ac: capitalise the package name. autoconf lowercases it for PACKAGE_TARNAME. * lib/command.c: Update the copyright string in the default motd.
2004-08-27Make "terminal length <0-512>" command work in vtysh.hasso
2004-03-162004-03-16 David Young <dyoung@pobox.com>gdt
* (many) reference <lib/version.h> rather than "version.h", because version.h is a generated file and not present in the source tree when using objdir builds. (committed by gdt) works fine with normal builds; didn't try objdir
2003-12-23Merge isisd into the Quagga's framework:jardin
- add privs support - use misc quagga's definitions - make it compile"able" - fix segfault cases related to hostname() - add debug isis xxx command This patch has been approved by Paul Jakma.
2003-12-222003-12-22 Christian Hammers <ch@lathspell.de>gdt
* configure.ac (and everywhere a regular file is opened for writing): use file permissions from configure rather than compiled-in umask.
2003-08-212003-08-20 Yasuhiro Ohara <yasu@sfc.wide.ad.jp>paul
* command.c: Fix <cr> display problem for command line description.
2003-08-132003-08-13 Paul Jakma <paul@dishone.st>paul
* lib/version.h: Add QUAGGA_PROGNAME * lib/smux.c: hardcoded zebra/quagga -> QUAGGA_PROGNAME * lib/command.c: ditto * vtysh/vtysh_user.c: ditto
2003-08-122003-08-12 Paul Jakma <paul@dishone.st>paul
2003-08-12 Paul Jakma <paul@dishone.st> * Makefile.am: redhat/zebra.* -> redhat/quagga.* * configure.ac: Bump autoconf prerequisite to 2.53. dist name zebra -> quagga. general Zebra -> Quagga where appropriate (ie not zebra daemon). User and group zebra->quagga. s/ZEBRA\(_VERSION\)/QUAGGA\1/. * bgpd/bgp_main.c: s/ZEBRA\(_VERSION\)/QUAGGA\1/ * lib/command.c: Update banners and s/ZEBRA\(_VERSION\)/QUAGGA\1/ * lib/print_version.c: ditto * lib/version.h: s/ZEBRA\(_VERSION\)/QUAGGA\1/ and bump version. Change ZEBRA_URL. * lib/smux.c: s/ZEBRA\(_VERSION\)/QUAGGA\1/ * lib/vty.h: Change Zebra.conf to Quagga.conf (integrated file) * ospf6d/ospf6{,_main}.c: s/ZEBRA\(_VERSION\)/QUAGGA\1/ * ospfd/ospf_main.c: s/ZEBRA\(_VERSION\)/QUAGGA\1/
2003-07-262003-07-26 Paul Jakma <paul at dishone.st>paul
* lib/command.c: Add config_log_syslog_facility_cmd, to set syslog facility. This was a commit to zebra.org on May 20, merge in to zebra-pj.