Tracing of CLI connections/commands can be now controlled
by `debug commands <level>' in the configuration. Level 0 means no tracing, 1 means connections only, 2 includes all commands.
This commit is contained in:
parent
26eee1c33a
commit
4761efdb43
4 changed files with 14 additions and 6 deletions
|
@ -23,6 +23,7 @@ struct config {
|
||||||
struct rtable_config *master_rtc; /* Configuration of master routing table */
|
struct rtable_config *master_rtc; /* Configuration of master routing table */
|
||||||
u32 router_id; /* Our Router ID */
|
u32 router_id; /* Our Router ID */
|
||||||
unsigned int proto_default_debug; /* Default protocol debug mask */
|
unsigned int proto_default_debug; /* Default protocol debug mask */
|
||||||
|
int cli_debug; /* Tracing of CLI connections and commands */
|
||||||
char *err_msg; /* Parser error message */
|
char *err_msg; /* Parser error message */
|
||||||
int err_lino; /* Line containing error */
|
int err_lino; /* Line containing error */
|
||||||
char *file_name; /* Name of configuration file */
|
char *file_name; /* Name of configuration file */
|
||||||
|
|
|
@ -162,6 +162,8 @@ cli_command(struct cli *c)
|
||||||
struct config f;
|
struct config f;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
if (config->cli_debug > 1)
|
||||||
|
log(L_TRACE "CLI: %s", c->rx_buf);
|
||||||
bzero(&f, sizeof(f));
|
bzero(&f, sizeof(f));
|
||||||
f.mem = c->parser_pool;
|
f.mem = c->parser_pool;
|
||||||
cf_read_hook = cli_cmd_read_hook;
|
cf_read_hook = cli_cmd_read_hook;
|
||||||
|
|
|
@ -22,7 +22,7 @@ CF_DECLS
|
||||||
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
|
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
|
||||||
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
|
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
|
||||||
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
|
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
|
||||||
CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR)
|
CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS)
|
||||||
|
|
||||||
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
|
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
|
||||||
RIP, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE)
|
RIP, OSPF, OSPF_EXT, OSPF_IA, OSPF_BOUNDARY, BGP, PIPE)
|
||||||
|
@ -118,6 +118,7 @@ CF_ADDTO(conf, debug_default)
|
||||||
|
|
||||||
debug_default:
|
debug_default:
|
||||||
DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
|
DEBUG PROTOCOLS debug_mask { new_config->proto_default_debug = $3; }
|
||||||
|
| DEBUG COMMANDS expr { new_config->cli_debug = $3; }
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Interface patterns */
|
/* Interface patterns */
|
||||||
|
|
|
@ -232,11 +232,14 @@ cli_tx(sock *s)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cli_err(sock *s, int err)
|
cli_err(sock *s, int err)
|
||||||
|
{
|
||||||
|
if (config->cli_debug)
|
||||||
{
|
{
|
||||||
if (err)
|
if (err)
|
||||||
log(L_INFO "CLI connection dropped: %s", strerror(err));
|
log(L_INFO "CLI connection dropped: %s", strerror(err));
|
||||||
else
|
else
|
||||||
log(L_INFO "CLI connection closed");
|
log(L_INFO "CLI connection closed");
|
||||||
|
}
|
||||||
cli_free(s->data);
|
cli_free(s->data);
|
||||||
sk_close(s);
|
sk_close(s);
|
||||||
}
|
}
|
||||||
|
@ -246,6 +249,7 @@ cli_connect(sock *s, int size)
|
||||||
{
|
{
|
||||||
cli *c;
|
cli *c;
|
||||||
|
|
||||||
|
if (config->cli_debug)
|
||||||
log(L_INFO "CLI connect");
|
log(L_INFO "CLI connect");
|
||||||
s->rx_hook = cli_rx;
|
s->rx_hook = cli_rx;
|
||||||
s->tx_hook = cli_tx;
|
s->tx_hook = cli_tx;
|
||||||
|
|
Loading…
Reference in a new issue