annotate src/twjit_vty.c @ 40:d73b6ec27ae6

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