summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorajs <ajs>2004-12-07 15:39:31 +0000
committerajs <ajs>2004-12-07 15:39:31 +0000
commit274a4a4447b13f89f8237156a887d05a24a73cc6 (patch)
treed5c2c6ee94bb77ef4346bcc07834808a75210bfd
parent5e76477456ce8bc4a1eeaccb5c5e1d3d99ab1300 (diff)
2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* 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.
-rw-r--r--bgpd/ChangeLog4
-rw-r--r--bgpd/bgp_main.c2
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/basic.texi141
-rw-r--r--doc/quagga.info513
-rw-r--r--isisd/ChangeLog4
-rw-r--r--isisd/isis_main.c2
-rw-r--r--lib/ChangeLog69
-rw-r--r--lib/command.c636
-rw-r--r--lib/command.h29
-rw-r--r--lib/log.c167
-rw-r--r--lib/log.h82
-rw-r--r--lib/vty.c36
-rw-r--r--lib/vty.h6
-rw-r--r--ospf6d/ChangeLog6
-rw-r--r--ospf6d/ospf6_main.c8
-rw-r--r--ospfd/ChangeLog4
-rw-r--r--ospfd/ospf_main.c2
-rw-r--r--ripd/ChangeLog4
-rw-r--r--ripd/rip_main.c2
-rw-r--r--ripngd/ChangeLog4
-rw-r--r--ripngd/ripng_main.c2
-rw-r--r--vtysh/ChangeLog6
-rw-r--r--vtysh/vtysh.c175
-rw-r--r--zebra/ChangeLog7
-rw-r--r--zebra/irdp_main.c2
-rw-r--r--zebra/main.c2
27 files changed, 1291 insertions, 629 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index c76627b6..705d76f9 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * bgp_main.c: (main) The 2nd argument to openzlog has been removed.
+
2004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* bgp_main.c: (sigint) Use zlog_notice for termination message.
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index ee498b0c..6de0a8a0 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -205,7 +205,7 @@ main (int argc, char **argv)
/* Preserve name of myself. */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog (progname, ZLOG_NOLOG, ZLOG_BGP,
+ zlog_default = openzlog (progname, ZLOG_BGP,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
/* BGP master init. */
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 6afe5a3d..0327be2b 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * basic.texi: Document new logging features. Separate basic config
+ commands from basic VTY commands.
+
2004-11-25 Hasso Tepper <hasso at quagga.net>
* *.8: Document -g/--group command line switch and some small
diff --git a/doc/basic.texi b/doc/basic.texi
index ab976445..cbbdea49 100644
--- a/doc/basic.texi
+++ b/doc/basic.texi
@@ -15,9 +15,10 @@ The following sections discuss commands common to all the routing
daemons.
@menu
+* Terminal Mode Commands:: Common commands used in a VTY
* Config Commands:: Commands used in config files
* Common Invocation Options:: Starting the daemons
-* Virtual Terminal Interfaces:: Interacting with the daemons
+* Virtual Terminal Interfaces:: Interacting with the daemons
@end menu
@@ -78,47 +79,85 @@ accept connections.
Set enable password.
@end deffn
+@deffn Command {log trap @var{level}} {}
+@deffnx Command {no log trap} {}
+These commands are deprecated and are present only for historical compatibility.
+The log trap command sets the current logging level for all enabled
+logging destinations, and it sets the default for all future logging commands
+that do not specify a level. The normal default
+logging level is debugging. The @code{no} form of the command resets
+the default level for future logging commands to debugging, but it does
+not change the logging level of existing logging destinations.
+@end deffn
+
+
@deffn Command {log stdout} {}
+@deffnx Command {log stdout @var{level}} {}
@deffnx Command {no log stdout} {}
-Set logging output to stdout.
+Enable logging output to stdout.
+If the optional second argument specifying the
+logging level is not present, the default logging level (typically debugging,
+but can be changed using the deprecated @code{log trap} command) will be used.
+The @code{no} form of the command disables logging to stdout.
+The @code{level} argument must have one of these values:
+emergencies, alerts, critical, errors, warnings, notifications, informational, or debugging. Note that the existing code logs its most important messages
+with severity @code{errors}.
@end deffn
@deffn Command {log file @var{filename}} {}
-If you want to log into a file please specify @code{filename} as
-follows.
+@deffnx Command {log file @var{filename} @var{level}} {}
+@deffnx Command {no log file} {}
+If you want to log into a file, please specify @code{filename} as
+in this example:
@example
-log file /usr/local/etc/bgpd.log
+log file /var/log/quagga/bgpd.log informational
@end example
+If the optional second argument specifying the
+logging level is not present, the default logging level (typically debugging,
+but can be changed using the deprecated @code{log trap} command) will be used.
+The @code{no} form of the command disables logging to a file.
@end deffn
@deffn Command {log syslog} {}
+@deffnx Command {log syslog @var{level}} {}
@deffnx Command {no log syslog} {}
-Set logging output to syslog.
-@end deffn
-
-@deffn Command {write terminal} {}
-Displays the current configuration to the vty interface.
-@end deffn
-
-@deffn Command {write file} {}
-Write current configuration to configuration file.
-@end deffn
-
-@deffn Command {configure terminal} {}
-Change to configuration mode. This command is the first step to
-configuration.
+Enable logging output to syslog.
+If the optional second argument specifying the
+logging level is not present, the default logging level (typically debugging,
+but can be changed using the deprecated @code{log trap} command) will be used.
+The @code{no} form of the command disables logging to syslog.
@end deffn
-@deffn Command {terminal length @var{<0-512>}} {}
-Set terminal display length to @var{<0-512>}. If length is 0, no
-display control is performed.
+@deffn Command {log monitor} {}
+@deffnx Command {log monitor @var{level}} {}
+@deffnx Command {no log monitor} {}
+Enable logging output to vty terminals that have enabled logging
+using the @code{terminal monitor} command.
+By default, monitor logging is enabled at the debugging level, but this
+command (or the deprecated @code{log trap} command) can be used to change
+the monitor logging level.
+If the optional second argument specifying the
+logging level is not present, the default logging level (typically debugging,
+but can be changed using the deprecated @code{log trap} command) will be used.
+The @code{no} form of the command disables logging to terminal monitors.
@end deffn
-@deffn Command {who} {}
+@deffn Command {log facility @var{facility}} {}
+@deffnx Command {no log facility} {}
+This command changes the facility used in syslog messages. The default
+facility is @code{daemon}. The @code{no} form of the command resets
+the facility to the default @code{daemon} facility.
@end deffn
-@deffn Command {list} {}
-List commands.
+@deffn Command {log record-priority} {}
+@deffnx Command {no log record-priority} {}
+To include the severity in all messages logged to a file, to stdout, or to
+a terminal monitor (i.e. anything except syslog),
+use the @code{log record-priority} global configuration command.
+To disable this option, use the @code{no} form of the command. By default,
+the severity level is not included in logged messages. Note: some
+versions of syslogd (including Solaris) can be configured to include
+the facility and level in the messages emitted.
@end deffn
@deffn Command {service password-encryption} {}
@@ -134,10 +173,6 @@ Set system wide line configuration. This configuration command applies
to all VTY interfaces.
@end deffn
-@deffn Command {show version} {}
-Show the current version of @value{PACKAGE_NAME} and its build host information.
-@end deffn
-
@deffn Command {line vty} {}
Enter vty configuration mode.
@end deffn
@@ -167,8 +202,6 @@ Do not perform timeout at all. This command is as same as
Restrict vty connections with an access list.
@end deffn
-
-
@node Sample Config File
@subsection Sample Config File
@@ -204,6 +237,52 @@ comment and the password is set to 'zebra!password'.
+@node Terminal Mode Commands
+@section Terminal Mode Commands
+
+@deffn Command {write terminal} {}
+Displays the current configuration to the vty interface.
+@end deffn
+
+@deffn Command {write file} {}
+Write current configuration to configuration file.
+@end deffn
+
+@deffn Command {configure terminal} {}
+Change to configuration mode. This command is the first step to
+configuration.
+@end deffn
+
+@deffn Command {terminal length @var{<0-512>}} {}
+Set terminal display length to @var{<0-512>}. If length is 0, no
+display control is performed.
+@end deffn
+
+@deffn Command {who} {}
+Show a list of currently connected vty sessions.
+@end deffn
+
+@deffn Command {list} {}
+List all available commands.
+@end deffn
+
+@deffn Command {show version} {}
+Show the current version of @value{PACKAGE_NAME} and its build host information.
+@end deffn
+
+@deffn Command {show logging} {}
+Shows the current configuration of the logging system. This includes
+the status of all logging destinations.
+@end deffn
+
+@deffn Command {logmsg @var{level} @var{message}} {}
+Send a message to all logging destinations that are enabled for messages
+of the given severity.
+@end deffn
+
+
+
+
@node Common Invocation Options
@section Common Invocation Options
@c COMMON_OPTIONS
diff --git a/doc/quagga.info b/doc/quagga.info
index b2db6d9a..c6045838 100644
--- a/doc/quagga.info
+++ b/doc/quagga.info
@@ -22,7 +22,7 @@ END-INFO-DIR-ENTRY
This file documents the Quagga Software Routing Suite which manages
common TCP/IP routing protocols.
- This is Edition 0.97.3, last updated 7 November 2004 of `The Quagga
+ This is Edition 0.97.3, last updated 8 November 2004 of `The Quagga
Manual', for Quagga Version 0.97.3.
Copyright (C) 1999-2004 Kunihiro Ishiguro, et al.
@@ -693,12 +693,13 @@ daemons.
* Menu:
+* Terminal Mode Commands:: Common commands used in a VTY
* Config Commands:: Commands used in config files
* Common Invocation Options:: Starting the daemons
-* Virtual Terminal Interfaces:: Interacting with the daemons
+* Virtual Terminal Interfaces:: Interacting with the daemons

-File: quagga.info, Node: Config Commands, Next: Common Invocation Options, Up: Basic commands
+File: quagga.info, Node: Config Commands, Next: Common Invocation Options, Prev: Terminal Mode Commands, Up: Basic commands
3.1 Config Commands
===================
@@ -742,37 +743,78 @@ File: quagga.info, Node: Basic Config Commands, Next: Sample Config File, Up:
-- Command: enable password PASSWORD
Set enable password.
+ -- Command: log trap LEVEL
+ -- Command: no log trap
+ These commands are deprecated and are present only for historical
+ compatibility. The log trap command sets the current logging
+ level for all enabled logging destinations, and it sets the
+ default for all future logging commands that do not specify a
+ level. The normal default logging level is debugging. The `no'
+ form of the command resets the default level for future logging
+ commands to debugging, but it does not change the logging level of
+ existing logging destinations.
+
-- Command: log stdout
+ -- Command: log stdout LEVEL
-- Command: no log stdout
- Set logging output to stdout.
+ Enable logging output to stdout. If the optional second argument
+ specifying the logging level is not present, the default logging
+ level (typically debugging, but can be changed using the
+ deprecated `log trap' command) will be used. The `no' form of the
+ command disables logging to stdout. The `level' argument must
+ have one of these values: emergencies, alerts, critical, errors,
+ warnings, notifications, informational, or debugging. Note that
+ the existing code logs its most important messages with severity
+ `errors'.
-- Command: log file FILENAME
- If you want to log into a file please specify `filename' as
- follows.
- log file /usr/local/etc/bgpd.log
+ -- Command: log file FILENAME LEVEL
+ -- Command: no log file
+ If you want to log into a file, please specify `filename' as in
+ this example:
+ log file /var/log/quagga/bgpd.log informational
+ If the optional second argument specifying the logging level is
+ not present, the default logging level (typically debugging, but
+ can be changed using the deprecated `log trap' command) will be
+ used. The `no' form of the command disables logging to a file.
-- Command: log syslog
+ -- Command: log syslog LEVEL
-- Command: no log syslog
- Set logging output to syslog.
-
- -- Command: write terminal
- Displays the current configuration to the vty interface.
-
- -- Command: write file
- Write current configuration to configuration file.
-
- -- Command: configure terminal
- Change to configuration mode. This command is the first step to
- configuration.
-
- -- Command: terminal length <0-512>
- Set terminal display length to <0-512>. If length is 0, no
- display control is performed.
-
- -- Command: who
-
- -- Command: list
- List commands.
+ Enable logging output to syslog. If the optional second argument
+ specifying the logging level is not present, the default logging
+ level (typically debugging, but can be changed using the
+ deprecated `log trap' command) will be used. The `no' form of the
+ command disables logging to syslog.
+
+ -- Command: log monitor
+ -- Command: log monitor LEVEL
+ -- Command: no log monitor
+ Enable logging output to vty terminals that have enabled logging
+ using the `terminal monitor' command. By default, monitor logging
+ is enabled at the debugging level, but this command (or the
+ deprecated `log trap' command) can be used to change the monitor
+ logging level. If the optional second argument specifying the
+ logging level is not present, the default logging level (typically
+ debugging, but can be changed using the deprecated `log trap'
+ command) will be used. The `no' form of the command disables
+ logging to terminal monitors.
+
+ -- Command: log facility FACILITY
+ -- Command: no log facility
+ This command changes the facility used in syslog messages. The
+ default facility is `daemon'. The `no' form of the command resets
+ the facility to the default `daemon' facility.
+
+ -- Command: log record-priority
+ -- Command: no log record-priority
+ To include the severity in all messages logged to a file, to
+ stdout, or to a terminal monitor (i.e. anything except syslog),
+ use the `log record-priority' global configuration command. To
+ disable this option, use the `no' form of the command. By default,
+ the severity level is not included in logged messages. Note: some
+ versions of syslogd (including Solaris) can be configured to
+ include the facility and level in the messages emitted.
-- Command: service password-encryption
Encrypt password.
@@ -784,9 +826,6 @@ File: quagga.info, Node: Basic Config Commands, Next: Sample Config File, Up:
Set system wide line configuration. This configuration command
applies to all VTY interfaces.
- -- Command: show version
- Show the current version of Quagga and its build host information.
-
-- Command: line vty
Enter vty configuration mode.
@@ -841,9 +880,46 @@ normal character. So in the above example '!' will not be regarded as a
comment and the password is set to 'zebra!password'.

+File: quagga.info, Node: Terminal Mode Commands, Next: Config Commands, Up: Basic commands
+
+3.2 Terminal Mode Commands
+==========================
+
+ -- Command: write terminal
+ Displays the current configuration to the vty interface.
+
+ -- Command: write file
+ Write current configuration to configuration file.
+
+ -- Command: configure terminal
+ Change to configuration mode. This command is the first step to
+ configuration.
+
+ -- Command: terminal length <0-512>
+ Set terminal display length to <0-512>. If length is 0, no
+ display control is performed.
+
+ -- Command: who
+ Show a list of currently connected vty sessions.
+
+ -- Command: list
+ List all available commands.
+
+ -- Command: show version
+ Show the current version of Quagga and its build host information.
+
+ -- Command: show logging
+ Shows the current configuration of the logging system. This
+ includes the status of all logging destinations.
+
+ -- Command: logmsg LEVEL MESSAGE
+ Send a message to all logging destinations that are enabled for
+ messages of the given severity.
+
+
File: quagga.info, Node: Common Invocation Options, Next: Virtual Terminal Interfaces, Prev: Config Commands, Up: Basic commands
-3.2 Common Invocation Options
+3.3 Common Invocation Options
=============================
These options apply to all Quagga daemons.
@@ -895,7 +971,7 @@ These options apply to all Quagga daemons.

File: quagga.info, Node: Virtual Terminal Interfaces, Prev: Common Invocation Options, Up: Basic commands
-3.3 Virtual Terminal Interfaces
+3.4 Virtual Terminal Interfaces
===============================
VTY - Virtual Terminal [aka TeletYpe] Interface is a command line
@@ -910,7 +986,7 @@ interface (CLI) for user interaction with the routing daemon.

File: quagga.info, Node: VTY Overview, Next: VTY Modes, Up: Virtual Terminal Interfaces
-3.3.1 VTY Overview
+3.4.1 VTY Overview
------------------
VTY stands for Virtual TeletYpe interface. It means you can connect to
@@ -951,7 +1027,7 @@ all.

File: quagga.info, Node: VTY Modes, Next: VTY CLI Commands, Prev: VTY Overview, Up: Virtual Terminal Interfaces
-3.3.2 VTY Modes
+3.4.2 VTY Modes
---------------
There are three basic VTY modes:
@@ -967,7 +1043,7 @@ There are three basic VTY modes:

File: quagga.info, Node: VTY View Mode, Next: VTY Enable Mode, Up: VTY Modes
-3.3.2.1 VTY View Mode
+3.4.2.1 VTY View Mode
.....................
This mode is for read-only access to the CLI. One may exit the mode by
@@ -976,7 +1052,7 @@ leaving the system, or by entering `enable' mode.

File: quagga.info, Node: VTY Enable Mode, Next: VTY Other Modes, Prev: VTY View Mode, Up: VTY Modes
-3.3.2.2 VTY Enable Mode
+3.4.2.2 VTY Enable Mode
.......................
This mode is for read-write access to the CLI. One may exit the mode by
@@ -985,7 +1061,7 @@ leaving the system, or by escaping to view mode.

File: quagga.info, Node: VTY Other Modes, Prev: VTY Enable Mode, Up: VTY Modes
-3.3.2.3 VTY Other Modes
+3.4.2.3 VTY Other Modes
.......................
This page is for describing other modes.
@@ -993,7 +1069,7 @@ This page is for describing other modes.

File: quagga.info, Node: VTY CLI Commands, Prev: VTY Modes, Up: Virtual Terminal Interfaces
-3.3.3 VTY CLI Commands
+3.4.3 VTY CLI Commands
----------------------
Commands that you may use at the command-line are described in the
@@ -1008,7 +1084,7 @@ following three subsubsections.

File: quagga.info, Node: CLI Movement Commands, Next: CLI Editing Commands, Up: VTY CLI Commands
-3.3.3.1 CLI Movement Commands
+3.4.3.1 CLI Movement Commands
.............................
These commands are used for moving the CLI cursor. The <C> character
@@ -1038,7 +1114,7 @@ means press the Control Key.

File: quagga.info, Node: CLI Editing Commands, Next: CLI Advanced Commands, Prev: CLI Movement Commands, Up: VTY CLI Commands
-3.3.3.2 CLI Editing Commands
+3.4.3.2 CLI Editing Commands
............................
These commands are used for editing text on a line. The <C> character
@@ -1070,7 +1146,7 @@ means press the Control Key.

File: quagga.info, Node: CLI Advanced Commands, Prev: CLI Editing Commands, Up: VTY CLI Commands
-3.3.3.3 CLI Advanced Commands
+3.4.3.3 CLI Advanced Commands
.............................
There are several additional CLI commands for command line completions,
@@ -5101,7 +5177,7 @@ Command Index
* Menu:
* access-class ACCESS-LIST: Basic Config Commands.
- (line 83)
+ (line 121)
* access-list NAME deny IPV4-NETWORK: IP Access List. (line 8)
* access-list NAME permit IPV4-NETWORK: IP Access List. (line 7)
* aggregate-address A.B.C.D/M: Route Aggregation. (line 7)
@@ -5138,7 +5214,7 @@ Command Index
* auto-cost refrence-bandwidth <1-4294967>: OSPF router. (line 53)
* bandwidth <1-10000000>: Interface Commands. (line 31)
* banner motd default: Basic Config Commands.
- (line 65)
+ (line 103)
* bgp cluster-id A.B.C.D: Route Reflector. (line 7)
* bgp config-type cisco: Multiple instance. (line 20)
* bgp config-type zebra: Multiple instance. (line 49)
@@ -5154,8 +5230,8 @@ Command Index
(line 11)
* clear ip prefix-list NAME A.B.C.D/M: Clear counter of ip prefix-list.
(line 13)
-* configure terminal: Basic Config Commands.
- (line 36)
+* configure terminal: Terminal Mode Commands.
+ (line 13)
* debug event: More Show IP BGP. (line 33)
* debug keepalive: More Show IP BGP. (line 37)
* debug ospf ism: Debugging OSPF. (line 12)
@@ -5232,9 +5308,9 @@ Command Index
* enable password PASSWORD: Basic Config Commands.
(line 14)
* exec-timeout MINUTE: Basic Config Commands.
- (line 71)
+ (line 109)
* exec-timeout MINUTE SECOND: Basic Config Commands.
- (line 72)
+ (line 110)
* flush_timer TIME: ripngd Configuration.
(line 12)
* hostname HOSTNAME: Basic Config Commands.
@@ -5318,16 +5394,34 @@ Command Index
* ipv6 route NETWORK GATEWAY DISTANCE: Static Route Commands.
(line 78)
* line vty: Basic Config Commands.
- (line 62)
+ (line 100)
* link-detect: Interface Commands. (line 37)
-* list: Basic Config Commands.
- (line 46)
+* list: Terminal Mode Commands.
+ (line 24)
+* log facility FACILITY: Basic Config Commands.
+ (line 74)
* log file FILENAME: Basic Config Commands.
- (line 21)
+ (line 41)
+* log file FILENAME LEVEL: Basic Config Commands.
+ (line 42)
+* log monitor: Basic Config Commands.
+ (line 61)
+* log monitor LEVEL: Basic Config Commands.
+ (line 62)
+* log record-priority: Basic Config Commands.
+ (line 80)
* log stdout: Basic Config Commands.
- (line 17)
+ (line 28)
+* log stdout LEVEL: Basic Config Commands.
+ (line 29)
* log syslog: Basic Config Commands.
- (line 26)
+ (line 52)
+* log syslog LEVEL: Basic Config Commands.
+ (line 53)
+* log trap LEVEL: Basic Config Commands.
+ (line 17)
+* logmsg LEVEL MESSAGE: Terminal Mode Commands.
+ (line 34)
* match as-path WORD: Using AS Path in Route Map.
(line 7)
* match aspath AS_PATH: Route Map Match Command.
@@ -5429,7 +5523,7 @@ Command Index
* no auto-cost refrence-bandwidth: OSPF router. (line 54)
* no bandwidth <1-10000000>: Interface Commands. (line 32)
* no banner motd: Basic Config Commands.
- (line 68)
+ (line 106)
* no bgp multiple-instance: Multiple instance. (line 14)
* no debug event: More Show IP BGP. (line 39)
* no debug keepalive: More Show IP BGP. (line 43)
@@ -5462,7 +5556,7 @@ Command Index
* no distribute-list NAME out (kernel|connected|static|rip|ospf: Redistribute routes to OSPF.
(line 42)
* no exec-timeout: Basic Config Commands.
- (line 79)
+ (line 117)
* no ip address ADDRESS/PREFIX: Interface Commands. (line 15)
* no ip address ADDRESS/PREFIX secondary: Interface Commands. (line 20)
* no ip as-path access-list WORD: AS Path Access List. (line 12)
@@ -5511,10 +5605,20 @@ Command Index
* no ipv6 nd suppress-ra: Router Advertisement.
(line 7)
* no link-detect: Interface Commands. (line 38)
+* no log facility: Basic Config Commands.
+ (line 75)
+* no log file: Basic Config Commands.
+ (line 43)
+* no log monitor: Basic Config Commands.
+ (line 63)
+* no log record-priority: Basic Config Commands.
+ (line 81)
* no log stdout: Basic Config Commands.
- (line 18)
+ (line 30)
* no log syslog: Basic Config Commands.
- (line 27)
+ (line 54)
+* no log trap: Basic Config Commands.
+ (line 18)
* no multicast: Interface Commands. (line 28)
* no neighbor A.B.C.D: RIP Configuration. (line 46)
* no neighbor PEER default-originate: BGP Peer commands. (line 48)
@@ -5662,13 +5766,13 @@ Command Index
(line 24)
* router-id A.B.C.D: OSPF6 router. (line 9)
* service advanced-vty: Basic Config Commands.
- (line 52)
+ (line 93)
* service integrated-vtysh-config: VTY shell integrated configuration.
(line 7)
* service password-encryption: Basic Config Commands.
- (line 49)
+ (line 90)
* service terminal-length <0-512>: Basic Config Commands.
- (line 55)
+ (line 96)
* set as-path prepend AS-PATH: Using AS Path in Route Map.
(line 9)
* set as-path prepend AS_PATH: Route Map Set Command.
@@ -5819,8 +5923,10 @@ Command Index
(line 24)
* show ipv6forward: zebra Terminal Mode Commands.
(line 28)
-* show version: Basic Config Commands.
- (line 59)
+* show logging: Terminal Mode Commands.
+ (line 30)
+* show version: Terminal Mode Commands.
+ (line 27)
* shutdown: Interface Commands. (line 9)
* smux peer OID: MIB and command reference.
(line 28)
@@ -5828,18 +5934,18 @@ Command Index
(line 31)
* table TABLENO: Static Route Commands.
(line 81)
-* terminal length <0-512>: Basic Config Commands.
- (line 40)
+* terminal length <0-512>: Terminal Mode Commands.
+ (line 17)
* timers basic UPDATE TIMEOUT GARBAGE: RIP Timers. (line 7)
* timers spf <0-4294967295> <0-4294967295>: OSPF router. (line 46)
* username USERNAME nopassword: VTY shell username. (line 7)
* version VERSION: RIP Configuration. (line 23)
-* who: Basic Config Commands.
- (line 44)
-* write file: Basic Config Commands.
- (line 33)
-* write terminal: Basic Config Commands.
- (line 30)
+* who: Terminal Mode Commands.
+ (line 21)
+* write file: Terminal Mode Commands.
+ (line 10)
+* write terminal: Terminal Mode Commands.
+ (line 7)

File: quagga.info, Node: VTY Key Index, Prev: Command Index, Up: Top
@@ -5912,138 +6018,139 @@ Ref: Linux notes-Footnote-121476
Node: Build the Software21542
Node: Install the Software22090
Node: Basic commands23550
-Node: Config Commands24264
-Node: Basic Config Commands25126
-Node: Sample Config File27530
-Node: Common Invocation Options28300
-Node: Virtual Terminal Interfaces29707
-Node: VTY Overview30218
-Node: VTY Modes31469
-Node: VTY View Mode31919
-Node: VTY Enable Mode32169
-Node: VTY Other Modes32447
-Node: VTY CLI Commands32623
-Node: CLI Movement Commands33083
-Node: CLI Editing Commands33606
-Node: CLI Advanced Commands34194
-Node: Zebra34960
-Node: Invoking zebra35469
-Node: Interface Commands36048
-Node: Static Route Commands37580
-Node: zebra Terminal Mode Commands40853
-Node: RIP41818
-Node: Starting and Stopping ripd42755
-Node: RIP netmask44168
-Node: RIP Configuration45267
-Node: How to Announce RIP route49532
-Node: Filtering RIP Routes52095
-Node: RIP Metric Manipulation53562
-Node: RIP distance54475
-Node: RIP route-map55290
-Node: RIP Authentication57806
-Node: RIP Timers58913
-Node: Show RIP Information60199
-Node: RIP Debug Commands61572
-Node: RIPng62568
-Node: Invoking ripngd62888
-Node: ripngd Configuration63137
-Node: ripngd Terminal Mode Commands63888
-Node: ripngd Filtering Commands64252
-Node: OSPFv264761
-Node: Configuring ospfd65320
-Node: OSPF router65788
-Node: OSPF area68944
-Node: OSPF interface74126
-Node: Redistribute routes to OSPF77509
-Node: Showing OSPF information79672
-Node: Debugging OSPF80918
-Node: OSPFv381957
-Node: OSPF6 router82277
-Node: OSPF6 area82631
-Node: OSPF6 interface82809
-Node: Redistribute routes to OSPF683686
-Node: Showing OSPF6 information84002
-Node: BGP84822
-Node: Starting BGP85712
-Node: BGP router86289
-Node: BGP distance87533
-Node: BGP decision process87971
-Node: BGP network88241
-Node: BGP route88431
-Node: Route Aggregation88987
-Node: Redistribute to BGP89556
-Node: BGP Peer90083
-Node: Defining Peer90270
-Node: BGP Peer commands90883
-Node: Peer filtering93287
-Node: BGP Peer Group93795
-Node: BGP Address Family94108
-Node: Autonomous System94262
-Node: AS Path Regular Expression95099
-Node: Display BGP Routes by AS Path96346
-Node: AS Path Access List96786
-Node: Using AS Path in Route Map97253
-Node: Private AS Numbers97534
-Node: BGP Communities Attribute97692
-Node: BGP Community Lists100159
-Node: Numbered BGP Community Lists102813
-Node: BGP Community in Route Map104400
-Node: Display BGP Routes by Community106343
-Node: Using BGP Communities Attribute107512
-Node: BGP Extended Communities Attribute111080
-Node: BGP Extended Community Lists112852
-Node: BGP Extended Communities in Route Map114727
-Node: Displaying BGP routes115186
-Node: Show IP BGP115423
-Node: More Show IP BGP116123
-Node: Capability Negotiation117274
-Node: Route Reflector120578
-Node: Route Server120857
-Node: Multiple instance121923
-Node: BGP instance and view123734
-Node: Routing policy125114
-Node: Viewing the view125882
-Node: How to set up a 6-Bone connection126167
-Node: Dump BGP packets and table127539
-Node: Configuring Quagga as a Route Server128086
-Node: Description of the Route Server model129047
-Ref: fig:normal-processing130624
-Ref: fig:full-mesh130774
-Ref: fig:route-server130870
-Ref: filter-delegation131284
-Ref: Route Server tasks132468
-Ref: Route-server path filter process132839
-Ref: fig:rs-processing135153
-Node: Commands for configuring a Route Server135270
-Node: Example of Route Server Configuration138297
-Node: Configuration of the BGP routers without Route Server139218
-Node: Configuration of the BGP routers with Route Server142101
-Node: Configuration of the Route Server itself143402
-Node: Further considerations about Import and Export route-maps148401
-Node: VTY shell151445
-Node: VTY shell username152114
-Node: VTY shell integrated configuration152746
-Node: Filtering154124
-Node: IP Access List154477
-Node: IP Prefix List154863
-Node: ip prefix-list description157882
-Node: ip prefix-list sequential number control158409
-Node: Showing ip prefix-list158951
-Node: Clear counter of ip prefix-list160059
-Node: Route Map160498
-Node: Route Map Command161003
-Node: Route Map Match Command161200
-Node: Route Map Set Command161824
-Node: IPv6 Support162701
-Node: Router Advertisement163273
-Node: Kernel Interface167074
-Node: SNMP Support169031
-Node: Getting and installing an SNMP agent169603
-Node: SMUX configuration170176
-Node: MIB and command reference172312
-Node: Zebra Protocol173699
-Node: Packet Binary Dump Format175613
-Node: Command Index187223
-Node: VTY Key Index241352
+Node: Config Commands24325
+Node: Basic Config Commands25218
+Node: Sample Config File30316
+Node: Terminal Mode Commands31086
+Node: Common Invocation Options32183
+Node: Virtual Terminal Interfaces33590
+Node: VTY Overview34101
+Node: VTY Modes35352
+Node: VTY View Mode35802
+Node: VTY Enable Mode36052
+Node: VTY Other Modes36330
+Node: VTY CLI Commands36506
+Node: CLI Movement Commands36966
+Node: CLI Editing Commands37489
+Node: CLI Advanced Commands38077
+Node: Zebra38843
+Node: Invoking zebra39352
+Node: Interface Commands39931
+Node: Static Route Commands41463
+Node: zebra Terminal Mode Commands44736
+Node: RIP45701
+Node: Starting and Stopping ripd46638
+Node: RIP netmask48051
+Node: RIP Configuration49150
+Node: How to Announce RIP route53415
+Node: Filtering RIP Routes55978
+Node: RIP Metric Manipulation57445
+Node: RIP distance58358
+Node: RIP route-map59173
+Node: RIP Authentication61689
+Node: RIP Timers62796
+Node: Show RIP Information64082
+Node: RIP Debug Commands65455
+Node: RIPng66451
+Node: Invoking ripngd66771
+Node: ripngd Configuration67020
+Node: ripngd Terminal Mode Commands67771
+Node: ripngd Filtering Commands68135
+Node: OSPFv268644
+Node: Configuring ospfd69203
+Node: OSPF router69671
+Node: OSPF area72827
+Node: OSPF interface78009
+Node: Redistribute routes to OSPF81392
+Node: Showing OSPF information83555
+Node: Debugging OSPF84801
+Node: OSPFv385840
+Node: OSPF6 router86160
+Node: OSPF6 area86514
+Node: OSPF6 interface86692
+Node: Redistribute routes to OSPF687569
+Node: Showing OSPF6 information87885
+Node: BGP88705
+Node: Starting BGP89595
+Node: BGP router90172
+Node: BGP distance91416
+Node: BGP decision process91854
+Node: BGP network92124
+Node: BGP route92314
+Node: Route Aggregation92870
+Node: Redistribute to BGP93439
+Node: BGP Peer93966
+Node: Defining Peer94153
+Node: BGP Peer commands94766
+Node: Peer filtering97170
+Node: BGP Peer Group97678
+Node: BGP Address Family97991
+Node: Autonomous System98145
+Node: AS Path Regular Expression98982
+Node: Display BGP Routes by AS Path100229
+Node: AS Path Access List100669
+Node: Using AS Path in Route Map101136
+Node: Private AS Numbers101417
+Node: BGP Communities Attribute101575
+Node: BGP Community Lists104042
+Node: Numbered BGP Community Lists106696
+Node: BGP Community in Route Map108283
+Node: Display BGP Routes by Community110226
+Node: Using BGP Communities Attribute111395
+Node: BGP Extended Communities Attribute114963
+Node: BGP Extended Community Lists116735
+Node: BGP Extended Communities in Route Map118610
+Node: Displaying BGP routes119069
+Node: Show IP BGP119306
+Node: More Show IP BGP120006
+Node: Capability Negotiation121157
+Node: Route Reflector124461
+Node: Route Server124740
+Node: Multiple instance125806
+Node: BGP instance and view127617
+Node: Routing policy128997
+Node: Viewing the view129765
+Node: How to set up a 6-Bone connection130050
+Node: Dump BGP packets and table131422
+Node: Configuring Quagga as a Route Server131969
+Node: Description of the Route Server model132930
+Ref: fig:normal-processing134507
+Ref: fig:full-mesh134657
+Ref: fig:route-server134753
+Ref: filter-delegation135167
+Ref: Route Server tasks136351
+Ref: Route-server path filter process136722
+Ref: fig:rs-processing139036
+Node: Commands for configuring a Route Server139153
+Node: Example of Route Server Configuration142180
+Node: Configuration of the BGP routers without Route Server143101
+Node: Configuration of the BGP routers with Route Server145984
+Node: Configuration of the Route Server itself147285
+Node: Further considerations about Import and Export route-maps152284
+Node: VTY shell155328
+Node: VTY shell username155997
+Node: VTY shell integrated configuration156629
+Node: Filtering158007
+Node: IP Access List158360
+Node: IP Prefix List158746
+Node: ip prefix-list description161765
+Node: ip prefix-list sequential number control162292
+Node: Showing ip prefix-list162834
+Node: Clear counter of ip prefix-list163942
+Node: Route Map164381
+Node: Route Map Command164886
+Node: Route Map Match Command165083
+Node: Route Map Set Command165707
+Node: IPv6 Support166584
+Node: Router Advertisement167156
+Node: Kernel Interface170957
+Node: SNMP Support172914
+Node: Getting and installing an SNMP agent173486
+Node: SMUX configuration174059
+Node: MIB and command reference176195
+Node: Zebra Protocol177582
+Node: Packet Binary Dump Format179496
+Node: Command Index191106
+Node: VTY Key Index247299

End Tag Table
diff --git a/isisd/ChangeLog b/isisd/ChangeLog
index e241d54d..32905516 100644
--- a/isisd/ChangeLog
+++ b/isisd/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * isis_main.c: (main) The 2nd argument to openzlog has been removed.
+
2004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* isis_main.c: (sigint,sigterm) Use zlog_notice for termination message.
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index 9aa487a7..027e47b4 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -218,7 +218,7 @@ main (int argc, char **argv, char **envp)
/* Get the programname without the preceding path. */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog (progname, ZLOG_NOLOG, ZLOG_ISIS,
+ zlog_default = openzlog (progname, ZLOG_ISIS,
LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON);
/* for reload */
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 79062cae..986c67aa 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,72 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * 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-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* log.h: Document appropriate use of syslog logging priorities
diff --git a/lib/command.c b/lib/command.c
index 99036d17..18829672 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -1,4 +1,7 @@
-/* Command interpreter routine for virtual terminal [aka TeletYpe]
+/*
+ $Id: command.c,v 1.28 2004/12/07 15:39:32 ajs Exp $
+
+ Command interpreter routine for virtual terminal [aka TeletYpe]
Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
This file is part of GNU Zebra.
@@ -75,6 +78,70 @@ Hello, this is " QUAGGA_PROGNAME " (version " QUAGGA_VERSION ").\r\n\
" QUAGGA_COPYRIGHT "\r\n\
\r\n";
+
+static struct facility_map {
+ int facility;
+ const char *name;
+ size_t match;
+} syslog_facilities[] =
+ {
+ { LOG_KERN, "kern", 1 },
+ { LOG_USER, "user", 2 },
+ { LOG_MAIL, "mail", 1 },
+ { LOG_DAEMON, "daemon", 1 },
+ { LOG_AUTH, "auth", 1 },
+ { LOG_SYSLOG, "syslog", 1 },
+ { LOG_LPR, "lpr", 2 },
+ { LOG_NEWS, "news", 1 },
+ { LOG_UUCP, "uucp", 2 },
+ { LOG_CRON, "cron", 1 },
+#ifdef LOG_FTP
+ { LOG_FTP, "ftp", 1 },
+#endif
+ { LOG_LOCAL0, "local0", 6 },
+ { LOG_LOCAL1, "local1", 6 },
+ { LOG_LOCAL2, "local2", 6 },
+ { LOG_LOCAL3, "local3", 6 },
+ { LOG_LOCAL4, "local4", 6 },
+ { LOG_LOCAL5, "local5", 6 },
+ { LOG_LOCAL6, "local6", 6 },
+ { LOG_LOCAL7, "local7", 6 },
+ { 0, NULL, 0 },
+ };
+
+static const char *
+facility_name(int facility)
+{
+ struct facility_map *fm;
+
+ for (fm = syslog_facilities; fm->name; fm++)
+ if (fm->facility == facility)
+ return fm->name;
+ return "";
+}
+
+static int
+facility_match(const char *str)
+{
+ struct facility_map *fm;
+
+ for (fm = syslog_facilities; fm->name; fm++)
+ if (!strncmp(str,fm->name,fm->match))
+ return fm->facility;
+ return -1;
+}
+
+static int
+level_match(const char *s)
+{
+ int level ;
+
+ for ( level = 0 ; zlog_priority [level] != NULL ; level ++ )
+ if (!strncmp (s, zlog_priority[level], 2))
+ return level;
+ return ZLOG_DISABLED;
+}
+
void
print_version (const char *progname)
{
@@ -128,7 +195,7 @@ install_node (struct cmd_node *node,
}
/* Compare two command's string. Used in sort_node (). */
-int
+static int
cmp_node (const void *p, const void *q)
{
struct cmd_element *a = *(struct cmd_element **)p;
@@ -137,7 +204,7 @@ cmp_node (const void *p, const void *q)
return strcmp (a->string, b->string);
}
-int
+static int
cmp_desc (const void *p, const void *q)
{
struct desc *a = *(struct desc **)p;
@@ -241,7 +308,7 @@ cmd_free_strvec (vector v)
}
/* Fetch next description. Used in cmd_make_descvec(). */
-char *
+static char *
cmd_desc_str (const char **string)
{
const char *cp, *start;
@@ -277,7 +344,7 @@ cmd_desc_str (const char **string)
}
/* New string vector. */
-vector
+static vector
cmd_make_descvec (const char *string, const char *descstr)
{
int multiple = 0;
@@ -370,7 +437,7 @@ cmd_make_descvec (const char *string, const char *descstr)
/* Count mandantory string vector size. This is to determine inputed
command has enough command length. */
-int
+static int
cmd_cmdsize (vector strvec)
{
unsigned int i;
@@ -430,7 +497,7 @@ install_element (enum node_type ntype, struct cmd_element *cmd)
static unsigned char itoa64[] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-void
+static void
to64(char *s, long v, int n)
{
while (--n >= 0)
@@ -440,7 +507,8 @@ to64(char *s, long v, int n)
}
}
-char *zencrypt (const char *passwd)
+static char *
+zencrypt (const char *passwd)
{
char salt[6];
struct timeval tv;
@@ -455,73 +523,8 @@ char *zencrypt (const char *passwd)
return crypt (passwd, salt);
}
-const char *
-syslog_facility_print (int facility)
-{
- switch (facility)
- {
- case LOG_KERN:
- return "kern";
- break;
- case LOG_USER:
- return "user";
- break;
- case LOG_MAIL:
- return "mail";
- break;
- case LOG_DAEMON:
- return "daemon";
- break;
- case LOG_AUTH:
- return "auth";
- break;
- case LOG_SYSLOG:
- return "syslog";
- break;
- case LOG_LPR:
- return "lpr";
- break;
- case LOG_NEWS:
- return "news";
- break;
- case LOG_UUCP:
- return "uucp";
- break;
- case LOG_CRON:
- return "cron";
- break;
- case LOG_LOCAL0:
- return "local0";
- break;
- case LOG_LOCAL1:
- return "local1";
- break;
- case LOG_LOCAL2:
- return "local2";
- break;
- case LOG_LOCAL3:
- return "local3";
- break;
- case LOG_LOCAL4:
- return "local4";
- break;
- case LOG_LOCAL5:
- return "local5";
- break;
- case LOG_LOCAL6:
- return "local6";
- break;
- case LOG_LOCAL7:
- return "local7";
- break;
- default:
- break;
- }
- return "";
-}
-
/* This function write configuration of this host. */
-int
+static int
config_write_host (struct vty *vty)
{
if (host.name)
@@ -542,21 +545,46 @@ config_write_host (struct vty *vty)
vty_out (vty, "enable password %s%s", host.enable, VTY_NEWLINE);
}
- if (host.logfile)
- vty_out (vty, "log file %s%s", host.logfile, VTY_NEWLINE);
+ if (zlog_default->default_lvl != LOG_DEBUG)
+ vty_out (vty, "log trap %s%s",
+ zlog_priority[zlog_default->default_lvl], VTY_NEWLINE);
+
+ if (host.logfile && (zlog_default->maxlvl[ZLOG_DEST_FILE] != ZLOG_DISABLED))
+ {
+ vty_out (vty, "log file %s", host.logfile);
+ if (zlog_default->maxlvl[ZLOG_DEST_FILE] != zlog_default->default_lvl)
+ vty_out (vty, " %s",
+ zlog_priority[zlog_default->maxlvl[ZLOG_DEST_FILE]]);
+ vty_out (vty, "%s", VTY_NEWLINE);
+ }
+
+ if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != ZLOG_DISABLED)
+ {
+ vty_out (vty, "log stdout");
+ if (zlog_default->maxlvl[ZLOG_DEST_STDOUT] != zlog_default->default_lvl)
+ vty_out (vty, " %s",
+ zlog_priority[zlog_default->maxlvl[ZLOG_DEST_STDOUT]]);
+ vty_out (vty, "%s", VTY_NEWLINE);
+ }
- if (zlog_default->flags & ZLOG_STDOUT)
- vty_out (vty, "log stdout%s", VTY_NEWLINE);
+ if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED)
+ vty_out(vty,"no log monitor%s",VTY_NEWLINE);
+ else if (zlog_default->maxlvl[ZLOG_DEST_MONITOR] != zlog_default->default_lvl)
+ vty_out(vty,"log monitor %s%s",
+ zlog_priority[zlog_default->maxlvl[ZLOG_DEST_MONITOR]],VTY_NEWLINE);
- if (zlog_default->flags & ZLOG_SYSLOG)
+ if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != ZLOG_DISABLED)
{
vty_out (vty, "log syslog");
- if (zlog_default->facility != LOG_DAEMON)
- vty_out (vty, " facility %s", syslog_facility_print (zlog_default->facility));
+ if (zlog_default->maxlvl[ZLOG_DEST_SYSLOG] != zlog_default->default_lvl)
+ vty_out (vty, " %s",
+ zlog_priority[zlog_default->maxlvl[ZLOG_DEST_SYSLOG]]);
vty_out (vty, "%s", VTY_NEWLINE);
}
- if (zlog_default->maskpri != LOG_DEBUG)
- vty_out (vty, "log trap %s%s", zlog_priority[zlog_default->maskpri], VTY_NEWLINE);
+
+ if (zlog_default->facility != LOG_DAEMON)
+ vty_out (vty, "log facility %s%s",
+ facility_name(zlog_default->facility), VTY_NEWLINE);
if (zlog_default->record_priority == 1)
vty_out (vty, "log record-priority%s", VTY_NEWLINE);
@@ -578,15 +606,17 @@ config_write_host (struct vty *vty)
}
/* Utility function for getting command vector. */
-vector
+static vector
cmd_node_vector (vector v, enum node_type ntype)
{
struct cmd_node *cnode = vector_slot (v, ntype);
return cnode->cmd_vector;
}
-/* Filter command vector by symbol */
-int
+#if 0
+/* Filter command vector by symbol. This function is not actually used;
+ * should it be deleted? */
+static int
cmd_filter_by_symbol (char *command, char *symbol)
{
int i, lim;
@@ -629,6 +659,7 @@ cmd_filter_by_symbol (char *command, char *symbol)
}
return 0;
}
+#endif
/* Completion match types. */
enum match_type
@@ -645,7 +676,7 @@ enum match_type
exact_match
};
-enum match_type
+static enum match_type
cmd_ipv4_match (const char *str)
{
const char *sp;
@@ -702,7 +733,7 @@ cmd_ipv4_match (const char *str)
return exact_match;
}
-enum match_type
+static enum match_type
cmd_ipv4_prefix_match (const char *str)
{
const char *sp;
@@ -793,7 +824,7 @@ cmd_ipv4_prefix_match (const char *str)
#ifdef HAVE_IPV6
-enum match_type
+static enum match_type
cmd_ipv6_match (const char *str)
{
int state = STATE_START;
@@ -899,7 +930,7 @@ cmd_ipv6_match (const char *str)
return exact_match;
}
-enum match_type
+static enum match_type
cmd_ipv6_prefix_match (const char *str)
{
int state = STATE_START;
@@ -1034,7 +1065,7 @@ cmd_ipv6_prefix_match (const char *str)
#define DECIMAL_STRLEN_MAX 10
-int
+static int
cmd_range_match (const char *range, const char *str)
{
char *p;
@@ -1080,7 +1111,7 @@ cmd_range_match (const char *range, const char *str)
}
/* Make completion match and return match type flag. */
-enum match_type
+static enum match_type
cmd_filter_by_completion (char *command, vector v, unsigned int index)
{
unsigned int i;
@@ -1195,7 +1226,7 @@ cmd_filter_by_completion (char *command, vector v, unsigned int index)
}
/* Filter vector by command character with index. */
-enum match_type
+static enum match_type
cmd_filter_by_string (char *command, vector v, unsigned int index)
{
unsigned int i;
@@ -1303,7 +1334,7 @@ cmd_filter_by_string (char *command, vector v, unsigned int index)
}
/* Check ambiguous match */
-int
+static int
is_cmd_ambiguous (char *command, vector v, int index, enum match_type type)
{
unsigned int i;
@@ -1400,7 +1431,7 @@ is_cmd_ambiguous (char *command, vector v, int index, enum match_type type)
}
/* If src matches dst return dst string, otherwise return NULL */
-const char *
+static const char *
cmd_entry_function (const char *src, const char *dst)
{
/* Skip variable arguments. */
@@ -1422,7 +1453,7 @@ cmd_entry_function (const char *src, const char *dst)
/* If src matches dst return dst string, otherwise return NULL */
/* This version will return the dst string always if it is
CMD_VARIABLE for '?' key processing */
-const char *
+static const char *
cmd_entry_function_desc (const char *src, const char *dst)
{
if (CMD_VARARG (dst))
@@ -1486,7 +1517,7 @@ cmd_entry_function_desc (const char *src, const char *dst)
/* Check same string element existence. If it isn't there return
1. */
-int
+static int
cmd_unique_string (vector v, const char *str)
{
unsigned int i;
@@ -1501,7 +1532,7 @@ cmd_unique_string (vector v, const char *str)
/* Compare string to description vector. If there is same string
return 1 else return 0. */
-int
+static int
desc_unique_string (vector v, const char *str)
{
unsigned int i;
@@ -1514,7 +1545,7 @@ desc_unique_string (vector v, const char *str)
return 0;
}
-int
+static int
cmd_try_do_shortcut (enum node_type node, char* first_word) {
if ( first_word != NULL &&
node != AUTH_NODE &&
@@ -1527,7 +1558,7 @@ cmd_try_do_shortcut (enum node_type node, char* first_word) {
}
/* '?' describe command support. */
-vector
+static vector
cmd_describe_command_real (vector vline, struct vty *vty, int *status)
{
unsigned int i;
@@ -1690,7 +1721,7 @@ cmd_describe_command (vector vline, struct vty *vty, int *status)
/* Check LCD of matched command. */
-int
+static int
cmd_lcd (char **matched)
{
int i;
@@ -1723,7 +1754,7 @@ cmd_lcd (char **matched)
}
/* Command line completion support. */
-char **
+static char **
cmd_complete_command_real (vector vline, struct vty *vty, int *status)
{
unsigned int i;
@@ -1905,7 +1936,8 @@ cmd_complete_command (vector vline, struct vty *vty, int *status)
/* return parent node */
/* MUST eventually converge on CONFIG_NODE */
-enum node_type node_parent ( enum node_type node )
+static enum node_type
+node_parent ( enum node_type node )
{
enum node_type ret;
@@ -1930,7 +1962,7 @@ enum node_type node_parent ( enum node_type node )
}
/* Execute command by argument vline vector. */
-int
+static int
cmd_execute_command_real (vector vline, struct vty *vty, struct cmd_element **cmd)
{
unsigned int i;
@@ -2959,40 +2991,158 @@ DEFUN (no_service_terminal_length, no_service_terminal_length_cmd,
return CMD_SUCCESS;
}
+DEFUN (config_logmsg,
+ config_logmsg_cmd,
+ "logmsg "LOG_LEVELS" .MESSAGE",
+ "Send a message to enabled logging destinations\n"
+ LOG_LEVEL_DESC
+ "The message to send\n")
+{
+ int level;
+ char *message;
+
+ if ((level = level_match(argv[0])) == ZLOG_DISABLED)
+ return CMD_ERR_NO_MATCH;
+
+ zlog(NULL, level, (message = argv_concat(argv, argc, 1)));
+ XFREE(MTYPE_TMP, message);
+ return CMD_SUCCESS;
+}
+
+DEFUN (show_logging,
+ show_logging_cmd,
+ "show logging",
+ SHOW_STR
+ "Show current logging configuration\n")
+{
+ struct zlog *zl = zlog_default;
+
+ vty_out (vty, "Syslog logging: ");
+ if (zl->maxlvl[ZLOG_DEST_SYSLOG] == ZLOG_DISABLED)
+ vty_out (vty, "disabled");
+ else
+ vty_out (vty, "level %s, facility %s, ident %s",
+ zlog_priority[zl->maxlvl[ZLOG_DEST_SYSLOG]],
+ facility_name(zl->facility), zl->ident);
+ vty_out (vty, "%s", VTY_NEWLINE);
+
+ vty_out (vty, "Stdout logging: ");
+ if (zl->maxlvl[ZLOG_DEST_STDOUT] == ZLOG_DISABLED)
+ vty_out (vty, "disabled");
+ else
+ vty_out (vty, "level %s",
+ zlog_priority[zl->maxlvl[ZLOG_DEST_STDOUT]]);
+ vty_out (vty, "%s", VTY_NEWLINE);
+
+ vty_out (vty, "Monitor logging: ");
+ if (zl->maxlvl[ZLOG_DEST_MONITOR] == ZLOG_DISABLED)
+ vty_out (vty, "disabled");
+ else
+ vty_out (vty, "level %s",
+ zlog_priority[zl->maxlvl[ZLOG_DEST_MONITOR]]);
+ vty_out (vty, "%s", VTY_NEWLINE);
+
+ vty_out (vty, "File logging: ");
+ if ((zl->maxlvl[ZLOG_DEST_FILE] == ZLOG_DISABLED) ||
+ !zl->fp)
+ vty_out (vty, "disabled");
+ else
+ vty_out (vty, "level %s, filename %s",
+ zlog_priority[zl->maxlvl[ZLOG_DEST_FILE]],
+ zl->filename);
+ vty_out (vty, "%s", VTY_NEWLINE);
+
+ vty_out (vty, "Protocol name: %s%s",
+ zlog_proto_names[zl->protocol], VTY_NEWLINE);
+ vty_out (vty, "Record priority: %s%s",
+ (zl->record_priority ? "enabled" : "disabled"), VTY_NEWLINE);
+
+ return CMD_SUCCESS;
+}
+
DEFUN (config_log_stdout,
config_log_stdout_cmd,
"log stdout",
"Logging control\n"
- "Logging goes to stdout\n")
+ "Set stdout logging level\n")
{
- zlog_set_flag (NULL, ZLOG_STDOUT);
+ zlog_set_level (NULL, ZLOG_DEST_STDOUT, zlog_default->default_lvl);
+ return CMD_SUCCESS;
+}
+
+DEFUN (config_log_stdout_level,
+ config_log_stdout_level_cmd,
+ "log stdout "LOG_LEVELS,
+ "Logging control\n"
+ "Set stdout logging level\n"
+ LOG_LEVEL_DESC)
+{
+ int level;
+
+ if ((level = level_match(argv[0])) == ZLOG_DISABLED)
+ return CMD_ERR_NO_MATCH;
+ zlog_set_level (NULL, ZLOG_DEST_STDOUT, level);
return CMD_SUCCESS;
}
DEFUN (no_config_log_stdout,
no_config_log_stdout_cmd,
- "no log stdout",
+ "no log stdout [LEVEL]",
NO_STR
"Logging control\n"
- "Cancel logging to stdout\n")
+ "Cancel logging to stdout\n"
+ "Logging level\n")
{
- zlog_reset_flag (NULL, ZLOG_STDOUT);
+ zlog_set_level (NULL, ZLOG_DEST_STDOUT, ZLOG_DISABLED);
return CMD_SUCCESS;
}
-DEFUN (config_log_file,
- config_log_file_cmd,
- "log file FILENAME",
+DEFUN (config_log_monitor,
+ config_log_monitor_cmd,
+ "log monitor",
"Logging control\n"
- "Logging to file\n"
- "Logging filename\n")
+ "Set terminal line (monitor) logging level\n")
+{
+ zlog_set_level (NULL, ZLOG_DEST_MONITOR, zlog_default->default_lvl);
+ return CMD_SUCCESS;
+}
+
+DEFUN (config_log_monitor_level,
+ config_log_monitor_level_cmd,
+ "log monitor "LOG_LEVELS,
+ "Logging control\n"
+ "Set terminal line (monitor) logging level\n"
+ LOG_LEVEL_DESC)
+{
+ int level;
+
+ if ((level = level_match(argv[0])) == ZLOG_DISABLED)
+ return CMD_ERR_NO_MATCH;
+ zlog_set_level (NULL, ZLOG_DEST_MONITOR, level);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_config_log_monitor,
+ no_config_log_monitor_cmd,
+ "no log monitor [LEVEL]",
+ NO_STR
+ "Logging control\n"
+ "Disable terminal line (monitor) logging\n"
+ "Logging level\n")
+{
+ zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
+ return CMD_SUCCESS;
+}
+
+static int
+set_log_file(struct vty *vty, const char *fname, int loglevel)
{
int ret;
char *p = NULL;
const char *fullpath;
/* Path detection. */
- if (! IS_DIRECTORY_SEP (*argv[0]))
+ if (! IS_DIRECTORY_SEP (*fname))
{
char cwd[MAXPATHLEN+1];
cwd[MAXPATHLEN] = '\0';
@@ -3003,37 +3153,62 @@ DEFUN (config_log_file,
return CMD_WARNING;
}
- if ( (p = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (argv[0]) + 2))
+ if ( (p = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (fname) + 2))
== NULL)
{
zlog_err ("config_log_file: Unable to alloc mem!");
return CMD_WARNING;
}
- sprintf (p, "%s/%s", cwd, argv[0]);
+ sprintf (p, "%s/%s", cwd, fname);
fullpath = p;
}
else
- fullpath = argv[0];
+ fullpath = fname;
- ret = zlog_set_file (NULL, fullpath);
+ ret = zlog_set_file (NULL, fullpath, loglevel);
if (p)
XFREE (MTYPE_TMP, p);
if (!ret)
{
- vty_out (vty, "can't open logfile %s\n", argv[0]);
+ vty_out (vty, "can't open logfile %s\n", fname);
return CMD_WARNING;
}
if (host.logfile)
XFREE (MTYPE_TMP, host.logfile);
- host.logfile = XSTRDUP (MTYPE_TMP, argv[0]);
+ host.logfile = XSTRDUP (MTYPE_TMP, fname);
return CMD_SUCCESS;
}
+DEFUN (config_log_file,
+ config_log_file_cmd,
+ "log file FILENAME",
+ "Logging control\n"
+ "Logging to file\n"
+ "Logging filename\n")
+{
+ return set_log_file(vty, argv[0], zlog_default->default_lvl);
+}
+
+DEFUN (config_log_file_level,
+ config_log_file_level_cmd,
+ "log file FILENAME "LOG_LEVELS,
+ "Logging control\n"
+ "Logging to file\n"
+ "Logging filename\n"
+ LOG_LEVEL_DESC)
+{
+ int level;
+
+ if ((level = level_match(argv[1])) == ZLOG_DISABLED)
+ return CMD_ERR_NO_MATCH;
+ return set_log_file(vty, argv[0], level);
+}
+
DEFUN (no_config_log_file,
no_config_log_file_cmd,
"no log file [FILENAME]",
@@ -3052,154 +3227,135 @@ DEFUN (no_config_log_file,
return CMD_SUCCESS;
}
+ALIAS (no_config_log_file,
+ no_config_log_file_level_cmd,
+ "no log file FILENAME LEVEL",
+ NO_STR
+ "Logging control\n"
+ "Cancel logging to file\n"
+ "Logging file name\n"
+ "Logging level\n")
+
DEFUN (config_log_syslog,
config_log_syslog_cmd,
"log syslog",
"Logging control\n"
- "Logging goes to syslog\n")
+ "Set syslog logging level\n")
{
- zlog_set_flag (NULL, ZLOG_SYSLOG);
- zlog_default->facility = LOG_DAEMON;
+ zlog_set_level (NULL, ZLOG_DEST_SYSLOG, zlog_default->default_lvl);
return CMD_SUCCESS;
}
-DEFUN (config_log_syslog_facility,
- config_log_syslog_facility_cmd,
- "log syslog facility (kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)",
+DEFUN (config_log_syslog_level,
+ config_log_syslog_level_cmd,
+ "log syslog "LOG_LEVELS,
"Logging control\n"
- "Logging goes to syslog\n"
- "Facility parameter for syslog messages\n"
- "Kernel\n"
- "User process\n"
- "Mail system\n"
- "System daemons\n"
- "Authorization system\n"
- "Syslog itself\n"
- "Line printer system\n"
- "USENET news\n"
- "Unix-to-Unix copy system\n"
- "Cron/at facility\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n")
-{
- int facility = LOG_DAEMON;
-
- zlog_set_flag (NULL, ZLOG_SYSLOG);
-
- if (strncmp (argv[0], "kern", 1) == 0)
- facility = LOG_KERN;
- else if (strncmp (argv[0], "user", 2) == 0)
- facility = LOG_USER;
- else if (strncmp (argv[0], "mail", 1) == 0)
- facility = LOG_MAIL;
- else if (strncmp (argv[0], "daemon", 1) == 0)
- facility = LOG_DAEMON;
- else if (strncmp (argv[0], "auth", 1) == 0)
- facility = LOG_AUTH;
- else if (strncmp (argv[0], "syslog", 1) == 0)
- facility = LOG_SYSLOG;
- else if (strncmp (argv[0], "lpr", 2) == 0)
- facility = LOG_LPR;
- else if (strncmp (argv[0], "news", 1) == 0)
- facility = LOG_NEWS;
- else if (strncmp (argv[0], "uucp", 2) == 0)
- facility = LOG_UUCP;
- else if (strncmp (argv[0], "cron", 1) == 0)
- facility = LOG_CRON;
- else if (strncmp (argv[0], "local0", 6) == 0)
- facility = LOG_LOCAL0;
- else if (strncmp (argv[0], "local1", 6) == 0)
- facility = LOG_LOCAL1;
- else if (strncmp (argv[0], "local2", 6) == 0)
- facility = LOG_LOCAL2;
- else if (strncmp (argv[0], "local3", 6) == 0)
- facility = LOG_LOCAL3;
- else if (strncmp (argv[0], "local4", 6) == 0)
- facility = LOG_LOCAL4;
- else if (strncmp (argv[0], "local5", 6) == 0)
- facility = LOG_LOCAL5;
- else if (strncmp (argv[0], "local6", 6) == 0)
- facility = LOG_LOCAL6;
- else if (strncmp (argv[0], "local7", 6) == 0)
- facility = LOG_LOCAL7;
+ "Set syslog logging level\n"
+ LOG_LEVEL_DESC)
+{
+ int level;
- zlog_default->facility = facility;
+ if ((level = level_match(argv[0])) == ZLOG_DISABLED)
+ return CMD_ERR_NO_MATCH;
+ zlog_set_level (NULL, ZLOG_DEST_SYSLOG, level);
+ return CMD_SUCCESS;
+}
+
+DEFUN_DEPRECATED (config_log_syslog_facility,
+ config_log_syslog_facility_cmd,
+ "log syslog facility "LOG_FACILITIES,
+ "Logging control\n"
+ "Logging goes to syslog\n"
+ "(Deprecated) Facility parameter for syslog messages\n"
+ LOG_FACILITY_DESC)
+{
+ int facility;
+
+ if ((facility = facility_match(argv[0])) < 0)
+ return CMD_ERR_NO_MATCH;
+ zlog_set_level (NULL, ZLOG_DEST_SYSLOG, zlog_default->default_lvl);
+ zlog_default->facility = facility;
return CMD_SUCCESS;
}
DEFUN (no_config_log_syslog,
no_config_log_syslog_cmd,
- "no log syslog",
+ "no log syslog [LEVEL]",
NO_STR
"Logging control\n"
- "Cancel logging to syslog\n")
+ "Cancel logging to syslog\n"
+ "Logging level\n")
{
- zlog_reset_flag (NULL, ZLOG_SYSLOG);
- zlog_default->facility = LOG_DAEMON;
+ zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
return CMD_SUCCESS;
}
ALIAS (no_config_log_syslog,
no_config_log_syslog_facility_cmd,
- "no log syslog facility (kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)",
+ "no log syslog facility "LOG_FACILITIES,
NO_STR
"Logging control\n"
"Logging goes to syslog\n"
"Facility parameter for syslog messages\n"
- "Kernel\n"
- "User process\n"
- "Mail system\n"
- "System daemons\n"
- "Authorization system\n"
- "Syslog itself\n"
- "Line printer system\n"
- "USENET news\n"
- "Unix-to-Unix copy system\n"
- "Cron/at facility\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n"
- "Local use\n")
-
-DEFUN (config_log_trap,
- config_log_trap_cmd,
- "log trap (emergencies|alerts|critical|errors|warnings|notifications|informational|debugging)",
+ LOG_FACILITY_DESC)
+
+DEFUN (config_log_facility,
+ config_log_facility_cmd,
+ "log facility "LOG_FACILITIES,
"Logging control\n"
- "Limit logging to specifed level\n")
+ "Facility parameter for syslog messages\n"
+ LOG_FACILITY_DESC)
{
- int new_level ;
-
- for ( new_level = 0 ; zlog_priority [new_level] != NULL ; new_level ++ )
- {
- if ( strcmp ( argv[0], zlog_priority [new_level] ) == 0 )
- /* found new logging level */
- {
- zlog_default->maskpri = new_level;
- return CMD_SUCCESS;
- }
- }
- return CMD_ERR_NO_MATCH;
+ int facility;
+
+ if ((facility = facility_match(argv[0])) < 0)
+ return CMD_ERR_NO_MATCH;
+ zlog_default->facility = facility;
+ return CMD_SUCCESS;
}
-DEFUN (no_config_log_trap,
- no_config_log_trap_cmd,
- "no log trap",
+DEFUN (no_config_log_facility,
+ no_config_log_facility_cmd,
+ "no log facility [FACILITY]",
NO_STR
"Logging control\n"
- "Permit all logging information\n")
+ "Reset syslog facility to default (daemon)\n"
+ "Syslog facility\n")
+{
+ zlog_default->facility = LOG_DAEMON;
+ return CMD_SUCCESS;
+}
+
+DEFUN_DEPRECATED (config_log_trap,
+ config_log_trap_cmd,
+ "log trap "LOG_LEVELS,
+ "Logging control\n"
+ "(Deprecated) Set logging level and default for all destinations\n"
+ LOG_LEVEL_DESC)
+{
+ int new_level ;
+ int i;
+
+ if ((new_level = level_match(argv[0])) == ZLOG_DISABLED)
+ return CMD_ERR_NO_MATCH;
+
+ zlog_default->default_lvl = new_level;
+ for (i = 0; i < ZLOG_NUM_DESTS; i++)
+ if (zlog_default->maxlvl[i] != ZLOG_DISABLED)
+ zlog_default->maxlvl[i] = new_level;
+ return CMD_SUCCESS;
+}
+
+DEFUN_DEPRECATED (no_config_log_trap,
+ no_config_log_trap_cmd,
+ "no log trap [LEVEL]",
+ NO_STR
+ "Logging control\n"
+ "Permit all logging information\n"
+ "Logging level\n")
{
- zlog_default->maskpri = LOG_DEBUG;
+ zlog_default->default_lvl = LOG_DEBUG;
return CMD_SUCCESS;
}
@@ -3304,6 +3460,7 @@ cmd_init (int terminal)
install_element (VIEW_NODE, &config_enable_cmd);
install_element (VIEW_NODE, &config_terminal_length_cmd);
install_element (VIEW_NODE, &config_terminal_no_length_cmd);
+ install_element (VIEW_NODE, &show_logging_cmd);
}
if (terminal)
@@ -3320,6 +3477,8 @@ cmd_init (int terminal)
{
install_element (ENABLE_NODE, &config_terminal_length_cmd);
install_element (ENABLE_NODE, &config_terminal_no_length_cmd);
+ install_element (ENABLE_NODE, &show_logging_cmd);
+ install_element (ENABLE_NODE, &config_logmsg_cmd);
install_default (CONFIG_NODE);
}
@@ -3336,13 +3495,22 @@ cmd_init (int terminal)
install_element (CONFIG_NODE, &no_enable_password_cmd);
install_element (CONFIG_NODE, &config_log_stdout_cmd);
+ install_element (CONFIG_NODE, &config_log_stdout_level_cmd);
install_element (CONFIG_NODE, &no_config_log_stdout_cmd);
+ install_element (CONFIG_NODE, &config_log_monitor_cmd);
+ install_element (CONFIG_NODE, &config_log_monitor_level_cmd);
+ install_element (CONFIG_NODE, &no_config_log_monitor_cmd);
install_element (CONFIG_NODE, &config_log_file_cmd);
+ install_element (CONFIG_NODE, &config_log_file_level_cmd);
install_element (CONFIG_NODE, &no_config_log_file_cmd);
+ install_element (CONFIG_NODE, &no_config_log_file_level_cmd);
install_element (CONFIG_NODE, &config_log_syslog_cmd);
+ install_element (CONFIG_NODE, &config_log_syslog_level_cmd);
install_element (CONFIG_NODE, &config_log_syslog_facility_cmd);
install_element (CONFIG_NODE, &no_config_log_syslog_cmd);
install_element (CONFIG_NODE, &no_config_log_syslog_facility_cmd);
+ install_element (CONFIG_NODE, &config_log_facility_cmd);
+ install_element (CONFIG_NODE, &no_config_log_facility_cmd);
install_element (CONFIG_NODE, &config_log_trap_cmd);
install_element (CONFIG_NODE, &no_config_log_trap_cmd);
install_element (CONFIG_NODE, &config_log_record_priority_cmd);
diff --git a/lib/command.h b/lib/command.h
index 52cfded9..c8699e10 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -177,10 +177,10 @@ struct desc
};
#define DEFUN_CMD_FUNC_DECL(funcname) \
- int funcname (struct cmd_element *, struct vty *, int, const char *[]); \
+ static int funcname (struct cmd_element *, struct vty *, int, const char *[]); \
#define DEFUN_CMD_FUNC_TEXT(funcname) \
- int funcname \
+ static int funcname \
(struct cmd_element *self, struct vty *vty, int argc, const char *argv[])
/* DEFUN for vty command interafce. Little bit hacky ;-). */
@@ -214,12 +214,24 @@ struct desc
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon) \
DEFUN_CMD_FUNC_TEXT(funcname)
+/* DEFUN + DEFSH with attributes */
+#define DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, attr) \
+ DEFUN_CMD_FUNC_DECL(funcname) \
+ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, daemon) \
+ DEFUN_CMD_FUNC_TEXT(funcname)
+
+#define DEFUNSH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \
+ DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN)
+
+#define DEFUNSH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \
+ DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED)
+
/* ALIAS macro which define existing command's alias. */
#define ALIAS(funcname, cmdname, cmdstr, helpstr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0)
#define ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \
- DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, daemon) \
+ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0)
#define ALIAS_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, 0)
@@ -227,6 +239,15 @@ struct desc
#define ALIAS_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, 0)
+#define ALIAS_SH(daemon, funcname, cmdname, cmdstr, helpstr) \
+ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon)
+
+#define ALIAS_SH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \
+ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, daemon)
+
+#define ALIAS_SH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \
+ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, daemon)
+
#endif /* VTYSH_EXTRACT_PL */
/* Some macroes */
@@ -319,8 +340,6 @@ extern struct cmd_element config_exit_cmd;
extern struct cmd_element config_quit_cmd;
extern struct cmd_element config_help_cmd;
extern struct cmd_element config_list_cmd;
-int config_exit (struct cmd_element *, struct vty *, int, const char *[]);
-int config_help (struct cmd_element *, struct vty *, int, const char *[]);
char *host_config_file ();
void host_config_set (char *);
diff --git a/lib/log.c b/lib/log.c
index d3106cb4..b68896ca 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -1,4 +1,7 @@
-/* Logging of zebra
+/*
+ * $Id: log.c,v 1.17 2004/12/07 15:39:32 ajs Exp $
+ *
+ * Logging of zebra
* Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
*
* This file is part of GNU Zebra.
@@ -104,12 +107,8 @@ vzlog (struct zlog *zl, int priority, const char *format, va_list args)
return;
}
- /* only log this information if it has not been masked out */
- if ( priority > zl->maskpri )
- return ;
-
/* Syslog output */
- if (zl->flags & ZLOG_SYSLOG)
+ if (priority <= zl->maxlvl[ZLOG_DEST_SYSLOG])
{
va_list ac;
va_copy(ac, args);
@@ -118,7 +117,7 @@ vzlog (struct zlog *zl, int priority, const char *format, va_list args)
}
/* File output. */
- if (zl->flags & ZLOG_FILE)
+ if ((priority <= zl->maxlvl[ZLOG_DEST_FILE]) && zl->fp)
{
va_list ac;
time_print (zl->fp);
@@ -133,7 +132,7 @@ vzlog (struct zlog *zl, int priority, const char *format, va_list args)
}
/* stdout output. */
- if (zl->flags & ZLOG_STDOUT)
+ if (priority <= zl->maxlvl[ZLOG_DEST_STDOUT])
{
va_list ac;
time_print (stdout);
@@ -147,23 +146,10 @@ vzlog (struct zlog *zl, int priority, const char *format, va_list args)
fflush (stdout);
}
- /* stderr output. */
- if (zl->flags & ZLOG_STDERR)
- {
- va_list ac;
- time_print (stderr);
- if (zl->record_priority)
- fprintf (stderr, "%s: ", zlog_priority[priority]);
- fprintf (stderr, "%s: ", zlog_proto_names[zl->protocol]);
- va_copy(ac, args);
- vfprintf (stderr, format, ac);
- va_end(ac);
- fprintf (stderr, "\n");
- fflush (stderr);
- }
-
/* Terminal monitor. */
- vty_log (zlog_proto_names[zl->protocol], format, args);
+ if (priority <= zl->maxlvl[ZLOG_DEST_MONITOR])
+ vty_log ((zl->record_priority ? zlog_priority[priority] : NULL),
+ zlog_proto_names[zl->protocol], format, args);
}
static char *
@@ -297,26 +283,29 @@ zlog_signal(int signo, const char *action)
if (s < buf+sizeof(buf))
*s++ = '\n';
+ /* N.B. implicit priority is most severe */
+#define PRI LOG_EMERG
+
#define DUMP(FP) write(fileno(FP),buf,s-buf);
if (!zlog_default)
DUMP(stderr)
else
{
- if ((zlog_default->flags & ZLOG_FILE) && zlog_default->fp)
+ if ((PRI <= zlog_default->maxlvl[ZLOG_DEST_FILE]) && zlog_default->fp)
DUMP(zlog_default->fp)
- if (zlog_default->flags & ZLOG_STDOUT)
+ if (PRI <= zlog_default->maxlvl[ZLOG_DEST_STDOUT])
DUMP(stdout)
- if (zlog_default->flags & ZLOG_STDERR)
- DUMP(stderr)
- if (zlog_default->flags & ZLOG_SYSLOG)
- {
- *--s = '\0';
- syslog_sigsafe(LOG_ERR|zlog_default->facility,msgstart,s-msgstart);
- }
+ /* Remove trailing '\n' for monitor and syslog */
+ *--s = '\0';
+ if (PRI <= zlog_default->maxlvl[ZLOG_DEST_MONITOR])
+ vty_log_fixed(buf,s-buf);
+ if (PRI <= zlog_default->maxlvl[ZLOG_DEST_SYSLOG])
+ syslog_sigsafe(PRI|zlog_default->facility,msgstart,s-msgstart);
}
#undef DUMP
- zlog_backtrace_sigsafe(LOG_ERR);
+ zlog_backtrace_sigsafe(PRI);
+#undef PRI
#undef LOC
}
@@ -332,10 +321,6 @@ zlog_backtrace_sigsafe(int priority)
char *s;
#define LOC s,buf+sizeof(buf)-s
- /* only log this information if it has not been masked out */
- if (zlog_default && (priority > zlog_default->maskpri))
- return;
-
if (((size = backtrace(array,sizeof(array)/sizeof(array[0]))) <= 0) ||
((size_t)size > sizeof(array)/sizeof(array[0])))
return;
@@ -353,29 +338,34 @@ zlog_backtrace_sigsafe(int priority)
DUMP(stderr)
else
{
- if ((zlog_default->flags & ZLOG_FILE) && zlog_default->fp)
+ if ((priority <= zlog_default->maxlvl[ZLOG_DEST_FILE]) &&
+ zlog_default->fp)
DUMP(zlog_default->fp)
- if (zlog_default->flags & ZLOG_STDOUT)
+ if (priority <= zlog_default->maxlvl[ZLOG_DEST_STDOUT])
DUMP(stdout)
- if (zlog_default->flags & ZLOG_STDERR)
- DUMP(stderr)
- if (zlog_default->flags & ZLOG_SYSLOG)
- {
- int i;
- *--s = '\0';
- syslog_sigsafe(priority|zlog_default->facility,buf,s-buf);
- /* Just print the function addresses. */
- for (i = 0; i < size; i++)
- {
- s = buf;
- s = str_append(LOC,"[bt ");
- s = num_append(LOC,i);
- s = str_append(LOC,"] 0x");
- s = hex_append(LOC,(u_long)(array[i]));
- *s = '\0';
+ /* Remove trailing '\n' for monitor and syslog */
+ *--s = '\0';
+ if (priority <= zlog_default->maxlvl[ZLOG_DEST_MONITOR])
+ vty_log_fixed(buf,s-buf);
+ if (priority <= zlog_default->maxlvl[ZLOG_DEST_SYSLOG])
+ syslog_sigsafe(priority|zlog_default->facility,buf,s-buf);
+ {
+ int i;
+ /* Just print the function addresses. */
+ for (i = 0; i < size; i++)
+ {
+ s = buf;
+ s = str_append(LOC,"[bt ");
+ s = num_append(LOC,i);
+ s = str_append(LOC,"] 0x");
+ s = hex_append(LOC,(u_long)(array[i]));
+ *s = '\0';
+ if (priority <= zlog_default->maxlvl[ZLOG_DEST_MONITOR])
+ vty_log_fixed(buf,s-buf);
+ if (priority <= zlog_default->maxlvl[ZLOG_DEST_SYSLOG])
syslog_sigsafe(priority|zlog_default->facility,buf,s-buf);
- }
- }
+ }
+ }
}
#undef DUMP
#undef LOC
@@ -476,29 +466,32 @@ _zlog_assert_failed (const char *assertion, const char *file,
{
zlog_err("Assertion `%s' failed in file %s, line %u, function %s",
assertion,file,line,(function ? function : "?"));
- zlog_backtrace(LOG_ERR);
+ zlog_backtrace(LOG_EMERG);
abort();
}
/* Open log stream */
struct zlog *
-openzlog (const char *progname, int flags, zlog_proto_t protocol,
+openzlog (const char *progname, zlog_proto_t protocol,
int syslog_flags, int syslog_facility)
{
struct zlog *zl;
+ u_int i;
- zl = XMALLOC(MTYPE_ZLOG, sizeof (struct zlog));
- memset (zl, 0, sizeof (struct zlog));
+ zl = XCALLOC(MTYPE_ZLOG, sizeof (struct zlog));
zl->ident = progname;
- zl->flags = flags;
zl->protocol = protocol;
zl->facility = syslog_facility;
- zl->maskpri = LOG_DEBUG;
- zl->record_priority = 0;
zl->syslog_options = syslog_flags;
+ /* Set default logging levels. */
+ for (i = 0; i < sizeof(zl->maxlvl)/sizeof(zl->maxlvl[0]); i++)
+ zl->maxlvl[i] = ZLOG_DISABLED;
+ zl->maxlvl[ZLOG_DEST_MONITOR] = LOG_DEBUG;
+ zl->default_lvl = LOG_DEBUG;
+
openlog (progname, syslog_flags, zl->facility);
return zl;
@@ -515,25 +508,16 @@ closezlog (struct zlog *zl)
/* Called from command.c. */
void
-zlog_set_flag (struct zlog *zl, int flags)
+zlog_set_level (struct zlog *zl, zlog_dest_t dest, int log_level)
{
if (zl == NULL)
zl = zlog_default;
- zl->flags |= flags;
-}
-
-void
-zlog_reset_flag (struct zlog *zl, int flags)
-{
- if (zl == NULL)
- zl = zlog_default;
-
- zl->flags &= ~flags;
+ zl->maxlvl[dest] = log_level;
}
int
-zlog_set_file (struct zlog *zl, const char *filename)
+zlog_set_file (struct zlog *zl, const char *filename, int log_level)
{
FILE *fp;
mode_t oldumask;
@@ -548,16 +532,13 @@ zlog_set_file (struct zlog *zl, const char *filename)
/* Open file. */
oldumask = umask (0777 & ~LOGFILE_MASK);
fp = fopen (filename, "a");
- if (fp == NULL)
- {
- umask(oldumask);
- return 0;
- }
umask(oldumask);
+ if (fp == NULL)
+ return 0;
/* Set flags. */
zl->filename = strdup (filename);
- zl->flags |= ZLOG_FILE;
+ zl->maxlvl[ZLOG_DEST_FILE] = log_level;
zl->fp = fp;
return 1;
@@ -570,11 +551,10 @@ zlog_reset_file (struct zlog *zl)
if (zl == NULL)
zl = zlog_default;
- zl->flags &= ~ZLOG_FILE;
-
if (zl->fp)
fclose (zl->fp);
zl->fp = NULL;
+ zl->maxlvl[ZLOG_DEST_FILE] = ZLOG_DISABLED;
if (zl->filename)
free (zl->filename);
@@ -587,7 +567,7 @@ zlog_reset_file (struct zlog *zl)
int
zlog_rotate (struct zlog *zl)
{
- FILE *fp;
+ int level;
if (zl == NULL)
zl = zlog_default;
@@ -595,20 +575,25 @@ zlog_rotate (struct zlog *zl)
if (zl->fp)
fclose (zl->fp);
zl->fp = NULL;
+ level = zl->maxlvl[ZLOG_DEST_FILE];
+ zl->maxlvl[ZLOG_DEST_FILE] = ZLOG_DISABLED;
if (zl->filename)
{
mode_t oldumask;
+ int save_errno;
oldumask = umask (0777 & ~LOGFILE_MASK);
- fp = fopen (zl->filename, "a");
- if (fp == NULL)
+ zl->fp = fopen (zl->filename, "a");
+ save_errno = errno;
+ umask(oldumask);
+ if (zl->fp == NULL)
{
- umask(oldumask);
+ zlog_err("Log rotate failed: cannot open file %s for append: %s",
+ zl->filename, safe_strerror(save_errno));
return -1;
}
- umask(oldumask);
- zl->fp = fp;
+ zl->maxlvl[ZLOG_DEST_FILE] = level;
}
return 1;
diff --git a/lib/log.h b/lib/log.h
index 26ff902b..1f9f23cd 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -1,4 +1,7 @@
-/* Zebra logging funcions.
+/*
+ * $Id: log.h,v 1.14 2004/12/07 15:39:32 ajs Exp $
+ *
+ * Zebra logging funcions.
* Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
*
* This file is part of GNU Zebra.
@@ -40,12 +43,6 @@
* please use LOG_ERR instead.
*/
-#define ZLOG_NOLOG 0x00
-#define ZLOG_FILE 0x01
-#define ZLOG_SYSLOG 0x02
-#define ZLOG_STDOUT 0x04
-#define ZLOG_STDERR 0x08
-
typedef enum
{
ZLOG_NONE,
@@ -60,14 +57,28 @@ typedef enum
ZLOG_MASC
} zlog_proto_t;
+/* If maxlvl is set to ZLOG_DISABLED, then no messages will be sent
+ to that logging destination. */
+#define ZLOG_DISABLED (LOG_EMERG-1)
+
+typedef enum
+{
+ ZLOG_DEST_SYSLOG = 0,
+ ZLOG_DEST_STDOUT,
+ ZLOG_DEST_MONITOR,
+ ZLOG_DEST_FILE
+} zlog_dest_t;
+#define ZLOG_NUM_DESTS (ZLOG_DEST_FILE+1)
+
struct zlog
{
const char *ident; /* daemon name (first arg to openlog) */
zlog_proto_t protocol;
- int flags; /* mask indicating which destinations to log to */
+ int maxlvl[ZLOG_NUM_DESTS]; /* maximum priority to send to associated
+ logging destination */
+ int default_lvl; /* maxlvl to use if none is specified */
FILE *fp;
char *filename;
- int maskpri; /* discard messages with priority > maskpri */
int facility; /* as per syslog facility */
int record_priority; /* should messages logged through stdio include the
priority of the message? */
@@ -85,7 +96,8 @@ struct message
extern struct zlog *zlog_default;
/* Open zlog function */
-struct zlog *openzlog (const char *, int, zlog_proto_t, int, int);
+struct zlog *openzlog (const char *progname, zlog_proto_t protocol,
+ int syslog_options, int syslog_facility);
/* Close zlog function. */
void closezlog (struct zlog *zl);
@@ -114,12 +126,15 @@ void plog_info (struct zlog *, const char *format, ...);
void plog_notice (struct zlog *, const char *format, ...);
void plog_debug (struct zlog *, const char *format, ...);
-/* Set zlog flags. */
-void zlog_set_flag (struct zlog *zl, int flags);
-void zlog_reset_flag (struct zlog *zl, int flags);
+/* Set logging level for the given destination. If the log_level
+ argument is ZLOG_DISABLED, then the destination is disabled.
+ This function should not be used for file logging (use zlog_set_file
+ or zlog_reset_file instead). */
+void zlog_set_level (struct zlog *zl, zlog_dest_t, int log_level);
-/* Set zlog filename. */
-int zlog_set_file (struct zlog *zl, const char *filename);
+/* Set logging to the given filename at the specified level. */
+int zlog_set_file (struct zlog *zl, const char *filename, int log_level);
+/* Disable file logging. */
int zlog_reset_file (struct zlog *zl);
/* Rotate log. */
@@ -132,6 +147,7 @@ const char *lookup (struct message *, int);
const char *mes_lookup (struct message *meslist, int max, int index);
extern const char *zlog_priority[];
+extern const char *zlog_proto_names[];
/* Safe version of strerror -- never returns NULL. */
extern const char *safe_strerror(int errnum);
@@ -147,4 +163,40 @@ extern void zlog_backtrace(int priority);
up the state of zlog file pointers. */
extern void zlog_backtrace_sigsafe(int priority);
+/* Defines for use in command construction: */
+
+#define LOG_LEVELS "(emergencies|alerts|critical|errors|warnings|notifications|informational|debugging)"
+
+#define LOG_LEVEL_DESC \
+ "System is unusable\n" \
+ "Immediate action needed\n" \
+ "Critical conditions\n" \
+ "Error conditions\n" \
+ "Warning conditions\n" \
+ "Normal but significant conditions\n" \
+ "Informational messages\n" \
+ "Debugging messages\n"
+
+#define LOG_FACILITIES "(kern|user|mail|daemon|auth|syslog|lpr|news|uucp|cron|local0|local1|local2|local3|local4|local5|local6|local7)"
+
+#define LOG_FACILITY_DESC \
+ "Kernel\n" \
+ "User process\n" \
+ "Mail system\n" \
+ "System daemons\n" \
+ "Authorization system\n" \
+ "Syslog itself\n" \
+ "Line printer system\n" \
+ "USENET news\n" \
+ "Unix-to-Unix copy system\n" \
+ "Cron/at facility\n" \
+ "Local use\n" \
+ "Local use\n" \
+ "Local use\n" \
+ "Local use\n" \
+ "Local use\n" \
+ "Local use\n" \
+ "Local use\n" \
+ "Local use\n"
+
#endif /* _ZEBRA_LOG_H */
diff --git a/lib/vty.c b/lib/vty.c
index bf1eec38..25366fb4 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -148,14 +148,17 @@ vty_out (struct vty *vty, const char *format, ...)
}
static int
-vty_log_out (struct vty *vty, const char *proto_str, const char *format,
- va_list va)
+vty_log_out (struct vty *vty, const char *level, const char *proto_str,
+ const char *format, va_list va)
{
int len;
char buf[1024];
- snprintf (buf, sizeof buf, "%s: ", proto_str);
- write (vty->fd, buf, strlen (proto_str) + 2);
+ if (level)
+ snprintf (buf, sizeof buf, "%s: %s: ", level, proto_str);
+ else
+ snprintf (buf, sizeof buf, "%s: ", proto_str);
+ write (vty->fd, buf, strlen (buf));
len = vsnprintf (buf, sizeof buf, format, va);
if (len < 0)
@@ -602,7 +605,7 @@ static void
vty_down_level (struct vty *vty)
{
vty_out (vty, "%s", VTY_NEWLINE);
- config_exit (NULL, vty, 0, NULL);
+ (*config_exit_cmd.func)(NULL, vty, 0, NULL);
vty_prompt (vty);
vty->cp = 0;
}
@@ -2273,7 +2276,8 @@ vty_read_config (char *config_file,
/* Small utility function which output log to the VTY. */
void
-vty_log (const char *proto_str, const char *format, va_list va)
+vty_log (const char *level, const char *proto_str,
+ const char *format, va_list va)
{
unsigned int i;
struct vty *vty;
@@ -2284,11 +2288,29 @@ vty_log (const char *proto_str, const char *format, va_list va)
{
va_list ac;
va_copy(ac, va);
- vty_log_out (vty, proto_str, format, ac);
+ vty_log_out (vty, level, proto_str, format, ac);
va_end(ac);
}
}
+/* Async-signal-safe version of vty_log for fixed strings. */
+void
+vty_log_fixed (const char *buf, size_t len)
+{
+ unsigned int i;
+
+ for (i = 0; i < vector_max (vtyvec); i++)
+ {
+ struct vty *vty;
+ if ((vty = vector_slot (vtyvec, i)) != NULL)
+ if (vty->monitor)
+ {
+ write(vty->fd, buf, len);
+ write(vty->fd, "\r\n", 2);
+ }
+ }
+}
+
int
vty_config_lock (struct vty *vty)
{
diff --git a/lib/vty.h b/lib/vty.h
index c3221e2a..8cd2b4e3 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -180,11 +180,15 @@ void vty_time_print (struct vty *, int);
void vty_serv_sock (const char *, unsigned short, const char *);
void vty_close (struct vty *);
char *vty_get_cwd (void);
-void vty_log (const char *, const char *, va_list);
+void vty_log (const char *level, const char *proto, const char *fmt, va_list);
int vty_config_lock (struct vty *);
int vty_config_unlock (struct vty *);
int vty_shell (struct vty *);
int vty_shell_serv (struct vty *);
void vty_hello (struct vty *);
+/* Send a fixed-size message to all vty terminal monitors; this should be
+ an async-signal-safe function. */
+extern void vty_log_fixed (const char *buf, size_t len);
+
#endif /* _ZEBRA_VTY_H */
diff --git a/ospf6d/ChangeLog b/ospf6d/ChangeLog
index 7bb6b4bf..a3e8c949 100644
--- a/ospf6d/ChangeLog
+++ b/ospf6d/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * 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.
+
2004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ospf6_main.c: (sigint,sigterm) Use zlog_notice for termination
diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c
index ba266d95..073e9d68 100644
--- a/ospf6d/ospf6_main.c
+++ b/ospf6d/ospf6_main.c
@@ -184,7 +184,6 @@ main (int argc, char *argv[], char *envp[])
int vty_port = 0;
char *config_file = NULL;
struct thread thread;
- int flag;
/* Set umask before anything for security */
umask (0027);
@@ -250,12 +249,7 @@ main (int argc, char *argv[], char *envp[])
master = thread_master_create ();
/* Initializations. */
- if (! daemon_mode)
- flag = ZLOG_STDOUT;
- else
- flag = 0;
-
- zlog_default = openzlog (progname, flag, ZLOG_OSPF6,
+ zlog_default = openzlog (progname, ZLOG_OSPF6,
LOG_CONS|LOG_NDELAY|LOG_PID,
LOG_DAEMON);
zprivs_init (&ospf6d_privs);
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index 9d5b1fb8..33c790ad 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * ospf_main.c: (main) The 2nd argument to openzlog has been removed.
+
2004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ospf_packet.c: (ospf_db_desc) Reduce priority on a debug message
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index d155c980..7955162d 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -201,7 +201,7 @@ main (int argc, char **argv)
exit (1);
}
- zlog_default = openzlog (progname, ZLOG_NOLOG, ZLOG_OSPF,
+ zlog_default = openzlog (progname, ZLOG_OSPF,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
/* OSPF master init. */
diff --git a/ripd/ChangeLog b/ripd/ChangeLog
index 1c703dfa..46b7f193 100644
--- a/ripd/ChangeLog
+++ b/ripd/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * rip_main.c: (main) The 2nd argument to openzlog has been removed.
+
2004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* rip_main.c: (sigint) Use zlog_notice for termination message.
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index 2b2939dd..ba60b36f 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -195,7 +195,7 @@ main (int argc, char **argv)
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
/* First of all we need logging init. */
- zlog_default = openzlog (progname, ZLOG_NOLOG, ZLOG_RIP,
+ zlog_default = openzlog (progname, ZLOG_RIP,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
/* Command line option parse. */
diff --git a/ripngd/ChangeLog b/ripngd/ChangeLog
index 840f4130..a6682567 100644
--- a/ripngd/ChangeLog
+++ b/ripngd/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * ripng_main.c: (main) The 2nd argument to openzlog has been removed.
+
2004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ripng_main.c: (sighup) Remove spurious terminating message.
diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c
index ac63abbb..ea30c1bf 100644
--- a/ripngd/ripng_main.c
+++ b/ripngd/ripng_main.c
@@ -197,7 +197,7 @@ main (int argc, char **argv)
/* get program name */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog(progname, ZLOG_NOLOG, ZLOG_RIPNG,
+ zlog_default = openzlog(progname, ZLOG_RIPNG,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
while (1)
diff --git a/vtysh/ChangeLog b/vtysh/ChangeLog
index ea611179..5e32f015 100644
--- a/vtysh/ChangeLog
+++ b/vtysh/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * 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.
+
2004-11-11 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* vtysh.c: (vtysh_client_execute) Fix flaws in detecting trailing
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 08bd1275..0a043cf9 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -52,7 +52,7 @@ int vtysh_writeconfig_integrated = 0;
extern char config_default[];
-void
+static void
vclient_close (struct vtysh_client *vclient)
{
if (vclient->fd > 0)
@@ -63,7 +63,7 @@ vclient_close (struct vtysh_client *vclient)
/* Following filled with debug code to trace a problematic condition
* under load - it SHOULD handle it. */
#define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): "
-int
+static int
vtysh_client_config (struct vtysh_client *vclient, char *line)
{
int ret;
@@ -161,7 +161,7 @@ vtysh_client_config (struct vtysh_client *vclient, char *line)
return ret;
}
-int
+static int
vtysh_client_execute (struct vtysh_client *vclient, const char *line, FILE *fp)
{
int ret;
@@ -247,7 +247,7 @@ vtysh_pager_init ()
}
/* Command execution over the vty interface. */
-void
+static void
vtysh_execute_func (const char *line, int pager)
{
int ret, cmd_stat;
@@ -604,7 +604,7 @@ vtysh_rl_describe ()
* correct places only. */
int complete_status;
-char *
+static char *
command_generator (const char *text, int state)
{
vector vline;
@@ -635,7 +635,7 @@ command_generator (const char *text, int state)
return NULL;
}
-char **
+static char **
new_completion (char *text, int start, int end)
{
char **matches;
@@ -652,7 +652,9 @@ new_completion (char *text, int start, int end)
return matches;
}
-char **
+#if 0
+/* This function is not actually being used. */
+static char **
vtysh_completion (char *text, int start, int end)
{
int ret;
@@ -676,6 +678,7 @@ vtysh_completion (char *text, int start, int end)
return (char **) matched;
}
+#endif
/* Vty node structures. */
struct cmd_node bgp_node =
@@ -1015,7 +1018,7 @@ DEFUNSH (VTYSH_ALL,
return CMD_SUCCESS;
}
-int
+static int
vtysh_exit (struct vty *vty)
{
switch (vty->node)
@@ -1265,7 +1268,18 @@ DEFUNSH (VTYSH_ALL,
vtysh_log_stdout_cmd,
"log stdout",
"Logging control\n"
- "Logging goes to stdout\n")
+ "Set stdout logging level\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ vtysh_log_stdout_level,
+ vtysh_log_stdout_level_cmd,
+ "log stdout "LOG_LEVELS,
+ "Logging control\n"
+ "Set stdout logging level\n"
+ LOG_LEVEL_DESC)
{
return CMD_SUCCESS;
}
@@ -1273,10 +1287,11 @@ DEFUNSH (VTYSH_ALL,
DEFUNSH (VTYSH_ALL,
no_vtysh_log_stdout,
no_vtysh_log_stdout_cmd,
- "no log stdout",
+ "no log stdout [LEVEL]",
NO_STR
"Logging control\n"
- "Logging goes to stdout\n")
+ "Cancel logging to stdout\n"
+ "Logging level\n")
{
return CMD_SUCCESS;
}
@@ -1293,6 +1308,18 @@ DEFUNSH (VTYSH_ALL,
}
DEFUNSH (VTYSH_ALL,
+ vtysh_log_file_level,
+ vtysh_log_file_level_cmd,
+ "log file FILENAME "LOG_LEVELS,
+ "Logging control\n"
+ "Logging to file\n"
+ "Logging filename\n"
+ LOG_LEVEL_DESC)
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
no_vtysh_log_file,
no_vtysh_log_file_cmd,
"no log file [FILENAME]",
@@ -1304,12 +1331,66 @@ DEFUNSH (VTYSH_ALL,
return CMD_SUCCESS;
}
+ALIAS_SH (VTYSH_ALL,
+ no_vtysh_log_file,
+ no_vtysh_log_file_level_cmd,
+ "no log file FILENAME LEVEL",
+ NO_STR
+ "Logging control\n"
+ "Cancel logging to file\n"
+ "Logging file name\n"
+ "Logging level\n")
+
+DEFUNSH (VTYSH_ALL,
+ vtysh_log_monitor,
+ vtysh_log_monitor_cmd,
+ "log monitor",
+ "Logging control\n"
+ "Set terminal line (monitor) logging level\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ vtysh_log_monitor_level,
+ vtysh_log_monitor_level_cmd,
+ "log monitor "LOG_LEVELS,
+ "Logging control\n"
+ "Set terminal line (monitor) logging level\n"
+ LOG_LEVEL_DESC)
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ no_vtysh_log_monitor,
+ no_vtysh_log_monitor_cmd,
+ "no log monitor [LEVEL]",
+ NO_STR
+ "Logging control\n"
+ "Disable terminal line (monitor) logging\n"
+ "Logging level\n")
+{
+ return CMD_SUCCESS;
+}
+
DEFUNSH (VTYSH_ALL,
vtysh_log_syslog,
vtysh_log_syslog_cmd,
"log syslog",
"Logging control\n"
- "Logging goes to syslog\n")
+ "Set syslog logging level\n")
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH (VTYSH_ALL,
+ vtysh_log_syslog_level,
+ vtysh_log_syslog_level_cmd,
+ "log syslog "LOG_LEVELS,
+ "Logging control\n"
+ "Set syslog logging level\n"
+ LOG_LEVEL_DESC)
{
return CMD_SUCCESS;
}
@@ -1317,32 +1398,60 @@ DEFUNSH (VTYSH_ALL,
DEFUNSH (VTYSH_ALL,
no_vtysh_log_syslog,
no_vtysh_log_syslog_cmd,
- "no log syslog",
+ "no log syslog [LEVEL]",
NO_STR
"Logging control\n"
- "Cancel logging to syslog\n")
+ "Cancel logging to syslog\n"
+ "Logging level\n")
{
return CMD_SUCCESS;
}
DEFUNSH (VTYSH_ALL,
- vtysh_log_trap,
- vtysh_log_trap_cmd,
- "log trap (emergencies|alerts|critical|errors|warnings|\
- notifications|informational|debugging)",
+ vtysh_log_facility,
+ vtysh_log_facility_cmd,
+ "log facility "LOG_FACILITIES,
"Logging control\n"
- "Limit logging to specifed level\n")
+ "Facility parameter for syslog messages\n"
+ LOG_FACILITY_DESC)
+
{
return CMD_SUCCESS;
}
DEFUNSH (VTYSH_ALL,
- no_vtysh_log_trap,
- no_vtysh_log_trap_cmd,
- "no log trap",
+ no_vtysh_log_facility,
+ no_vtysh_log_facility_cmd,
+ "no log facility [FACILITY]",
NO_STR
"Logging control\n"
- "Permit all logging information\n")
+ "Reset syslog facility to default (daemon)\n"
+ "Syslog facility\n")
+
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH_DEPRECATED (VTYSH_ALL,
+ vtysh_log_trap,
+ vtysh_log_trap_cmd,
+ "log trap "LOG_LEVELS,
+ "Logging control\n"
+ "(Deprecated) Set logging level and default for all destinations\n"
+ LOG_LEVEL_DESC)
+
+{
+ return CMD_SUCCESS;
+}
+
+DEFUNSH_DEPRECATED (VTYSH_ALL,
+ no_vtysh_log_trap,
+ no_vtysh_log_trap_cmd,
+ "no log trap [LEVEL]",
+ NO_STR
+ "Logging control\n"
+ "Permit all logging information\n"
+ "Logging level\n")
{
return CMD_SUCCESS;
}
@@ -1521,7 +1630,8 @@ DEFUN (no_vtysh_integrated_config,
return CMD_SUCCESS;
}
-int write_config_integrated(void)
+static int
+write_config_integrated(void)
{
int ret;
char line[] = "write terminal\n";
@@ -1702,7 +1812,7 @@ DEFUN (vtysh_show_daemons,
}
/* Execute command in child process. */
-int
+static int
execute_command (const char *command, int argc, const char *arg1,
const char *arg2)
{
@@ -1867,14 +1977,14 @@ DEFUN (vtysh_start_zsh,
return CMD_SUCCESS;
}
-void
+static void
vtysh_install_default (enum node_type node)
{
install_element (node, &config_list_cmd);
}
/* Making connection to protocol daemon. */
-int
+static int
vtysh_connect (struct vtysh_client *vclient, const char *path)
{
int ret;
@@ -1957,7 +2067,7 @@ vtysh_connect_all()
}
/* To disable readline's filename completion. */
-char *
+static char *
vtysh_completion_entry_function (const char *ignore, int invoking_key)
{
return NULL;
@@ -2190,13 +2300,22 @@ vtysh_init_vty ()
install_element (ENABLE_NODE, &vtysh_start_zsh_cmd);
install_element (CONFIG_NODE, &vtysh_log_stdout_cmd);
+ install_element (CONFIG_NODE, &vtysh_log_stdout_level_cmd);
install_element (CONFIG_NODE, &no_vtysh_log_stdout_cmd);
install_element (CONFIG_NODE, &vtysh_log_file_cmd);
+ install_element (CONFIG_NODE, &vtysh_log_file_level_cmd);
install_element (CONFIG_NODE, &no_vtysh_log_file_cmd);
+ install_element (CONFIG_NODE, &no_vtysh_log_file_level_cmd);
+ install_element (CONFIG_NODE, &vtysh_log_monitor_cmd);
+ install_element (CONFIG_NODE, &vtysh_log_monitor_level_cmd);
+ install_element (CONFIG_NODE, &no_vtysh_log_monitor_cmd);
install_element (CONFIG_NODE, &vtysh_log_syslog_cmd);
+ install_element (CONFIG_NODE, &vtysh_log_syslog_level_cmd);
install_element (CONFIG_NODE, &no_vtysh_log_syslog_cmd);
install_element (CONFIG_NODE, &vtysh_log_trap_cmd);
install_element (CONFIG_NODE, &no_vtysh_log_trap_cmd);
+ install_element (CONFIG_NODE, &vtysh_log_facility_cmd);
+ install_element (CONFIG_NODE, &no_vtysh_log_facility_cmd);
install_element (CONFIG_NODE, &vtysh_log_record_priority_cmd);
install_element (CONFIG_NODE, &no_vtysh_log_record_priority_cmd);
diff --git a/zebra/ChangeLog b/zebra/ChangeLog
index c38b47de..d22ba630 100644
--- a/zebra/ChangeLog
+++ b/zebra/ChangeLog
@@ -1,3 +1,10 @@
+2004-12-07 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * 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.
+
2004-12-03 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* main.c: (sigint) Use zlog_notice for termination message.
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index 8f0250bf..10062db5 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -322,7 +322,7 @@ void irdp_finish()
struct zebra_if *zi;
struct irdp_interface *irdp;
- zlog_warn("IRDP: Received shutdown notification.");
+ zlog_info("IRDP: Received shutdown notification.");
for (node = listhead (iflist); node; node = nextnode (node))
{
diff --git a/zebra/main.c b/zebra/main.c
index 96420da6..019e8d20 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -224,7 +224,7 @@ main (int argc, char **argv)
/* preserve my name */
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
- zlog_default = openzlog (progname, ZLOG_STDOUT, ZLOG_ZEBRA,
+ zlog_default = openzlog (progname, ZLOG_ZEBRA,
LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
while (1)