9
0
Fork 0

ss7: Create a SS7 application that is responsible for the routing

This commit is contained in:
Holger Hans Peter Freyther 2011-02-16 16:12:07 +01:00
parent 2cdb73cf4a
commit a7bc3aafdc
15 changed files with 499 additions and 115 deletions

View File

@ -1,6 +1,6 @@
noinst_HEADERS = mtp_level3.h mtp_data.h ipaccess.h thread.h mtp_pcap.h \ noinst_HEADERS = mtp_level3.h mtp_data.h ipaccess.h thread.h mtp_pcap.h \
mgcp_ss7.h bss_patch.h bssap_sccp.h bsc_data.h udp_input.h \ mgcp_ss7.h bss_patch.h bssap_sccp.h bsc_data.h udp_input.h \
snmp_mtp.h cellmgr_debug.h bsc_sccp.h bsc_ussd.h sctp_m2ua.h \ snmp_mtp.h cellmgr_debug.h bsc_sccp.h bsc_ussd.h sctp_m2ua.h \
isup_types.h counter.h msc_connection.h isup_types.h counter.h msc_connection.h ss7_application.h
SUBDIRS = mgcp SUBDIRS = mgcp

View File

@ -67,12 +67,6 @@ struct mtp_udp_link {
struct snmp_mtp_session *session; struct snmp_mtp_session *session;
}; };
enum {
APP_CELLMGR,
APP_RELAY,
APP_STP,
};
struct bsc_data { struct bsc_data {
int app; int app;
@ -116,6 +110,10 @@ struct bsc_data {
/* MSCs */ /* MSCs */
struct llist_head mscs; struct llist_head mscs;
int num_mscs; int num_mscs;
/* application */
struct llist_head apps;
int num_apps;
}; };
/* bsc related functions */ /* bsc related functions */
@ -125,7 +123,6 @@ void mtp_linkset_down(struct mtp_link_set *);
void mtp_linkset_up(struct mtp_link_set *); void mtp_linkset_up(struct mtp_link_set *);
/* connection tracking and action */ /* connection tracking and action */
void update_con_state(struct msc_connection *msc, int rc, struct sccp_parse_result *result, struct msgb *msg, int from_msc, int sls);
/* udp init */ /* udp init */
int link_global_init(struct mtp_udp_data *data, int src_port); int link_global_init(struct mtp_udp_data *data, int src_port);

View File

@ -30,7 +30,7 @@
#include <osmocom/sccp/sccp.h> #include <osmocom/sccp/sccp.h>
struct msc_connection; struct ss7_application;
/* /*
* One SCCP connection. * One SCCP connection.
@ -55,7 +55,8 @@ struct active_sccp_con {
/* how often did we send a RLSD this */ /* how often did we send a RLSD this */
unsigned int rls_tries; unsigned int rls_tries;
/* MTP link this was coming in */ /* Link to the SS7 Application */
struct ss7_application *app;
struct mtp_link_set *link; struct mtp_link_set *link;
/* sls id */ /* sls id */
@ -63,10 +64,10 @@ struct active_sccp_con {
}; };
void free_con(struct active_sccp_con *con); void free_con(struct active_sccp_con *con);
struct active_sccp_con *find_con_by_dest_ref(struct msc_connection *, struct sccp_source_reference *ref); struct active_sccp_con *find_con_by_dest_ref(struct ss7_application *, struct sccp_source_reference *ref);
struct active_sccp_con *find_con_by_src_ref(struct msc_connection *,struct sccp_source_reference *src_ref); struct active_sccp_con *find_con_by_src_ref(struct ss7_application *,struct sccp_source_reference *src_ref);
struct active_sccp_con *find_con_by_src_dest_ref(struct msc_connection *, struct sccp_source_reference *src_ref, struct active_sccp_con *find_con_by_src_dest_ref(struct ss7_application *, struct sccp_source_reference *src_ref,
struct sccp_source_reference *dst_ref); struct sccp_source_reference *dst_ref);
unsigned int sls_for_src_ref(struct msc_connection *, struct sccp_source_reference *ref); unsigned int sls_for_src_ref(struct ss7_application *, struct sccp_source_reference *ref);
#endif #endif

View File

@ -55,16 +55,12 @@ struct msc_connection {
int pong_time; int pong_time;
struct timer_list ping_timeout; struct timer_list ping_timeout;
struct timer_list pong_timeout; struct timer_list pong_timeout;
struct timer_list reset_timeout;
/* mgcp messgaes */ /* mgcp messgaes */
struct write_queue mgcp_agent; struct write_queue mgcp_agent;
/* application pointer */ /* application pointer */
struct llist_head sccp_connections; struct ss7_application *app;
struct mtp_link_set *target_link;
int forward_only;
int reset_count;
}; };
/* msc related functions */ /* msc related functions */

View File

@ -25,10 +25,10 @@
#include <osmocore/utils.h> #include <osmocore/utils.h>
struct bsc_data; struct bsc_data;
struct msc_connection;
struct mtp_link; struct mtp_link;
struct mtp_level_3_mng *mng; struct mtp_level_3_mng *mng;
struct rate_ctr_group; struct rate_ctr_group;
struct ss7_application;
/* MTP Level3 timers */ /* MTP Level3 timers */
@ -76,8 +76,7 @@ struct mtp_link_set {
/* custom data */ /* custom data */
struct bsc_data *bsc; struct bsc_data *bsc;
struct msc_connection *fw; struct ss7_application *app;
struct mtp_link_set *forward;
}; };
/** /**

82
include/ss7_application.h Normal file
View File

@ -0,0 +1,82 @@
/* Stuff to handle the SS7 application */
/*
* (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SS7_APPLICATION_H
#define SS7_APPLICATION_H
#include <osmocore/linuxlist.h>
#include <osmocore/timer.h>
struct bsc_data;
struct msc_connection;
struct mtp_link_set;
struct mtp_link;
enum ss7_set_type {
SS7_SET_LINKSET,
SS7_SET_MSC,
};
enum ss7_app_type {
APP_CELLMGR,
APP_RELAY,
APP_STP,
};
struct ss7_application_route {
int type;
int nr;
/* maybe they were resolved */
struct mtp_link_set *set;
struct msc_connection *msc;
};
struct ss7_application {
/* handling */
struct llist_head entry;
int nr;
char *name;
/* app type */
int type;
/* for the routing */
struct ss7_application_route route_src;
struct ss7_application_route route_dst;
struct bsc_data *bsc;
/* handling for the NAT/State handling */
struct llist_head sccp_connections;
struct timer_list reset_timeout;
struct mtp_link_set *target_link;
int forward_only;
int reset_count;
};
struct ss7_application *ss7_application_alloc(struct bsc_data *);
struct ss7_application *ss7_application_num(struct bsc_data *, int nr);
int ss7_application_setup(struct ss7_application *, int type,
int src_type, int src_num,
int dst_type, int dst_num);
#endif

View File

@ -12,12 +12,12 @@ mgcp_mgw_LDADD = $(LAFORGE_LIBS) $(NEXUSWARE_C7_LIBS) $(NEXUSWARE_UNIPORTE_LIBS)
cellmgr_ng_SOURCES = main.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \ cellmgr_ng_SOURCES = main.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \
bss_patch.c bssap_sccp.c bsc_sccp.c bsc_ussd.c links.c \ bss_patch.c bssap_sccp.c bsc_sccp.c bsc_ussd.c links.c \
msc_conn.c link_udp.c snmp_mtp.c debug.c vty_interface.c isup.c \ msc_conn.c link_udp.c snmp_mtp.c debug.c vty_interface.c isup.c \
mtp_link.c counter.c sccp_state.c bsc.c mtp_link.c counter.c sccp_state.c bsc.c ss7_application.c
cellmgr_ng_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \ cellmgr_ng_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto -lpthread -lnetsnmp -lcrypto
osmo_stp_SOURCES = main_stp.c mtp_layer3.c thread.c pcap.c link_udp.c snmp_mtp.c \ osmo_stp_SOURCES = main_stp.c mtp_layer3.c thread.c pcap.c link_udp.c snmp_mtp.c \
debug.c vty_interface.c links.c isup.c sctp_m2ua.c \ debug.c vty_interface.c links.c isup.c sctp_m2ua.c \
mtp_link.c counter.c bsc.c mtp_link.c counter.c bsc.c ss7_application.c
osmo_stp_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \ osmo_stp_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto -lm2ua -lsctp -lpthread -lnetsnmp -lcrypto -lm2ua -lsctp

View File

@ -37,6 +37,7 @@ struct bsc_data *bsc_data_create()
INIT_LLIST_HEAD(&bsc->linksets); INIT_LLIST_HEAD(&bsc->linksets);
INIT_LLIST_HEAD(&bsc->mscs); INIT_LLIST_HEAD(&bsc->mscs);
INIT_LLIST_HEAD(&bsc->apps);
bsc->dpc = 1; bsc->dpc = 1;
bsc->opc = 0; bsc->opc = 0;

View File

@ -23,13 +23,14 @@
#include "bsc_data.h" #include "bsc_data.h"
#include <cellmgr_debug.h> #include <cellmgr_debug.h>
#include <msc_connection.h> #include <ss7_application.h>
#include <ss7_application.h>
#include <osmocore/talloc.h> #include <osmocore/talloc.h>
#include <string.h> #include <string.h>
struct active_sccp_con *find_con_by_dest_ref(struct msc_connection *fw, struct sccp_source_reference *ref) struct active_sccp_con *find_con_by_dest_ref(struct ss7_application *fw, struct sccp_source_reference *ref)
{ {
struct active_sccp_con *con; struct active_sccp_con *con;
@ -48,7 +49,7 @@ struct active_sccp_con *find_con_by_dest_ref(struct msc_connection *fw, struct s
} }
struct active_sccp_con *find_con_by_src_ref(struct msc_connection *fw, struct sccp_source_reference *src_ref) struct active_sccp_con *find_con_by_src_ref(struct ss7_application *fw, struct sccp_source_reference *src_ref)
{ {
struct active_sccp_con *con; struct active_sccp_con *con;
@ -64,7 +65,7 @@ struct active_sccp_con *find_con_by_src_ref(struct msc_connection *fw, struct sc
return NULL; return NULL;
} }
struct active_sccp_con *find_con_by_src_dest_ref(struct msc_connection *fw, struct active_sccp_con *find_con_by_src_dest_ref(struct ss7_application *fw,
struct sccp_source_reference *src_ref, struct sccp_source_reference *src_ref,
struct sccp_source_reference *dst_ref) struct sccp_source_reference *dst_ref)
{ {
@ -80,7 +81,7 @@ struct active_sccp_con *find_con_by_src_dest_ref(struct msc_connection *fw,
return NULL; return NULL;
} }
unsigned int sls_for_src_ref(struct msc_connection *fw, struct sccp_source_reference *ref) unsigned int sls_for_src_ref(struct ss7_application *fw, struct sccp_source_reference *ref)
{ {
struct active_sccp_con *con; struct active_sccp_con *con;

View File

@ -29,6 +29,7 @@
#include <bsc_data.h> #include <bsc_data.h>
#include <cellmgr_debug.h> #include <cellmgr_debug.h>
#include <bsc_sccp.h> #include <bsc_sccp.h>
#include <ss7_application.h>
#include <osmocore/talloc.h> #include <osmocore/talloc.h>
@ -174,6 +175,7 @@ int main(int argc, char **argv)
int rc; int rc;
struct msc_connection *msc; struct msc_connection *msc;
struct mtp_link_set *set; struct mtp_link_set *set;
struct ss7_application *app;
thread_init(); thread_init();
@ -226,8 +228,15 @@ int main(int argc, char **argv)
if (!set) if (!set)
return -1; return -1;
set->fw = msc; app = ss7_application_alloc(bsc);
msc->target_link = set; if (!app) {
LOGP(DINP, LOGL_ERROR, "Failed to create the SS7 application.\n");
return -1;
}
ss7_application_setup(app, APP_CELLMGR,
SS7_SET_LINKSET, 0,
SS7_SET_MSC, 0);
while (1) { while (1) {
bsc_select_main(0); bsc_select_main(0);

View File

@ -28,6 +28,7 @@
#include <snmp_mtp.h> #include <snmp_mtp.h>
#include <cellmgr_debug.h> #include <cellmgr_debug.h>
#include <sctp_m2ua.h> #include <sctp_m2ua.h>
#include <ss7_application.h>
#include <osmocom/m2ua/m2ua_msg.h> #include <osmocom/m2ua/m2ua_msg.h>
@ -71,12 +72,30 @@ extern void cell_vty_init(void);
*/ */
void mtp_link_set_forward_sccp(struct mtp_link_set *set, struct msgb *_msg, int sls) void mtp_link_set_forward_sccp(struct mtp_link_set *set, struct msgb *_msg, int sls)
{ {
mtp_link_set_submit_sccp_data(set->forward, sls, _msg->l2h, msgb_l2len(_msg)); struct mtp_link_set *other;
if (!set->app) {
LOGP(DINP, LOGL_ERROR, "Linkset %d/%s does not have an app.\n",
set->no, set->name);
return;
}
other = set->app->route_src.set == set ?
set->app->route_dst.set : set->app->route_src.set;
mtp_link_set_submit_sccp_data(other, sls, _msg->l2h, msgb_l2len(_msg));
} }
void mtp_link_set_forward_isup(struct mtp_link_set *set, struct msgb *msg, int sls) void mtp_link_set_forward_isup(struct mtp_link_set *set, struct msgb *msg, int sls)
{ {
mtp_link_set_submit_isup_data(set->forward, sls, msg->l3h, msgb_l3len(msg)); struct mtp_link_set *other;
if (!set->app) {
LOGP(DINP, LOGL_ERROR, "Linkset %d/%s does not have an app.\n",
set->no, set->name);
return;
}
other = set->app->route_src.set == set ?
set->app->route_dst.set : set->app->route_src.set;
mtp_link_set_submit_isup_data(other, sls, msg->l3h, msgb_l3len(msg));
} }
void mtp_linkset_down(struct mtp_link_set *set) void mtp_linkset_down(struct mtp_link_set *set)
@ -307,6 +326,7 @@ int main(int argc, char **argv)
struct mtp_link_set *set; struct mtp_link_set *set;
struct mtp_link_set *m2ua_set; struct mtp_link_set *m2ua_set;
struct mtp_m2ua_link *lnk; struct mtp_m2ua_link *lnk;
struct ss7_application *app;
thread_init(); thread_init();
@ -352,6 +372,10 @@ int main(int argc, char **argv)
return -1; return -1;
} }
app = ss7_application_alloc(bsc);
if (!app)
return -1;
set = link_init(bsc); set = link_init(bsc);
if (!set) if (!set)
return -1; return -1;
@ -374,14 +398,16 @@ int main(int argc, char **argv)
/* setup things */ /* setup things */
set->pass_all_isup = bsc->isup_pass; set->pass_all_isup = bsc->isup_pass;
set->forward = m2ua_set;
m2ua_set->pass_all_isup = bsc->isup_pass; m2ua_set->pass_all_isup = bsc->isup_pass;
m2ua_set->forward = set;
lnk = mtp_m2ua_link_create(m2ua_set); lnk = mtp_m2ua_link_create(m2ua_set);
lnk->base.pcap_fd = -1; lnk->base.pcap_fd = -1;
mtp_link_set_add_link(m2ua_set, (struct mtp_link *) lnk); mtp_link_set_add_link(m2ua_set, (struct mtp_link *) lnk);
ss7_application_setup(app, APP_STP,
SS7_SET_LINKSET, 0,
SS7_SET_LINKSET, 1);
llist_for_each_entry(data, &m2ua_set->links, entry) llist_for_each_entry(data, &m2ua_set->links, entry)
data->start(data); data->start(data);

View File

@ -549,7 +549,6 @@ struct msc_connection *msc_connection_create(struct bsc_data *bsc, int mgcp)
return NULL; return NULL;
} }
INIT_LLIST_HEAD(&msc->sccp_connections);
llist_add(&msc->entry, &bsc->mscs); llist_add(&msc->entry, &bsc->mscs);
msc->nr = bsc->num_mscs++; msc->nr = bsc->num_mscs++;

View File

@ -28,6 +28,7 @@
#include <cellmgr_debug.h> #include <cellmgr_debug.h>
#include <bsc_sccp.h> #include <bsc_sccp.h>
#include <bsc_ussd.h> #include <bsc_ussd.h>
#include <ss7_application.h>
#include <osmocore/talloc.h> #include <osmocore/talloc.h>
@ -46,10 +47,11 @@
#include <unistd.h> #include <unistd.h>
static void send_reset_ack(struct mtp_link_set *link, int sls); static void send_reset_ack(struct mtp_link_set *link, int sls);
static void bsc_resources_released(struct msc_connection *bsc); static void app_resources_released(struct ss7_application *ss7);
static void app_clear_connections(struct ss7_application *ss7);
static void handle_local_sccp(struct mtp_link_set *link, struct msgb *inp, struct sccp_parse_result *res, int sls); static void handle_local_sccp(struct mtp_link_set *link, struct msgb *inp, struct sccp_parse_result *res, int sls);
static void clear_connections(struct msc_connection *bsc);
static void send_local_rlsd(struct mtp_link_set *link, struct sccp_parse_result *res); static void send_local_rlsd(struct mtp_link_set *link, struct sccp_parse_result *res);
static void update_con_state(struct ss7_application *ss7, int rc, struct sccp_parse_result *result, struct msgb *msg, int from_msc, int sls);
/* send a RSIP to the MGCP GW */ /* send a RSIP to the MGCP GW */
static void mgcp_reset(struct msc_connection *fw) static void mgcp_reset(struct msc_connection *fw)
@ -68,14 +70,27 @@ void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *_msg, int
{ {
int rc; int rc;
struct sccp_parse_result result; struct sccp_parse_result result;
struct msc_connection *fw = link->fw; struct msc_connection *fw;
struct msgb *msg; struct msgb *msg;
if (fw->forward_only) { if (!link->app) {
msc_send_direct(fw, _msg); LOGP(DINP, LOGL_ERROR, "The linkset %d/%s has no application.\n",
link->no, link->name);
return; return;
} }
fw = link->app->route_dst.msc;
if (!fw) {
LOGP(DINP, LOGL_ERROR, "The application %d/%s has no MSC.\n",
link->app->nr, link->app->name);
return;
}
if (link->app->forward_only) {
msc_send_direct(fw, _msg);
return;
}
rc = bss_patch_filter_msg(_msg, &result); rc = bss_patch_filter_msg(_msg, &result);
if (rc == BSS_FILTER_RESET) { if (rc == BSS_FILTER_RESET) {
@ -87,10 +102,10 @@ void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *_msg, int
/* special responder */ /* special responder */
if (fw->msc_link_down) { if (fw->msc_link_down) {
if (rc == BSS_FILTER_RESET_ACK && fw->reset_count > 0) { if (rc == BSS_FILTER_RESET_ACK && link->app->reset_count > 0) {
LOGP(DMSC, LOGL_ERROR, "Received reset ack for closing.\n"); LOGP(DMSC, LOGL_ERROR, "Received reset ack for closing.\n");
clear_connections(fw); app_clear_connections(link->app);
bsc_resources_released(fw); app_resources_released(link->app);
return; return;
} }
@ -103,7 +118,7 @@ void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *_msg, int
} }
/* update the connection state */ /* update the connection state */
update_con_state(link->fw, rc, &result, _msg, 0, sls); update_con_state(link->app, rc, &result, _msg, 0, sls);
if (rc == BSS_FILTER_CLEAR_COMPL) { if (rc == BSS_FILTER_CLEAR_COMPL) {
send_local_rlsd(link, &result); send_local_rlsd(link, &result);
@ -113,7 +128,7 @@ void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *_msg, int
} }
/* now send it out */ /* now send it out */
bsc_ussd_handle_out_msg(link->fw, &result, _msg); bsc_ussd_handle_out_msg(fw, &result, _msg);
msg = msgb_alloc_headroom(4096, 128, "SCCP to MSC"); msg = msgb_alloc_headroom(4096, 128, "SCCP to MSC");
if (!msg) { if (!msg) {
@ -122,7 +137,7 @@ void mtp_link_set_forward_sccp(struct mtp_link_set *link, struct msgb *_msg, int
} }
bss_rewrite_header_for_msc(rc, msg, _msg, &result); bss_rewrite_header_for_msc(rc, msg, _msg, &result);
msc_send_direct(link->fw, msg); msc_send_direct(fw, msg);
} }
void mtp_link_set_forward_isup(struct mtp_link_set *set, struct msgb *msg, int sls) void mtp_link_set_forward_isup(struct mtp_link_set *set, struct msgb *msg, int sls)
@ -158,7 +173,7 @@ static void handle_local_sccp(struct mtp_link_set *link, struct msgb *inpt, stru
form1 = (struct sccp_data_form1 *) inpt->l2h; form1 = (struct sccp_data_form1 *) inpt->l2h;
llist_for_each_entry(con, &link->fw->sccp_connections, entry) { llist_for_each_entry(con, &link->app->sccp_connections, entry) {
if (memcmp(&form1->destination_local_reference, if (memcmp(&form1->destination_local_reference,
&con->dst_ref, sizeof(con->dst_ref)) == 0) { &con->dst_ref, sizeof(con->dst_ref)) == 0) {
LOGP(DINP, LOGL_DEBUG, "Sending a release request now.\n"); LOGP(DINP, LOGL_DEBUG, "Sending a release request now.\n");
@ -176,60 +191,61 @@ static void handle_local_sccp(struct mtp_link_set *link, struct msgb *inpt, stru
} else if (inpt->l2h[0] == SCCP_MSG_TYPE_UDT && result->data_len >= 3) { } else if (inpt->l2h[0] == SCCP_MSG_TYPE_UDT && result->data_len >= 3) {
if (inpt->l3h[0] == 0 && inpt->l3h[2] == BSS_MAP_MSG_RESET_ACKNOWLEDGE) { if (inpt->l3h[0] == 0 && inpt->l3h[2] == BSS_MAP_MSG_RESET_ACKNOWLEDGE) {
LOGP(DINP, LOGL_NOTICE, "Reset ACK. Connecting to the MSC again.\n"); LOGP(DINP, LOGL_NOTICE, "Reset ACK. Connecting to the MSC again.\n");
bsc_resources_released(link->fw); app_resources_released(link->app);
return; return;
} }
} }
/* Update the state, maybe the connection was released? */ /* Update the state, maybe the connection was released? */
update_con_state(link->fw, 0, result, inpt, 0, sls); update_con_state(link->app, 0, result, inpt, 0, sls);
if (llist_empty(&link->fw->sccp_connections)) if (llist_empty(&link->app->sccp_connections))
bsc_resources_released(link->fw); app_resources_released(link->app);
return; return;
} }
static void clear_connections(struct msc_connection *fw) static void app_clear_connections(struct ss7_application *app)
{ {
struct active_sccp_con *tmp, *con; struct active_sccp_con *tmp, *con;
llist_for_each_entry_safe(con, tmp, &fw->sccp_connections, entry) { llist_for_each_entry_safe(con, tmp, &app->sccp_connections, entry) {
free_con(con); free_con(con);
} }
link_clear_all(fw->target_link); link_clear_all(app->route_src.set);
} }
void bsc_resources_released(struct msc_connection *fw) void app_resources_released(struct ss7_application *app)
{ {
bsc_del_timer(&fw->reset_timeout); bsc_del_timer(&app->reset_timeout);
} }
static void bsc_reset_timeout(void *_data) static void bsc_reset_timeout(void *_app)
{ {
struct msgb *msg; struct msgb *msg;
struct msc_connection *fw = _data; struct ss7_application *app = _app;
struct mtp_link_set *set = app->route_src.set;
/* no reset */ /* no reset */
if (fw->reset_count > 0) { if (app->reset_count > 0) {
LOGP(DINP, LOGL_ERROR, "The BSC did not answer the GSM08.08 reset. Restart MTP\n"); LOGP(DINP, LOGL_ERROR, "The BSC did not answer the GSM08.08 reset. Restart MTP\n");
mtp_link_set_stop(fw->target_link); mtp_link_set_stop(app->route_src.set);
clear_connections(fw); app_clear_connections(app);
link_reset_all(fw->target_link); link_reset_all(app->route_src.set);
bsc_resources_released(fw); app_resources_released(app);
return; return;
} }
msg = create_reset(); msg = create_reset();
if (!msg) { if (!msg) {
bsc_schedule_timer(&fw->reset_timeout, 10, 0); bsc_schedule_timer(&app->reset_timeout, 10, 0);
return; return;
} }
++fw->reset_count; ++app->reset_count;
mtp_link_set_submit_sccp_data(fw->target_link, -1, msg->l2h, msgb_l2len(msg)); mtp_link_set_submit_sccp_data(set, -1, msg->l2h, msgb_l2len(msg));
msgb_free(msg); msgb_free(msg);
bsc_schedule_timer(&fw->reset_timeout, 20, 0); bsc_schedule_timer(&app->reset_timeout, 20, 0);
} }
/* /*
@ -249,19 +265,33 @@ static void bsc_reset_timeout(void *_data)
* this means we need to parse response message. In the case the * this means we need to parse response message. In the case the
* MTP link is going down while we are sending. We will simply * MTP link is going down while we are sending. We will simply
* reconnect to the MSC. * reconnect to the MSC.
*
* This could be called for the relay type and the cellmgr type, in case
* of the relay type the list of connections should be empty so we can
* avoid branching out.
*/ */
void release_bsc_resources(struct msc_connection *fw) void release_bsc_resources(struct msc_connection *fw)
{ {
struct ss7_application *app;
struct mtp_link_set *set;
struct active_sccp_con *tmp; struct active_sccp_con *tmp;
struct active_sccp_con *con; struct active_sccp_con *con;
bsc_del_timer(&fw->reset_timeout); if (!fw->app) {
LOGP(DINP, LOGL_ERROR, "No app assigned to the MSC connection %d/%s\n",
fw->nr, fw->name);
return;
}
app = fw->app;
set = app->route_src.set;
bsc_del_timer(&app->reset_timeout);
/* 2. clear the MGCP endpoints */ /* 2. clear the MGCP endpoints */
mgcp_reset(fw); mgcp_reset(fw);
/* 1. send BSSMAP Cleanup.. if we have any connection */ /* 1. send BSSMAP Cleanup.. if we have any connection */
llist_for_each_entry_safe(con, tmp, &fw->sccp_connections, entry) { llist_for_each_entry_safe(con, tmp, &app->sccp_connections, entry) {
if (!con->has_dst_ref) { if (!con->has_dst_ref) {
free_con(con); free_con(con);
continue; continue;
@ -272,18 +302,18 @@ void release_bsc_resources(struct msc_connection *fw)
continue; continue;
/* wait for the clear commands */ /* wait for the clear commands */
mtp_link_set_submit_sccp_data(fw->target_link, con->sls, msg->l2h, msgb_l2len(msg)); mtp_link_set_submit_sccp_data(set, con->sls, msg->l2h, msgb_l2len(msg));
msgb_free(msg); msgb_free(msg);
} }
if (llist_empty(&fw->sccp_connections)) { if (llist_empty(&app->sccp_connections)) {
bsc_resources_released(fw); app_resources_released(app);
} else { } else {
/* Send a reset in 20 seconds if we fail to bring everything down */ /* Send a reset in 20 seconds if we fail to bring everything down */
fw->reset_timeout.cb = bsc_reset_timeout; app->reset_timeout.cb = bsc_reset_timeout;
fw->reset_timeout.data = fw; app->reset_timeout.data = app;
fw->reset_count = 0; app->reset_count = 0;
bsc_schedule_timer(&fw->reset_timeout, 10, 0); bsc_schedule_timer(&app->reset_timeout, 10, 0);
} }
} }
@ -291,11 +321,14 @@ void mtp_linkset_down(struct mtp_link_set *set)
{ {
set->available = 0; set->available = 0;
mtp_link_set_stop(set); mtp_link_set_stop(set);
clear_connections(set->fw);
mgcp_reset(set->fw);
/* If we have an A link send a reset to the MSC */ if (set->app) {
msc_send_reset(set->fw); app_clear_connections(set->app);
/* If we have an A link send a reset to the MSC */
mgcp_reset(set->app->route_dst.msc);
msc_send_reset(set->app->route_dst.msc);
}
} }
void mtp_linkset_up(struct mtp_link_set *set) void mtp_linkset_up(struct mtp_link_set *set)
@ -303,9 +336,9 @@ void mtp_linkset_up(struct mtp_link_set *set)
set->available = 1; set->available = 1;
/* we have not gone through link down */ /* we have not gone through link down */
if (set->fw->msc_link_down) { if (set->app && set->app->route_dst.msc->msc_link_down) {
clear_connections(set->fw); app_clear_connections(set->app);
bsc_resources_released(set->fw); app_resources_released(set->app);
} }
mtp_link_set_reset(set); mtp_link_set_reset(set);
@ -314,7 +347,7 @@ void mtp_linkset_up(struct mtp_link_set *set)
/** /**
* update the connection state and helpers below * update the connection state and helpers below
*/ */
static void send_rlc_to_bsc(struct msc_connection *fw, static void send_rlc_to_bsc(struct mtp_link_set *set,
unsigned int sls, struct sccp_source_reference *src, unsigned int sls, struct sccp_source_reference *src,
struct sccp_source_reference *dst) struct sccp_source_reference *dst)
{ {
@ -324,17 +357,19 @@ static void send_rlc_to_bsc(struct msc_connection *fw,
if (!msg) if (!msg)
return; return;
mtp_link_set_submit_sccp_data(fw->target_link, sls, msg->l2h, msgb_l2len(msg)); mtp_link_set_submit_sccp_data(set, sls, msg->l2h, msgb_l2len(msg));
msgb_free(msg); msgb_free(msg);
} }
static void handle_rlsd(struct msc_connection *fw, struct sccp_connection_released *rlsd, int from_msc) static void handle_rlsd(struct ss7_application *app, struct sccp_connection_released *rlsd, int from_msc)
{ {
struct active_sccp_con *con; struct active_sccp_con *con;
struct msc_connection *msc = app->route_dst.msc;
struct mtp_link_set *set = app->route_src.set;
if (from_msc) { if (from_msc) {
/* search for a connection, reverse src/dest for MSC */ /* search for a connection, reverse src/dest for MSC */
con = find_con_by_src_dest_ref(fw, &rlsd->destination_local_reference, con = find_con_by_src_dest_ref(app, &rlsd->destination_local_reference,
&rlsd->source_local_reference); &rlsd->source_local_reference);
if (con) { if (con) {
LOGP(DINP, LOGL_DEBUG, "RLSD conn still alive: local: 0x%x remote: 0x%x\n", LOGP(DINP, LOGL_DEBUG, "RLSD conn still alive: local: 0x%x remote: 0x%x\n",
@ -346,19 +381,19 @@ static void handle_rlsd(struct msc_connection *fw, struct sccp_connection_releas
LOGP(DINP, LOGL_DEBUG, "Sending RLC for MSC: src: 0x%x dst: 0x%x\n", LOGP(DINP, LOGL_DEBUG, "Sending RLC for MSC: src: 0x%x dst: 0x%x\n",
sccp_src_ref_to_int(&rlsd->destination_local_reference), sccp_src_ref_to_int(&rlsd->destination_local_reference),
sccp_src_ref_to_int(&rlsd->source_local_reference)); sccp_src_ref_to_int(&rlsd->source_local_reference));
msc_send_rlc(fw, &rlsd->destination_local_reference, msc_send_rlc(msc, &rlsd->destination_local_reference,
&rlsd->source_local_reference); &rlsd->source_local_reference);
} }
} else { } else {
unsigned int sls = -1; unsigned int sls = -1;
con = find_con_by_src_dest_ref(fw, &rlsd->source_local_reference, con = find_con_by_src_dest_ref(app, &rlsd->source_local_reference,
&rlsd->destination_local_reference); &rlsd->destination_local_reference);
if (con) { if (con) {
LOGP(DINP, LOGL_DEBUG, "Timeout on BSC. Sending RLC. src: 0x%x\n", LOGP(DINP, LOGL_DEBUG, "Timeout on BSC. Sending RLC. src: 0x%x\n",
sccp_src_ref_to_int(&rlsd->source_local_reference)); sccp_src_ref_to_int(&rlsd->source_local_reference));
if (con->released_from_msc) if (con->released_from_msc)
msc_send_rlc(fw, &con->src_ref, &con->dst_ref); msc_send_rlc(msc, &con->src_ref, &con->dst_ref);
sls = con->sls; sls = con->sls;
free_con(con); free_con(con);
} else { } else {
@ -367,7 +402,7 @@ static void handle_rlsd(struct msc_connection *fw, struct sccp_connection_releas
} }
/* now send a rlc back to the BSC */ /* now send a rlc back to the BSC */
send_rlc_to_bsc(fw, sls, &rlsd->destination_local_reference, &rlsd->source_local_reference); send_rlc_to_bsc(set, sls, &rlsd->destination_local_reference, &rlsd->source_local_reference);
} }
} }
@ -385,18 +420,21 @@ static void handle_rlsd(struct msc_connection *fw, struct sccp_connection_releas
* 1.) We are destroying the connection, we might send a RLC to * 1.) We are destroying the connection, we might send a RLC to
* the MSC if we are waiting for one. * the MSC if we are waiting for one.
*/ */
void update_con_state(struct msc_connection *fw, int rc, struct sccp_parse_result *res, struct msgb *msg, int from_msc, int sls) void update_con_state(struct ss7_application *app, int rc, struct sccp_parse_result *res, struct msgb *msg, int from_msc, int sls)
{ {
struct active_sccp_con *con; struct active_sccp_con *con;
struct sccp_connection_request *cr; struct sccp_connection_request *cr;
struct sccp_connection_confirm *cc; struct sccp_connection_confirm *cc;
struct sccp_connection_release_complete *rlc; struct sccp_connection_release_complete *rlc;
struct sccp_connection_refused *cref; struct sccp_connection_refused *cref;
struct msc_connection *msc;
/* was the header okay? */ /* was the header okay? */
if (rc < 0) if (rc < 0)
return; return;
msc = app->route_dst.msc;
/* the header was size checked */ /* the header was size checked */
switch (msg->l2h[0]) { switch (msg->l2h[0]) {
case SCCP_MSG_TYPE_CR: case SCCP_MSG_TYPE_CR:
@ -406,7 +444,7 @@ void update_con_state(struct msc_connection *fw, int rc, struct sccp_parse_resul
} }
cr = (struct sccp_connection_request *) msg->l2h; cr = (struct sccp_connection_request *) msg->l2h;
con = find_con_by_src_ref(fw, &cr->source_local_reference); con = find_con_by_src_ref(app, &cr->source_local_reference);
if (con) { if (con) {
LOGP(DINP, LOGL_ERROR, "Duplicate SRC reference for: 0x%x. Reusing\n", LOGP(DINP, LOGL_ERROR, "Duplicate SRC reference for: 0x%x. Reusing\n",
sccp_src_ref_to_int(&con->src_ref)); sccp_src_ref_to_int(&con->src_ref));
@ -421,8 +459,8 @@ void update_con_state(struct msc_connection *fw, int rc, struct sccp_parse_resul
con->src_ref = cr->source_local_reference; con->src_ref = cr->source_local_reference;
con->sls = sls; con->sls = sls;
con->link = fw->target_link; con->app = app;
llist_add_tail(&con->entry, &fw->sccp_connections); llist_add_tail(&con->entry, &app->sccp_connections);
LOGP(DINP, LOGL_DEBUG, "Adding CR: local ref: 0x%x\n", sccp_src_ref_to_int(&con->src_ref)); LOGP(DINP, LOGL_DEBUG, "Adding CR: local ref: 0x%x\n", sccp_src_ref_to_int(&con->src_ref));
break; break;
case SCCP_MSG_TYPE_CC: case SCCP_MSG_TYPE_CC:
@ -432,7 +470,7 @@ void update_con_state(struct msc_connection *fw, int rc, struct sccp_parse_resul
} }
cc = (struct sccp_connection_confirm *) msg->l2h; cc = (struct sccp_connection_confirm *) msg->l2h;
con = find_con_by_src_ref(fw, &cc->destination_local_reference); con = find_con_by_src_ref(app, &cc->destination_local_reference);
if (con) { if (con) {
con->dst_ref = cc->source_local_reference; con->dst_ref = cc->source_local_reference;
con->has_dst_ref = 1; con->has_dst_ref = 1;
@ -451,7 +489,7 @@ void update_con_state(struct msc_connection *fw, int rc, struct sccp_parse_resul
} }
cref = (struct sccp_connection_refused *) msg->l2h; cref = (struct sccp_connection_refused *) msg->l2h;
con = find_con_by_src_ref(fw, &cref->destination_local_reference); con = find_con_by_src_ref(app, &cref->destination_local_reference);
if (con) { if (con) {
LOGP(DINP, LOGL_DEBUG, "Releasing local: 0x%x\n", sccp_src_ref_to_int(&con->src_ref)); LOGP(DINP, LOGL_DEBUG, "Releasing local: 0x%x\n", sccp_src_ref_to_int(&con->src_ref));
free_con(con); free_con(con);
@ -461,7 +499,7 @@ void update_con_state(struct msc_connection *fw, int rc, struct sccp_parse_resul
LOGP(DINP, LOGL_ERROR, "CREF from BSC is not handled.\n"); LOGP(DINP, LOGL_ERROR, "CREF from BSC is not handled.\n");
break; break;
case SCCP_MSG_TYPE_RLSD: case SCCP_MSG_TYPE_RLSD:
handle_rlsd(fw, (struct sccp_connection_released *) msg->l2h, from_msc); handle_rlsd(app, (struct sccp_connection_released *) msg->l2h, from_msc);
break; break;
case SCCP_MSG_TYPE_RLC: case SCCP_MSG_TYPE_RLC:
if (from_msc) { if (from_msc) {
@ -470,12 +508,12 @@ void update_con_state(struct msc_connection *fw, int rc, struct sccp_parse_resul
} }
rlc = (struct sccp_connection_release_complete *) msg->l2h; rlc = (struct sccp_connection_release_complete *) msg->l2h;
con = find_con_by_src_dest_ref(fw, &rlc->source_local_reference, con = find_con_by_src_dest_ref(app, &rlc->source_local_reference,
&rlc->destination_local_reference); &rlc->destination_local_reference);
if (con) { if (con) {
LOGP(DINP, LOGL_DEBUG, "Releasing local: 0x%x\n", sccp_src_ref_to_int(&con->src_ref)); LOGP(DINP, LOGL_DEBUG, "Releasing local: 0x%x\n", sccp_src_ref_to_int(&con->src_ref));
if (con->released_from_msc) if (con->released_from_msc)
msc_send_rlc(fw, &con->src_ref, &con->dst_ref); msc_send_rlc(msc, &con->src_ref, &con->dst_ref);
free_con(con); free_con(con);
return; return;
} }
@ -515,7 +553,7 @@ static void send_local_rlsd(struct mtp_link_set *link, struct sccp_parse_result
LOGP(DINP, LOGL_DEBUG, "Received GSM Clear Complete. Sending RLSD locally.\n"); LOGP(DINP, LOGL_DEBUG, "Received GSM Clear Complete. Sending RLSD locally.\n");
con = find_con_by_dest_ref(link->fw, res->destination_local_reference); con = find_con_by_dest_ref(link->app, res->destination_local_reference);
if (!con) if (!con)
return; return;
con->rls_tries = 0; con->rls_tries = 0;
@ -535,11 +573,22 @@ static void send_reset_ack(struct mtp_link_set *link, int sls)
void msc_dispatch_sccp(struct msc_connection *msc, struct msgb *msg) void msc_dispatch_sccp(struct msc_connection *msc, struct msgb *msg)
{ {
struct mtp_link_set *set;
if (!msc->app) {
LOGP(DINP, LOGL_ERROR, "The MSC Connection %d/%s has no app assigned.\n",
msc->nr, msc->name);
return;
}
set = msc->app->route_src.set;
/* we can not forward it right now */ /* we can not forward it right now */
if (msc->forward_only) { if (msc->app->forward_only) {
if (!msc->target_link->sccp_up) if (!set->sccp_up)
return; return;
mtp_link_set_submit_sccp_data(msc->target_link, -1, mtp_link_set_submit_sccp_data(set, -1,
msg->l2h, msgb_l2len(msg)); msg->l2h, msgb_l2len(msg));
} else { } else {
struct sccp_parse_result result; struct sccp_parse_result result;
@ -551,27 +600,26 @@ void msc_dispatch_sccp(struct msc_connection *msc, struct msgb *msg)
LOGP(DMSC, LOGL_NOTICE, "Filtering reset ack from the MSC\n"); LOGP(DMSC, LOGL_NOTICE, "Filtering reset ack from the MSC\n");
} else if (rc == BSS_FILTER_RLSD) { } else if (rc == BSS_FILTER_RLSD) {
LOGP(DMSC, LOGL_DEBUG, "Filtering RLSD from the MSC\n"); LOGP(DMSC, LOGL_DEBUG, "Filtering RLSD from the MSC\n");
update_con_state(msc, rc, &result, msg, 1, 0); update_con_state(msc->app, rc, &result, msg, 1, 0);
} else if (rc == BSS_FILTER_RLC) { } else if (rc == BSS_FILTER_RLC) {
/* if we receive this we have forwarded a RLSD to the network */ /* if we receive this we have forwarded a RLSD to the network */
LOGP(DMSC, LOGL_ERROR, "RLC from the network. BAD!\n"); LOGP(DMSC, LOGL_ERROR, "RLC from the network. BAD!\n");
} else if (rc == BSS_FILTER_CLEAR_COMPL) { } else if (rc == BSS_FILTER_CLEAR_COMPL) {
LOGP(DMSC, LOGL_ERROR, "Clear Complete from the network.\n"); LOGP(DMSC, LOGL_ERROR, "Clear Complete from the network.\n");
} else if (msc->target_link->sccp_up) { } else if (set->sccp_up) {
unsigned int sls; unsigned int sls;
update_con_state(msc, rc, &result, msg, 1, 0); update_con_state(msc->app, rc, &result, msg, 1, 0);
sls = sls_for_src_ref(msc, result.destination_local_reference); sls = sls_for_src_ref(msc->app, result.destination_local_reference);
/* Check for Location Update Accept */ /* Check for Location Update Accept */
bsc_ussd_handle_in_msg(msc, &result, msg); bsc_ussd_handle_in_msg(msc, &result, msg);
/* patch a possible PC */ /* patch a possible PC */
bss_rewrite_header_to_bsc(msg, msc->target_link->opc, bss_rewrite_header_to_bsc(msg, set->opc, set->dpc);
msc->target_link->dpc);
/* we can not forward it right now */ /* we can not forward it right now */
mtp_link_set_submit_sccp_data(msc->target_link, sls, mtp_link_set_submit_sccp_data(set, sls,
msg->l2h, msgb_l2len(msg)); msg->l2h, msgb_l2len(msg));
} }
} }

227
src/ss7_application.c Normal file
View File

@ -0,0 +1,227 @@
/*
* The SS7 Application part for forwarding or nat...
*
* (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010-2011 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <ss7_application.h>
#include <bsc_data.h>
#include <cellmgr_debug.h>
#include <msc_connection.h>
#include <sctp_m2ua.h>
#include <osmocore/talloc.h>
struct ss7_application *ss7_application_alloc(struct bsc_data *bsc)
{
struct ss7_application *app;
app = talloc_zero(bsc, struct ss7_application);
if (!app) {
LOGP(DINP, LOGL_ERROR, "Failed to create SS7 Application.\n");
return NULL;
}
INIT_LLIST_HEAD(&app->sccp_connections);
llist_add(&app->entry, &bsc->apps);
app->nr = bsc->num_apps++;
app->bsc = bsc;
return app;
}
struct ss7_application *ss7_application_num(struct bsc_data *bsc, int num)
{
struct ss7_application *ss7;
llist_for_each_entry(ss7, &bsc->apps, entry)
if (ss7->nr == num)
return ss7;
return NULL;
}
static int ss7_app_setup_stp(struct ss7_application *app,
int src_type, int src_num,
int dst_type, int dst_num)
{
struct mtp_link_set *src, *dst;
if (src_type != SS7_SET_LINKSET) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s source needs to be a linkset.\n",
app->nr, app->name);
return -1;
}
if (dst_type != SS7_SET_LINKSET) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s destination needs to be a linkset.\n",
app->nr, app->name);
return -1;
}
/* veryify the MTP Linkset */
src = mtp_link_set_num(app->bsc, src_num);
if (!src) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s source linkset not found with nr: %d.\n",
app->nr, app->name, src_num);
return -2;
}
if (src->app) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s is using linkset %d/%s\n",
src->app->nr, src->app->name,
src->no, src->name);
return -3;
}
/* veryify the MTP Linkset */
dst = mtp_link_set_num(app->bsc, dst_num);
if (!dst) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s destionation linkset not found with nr: %d.\n",
app->nr, app->name, dst_num);
return -2;
}
if (dst->app) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s is using linkset %d/%s\n",
dst->app->nr, dst->app->name,
dst->no, dst->name);
return -3;
}
/* now connect it */
src->app = app;
app->route_src.type = src_type;
app->route_src.nr = src_num;
app->route_src.set = src;
app->route_src.msc = NULL;
dst->app = app;
app->route_dst.type = dst_type;
app->route_dst.nr = dst_num;
app->route_dst.set = dst;
app->route_dst.msc = NULL;
app->type = APP_STP;
app->bsc->m2ua_trans->started = 1;
/* TODO: start the applications here */
return 0;
}
static int ss7_app_setup_relay(struct ss7_application *app, int type,
int src_type, int src_num, int dst_type, int dst_num)
{
struct mtp_link_set *mtp;
struct msc_connection *msc;
/* verify the types */
if (src_type != SS7_SET_LINKSET) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s source needs to be a linkset.\n",
app->nr, app->name);
return -1;
}
if (dst_type != SS7_SET_MSC) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s dest needs to be a MSC.\n",
app->nr, app->name);
return -1;
}
/* veryify the MTP Linkset */
mtp = mtp_link_set_num(app->bsc, src_num);
if (!mtp) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s source linkset not found with nr: %d.\n",
app->nr, app->name, src_num);
return -2;
}
if (mtp->app) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s is using linkset %d/%s\n",
mtp->app->nr, mtp->app->name,
mtp->no, mtp->name);
return -3;
}
/* verify the MSC connection */
msc = msc_connection_num(app->bsc, dst_num);
if (!msc) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s dest MSC not found with nr: %d.\n",
app->nr, app->name, dst_num);
return -4;
}
if (msc->app) {
LOGP(DINP, LOGL_ERROR,
"SS7 %d/%s is using MSC connection %d/%s\n",
msc->app->nr, msc->app->name,
msc->nr, msc->name);
return -5;
}
/* now connect it and run the app */
mtp->app = app;
app->route_src.type = src_type;
app->route_src.nr = src_num;
app->route_src.set = mtp;
app->route_src.msc = NULL;
msc->app = app;
app->route_dst.type = dst_type;
app->route_dst.nr = dst_num;
app->route_dst.set = NULL;
app->route_dst.msc = msc;
app->type = type;
/* TODO: start the applications here */
return 0;
}
int ss7_application_setup(struct ss7_application *ss7, int type,
int src_type, int src_num,
int dst_type, int dst_num)
{
switch (type) {
case APP_CELLMGR:
case APP_RELAY:
return ss7_app_setup_relay(ss7, type, src_type, src_num,
dst_type, dst_num);
break;
case APP_STP:
return ss7_app_setup_stp(ss7, src_type, src_num,
dst_type, dst_num);
default:
LOGP(DINP, LOGL_ERROR,
"SS7 Application %d is not supported.\n", type);
return -1;
}
}

View File

@ -593,9 +593,7 @@ void cell_vty_init(void)
install_element_ve(&show_linksets_cmd); install_element_ve(&show_linksets_cmd);
install_element_ve(&show_slc_cmd); install_element_ve(&show_slc_cmd);
if (bsc->app != APP_STP) { install_element_ve(&show_msc_cmd);
install_element_ve(&show_msc_cmd);
}
} }
const char *openbsc_copyright = ""; const char *openbsc_copyright = "";