9
0
Fork 0

isup: Hook the reset scanner before we forward the ISUP message

Scan for two kind of reset messages in the ISUP messages. Forward
them to the mgcp_ss7.
This commit is contained in:
Holger Hans Peter Freyther 2012-12-11 14:19:03 +01:00
parent a9530059a1
commit e833478898
8 changed files with 143 additions and 6 deletions

View File

@ -2,6 +2,7 @@ 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 \
snmp_mtp.h cellmgr_debug.h bsc_sccp.h bsc_ussd.h sctp_m2ua.h \
isup_types.h counter.h msc_connection.h ss7_application.h \
mgcp_patch.h ss7_vty.h dtmf_scheduler.h mgcp_callagent.h
mgcp_patch.h ss7_vty.h dtmf_scheduler.h mgcp_callagent.h \
isup_filter.h
SUBDIRS = mgcp

View File

@ -1,7 +1,7 @@
/* Everything related to the BSC connection */
/*
* (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010-2011 by On-Waves
* (C) 2010-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
* (C) 2010-2012 by On-Waves
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
@ -23,6 +23,7 @@
#define BSC_DATA_H
#include "mtp_data.h"
#include "mgcp_callagent.h"
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/select.h>
@ -92,6 +93,9 @@ struct bsc_data {
struct llist_head mscs;
int num_mscs;
/* Simple send only mgcp agent */
struct mgcp_callagent mgcp_agent;
/* application */
struct llist_head apps;
int num_apps;

29
include/isup_filter.h Normal file
View File

@ -0,0 +1,29 @@
/*
* (C) 2012 by Holger Hans Peter Freyther
* (C) 2012 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/>.
*
*/
#ifndef isup_filter_h
#define isup_filter_h
struct ss7_application;
struct msgb;
int isup_scan_for_reset(struct ss7_application *app, struct msgb *msg);
#endif

View File

@ -16,7 +16,7 @@ cellmgr_ng_SOURCES = main.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \
msc_conn.c link_udp.c snmp_mtp.c debug.c isup.c \
mtp_link.c counter.c sccp_state.c bsc.c ss7_application.c \
vty_interface_legacy.c vty_interface_cmds.c mgcp_patch.c \
mgcp_callagent.c
mgcp_callagent.c isup_filter.c
cellmgr_ng_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) \
$(LIBOSMOSCCP_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto
@ -26,7 +26,7 @@ osmo_stp_SOURCES = main_stp.c mtp_layer3.c thread.c pcap.c link_udp.c snmp_mtp.c
bss_patch.c bssap_sccp.c bsc_sccp.c bsc_ussd.c input/ipaccess.c \
mtp_link.c counter.c bsc.c ss7_application.c \
vty_interface.c vty_interface_cmds.c mgcp_patch.c \
mgcp_callagent.c
mgcp_callagent.c isup_filter.c
osmo_stp_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) \
$(LIBOSMOSCCP_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto -lm2ua -lsctp

86
src/isup_filter.c Normal file
View File

@ -0,0 +1,86 @@
/*
* (C) 2012 by Holger Hans Peter Freyther
* (C) 2012 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 <isup_filter.h>
#include <isup_types.h>
#include <mgcp_callagent.h>
#include <ss7_application.h>
#include <bsc_data.h>
#include <osmocom/core/msgb.h>
#include <stdio.h>
#include <string.h>
static void send_reset(struct ss7_application *app, int endp, int range)
{
char buf[1024];
snprintf(buf, sizeof(buf) - 1,
"RSIP 2 %s/%d@127.0.0.1 MGCP 1.0\r\n"
"R: %d\n", app->trunk_name, endp, range);
buf[sizeof(buf) - 1] = '\0';
mgcp_forward(&app->bsc->mgcp_agent,
(const uint8_t *) buf, strlen(buf));
}
static void reset_cic(struct ss7_application *app, int cic)
{
return send_reset(app, cic, 1);
}
static void reset_cics(struct ss7_application *app, int cic, int range)
{
return send_reset(app, cic, range);
}
/**
* Discover resets and forward them to the local MGCP gateway
*/
int isup_scan_for_reset(struct ss7_application *app, struct msgb *msg)
{
struct isup_msg_hdr *hdr;
int range;
/* too small for an isup message? */
if (msgb_l3len(msg) < sizeof(*hdr))
return -1;
/* no trunk name, don't bother forwarding */
if (!app->trunk_name)
return 0;
hdr = (struct isup_msg_hdr *) msg->l3h;
switch (hdr->msg_type) {
case ISUP_MSG_GRS:
range = isup_parse_status(&hdr->data[0],
msgb_l3len(msg) - sizeof(*hdr));
if (range >= 0)
reset_cics(app, hdr->cic, range);
break;
case ISUP_MSG_RSC:
reset_cic(app, hdr->cic);
break;
}
return 0;
}

View File

@ -70,6 +70,12 @@ struct bsc_data *bsc;
extern void cell_vty_init(void);
extern void handle_options(int argc, char **argv);
static void mgcp_destroy_cb(struct mgcp_callagent *agent, struct msgb *msg)
{
/* we do not care about potential responses here */
msgb_free(msg);
}
static struct mtp_link_set *find_link_set(struct bsc_data *bsc,
int len, const char *buf)
{
@ -261,6 +267,13 @@ int main(int argc, char **argv)
return -1;
}
if (mgcp_create_port(&bsc->mgcp_agent) != 0) {
LOGP(DINP, LOGL_ERROR,
"Failed to create the MGCP call agent.\n");
return -1;
}
bsc->mgcp_agent.read_cb = mgcp_destroy_cb;
/* start all apps */
llist_for_each_entry(app, &bsc->apps, entry) {
LOGP(DINP, LOGL_NOTICE,

View File

@ -27,6 +27,7 @@
#include <msc_connection.h>
#include <sctp_m2ua.h>
#include <counter.h>
#include <isup_filter.h>
#include <osmocom/core/talloc.h>
@ -45,6 +46,7 @@ static void forward_isup_stp(struct mtp_link_set *set, struct msgb *msg, int sls
struct mtp_link_set *other;
other = set->app->route_src.set == set ?
set->app->route_dst.set : set->app->route_src.set;
isup_scan_for_reset(set->app, msg);
mtp_link_set_submit_isup_data(other, sls, msg->l3h, msgb_l3len(msg));
}

View File

@ -298,7 +298,9 @@ static void write_application(struct vty *vty, struct ss7_application *app)
if (app->type == APP_STP) {
vty_out(vty, " isup-pass-through %d%s", app->isup_pass, VTY_NEWLINE);
vty_out(vty, " trunk-name %s%s", app->trunk_name, VTY_NEWLINE);
if (app->trunk_name)
vty_out(vty, " trunk-name %s%s",
app->trunk_name, VTY_NEWLINE);
}
if (app->type == APP_CELLMGR && app->mgcp_domain_name) {