summaryrefslogtreecommitdiffstats
path: root/src/app.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-03-22 16:31:26 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-03-22 16:32:48 +0100
commit45f0fa09d2ae8f4c15a2096e37c05be5d283d027 (patch)
treeeeea3d9bbc6fbb3adfdc44e2ddc45b1d8a68bd31 /src/app.c
parent10e22bd6f4ebc93e9467fec98a27585a34fcb5d8 (diff)
call/app: Hook the MNCC disconnect event in the app and release calls
In case the MNCC server is crashing we need to release all calls, use the event emitted by the MNCC connection and iterate over all calls and call the release function.
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/app.c b/src/app.c
new file mode 100644
index 0000000..80bd3af
--- /dev/null
+++ b/src/app.c
@@ -0,0 +1,57 @@
+/*
+ * (C) 2016 by Holger Hans Peter Freyther
+ *
+ * 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 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 "app.h"
+#include "call.h"
+#include "logging.h"
+#include "mncc.h"
+
+void app_mncc_disconnected(struct mncc_connection *conn)
+{
+ struct call *call, *tmp;
+
+ llist_for_each_entry_safe(call, tmp, &g_call_list, entry) {
+ int has_mncc = 0;
+
+ if (call->initial && call->initial->type == CALL_TYPE_MNCC)
+ has_mncc = 1;
+ if (call->remote && call->remote->type == CALL_TYPE_MNCC)
+ has_mncc = 1;
+
+ if (!has_mncc)
+ continue;
+
+ /*
+ * this call has a MNCC component and we will release it.
+ */
+ LOGP(DAPP, LOGL_NOTICE,
+ "Going to release call(%u) due MNCC.\n", call->id);
+ call_leg_release(call, call->initial);
+ call_leg_release(call, call->remote);
+ }
+}
+
+/*
+ * I hook SIP and MNCC together.
+ */
+void app_setup(struct app_config *cfg)
+{
+ cfg->mncc.conn.on_disconnect = app_mncc_disconnected;
+}