aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/vty/command.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/osmocom/vty/command.h')
-rw-r--r--include/osmocom/vty/command.h94
1 files changed, 88 insertions, 6 deletions
diff --git a/include/osmocom/vty/command.h b/include/osmocom/vty/command.h
index 88490f79..61b58815 100644
--- a/include/osmocom/vty/command.h
+++ b/include/osmocom/vty/command.h
@@ -24,10 +24,12 @@
#pragma once
#include <stdio.h>
+#include <stdbool.h>
#include <sys/types.h>
#include "vector.h"
#include <osmocom/core/defs.h>
+#include <osmocom/core/utils.h>
/*! \defgroup command VTY Command
* @{
@@ -97,11 +99,21 @@ enum node_type {
L_CS7_SCCPADDR_NODE, /*!< SS7 SCCP Address */
L_CS7_SCCPADDR_GT_NODE, /*!< SS7 SCCP Global Title */
+ L_CPU_SCHED_NODE, /*!< CPU Sched related options node */
+ L_NS_BIND_NODE, /*!< NS bind node */
+ L_NS_NSE_NODE, /*!< NS NSE node */
/*
* When adding new nodes to the libosmocore project, these nodes can be
* used to avoid ABI changes for unrelated projects.
*/
+ RESERVED1_NODE, /*!< Reserved for later extensions */
+ RESERVED2_NODE, /*!< Reserved for later extensions */
RESERVED3_NODE, /*!< Reserved for later extensions */
+ RESERVED4_NODE, /*!< Reserved for later extensions */
+ RESERVED5_NODE, /*!< Reserved for later extensions */
+ RESERVED6_NODE, /*!< Reserved for later extensions */
+ RESERVED7_NODE, /*!< Reserved for later extensions */
+ RESERVED8_NODE, /*!< Reserved for later extensions */
_LAST_OSMOVTY_NODE
};
@@ -136,6 +148,27 @@ struct cmd_node {
enum {
CMD_ATTR_DEPRECATED = (1 << 0),
CMD_ATTR_HIDDEN = (1 << 1),
+ CMD_ATTR_IMMEDIATE = (1 << 2),
+ CMD_ATTR_NODE_EXIT = (1 << 3),
+ CMD_ATTR_LIB_COMMAND = (1 << 4),
+};
+
+/*! Attributes shared between libraries (up to 32 entries). */
+enum {
+ /* The entries of this enum shall conform the following requirements:
+ * 1. Naming format: 'OSMO_' + <LIBNAME> + '_LIB_ATTR_' + <ATTRNAME>,
+ * where LIBNAME is a short name of the library, e.g. 'ABIS', 'MGCP',
+ * and ATTRNAME is a brief name of the attribute, e.g. RTP_CONN_EST;
+ * for example: 'OSMO_ABIS_LIB_ATTR_RSL_LINK_UP'.
+ * 2. Brevity: shortenings and abbreviations are welcome!
+ * 3. Values are not flags but indexes, unlike CMD_ATTR_*.
+ * 4. Ordering: new entries added before _OSMO_CORE_LIB_ATTR_COUNT. */
+ OSMO_SCCP_LIB_ATTR_RSTRT_ASP,
+ OSMO_ABIS_LIB_ATTR_IPA_NEW_LNK,
+ OSMO_ABIS_LIB_ATTR_LINE_UPD,
+
+ /* Keep this floating entry last, it's needed for count check. */
+ _OSMO_CORE_LIB_ATTR_COUNT
};
/*! Structure of a command element */
@@ -148,7 +181,8 @@ struct cmd_element {
unsigned int cmdsize; /*!< Command index count. */
char *config; /*!< Configuration string */
vector subconfig; /*!< Sub configuration string */
- unsigned char attr; /*!< Command attributes */
+ unsigned char attr; /*!< Command attributes (global) */
+ unsigned int usrattr; /*!< Command attributes (program specific) */
};
/*! Command description structure. */
@@ -199,6 +233,16 @@ struct desc {
.daemon = dnum, \
};
+#define DEFUN_CMD_ELEMENT_ATTR_USRATTR(funcname, cmdname, cmdstr, helpstr, attrs, usrattrs) \
+ static struct cmd_element cmdname = \
+ { \
+ .string = cmdstr, \
+ .func = funcname, \
+ .doc = helpstr, \
+ .attr = attrs, \
+ .usrattr = usrattrs, \
+ };
+
#define DEFUN_CMD_FUNC_DECL(funcname) \
static int funcname (struct cmd_element *, struct vty *, int, const char *[]); \
@@ -237,7 +281,23 @@ struct desc {
DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN)
#define DEFUN_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \
- DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED) \
+ DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED)
+
+/*! Macro for defining a VTY node and function with global & program specific attributes.
+ * \param[in] funcname Name of the function implementing the node.
+ * \param[in] cmdname Name of the command node.
+ * \param[in] attr Global attributes (see CMD_ATTR_*).
+ * \param[in] usrattr Program specific attributes.
+ * \param[in] cmdstr String with syntax of node.
+ * \param[in] helpstr String with help message of node.
+ */
+#define DEFUN_ATTR_USRATTR(funcname, cmdname, attr, usrattr, cmdstr, helpstr) \
+ DEFUN_CMD_FUNC_DECL(funcname) \
+ DEFUN_CMD_ELEMENT_ATTR_USRATTR(funcname, cmdname, cmdstr, helpstr, attr, usrattr) \
+ DEFUN_CMD_FUNC_TEXT(funcname)
+
+#define DEFUN_USRATTR(funcname, cmdname, usrattr, cmdstr, helpstr) \
+ DEFUN_ATTR_USRATTR(funcname, cmdname, 0, usrattr, cmdstr, helpstr)
/* DEFUN_NOSH for commands that vtysh should ignore */
#define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \
@@ -304,6 +364,10 @@ struct desc {
#define CMD_IPV6(S) ((strcmp ((S), "X:X::X:X") == 0))
#define CMD_IPV6_PREFIX(S) ((strcmp ((S), "X:X::X:X/M") == 0))
+#define VTY_IPV4_CMD "A.B.C.D"
+#define VTY_IPV6_CMD "X:X::X:X"
+#define VTY_IPV46_CMD "(" VTY_IPV4_CMD "|" VTY_IPV6_CMD ")"
+
/* Common descriptions. */
#define SHOW_STR "Show running system information\n"
#define IP_STR "IP information\n"
@@ -363,7 +427,9 @@ struct desc {
void install_node(struct cmd_node *, int (*)(struct vty *));
void install_default(int node_type) OSMO_DEPRECATED("Now happens implicitly with install_node()");
void install_element(int node_type, struct cmd_element *);
+void install_lib_element(int node_type, struct cmd_element *);
void install_element_ve(struct cmd_element *cmd);
+void install_lib_element_ve(struct cmd_element *cmd);
void sort_node(void);
void vty_install_default(int node_type) OSMO_DEPRECATED("Now happens implicitly with install_node()");
@@ -376,8 +442,8 @@ char *argv_concat(const char **argv, int argc, int shift);
vector cmd_make_strvec(const char *);
int cmd_make_strvec2(const char *string, char **indent, vector *strvec_p);
void cmd_free_strvec(vector);
-vector cmd_describe_command();
-char **cmd_complete_command();
+vector cmd_describe_command(vector vline, struct vty *vty, int *status);
+char **cmd_complete_command(vector vline, struct vty *vty, int *status);
const char *cmd_prompt(enum node_type);
int config_from_file(struct vty *, FILE *);
enum node_type node_parent(enum node_type);
@@ -391,7 +457,7 @@ extern struct cmd_element config_exit_cmd;
extern struct cmd_element config_help_cmd;
extern struct cmd_element config_list_cmd;
extern struct cmd_element config_end_cmd;
-char *host_config_file();
+const char *host_config_file(void);
void host_config_set(const char *);
char *osmo_asciidoc_escape(const char *inp);
@@ -401,6 +467,22 @@ void print_version(int print_copyright);
extern void *tall_vty_cmd_ctx;
-int vty_dump_xml_ref(FILE *stream);
+/*! VTY reference generation mode. */
+enum vty_ref_gen_mode {
+ /*! Default mode: all commands except deprecated and hidden. */
+ VTY_REF_GEN_MODE_DEFAULT = 0,
+ /*! Expert mode: all commands including hidden, excluding deprecated. */
+ VTY_REF_GEN_MODE_EXPERT,
+ /*! "Inverse" mode: only hidden commands. */
+ VTY_REF_GEN_MODE_HIDDEN,
+};
+
+extern const struct value_string vty_ref_gen_mode_names[];
+extern const struct value_string vty_ref_gen_mode_desc[];
+
+int vty_dump_xml_ref_mode(FILE *stream, enum vty_ref_gen_mode mode);
+int vty_dump_xml_ref(FILE *stream) OSMO_DEPRECATED("Use vty_dump_xml_ref_mode() instead");
+
+int vty_cmd_range_match(const char *range, const char *str);
/*! @} */