aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-01-20 23:34:43 +0100
committerHarald Welte <laforge@gnumonks.org>2016-02-15 14:27:52 +0100
commita9a7120c82f571554e6c1417eec0803f15e6c7bb (patch)
treefcfd92dd0f13f9edacc7ff8a22f45bbe264213d9
parent5dfb115eaf16a5c5e9ccea5b03374651aa97da11 (diff)
make PCU socket and telnet port configurable
In some cases we'd like to run multiple instances of osmo-bts on a single machine. This is the case where we a multi-TRX PHY is to be used for several BTSs, or in case osmo-bts-trx has multple SDRs attached. This wa currently prevented by having a hard-coded PCU socket path and telnet port, which are now configurable via VTY / config file itself.
-rw-r--r--include/osmo-bts/gsm_data.h4
-rw-r--r--include/osmo-bts/pcu_if.h4
-rw-r--r--src/common/bts.c2
-rw-r--r--src/common/main.c10
-rw-r--r--src/common/pcu_sock.c4
-rw-r--r--src/common/vty.c36
6 files changed, 52 insertions, 8 deletions
diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index c4953cbb..7a486670 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -107,6 +107,10 @@ struct gsm_bts_role_bts {
float min_qual_rach; /* minimum quality for RACH bursts */
float min_qual_norm; /* minimum quality for normal daata */
+
+ struct {
+ char *sock_path;
+ } pcu;
};
enum lchan_ciph_state {
diff --git a/include/osmo-bts/pcu_if.h b/include/osmo-bts/pcu_if.h
index 71738445..0c4fb696 100644
--- a/include/osmo-bts/pcu_if.h
+++ b/include/osmo-bts/pcu_if.h
@@ -1,6 +1,8 @@
#ifndef _PCU_IF_H
#define _PCU_IF_H
+#define PCU_SOCK_DEFAULT "/tmp/pcu_bts"
+
extern int pcu_direct;
int pcu_tx_info_ind(void);
@@ -14,7 +16,7 @@ int pcu_tx_time_ind(uint32_t fn);
int pcu_tx_pag_req(const uint8_t *identity_lv, uint8_t chan_needed);
int pcu_tx_pch_data_cnf(uint32_t fn, uint8_t *data, uint8_t len);
-int pcu_sock_init(void);
+int pcu_sock_init(const char *path);
void pcu_sock_exit(void);
#endif /* _PCU_IF_H */
diff --git a/src/common/bts.c b/src/common/bts.c
index 20d551dc..6f621c4d 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -40,6 +40,7 @@
#include <osmo-bts/abis.h>
#include <osmo-bts/bts.h>
#include <osmo-bts/bts_model.h>
+#include <osmo-bts/pcu_if.h>
#include <osmo-bts/rsl.h>
#include <osmo-bts/oml.h>
#include <osmo-bts/signal.h>
@@ -117,6 +118,7 @@ int bts_init(struct gsm_bts *bts)
btsb->t3105_ms = 300;
btsb->min_qual_rach = MIN_QUAL_RACH;
btsb->min_qual_norm = MIN_QUAL_NORM;
+ btsb->pcu.sock_path = talloc_strdup(btsb, PCU_SOCK_DEFAULT);
for (i = 0; i < ARRAY_SIZE(btsb->t200_ms); i++)
btsb->t200_ms[i] = oml_default_t200_ms[i];
diff --git a/src/common/main.c b/src/common/main.c
index e454a28b..d19c2840 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -1,6 +1,6 @@
/* Main program for Osmocom BTS */
-/* (C) 2011-2015 by Harald Welte <laforge@gnumonks.org>
+/* (C) 2011-2016 by Harald Welte <laforge@gnumonks.org>
*
* All Rights Reserved
*
@@ -37,7 +37,6 @@
#include <osmocom/core/application.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/logging.h>
-#include <osmocom/vty/ports.h>
#include <osmocom/core/gsmtap_util.h>
#include <osmocom/core/gsmtap.h>
@@ -58,6 +57,7 @@ static int daemonize = 0;
static int rt_prio = -1;
static int trx_num = 1;
static char *gsmtap_ip = 0;
+extern int g_vty_port_num;
static void print_help()
{
@@ -275,6 +275,7 @@ int bts_main(int argc, char **argv)
fprintf(stderr, "unable to open bts\n");
exit(1);
}
+ btsb = bts_role_bts(bts);
abis_init(bts);
@@ -302,13 +303,13 @@ int bts_main(int argc, char **argv)
bts_controlif_setup(bts);
- rc = telnet_init(tall_bts_ctx, NULL, OSMO_VTY_PORT_BTS);
+ rc = telnet_init(tall_bts_ctx, NULL, g_vty_port_num);
if (rc < 0) {
fprintf(stderr, "Error initializing telnet\n");
exit(1);
}
- if (pcu_sock_init()) {
+ if (pcu_sock_init(btsb->pcu.sock_path)) {
fprintf(stderr, "PCU L1 socket failed\n");
exit(1);
}
@@ -319,7 +320,6 @@ int bts_main(int argc, char **argv)
signal(SIGUSR2, &signal_handler);
osmo_init_ignore_signals();
- btsb = bts_role_bts(bts);
if (!btsb->bsc_oml_host) {
fprintf(stderr, "Cannot start BTS without knowing BSC OML IP\n");
exit(1);
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c
index 34c6e74b..7c835fb9 100644
--- a/src/common/pcu_sock.c
+++ b/src/common/pcu_sock.c
@@ -809,7 +809,7 @@ static int pcu_sock_accept(struct osmo_fd *bfd, unsigned int flags)
return 0;
}
-int pcu_sock_init(void)
+int pcu_sock_init(const char *path)
{
struct pcu_sock_state *state;
struct osmo_fd *bfd;
@@ -825,7 +825,7 @@ int pcu_sock_init(void)
bfd = &state->listen_bfd;
- rc = osmo_unixsock_listen(bfd, SOCK_SEQPACKET, "/tmp/pcu_bts");
+ rc = osmo_unixsock_listen(bfd, SOCK_SEQPACKET, path);
if (rc < 0) {
LOGP(DPCU, LOGL_ERROR, "Could not create unix socket: %s\n",
strerror(errno));
diff --git a/src/common/vty.c b/src/common/vty.c
index 383fa3c3..bba6af14 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -33,6 +33,7 @@
#include <osmocom/vty/command.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/misc.h>
+#include <osmocom/vty/ports.h>
#include <osmocom/core/gsmtap.h>
#include <osmocom/trau/osmo_ortp.h>
@@ -47,10 +48,15 @@
#include <osmo-bts/oml.h>
#include <osmo-bts/signal.h>
#include <osmo-bts/bts_model.h>
+#include <osmo-bts/pcu_if.h>
#include <osmo-bts/measurement.h>
#include <osmo-bts/vty.h>
#include <osmo-bts/l1sap.h>
+#define VTY_STR "Configure the VTY\n"
+
+int g_vty_port_num = OSMO_VTY_PORT_BTS;
+
struct phy_instance *vty_get_phy_instance(struct vty *vty, int phy_nr, int inst_nr)
{
struct phy_link *plink = phy_link_by_num(phy_nr);
@@ -298,6 +304,8 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
VTY_NEWLINE);
vty_out(vty, " min-qual-norm %.0f%s", btsb->min_qual_norm * 10.0f,
VTY_NEWLINE);
+ if (strcmp(btsb->pcu.sock_path, PCU_SOCK_DEFAULT))
+ vty_out(vty, " pcu-socket %s%s", btsb->pcu.sock_path, VTY_NEWLINE);
bts_model_config_write_bts(vty, bts);
@@ -370,6 +378,15 @@ static int config_write_dummy(struct vty *vty)
return CMD_SUCCESS;
}
+DEFUN(cfg_vty_telnet_port, cfg_vty_telnet_port_cmd,
+ "vty telnet-port <0-65535>",
+ VTY_STR "Set the VTY telnet port\n"
+ "TCP Port number\n")
+{
+ g_vty_port_num = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
/* per-BTS configuration */
DEFUN(cfg_bts,
cfg_bts_cmd,
@@ -586,6 +603,23 @@ DEFUN(cfg_bts_min_qual_norm, cfg_bts_min_qual_norm_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_bts_pcu_sock, cfg_bts_pcu_sock_cmd,
+ "pcu-socket PATH",
+ "Configure the PCU socket file/path name\n")
+{
+ struct gsm_bts *bts = vty->index;
+ struct gsm_bts_role_bts *btsb = bts_role_bts(bts);
+
+ if (btsb->pcu.sock_path) {
+ /* FIXME: close the interface? */
+ talloc_free(btsb->pcu.sock_path);
+ }
+ btsb->pcu.sock_path = talloc_strdup(btsb, argv[0]);
+ /* FIXME: re-open the interface? */
+
+ return CMD_SUCCESS;
+}
+
#define DB_DBM_STR \
"Unit is dB (decibels)\n" \
@@ -1043,6 +1077,7 @@ int bts_vty_init(struct gsm_bts *bts, const struct log_info *cat)
install_node(&bts_node, config_write_bts);
install_element(CONFIG_NODE, &cfg_bts_cmd);
+ install_element(CONFIG_NODE, &cfg_vty_telnet_port_cmd);
install_default(BTS_NODE);
install_element(BTS_NODE, &cfg_bts_unit_id_cmd);
install_element(BTS_NODE, &cfg_bts_oml_ip_cmd);
@@ -1058,6 +1093,7 @@ int bts_vty_init(struct gsm_bts *bts, const struct log_info *cat)
install_element(BTS_NODE, &cfg_bts_ul_power_target_cmd);
install_element(BTS_NODE, &cfg_bts_min_qual_rach_cmd);
install_element(BTS_NODE, &cfg_bts_min_qual_norm_cmd);
+ install_element(BTS_NODE, &cfg_bts_pcu_sock_cmd);
install_element(BTS_NODE, &cfg_trx_gsmtap_sapi_cmd);
install_element(BTS_NODE, &cfg_trx_no_gsmtap_sapi_cmd);