From 7acb30c69b1c10458b37ac403c82e3b98edd9ab1 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 17 Aug 2011 17:13:48 +0200 Subject: doxygen: Add (partial) VTY API documentation --- src/vty/command.c | 30 +++++++++++++++++++++--------- src/vty/telnet_interface.c | 15 ++++++++++++++- src/vty/utils.c | 13 +++++++++++++ src/vty/vty.c | 45 +++++++++++++++++++++++++++++++++++++++------ 4 files changed, 87 insertions(+), 16 deletions(-) (limited to 'src/vty') diff --git a/src/vty/command.c b/src/vty/command.c index 1c8df61a..890fb7df 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -40,6 +40,11 @@ Boston, MA 02111-1307, USA. */ #include +/*! \addtogroup vty + * @{ + */ +/*! \file command.c */ + #define CONFIGFILE_MASK 022 void *tall_vty_cmd_ctx; @@ -81,7 +86,9 @@ struct cmd_node config_node = { /* Default motd string. */ const char *default_motd = ""; -/* This is called from main when a daemon is invoked with -v or --version. */ +/*! \brief print the version (and optionally copyright) information + * + * This is called from main when a daemon is invoked with -v or --version. */ void print_version(int print_copyright) { printf("%s version %s\n", host.app_info->name, host.app_info->version); @@ -114,7 +121,7 @@ char *argv_concat(const char **argv, int argc, int shift) return str; } -/* Install top node of command vector. */ +/*! \brief Install top node of command vector. */ void install_node(struct cmd_node *node, int (*func) (struct vty *)) { vector_set_index(cmdvec, node->node, node); @@ -151,7 +158,7 @@ static int is_config(struct vty *vty) return vty->node > CONFIG_NODE; } -/* Sort each node's command element according to command string. */ +/*! \brief Sort each node's command element according to command string. */ void sort_node(void) { unsigned int i, j; @@ -181,7 +188,7 @@ void sort_node(void) } } -/* Breaking up string into each command piece. I assume given +/*! Breaking up string into each command piece. I assume given character is separated by a space character. Return value is a vector which includes char ** data element. */ vector cmd_make_strvec(const char *string) @@ -231,7 +238,7 @@ vector cmd_make_strvec(const char *string) } } -/* Free allocated string vector. */ +/*! \brief Free allocated string vector. */ void cmd_free_strvec(vector v) { unsigned int i; @@ -247,7 +254,7 @@ void cmd_free_strvec(vector v) vector_free(v); } -/* Fetch next description. Used in cmd_make_descvec(). */ +/*! \brief Fetch next description. Used in \ref cmd_make_descvec(). */ static char *cmd_desc_str(const char **string) { const char *cp, *start; @@ -282,7 +289,7 @@ static char *cmd_desc_str(const char **string) return token; } -/* New string vector. */ +/*! \brief New string vector. */ static vector cmd_make_descvec(const char *string, const char *descstr) { int multiple = 0; @@ -389,7 +396,7 @@ static int cmd_cmdsize(vector strvec) return size; } -/* Return prompt character of specified node. */ +/*! \brief Return prompt character of specified node. */ const char *cmd_prompt(enum node_type node) { struct cmd_node *cnode; @@ -398,7 +405,10 @@ const char *cmd_prompt(enum node_type node) return cnode->prompt; } -/* Install a command into a node. */ +/*! \brief Install a command into a node + * \param[in] ntype Node Type + * \param[cmd] element to be installed + */ void install_element(enum node_type ntype, struct cmd_element *cmd) { struct cmd_node *cnode; @@ -3227,3 +3237,5 @@ void cmd_init(int terminal) } srand(time(NULL)); } + +/*! }@ */ diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c index 1a285102..89cba581 100644 --- a/src/vty/telnet_interface.c +++ b/src/vty/telnet_interface.c @@ -33,6 +33,11 @@ #include #include +/*! \addtogroup vty + * @{ + */ +/*! \file telnet_interface.c */ + /* per connection data */ LLIST_HEAD(active_connections); @@ -47,6 +52,11 @@ static struct osmo_fd server_socket = { .priv_nr = 0, }; +/*! \brief Initialize telnet based VTY interface + * \param[in] tall_ctx \ref talloc context + * \param[in] priv private data to be passed to callback + * \param[in] port UDP port number + */ int telnet_init(void *tall_ctx, void *priv, int port) { struct sockaddr_in sock_addr; @@ -55,6 +65,7 @@ int telnet_init(void *tall_ctx, void *priv, int port) tall_telnet_ctx = talloc_named_const(tall_ctx, 1, "telnet_connection"); + /* FIXME: use new socket.c code of libosmocore */ fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd < 0) { @@ -109,6 +120,7 @@ static void print_welcome(int fd) write(fd, host.app_info->copyright, strlen(host.app_info->copyright)); } +/*! \brief close a telnet connection */ int telnet_close_client(struct osmo_fd *fd) { struct telnet_connection *conn = (struct telnet_connection*)fd->data; @@ -183,7 +195,7 @@ static int telnet_new_connection(struct osmo_fd *fd, unsigned int what) return 0; } -/* callback from VTY code */ +/*! \brief callback from core VTY code about VTY related events */ void vty_event(enum event event, int sock, struct vty *vty) { struct telnet_connection *connection = vty->priv; @@ -209,3 +221,4 @@ void vty_event(enum event event, int sock, struct vty *vty) } } +/*! }@ */ diff --git a/src/vty/utils.c b/src/vty/utils.c index 7797e62d..47b9931f 100644 --- a/src/vty/utils.c +++ b/src/vty/utils.c @@ -30,6 +30,17 @@ #include +/* \file utils.c */ + +/*! \addtogroup rate_ctr + * @{ + */ + +/*! \brief print a rate counter group to given VTY + * \param[in] vty The VTY to which it should be printed + * \param[in] prefix Any additional log prefix ahead of each line + * \param[in] ctrg Rate counter group to be printed + */ void vty_out_rate_ctr_group(struct vty *vty, const char *prefix, struct rate_ctr_group *ctrg) { @@ -48,3 +59,5 @@ void vty_out_rate_ctr_group(struct vty *vty, const char *prefix, VTY_NEWLINE); }; } + +/*! }@ */ diff --git a/src/vty/vty.c b/src/vty/vty.c index 1f3237ad..56e0088c 100644 --- a/src/vty/vty.c +++ b/src/vty/vty.c @@ -18,6 +18,11 @@ #include #include +/* \addtogroup vty + * @{ + */ +/*! \file vty.c */ + #define SYSCONFDIR "/usr/local/etc" /* our callback, located in telnet_interface.c */ @@ -44,7 +49,7 @@ static void vty_clear_buf(struct vty *vty) memset(vty->buf, 0, vty->max); } -/* Allocate new vty struct. */ +/*! \brief Allocate a new vty interface structure */ struct vty *vty_new(void) { struct vty *new = talloc_zero(tall_vty_ctx, struct vty); @@ -137,7 +142,7 @@ static void vty_auth(struct vty *vty, char *buf) } } -/* Close vty interface. */ +/*! \brief Close a given vty interface. */ void vty_close(struct vty *vty) { int i; @@ -178,13 +183,17 @@ void vty_close(struct vty *vty) talloc_free(vty); } +/*! \brief Return if this VTY is a shell or not */ int vty_shell(struct vty *vty) { return vty->type == VTY_SHELL ? 1 : 0; } -/* VTY standard output function. */ +/*! \brief VTY standard output function + * \param[in] vty VTY to which we should print + * \param[in] format variable-length format string + */ int vty_out(struct vty *vty, const char *format, ...) { va_list args; @@ -241,6 +250,7 @@ int vty_out(struct vty *vty, const char *format, ...) return len; } +/*! \brief print a newline on the given VTY */ int vty_out_newline(struct vty *vty) { char *p = vty_newline(vty); @@ -248,15 +258,24 @@ int vty_out_newline(struct vty *vty) return 0; } +/*! \brief return the current index of a given VTY */ void *vty_current_index(struct vty *vty) { return vty->index; } + +/*! \brief return the current node of a given VTY */ int vty_current_node(struct vty *vty) { return vty->node; } +/*! \brief Lock the configuration to a given VTY + * \param[in] vty VTY to which the config shall be locked + * \returns 1 on success, 0 on error + * + * This shall be used to make sure only one VTY at a given time has + * access to modify the configuration */ int vty_config_lock(struct vty *vty) { if (vty_config == 0) { @@ -266,6 +285,10 @@ int vty_config_lock(struct vty *vty) return vty->config; } +/*! \brief Unlock the configuration from a given VTY + * \param[in] vty VTY from which the configuration shall be unlocked + * \returns 0 in case of success + */ int vty_config_unlock(struct vty *vty) { if (vty_config == 1 && vty->config == 1) { @@ -1182,7 +1205,7 @@ static void vty_buffer_reset(struct vty *vty) vty_redraw_line(vty); } -/* Read data via vty socket. */ +/*! \brief Read data via vty socket. */ int vty_read(struct vty *vty) { int i; @@ -1401,7 +1424,7 @@ vty_read_file(FILE *confp, void *priv) return 0; } -/* Create new vty structure. */ +/*! \brief Create new vty structure. */ struct vty * vty_create (int vty_sock, void *priv) { @@ -1590,7 +1613,7 @@ struct cmd_node vty_node = { 1, }; -/* Reset all VTY status. */ +/*! \brief Reset all VTY status. */ void vty_reset(void) { unsigned int i; @@ -1647,6 +1670,10 @@ void vty_init_vtysh(void) } extern void *tall_bsc_ctx; + +/*! \brief Initialize VTY layer + * \param[in] app_info application information + */ /* Install vty's own commands like `who' command. */ void vty_init(struct vty_app_info *app_info) { @@ -1680,6 +1707,10 @@ void vty_init(struct vty_app_info *app_info) install_element(VTY_NODE, &no_vty_login_cmd); } +/*! \brief Read the configuration file using the VTY code + * \param[in] file_name file name of the configuration file + * \param[in] priv private data to be passed to \ref vty_read_file + */ int vty_read_config_file(const char *file_name, void *priv) { FILE *cfile; @@ -1696,3 +1727,5 @@ int vty_read_config_file(const char *file_name, void *priv) return rc; } + +/*! }@ */ -- cgit v1.2.3