add osmo-msc --vty-ref-xml: dump VTY ref XML to stdout
Add only a long option to not clutter the cmdline namespace. To add a long option without a short letter is slightly complex: use the 'flag' and 'val' mechanism as in 'man 3 getopt' to write an option index to long_option. Make sure that all VTY commands have been added before parsing cmdline options: move various VTY init further above. For msc_vty_init(), the global msc_network already needs to be allocated, so also move that. Depends: Ic74bbdb6dc5ea05f03c791cc70184861e39cd492 (libosmocore) Change-Id: I9146d5a44427509265420f52ae6540ad93eb14fc
This commit is contained in:
parent
7da956e4c6
commit
a509a22b9e
|
@ -131,12 +131,14 @@ static void print_help()
|
||||||
printf(" -V --version Print the version of OsmoMSC.\n");
|
printf(" -V --version Print the version of OsmoMSC.\n");
|
||||||
printf(" -e --log-level number Set a global loglevel.\n");
|
printf(" -e --log-level number Set a global loglevel.\n");
|
||||||
printf(" -M --mncc-sock-path PATH Disable built-in MNCC handler and offer socket.\n");
|
printf(" -M --mncc-sock-path PATH Disable built-in MNCC handler and offer socket.\n");
|
||||||
|
printf(" --vty-ref-xml Generate the VTY reference XML output and exit.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_options(int argc, char **argv)
|
static void handle_options(int argc, char **argv)
|
||||||
{
|
{
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0, c;
|
int option_index = 0, c;
|
||||||
|
static int long_option = 0;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"help", 0, 0, 'h'},
|
{"help", 0, 0, 'h'},
|
||||||
{"debug", 1, 0, 'd'},
|
{"debug", 1, 0, 'd'},
|
||||||
|
@ -149,6 +151,7 @@ static void handle_options(int argc, char **argv)
|
||||||
{"log-level", 1, 0, 'e'},
|
{"log-level", 1, 0, 'e'},
|
||||||
{"mncc-sock-path", 1, 0, 'M'},
|
{"mncc-sock-path", 1, 0, 'M'},
|
||||||
{"no-dbcounter", 0, 0, 'C'}, /* deprecated */
|
{"no-dbcounter", 0, 0, 'C'}, /* deprecated */
|
||||||
|
{"vty-ref-xml", 0, &long_option, 1},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -162,6 +165,15 @@ static void handle_options(int argc, char **argv)
|
||||||
print_usage();
|
print_usage();
|
||||||
print_help();
|
print_help();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
case 0:
|
||||||
|
switch (long_option) {
|
||||||
|
case 1:
|
||||||
|
vty_dump_xml_ref(stdout);
|
||||||
|
exit(0);
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "error parsing cmdline options\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
case 's':
|
case 's':
|
||||||
log_set_use_color(osmo_stderr_target, 0);
|
log_set_use_color(osmo_stderr_target, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -534,9 +546,9 @@ int main(int argc, char **argv)
|
||||||
OSMO_ASSERT(osmo_ss7_init() == 0);
|
OSMO_ASSERT(osmo_ss7_init() == 0);
|
||||||
osmo_ss7_vty_init_asp(tall_msc_ctx);
|
osmo_ss7_vty_init_asp(tall_msc_ctx);
|
||||||
osmo_sccp_vty_init();
|
osmo_sccp_vty_init();
|
||||||
|
ctrl_vty_init(tall_msc_ctx);
|
||||||
/* Parse options */
|
logging_vty_add_cmds();
|
||||||
handle_options(argc, argv);
|
osmo_talloc_vty_add_cmds();
|
||||||
|
|
||||||
/* Allocate global gsm_network struct.
|
/* Allocate global gsm_network struct.
|
||||||
* At first set the internal MNCC as default, may be changed below according to cfg or cmdline option. */
|
* At first set the internal MNCC as default, may be changed below according to cfg or cmdline option. */
|
||||||
|
@ -544,6 +556,11 @@ int main(int argc, char **argv)
|
||||||
if (!msc_network)
|
if (!msc_network)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
msc_vty_init(msc_network);
|
||||||
|
|
||||||
|
/* Parse options */
|
||||||
|
handle_options(argc, argv);
|
||||||
|
|
||||||
call_leg_init(msc_network);
|
call_leg_init(msc_network);
|
||||||
mncc_call_fsm_init(msc_network);
|
mncc_call_fsm_init(msc_network);
|
||||||
|
|
||||||
|
@ -552,11 +569,6 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrl_vty_init(tall_msc_ctx);
|
|
||||||
logging_vty_add_cmds();
|
|
||||||
osmo_talloc_vty_add_cmds();
|
|
||||||
msc_vty_init(msc_network);
|
|
||||||
|
|
||||||
#ifdef BUILD_SMPP
|
#ifdef BUILD_SMPP
|
||||||
if (smpp_openbsc_alloc_init(tall_msc_ctx) < 0)
|
if (smpp_openbsc_alloc_init(tall_msc_ctx) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue