aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-10-27 16:40:21 +0300
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-10-27 17:03:42 +0300
commitbd66804082bf813a1f925c6af4df28fd664ac1de (patch)
tree8e7add447d7259143da95ec4f731fc8229641d4c
parentf3eb44f54bec0b6ebf78ccd7a182e1dbbd54f5b7 (diff)
mncc: rework passing GCR over the MNCC interface
Using *unpacked* 'struct osmo_gcr_parsed' in the MNCC PDUs makes the protocol even more complicated than it currently is, and moreover complicates implementing MNCCv8 in the ttcn3-sip-test. Replace 'struct osmo_gcr_parsed' in 'struct gsm_mncc' with a fixed-length buffer, which is supposed to hold the Global Call Reference encoded as per 3GPP TS 29.205. Check / indicate presence of GCR using the MNCC_F_GCR flag. Change-Id: Iaff46732948f8f5d03e42f17c35cbac8a80af49b Fixes: Id40d7e0fed9356f801b3627c118150055e7232b1 Related: OS#5164, OS#5282
-rw-r--r--src/mncc.c31
-rw-r--r--src/mncc_protocol.h6
2 files changed, 31 insertions, 6 deletions
diff --git a/src/mncc.c b/src/mncc.c
index c8bf4bd..f302b3e 100644
--- a/src/mncc.c
+++ b/src/mncc.c
@@ -485,6 +485,7 @@ static void check_setup(struct mncc_connection *conn, const char *buf, int rc)
const struct gsm_mncc_number *called;
struct call *call;
struct mncc_call_leg *leg;
+ struct osmo_gcr_parsed gcr;
if (rc < sizeof(*data)) {
LOGP(DMNCC, LOGL_ERROR, "gsm_mncc of wrong size %d vs. %zu\n",
@@ -525,6 +526,16 @@ static void check_setup(struct mncc_connection *conn, const char *buf, int rc)
return;
}
+ /* Decode the Global Call Reference (if present) */
+ if (data->fields & MNCC_F_GCR) {
+ if (osmo_dec_gcr(&gcr, data->gcr, sizeof(data->gcr)) < 0) {
+ LOGP(DMNCC, LOGL_ERROR,
+ "MNCC leg(%u) failed to parse GCR\n", data->callref);
+ mncc_send(conn, MNCC_REJ_REQ, data->callref);
+ return;
+ }
+ }
+
/* Create an RTP port and then allocate a call */
call = call_mncc_create();
if (!call) {
@@ -543,12 +554,15 @@ static void check_setup(struct mncc_connection *conn, const char *buf, int rc)
leg->conn = conn;
leg->state = MNCC_CC_INITIAL;
leg->dir = MNCC_DIR_MO;
- leg->base.call->gcr = data->gcr;
- leg->base.call->gcr_present = true;
memcpy(&leg->called, called, sizeof(leg->called));
memcpy(&leg->calling, &data->calling, sizeof(leg->calling));
memcpy(&leg->imsi, data->imsi, sizeof(leg->imsi));
+ if (data->fields & MNCC_F_GCR) {
+ leg->base.call->gcr_present = true;
+ leg->base.call->gcr = gcr;
+ }
+
LOGP(DMNCC, LOGL_INFO,
"Created call(%u) with MNCC leg(%u) IMSI(%.16s)\n",
call->id, leg->callref, data->imsi);
@@ -873,6 +887,7 @@ int mncc_create_remote_leg(struct mncc_connection *conn, struct call *call)
{
struct mncc_call_leg *leg;
struct gsm_mncc mncc = { 0, };
+ struct msgb *msg;
int rc;
leg = talloc_zero(call, struct mncc_call_leg);
@@ -900,8 +915,6 @@ int mncc_create_remote_leg(struct mncc_connection *conn, struct call *call)
mncc.fields |= MNCC_F_CALLING;
mncc.calling.plan = GSM48_NPI_ISDN_E164;
- if (call->gcr_present)
- mncc.gcr = call->gcr;
if (call->source && call->source[0] == '+') {
mncc.calling.type = GSM48_TON_INTERNATIONAL;
@@ -920,6 +933,16 @@ int mncc_create_remote_leg(struct mncc_connection *conn, struct call *call)
OSMO_STRLCPY_ARRAY(mncc.called.number, call->dest);
}
+ /* Encode the Global Call Reference (if present) */
+ if (call->gcr_present) {
+ msg = msgb_alloc(sizeof(mncc.gcr), "MNCC GCR");
+ if (msg == NULL || (rc = osmo_enc_gcr(msg, &call->gcr)) == 0)
+ LOGP(DMNCC, LOGL_ERROR, "MNCC leg(%u) failed to encode GCR\n", call->id);
+ else
+ memcpy(&mncc.gcr[0], msg->data, rc);
+ msgb_free(msg);
+ }
+
/*
* TODO/FIXME:
* - Determine/request channel based on offered audio codecs
diff --git a/src/mncc_protocol.h b/src/mncc_protocol.h
index 11969ee..cd592ad 100644
--- a/src/mncc_protocol.h
+++ b/src/mncc_protocol.h
@@ -26,7 +26,6 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/gsm/mncc.h>
-#include <osmocom/gsm/gsm29205.h>
#include <stdint.h>
#include <netinet/in.h>
@@ -124,6 +123,7 @@ struct gsm_call {
#define MNCC_F_CCCAP 0x0800
#define MNCC_F_KEYPAD 0x1000
#define MNCC_F_SIGNAL 0x2000
+#define MNCC_F_GCR 0x4000
struct gsm_mncc {
/* context based information */
@@ -160,7 +160,9 @@ struct gsm_mncc {
unsigned char lchan_type;
unsigned char lchan_mode;
- struct osmo_gcr_parsed gcr;
+
+ /* Global Call Reference (encoded as per 3GPP TS 29.205) */
+ uint8_t gcr[16];
/* A buffer to contain SDP ('\0' terminated) */
char sdp[1024];