[31/33] Add gsmtap option to command line to main.c of osmo-bts-sysmo
diff mbox

Message ID 1409176492-13269-32-git-send-email-laforge@gnumonks.org
State Superseded
Headers show

Commit Message

Harald Welte Aug. 27, 2014, 9:54 p.m. UTC
From: Andreas Eversberg <jolly@eversberg.eu>

---
 src/osmo-bts-sysmo/main.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Patch
diff mbox

diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c
index 27b593b..8abff5f 100644
--- a/src/osmo-bts-sysmo/main.c
+++ b/src/osmo-bts-sysmo/main.c
@@ -38,6 +38,8 @@ 
 #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>
 
 #include <osmo-bts/gsm_data.h>
 #include <osmo-bts/logging.h>
@@ -47,6 +49,7 @@ 
 #include <osmo-bts/bts_model.h>
 #include <osmo-bts/pcu_if.h>
 #include <osmo-bts/control_if.h>
+#include <osmo-bts/l1sap.h>
 
 #define SYSMOBTS_RF_LOCK_PATH	"/var/lock/bts_rf_lock"
 
@@ -64,6 +67,7 @@  static const char *config_file = "osmo-bts.cfg";
 static int daemonize = 0;
 static unsigned int dsp_trace = 0x71c00020;
 static int rt_prio = -1;
+static char *gsmtap_ip = 0;
 
 int bts_model_init(struct gsm_bts *bts)
 {
@@ -167,6 +171,7 @@  static void print_help()
 		"  -w	--hw-version	Print the targeted HW Version\n"
 		"  -M	--pcu-direct	Force PCU to access message queue for "
 			"PDCH dchannel directly\n"
+		"  -i	--gsmtap-ip	The destination IP used for GSMTAP.\n"
 		);
 }
 
@@ -198,10 +203,11 @@  static void handle_options(int argc, char **argv)
 			{ "hw-version", 0, 0, 'w' },
 			{ "pcu-direct", 0, 0, 'M' },
 			{ "realtime", 1, 0, 'r' },
+			{ "gsmtap-ip", 1, 0, 'i' },
 			{ 0, 0, 0, 0 }
 		};
 
-		c = getopt_long(argc, argv, "hc:d:Dc:sTVe:p:w:Mr:",
+		c = getopt_long(argc, argv, "hc:d:Dc:sTVe:p:w:Mr:i:",
 				long_options, &option_idx);
 		if (c == -1)
 			break;
@@ -246,6 +252,9 @@  static void handle_options(int argc, char **argv)
 		case 'r':
 			rt_prio = atoi(optarg);
 			break;
+		case 'i':
+			gsmtap_ip = optarg;
+			break;
 		default:
 			break;
 		}
@@ -328,6 +337,15 @@  int main(int argc, char **argv)
 		}
 	}
 
+        if (gsmtap_ip) {
+		gsmtap = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1);
+		if (!gsmtap) {
+			fprintf(stderr, "Failed during gsmtap_init()\n");
+			exit(1);
+		}
+		gsmtap_source_add_sink(gsmtap);
+	}
+
 	if (bts_init(bts) < 0) {
 		fprintf(stderr, "unable to open bts\n");
 		exit(1);