pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/32637 )


Change subject: layer23: modem: Use in SN SAP the TLLI retrieved from GMM
......................................................................

layer23: modem: Use in SN SAP the TLLI retrieved from GMM

Depends: libosmo-gprs.git Change-Id I7b1b8ac414474652b438f15b7f07961032a0f56d
Change-Id: Icac16626a6b89489b7f1ee2ab8ffbaca04e8bacc
---
M src/host/layer23/include/osmocom/bb/common/ms.h
M src/host/layer23/src/common/ms.c
M src/host/layer23/src/modem/gmm.c
M src/host/layer23/src/modem/sm.c
M src/host/layer23/src/modem/sndcp.c
5 files changed, 37 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/37/32637/1

diff --git a/src/host/layer23/include/osmocom/bb/common/ms.h 
b/src/host/layer23/include/osmocom/bb/common/ms.h
index d9c6255..bfbf879 100644
--- a/src/host/layer23/include/osmocom/bb/common/ms.h
+++ b/src/host/layer23/include/osmocom/bb/common/ms.h
@@ -24,6 +24,7 @@
        uint8_t ac_ref_nr;
        uint8_t key_seq;
        uint8_t rand[16];
+       uint32_t tlli;
 };

 struct osmosap_entity {
diff --git a/src/host/layer23/src/common/ms.c b/src/host/layer23/src/common/ms.c
index 4b1440e..f03427c 100644
--- a/src/host/layer23/src/common/ms.c
+++ b/src/host/layer23/src/common/ms.c
@@ -16,6 +16,7 @@
  * GNU General Public License for more details.
  *
  */
+#include <osmocom/gsm/gsm48.h>

 #include <osmocom/bb/common/ms.h>

@@ -54,6 +55,8 @@
        ms->l2_wq.bfd.fd = -1;
        ms->sap_wq.bfd.fd = -1;

+       ms->gmmlayer.tlli = GSM_RESERVED_TMSI;
+
        /* Register a new MS */
        llist_add_tail(&ms->entity, &ms_list);

diff --git a/src/host/layer23/src/modem/gmm.c b/src/host/layer23/src/modem/gmm.c
index b95f15a..b283192 100644
--- a/src/host/layer23/src/modem/gmm.c
+++ b/src/host/layer23/src/modem/gmm.c
@@ -62,6 +62,7 @@
                                LOGP(DGMM, LOGL_NOTICE, "%s(): Rx %s: Attach 
success P-TMSI=0x%08x\n",
                                     __func__, pdu_name, 
gmm_prim->gmmreg.attach_cnf.acc.allocated_ptmsi);
                                ms->subscr.ptmsi = 
gmm_prim->gmmreg.attach_cnf.acc.allocated_ptmsi;
+                               ms->gmmlayer.tlli = 
gmm_prim->gmmreg.attach_cnf.acc.allocated_tlli;
                                app_data.modem_state = MODEM_ST_ATTACHED;
                                /* Activate APN if not yet already: */
                                llist_for_each_entry(apn, &ms->gprs.apn_list, 
list) {
diff --git a/src/host/layer23/src/modem/sm.c b/src/host/layer23/src/modem/sm.c
index 03982c6..63f922a 100644
--- a/src/host/layer23/src/modem/sm.c
+++ b/src/host/layer23/src/modem/sm.c
@@ -76,6 +76,9 @@
                return 0;
        }

+       ms->subscr.ptmsi = sm_prim->smreg.pdp_act_cnf.acc.gmm.allocated_ptmsi;
+       ms->gmmlayer.tlli = sm_prim->smreg.pdp_act_cnf.acc.gmm.allocated_tlli;
+
        netdev = osmo_tundev_get_netdev(apn->tun);
        switch (sm_prim->smreg.pdp_act_cnf.acc.pdp_addr_ietf_type) {
        case OSMO_GPRS_SM_PDP_ADDR_IETF_IPV4:
diff --git a/src/host/layer23/src/modem/sndcp.c 
b/src/host/layer23/src/modem/sndcp.c
index 7814e50..34b85af 100644
--- a/src/host/layer23/src/modem/sndcp.c
+++ b/src/host/layer23/src/modem/sndcp.c
@@ -75,7 +75,7 @@
 static int modem_sndcp_prim_up_cb(struct osmo_gprs_sndcp_prim *sndcp_prim, 
void *user_data)
 {
        struct osmocom_ms *ms = user_data;
-       struct osmobb_apn *apn;
+       struct osmobb_apn *apn = NULL, *apn_it;
        const char *npdu_name = osmo_gprs_sndcp_prim_name(sndcp_prim);
        int rc = 0;

@@ -84,8 +84,17 @@
                OSMO_ASSERT(0);
        }

-       /* TODO: properly retrieve APN/PDP based on TLLI/SAPI/NSAPI: */
-       apn = llist_first_entry_or_null(&ms->gprs.apn_list, struct osmobb_apn, 
list);
+       if (ms->gmmlayer.tlli != sndcp_prim->sn.tlli) {
+               LOGP(DSNDCP, LOGL_ERROR, "%s(): Rx %s: MS has no 
TLLI=0x%08x\n", __func__, npdu_name, sndcp_prim->sn.tlli);
+               return -ENOENT;
+       }
+
+       llist_for_each_entry(apn_it, &ms->gprs.apn_list, list) {
+               if (apn_it->pdp.nsapi != sndcp_prim->sn.unitdata_ind.nsapi)
+                       continue;
+               apn = apn_it;
+               break;
+       }
        if (!apn) {
                LOGP(DSNDCP, LOGL_NOTICE, "Unable to find destination APN: Rx 
%s\n", npdu_name);
                return -ENODEV;
@@ -179,10 +188,9 @@
        struct osmocom_ms *ms = apn->ms;
        struct gprs_settings *set = &ms->gprs;

-       /* TODO: look up PDP context IDs from ms once we have GMM layer. */
-       uint32_t tlli = 0xe1c5d364;
-
-       sndcp_prim = osmo_gprs_sndcp_prim_alloc_sn_xid_req(tlli, 
apn->pdp.llc_sapi, apn->pdp.nsapi);
+       sndcp_prim = osmo_gprs_sndcp_prim_alloc_sn_xid_req(ms->gmmlayer.tlli,
+                                                          apn->pdp.llc_sapi,
+                                                          apn->pdp.nsapi);
        OSMO_ASSERT(sndcp_prim);
        sndcp_prim->sn.xid_req.pcomp_rfc1144.active = set->pcomp_rfc1144.active;
        sndcp_prim->sn.xid_req.pcomp_rfc1144.s01 = set->pcomp_rfc1144.s01;
@@ -199,10 +207,10 @@
        struct osmo_gprs_sndcp_prim *sndcp_prim;
        int rc;

-       /* TODO: look up PDP context IDs from apn->ms once we have GMM layer. */
-       uint32_t tlli = 0xe1c5d364;
-
-       sndcp_prim = osmo_gprs_sndcp_prim_alloc_sn_unitdata_req(tlli, 
apn->pdp.llc_sapi, apn->pdp.nsapi, npdu, npdu_len);
+       sndcp_prim = 
osmo_gprs_sndcp_prim_alloc_sn_unitdata_req(apn->ms->gmmlayer.tlli,
+                                                               
apn->pdp.llc_sapi,
+                                                               apn->pdp.nsapi,
+                                                               npdu, npdu_len);
        OSMO_ASSERT(sndcp_prim);
        rc = osmo_gprs_sndcp_prim_upper_down(sndcp_prim);
        return rc;

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

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Icac16626a6b89489b7f1ee2ab8ffbaca04e8bacc
Gerrit-Change-Number: 32637
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to