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.
This commit is contained in:
Holger Hans Peter Freyther 2016-03-23 17:41:23 +01:00
parent bc4fed27e1
commit 4f8cafa5b0
3 changed files with 58 additions and 2 deletions

View File

@ -55,3 +55,20 @@ void app_setup(struct app_config *cfg)
{ {
cfg->mncc.conn.on_disconnect = app_mncc_disconnected; 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);
}
}

View File

@ -3,6 +3,8 @@
#include "mncc.h" #include "mncc.h"
#include "sip.h" #include "sip.h"
struct call;
struct app_config { struct app_config {
struct { struct {
const char *local_addr; const char *local_addr;
@ -24,4 +26,6 @@ struct app_config {
extern struct app_config g_app; extern struct app_config g_app;
void app_setup(struct app_config *cfg); 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); void app_mncc_disconnected(struct mncc_connection *conn);

View File

@ -24,6 +24,8 @@
#include "logging.h" #include "logging.h"
#include "call.h" #include "call.h"
#include <osmocom/gsm/protocol/gsm_03_40.h>
#include <osmocom/core/socket.h> #include <osmocom/core/socket.h>
#include <osmocom/core/utils.h> #include <osmocom/core/utils.h>
@ -33,6 +35,8 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
extern void *tall_mncc_ctx;
static void close_connection(struct mncc_connection *conn); static void close_connection(struct mncc_connection *conn);
static void cmd_timeout(void *data) static void cmd_timeout(void *data)
@ -155,6 +159,21 @@ static void close_connection(struct mncc_connection *conn)
conn->on_disconnect(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) static void check_rtp_create(struct mncc_connection *conn, char *buf, int rc)
{ {
struct gsm_mncc_rtp *rtp; 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, LOGP(DMNCC, LOGL_DEBUG,
"RTP set-up continuing with call with leg(%u)\n", leg->callref); "RTP set-up continuing with call with leg(%u)\n", leg->callref);
stop_cmd_timer(leg, MNCC_RTP_CREATE); stop_cmd_timer(leg, MNCC_RTP_CREATE);
mncc_send(leg->conn, MNCC_REJ_REQ, leg->callref); continue_call(leg);
call_leg_release(&leg->base); }
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) 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 */ /* 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 */ /* Create an RTP port and then allocate a call */
call = sip_call_mncc_create(); call = sip_call_mncc_create();