[PATCH] osmocom-bb[master]: VIRT-PHY: Added option parsing.

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Jul 12 21:20:48 UTC 2017


Review at  https://gerrit.osmocom.org/3213

VIRT-PHY: Added option parsing.

Available options:
dl-rx-grp: mcast group messages on downlink are received from
ul-tx-grp: mcast group messages on uplink are sent to
port: port used for mcast sockets
log-mask: logging mask
l1ctl-sock: l1ctl socket path to connect to l23

Change-Id: Id939e5d7b90b592c85ad19f3ad6f459351e2d8f6
---
M src/host/virt_phy/src/gsmtapl1_if.c
M src/host/virt_phy/src/l1ctl_sap.c
M src/host/virt_phy/src/virtphy.c
3 files changed, 70 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/13/3213/1

diff --git a/src/host/virt_phy/src/gsmtapl1_if.c b/src/host/virt_phy/src/gsmtapl1_if.c
index b84186a..401df9e 100644
--- a/src/host/virt_phy/src/gsmtapl1_if.c
+++ b/src/host/virt_phy/src/gsmtapl1_if.c
@@ -153,6 +153,12 @@
 
 /**
  * Receive a gsmtap message from the virt um.
+ *
+ * As we do not have a downlink scheduler, but not all dl messages must be processed and thus forwarded to l2, this function also implements some message filtering.
+ * E.g. we do not forward:
+ * - uplink messages
+ * - messages with a wrong arfcn
+ * - if in MS_STATE_IDLE_SEARCHING
  */
 void gsmtapl1_rx_from_virt_um_inst_cb(struct virt_um_inst *vui,
                                       struct msgb *msg)
@@ -237,6 +243,7 @@
 	case GSMTAP_CHANNEL_AGCH:
 	case GSMTAP_CHANNEL_PCH:
 	case GSMTAP_CHANNEL_BCCH:
+		// save to just forward here, as upper layer ignores messages that do not fit the current state (e.g. gsm48_rr.c:2159)
 		l1ctl_tx_data_ind(msg, arfcn, link_id, chan_nr, fn, snr,
 						  signal_dbm, 0, 0);
 		break;
diff --git a/src/host/virt_phy/src/l1ctl_sap.c b/src/host/virt_phy/src/l1ctl_sap.c
index b6c4508..f0f3f68 100644
--- a/src/host/virt_phy/src/l1ctl_sap.c
+++ b/src/host/virt_phy/src/l1ctl_sap.c
@@ -262,6 +262,8 @@
 	l1_model_ms->state->dedicated.chan_type = rsl_chantype;
 	l1_model_ms->state->dedicated.tn = timeslot;
 	l1_model_ms->state->dedicated.subslot = subslot;
+	l1_model_ms->state->state = MS_STATE_DEDICATED;
+
 	/* TCH config */
 	if (rsl_chantype == RSL_CHAN_Bm_ACCHs
 	                || rsl_chantype == RSL_CHAN_Lm_ACCHs) {
@@ -340,7 +342,6 @@
  *
  * Handle state change from dedicated to idle mode. Flush message buffers of dedicated channel.
  *
- * TODO: Implement this handler routine!
  */
 void l1ctl_rx_dm_rel_req(struct msgb *msg)
 {
@@ -350,6 +351,7 @@
 	l1_model_ms->state->dedicated.tn = 0;
 	l1_model_ms->state->dedicated.subslot = 0;
 	l1_model_ms->state->tch_mode = GSM48_CMODE_SIGN;
+	l1_model_ms->state->state = MS_STATE_IDLE_CAMPING;
 
 	// TODO: disable ciphering
 	// TODO: disable audio recording / playing
diff --git a/src/host/virt_phy/src/virtphy.c b/src/host/virt_phy/src/virtphy.c
index 1454c4e..dd11c67 100644
--- a/src/host/virt_phy/src/virtphy.c
+++ b/src/host/virt_phy/src/virtphy.c
@@ -5,6 +5,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <getopt.h>
 #include <virtphy/virtual_um.h>
 #include <virtphy/l1ctl_sock.h>
 #include <virtphy/virt_l1_model.h>
@@ -13,44 +14,84 @@
 #include <virtphy/logging.h>
 #include <virtphy/virt_l1_sched.h>
 
-int main( int argc, char *argv[] )
+#define DEFAULT_MCAST_PORT 4729 /* IANA-registered port for GSMTAP */
+#define DEFAULT_LOG_MASK "DL1C,1:DVIRPHY,1"
+
+static char* dl_rx_grp = DEFAULT_MS_MCAST_GROUP;
+static char* ul_tx_grp = DEFAULT_BTS_MCAST_GROUP;
+static int port = DEFAULT_MCAST_PORT;
+static char* log_mask = DEFAULT_LOG_MASK;
+static char * l1ctl_sock_path = L1CTL_SOCK_PATH;
+
+static void handle_options(int argc, char **argv)
+{
+	while (1) {
+		int option_index = 0, c;
+		static struct option long_options[] = {
+			{"dl-rx-grp", required_argument, 0, 'z'},
+		        {"ul-tx-grp", required_argument, 0, 'y'},
+		        {"port", required_argument, 0, 'x'},
+		        {"log-mask", required_argument, 0, 'd'},
+		        {"l1ctl-sock", required_argument, 0, 's'},
+		        {0, 0, 0, 0},
+		};
+		c = getopt_long(argc, argv, "z:y:x:d:s:", long_options,
+		                &option_index);
+		if (c == -1)
+			break;
+
+		switch (c) {
+		case 'z':
+			dl_rx_grp = optarg;
+			break;
+		case 'y':
+			ul_tx_grp = optarg;
+			break;
+		case 'x':
+			port = atoi(optarg);
+			break;
+		case 'd':
+			log_mask = optarg;
+			break;
+		case 's':
+			l1ctl_sock_path = optarg;
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+int main(int argc, char *argv[])
 {
 	// init loginfo
 	static struct l1_model_ms *model;
-	char * l1ctl_sock_path = NULL;
 
-	// get path from commandline argument
-	if( argc > 1 ) {
-	      l1ctl_sock_path = argv[1];
-	}
+	handle_options(argc, argv);
 
-
-	//ms_log_init("DL1C,1:DVIRPHY,1");
-	ms_log_init("DL1C,1");
-	//ms_log_init("DL1C,8:DVIRPHY,8");
+	ms_log_init(log_mask);
 
 	LOGP(DVIRPHY, LOGL_INFO, "Virtual physical layer starting up...\n");
 
 	model = l1_model_ms_init(NULL);
 
-	// TODO: make this configurable
-	model->vui = virt_um_init(NULL, DEFAULT_BTS_MCAST_GROUP,
-	DEFAULT_BTS_MCAST_PORT, DEFAULT_MS_MCAST_GROUP,
-	DEFAULT_MS_MCAST_PORT, gsmtapl1_rx_from_virt_um_inst_cb);
-	model->lsi = l1ctl_sock_init(NULL, l1ctl_sap_rx_from_l23_inst_cb, l1ctl_sock_path);
+	model->vui = virt_um_init(NULL, ul_tx_grp, port, dl_rx_grp, port,
+	                          gsmtapl1_rx_from_virt_um_inst_cb);
+	model->lsi = l1ctl_sock_init(NULL, l1ctl_sap_rx_from_l23_inst_cb,
+	                             l1ctl_sock_path);
 
 	gsmtapl1_init(model);
 	l1ctl_sap_init(model);
 	virt_l1_sched_init(model);
 
-	LOGP(DVIRPHY, LOGL_INFO, "Virtual physical layer ready...\n \
-			Waiting for l23 app on %s", l1ctl_sock_path ? l1ctl_sock_path : L1CTL_SOCK_PATH);
+	LOGP(DVIRPHY, LOGL_INFO,
+	     "Virtual physical layer ready...\n \
+			Waiting for l23 app on %s",
+	     l1ctl_sock_path);
 
 	while (1) {
 		// handle osmocom fd READ events (l1ctl-unix-socket, virtual-um-mcast-socket)
 		osmo_select_main(0);
-		// handle outgoing l1ctl primitives to l2
-		// TODO implement scheduler for uplink messages
 	}
 
 	l1_model_ms_destroy(model);

-- 
To view, visit https://gerrit.osmocom.org/3213
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id939e5d7b90b592c85ad19f3ad6f459351e2d8f6
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: BastusIII <sebastian.stumpf87 at googlemail.com>



More information about the gerrit-log mailing list