comparison src/twjit_vty.c @ 14:073b8c7b361f

twjit: port over vty config module
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 Jul 2024 17:32:26 +0000
parents
children
comparison
equal deleted inserted replaced
13:19367028cc6e 14:073b8c7b361f
1 /*
2 * Themyscira Wireless jitter buffer implementation: vty configuration.
3 */
4
5 #include <stdint.h>
6 #include <stdbool.h>
7 #include <stdlib.h>
8 #include <string.h>
9
10 #include <osmocom/core/utils.h>
11 #include <osmocom/vty/vty.h>
12 #include <osmocom/vty/command.h>
13
14 #include <themwi/rtp/twjit.h>
15
16 int twrtp_jibuf_config_write(struct vty *vty,
17 const struct twrtp_jibuf_config *conf,
18 const char *name, const char *prefix)
19 {
20 vty_out(vty, "%s%s%s", prefix, name ? : "twjit", VTY_NEWLINE);
21 vty_out(vty, "%s buffer-depth %u %u%s", prefix, conf->bd_start,
22 conf->bd_hiwat, VTY_NEWLINE);
23 vty_out(vty, "%s thinning-interval %u%s", prefix, conf->thinning_int,
24 VTY_NEWLINE);
25 vty_out(vty, "%s max-future-sec %u%s", prefix, conf->max_future_sec,
26 VTY_NEWLINE);
27
28 if (conf->start_min_delta) {
29 vty_out(vty, "%s start-min-delta %u%s", prefix,
30 conf->start_min_delta, VTY_NEWLINE);
31 }
32 if (conf->start_max_delta) {
33 vty_out(vty, "%s start-max-delta %u%s", prefix,
34 conf->start_max_delta, VTY_NEWLINE);
35 }
36
37 return CMD_SUCCESS;
38 }
39
40 DEFUN(cfg_buffer_depth, cfg_buffer_depth_cmd,
41 "buffer-depth <2-65535> <2-65535>",
42 "Buffer depth configuration\n"
43 "Minimum fill required to start flow\n"
44 "High water mark fill level\n")
45 {
46 struct twrtp_jibuf_config *conf = vty->index;
47 unsigned bd_start = atoi(argv[0]);
48 unsigned bd_hiwat = atoi(argv[1]);
49
50 if (bd_hiwat < bd_start) {
51 vty_out(vty, "%% Error: high water mark cannot be less than starting level%s",
52 VTY_NEWLINE);
53 return CMD_WARNING;
54 }
55
56 conf->bd_start = bd_start;
57 conf->bd_hiwat = bd_hiwat;
58
59 return CMD_SUCCESS;
60 }
61
62 DEFUN(cfg_thinning, cfg_thinning_cmd,
63 "thinning-interval <2-65535>",
64 "Standing queue thinning configuration\n"
65 "Drop every Nth packet\n")
66 {
67 struct twrtp_jibuf_config *conf = vty->index;
68 conf->thinning_int = atoi(argv[0]);
69 return CMD_SUCCESS;
70 }
71
72 DEFUN(cfg_max_future, cfg_max_future_cmd,
73 "max-future-sec <1-65535>",
74 "Guard against time traveler packets\n"
75 "Maximum permissible number of seconds into the future\n")
76 {
77 struct twrtp_jibuf_config *conf = vty->index;
78 conf->max_future_sec = atoi(argv[0]);
79 return CMD_SUCCESS;
80 }
81
82 DEFUN(cfg_start_min_delta, cfg_start_min_delta_cmd,
83 "start-min-delta <1-65535>",
84 "Minimum required delta in time-of-arrival to start flow\n"
85 "Time delta value in ms\n")
86 {
87 struct twrtp_jibuf_config *conf = vty->index;
88 conf->start_min_delta = atoi(argv[0]);
89 return CMD_SUCCESS;
90 }
91
92 DEFUN(cfg_no_start_min_delta, cfg_no_start_min_delta_cmd,
93 "no start-min-delta",
94 NO_STR "Minimum required delta in time-of-arrival to start flow\n")
95 {
96 struct twrtp_jibuf_config *conf = vty->index;
97 conf->start_min_delta = 0;
98 return CMD_SUCCESS;
99 }
100
101 DEFUN(cfg_start_max_delta, cfg_start_max_delta_cmd,
102 "start-max-delta <1-65535>",
103 "Maximum permitted gap in time-of-arrival in starting state\n"
104 "Time delta value in ms\n")
105 {
106 struct twrtp_jibuf_config *conf = vty->index;
107 conf->start_max_delta = atoi(argv[0]);
108 return CMD_SUCCESS;
109 }
110
111 DEFUN(cfg_no_start_max_delta, cfg_no_start_max_delta_cmd,
112 "no start-max-delta",
113 NO_STR "Maximum permitted gap in time-of-arrival in starting state\n")
114 {
115 struct twrtp_jibuf_config *conf = vty->index;
116 conf->start_max_delta = 0;
117 return CMD_SUCCESS;
118 }
119
120 void twrtp_jibuf_vty_init(int twjit_node)
121 {
122 install_lib_element(twjit_node, &cfg_buffer_depth_cmd);
123 install_lib_element(twjit_node, &cfg_thinning_cmd);
124 install_lib_element(twjit_node, &cfg_max_future_cmd);
125 install_lib_element(twjit_node, &cfg_start_min_delta_cmd);
126 install_lib_element(twjit_node, &cfg_no_start_min_delta_cmd);
127 install_lib_element(twjit_node, &cfg_start_max_delta_cmd);
128 install_lib_element(twjit_node, &cfg_no_start_max_delta_cmd);
129 }