/* * (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 . * */ #include #include #include #include #include #include #include #include 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 + 1); } /** * 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; }