aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-12-11 14:19:03 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-12-16 12:45:58 +0100
commite833478898850aad99fe5b9b1efee34e6ec1ca64 (patch)
tree6ed239d42901811cbccd70a115dcacb9c64d34e2 /src
parenta9530059a1ecab57a0ebe362ad8b8f3353e3f7b2 (diff)
isup: Hook the reset scanner before we forward the ISUP message1.3.0
Scan for two kind of reset messages in the ISUP messages. Forward them to the mgcp_ss7.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/isup_filter.c86
-rw-r--r--src/main_stp.c13
-rw-r--r--src/ss7_application.c2
-rw-r--r--src/vty_interface.c4
5 files changed, 106 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 4d6061c..d2e211d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/isup_filter.c b/src/isup_filter.c
new file mode 100644
index 0000000..db023b6
--- /dev/null
+++ b/src/isup_filter.c
@@ -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;
+}
diff --git a/src/main_stp.c b/src/main_stp.c
index fd20eb3..11f6255 100644
--- a/src/main_stp.c
+++ b/src/main_stp.c
@@ -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,
diff --git a/src/ss7_application.c b/src/ss7_application.c
index b28c376..cedc2d0 100644
--- a/src/ss7_application.c
+++ b/src/ss7_application.c
@@ -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));
}
diff --git a/src/vty_interface.c b/src/vty_interface.c
index 48e150e..001ba44 100644
--- a/src/vty_interface.c
+++ b/src/vty_interface.c
@@ -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) {