jolly has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/34476?usp=email )


Change subject: ASCI: Add GCC/BCC (call control) to mobility management
......................................................................

ASCI: Add GCC/BCC (call control) to mobility management

GCC is the call control for voice group calls, BCC is the call control
for voice broadcast calls.

This patch includes the new message primitives between MM layer and the
GCC/BCC layers.

Related: OS#5364
Change-Id: If6f3cea4b2ca839559596a6ee5a3d169c6d85dbe
---
M src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h
M src/host/layer23/src/mobile/gsm48_mm.c
2 files changed, 238 insertions(+), 97 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/76/34476/1

diff --git a/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h 
b/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h
index b637a60..bdf5716 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h
@@ -8,6 +8,9 @@
 #define GSM48_MMCC_CLASS               0x100
 #define GSM48_MMSS_CLASS               0x200
 #define GSM48_MMSMS_CLASS              0x300
+#define GSM48_MMBCC_CLASS              0x500
+#define GSM48_MMGCC_CLASS              0x600
+#define GSM48_MMXX_REL_IND             0x022
 #define GSM48_MMCC_EST_REQ             0x110
 #define GSM48_MMCC_EST_IND             0x112
 #define GSM48_MMCC_EST_CNF             0x111
@@ -51,6 +54,29 @@
 #define GSM48_MMSMS_ERR_IND            0x372
 #define GSM48_MMSMS_PROMPT_IND         0x382
 #define GSM48_MMSMS_PROMPT_REJ         0x384
+/* MM messages for Voice Group/Broadcast Calls */
+#define GSM48_MMGCC_EST_REQ            0x510
+#define GSM48_MMGCC_EST_CNF            0x511
+#define GSM48_MMGCC_REL_REQ            0x520
+#define GSM48_MMGCC_REL_IND            0x522
+#define GSM48_MMGCC_DATA_REQ           0x530
+#define GSM48_MMGCC_DATA_IND           0x532
+#define GSM48_MMGCC_UNIT_DATA_REQ      0x540
+#define GSM48_MMGCC_UNIT_DATA_IND      0x542
+#define GSM48_MMGCC_REEST_REQ          0x560
+#define GSM48_MMGCC_REEST_CNF          0x561
+#define GSM48_MMGCC_ERR_IND            0x572
+#define GSM48_MMBCC_EST_REQ            0x610
+#define GSM48_MMBCC_EST_CNF            0x611
+#define GSM48_MMBCC_REL_REQ            0x620
+#define GSM48_MMBCC_REL_IND            0x622
+#define GSM48_MMBCC_DATA_REQ           0x630
+#define GSM48_MMBCC_DATA_IND           0x632
+#define GSM48_MMBCC_UNIT_DATA_REQ      0x640
+#define GSM48_MMBCC_UNIT_DATA_IND      0x642
+#define GSM48_MMBCC_REEST_REQ          0x660
+#define GSM48_MMBCC_REEST_CNF          0x661
+#define GSM48_MMBCC_ERR_IND            0x672

 #define MMXX_ALLOC_SIZE                        256
 #define MMXX_ALLOC_HEADROOM            64
diff --git a/src/host/layer23/src/mobile/gsm48_mm.c 
b/src/host/layer23/src/mobile/gsm48_mm.c
index 2bba0e1..fe7115e 100644
--- a/src/host/layer23/src/mobile/gsm48_mm.c
+++ b/src/host/layer23/src/mobile/gsm48_mm.c
@@ -639,6 +639,28 @@
        { GSM48_MMSMS_ERR_IND,          "MMSMS_ERR_IND" },
        { GSM48_MMSMS_PROMPT_IND,       "MMSMS_PROMPT_IND" },
        { GSM48_MMSMS_PROMPT_REJ,       "MMSMS_PROMPT_REJ" },
+       { GSM48_MMBCC_EST_REQ,          "MMBCC_EST_REQ" },
+       { GSM48_MMBCC_EST_CNF,          "MMBCC_EST_CNF" },
+       { GSM48_MMBCC_REL_REQ,          "MMBCC_REL_REQ" },
+       { GSM48_MMBCC_REL_IND,          "MMBCC_REL_IND" },
+       { GSM48_MMBCC_DATA_REQ,         "MMBCC_DATA_REQ" },
+       { GSM48_MMBCC_DATA_IND,         "MMBCC_DATA_IND" },
+       { GSM48_MMBCC_UNIT_DATA_REQ,    "MMBCC_UNIT_DATA_REQ" },
+       { GSM48_MMBCC_UNIT_DATA_IND,    "MMBCC_UNIT_DATA_IND" },
+       { GSM48_MMBCC_REEST_REQ,        "MMBCC_REEST_REQ" },
+       { GSM48_MMBCC_REEST_CNF,        "MMBCC_REEST_CNF" },
+       { GSM48_MMBCC_ERR_IND,          "MMBCC_ERR_IND" },
+       { GSM48_MMGCC_EST_REQ,          "MMGCC_EST_REQ" },
+       { GSM48_MMGCC_EST_CNF,          "MMGCC_EST_CNF" },
+       { GSM48_MMGCC_REL_REQ,          "MMGCC_REL_REQ" },
+       { GSM48_MMGCC_REL_IND,          "MMGCC_REL_IND" },
+       { GSM48_MMGCC_DATA_REQ,         "MMGCC_DATA_REQ" },
+       { GSM48_MMGCC_DATA_IND,         "MMGCC_DATA_IND" },
+       { GSM48_MMGCC_UNIT_DATA_REQ,    "MMGCC_UNIT_DATA_REQ" },
+       { GSM48_MMGCC_UNIT_DATA_IND,    "MMGCC_UNIT_DATA_IND" },
+       { GSM48_MMGCC_REEST_REQ,        "MMGCC_REEST_REQ" },
+       { GSM48_MMGCC_REEST_CNF,        "MMGCC_REEST_CNF" },
+       { GSM48_MMGCC_ERR_IND,          "MMGCC_ERR_IND" },
        { 0,                            NULL }
 };

@@ -764,6 +786,9 @@
                case GSM48_MMSMS_CLASS:
                        gsm411_rcv_sms(ms, msg);
                        break;
+               case GSM48_MMGCC_CLASS:
+               case GSM48_MMBCC_CLASS:
+                       break;
                }
                msgb_free(msg);
                work = 1; /* work done */
@@ -1455,6 +1480,7 @@
        struct gsm48_mm_conn *conn, *conn2;
        struct msgb *nmsg;
        struct gsm48_mmxx_hdr *nmmh;
+       int msg_type;

        /* Note: For SAPI 0 all connections are released */

@@ -1470,35 +1496,44 @@
                /* abort any OR the pending connection */
                if ((abort_any || conn->state == GSM48_MMXX_ST_CONN_PEND)
                 && (sapi == conn->sapi || sapi == 0)) {
-                       /* send MMxx-REL-IND */
-                       nmsg = NULL;
+                       /* send MMXX-REL-IND or MMXX-ERR-IND */
                        switch(conn->protocol) {
                        case GSM48_PDISC_CC:
-                               nmsg = gsm48_mmxx_msgb_alloc(
-                                       error ? GSM48_MMCC_ERR_IND
-                                       : GSM48_MMCC_REL_IND, conn->ref,
-                                               conn->transaction_id,
-                                               conn->sapi);
+                               msg_type = (error) ? GSM48_MMCC_ERR_IND
+                                                  : GSM48_MMCC_REL_IND;
                                break;
                        case GSM48_PDISC_NC_SS:
-                               nmsg = gsm48_mmxx_msgb_alloc(
-                                       error ? GSM48_MMSS_ERR_IND
-                                       : GSM48_MMSS_REL_IND, conn->ref,
-                                               conn->transaction_id,
-                                               conn->sapi);
+                               msg_type = (error) ? GSM48_MMSS_ERR_IND
+                                                  : GSM48_MMSS_REL_IND;
                                break;
                        case GSM48_PDISC_SMS:
-                               nmsg = gsm48_mmxx_msgb_alloc(
-                                       error ? GSM48_MMSMS_ERR_IND
-                                       : GSM48_MMSMS_REL_IND, conn->ref,
-                                               conn->transaction_id,
-                                               conn->sapi);
+                               msg_type = (error) ? GSM48_MMSMS_ERR_IND
+                                                  : GSM48_MMSMS_REL_IND;
                                break;
+                       case GSM48_PDISC_GROUP_CC:
+                               msg_type = (error) ? GSM48_MMGCC_ERR_IND
+                                                  : GSM48_MMGCC_REL_IND;
+                               break;
+                       case GSM48_PDISC_BCAST_CC:
+                               msg_type = (error) ? GSM48_MMBCC_ERR_IND
+                                                  : GSM48_MMBCC_REL_IND;
+                               break;
+                       default:
+                               msg_type = -1;
                        }
-                       if (!nmsg) {
+                       if (msg_type == -1) {
                                /* this should not happen */
+                               LOGP(DMM, LOGL_ERROR, "MM connection of "
+                                    "unsupported protocol? Please fix!\n");
                                mm_conn_free(conn);
-                               continue; /* skip if not of CC type */
+                               continue;
+                       }
+                       nmsg = gsm48_mmxx_msgb_alloc(msg_type, conn->ref,
+                                                    conn->transaction_id,
+                                                    conn->sapi);
+                       if (!nmsg) {
+                               mm_conn_free(conn);
+                               continue;
                        }
                        nmmh = (struct gsm48_mmxx_hdr *)nmsg->data;
                        nmmh->cause = cause;
@@ -2961,23 +2996,10 @@
                 */
                sapi = conn_found->sapi;
                reject:
-               nmsg = NULL;
-               switch(msg_type) {
-               case GSM48_MMCC_EST_REQ:
-                       nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMCC_REL_IND,
-                               mmh->ref, mmh->transaction_id, sapi);
-                       break;
-               case GSM48_MMSS_EST_REQ:
-                       nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMSS_REL_IND,
-                               mmh->ref, mmh->transaction_id, sapi);
-                       break;
-               case GSM48_MMSMS_EST_REQ:
-                       nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMSMS_REL_IND,
-                               mmh->ref, mmh->transaction_id, sapi);
-                       break;
-               }
-               if (!nmsg)
-                       return -ENOMEM;
+               nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMXX_REL_IND |
+                                            (msg_type & GSM48_MMXX_MASK),
+                                            mmh->ref, mmh->transaction_id,
+                                            sapi);
                nmmh = (struct gsm48_mmxx_hdr *)nmsg->data;
                nmmh->cause = cause;
                gsm48_mmxx_upmsg(ms, nmsg);
@@ -3049,6 +3071,16 @@
                cm_serv = GSM48_CMSERV_SMS;
                proto = GSM48_PDISC_SMS;
                break;
+       case GSM48_MMGCC_EST_REQ:
+               cause = RR_EST_CAUSE_OTHER_SDCCH;
+               cm_serv = GSM48_CMSERV_VGCS;
+               proto = GSM48_PDISC_GROUP_CC;
+               break;
+       case GSM48_MMBCC_EST_REQ:
+               cause = RR_EST_CAUSE_OTHER_SDCCH;
+               cm_serv = GSM48_CMSERV_VBS;
+               proto = GSM48_PDISC_BCAST_CC;
+               break;
        }

        /* create MM connection instance */
@@ -3184,23 +3216,10 @@
        struct gsm48_mmxx_hdr *nmmh;

        /* reject */
-       nmsg = NULL;
-       switch(msg_type) {
-       case GSM48_MMCC_EST_REQ:
-               nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMCC_REL_IND, mmh->ref,
-                       mmh->transaction_id, sapi);
-               break;
-       case GSM48_MMSS_EST_REQ:
-               nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMSS_REL_IND, mmh->ref,
-                       mmh->transaction_id, sapi);
-               break;
-       case GSM48_MMSMS_EST_REQ:
-               nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMSMS_REL_IND, mmh->ref,
-                       mmh->transaction_id, sapi);
-               break;
-       }
-       if (!nmsg)
-               return -ENOMEM;
+       nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMXX_REL_IND |
+                                    (msg_type & GSM48_MMXX_MASK),
+                                    mmh->ref, mmh->transaction_id,
+                                    sapi);
        nmmh = (struct gsm48_mmxx_hdr *)nmsg->data;
        nmmh->cause = 17;
        gsm48_mmxx_upmsg(ms, nmsg);
@@ -3264,6 +3283,16 @@
                        conn_found->ref, conn_found->transaction_id,
                        conn_found->sapi);
                break;
+       case GSM48_PDISC_GROUP_CC:
+               nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMGCC_EST_CNF,
+                       conn_found->ref, conn_found->transaction_id,
+                       conn_found->sapi);
+               break;
+       case GSM48_PDISC_BCAST_CC:
+               nmsg = gsm48_mmxx_msgb_alloc(GSM48_MMBCC_EST_CNF,
+                       conn_found->ref, conn_found->transaction_id,
+                       conn_found->sapi);
+               break;
        }
        if (!nmsg)
                return -ENOMEM;
@@ -3403,17 +3432,7 @@
        if (!conn) {
                LOGP(DMM, LOGL_INFO, "MMXX_DATA_REQ with unknown (already "
                        "released) ref=%x, sending MMXX_REL_IND\n", mmh->ref);
-               switch(msg_type & GSM48_MMXX_MASK) {
-               case GSM48_MMCC_CLASS:
-                       mmh->msg_type = GSM48_MMCC_REL_IND;
-                       break;
-               case GSM48_MMSS_CLASS:
-                       mmh->msg_type = GSM48_MMSS_REL_IND;
-                       break;
-               case GSM48_MMSMS_CLASS:
-                       mmh->msg_type = GSM48_MMSMS_REL_IND;
-                       break;
-               }
+               mmh->msg_type = GSM48_MMXX_REL_IND | (msg_type & 
GSM48_MMXX_MASK);
                mmh->cause = 31;

                /* mirror message with REL_IND + cause */
@@ -3612,6 +3631,12 @@
        {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_NORMAL_SERVICE),
         GSM48_MMSMS_EST_REQ, gsm48_mm_init_mm_no_rr},

+       {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_NORMAL_SERVICE),
+        GSM48_MMGCC_EST_REQ, gsm48_mm_init_mm_no_rr},
+
+       {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_NORMAL_SERVICE),
+        GSM48_MMBCC_EST_REQ, gsm48_mm_init_mm_no_rr},
+
        /* 4.2.2.2 Attempt to update / Loc. Upd. needed */
        {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_ATTEMPT_UPDATE) |
                                SBIT(GSM48_MM_SST_LOC_UPD_NEEDED),
@@ -3635,6 +3660,12 @@
        {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_PLMN_SEARCH_NORMAL),
         GSM48_MMSMS_EST_REQ, gsm48_mm_init_mm_no_rr},

+       {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_PLMN_SEARCH_NORMAL),
+        GSM48_MMGCC_EST_REQ, gsm48_mm_init_mm_no_rr},
+
+       {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_PLMN_SEARCH_NORMAL),
+        GSM48_MMBCC_EST_REQ, gsm48_mm_init_mm_no_rr},
+
        /* 4.2.2.6 PLMN search */
        {SBIT(GSM48_MM_ST_MM_IDLE), SBIT(GSM48_MM_SST_PLMN_SEARCH),
         GSM48_MMCC_EST_REQ, gsm48_mm_init_mm_no_rr},
@@ -3649,6 +3680,12 @@
        {SBIT(GSM48_MM_ST_RR_CONN_RELEASE_NA), ALL_STATES,
         GSM48_MMSMS_EST_REQ, gsm48_mm_init_mm_first},

+       {SBIT(GSM48_MM_ST_RR_CONN_RELEASE_NA), ALL_STATES,
+        GSM48_MMGCC_EST_REQ, gsm48_mm_init_mm_first},
+
+       {SBIT(GSM48_MM_ST_RR_CONN_RELEASE_NA), ALL_STATES,
+        GSM48_MMBCC_EST_REQ, gsm48_mm_init_mm_first},
+
        {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE), ALL_STATES,
         GSM48_MMCC_EST_REQ, gsm48_mm_init_mm_more},

@@ -3658,6 +3695,12 @@
        {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE), ALL_STATES,
         GSM48_MMSMS_EST_REQ, gsm48_mm_init_mm_more},

+       {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE), ALL_STATES,
+        GSM48_MMGCC_EST_REQ, gsm48_mm_init_mm_more},
+
+       {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE), ALL_STATES,
+        GSM48_MMBCC_EST_REQ, gsm48_mm_init_mm_more},
+
        {SBIT(GSM48_MM_ST_WAIT_NETWORK_CMD), ALL_STATES,
         GSM48_MMCC_EST_REQ, gsm48_mm_init_mm_wait},

@@ -3667,6 +3710,12 @@
        {SBIT(GSM48_MM_ST_WAIT_NETWORK_CMD), ALL_STATES,
         GSM48_MMSMS_EST_REQ, gsm48_mm_init_mm_wait},

+       {SBIT(GSM48_MM_ST_WAIT_NETWORK_CMD), ALL_STATES,
+        GSM48_MMGCC_EST_REQ, gsm48_mm_init_mm_wait},
+
+       {SBIT(GSM48_MM_ST_WAIT_NETWORK_CMD), ALL_STATES,
+        GSM48_MMBCC_EST_REQ, gsm48_mm_init_mm_wait},
+
        {ALL_STATES, ALL_STATES,
         GSM48_MMCC_EST_REQ, gsm48_mm_init_mm_reject},

@@ -3676,6 +3725,12 @@
        {ALL_STATES, ALL_STATES,
         GSM48_MMSMS_EST_REQ, gsm48_mm_init_mm_reject},

+       {ALL_STATES, ALL_STATES,
+        GSM48_MMGCC_EST_REQ, gsm48_mm_init_mm_reject},
+
+       {ALL_STATES, ALL_STATES,
+        GSM48_MMBCC_EST_REQ, gsm48_mm_init_mm_reject},
+
        /* 4.5.2.1 MM Connection (DATA) */
        {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE) |
         SBIT(GSM48_MM_ST_WAIT_ADD_OUT_MM_CON), ALL_STATES,
@@ -3689,6 +3744,14 @@
         SBIT(GSM48_MM_ST_WAIT_ADD_OUT_MM_CON), ALL_STATES,
         GSM48_MMSMS_DATA_REQ, gsm48_mm_data},

+       {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE) |
+        SBIT(GSM48_MM_ST_WAIT_ADD_OUT_MM_CON), ALL_STATES,
+        GSM48_MMGCC_DATA_REQ, gsm48_mm_data},
+
+       {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE) |
+        SBIT(GSM48_MM_ST_WAIT_ADD_OUT_MM_CON), ALL_STATES,
+        GSM48_MMBCC_DATA_REQ, gsm48_mm_data},
+
        /* 4.5.2.1 MM Connection (REL) */
        {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE), ALL_STATES,
         GSM48_MMCC_REL_REQ, gsm48_mm_release_active},
@@ -3699,6 +3762,12 @@
        {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE), ALL_STATES,
         GSM48_MMSMS_REL_REQ, gsm48_mm_release_active},

+       {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE), ALL_STATES,
+        GSM48_MMGCC_REL_REQ, gsm48_mm_release_active},
+
+       {SBIT(GSM48_MM_ST_MM_CONN_ACTIVE), ALL_STATES,
+        GSM48_MMBCC_REL_REQ, gsm48_mm_release_active},
+
        {SBIT(GSM48_MM_ST_WAIT_ADD_OUT_MM_CON), ALL_STATES,
         GSM48_MMCC_REL_REQ, gsm48_mm_release_wait_add},

@@ -3708,6 +3777,12 @@
        {SBIT(GSM48_MM_ST_WAIT_ADD_OUT_MM_CON), ALL_STATES,
         GSM48_MMSMS_REL_REQ, gsm48_mm_release_wait_add},

+       {SBIT(GSM48_MM_ST_WAIT_ADD_OUT_MM_CON), ALL_STATES,
+        GSM48_MMGCC_REL_REQ, gsm48_mm_release_wait_add},
+
+       {SBIT(GSM48_MM_ST_WAIT_ADD_OUT_MM_CON), ALL_STATES,
+        GSM48_MMBCC_REL_REQ, gsm48_mm_release_wait_add},
+
        {SBIT(GSM48_MM_ST_WAIT_OUT_MM_CONN), ALL_STATES,
         GSM48_MMCC_REL_REQ, gsm48_mm_release_wait_active},

@@ -3725,6 +3800,12 @@

        {SBIT(GSM48_MM_ST_WAIT_RR_CONN_MM_CON), ALL_STATES,
         GSM48_MMSMS_REL_REQ, gsm48_mm_release_wait_rr},
+
+       {SBIT(GSM48_MM_ST_WAIT_RR_CONN_MM_CON), ALL_STATES,
+        GSM48_MMGCC_REL_REQ, gsm48_mm_release_wait_rr},
+
+       {SBIT(GSM48_MM_ST_WAIT_RR_CONN_MM_CON), ALL_STATES,
+        GSM48_MMBCC_REL_REQ, gsm48_mm_release_wait_rr},
 };

 #define DOWNSLLEN \
@@ -3945,6 +4026,8 @@
        struct gsm48_hdr *gh = msgb_l3(msg);
        uint8_t pdisc = gh->proto_discr & 0x0f;
        uint8_t msg_type = gh->msg_type & 0xbf;
+       uint8_t transaction_id;
+       struct gsm48_mm_conn *conn;
        struct gsm48_mmxx_hdr *mmh;
        int msg_supported = 0; /* determine, if message is supported at all */
        int rr_prim = -1, rr_est = -1; /* no prim set */
@@ -3966,7 +4049,7 @@
        /* pull the RR header */
        msgb_pull(msg, sizeof(struct gsm48_rr_hdr));

-       /* create transaction (if not exists) and push message */
+       /* create transaction (if not exists) and push MM header to message */
        switch (pdisc) {
        case GSM48_PDISC_CC:
                rr_prim = GSM48_MMCC_DATA_IND;
@@ -3980,45 +4063,62 @@
                rr_prim = GSM48_MMSMS_DATA_IND;
                rr_est = GSM48_MMSMS_EST_IND;
                break;
+       case GSM48_PDISC_GROUP_CC:
+               rr_prim = GSM48_MMGCC_DATA_IND;
+               break;
+       case GSM48_PDISC_BCAST_CC:
+               rr_prim = GSM48_MMBCC_DATA_IND;
+               break;
+       default:
+               LOGP(DMM, LOGL_NOTICE, "Protocol type 0x%02x unsupported.\n",
+                    pdisc);
+               msgb_free(msg);
+               return gsm48_mm_tx_mm_status(ms,
+                       GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED);
        }
-       if (rr_prim != -1) {
-               uint8_t transaction_id = ((gh->proto_discr & 0xf0) ^ 0x80) >> 4;
-                       /* flip */
-               struct gsm48_mm_conn *conn;

-               /* find transaction, if any */
-               conn = mm_conn_by_id(mm, pdisc, transaction_id);
+       transaction_id = ((gh->proto_discr & 0xf0) ^ 0x80) >> 4; /* flip */

-               /* create MM connection instance */
-               if (!conn) {
-                       conn = mm_conn_new(mm, pdisc, transaction_id, sapi,
-                               mm_conn_new_ref++);
-                       rr_prim = rr_est;
+       /* find transaction, if any */
+       conn = mm_conn_by_id(mm, pdisc, transaction_id);
+
+       /* create MM connection instance */
+       if (!conn) {
+               /* if MT calls are not supported with protocol */
+               if (rr_est == -1) {
+                       LOGP(DMM, LOGL_ERROR, "No MO connection for pdisc=%d, "
+                            "transaction_id=%d\n", pdisc, transaction_id);
+                       msgb_free(msg);
+                       return -EINVAL;
                }
+
+               conn = mm_conn_new(mm, pdisc, transaction_id, sapi,
+                       mm_conn_new_ref++);
                if (!conn) {
                        msgb_free(msg);
                        return -ENOMEM;
                }
+               rr_prim = rr_est;
+       }

-               /* push new header */
-               msgb_push(msg, sizeof(struct gsm48_mmxx_hdr));
-               mmh = (struct gsm48_mmxx_hdr *)msg->data;
-               mmh->msg_type = rr_prim;
-               mmh->ref = conn->ref;
-               mmh->transaction_id = conn->transaction_id;
-               mmh->sapi = conn->sapi;
+       /* push new header */
+       msgb_push(msg, sizeof(struct gsm48_mmxx_hdr));
+       mmh = (struct gsm48_mmxx_hdr *)msg->data;
+       mmh->msg_type = rr_prim;
+       mmh->ref = conn->ref;
+       mmh->transaction_id = conn->transaction_id;
+       mmh->sapi = conn->sapi;

-               /* go MM CONN ACTIVE state */
-               if (mm->state == GSM48_MM_ST_WAIT_NETWORK_CMD
-                || mm->state == GSM48_MM_ST_RR_CONN_RELEASE_NA) {
-                       /* stop RR release timer */
-                       stop_mm_t3240(mm);
+       /* go MM CONN ACTIVE state */
+       if (mm->state == GSM48_MM_ST_WAIT_NETWORK_CMD
+        || mm->state == GSM48_MM_ST_RR_CONN_RELEASE_NA) {
+               /* stop RR release timer */
+               stop_mm_t3240(mm);

-                       /* stop "RR connection release not allowed" timer */
-                       stop_mm_t3241(mm);
+               /* stop "RR connection release not allowed" timer */
+               stop_mm_t3241(mm);

-                       new_mm_state(mm, GSM48_MM_ST_MM_CONN_ACTIVE, 0);
-               }
+               new_mm_state(mm, GSM48_MM_ST_MM_CONN_ACTIVE, 0);
        }

        /* forward message */
@@ -4048,12 +4148,11 @@
                msgb_free(msg);
                return rc;

-       default:
-               LOGP(DMM, LOGL_NOTICE, "Protocol type 0x%02x unsupported.\n",
-                       pdisc);
+       case GSM48_PDISC_GROUP_CC:
+       case GSM48_PDISC_BCAST_CC:
+               rc = -ENOTSUP;
                msgb_free(msg);
-               return gsm48_mm_tx_mm_status(ms,
-                       GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED);
+               return rc;
        }

        LOGP(DMM, LOGL_INFO, "(ms %s) Received '%s' in MM state %s\n", ms->name,

--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/34476?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: If6f3cea4b2ca839559596a6ee5a3d169c6d85dbe
Gerrit-Change-Number: 34476
Gerrit-PatchSet: 1
Gerrit-Owner: jolly <andr...@eversberg.eu>
Gerrit-MessageType: newchange

Reply via email to