layer23: fix parsing of command line options
After the recent refactoring, parsing of the command line options is broken for some arguments. Specifically, the value of '-a'/'--arfcn' is ignored and hard-coded ARFCN=871 is used instead. The problem is that l23_app_init(), which allocates an MS state and sets the initial ARFCN, is called *before* handle_options(). So the cfg_test_arfcn is used before it gets overwritten from the argv[]. The usual approach in osmo-* apps is to parse the command line arguments first, and only then execute code which depends on configurable parameters. Let's follow this approach too. Change-Id: I77ca11c14561fa3fcb9add60ccea5b0b847a20c4
This commit is contained in:
parent
9feb5057da
commit
67943df4b7
|
@ -254,14 +254,14 @@ int main(int argc, char **argv)
|
|||
|
||||
print_copyright();
|
||||
|
||||
handle_options(argc, argv);
|
||||
|
||||
rc = l23_app_init();
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed during l23_app_init()\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
handle_options(argc, argv);
|
||||
|
||||
if (l23_app_info.opt_supported & L23_OPT_VTY) {
|
||||
if (_vty_init() < 0)
|
||||
exit(1);
|
||||
|
|
|
@ -255,6 +255,12 @@ int main(int argc, char **argv)
|
|||
|
||||
print_copyright();
|
||||
|
||||
rc = handle_options(argc, argv);
|
||||
if (rc) { /* Abort in case of parsing errors */
|
||||
fprintf(stderr, "Error in command line options. Exiting.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
INIT_LLIST_HEAD(&ms_list);
|
||||
|
@ -272,12 +278,6 @@ int main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
rc = handle_options(argc, argv);
|
||||
if (rc) { /* Abort in case of parsing errors */
|
||||
fprintf(stderr, "Error in command line options. Exiting.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (custom_cfg_file) {
|
||||
/* Use full path provided by user */
|
||||
config_file = talloc_strdup(l23_ctx, custom_cfg_file);
|
||||
|
|
Loading…
Reference in New Issue