aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-virtual/virtualbts_vty.c
blob: e8c97accfb5892b5fa9e7462103721e7cfce23f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* VTY interface for virtual OsmoBTS */

/* (C) 2015 by Harald Welte <laforge@gnumonks.org>
 *
 * All Rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <ctype.h>

#include <arpa/inet.h>

#include <osmocom/core/msgb.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>

#include <osmocom/gsm/tlv.h>

#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/misc.h>

#include <osmo-bts/gsm_data.h>
#include <osmo-bts/phy_link.h>
#include <osmo-bts/logging.h>
#include <osmo-bts/vty.h>

#define TRX_STR "Transceiver related commands\n" "TRX number\n"

#define SHOW_TRX_STR				\
	SHOW_STR				\
	TRX_STR

static struct gsm_bts *vty_bts;

void bts_model_config_write_bts(struct vty *vty, struct gsm_bts *bts)
{
}

void bts_model_config_write_trx(struct vty *vty, struct gsm_bts_trx *trx)
{
}

void bts_model_config_write_phy(struct vty *vty, struct phy_link *plink)
{
	if (plink->u.virt.mcast_dev)
		vty_out(vty, " virtual-um net-device %s%s",
			plink->u.virt.mcast_dev, VTY_NEWLINE);
	if (plink->u.virt.mcast_group)
		vty_out(vty, " virtual-um multicast-group %s%s",
			plink->u.virt.mcast_group, VTY_NEWLINE);
	if (plink->u.virt.mcast_port)
		vty_out(vty, " virtual-um udp-port %u%s",
			plink->u.virt.mcast_port, VTY_NEWLINE);
}

#define VUM_STR	"Virtual Um layer\n"

DEFUN(cfg_phy_mcast_group, cfg_phy_mcast_group_cmd,
	"virtual-um multicast-group GROUP",
	VUM_STR "Configure the multicast group\n")
{
	struct phy_link *plink = vty->index;

	if (plink->state != PHY_LINK_SHUTDOWN) {
		vty_out(vty, "Can only reconfigure a PHY link that is down%s",
			VTY_NEWLINE);
		return CMD_WARNING;
	}

	if (plink->u.virt.mcast_group)
		talloc_free(plink->u.virt.mcast_group);
	plink->u.virt.mcast_group = talloc_strdup(plink, argv[0]);

	return CMD_SUCCESS;
}


DEFUN(cfg_phy_mcast_port, cfg_phy_mcast_port_cmd,
	"virtual-um udp-port <0-65535>",
	VUM_STR "Configure the UDP port\n")
{
	struct phy_link *plink = vty->index;

	if (plink->state != PHY_LINK_SHUTDOWN) {
		vty_out(vty, "Can only reconfigure a PHY link that is down%s",
			VTY_NEWLINE);
		return CMD_WARNING;
	}

	plink->u.virt.mcast_port = atoi(argv[0]);

	return CMD_SUCCESS;
}

DEFUN(cfg_phy_mcast_dev, cfg_phy_mcast_dev_cmd,
	"virtual-um net-device NETDEV",
	VUM_STR "Configure the network device\n")
{
	struct phy_link *plink = vty->index;

	if (plink->state != PHY_LINK_SHUTDOWN) {
		vty_out(vty, "Can only reconfigure a PHY link that is down%s",
			VTY_NEWLINE);
		return CMD_WARNING;
	}

	if (plink->u.virt.mcast_dev)
		talloc_free(plink->u.virt.mcast_dev);
	plink->u.virt.mcast_dev = talloc_strdup(plink, argv[0]);

	return CMD_SUCCESS;
}

int bts_model_vty_init(struct gsm_bts *bts)
{
	vty_bts = bts;

	install_element(PHY_NODE, &cfg_phy_mcast_group_cmd);
	install_element(PHY_NODE, &cfg_phy_mcast_port_cmd);
	install_element(PHY_NODE, &cfg_phy_mcast_dev_cmd);

	return 0;
}