fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/34915?usp=email )

Change subject: mobile: add params and VTY commands for data calls
......................................................................

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/include/osmocom/bb/mobile/vty.h
M src/host/layer23/src/common/settings.c
M src/host/layer23/src/mobile/vty_interface.c
4 files changed, 162 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve




diff --git a/src/host/layer23/include/osmocom/bb/common/settings.h 
b/src/host/layer23/include/osmocom/bb/common/settings.h
index 458828a..3873611 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 format for voice calls */
 enum tch_voice_io_format {
        /* RFC3551 for FR/EFR, RFC5993 for HR, RFC4867 for AMR */
@@ -56,6 +70,18 @@
 static inline const char *tch_voice_io_format_name(enum tch_voice_io_format 
val)
 { return get_value_string(tch_voice_io_format_names, val); }

+/* TCH I/O format for data calls */
+enum tch_data_io_format {
+       /* Osmocom format, used by trxcon and virtphy */
+       TCH_DATA_IOF_OSMO,
+       /* Texas Instruments format, used by Calypso based phones (e.g. 
Motorola C1xx) */
+       TCH_DATA_IOF_TI,
+};
+
+extern const struct value_string tch_data_io_format_names[];
+static inline const char *tch_data_io_format_name(enum tch_data_io_format val)
+{ return get_value_string(tch_data_io_format_names, val); }
+
 struct tch_voice_settings {
        enum tch_voice_io_handler io_handler;
        enum tch_voice_io_format io_format;
@@ -63,6 +89,12 @@
        char alsa_input_dev[128];
 };
 
+struct tch_data_settings {
+       enum tch_data_io_handler io_handler;
+       enum tch_data_io_format io_format;
+       char unix_socket_path[128];
+};
+
 struct test_sim_settings {
        char                    imsi[OSMO_IMSI_BUF_SIZE];
        uint32_t                tmsi;
@@ -123,6 +155,7 @@

        /* TCH settings */
        struct tch_voice_settings tch_voice;
+       struct tch_data_settings tch_data;

        /* IMEI */
        char                    imei[GSM23003_IMEI_NUM_DIGITS + 1];
diff --git a/src/host/layer23/include/osmocom/bb/mobile/vty.h 
b/src/host/layer23/include/osmocom/bb/mobile/vty.h
index b681440..f03012e 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/vty.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/vty.h
@@ -11,6 +11,7 @@
 enum ms_vty_node {
        SUPPORT_NODE = _LAST_L23VTY_NODE + 1,
        TCH_VOICE_NODE,
+       TCH_DATA_NODE,
        VGCS_NODE,
        VBS_NODE,
 };
diff --git a/src/host/layer23/src/common/settings.c 
b/src/host/layer23/src/common/settings.c
index f251833..3fca52d 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)
@@ -54,6 +55,13 @@
        OSMO_STRLCPY_ARRAY(set->tch_voice.alsa_output_dev, alsa_dev_default);
        OSMO_STRLCPY_ARRAY(set->tch_voice.alsa_input_dev, alsa_dev_default);

+       /* TCH data: drop frames by default */
+       set->tch_data.io_handler = TCH_DATA_IOH_NONE;
+       set->tch_data.io_format = TCH_DATA_IOF_OSMO;
+       snprintf(set->tch_data.unix_socket_path,
+                sizeof(set->tch_data.unix_socket_path) - 1,
+                "%s_%s", data_socket_path, ms->name);
+
        /* Built-in MNCC handler */
        set->mncc_handler = MNCC_HANDLER_INTERNAL;

@@ -236,12 +244,24 @@
        { 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_voice_io_format_names[] = {
        { TCH_VOICE_IOF_RTP,            "rtp" },
        { TCH_VOICE_IOF_TI,             "ti" },
        { 0, NULL }
 };

+const struct value_string tch_data_io_format_names[] = {
+       { TCH_DATA_IOF_OSMO,            "osmo" },
+       { TCH_DATA_IOF_TI,              "ti" },
+       { 0, NULL }
+};

 int gprs_settings_init(struct osmocom_ms *ms)
 {
diff --git a/src/host/layer23/src/mobile/vty_interface.c 
b/src/host/layer23/src/mobile/vty_interface.c
index d6bac5a..6293768 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -55,6 +55,12 @@
        1
 };

+struct cmd_node tch_data_node = {
+       TCH_DATA_NODE,
+       "%s(tch-data)# ",
+       1
+};
+
 struct cmd_node vgcs_node = {
        VGCS_NODE,
        "%s(group-call)# ",
@@ -1487,6 +1493,16 @@
                        &set->tch_voice.alsa_input_dev[0], VTY_NEWLINE);
        }

+       vty_out(vty, " tch-data%s", VTY_NEWLINE);
+       vty_out(vty, "  io-handler %s%s",
+               tch_data_io_handler_name(set->tch_data.io_handler), 
VTY_NEWLINE);
+       vty_out(vty, "  io-tch-format %s%s",
+               tch_data_io_format_name(set->tch_data.io_format), VTY_NEWLINE);
+       if (set->tch_data.io_handler == TCH_DATA_IOH_UNIX_SOCK) {
+               vty_out(vty, "  unix-socket %s%s",
+                       set->tch_data.unix_socket_path, VTY_NEWLINE);
+       }
+
        if (ms->lua_script)
                vty_out(vty, " lua-script %s%s", ms->lua_script, VTY_NEWLINE);

@@ -2592,6 +2608,81 @@
        return CMD_SUCCESS;
 }

+DEFUN(cfg_ms_tch_data,
+      cfg_ms_tch_data_cmd,
+      "tch-data", "Configure TCH (Traffic CHannel) params for data calls\n")
+{
+       vty->node = TCH_DATA_NODE;
+       return CMD_SUCCESS;
+}
+
+static int set_tch_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.io_handler)
+               return CMD_SUCCESS;
+       set->tch_data.io_handler = val;
+
+       /* Restart required */
+       vty_restart_if_started(vty, ms);
+
+       return CMD_SUCCESS;
+}
+
+DEFUN(cfg_ms_tch_data_io_handler,
+      cfg_ms_tch_data_io_handler_cmd,
+      "io-handler (none|unix-sock|loopback)",
+      "Set TCH frame I/O handler for data calls\n"
+      "No handler, drop TCH frames (default)\n"
+      "UNIX socket (path set by 'data-unix-socket')\n"
+      "Return TCH frame payload back to sender\n")
+{
+       int val = get_string_value(tch_data_io_handler_names, argv[0]);
+
+       return set_tch_data_io_handler(vty, val);
+}
+
+DEFUN(cfg_ms_tch_data_no_io_handler,
+      cfg_ms_tch_data_no_io_handler_cmd,
+      "no io-handler", NO_STR "Disable TCH frame handling for data calls\n")
+{
+       return set_tch_data_io_handler(vty, TCH_DATA_IOH_NONE);
+}
+
+DEFUN(cfg_ms_tch_data_io_tch_format,
+      cfg_ms_tch_data_io_tch_format_cmd,
+      "io-tch-format (osmo|ti)",
+      "Set TCH I/O frame format used by the L1 PHY\n"
+      "Osmocom format used by both trxcon and viryphy (default)\n"
+      "Texas Instruments format, used by Calypso based phones (e.g. Motorola 
C1xx)\n")
+{
+       int val = get_string_value(tch_data_io_format_names, argv[0]);
+       struct osmocom_ms *ms = (struct osmocom_ms *)vty->index;
+       struct gsm_settings *set = &ms->settings;
+
+       OSMO_ASSERT(val >= 0);
+       set->tch_data.io_format = val;
+
+       return CMD_SUCCESS;
+}
+
+DEFUN(cfg_ms_tch_data_unix_sock,
+      cfg_ms_tch_data_unix_sock_cmd,
+      "unix-socket PATH",
+      "Define UNIX socket path (for 'io-handler unix-sock')\n"
+      "UNIX socket path (default '/tmp/ms_data_' + MS_NAME)\n")
+{
+       struct osmocom_ms *ms = (struct osmocom_ms *)vty->index;
+       struct gsm_settings *set = &ms->settings;
+
+       OSMO_STRLCPY_ARRAY(set->tch_data.unix_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")
 {
@@ -2765,6 +2856,7 @@
        install_element(MS_NODE, &cfg_ms_no_abbrev_cmd);
        install_element(MS_NODE, &cfg_ms_tch_voice_cmd);
        install_element(MS_NODE, &cfg_ms_audio_cmd);
+       install_element(MS_NODE, &cfg_ms_tch_data_cmd);
        install_element(MS_NODE, &cfg_ms_neighbour_cmd);
        install_element(MS_NODE, &cfg_ms_no_neighbour_cmd);
        install_element(MS_NODE, &cfg_ms_any_timeout_cmd);
@@ -2856,6 +2948,12 @@
        install_element(TCH_VOICE_NODE, &cfg_ms_tch_voice_alsa_out_dev_cmd);
        install_element(TCH_VOICE_NODE, &cfg_ms_tch_voice_alsa_in_dev_cmd);

+       install_node(&tch_data_node, config_write_dummy);
+       install_element(TCH_DATA_NODE, &cfg_ms_tch_data_io_handler_cmd);
+       install_element(TCH_DATA_NODE, &cfg_ms_tch_data_no_io_handler_cmd);
+       install_element(TCH_DATA_NODE, &cfg_ms_tch_data_io_tch_format_cmd);
+       install_element(TCH_DATA_NODE, &cfg_ms_tch_data_unix_sock_cmd);
+
        return 0;
 }


--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/34915?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: If52fa70cb202f0736a17fe8eb63d226186637f62
Gerrit-Change-Number: 34915
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: jolly <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to