aboutsummaryrefslogtreecommitdiffstats
path: root/src/isup_filter.c
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/isup_filter.c
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/isup_filter.c')
-rw-r--r--src/isup_filter.c86
1 files changed, 86 insertions, 0 deletions
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;
+}