diff --git a/server/cmd_opts.h b/server/cmd_opts.h index 09c9b033..cca30d7c 100644 --- a/server/cmd_opts.h +++ b/server/cmd_opts.h @@ -125,6 +125,7 @@ enum { ENABLE_PCAP_ANY_DIRECTION, ROTATE_DIGEST_CACHE, SYSLOG_ENABLE, + DUMP_SERVER_ERR_CODES, NOOP /* Just to be a marker for the end */ }; @@ -141,7 +142,8 @@ static struct option cmd_opts[] = {"packet-limit", 1, NULL, 'C'}, {"digest-file", 1, NULL, 'd'}, {"dump-config", 0, NULL, 'D'}, - {"syslog-enable", 0, NULL, SYSLOG_ENABLE }, + {"dump-serv-err-codes", 0, NULL, DUMP_SERVER_ERR_CODES }, + {"syslog-enable", 0, NULL, SYSLOG_ENABLE }, {"foreground", 0, NULL, 'f'}, {"help", 0, NULL, 'h'}, {"interface", 1, NULL, 'i'}, diff --git a/server/config_init.c b/server/config_init.c index 27ee391c..3383c363 100644 --- a/server/config_init.c +++ b/server/config_init.c @@ -29,6 +29,7 @@ ****************************************************************************** */ #include "fwknopd_common.h" +#include "fwknopd_errors.h" #include "config_init.h" #include "access.h" #include "cmd_opts.h" @@ -883,6 +884,9 @@ config_init(fko_srv_options_t *opts, int argc, char **argv) case 'D': opts->dump_config = 1; break; + case DUMP_SERVER_ERR_CODES: + dump_server_errors(); + clean_exit(opts, NO_FW_CLEANUP, EXIT_SUCCESS); case 'f': opts->foreground = 1; break; diff --git a/server/fwknopd_errors.c b/server/fwknopd_errors.c index 2507bb6d..fe0491d2 100644 --- a/server/fwknopd_errors.c +++ b/server/fwknopd_errors.c @@ -106,4 +106,24 @@ get_errstr(const int err_code) return(fwknopd_errstr(err_code)); } +/* print all server errors (from server/fwknopd_errors.c) to stdout +*/ +void +dump_server_errors(void) +{ + int i; + for (i=SPA_MSG_BAD_DATA; i<=SPA_MSG_ERROR; i++) + { + fprintf(stdout, "err code: %d, err string: '%s'\n", + i, fwknopd_errstr(i)); + } + for (i=FW_RULE_ADD_ERROR; i<=FW_RULE_UNKNOWN_ERROR; i++) + { + fprintf(stdout, "err code: %d, err string: '%s'\n", + i, fwknopd_errstr(i)); + } + fflush(stdout); + return; +} + /***EOF***/ diff --git a/test/tests/basic_operations.pl b/test/tests/basic_operations.pl index cd0c6947..bb062981 100644 --- a/test/tests/basic_operations.pl +++ b/test/tests/basic_operations.pl @@ -17,6 +17,16 @@ 'cmdline' => "$fwknopdCmd $default_server_conf_args " . "-O $conf_dir/override_fwknopd.conf --dump-config", }, + { + 'category' => 'basic operations', + 'subcategory' => 'server', + 'detail' => 'dump error codes ', + 'function' => \&generic_exec, + 'exec_err' => $NO, + 'cmdline' => "$fwknopdCmd $default_server_conf_args " . + "--dump-serv-err-codes", + }, + { 'category' => 'basic operations', 'subcategory' => 'client',