From 41b6803fd5d69b3a0f126e75d7734425c57644ee Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 27 Jul 2017 14:33:46 +0200 Subject: osmo_ss7_vty_init: ensure a talloc ctx is set by user Drop the separate osmo_ss7_set_vty_alloc_ctx() because we are likely to forget calling it. Instead, incorporate into osmo_ss7_vty_init_*() with a new ctx arg, and set the static context var in vty_init_shared(). Change-Id: Id4e7f47979001f7856b0b3665c9e94982e75e490 --- examples/m3ua_example.c | 2 +- include/osmocom/sigtran/osmo_ss7.h | 5 ++--- src/osmo_ss7_vty.c | 17 +++++++---------- stp/stp_main.c | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/examples/m3ua_example.c b/examples/m3ua_example.c index d3c6a7c..6c2b146 100644 --- a/examples/m3ua_example.c +++ b/examples/m3ua_example.c @@ -92,7 +92,7 @@ int main(int argc, char **argv) osmo_ss7_init(); osmo_fsm_log_addr(false); vty_init(&vty_info); - osmo_ss7_vty_init_asp(); + osmo_ss7_vty_init_asp(NULL); osmo_sccp_vty_init(); if (argc <= 1) diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 87ace4a..bbe425c 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -471,8 +471,7 @@ int osmo_ss7_tmode_to_xua(enum osmo_ss7_as_traffic_mode tmod); /* VTY related */ struct vty; -void osmo_ss7_set_vty_alloc_ctx(void *ctx); -void osmo_ss7_vty_init_asp(void); -void osmo_ss7_vty_init_sg(void); +void osmo_ss7_vty_init_asp(void *ctx); +void osmo_ss7_vty_init_sg(void *ctx); int osmo_ss7_vty_go_parent(struct vty *vty); int osmo_ss7_is_config_node(struct vty *vty, int node); diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index c859eb9..476aedf 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -1661,8 +1661,10 @@ static void vty_init_addr(void) install_element(L_CS7_SCCPADDR_GT_NODE, &cs7_sccpaddr_gt_digits_cmd); } -static void vty_init_shared(void) +static void vty_init_shared(void *ctx) { + g_ctx = ctx; + install_element_ve(&show_cs7_user_cmd); /* the mother of all VTY config nodes */ @@ -1706,14 +1708,14 @@ static void vty_init_shared(void) vty_init_addr(); } -void osmo_ss7_vty_init_asp(void) +void osmo_ss7_vty_init_asp(void *ctx) { - vty_init_shared(); + vty_init_shared(ctx); } -void osmo_ss7_vty_init_sg(void) +void osmo_ss7_vty_init_sg(void *ctx) { - vty_init_shared(); + vty_init_shared(ctx); install_node(&rtable_node, NULL); vty_install_default(L_CS7_RTABLE_NODE); @@ -1730,8 +1732,3 @@ void osmo_ss7_vty_init_sg(void) install_element(L_CS7_XUA_NODE, &xua_local_ip_cmd); install_element(L_CS7_XUA_NODE, &xua_accept_dyn_asp_cmd); } - -void osmo_ss7_set_vty_alloc_ctx(void *ctx) -{ - g_ctx = ctx; -}; diff --git a/stp/stp_main.c b/stp/stp_main.c index 074272b..ac8e6dd 100644 --- a/stp/stp_main.c +++ b/stp/stp_main.c @@ -137,7 +137,7 @@ int main(int argc, char **argv) osmo_ss7_init(); osmo_fsm_log_addr(false); logging_vty_add_cmds(&log_info); - osmo_ss7_vty_init_sg(); + osmo_ss7_vty_init_sg(NULL); osmo_fsm_vty_add_cmds(); rc = vty_read_config_file(cmdline_config.config_file, NULL); -- cgit v1.2.3