aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-11-17 14:07:52 +0100
committerHarald Welte <laforge@gnumonks.org>2017-11-17 14:07:52 +0100
commitd38126ba403bd73f50f903b35207143fbf12424c (patch)
treee73a133e336dcd63f9466b1ac2f11954831455ff
parentb93f60f7cd4bebbe6c26a456ea0b394fcafc731f (diff)
WIP: Add vty_node exit callbacklaforge/vty-node-exit-cb
This way an application (or library) implementing a VTY node can register an exit call-back that is called every time the node is exit-ed, e.g. to apply any configuration changes, to verify their consistency, or the like. THIS BREAKS ABI so don't merge it without increasing LIBVER major Change-Id: I9c917955e9569d22048449763b3ac6c770b58b58
-rw-r--r--include/osmocom/vty/command.h3
-rw-r--r--src/vty/command.c5
2 files changed, 8 insertions, 0 deletions
diff --git a/include/osmocom/vty/command.h b/include/osmocom/vty/command.h
index 13d6e89d..a364d59e 100644
--- a/include/osmocom/vty/command.h
+++ b/include/osmocom/vty/command.h
@@ -130,6 +130,9 @@ struct cmd_node {
* plus '-' and '_' characters (is used as XML ID for 'show
* online-help'). If left NUL, this is derived from the prompt.*/
char name[64];
+
+ /*! Node's exit call-back function */
+ void (*exit_cb) (struct vty *);
};
enum {
diff --git a/src/vty/command.c b/src/vty/command.c
index 5f7a42c3..cdb387df 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -2089,6 +2089,11 @@ static void vty_clear_parents(struct vty *vty)
*/
int vty_go_parent(struct vty *vty)
{
+ struct cmd_node *cnode = vector_slot(cmdvec, vty->node);
+
+ if (cnode->exit_cb)
+ cnode->exit_cb(vty);
+
switch (vty->node) {
case AUTH_NODE:
case VIEW_NODE: