vty: Add a new callback to let code decide if it is a config node or not
authorHolger Hans Peter Freyther <zecke@selfish.org>
Wed, 25 Aug 2010 09:34:56 +0000 (17:34 +0800)
committerHolger Hans Peter Freyther <zecke@selfish.org>
Thu, 26 Aug 2010 07:00:52 +0000 (15:00 +0800)
include/osmocom/vty/vty.h
src/vty/command.c

index e7399ba..71b6be0 100644 (file)
@@ -133,6 +133,7 @@ struct vty_app_info {
        const char *copyright;
        void *tall_ctx;
        enum node_type (*go_parent_cb)(struct vty *vty);
+       int (*is_config_node)(struct vty *vty, int node);
 };
 
 /* Prototypes. */
index bec28a0..6a52321 100644 (file)
@@ -141,6 +141,10 @@ static int cmp_desc(const void *p, const void *q)
 
 static int is_config(struct vty *vty)
 {
+       /* ask the application */
+       if (host.app_info->is_config_node)
+               return host.app_info->is_config_node(vty, vty->node);
+
        /* Assume that everything above CONFIG_NODE is a config node */
        return vty->node > CONFIG_NODE;
 }