diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/command.h | 4 | ||||
| -rw-r--r-- | lib/lib_vty.c | 54 | ||||
| -rw-r--r-- | lib/vty.c | 1 | ||||
| -rw-r--r-- | lib/yang.c | 6 | ||||
| -rw-r--r-- | lib/yang.h | 5 |
5 files changed, 65 insertions, 5 deletions
diff --git a/lib/command.h b/lib/command.h index bb007b0868..e529239f65 100644 --- a/lib/command.h +++ b/lib/command.h @@ -530,7 +530,9 @@ extern int cmd_execute_command(vector, struct vty *, const struct cmd_element **, int); extern int cmd_execute_command_strict(vector, struct vty *, const struct cmd_element **); -extern void cmd_init(int); +extern void cmd_init(int terminal); +extern void cmd_init_config_callbacks(void (*start_config)(void), + void (*end_config)(void)); extern void cmd_terminate(void); extern void cmd_exit(struct vty *vty); extern int cmd_list_cmds(struct vty *vty, int do_permute); diff --git a/lib/lib_vty.c b/lib/lib_vty.c index 9c927ca4af..8207aa20e6 100644 --- a/lib/lib_vty.c +++ b/lib/lib_vty.c @@ -212,6 +212,57 @@ DEFUN (frr_version, return CMD_SUCCESS; } +static struct call_back { + time_t readin_time; + + void (*start_config)(void); + void (*end_config)(void); +} callback; + + +DEFUN_HIDDEN (start_config, + start_config_cmd, + "start_configuration", + "The Beginning of Configuration\n") +{ + callback.readin_time = monotime(NULL); + + if (callback.start_config) + (*callback.start_config)(); + + return CMD_SUCCESS; +} + +DEFUN_HIDDEN (end_config, + end_config_cmd, + "end_configuration", + "The End of Configuration\n") +{ + time_t readin_time; + char readin_time_str[MONOTIME_STRLEN]; + + readin_time = monotime(NULL); + readin_time -= callback.readin_time; + + frrtime_to_interval(readin_time, readin_time_str, + sizeof(readin_time_str)); + + zlog_info("Configuration Read in Took: %s", readin_time_str); + + if (callback.end_config) + (*callback.end_config)(); + + return CMD_SUCCESS; +} + +void cmd_init_config_callbacks(void (*start_config)(void), + void (*end_config)(void)) +{ + callback.start_config = start_config; + callback.end_config = end_config; +} + + static void defaults_autocomplete(vector comps, struct cmd_token *token) { const char **p; @@ -234,6 +285,9 @@ void lib_cmd_init(void) install_element(VIEW_NODE, &show_memory_cmd); install_element(VIEW_NODE, &show_modules_cmd); + + install_element(CONFIG_NODE, &start_config_cmd); + install_element(CONFIG_NODE, &end_config_cmd); } /* Stats querying from users */ @@ -1811,6 +1811,7 @@ static int vty_accept(struct thread *thread) set_cloexec(vty_sock); if (!sockunion2hostprefix(&su, &p)) { + close(vty_sock); zlog_info("Vty unable to convert prefix from sockunion %s", sockunion2str(&su, buf, SU_ADDRSTRLEN)); return -1; diff --git a/lib/yang.c b/lib/yang.c index c59cb642f0..22fe938e4c 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -772,8 +772,7 @@ const struct lyd_node *yang_dnode_get_parent(const struct lyd_node *dnode, return NULL; } -/* API to check if the given node is last node in the list */ -static bool yang_is_last_list_dnode(const struct lyd_node *dnode) +bool yang_is_last_list_dnode(const struct lyd_node *dnode) { return (((dnode->next == NULL) || (dnode->next @@ -785,8 +784,7 @@ static bool yang_is_last_list_dnode(const struct lyd_node *dnode) != 0))); } -/* API to check if the given node is last node in the data tree level */ -static bool yang_is_last_level_dnode(const struct lyd_node *dnode) +bool yang_is_last_level_dnode(const struct lyd_node *dnode) { const struct lyd_node *parent; const struct lys_node_list *snode; diff --git a/lib/yang.h b/lib/yang.h index 0cd6a4a6f2..b8bf07ee7e 100644 --- a/lib/yang.h +++ b/lib/yang.h @@ -587,6 +587,11 @@ extern uint32_t yang_get_list_elements_count(const struct lyd_node *node); /* To get the immediate child of a dnode */ const struct lyd_node *yang_dnode_get_child(const struct lyd_node *dnode); +/* API to check if the given node is last node in the list */ +bool yang_is_last_list_dnode(const struct lyd_node *dnode); + +/* API to check if the given node is last node in the data tree level */ +bool yang_is_last_level_dnode(const struct lyd_node *dnode); #ifdef __cplusplus } |
