diff --git a/include/osmocom/msc/mncc.h b/include/osmocom/msc/mncc.h index 500222763..06a5dccc0 100644 --- a/include/osmocom/msc/mncc.h +++ b/include/osmocom/msc/mncc.h @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -125,6 +124,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 */ @@ -161,7 +161,10 @@ 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]; }; diff --git a/src/libmsc/gsm_04_08_cc.c b/src/libmsc/gsm_04_08_cc.c index d6a2864e7..6562daadd 100644 --- a/src/libmsc/gsm_04_08_cc.c +++ b/src/libmsc/gsm_04_08_cc.c @@ -320,12 +320,16 @@ static void cc_paging_cb(struct msc_a *msc_a, struct gsm_trans *trans) trans->paging_request = NULL; /* Get the GCR from the MO call leg (if any). */ - if (!trans->cc.lcls) { + if (!trans->cc.lcls) trans->cc.lcls = trans_lcls_compose(trans, true); - if (trans->cc.lcls) { - trans->cc.lcls->gcr = trans->cc.msg.gcr; + if (trans->cc.lcls && trans->cc.msg.fields & MNCC_F_GCR) { + int rc = osmo_dec_gcr(&trans->cc.lcls->gcr, + &trans->cc.msg.gcr[0], + sizeof(trans->cc.msg.gcr)); + if (rc < 0) + LOG_TRANS(trans, LOGL_ERROR, "Failed to parse GCR\n"); + else trans->cc.lcls->gcr_available = true; - } } osmo_fsm_inst_dispatch(msc_a->c.fi, MSC_A_EV_TRANSACTION_ACCEPTED, trans); @@ -517,8 +521,18 @@ static int gsm48_cc_rx_setup(struct gsm_trans *trans, struct msgb *msg) trans->cc.lcls = trans_lcls_compose(trans, true); /* Pass the LCLS GCR on to the MT call leg via MNCC */ - if (trans->cc.lcls) - setup.gcr = trans->cc.lcls->gcr; + if (trans->cc.lcls) { + struct msgb *gcr_msg = msgb_alloc(sizeof(setup.gcr), "MNCC GCR"); + const struct osmo_gcr_parsed *gcr = &trans->cc.lcls->gcr; + int rc; + + if (gcr_msg != NULL && (rc = osmo_enc_gcr(gcr_msg, gcr)) > 0) { + memcpy(&setup.gcr[0], gcr_msg->data, rc); + setup.fields |= MNCC_F_GCR; + } else + LOG_TRANS(trans, LOGL_ERROR, "Failed to encode GCR\n"); + msgb_free(gcr_msg); + } tlv_parse(&tp, &gsm48_att_tlvdef, gh->data, payload_len, 0, 0); /* emergency setup is identified by msg_type */ diff --git a/tests/mncc/mncc_test.ok b/tests/mncc/mncc_test.ok index 7cb12015e..059e8080d 100644 --- a/tests/mncc/mncc_test.ok +++ b/tests/mncc/mncc_test.ok @@ -1,15 +1,15 @@ test_sdp_termination() struct gsm_mncc: -empty SDP: len=1872 sdplen=1024 sdp="\0" rc=0 -empty SDP, shortest possible: len=849 sdplen=1 sdp="\0" rc=0 -empty SDP, zero len: len=848 sdplen=0 sdp=- rc=-22 -terminated SDP str: len=1872 sdplen=1024 sdp="Privacy is a desirable marketing option\0" rc=0 -terminated SDP str, shortest possible: len=888 sdplen=40 sdp="Privacy is a desirable marketing option\0" rc=0 -terminated SDP str, but len excludes nul: len=887 sdplen=39 sdp="Privacy is a desirable marketing option" rc=-22 -terminated SDP str, but len too short: len=871 sdplen=23 sdp="Privacy is a desirable " rc=-22 -len way too short: len=10 sdplen=-838 sdp=- rc=-22 -len zero: len=0 sdplen=-848 sdp=- rc=-22 +empty SDP: len=1876 sdplen=1026 sdp="\0" rc=0 +empty SDP, shortest possible: len=851 sdplen=1 sdp="\0" rc=0 +empty SDP, zero len: len=850 sdplen=0 sdp=- rc=-22 +terminated SDP str: len=1876 sdplen=1026 sdp="Privacy is a desirable marketing option\0" rc=0 +terminated SDP str, shortest possible: len=890 sdplen=40 sdp="Privacy is a desirable marketing option\0" rc=0 +terminated SDP str, but len excludes nul: len=889 sdplen=39 sdp="Privacy is a desirable marketing option" rc=-22 +terminated SDP str, but len too short: len=873 sdplen=23 sdp="Privacy is a desirable " rc=-22 +len way too short: len=10 sdplen=-840 sdp=- rc=-22 +len zero: len=0 sdplen=-850 sdp=- rc=-22 struct gsm_mncc_rtp: empty SDP: len=1168 sdplen=1024 sdp="\0" rc=0