net/templates: support running osmo-bts-virtual

New config variables:
* BTS0_RUN_IN_OSMO_DEV
* BTS0_IP
* BTS1_RUN_IN_OSMO_DEV
* BTS1_IP

Change-Id: Ibc8efe75abffcefc0a719b6323a9ceca39f14ea1
diff --git a/net/README b/net/README
index 696a803..3ca15fe 100644
--- a/net/README
+++ b/net/README
@@ -149,11 +149,14 @@
 
 === 2G BTS
 
-At the time of writing, there are no osmo-bts.cfg files, since this is intended
-for the core network and BSC components only. Feel free to add!
+You can either let osmo-dev run osmo-bts-virtual, or connect a real BTS to the
+BSC + CN started by osmo-dev.
 
-Typically you'd need to edit only the /etc/osmocom/osmo-bts.cfg to match your
-IP address and ipa unit-id:
+To start osmo-bts-virtual, set BTS0_RUN_IN_OSMO_DEV=1 and/or
+BTS1_RUN_IN_OSMO_DEV=1 in your copy of config_2g3g.
+
+To connect your real BTS, typically you'd need to edit only the
+/etc/osmocom/osmo-bts.cfg to match your IP address and ipa unit-id:
 
 bts 0
  oml remote-ip 192.168.0.23
diff --git a/net/config_2g3g b/net/config_2g3g
index eb43e03..bc0ced3 100644
--- a/net/config_2g3g
+++ b/net/config_2g3g
@@ -39,6 +39,9 @@
 BTS0_MAX_POWER_RED=${BTS_MAX_POWER_RED}
 BTS0_NOMINAL_POWER=${BTS_200mW}
 BTS0_CODEC_SUPPORT=${BTS_CODEC_SUPPORT}
+# set to 1 to have osmo-dev run osmo-bts-virtual
+BTS0_RUN_IN_OSMO_DEV=0
+BTS0_IP="127.0.0.12"
 
 BTS1_DESCRIPTION="my test BTS 1"
 BTS1_IPA_UNIT="1 0"
@@ -56,6 +59,9 @@
 BTS1_MAX_POWER_RED=${BTS_MAX_POWER_RED}
 BTS1_NOMINAL_POWER=${BTS_200mW}
 BTS1_CODEC_SUPPORT=${BTS_CODEC_SUPPORT}
+# set to 1 to have osmo-dev run osmo-bts-virtual
+BTS1_RUN_IN_OSMO_DEV=0
+BTS1_IP="127.0.0.13"
 
 HLR_IP=127.0.0.5
 
diff --git a/net/templates/osmo-bts.cfg b/net/templates/osmo-bts-0.cfg
similarity index 71%
rename from net/templates/osmo-bts.cfg
rename to net/templates/osmo-bts-0.cfg
index 1d3e6a9..f6fd3ac 100644
--- a/net/templates/osmo-bts.cfg
+++ b/net/templates/osmo-bts-0.cfg
@@ -4,3 +4,9 @@
 bts 0
  ipa unit-id ${BTS0_IPA_UNIT}
  oml remote-ip ${BSC0_IP}
+
+ctrl
+ bind ${BTS0_IP}
+
+line vty
+ bind ${BTS0_IP}
diff --git a/net/templates/osmo-bts-1.cfg b/net/templates/osmo-bts-1.cfg
new file mode 100644
index 0000000..e4e3c64
--- /dev/null
+++ b/net/templates/osmo-bts-1.cfg
@@ -0,0 +1,12 @@
+${include(common_template_warning)}
+${include(common_osmo_bts)}
+
+bts 0
+ ipa unit-id ${BTS1_IPA_UNIT}
+ oml remote-ip ${BSC1_IP}
+
+ctrl
+ bind ${BTS1_IP}
+
+line vty
+ bind ${BTS1_IP}
diff --git a/net/templates/run.sh b/net/templates/run.sh
index 3430966..42b1eb4 100755
--- a/net/templates/run.sh
+++ b/net/templates/run.sh
@@ -181,6 +181,7 @@
 stp4ran="osmo-stp -c osmo-stp-ran.cfg"
 bsc="LD_LIBRARY_PATH=/usr/local/lib gdb -ex run --args osmo-bsc"
 bscnat="osmo-bsc-nat"
+bts="osmo-bts-virtual"
 
 if [ "x${MSC_MNCC}" != "xinternal" ]; then
   sipcon="osmo-sip-connector -c osmo-sip-connector.cfg"
@@ -272,6 +273,13 @@
   term "$bsc -c osmo-bsc-1.cfg" BSC1
 fi
 
+${foreach(BTS)}
+if [ "${BTSn_RUN_IN_OSMO_DEV}" = 1 ]; then
+  term "$bts -c osmo-bts-${BTSn}.cfg" BTS${BTSn}
+fi
+${foreach_end}
+
+
 if [ "x${MSC_MNCC}" != "xinternal" ]; then
   sleep .2
   term "$sipcon" SIPCON