fixeria has uploaded this change for review.

View Change

mobile: add params and VTY commands for data calls

Change-Id: If52fa70cb202f0736a17fe8eb63d226186637f62
Related: OS#4396
---
M src/host/layer23/include/osmocom/bb/common/settings.h
M src/host/layer23/src/common/settings.c
M src/host/layer23/src/mobile/vty_interface.c
3 files changed, 115 insertions(+), 12 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/15/34915/1
diff --git a/src/host/layer23/include/osmocom/bb/common/settings.h b/src/host/layer23/include/osmocom/bb/common/settings.h
index 6cec54b..13b1e2b 100644
--- a/src/host/layer23/include/osmocom/bb/common/settings.h
+++ b/src/host/layer23/include/osmocom/bb/common/settings.h
@@ -44,6 +44,20 @@
static inline const char *tch_voice_io_handler_name(enum tch_voice_io_handler val)
{ return get_value_string(tch_voice_io_handler_names, val); }

+/* TCH I/O handler for data calls */
+enum tch_data_io_handler {
+ /* No handler, drop frames */
+ TCH_DATA_IOH_NONE = 0,
+ /* UNIX socket */
+ TCH_DATA_IOH_UNIX_SOCK,
+ /* Return to sender */
+ TCH_DATA_IOH_LOOPBACK,
+};
+
+extern const struct value_string tch_data_io_handler_names[];
+static inline const char *tch_data_io_handler_name(enum tch_data_io_handler val)
+{ return get_value_string(tch_data_io_handler_names, val); }
+
/* TCH I/O frame format */
enum tch_io_frame_format {
/* RFC3551 for FR/EFR, RFC5993 for HR, RFC4867 for AMR, packed bits for data */
@@ -58,9 +72,15 @@

struct tch_settings {
enum tch_voice_io_handler voice_handler;
+ enum tch_data_io_handler data_handler;
enum tch_io_frame_format frame_format;
+
+ /* voice related parameters */
char alsa_output_dev[128];
char alsa_input_dev[128];
+
+ /* data related parameters */
+ char data_socket_path[128];
};

struct test_sim_settings {
diff --git a/src/host/layer23/src/common/settings.c b/src/host/layer23/src/common/settings.c
index bfca1d5..9d1fd78 100644
--- a/src/host/layer23/src/common/settings.c
+++ b/src/host/layer23/src/common/settings.c
@@ -34,6 +34,7 @@

static char *sap_socket_path = "/tmp/osmocom_sap";
static char *mncc_socket_path = "/tmp/ms_mncc";
+static char *data_socket_path = "/tmp/ms_data";
static char *alsa_dev_default = "default";

int gsm_settings_init(struct osmocom_ms *ms)
@@ -52,8 +53,13 @@
set->tch.frame_format = TCH_IOFF_OSMO;
/* TCH voice: drop frames by default */
set->tch.voice_handler = TCH_VOICE_IOH_NONE;
+ /* TCH data: drop frames by default */
+ set->tch.data_handler = TCH_DATA_IOH_NONE;
OSMO_STRLCPY_ARRAY(set->tch.alsa_output_dev, alsa_dev_default);
OSMO_STRLCPY_ARRAY(set->tch.alsa_input_dev, alsa_dev_default);
+ /* Compose data (CSD) socket path using MS name */
+ snprintf(set->tch.data_socket_path, sizeof(set->tch.data_socket_path) - 1,
+ "%s_%s", data_socket_path, ms->name);

/* Built-in MNCC handler */
set->mncc_handler = MNCC_HANDLER_INTERNAL;
@@ -237,6 +243,13 @@
{ 0, NULL }
};

+const struct value_string tch_data_io_handler_names[] = {
+ { TCH_DATA_IOH_NONE, "none" },
+ { TCH_DATA_IOH_UNIX_SOCK, "unix-sock" },
+ { TCH_DATA_IOH_LOOPBACK, "loopback" },
+ { 0, NULL }
+};
+
const struct value_string tch_io_frame_format_names[] = {
{ TCH_IOFF_OSMO, "osmo" },
{ TCH_IOFF_OSMO, "rtp" }, /* for compatibility */
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index 8acc148..3cc3586 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -1478,14 +1478,20 @@
vty_out(vty, " tch%s", VTY_NEWLINE);
vty_out(vty, " voice-io-handler %s%s",
tch_voice_io_handler_name(set->tch.voice_handler), VTY_NEWLINE);
+ vty_out(vty, " data-io-handler %s%s",
+ tch_data_io_handler_name(set->tch.data_handler), VTY_NEWLINE);
+ vty_out(vty, " io-tch-format %s%s",
+ tch_io_frame_format_name(set->tch.frame_format), VTY_NEWLINE);
if (set->tch.voice_handler == TCH_VOICE_IOH_GAPK) {
- vty_out(vty, " io-tch-format %s%s",
- tch_io_frame_format_name(set->tch.frame_format), VTY_NEWLINE);
vty_out(vty, " alsa-output-dev %s%s",
set->tch.alsa_output_dev, VTY_NEWLINE);
vty_out(vty, " alsa-input-dev %s%s",
set->tch.alsa_input_dev, VTY_NEWLINE);
}
+ if (set->tch.data_handler == TCH_DATA_IOH_UNIX_SOCK) {
+ vty_out(vty, " data-unix-socket %s%s",
+ set->tch.data_socket_path, VTY_NEWLINE);
+ }

if (ms->lua_script)
vty_out(vty, " lua-script %s%s", ms->lua_script, VTY_NEWLINE);
@@ -2508,6 +2514,22 @@
return CMD_SUCCESS;
}

+static int set_data_io_handler(struct vty *vty, enum tch_data_io_handler val)
+{
+ struct osmocom_ms *ms = (struct osmocom_ms *) vty->index;
+ struct gsm_settings *set = &ms->settings;
+
+ /* Don't restart on unchanged value */
+ if (val == set->tch.data_handler)
+ return CMD_SUCCESS;
+ set->tch.data_handler = val;
+
+ /* Restart required */
+ vty_restart_if_started(vty, ms);
+
+ return CMD_SUCCESS;
+}
+
#define TCH_VOICE_IOH_SEL \
"(none|gapk|l1phy|mncc-sock|loopback)"
#define TCH_VOICE_IOH_SEL_DESC \
@@ -2517,6 +2539,13 @@
"External MNCC application (e.g. LCR) via MNCC socket\n" \
"Return TCH frame payload back to sender\n"

+#define TCH_DATA_IOH_SEL \
+ "(none|unix-sock|loopback)"
+#define TCH_DATA_IOH_SEL_DESC \
+ "No handler, drop TCH frames (default)\n" \
+ "UNIX socket (path set by 'data-unix-socket')\n" \
+ "Return TCH frame payload back to sender\n"
+
DEFUN(cfg_ms_tch_voice_io_handler,
cfg_ms_tch_voice_io_handler_cmd,
"voice-io-handler " TCH_VOICE_IOH_SEL,
@@ -2544,10 +2573,16 @@
return set_voice_io_handler(vty, val);
}

-ALIAS_DEPRECATED(cfg_ms_tch_voice_io_handler,
- cfg_ms_tch_io_handler_cmd,
- "io-handler " TCH_VOICE_IOH_SEL,
- "Set TCH I/O handler for voice calls\n" TCH_VOICE_IOH_SEL_DESC);
+DEFUN(cfg_ms_tch_data_io_handler,
+ cfg_ms_tch_data_io_handler_cmd,
+ "data-io-handler " TCH_DATA_IOH_SEL,
+ "Set TCH I/O handler for data calls\n"
+ TCH_DATA_IOH_SEL_DESC)
+{
+ int val = get_string_value(tch_data_io_handler_names, argv[0]);
+
+ return set_data_io_handler(vty, val);
+}

DEFUN(cfg_ms_tch_no_voice_io_handler,
cfg_ms_tch_no_voice_io_handler_cmd,
@@ -2557,6 +2592,19 @@
return set_voice_io_handler(vty, TCH_VOICE_IOH_NONE);
}

+DEFUN(cfg_ms_tch_no_data_io_handler,
+ cfg_ms_tch_no_data_io_handler_cmd,
+ "no data-io-handler",
+ NO_STR "Disable TCH I/O handling for data calls\n")
+{
+ return set_data_io_handler(vty, TCH_DATA_IOH_NONE);
+}
+
+ALIAS_DEPRECATED(cfg_ms_tch_voice_io_handler,
+ cfg_ms_tch_io_handler_cmd,
+ "io-handler " TCH_VOICE_IOH_SEL,
+ "Set TCH I/O handler for voice calls\n" TCH_VOICE_IOH_SEL_DESC);
+
ALIAS_DEPRECATED(cfg_ms_tch_no_voice_io_handler,
cfg_ms_tch_no_io_handler_cmd,
"no io-handler",
@@ -2564,7 +2612,7 @@

DEFUN(cfg_ms_tch_io_tch_format, cfg_ms_tch_io_tch_format_cmd,
"io-tch-format (osmo|rtp|ti)",
- "Set TCH I/O frame format used by the L1 PHY (for GAPK only)\n"
+ "Set TCH I/O frame format used by the L1 PHY\n"
"Osmocom format (RFC3551 for FR/EFR, RFC5993 for HR, RFC4867 for AMR)\n"
"(same as 'osmo', kept for backwards-compatibility)\n"
"Texas Instruments format, used by Calypso based phones (e.g. Motorola C1xx)\n")
@@ -2573,11 +2621,6 @@
struct osmocom_ms *ms = (struct osmocom_ms *) vty->index;
struct gsm_settings *set = &ms->settings;

- if (set->tch.voice_handler != TCH_VOICE_IOH_GAPK) {
- vty_out(vty, "This parameter is only valid for GAPK%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
OSMO_ASSERT(val >= 0);
set->tch.frame_format = val;

@@ -2612,6 +2655,20 @@
return CMD_SUCCESS;
}

+DEFUN(cfg_ms_tch_data_sock,
+ cfg_ms_tch_data_sock_cmd,
+ "data-unix-socket PATH",
+ "Define UNIX socket path (for 'data-io-handler unix-sock')\n"
+ "UNIX socket path (default '/tmp/ms_data_' + MS_NAME)\n")
+{
+ struct osmocom_ms *ms = vty->index;
+ struct gsm_settings *set = &ms->settings;
+
+ OSMO_STRLCPY_ARRAY(set->tch.data_socket_path, argv[0]);
+
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_ms_script_load_run, cfg_ms_script_load_run_cmd, "lua-script FILENAME",
"Load and execute a LUA script\nFilename for lua script")
{
@@ -2871,12 +2928,15 @@

install_node(&tch_node, config_write_dummy);
install_element(TCH_NODE, &cfg_ms_tch_voice_io_handler_cmd);
+ install_element(TCH_NODE, &cfg_ms_tch_data_io_handler_cmd);
install_element(TCH_NODE, &cfg_ms_tch_no_voice_io_handler_cmd);
+ install_element(TCH_NODE, &cfg_ms_tch_no_data_io_handler_cmd);
install_element(TCH_NODE, &cfg_ms_tch_io_handler_cmd);
install_element(TCH_NODE, &cfg_ms_tch_no_io_handler_cmd);
install_element(TCH_NODE, &cfg_ms_tch_io_tch_format_cmd);
install_element(TCH_NODE, &cfg_ms_tch_alsa_out_dev_cmd);
install_element(TCH_NODE, &cfg_ms_tch_alsa_in_dev_cmd);
+ install_element(TCH_NODE, &cfg_ms_tch_data_sock_cmd);

return 0;
}

To view, visit change 34915. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: If52fa70cb202f0736a17fe8eb63d226186637f62
Gerrit-Change-Number: 34915
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-MessageType: newchange