pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-gprs/+/32636 )

Change subject: sm: Use & forward to upper layers the PTMSI & TLLI received 
from GMM
......................................................................

sm: Use & forward to upper layers the PTMSI & TLLI received from GMM

App and SM itself may need access to PTMSI or TLLI.

PTMSI:
- App may want to store it somewhere in order to reuse it next time
  it wants to GMM Attach.
TLLI:
- App will need the TLLI to identify the MS when sending/receiving
  primitives over SN SAP (app<->SNDCP).
- SM layer will need the TLLI to communicate over SNSM SAP (SM<->SNDCP),
  as well as relay the information to the app if the GMM Attach happens
  implicitly over SMREG-Act_Pdp_Ctx.req -> GMMSM-Establish-Req.

Change-Id: I7b1b8ac414474652b438f15b7f07961032a0f56d
---
M include/osmocom/gprs/sm/sm_prim.h
M include/osmocom/gprs/sm/sm_private.h
M src/sm/sm.c
M src/sm/sm_prim.c
4 files changed, 42 insertions(+), 7 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved




diff --git a/include/osmocom/gprs/sm/sm_prim.h 
b/include/osmocom/gprs/sm/sm_prim.h
index 86a36d2..baa85ed 100644
--- a/include/osmocom/gprs/sm/sm_prim.h
+++ b/include/osmocom/gprs/sm/sm_prim.h
@@ -85,6 +85,10 @@
                                        uint8_t radio_prio;     /* TS 24.008 
10.5.7.2 */
                                        uint8_t qos[OSMO_GPRS_SM_QOS_MAXLEN];
                                        uint8_t qos_len;
+                                       struct {
+                                               uint32_t allocated_ptmsi;
+                                               uint32_t allocated_tlli;
+                                       } gmm;
                                } acc;
                                struct {
                                        uint8_t cause;
diff --git a/include/osmocom/gprs/sm/sm_private.h 
b/include/osmocom/gprs/sm/sm_private.h
index 163014e..99beaeb 100644
--- a/include/osmocom/gprs/sm/sm_private.h
+++ b/include/osmocom/gprs/sm/sm_private.h
@@ -127,6 +127,7 @@
 
        struct {
                uint32_t ptmsi;
+               uint32_t tlli;
                char imsi[OSMO_IMSI_BUF_SIZE];
                char imei[GSM23003_IMEI_NUM_DIGITS + 1];
                char imeisv[GSM23003_IMEISV_NUM_DIGITS+1];
diff --git a/src/sm/sm.c b/src/sm/sm.c
index 1f87f4e..3cddb58 100644
--- a/src/sm/sm.c
+++ b/src/sm/sm.c
@@ -128,7 +128,7 @@
        struct gprs_sm_ms *ms;

        llist_for_each_entry(ms, &g_sm_ctx->ms_list, list) {
-               if (ms->gmm.ptmsi == tlli)
+               if (ms->gmm.tlli == tlli)
                        return ms;
        }
        return NULL;
@@ -222,6 +222,8 @@
                sm_prim_tx->smreg.pdp_act_cnf.acc.qos_len = sme->qos_len;
                if (sme->qos_len)
                        memcpy(sm_prim_tx->smreg.pdp_act_cnf.acc.qos, 
&sme->qos, sme->qos_len);
+               sm_prim_tx->smreg.pdp_act_cnf.acc.gmm.allocated_ptmsi = 
sme->ms->gmm.ptmsi;
+               sm_prim_tx->smreg.pdp_act_cnf.acc.gmm.allocated_tlli = 
sme->ms->gmm.tlli;
        } else {
                sm_prim_tx->smreg.pdp_act_cnf.rej.cause = cause;
        }
@@ -237,7 +239,7 @@
        int rc;
 
        sndcp_prim_tx = osmo_gprs_sndcp_prim_alloc_snsm_activate_ind(
-                               sme->ms->gmm.ptmsi,
+                               sme->ms->gmm.tlli,
                                sme->nsapi,
                                sme->llc_sapi);
        //sndcp_prim_tx->snsm.activat_ind.qos_params = ; /* TODO */
diff --git a/src/sm/sm_prim.c b/src/sm/sm_prim.c
index c0fbca4..bb5653e 100644
--- a/src/sm/sm_prim.c
+++ b/src/sm/sm_prim.c
@@ -25,6 +25,7 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/core/logging.h>
+#include <osmocom/gsm/gsm48.h>

 #include <osmocom/gprs/sm/sm.h>
 #include <osmocom/gprs/sm/sm_prim.h>
@@ -466,17 +467,23 @@
 {
        struct osmo_gprs_gmm_gmmsm_prim *gmmsm = &gmm_prim->gmmsm;
        struct gprs_sm_entity *sme;
-       int rc, ev;
+       int rc;

        sme = gprs_sm_find_sme_by_sess_id(gmmsm->sess_id);
        if (!sme) {
                LOGSM(LOGL_ERROR, "Rx GMMSM-ESTABLISH.cnf for non existing SM 
Entity\n");
                return -EINVAL;
        }
-
-       ev = gmmsm->establish_cnf.accepted ?
-               GPRS_SM_MS_EV_RX_GMM_ESTABLISH_CNF : 
GPRS_SM_MS_EV_RX_GMM_ESTABLISH_REJ;
-       rc = osmo_fsm_inst_dispatch(sme->ms_fsm.fi, ev, NULL);
+       if (gmmsm->establish_cnf.accepted) {
+               /* Update allocated PTMSI: */
+               if (gmm_prim->gmmsm.establish_cnf.acc.allocated_ptmsi != 
GSM_RESERVED_TMSI)
+                       sme->ms->gmm.ptmsi = 
gmm_prim->gmmsm.establish_cnf.acc.allocated_ptmsi;
+               /* Set allocated TLLI: */
+               sme->ms->gmm.tlli = 
gmm_prim->gmmsm.establish_cnf.acc.allocated_tlli;
+               rc = osmo_fsm_inst_dispatch(sme->ms_fsm.fi, 
GPRS_SM_MS_EV_RX_GMM_ESTABLISH_CNF, NULL);
+       } else {
+               rc = osmo_fsm_inst_dispatch(sme->ms_fsm.fi, 
GPRS_SM_MS_EV_RX_GMM_ESTABLISH_REJ, NULL);
+       }

        return rc;
 }

--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/32636
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I7b1b8ac414474652b438f15b7f07961032a0f56d
Gerrit-Change-Number: 32636
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to