blob: 495560791394167662231a8e785bb7646204749d [file] [log] [blame]
Holger Hans Peter Freytherdcc33122011-03-01 01:24:10 +01001/* Extra vty handling for the SS7 code */
2/*
3 * (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
4 * (C) 2010-2011 by On-Waves
5 * All Rights Reserved
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include <mgcp_ss7.h>
23#include <ss7_vty.h>
24
25#include <mgcp/mgcp.h>
26
27#include <stdlib.h>
28
29extern struct mgcp_config *g_cfg;
30
Holger Hans Peter Freytherec84e3c2011-03-02 22:40:31 +010031enum node_type mgcp_go_parent(struct vty *vty);
Holger Hans Peter Freytherdcc33122011-03-01 01:24:10 +010032static struct vty_app_info vty_info = {
33 .name = "mgcp_ss7",
34 .version = "0.0.1",
Holger Hans Peter Freytherec84e3c2011-03-02 22:40:31 +010035 .go_parent_cb = mgcp_go_parent,
Holger Hans Peter Freytherdcc33122011-03-01 01:24:10 +010036};
37
38void logging_vty_add_cmds(void);
39
40DEFUN(cfg_mgcp_configure, cfg_mgcp_configure_cmd,
41 "configure-trunks (0|1)",
42 "Reconfigure the Trunk Configuration\n" "Reconfigure\n" "Keep\n")
43{
44 g_cfg->configure_trunks = atoi(argv[0]);
45 return CMD_SUCCESS;
46}
47
48DEFUN(cfg_mgcp_vad, cfg_mgcp_vad_cmd,
49 "vad (enabled|disabled)",
50 "Enable the Voice Activity Detection\n"
51 "Enable\n" "Disable\n")
52{
53 if (argv[0][0] == 'e')
54 g_cfg->trunk.vad_enabled = 1;
55 else
56 g_cfg->trunk.vad_enabled = 0;
57 return CMD_SUCCESS;
58}
59
60DEFUN(cfg_mgcp_realloc, cfg_mgcp_realloc_cmd,
61 "force-realloc (0|1)",
62 "Force the reallocation of an endpoint\n"
63 "Disable\n" "Enable\n")
64{
65 g_cfg->trunk.force_realloc = atoi(argv[0]);
66 return CMD_SUCCESS;
67}
68
69DEFUN(cfg_mgcp_inp_dig_gain, cfg_mgcp_inp_dig_gain_cmd,
70 "input-digital-gain <0-62>",
71 "Static Digital Input Gain\n"
72 "Gain value")
73{
74 g_cfg->trunk.digital_inp_gain = atoi(argv[0]);
75 return CMD_SUCCESS;
76}
77
78DEFUN(cfg_mgcp_out_dig_gain, cfg_mgcp_out_dig_gain_cmd,
79 "outut-digital-gain <0-62>",
80 "Static Digital Output Gain\n"
81 "Gain value")
82{
83 g_cfg->trunk.digital_out_gain = atoi(argv[0]);
84 return CMD_SUCCESS;
85}
86
87DEFUN(cfg_mgcp_upstr_agc, cfg_mgcp_upstr_agc_cmd,
88 "upstream-automatic-gain (0|1)",
89 "Enable automatic gain control on upstream\n"
90 "Disable\n" "Enabled\n")
91{
92 g_cfg->trunk.upstr_agc_enbl = argv[0][0] == '1';
93 return CMD_SUCCESS;
94}
95
96DEFUN(cfg_mgc_upstr_adp, cfg_mgcp_upstr_adp_cmd,
97 "upstream-adaptiton-rate <1-128>",
98 "Set the adaption rate in (dB/sec) * 10\n"
99 "Range\n")
100{
101 g_cfg->trunk.upstr_adp_rate = atoi(argv[0]);
102 return CMD_SUCCESS;
103}
104
105DEFUN(cfg_mgcp_upstr_max_gain, cfg_mgcp_upstr_max_gain_cmd,
106 "upstream-max-applied-gain <0-49>",
107 "Maximum applied gain from -31db to 18db\n"
108 "Gain level\n")
109{
110 g_cfg->trunk.upstr_max_gain = atoi(argv[0]);
111 return CMD_SUCCESS;
112}
113
114DEFUN(cfg_mgcp_upstr_target, cfg_mgcp_upstr_target_cmd,
115 "upstream-target-level <6-37>",
116 "Set the desired level in db\n"
117 "Desired lievel\n")
118{
119 g_cfg->trunk.upstr_target_lvl = atoi(argv[0]);
120 return CMD_SUCCESS;
121}
122
123DEFUN(cfg_mgcp_dwnstr_agc, cfg_mgcp_dwnstr_agc_cmd,
124 "downstream-automatic-gain (0|1)",
125 "Enable automatic gain control on downstream\n"
126 "Disable\n" "Enabled\n")
127{
128 g_cfg->trunk.dwnstr_agc_enbl = argv[0][0] == '1';
129 return CMD_SUCCESS;
130}
131
132DEFUN(cfg_mgc_dwnstr_adp, cfg_mgcp_dwnstr_adp_cmd,
133 "downstream-adaptation-rate <1-128>",
134 "Set the adaption rate in (dB/sec) * 10\n"
135 "Range\n")
136{
137 g_cfg->trunk.dwnstr_adp_rate = atoi(argv[0]);
138 return CMD_SUCCESS;
139}
140
141DEFUN(cfg_mgcp_dwnstr_max_gain, cfg_mgcp_dwnstr_max_gain_cmd,
142 "downstream-max-applied-gain <0-49>",
143 "Maximum applied gain from -31db to 18db\n"
144 "Gain level\n")
145{
146 g_cfg->trunk.dwnstr_max_gain = atoi(argv[0]);
147 return CMD_SUCCESS;
148}
149
150DEFUN(cfg_mgcp_dwnstr_target, cfg_mgcp_dwnstr_target_cmd,
151 "downstream-target-level <6-37>",
152 "Set the desired level in db\n"
153 "Desired lievel\n")
154{
155 g_cfg->trunk.dwnstr_target_lvl = atoi(argv[0]);
156 return CMD_SUCCESS;
157}
158
159DEFUN(cfg_mgcp_endp_offset, cfg_mgcp_endp_offset_cmd,
160 "endpoint-offset <-60-60>",
161 "Offset to the CIC map\n" "Value to set\n")
162{
163 g_cfg->trunk.endp_offset = atoi(argv[0]);
164 return CMD_SUCCESS;
165}
166
167DEFUN(cfg_mgcp_target_trunk, cfg_mgcp_target_trunk_cmd,
168 "target-trunk-start <1-24>",
169 "Map the virtual trunk to start here\n" "Trunk Nr\n")
170{
171 g_cfg->trunk.target_trunk_start = atoi(argv[0]);
172 return CMD_SUCCESS;
173}
174
175DEFUN(cfg_trunk_vad, cfg_trunk_vad_cmd,
176 "vad (enabled|disabled)",
177 "Enable the Voice Activity Detection\n"
178 "Enable\n" "Disable\n")
179{
180 struct mgcp_trunk_config *trunk = vty->index;
181
182 if (argv[0][0] == 'e')
183 trunk->vad_enabled = 1;
184 else
185 trunk->vad_enabled = 0;
186 return CMD_SUCCESS;
187}
188
189DEFUN(cfg_trunk_realloc, cfg_trunk_realloc_cmd,
190 "force-realloc (0|1)",
191 "Force the reallocation of an endpoint\n"
192 "Disable\n" "Enable\n")
193{
194 struct mgcp_trunk_config *trunk = vty->index;
195
196 trunk->force_realloc = atoi(argv[0]);
197 return CMD_SUCCESS;
198}
199
200DEFUN(cfg_trunk_inp_dig_gain, cfg_trunk_inp_dig_gain_cmd,
201 "input-digital-gain <0-62>",
202 "Static Digital Input Gain\n"
203 "Gain value")
204{
205 struct mgcp_trunk_config *trunk = vty->index;
206
207 trunk->digital_inp_gain = atoi(argv[0]);
208 return CMD_SUCCESS;
209}
210
211DEFUN(cfg_trunk_out_dig_gain, cfg_trunk_out_dig_gain_cmd,
212 "outut-digital-gain <0-62>",
213 "Static Digital Output Gain\n"
214 "Gain value")
215{
216 struct mgcp_trunk_config *trunk = vty->index;
217
218 trunk->digital_out_gain = atoi(argv[0]);
219 return CMD_SUCCESS;
220}
221
222DEFUN(cfg_trunk_upstr_agc, cfg_trunk_upstr_agc_cmd,
223 "upstream-automatic-gain (0|1)",
224 "Enable automatic gain control on upstream\n"
225 "Disable\n" "Enabled\n")
226{
227 struct mgcp_trunk_config *trunk = vty->index;
228
229 trunk->upstr_agc_enbl = argv[0][0] == '1';
230 return CMD_SUCCESS;
231}
232
233DEFUN(cfg_trunk_upstr_adp, cfg_trunk_upstr_adp_cmd,
234 "upstream-adaptiton-rate <1-128>",
235 "Set the adaption rate in (dB/sec) * 10\n"
236 "Range\n")
237{
238 struct mgcp_trunk_config *trunk = vty->index;
239
240 trunk->upstr_adp_rate = atoi(argv[0]);
241 return CMD_SUCCESS;
242}
243
244DEFUN(cfg_trunk_upstr_max_gain, cfg_trunk_upstr_max_gain_cmd,
245 "upstream-max-applied-gain <0-49>",
246 "Maximum applied gain from -31db to 18db\n"
247 "Gain level\n")
248{
249 struct mgcp_trunk_config *trunk = vty->index;
250
251 trunk->upstr_max_gain = atoi(argv[0]);
252 return CMD_SUCCESS;
253}
254
255DEFUN(cfg_trunk_upstr_target, cfg_trunk_upstr_target_cmd,
256 "upstream-target-level <6-37>",
257 "Set the desired level in db\n"
258 "Desired lievel\n")
259{
260 struct mgcp_trunk_config *trunk = vty->index;
261
262 trunk->upstr_target_lvl = atoi(argv[0]);
263 return CMD_SUCCESS;
264}
265
266DEFUN(cfg_trunk_dwnstr_agc, cfg_trunk_dwnstr_agc_cmd,
267 "downstream-automatic-gain (0|1)",
268 "Enable automatic gain control on downstream\n"
269 "Disable\n" "Enabled\n")
270{
271 struct mgcp_trunk_config *trunk = vty->index;
272
273 trunk->dwnstr_agc_enbl = argv[0][0] == '1';
274 return CMD_SUCCESS;
275}
276
277DEFUN(cfg_trunk_dwnstr_adp, cfg_trunk_dwnstr_adp_cmd,
278 "downstream-adaptation-rate <1-128>",
279 "Set the adaption rate in (dB/sec) * 10\n"
280 "Range\n")
281{
282 struct mgcp_trunk_config *trunk = vty->index;
283
284 trunk->dwnstr_adp_rate = atoi(argv[0]);
285 return CMD_SUCCESS;
286}
287
288DEFUN(cfg_trunk_dwnstr_max_gain, cfg_trunk_dwnstr_max_gain_cmd,
289 "downstream-max-applied-gain <0-49>",
290 "Maximum applied gain from -31db to 18db\n"
291 "Gain level\n")
292{
293 struct mgcp_trunk_config *trunk = vty->index;
294
295 trunk->dwnstr_max_gain = atoi(argv[0]);
296 return CMD_SUCCESS;
297}
298
299DEFUN(cfg_trunk_dwnstr_target, cfg_trunk_dwnstr_target_cmd,
300 "downstream-target-level <6-37>",
301 "Set the desired level in db\n"
302 "Desired lievel\n")
303{
304 struct mgcp_trunk_config *trunk = vty->index;
305
306 trunk->dwnstr_target_lvl = atoi(argv[0]);
307 return CMD_SUCCESS;
308}
309
310DEFUN(cfg_trunk_endp_offset, cfg_trunk_endp_offset_cmd,
311 "endpoint-offset <-60-60>",
312 "Offset to the CIC map\n" "Value to set\n")
313{
314 struct mgcp_trunk_config *trunk = vty->index;
315
316 trunk->endp_offset = atoi(argv[0]);
317 return CMD_SUCCESS;
318}
319
320void mgcp_write_extra(struct vty *vty, struct mgcp_config *cfg)
321{
322 vty_out(vty, " configure-trunks %d%s",
323 cfg->configure_trunks, VTY_NEWLINE);
324 vty_out(vty, " force-realloc %d%s",
325 cfg->trunk.force_realloc, VTY_NEWLINE);
326 vty_out(vty, " vad %s%s",
327 cfg->trunk.vad_enabled ? "enabled" : "disabled", VTY_NEWLINE);
328 vty_out(vty, " input-digital-gain %d%s",
329 cfg->trunk.digital_inp_gain, VTY_NEWLINE);
330 vty_out(vty, " output-digital-gain %d%s",
331 cfg->trunk.digital_out_gain, VTY_NEWLINE);
332 vty_out(vty, " upstream-automatic-gain %d%s",
333 cfg->trunk.upstr_agc_enbl, VTY_NEWLINE);
334 vty_out(vty, " upstream-adaptation-rate %d%s",
335 cfg->trunk.upstr_adp_rate, VTY_NEWLINE);
336 vty_out(vty, " upstream-max-applied-gain %d%s",
337 cfg->trunk.upstr_max_gain, VTY_NEWLINE);
338 vty_out(vty, " upstream-target-level %d%s",
339 cfg->trunk.upstr_target_lvl, VTY_NEWLINE);
340 vty_out(vty, " downstream-automatic-gain %d%s",
341 cfg->trunk.dwnstr_agc_enbl, VTY_NEWLINE);
342 vty_out(vty, " downstream-adaptation-rate %d%s",
343 cfg->trunk.dwnstr_adp_rate, VTY_NEWLINE);
344 vty_out(vty, " downstream-max-applied-gain %d%s",
345 cfg->trunk.dwnstr_max_gain, VTY_NEWLINE);
346 vty_out(vty, " downstream-target-level %d%s",
347 cfg->trunk.dwnstr_target_lvl, VTY_NEWLINE);
348 vty_out(vty, " endpoint-offset %d%s",
349 cfg->trunk.endp_offset, VTY_NEWLINE);
350 vty_out(vty, " target-trunk-start %d%s",
351 cfg->trunk.target_trunk_start, VTY_NEWLINE);
352}
353
354void mgcp_write_trunk_extra(struct vty *vty, struct mgcp_trunk_config *trunk)
355{
356 vty_out(vty, " force-realloc %d%s",
357 trunk->force_realloc, VTY_NEWLINE);
358 vty_out(vty, " vad %s%s",
359 trunk->vad_enabled ? "enabled" : "disabled", VTY_NEWLINE);
360 vty_out(vty, " input-digital-gain %d%s",
361 trunk->digital_inp_gain, VTY_NEWLINE);
362 vty_out(vty, " output-digital-gain %d%s",
363 trunk->digital_out_gain, VTY_NEWLINE);
364 vty_out(vty, " upstream-automatic-gain %d%s",
365 trunk->upstr_agc_enbl, VTY_NEWLINE);
366 vty_out(vty, " upstream-adaptation-rate %d%s",
367 trunk->upstr_adp_rate, VTY_NEWLINE);
368 vty_out(vty, " upstream-max-applied-gain %d%s",
369 trunk->upstr_max_gain, VTY_NEWLINE);
370 vty_out(vty, " upstream-target-level %d%s",
371 trunk->upstr_target_lvl, VTY_NEWLINE);
372 vty_out(vty, " downstream-automatic-gain %d%s",
373 trunk->dwnstr_agc_enbl, VTY_NEWLINE);
374 vty_out(vty, " downstream-adaptation-rate %d%s",
375 trunk->dwnstr_adp_rate, VTY_NEWLINE);
376 vty_out(vty, " downstream-max-applied-gain %d%s",
377 trunk->dwnstr_max_gain, VTY_NEWLINE);
378 vty_out(vty, " downstream-target-level %d%s",
379 trunk->dwnstr_target_lvl, VTY_NEWLINE);
380 vty_out(vty, " endpoint-offset %d%s",
381 trunk->endp_offset, VTY_NEWLINE);
382}
383
384
385void mgcp_mgw_vty_init(void)
386{
387 cmd_init(1);
388 vty_init(&vty_info);
389 logging_vty_add_cmds();
390 mgcp_vty_init();
391
392 install_element(MGCP_NODE, &cfg_mgcp_configure_cmd);
393 install_element(MGCP_NODE, &cfg_mgcp_vad_cmd);
394 install_element(MGCP_NODE, &cfg_mgcp_realloc_cmd);
395 install_element(MGCP_NODE, &cfg_mgcp_inp_dig_gain_cmd);
396 install_element(MGCP_NODE, &cfg_mgcp_out_dig_gain_cmd);
397 install_element(MGCP_NODE, &cfg_mgcp_upstr_agc_cmd);
398 install_element(MGCP_NODE, &cfg_mgcp_upstr_adp_cmd);
399 install_element(MGCP_NODE, &cfg_mgcp_upstr_max_gain_cmd);
400 install_element(MGCP_NODE, &cfg_mgcp_upstr_target_cmd);
401 install_element(MGCP_NODE, &cfg_mgcp_dwnstr_agc_cmd);
402 install_element(MGCP_NODE, &cfg_mgcp_dwnstr_adp_cmd);
403 install_element(MGCP_NODE, &cfg_mgcp_dwnstr_max_gain_cmd);
404 install_element(MGCP_NODE, &cfg_mgcp_dwnstr_target_cmd);
405 install_element(MGCP_NODE, &cfg_mgcp_endp_offset_cmd);
406 install_element(MGCP_NODE, &cfg_mgcp_target_trunk_cmd);
407
408 install_element(TRUNK_NODE, &cfg_trunk_vad_cmd);
409 install_element(TRUNK_NODE, &cfg_trunk_realloc_cmd);
410 install_element(TRUNK_NODE, &cfg_trunk_inp_dig_gain_cmd);
411 install_element(TRUNK_NODE, &cfg_trunk_out_dig_gain_cmd);
412 install_element(TRUNK_NODE, &cfg_trunk_upstr_agc_cmd);
413 install_element(TRUNK_NODE, &cfg_trunk_upstr_adp_cmd);
414 install_element(TRUNK_NODE, &cfg_trunk_upstr_max_gain_cmd);
415 install_element(TRUNK_NODE, &cfg_trunk_upstr_target_cmd);
416 install_element(TRUNK_NODE, &cfg_trunk_dwnstr_agc_cmd);
417 install_element(TRUNK_NODE, &cfg_trunk_dwnstr_adp_cmd);
418 install_element(TRUNK_NODE, &cfg_trunk_dwnstr_max_gain_cmd);
419 install_element(TRUNK_NODE, &cfg_trunk_dwnstr_target_cmd);
420 install_element(TRUNK_NODE, &cfg_trunk_endp_offset_cmd);
421}
422
423
424const char *openbsc_copyright = "";