ss7: Provide a way to start the application
This commit is contained in:
parent
a7bc3aafdc
commit
ab7c601118
|
@ -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
|
||||
|
|
33
src/links.c
33
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Reference in New Issue