summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-03-23 17:41:23 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-03-23 17:41:23 +0100
commit4f8cafa5b089ba0cab33afc7752fa54bd8e57d36 (patch)
tree027d5c792a2bd6512a4b3bb172cb02178bdaa082
parentbc4fed27e12a08e094d8193680236f0a73796bbf (diff)
call: Continue up to the point of call routing
We accept the call on MNCC and ask the core to select/create the second leg of the call.
-rw-r--r--src/app.c17
-rw-r--r--src/app.h4
-rw-r--r--src/mncc.c39
3 files changed, 58 insertions, 2 deletions
diff --git a/src/app.c b/src/app.c
index 6ab584d..6ec60ed 100644
--- a/src/app.c
+++ b/src/app.c
@@ -55,3 +55,20 @@ void app_setup(struct app_config *cfg)
{
cfg->mncc.conn.on_disconnect = app_mncc_disconnected;
}
+
+static void route_to_sip(struct call *call, const char *source, const char *dest)
+{
+ LOGP(DAPP, LOGL_ERROR, "Can not route call(%u) to SIP yet\n", call->id);
+ call_leg_release(call->initial);
+}
+
+void app_route_call(struct call *call, const char *source, const char *dest)
+{
+ if (call->initial->type == CALL_TYPE_MNCC)
+ route_to_sip(call, source, dest);
+ else {
+ LOGP(DAPP, LOGL_ERROR, "Can not route call(%u) to MNCC yet\n",
+ call->id);
+ call_leg_release(call->initial);
+ }
+}
diff --git a/src/app.h b/src/app.h
index 4e5b3fa..6bdc118 100644
--- a/src/app.h
+++ b/src/app.h
@@ -3,6 +3,8 @@
#include "mncc.h"
#include "sip.h"
+struct call;
+
struct app_config {
struct {
const char *local_addr;
@@ -24,4 +26,6 @@ struct app_config {
extern struct app_config g_app;
void app_setup(struct app_config *cfg);
+void app_route_call(struct call *call, const char *source, const char *port);
+
void app_mncc_disconnected(struct mncc_connection *conn);
diff --git a/src/mncc.c b/src/mncc.c
index fbbc88e..907384f 100644
--- a/src/mncc.c
+++ b/src/mncc.c
@@ -24,6 +24,8 @@
#include "logging.h"
#include "call.h"
+#include <osmocom/gsm/protocol/gsm_03_40.h>
+
#include <osmocom/core/socket.h>
#include <osmocom/core/utils.h>
@@ -33,6 +35,8 @@
#include <errno.h>
#include <unistd.h>
+extern void *tall_mncc_ctx;
+
static void close_connection(struct mncc_connection *conn);
static void cmd_timeout(void *data)
@@ -155,6 +159,21 @@ static void close_connection(struct mncc_connection *conn)
conn->on_disconnect(conn);
}
+static void continue_call(struct mncc_call_leg *leg)
+{
+ char *dest, *source;
+
+ if (leg->called.type == GSM340_TYPE_INTERNATIONAL)
+ dest = talloc_asprintf(tall_mncc_ctx, "+%.32s", leg->called.number);
+ else
+ dest = talloc_asprintf(tall_mncc_ctx, "%.32s", leg->called.number);
+ source = talloc_asprintf(tall_mncc_ctx, "%.32s", leg->calling.number);
+
+ app_route_call(leg->base.call, source, dest);
+ talloc_free(source);
+ talloc_free(dest);
+}
+
static void check_rtp_create(struct mncc_connection *conn, char *buf, int rc)
{
struct gsm_mncc_rtp *rtp;
@@ -177,8 +196,19 @@ static void check_rtp_create(struct mncc_connection *conn, char *buf, int rc)
LOGP(DMNCC, LOGL_DEBUG,
"RTP set-up continuing with call with leg(%u)\n", leg->callref);
stop_cmd_timer(leg, MNCC_RTP_CREATE);
- mncc_send(leg->conn, MNCC_REJ_REQ, leg->callref);
- call_leg_release(&leg->base);
+ continue_call(leg);
+}
+
+static int continue_setup(struct mncc_connection *conn, struct gsm_mncc *mncc)
+{
+ if (mncc->called.plan != GSM340_PLAN_ISDN) {
+ LOGP(DMNCC, LOGL_ERROR,
+ "leg(%u) has non(%d) ISDN dial plan. not supported.\n",
+ mncc->callref, mncc->called.plan);
+ return 0;
+ }
+
+ return 1;
}
static void check_setup(struct mncc_connection *conn, char *buf, int rc)
@@ -210,6 +240,11 @@ static void check_setup(struct mncc_connection *conn, char *buf, int rc)
}
/* TODO.. bearer caps and better audio handling */
+ if (!continue_setup(conn, data)) {
+ LOGP(DMNCC, LOGL_ERROR,
+ "MNCC screening parameters failed leg(%u)\n", data->callref);
+ return mncc_send(conn, MNCC_REJ_REQ, data->callref);
+ }
/* Create an RTP port and then allocate a call */
call = sip_call_mncc_create();