Hello Vadim Yanitskiy, Pau Espin Pedrol, Max, Jenkins Builder,

I'd like you to do a code review. Please visit

    https://gerrit.osmocom.org/12208

to review the following change.


Change subject: Revert "mobile: use VTY bind addr from config, deprecate cmd 
line options"
......................................................................

Revert "mobile: use VTY bind addr from config, deprecate cmd line options"

--vty-port=0 is a desirable "feature" and used by the ms_driver of the
osmo-gsm-tester. It let's the kernel pick a free port for the application
and by printing it on stdout one can still discover it. It allows to start
many "mobile" without having to worry about IP address assignment
(e.g. 127.0.0.23, 127.0.0.24).

I don't think there is a way to configure the port right now. This change
should be submitted once vty.c has a option to specify the address and
optionally the port.

This reverts commit da96b3c0aed7a63772faee91b7056dd0b3d72890.

Change-Id: Ie89bc16b667dbe05baa76cfa4f86b4946f8019e8
---
M src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
M src/host/layer23/src/mobile/app_mobile.c
M src/host/layer23/src/mobile/main.c
3 files changed, 20 insertions(+), 19 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/08/12208/1

diff --git a/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h 
b/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
index 191f4ba..c2ab3c8 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
@@ -9,7 +9,7 @@
 struct vty;

 int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *),
-       const char *config_file);
+       const char *config_file, const char *vty_ip, uint16_t vty_port);
 int l23_app_exit(void);
 int l23_app_work(int *quit);
 int mobile_delete(struct osmocom_ms *ms, int force);
diff --git a/src/host/layer23/src/mobile/app_mobile.c 
b/src/host/layer23/src/mobile/app_mobile.c
index a051fba..464cd55 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -39,8 +39,6 @@
 #include <osmocom/bb/mobile/voice.h>
 #include <osmocom/bb/mobile/primitives.h>
 #include <osmocom/bb/common/sap_interface.h>
-
-#include <osmocom/vty/ports.h>
 #include <osmocom/vty/logging.h>
 #include <osmocom/vty/telnet_interface.h>

@@ -436,7 +434,7 @@

 /* global init */
 int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *),
-       const char *config_file)
+       const char *config_file, const char *vty_ip, uint16_t vty_port)
 {
        struct telnet_connection dummy_conn;
        int rc = 0;
@@ -464,11 +462,10 @@
                LOGP(DMOB, LOGL_INFO, "Using configuration from '%s'\n", 
config_file);
        }
        vty_reading = 0;
-       rc = telnet_init_dynif(l23_ctx, NULL,
-               vty_get_bind_addr(), OSMO_VTY_PORT_BB);
+       rc = telnet_init_dynif(l23_ctx, NULL, vty_ip, vty_port);
        if (rc < 0) {
                LOGP(DMOB, LOGL_FATAL, "Cannot init VTY on %s port %u: %s\n",
-                       vty_get_bind_addr(), OSMO_VTY_PORT_BB, strerror(errno));
+                       vty_ip, vty_port, strerror(errno));
                return rc;
        }

diff --git a/src/host/layer23/src/mobile/main.c 
b/src/host/layer23/src/mobile/main.c
index 9764b33..e015c30 100644
--- a/src/host/layer23/src/mobile/main.c
+++ b/src/host/layer23/src/mobile/main.c
@@ -51,6 +51,8 @@
 static char *gsmtap_ip = 0;
 static const char *custom_cfg_file = NULL;
 struct gsmtap_inst *gsmtap_inst = NULL;
+static char *vty_ip = "127.0.0.1";
+unsigned short vty_port = 4247;
 char *config_dir = NULL;
 int use_mncc_sock = 0;
 int daemonize = 0;
@@ -85,6 +87,10 @@
        printf(" Some help...\n");
        printf("  -h --help             this text\n");
        printf("  -i --gsmtap-ip        The destination IP used for GSMTAP.\n");
+       printf("  -u --vty-ip           The VTY IP to telnet to. "
+               "(default %s)\n", vty_ip);
+       printf("  -v --vty-port         The VTY port number to telnet to. "
+               "(default %u)\n", vty_port);
        printf("  -d --debug            Change debug flags. default: %s\n",
                debug_default);
        printf("  -D --daemonize        Run as daemon\n");
@@ -100,13 +106,12 @@
                static struct option long_options[] = {
                        {"help", 0, 0, 'h'},
                        {"gsmtap-ip", 1, 0, 'i'},
+                       {"vty-ip", 1, 0, 'u'},
+                       {"vty-port", 1, 0, 'v'},
                        {"debug", 1, 0, 'd'},
                        {"daemonize", 0, 0, 'D'},
                        {"config-file", 1, 0, 'c'},
                        {"mncc-sock", 0, 0, 'm'},
-                       /* DEPRECATED options, to be removed */
-                       {"vty-ip", 1, 0, 'u'},
-                       {"vty-port", 1, 0, 'v'},
                        {0, 0, 0, 0},
                };

@@ -124,9 +129,15 @@
                case 'i':
                        gsmtap_ip = optarg;
                        break;
+               case 'u':
+                       vty_ip = optarg;
+                       break;
                case 'c':
                        custom_cfg_file = optarg;
                        break;
+               case 'v':
+                       vty_port = atoi(optarg);
+                       break;
                case 'd':
                        log_parse_category_mask(osmo_stderr_target, optarg);
                        break;
@@ -136,13 +147,6 @@
                case 'm':
                        use_mncc_sock = 1;
                        break;
-               /* DEPRECATED options, to be removed */
-               case 'u':
-               case 'v':
-                       fprintf(stderr, "Both 'u' and 'v' options are "
-                               "deprecated! Please use the configuration file "
-                               "in order to set VTY bind address.\n");
-                       /* fall-thru */
                default:
                        /* Unknown parameter passed */
                        return -EINVAL;
@@ -251,9 +255,9 @@
        config_dir = dirname(config_dir);

        if (use_mncc_sock)
-               rc = l23_app_init(mncc_recv_socket, config_file);
+               rc = l23_app_init(mncc_recv_socket, config_file, vty_ip, 
vty_port);
        else
-               rc = l23_app_init(NULL, config_file);
+               rc = l23_app_init(NULL, config_file, vty_ip, vty_port);
        if (rc)
                exit(rc);


--
To view, visit https://gerrit.osmocom.org/12208
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie89bc16b667dbe05baa76cfa4f86b4946f8019e8
Gerrit-Change-Number: 12208
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Freyther <hol...@freyther.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msur...@sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pes...@sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilira...@gmail.com>

Reply via email to