blob: 6d44a95ba7d3b86170f009a5d604594bf8a78717 [file] [log] [blame]
Harald Welte3016d9f2011-02-05 13:54:41 +01001/* OpenBSC E1 vty interface */
2/* (C) 2011 by Harald Welte <laforge@gnumonks.org>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20#include <stdlib.h>
21#include <unistd.h>
22#include <sys/types.h>
23
24#include <osmocom/vty/command.h>
25#include <osmocom/vty/buffer.h>
26#include <osmocom/vty/vty.h>
27#include <osmocom/vty/logging.h>
28#include <osmocom/vty/telnet_interface.h>
29
30#include <osmocore/linuxlist.h>
31#include <openbsc/gsm_data.h>
32#include <openbsc/e1_input.h>
33#include <osmocore/utils.h>
34#include <osmocore/gsm_utils.h>
35#include <osmocore/talloc.h>
36#include <openbsc/vty.h>
37#include <openbsc/debug.h>
38
39#include "../bscconfig.h"
40
41#define E1_DRIVER_NAMES "(misdn)"
42#define E1_DRIVER_HELP "mISDN supported E1 Card\n"
43
44DEFUN(cfg_e1line_driver, cfg_e1_line_driver_cmd,
45 "e1_line <0-255> driver " E1_DRIVER_NAMES,
46 "Configure E1/T1/J1 Line\n" "Line Number\n" "Set driver for this line\n"
47 E1_DRIVER_HELP)
48{
49 struct e1inp_line *line;
50 int e1_nr = atoi(argv[0]);
51
52 line = e1inp_line_get(e1_nr);
53 if (line) {
54 vty_out(vty, "%% Line %d already exists%s", e1_nr, VTY_NEWLINE);
55 return CMD_WARNING;
56 }
57 line = e1inp_line_create(e1_nr, argv[1]);
58 if (!line) {
59 vty_out(vty, "%% Error creating line %d%s", e1_nr, VTY_NEWLINE);
60 return CMD_WARNING;
61 }
62
63 return CMD_SUCCESS;
64}
65
66DEFUN(cfg_e1inp, cfg_e1inp_cmd,
67 "e1_input",
68 "Configure E1/T1/J1 TDM input\n")
69{
70 vty->node = E1INP_NODE;
71
72 return CMD_SUCCESS;
73}
74
75static int e1inp_config_write(struct vty *vty)
76{
77 struct e1inp_line *line;
78
79 llist_for_each_entry(line, &e1inp_line_list, list) {
80 vty_out(vty, " e1_line %u driver %s%s", line->num,
81 line->driver->name, VTY_NEWLINE);
82 }
83 return CMD_SUCCESS;
84}
85
86struct cmd_node e1inp_node = {
87 E1INP_NODE,
88 "%s(e1_input)#",
89 1,
90};
91
92int e1inp_vty_init(void)
93{
94 install_element(CONFIG_NODE, &cfg_e1inp_cmd);
95 install_node(&e1inp_node, e1inp_config_write);
96 install_element(E1INP_NODE, &cfg_e1_line_driver_cmd);
97
98 return 0;
99}