aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-virtual/virtualbts_vty.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-01-09 13:13:37 +0100
committerHarald Welte <laforge@gnumonks.org>2017-07-13 19:34:17 +0000
commit5eb17e28acdd6fba22a1f2e60f4d55aaef18b47a (patch)
tree7e2e6dd96ce541fb4fda6ae3694ba27d971e1033 /src/osmo-bts-virtual/virtualbts_vty.c
parent152c2f489cd214b1a400b158df2b8726f779358a (diff)
VIRT-PHY: Initial check-in of a new virtual BTS
This patch adds a virtual physical layer designed to simulate the Um air interface between BTS and MS. It does so by encapsulating MAC blocks (Layer 2 PDUs) via GSMTAP and sending them through multicast UDP streams, both in uplink and in downlink. The purpose of this is enable testing without any radio hardware or related licenses. OsmocomBB has recently received as similar patch-set, adding a virty_phy executable that can be run on a PC instead of the classic 'layer1' firmware on a real phone. Using GSMTAP means that one can use unmodified wireshark to decode the messages exchanged on the virtual Um layer. This code was originally started by Harald in January 2016, continued by Sebastian Stumpf in late 2016 and early 2017, and finally completed by Harald in July 2017. Change-Id: I1bf7670975b1e367c1c62983020865a043542622
Diffstat (limited to 'src/osmo-bts-virtual/virtualbts_vty.c')
-rw-r--r--src/osmo-bts-virtual/virtualbts_vty.c185
1 files changed, 185 insertions, 0 deletions
diff --git a/src/osmo-bts-virtual/virtualbts_vty.c b/src/osmo-bts-virtual/virtualbts_vty.c
new file mode 100644
index 00000000..45c10861
--- /dev/null
+++ b/src/osmo-bts-virtual/virtualbts_vty.c
@@ -0,0 +1,185 @@
+/* VTY interface for virtual OsmoBTS */
+
+/* (C) 2015-2017 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2017 Sebastian Stumpf <sebastian.stumpf87@googlemail.com>
+ * 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>
+#include "virtual_um.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_inst(struct vty *vty, struct phy_instance *pinst)
+{
+}
+
+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 (strcmp(plink->u.virt.ms_mcast_group, DEFAULT_BTS_MCAST_GROUP))
+ vty_out(vty, " virtual-um ms-multicast-group %s%s",
+ plink->u.virt.ms_mcast_group, VTY_NEWLINE);
+ if (plink->u.virt.ms_mcast_port)
+ vty_out(vty, " virtual-um ms-udp-port %u%s",
+ plink->u.virt.ms_mcast_port, VTY_NEWLINE);
+ if (strcmp(plink->u.virt.bts_mcast_group, DEFAULT_MS_MCAST_GROUP))
+ vty_out(vty, " virtual-um bts-multicast-group %s%s",
+ plink->u.virt.bts_mcast_group, VTY_NEWLINE);
+ if (plink->u.virt.bts_mcast_port)
+ vty_out(vty, " virtual-um bts-udp-port %u%s",
+ plink->u.virt.bts_mcast_port, VTY_NEWLINE);
+
+}
+
+#define VUM_STR "Virtual Um layer\n"
+
+DEFUN(cfg_phy_ms_mcast_group, cfg_phy_ms_mcast_group_cmd,
+ "virtual-um ms-multicast-group GROUP",
+ VUM_STR "Configure the MS 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;
+ }
+
+ osmo_talloc_replace_string(plink, &plink->u.virt.ms_mcast_group, argv[0]);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_phy_ms_mcast_port, cfg_phy_ms_mcast_port_cmd,
+ "virtual-um ms-udp-port <0-65535>",
+ VUM_STR "Configure the MS 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.ms_mcast_port = atoi(argv[0]);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_phy_bts_mcast_group, cfg_phy_bts_mcast_group_cmd,
+ "virtual-um bts-multicast-group GROUP",
+ VUM_STR "Configure the BTS 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;
+ }
+
+ osmo_talloc_replace_string(plink, &plink->u.virt.bts_mcast_group, argv[0]);
+
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_phy_bts_mcast_port, cfg_phy_bts_mcast_port_cmd,
+ "virtual-um bts-udp-port <0-65535>",
+ VUM_STR "Configure the BTS 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.bts_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;
+ }
+
+ osmo_talloc_replace_string(plink, &plink->u.virt.mcast_dev, argv[0]);
+
+ return CMD_SUCCESS;
+}
+
+int bts_model_vty_init(struct gsm_bts *bts)
+{
+ vty_bts = bts;
+
+ install_element(PHY_NODE, &cfg_phy_ms_mcast_group_cmd);
+ install_element(PHY_NODE, &cfg_phy_ms_mcast_port_cmd);
+ install_element(PHY_NODE, &cfg_phy_bts_mcast_group_cmd);
+ install_element(PHY_NODE, &cfg_phy_bts_mcast_port_cmd);
+ install_element(PHY_NODE, &cfg_phy_mcast_dev_cmd);
+
+ return 0;
+}