Neels Hofmeyr | 0fd615f | 2019-01-26 20:36:12 +0100 | [diff] [blame] | 1 | /*! \file tdef_vty.h |
| 2 | * API to configure osmo_tdef Tnnn timers from VTY configuration. |
| 3 | */ |
| 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 |
Harald Welte | 581a34d | 2019-05-27 23:15:28 +0200 | [diff] [blame] | 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 |
Neels Hofmeyr | 0fd615f | 2019-01-26 20:36:12 +0100 | [diff] [blame] | 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 |
Harald Welte | 581a34d | 2019-05-27 23:15:28 +0200 | [diff] [blame] | 18 | * GNU General Public License for more details. |
Neels Hofmeyr | 0fd615f | 2019-01-26 20:36:12 +0100 | [diff] [blame] | 19 | * |
Harald Welte | 581a34d | 2019-05-27 23:15:28 +0200 | [diff] [blame] | 20 | * You should have received a copy of the GNU General Public License |
Neels Hofmeyr | 0fd615f | 2019-01-26 20:36:12 +0100 | [diff] [blame] | 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Harald Welte | 581a34d | 2019-05-27 23:15:28 +0200 | [diff] [blame] | 22 | * |
| 23 | * SPDX-License-Identifier: GPL-2.0+ |
Neels Hofmeyr | 0fd615f | 2019-01-26 20:36:12 +0100 | [diff] [blame] | 24 | */ |
| 25 | #pragma once |
| 26 | |
| 27 | #include <stdint.h> |
Pau Espin Pedrol | 097b509 | 2019-09-05 13:49:05 +0200 | [diff] [blame] | 28 | #include <stdarg.h> |
| 29 | |
| 30 | #include <osmocom/vty/command.h> |
Neels Hofmeyr | 0fd615f | 2019-01-26 20:36:12 +0100 | [diff] [blame] | 31 | |
| 32 | struct vty; |
| 33 | |
| 34 | /*! \defgroup Tdef_VTY Tnnn timer VTY configuration |
| 35 | * @{ |
| 36 | * \file tdef_vty.h |
| 37 | */ |
| 38 | |
| 39 | struct osmo_tdef; |
| 40 | struct osmo_tdef_group; |
| 41 | |
| 42 | #define OSMO_TDEF_VTY_ARG_T "TNNNN" |
Neels Hofmeyr | 5734bff | 2019-02-21 02:27:48 +0100 | [diff] [blame] | 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" |
Neels Hofmeyr | 0fd615f | 2019-01-26 20:36:12 +0100 | [diff] [blame] | 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 | |
Vadim Yanitskiy | df4f608 | 2020-01-25 09:49:22 +0700 | [diff] [blame] | 71 | void osmo_tdef_vty_groups_init(unsigned int parent_cfg_node, struct osmo_tdef_group *groups); |
Neels Hofmeyr | 0fd615f | 2019-01-26 20:36:12 +0100 | [diff] [blame] | 72 | void osmo_tdef_vty_groups_write(struct vty *vty, const char *indent); |
| 73 | |
| 74 | /*! @} */ |