From ab7c601118ef19414e8c83fe7f93415f5061b04c Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 16 Feb 2011 22:23:52 +0100 Subject: ss7: Provide a way to start the application --- include/ss7_application.h | 2 ++ src/links.c | 33 --------------------------------- src/main.c | 1 + src/main_stp.c | 4 +--- src/ss7_application.c | 33 +++++++++++++++++++++++++++++++-- 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/include/ss7_application.h b/include/ss7_application.h index 76117e6..51426b5 100644 --- a/include/ss7_application.h +++ b/include/ss7_application.h @@ -79,4 +79,6 @@ int ss7_application_setup(struct ss7_application *, int type, int src_type, int src_num, int dst_type, int dst_num); +int ss7_application_start(struct ss7_application *); + #endif diff --git a/src/links.c b/src/links.c index 2a72b46..a3874be 100644 --- a/src/links.c +++ b/src/links.c @@ -86,23 +86,6 @@ void mtp_link_restart(struct mtp_link *link) link->reset(link); } -static void start_rest(void *_set) -{ - struct msc_connection *msc; - struct mtp_link_set *set = _set; - struct mtp_link *data; - bsc->setup = 1; - - msc = msc_connection_num(bsc, 0); - if (msc && msc_connection_start(msc) != 0) { - fprintf(stderr, "Failed to init MSC part.\n"); - exit(3); - } - - llist_for_each_entry(data, &set->links, entry) - data->start(data); -} - struct mtp_link_set *link_init(struct bsc_data *bsc) { int i; @@ -145,24 +128,8 @@ struct mtp_link_set *link_init(struct bsc_data *bsc) /* now connect to the transport */ if (link_udp_init(lnk, bsc->udp_ip, bsc->udp_port) != 0) return NULL; - - /* - * We will ask the MTP link to be taken down for two - * timeouts of the BSC to make sure we are missing the - * SLTM and it begins a reset. Then we will take it up - * again and do the usual business. - */ - snmp_mtp_deactivate(lnk->session, - lnk->link_index); - LOGP(DMSC, LOGL_NOTICE, - "Forcing link alignment on %s/%d.\n", - lnk->base.set->name, lnk->base.link_no); } - bsc->start_timer.cb = start_rest; - bsc->start_timer.data = set; - bsc_schedule_timer(&bsc->start_timer, bsc->udp_reset_timeout, 0); - return set; } diff --git a/src/main.c b/src/main.c index 8cc37d4..ab9ddfc 100644 --- a/src/main.c +++ b/src/main.c @@ -237,6 +237,7 @@ int main(int argc, char **argv) ss7_application_setup(app, APP_CELLMGR, SS7_SET_LINKSET, 0, SS7_SET_MSC, 0); + ss7_application_start(app); while (1) { bsc_select_main(0); diff --git a/src/main_stp.c b/src/main_stp.c index 77a90f0..594e2b0 100644 --- a/src/main_stp.c +++ b/src/main_stp.c @@ -322,7 +322,6 @@ static int inject_init(struct bsc_data *bsc) int main(int argc, char **argv) { int rc; - struct mtp_link *data; struct mtp_link_set *set; struct mtp_link_set *m2ua_set; struct mtp_m2ua_link *lnk; @@ -408,8 +407,7 @@ int main(int argc, char **argv) SS7_SET_LINKSET, 0, SS7_SET_LINKSET, 1); - llist_for_each_entry(data, &m2ua_set->links, entry) - data->start(data); + ss7_application_start(app); while (1) { bsc_select_main(0); diff --git a/src/ss7_application.c b/src/ss7_application.c index 49ae4c1..1eb7ec9 100644 --- a/src/ss7_application.c +++ b/src/ss7_application.c @@ -127,7 +127,6 @@ static int ss7_app_setup_stp(struct ss7_application *app, app->type = APP_STP; app->bsc->m2ua_trans->started = 1; - /* TODO: start the applications here */ return 0; } @@ -202,7 +201,6 @@ static int ss7_app_setup_relay(struct ss7_application *app, int type, app->type = type; - /* TODO: start the applications here */ return 0; } @@ -225,3 +223,34 @@ int ss7_application_setup(struct ss7_application *ss7, int type, return -1; } } + + +static void start_mtp(struct mtp_link_set *set) +{ + struct mtp_link *link; + + llist_for_each_entry(link, &set->links, entry) + link->reset(link); +} + +static void start_msc(struct msc_connection *msc) +{ + msc_connection_start(msc); +} + +int ss7_application_start(struct ss7_application *app) +{ + if (app->route_src.set) + start_mtp(app->route_src.set); + if (app->route_dst.set) + start_mtp(app->route_dst.set); + + if (app->route_src.msc) + start_msc(app->route_src.msc); + if (app->route_dst.msc) + start_msc(app->route_dst.msc); + + LOGP(DINP, LOGL_NOTICE, "SS7 Application %d/%s is now running.\n", + app->nr, app->name); + return 0; +} -- cgit v1.2.3