libosmovty  1.10.0.16-62d38.202410082026
Osmocom VTY library
tdef_vty.h
Go to the documentation of this file.
1 
4 /* (C) 2018-2019 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
5  *
6  * Author: Neels Hofmeyr <neels@hofmeyr.de>
7  *
8  * All Rights Reserved
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * SPDX-License-Identifier: GPL-2.0+
24  */
25 #pragma once
26 
27 #include <stdint.h>
28 #include <stdarg.h>
29 
30 #include <osmocom/vty/command.h>
31 
32 struct vty;
33 
39 struct osmo_tdef;
40 struct osmo_tdef_group;
41 
42 #define OSMO_TDEF_VTY_ARG_T "TNNNN"
43 #define OSMO_TDEF_VTY_DOC_T \
44  "T- or X-timer-number -- 3GPP compliant timer number of the format '1234' or 'T1234' or 't1234';" \
45  " Osmocom-specific timer number of the format: 'X1234' or 'x1234'.\n"
46 #define OSMO_TDEF_VTY_ARG_T_OPTIONAL "[" OSMO_TDEF_VTY_ARG_T "]"
47 
48 #define OSMO_TDEF_VTY_ARG_VAL "(<0-2147483647>|default)"
49 #define OSMO_TDEF_VTY_DOC_VAL "New timer value\n" "Set to default timer value\n"
50 #define OSMO_TDEF_VTY_ARG_VAL_OPTIONAL "[" OSMO_TDEF_VTY_ARG_VAL "]"
51 
52 #define OSMO_TDEF_VTY_ARG_SET OSMO_TDEF_VTY_ARG_T " " OSMO_TDEF_VTY_ARG_VAL
53 #define OSMO_TDEF_VTY_DOC_SET OSMO_TDEF_VTY_DOC_T OSMO_TDEF_VTY_DOC_VAL
54 #define OSMO_TDEF_VTY_ARG_SET_OPTIONAL OSMO_TDEF_VTY_ARG_T_OPTIONAL " " OSMO_TDEF_VTY_ARG_VAL_OPTIONAL
55 
56 int osmo_tdef_vty_set_cmd(struct vty *vty, struct osmo_tdef *tdefs, const char **args);
57 int osmo_tdef_vty_show_cmd(struct vty *vty, struct osmo_tdef *tdefs, const char *T_arg,
58  const char *prefix_fmt, ...);
59 void osmo_tdef_vty_write(struct vty *vty, struct osmo_tdef *tdefs,
60  const char *prefix_fmt, ...);
61 
62 void osmo_tdef_vty_out_one(struct vty *vty, struct osmo_tdef *t, const char *prefix_fmt, ...);
63 void osmo_tdef_vty_out_all(struct vty *vty, struct osmo_tdef *tdefs, const char *prefix_fmt, ...);
64 
65 void osmo_tdef_vty_out_one_va(struct vty *vty, struct osmo_tdef *t, const char *prefix_fmt, va_list va);
66 void osmo_tdef_vty_out_all_va(struct vty *vty, struct osmo_tdef *tdefs, const char *prefix_fmt, va_list va);
67 
68 struct osmo_tdef *osmo_tdef_vty_parse_T_arg(struct vty *vty, struct osmo_tdef *tdefs, const char *osmo_tdef_str);
69 unsigned long osmo_tdef_vty_parse_val_arg(const char *val_arg, unsigned long default_val);
70 
71 void osmo_tdef_vty_groups_init(unsigned int parent_cfg_node, struct osmo_tdef_group *groups);
72 void osmo_tdef_vty_groups_write(struct vty *vty, const char *indent);
73 
Zebra configuration command interface routine.
struct osmo_tdef * osmo_tdef_vty_parse_T_arg(struct vty *vty, struct osmo_tdef *tdefs, const char *osmo_tdef_str)
Parse an argument like "1234", "T1234", "t1234", or "X1234", "x1234", as from OSMO_TDEF_VTY_ARG_T.
Definition: tdef_vty.c:51
void osmo_tdef_vty_out_all(struct vty *vty, struct osmo_tdef *tdefs, const char *prefix_fmt,...)
Write to VTY the current status of all given timers.
Definition: tdef_vty.c:235
void osmo_tdef_vty_write(struct vty *vty, struct osmo_tdef *tdefs, const char *prefix_fmt,...)
Write current timer configuration arguments to the vty.
Definition: tdef_vty.c:250
void osmo_tdef_vty_out_one(struct vty *vty, struct osmo_tdef *t, const char *prefix_fmt,...)
Write to VTY the current status of one timer.
Definition: tdef_vty.c:201
int osmo_tdef_vty_show_cmd(struct vty *vty, struct osmo_tdef *tdefs, const char *T_arg, const char *prefix_fmt,...)
Output one or all timers to the VTY, as for a VTY command like 'show timer [TNNNN]'.
Definition: tdef_vty.c:144
void osmo_tdef_vty_out_all_va(struct vty *vty, struct osmo_tdef *tdefs, const char *prefix_fmt, va_list va)
Write to VTY the current status of all given timers.
Definition: tdef_vty.c:215
void osmo_tdef_vty_groups_write(struct vty *vty, const char *indent)
Write the global osmo_tdef_group configuration to VTY, as previously passed to osmo_tdef_vty_groups_i...
Definition: tdef_vty.c:387
const char * T_arg
Definition: tdef_vty.c:273
void osmo_tdef_vty_out_one_va(struct vty *vty, struct osmo_tdef *t, const char *prefix_fmt, va_list va)
Write to VTY the current status of one timer.
Definition: tdef_vty.c:169
void osmo_tdef_vty_groups_init(unsigned int parent_cfg_node, struct osmo_tdef_group *groups)
Convenience implementation for keeping a fixed set of timer groups in a program.
Definition: tdef_vty.c:364
struct osmo_tdef * tdefs
Definition: tdef_vty.c:291
int osmo_tdef_vty_set_cmd(struct vty *vty, struct osmo_tdef *tdefs, const char **args)
Apply a timer configuration from VTY argument strings.
Definition: tdef_vty.c:113
unsigned long osmo_tdef_vty_parse_val_arg(const char *val_arg, unsigned long default_val)
Parse an argument of the form "(0-2147483647|default)", as from OSMO_TDEF_VTY_ARG_VAL.
Definition: tdef_vty.c:96
const unsigned long default_val
Internal representation of a single VTY.
Definition: vty.h:60