[layer23] Added option argument to alter default VTY port number.
authorAndreas.Eversberg <jolly@eversberg.eu>
Sat, 26 Jun 2010 22:27:38 +0000 (22:27 +0000)
committerAndreas.Eversberg <jolly@eversberg.eu>
Sat, 26 Jun 2010 22:27:38 +0000 (22:27 +0000)
src/host/layer23/src/app_mobile.c
src/host/layer23/src/main.c

index a40d382..52100e0 100644 (file)
@@ -46,6 +46,7 @@
 extern struct log_target *stderr_target;
 static const char *config_file = "/etc/osmocom/osmocom.cfg";
 extern void *l23_ctx;
+extern unsigned short vty_port;
 
 static int started = 0;
 
@@ -177,12 +178,14 @@ int l23_app_init(struct osmocom_ms *ms)
                        "'touch %s%s'\n", OSMOCOM_CONFDIR, config_file);
                return rc;
        }
-       telnet_init(l23_ctx, NULL, 4247);
+       telnet_init(l23_ctx, NULL, vty_port);
        if (rc < 0)
                return rc;
+       printf("VTY available on port %u.\n", vty_port);
 
        gsm_random_imei(&ms->settings);
 
+       printf("Mobile initialized, please start phone now!\n");
        return 0;
 }
 
index 4aa9bf1..1816e15 100644 (file)
@@ -52,6 +52,7 @@ static char *socket_path = "/tmp/osmocom_l2";
 struct llist_head ms_list;
 static struct osmocom_ms *ms = NULL;
 static uint32_t gsmtap_ip = 0;
+unsigned short vty_port = 4247;
 int (*l23_app_work) (struct osmocom_ms *ms) = NULL;
 int (*l23_app_exit) (struct osmocom_ms *ms) = NULL;
 int quit = 0;
@@ -59,7 +60,8 @@ int quit = 0;
 const char *openbsc_copyright =
        "Copyright (C) 2008-2010 ...\n"
        "Contributions by ...\n\n"
-       "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n"
+       "License GPLv2+: GNU GPL version 2 or later "
+               "<http://gnu.org/licenses/gpl.html>\n"
        "This is free software: you are free to change and redistribute it.\n"
        "There is NO WARRANTY, to the extent permitted by law.\n";
 
@@ -72,9 +74,13 @@ static void print_help()
 {
        printf(" Some help...\n");
        printf("  -h --help             this text\n");
-       printf("  -s --socket           /tmp/osmocom_l2. Path to the unix domain socket\n");
+       printf("  -s --socket           /tmp/osmocom_l2. Path to the unix "
+               "domain socket\n");
        printf("  -a --arfcn NR         The ARFCN to be used for layer2.\n");
        printf("  -i --gsmtap-ip        The destination IP used for GSMTAP.\n");
+       printf("  -v --vty-port         The VTY port number to telnet to. "
+               "(default %u)\n", vty_port);
+       printf("  -d --debug            Change debug flags.\n");
 }
 
 static void handle_options(int argc, char **argv)
@@ -87,18 +93,18 @@ static void handle_options(int argc, char **argv)
                        {"socket", 1, 0, 's'},
                        {"arfcn", 1, 0, 'a'},
                        {"gsmtap-ip", 1, 0, 'i'},
+                       {"vty-port", 1, 0, 'v'},
                        {"debug", 1, 0, 'd'},
                        {0, 0, 0, 0},
                };
 
-               c = getopt_long(argc, argv, "hs:a:i:d:",
+               c = getopt_long(argc, argv, "hs:a:i:v:d:",
                                long_options, &option_index);
                if (c == -1)
                        break;
 
                switch (c) {
                case 'h':
-                       printf("%s\n", openbsc_copyright);
                        print_usage(argv[0]);
                        print_help();
                        exit(0);
@@ -116,6 +122,9 @@ static void handle_options(int argc, char **argv)
                        }
                        gsmtap_ip = ntohl(gsmtap.sin_addr.s_addr);
                        break;
+               case 'v':
+                       vty_port = atoi(optarg);
+                       break;
                case 'd':
                        log_parse_category_mask(stderr_target, optarg);
                        break;
@@ -144,6 +153,8 @@ int main(int argc, char **argv)
 {
        int rc;
 
+       printf("%s\n", openbsc_copyright);
+
        INIT_LLIST_HEAD(&ms_list);
        log_init(&log_info);
        stderr_target = log_target_create_stderr();