summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-05-05 15:04:00 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-05-15 12:05:51 +0200
commit39b04cf6ef81a4bf8e83143b3fbaf06ce095bc81 (patch)
tree8abdefcbe97b9686a29a675cda1eb9d9e1314c62 /src/host/layer23/src
parent80de799514f20dd9d3759932d7c839902c7b7692 (diff)
layer23: modem: Use in SN SAP the TLLI retrieved from GMM and SM
Diffstat (limited to 'src/host/layer23/src')
-rw-r--r--src/host/layer23/src/common/ms.c3
-rw-r--r--src/host/layer23/src/modem/gmm.c1
-rw-r--r--src/host/layer23/src/modem/sm.c3
-rw-r--r--src/host/layer23/src/modem/sndcp.c30
4 files changed, 26 insertions, 11 deletions
diff --git a/src/host/layer23/src/common/ms.c b/src/host/layer23/src/common/ms.c
index 4b1440e2..f03427c3 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 @@ struct osmocom_ms *osmocom_ms_alloc(void *ctx, const char *name)
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 b95f15a2..b2831921 100644
--- a/src/host/layer23/src/modem/gmm.c
+++ b/src/host/layer23/src/modem/gmm.c
@@ -62,6 +62,7 @@ static int modem_gmm_prim_up_cb(struct osmo_gprs_gmm_prim *gmm_prim, void *user_
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 03982c64..63f922ab 100644
--- a/src/host/layer23/src/modem/sm.c
+++ b/src/host/layer23/src/modem/sm.c
@@ -76,6 +76,9 @@ static int modem_sm_handle_pdp_act_cnf(struct osmocom_ms *ms, struct osmo_gprs_s
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 7814e503..34b85af7 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_handle_sn_unitdata_ind(struct osmobb_apn *apn, struct osm
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 @@ static int modem_sndcp_prim_up_cb(struct osmo_gprs_sndcp_prim *sndcp_prim, void
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 @@ int modem_sndcp_sn_xid_req(struct osmobb_apn *apn)
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 @@ int modem_sndcp_sn_unitdata_req(struct osmobb_apn *apn, uint8_t *npdu, size_t np
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;