lynxis lazus has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-sgsn/+/37860?usp=email )

Change subject: Replace gprs_ra_id with modern osmo_routing_area_id
......................................................................

Replace gprs_ra_id with modern osmo_routing_area_id

The new modern osmo_routing_area_id is more flexible
and allow to access PLMN, LAC more convient.

Depends: Iaef54cac541913534af00f40483723e9952a6807 (libosmocore)
Change-Id: Ia41eb8f51d3836b1bc65325ff1ec6bdb16e20c7e
---
M include/osmocom/sgsn/gprs_gmm.h
M include/osmocom/sgsn/gprs_sndcp.h
M include/osmocom/sgsn/gtp.h
M include/osmocom/sgsn/mmctx.h
M src/sgsn/gprs_bssgp.c
M src/sgsn/gprs_gmm.c
M src/sgsn/gprs_sndcp.c
M src/sgsn/gprs_subscriber.c
M src/sgsn/mmctx.c
M src/sgsn/sgsn_auth.c
M src/sgsn/sgsn_cdr.c
M src/sgsn/sgsn_libgtp.c
M src/sgsn/sgsn_vty.c
M tests/sgsn/sgsn_test.c
14 files changed, 72 insertions(+), 67 deletions(-)

Approvals:
  pespin: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/include/osmocom/sgsn/gprs_gmm.h b/include/osmocom/sgsn/gprs_gmm.h
index 71dd1fa..6fca77e 100644
--- a/include/osmocom/sgsn/gprs_gmm.h
+++ b/include/osmocom/sgsn/gprs_gmm.h
@@ -9,6 +9,7 @@

 struct sgsn_mm_ctx;
 struct gprs_llc_llme;
+struct osmo_routing_area_id;

 int gsm48_tx_gmm_auth_ciph_req(struct sgsn_mm_ctx *mm,
                                      const struct osmo_auth_vector *vec,
@@ -28,8 +29,8 @@
 void gsm0408_gprs_access_cancelled(struct sgsn_mm_ctx *mmctx, int gmm_cause);
 void gsm0408_gprs_authenticate(struct sgsn_mm_ctx *mmctx);

-int gprs_gmm_rx_suspend(struct gprs_ra_id *raid, uint32_t tlli);
-int gprs_gmm_rx_resume(struct gprs_ra_id *raid, uint32_t tlli,
+int gprs_gmm_rx_suspend(struct osmo_routing_area_id *raid, uint32_t tlli);
+int gprs_gmm_rx_resume(struct osmo_routing_area_id *raid, uint32_t tlli,
                       uint8_t suspend_ref);

 int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme,
diff --git a/include/osmocom/sgsn/gprs_sndcp.h 
b/include/osmocom/sgsn/gprs_sndcp.h
index 30ea053..058cb29 100644
--- a/include/osmocom/sgsn/gprs_sndcp.h
+++ b/include/osmocom/sgsn/gprs_sndcp.h
@@ -47,7 +47,7 @@
        struct llist_head list;

        /* FIXME: move this RA_ID up to the LLME or even higher */
-       struct gprs_ra_id ra_id;
+       struct osmo_routing_area_id ra_id;
        /* reference to the LLC Entity below this SNDCP entity */
        struct gprs_llc_lle *lle;
        /* The NSAPI we shall use on top of LLC */
diff --git a/include/osmocom/sgsn/gtp.h b/include/osmocom/sgsn/gtp.h
index 1d76243..ed6cbf5 100644
--- a/include/osmocom/sgsn/gtp.h
+++ b/include/osmocom/sgsn/gtp.h
@@ -23,7 +23,7 @@
                                         uint16_t nsapi,
                                         struct tlv_parsed *tp);

-int sgsn_gtp_data_req(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi,
+int sgsn_gtp_data_req(struct osmo_routing_area_id *ra_id, int32_t tlli, 
uint8_t nsapi,
                      struct msgb *msg, uint32_t npdu_len, uint8_t *npdu);
 int sgsn_delete_pdp_ctx(struct sgsn_pdp_ctx *pctx);
 int send_act_pdp_cont_acc(struct sgsn_pdp_ctx *pctx);
diff --git a/include/osmocom/sgsn/mmctx.h b/include/osmocom/sgsn/mmctx.h
index 5e4662f..03bb845 100644
--- a/include/osmocom/sgsn/mmctx.h
+++ b/include/osmocom/sgsn/mmctx.h
@@ -105,7 +105,7 @@
        char                    imei[GSM23003_IMEISV_NUM_DIGITS+1];
        /* Opt: Software Version Numbber / TS 23.195 */
        char                    msisdn[GSM_EXTENSION_LENGTH];
-       struct gprs_ra_id       ra;
+       struct osmo_routing_area_id     ra;
        struct {
                uint16_t                cell_id;        /* Gb only */
                uint32_t                cell_id_age;    /* Gb only */
@@ -253,7 +253,7 @@

 /* look-up a SGSN MM context based on TLLI + RAI */
 struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli,
-                                       const struct gprs_ra_id *raid);
+                                       const struct osmo_routing_area_id 
*raid);
 struct sgsn_mm_ctx *sgsn_mm_ctx_by_ptmsi(uint32_t tmsi);
 struct sgsn_mm_ctx *sgsn_mm_ctx_by_imsi(const char *imsi);
 struct sgsn_mm_ctx *sgsn_mm_ctx_by_ue_ctx(const void *uectx);
@@ -261,11 +261,11 @@

 /* look-up by matching TLLI and P-TMSI (think twice before using this) */
 struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli_and_ptmsi(uint32_t tlli,
-                                       const struct gprs_ra_id *raid);
+                                       const struct osmo_routing_area_id 
*raid);

 /* Allocate a new SGSN MM context */
 struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
-                                       const struct gprs_ra_id *raid);
+                                       const struct osmo_routing_area_id 
*raid);
 struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx);

 void sgsn_mm_ctx_cleanup_free(struct sgsn_mm_ctx *ctx);
diff --git a/src/sgsn/gprs_bssgp.c b/src/sgsn/gprs_bssgp.c
index 5db751c..0a9bb91 100644
--- a/src/sgsn/gprs_bssgp.c
+++ b/src/sgsn/gprs_bssgp.c
@@ -26,6 +26,8 @@
 #include <osmocom/gprs/gprs_bssgp.h>
 #include <osmocom/gprs/gprs_ns2.h>

+#include <osmocom/gsm/gsm48.h>
+
 #include <osmocom/sgsn/gprs_llc.h>
 #include <osmocom/sgsn/gprs_gmm.h>
 #include <osmocom/sgsn/sgsn_rim.h>
@@ -35,6 +37,7 @@
 int sgsn_bssgp_rx_prim(struct osmo_prim_hdr *oph)
 {
        struct osmo_bssgp_prim *bp;
+       struct osmo_routing_area_id ra_id = {};
        bp = container_of(oph, struct osmo_bssgp_prim, oph);

        switch (oph->sap) {
@@ -45,11 +48,12 @@
                }
                break;
        case SAP_BSSGP_GMM:
+               gprs_rai_to_osmo(&ra_id, bp->ra_id);
                switch (oph->primitive) {
                case PRIM_BSSGP_GMM_SUSPEND:
-                       return gprs_gmm_rx_suspend(bp->ra_id, bp->tlli);
+                       return gprs_gmm_rx_suspend(&ra_id, bp->tlli);
                case PRIM_BSSGP_GMM_RESUME:
-                       return gprs_gmm_rx_resume(bp->ra_id, bp->tlli,
+                       return gprs_gmm_rx_resume(&ra_id, bp->tlli,
                                                  bp->u.resume.suspend_ref);
                }
                break;
diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c
index 911d42d..7f70260 100644
--- a/src/sgsn/gprs_gmm.c
+++ b/src/sgsn/gprs_gmm.c
@@ -312,7 +312,7 @@
        t = osmo_tdef_get(sgsn->cfg.T_defs, 3312, OSMO_TDEF_S, -1);
        aa->ra_upd_timer = gprs_secs_to_tmr_floor(t);
        aa->radio_prio = 0x44;  /* lowest */
-       gsm48_encode_ra(&aa->ra_id, &mm->ra);
+       osmo_routing_area_id_encode_buf((uint8_t *) &aa->ra_id, sizeof(struct 
gsm48_ra_id), &mm->ra);

 #if 0
        /* Optional: P-TMSI signature */
@@ -1195,7 +1195,7 @@
        uint8_t msnc_len, att_type, mi_len, ms_ra_acc_cap_len;
        uint16_t drx_par;
        char mi_log_string[32];
-       struct gprs_ra_id ra_id;
+       struct osmo_routing_area_id ra_id;
        uint16_t cid = 0;
        enum gsm48_gmm_cause reject_cause;
        struct osmo_mobile_identity mi;
@@ -1210,10 +1210,10 @@

        if (!MSG_IU_UE_CTX(msg)) {
                /* Gb mode */
-               cid = bssgp_parse_cell_id(&ra_id, msgb_bcid(msg));
+               bssgp_parse_cell_id2(&ra_id, &cid, msgb_bcid(msg), 8);
        } else {
 #ifdef BUILD_IU
-               ra_id = MSG_IU_UE_CTX(msg)->ra_id;
+               gprs_rai_to_osmo(&ra_id, &MSG_IU_UE_CTX(msg)->ra_id);
 #else
                LOGMMCTXP(LOGL_ERROR, ctx, "Cannot handle Iu Attach Request, 
built without Iu support\n");
                return -ENOTSUP;
@@ -1515,7 +1515,7 @@
        t = osmo_tdef_get(sgsn->cfg.T_defs, 3312, OSMO_TDEF_S, -1);
        rua->ra_upd_timer = gprs_secs_to_tmr_floor(t);

-       gsm48_encode_ra(&rua->ra_id, &mm->ra);
+       osmo_routing_area_id_encode_buf((uint8_t *)&rua->ra_id, sizeof(struct 
gsm48_ra_id), &mm->ra);

 #if 0
        /* Optional: P-TMSI signature */
@@ -1622,7 +1622,7 @@
        struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg);
        uint8_t *cur = gh->data;
        uint8_t ms_ra_acc_cap_len;
-       struct gprs_ra_id old_ra_id;
+       struct osmo_routing_area_id old_ra_id;
        struct tlv_parsed tp;
        uint8_t upd_type;
        enum gsm48_gmm_cause reject_cause = GMM_CAUSE_PROTO_ERR_UNSPEC;
@@ -1642,7 +1642,7 @@
                get_value_string(gprs_upd_t_strs, upd_type));

        /* Old routing area identification 10.5.5.15 */
-       gsm48_parse_ra(&old_ra_id, cur);
+       osmo_routing_area_id_decode(&old_ra_id, cur, msgb_l3len(msg) - (cur - 
msgb_gmmh(msg)));
        cur += 6;

        /* MS Radio Access Capability 10.5.5.12a */
@@ -1709,7 +1709,7 @@
                                msgb_tlli(msg),
                                mmctx->p_tmsi, mmctx->p_tmsi_old,
                                mmctx->gb.tlli, mmctx->gb.tlli_new,
-                               osmo_rai_name(&mmctx->ra));
+                               osmo_rai_name2(&mmctx->ra));
                        /* A RAT change will trigger the common procedure
                         * below after handling the RAT change. Protect it
                         * here from being called twice */
@@ -1717,26 +1717,26 @@
                                osmo_fsm_inst_dispatch(mmctx->gmm_fsm, 
E_GMM_COMMON_PROC_INIT_REQ, NULL);

                }
-       } else if (!gprs_ra_id_equals(&mmctx->ra, &old_ra_id) ||
+       } else if (osmo_rai_cmp(&mmctx->ra, &old_ra_id) ||
                mmctx->gmm_fsm->state == ST_GMM_DEREGISTERED)
        {
                /* We've received either a RAU for a MS which isn't registered
                 * or a RAU with an unknown RA ID. As long the SGSN doesn't 
support
                 * PS handover we treat this as invalid RAU */
-               struct gprs_ra_id new_ra_id;
+               struct osmo_routing_area_id new_ra_id = {};
                char new_ra[32];

-               bssgp_parse_cell_id(&new_ra_id, msgb_bcid(msg));
-               osmo_rai_name_buf(new_ra, sizeof(new_ra), &new_ra_id);
+               bssgp_parse_cell_id2(&new_ra_id, NULL, msgb_bcid(msg), 8);
+               osmo_rai_name2_buf(new_ra, sizeof(new_ra), &new_ra_id);

                if (mmctx->gmm_fsm->state == ST_GMM_DEREGISTERED)
                        LOGMMCTXP(LOGL_INFO, mmctx,
                                  "Rejecting RAU - GMM state is deregistered. 
Old RA: %s New RA: %s\n",
-                                 osmo_rai_name(&old_ra_id), new_ra);
+                                 osmo_rai_name2(&old_ra_id), new_ra);
                else
                        LOGMMCTXP(LOGL_INFO, mmctx,
                                  "Rejecting RAU - Old RA doesn't match MM. Old 
RA: %s New RA: %s\n",
-                                 osmo_rai_name(&old_ra_id), new_ra);
+                                 osmo_rai_name2(&old_ra_id), new_ra);

                reject_cause = GMM_CAUSE_IMPL_DETACHED;
                goto rejected;
@@ -1757,10 +1757,10 @@
                        mmctx = sgsn_mm_ctx_by_llme(llme);
                        if (mmctx) {
                                char old_ra_id_name[32];
-                               osmo_rai_name_buf(old_ra_id_name, 
sizeof(old_ra_id_name), &old_ra_id);
+                               osmo_rai_name2_buf(old_ra_id_name, 
sizeof(old_ra_id_name), &old_ra_id);
                                LOGMMCTXP(LOGL_NOTICE, mmctx,
                                          "Rx RA Update Request with unexpected 
TLLI=%08x Old RA=%s (expected Old RA: %s)!\n",
-                                         msgb_tlli(msg), old_ra_id_name, 
osmo_rai_name(&mmctx->ra));
+                                         msgb_tlli(msg), old_ra_id_name, 
osmo_rai_name2(&mmctx->ra));
                                /* mmctx will be released (and its llme un 
assigned) after REJECT below. */
                        }
                }
@@ -1784,7 +1784,7 @@

        /* Update the MM context with the new RA-ID */
        if (mmctx->ran_type == MM_CTX_T_GERAN_Gb && msgb_bcid(msg)) {
-               bssgp_parse_cell_id(&mmctx->ra, msgb_bcid(msg));
+               bssgp_parse_cell_id2(&mmctx->ra, NULL, msgb_bcid(msg), 8);
                /* Update the MM context with the new (i.e. foreign) TLLI */
                mmctx->gb.tlli = msgb_tlli(msg);
        }
@@ -2292,7 +2292,7 @@
        return rc;
 }

-int gprs_gmm_rx_suspend(struct gprs_ra_id *raid, uint32_t tlli)
+int gprs_gmm_rx_suspend(struct osmo_routing_area_id *raid, uint32_t tlli)
 {
        struct sgsn_mm_ctx *mmctx;

@@ -2314,7 +2314,7 @@
        return 0;
 }

-int gprs_gmm_rx_resume(struct gprs_ra_id *raid, uint32_t tlli,
+int gprs_gmm_rx_resume(struct osmo_routing_area_id *raid, uint32_t tlli,
                       uint8_t suspend_ref)
 {
        struct sgsn_mm_ctx *mmctx;
@@ -2355,10 +2355,10 @@
        struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg);
        uint8_t pdisc = gsm48_hdr_pdisc(gh);
        struct sgsn_mm_ctx *mmctx;
-       struct gprs_ra_id ra_id;
+       struct osmo_routing_area_id ra_id = {};
        int rc = -EINVAL;

-       bssgp_parse_cell_id(&ra_id, msgb_bcid(msg));
+       bssgp_parse_cell_id2(&ra_id, NULL, msgb_bcid(msg), 8);
        mmctx = sgsn_mm_ctx_by_tlli(msgb_tlli(msg), &ra_id);
        if (mmctx) {
                rate_ctr_inc(rate_ctr_group_get_ctr(mmctx->ctrg, 
GMM_CTR_PKTS_SIG_IN));
diff --git a/src/sgsn/gprs_sndcp.c b/src/sgsn/gprs_sndcp.c
index 3eae127..636fe2e 100644
--- a/src/sgsn/gprs_sndcp.c
+++ b/src/sgsn/gprs_sndcp.c
@@ -834,7 +834,7 @@
                return -EIO;
        }
        /* FIXME: move this RA_ID up to the LLME or even higher */
-       bssgp_parse_cell_id(&sne->ra_id, msgb_bcid(msg));
+       bssgp_parse_cell_id2(&sne->ra_id, NULL, msgb_bcid(msg), 8);

        mmctx = sgsn_mm_ctx_by_tlli(msgb_tlli(msg), &sne->ra_id);
        if (!mmctx) {
diff --git a/src/sgsn/gprs_subscriber.c b/src/sgsn/gprs_subscriber.c
index a52abe8..07ea4c2 100644
--- a/src/sgsn/gprs_subscriber.c
+++ b/src/sgsn/gprs_subscriber.c
@@ -877,8 +877,8 @@

        osmo_strlcpy(subscr->imei, mmctx->imei, sizeof(subscr->imei));

-       if (subscr->lac != mmctx->ra.lac)
-               subscr->lac = mmctx->ra.lac;
+       if (subscr->lac != mmctx->ra.lac.lac)
+               subscr->lac = mmctx->ra.lac.lac;
 
        subscr->sgsn_data->mm = mmctx;
        mmctx->subscr = gprs_subscr_get(subscr);
diff --git a/src/sgsn/mmctx.c b/src/sgsn/mmctx.c
index 459f6cf..e0af4ed 100644
--- a/src/sgsn/mmctx.c
+++ b/src/sgsn/mmctx.c
@@ -122,13 +122,13 @@

 /* look-up a SGSN MM context based on TLLI + RAI */
 struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli,
-                                       const struct gprs_ra_id *raid)
+                                       const struct osmo_routing_area_id *raid)
 {
        struct sgsn_mm_ctx *ctx;

        llist_for_each_entry(ctx, &sgsn->mm_list, list) {
                if ((tlli == ctx->gb.tlli || tlli == ctx->gb.tlli_new) &&
-                   gprs_ra_id_equals(raid, &ctx->ra))
+                   !osmo_rai_cmp(raid, &ctx->ra))
                        return ctx;
        }

@@ -136,7 +136,7 @@
 }

 struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli_and_ptmsi(uint32_t tlli,
-                                       const struct gprs_ra_id *raid)
+                                       const struct osmo_routing_area_id *raid)
 {
        struct sgsn_mm_ctx *ctx;
        int tlli_type;
@@ -153,7 +153,7 @@
        llist_for_each_entry(ctx, &sgsn->mm_list, list) {
                if ((gprs_tmsi2tlli(ctx->p_tmsi, tlli_type) == tlli ||
                     gprs_tmsi2tlli(ctx->p_tmsi_old, tlli_type) == tlli) &&
-                   gprs_ra_id_equals(raid, &ctx->ra))
+                   !osmo_rai_cmp(raid, &ctx->ra))
                        return ctx;
        }

@@ -239,7 +239,7 @@
 }
 /* Allocate a new SGSN MM context for GERAN_Gb */
 struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
-                                        const struct gprs_ra_id *raid)
+                                        const struct osmo_routing_area_id 
*raid)
 {
        struct sgsn_mm_ctx *ctx;

@@ -267,7 +267,7 @@
                return NULL;

        /* Need to get RAID from IU conn */
-       ctx->ra = ue_ctx->ra_id;
+       gprs_rai_to_osmo(&ctx->ra, &ue_ctx->ra_id);
        ctx->ran_type = MM_CTX_T_UTRAN_Iu;
        ctx->iu.ue_ctx = ue_ctx;
        ctx->iu.ue_ctx->rab_assign_addr_enc = sgsn->cfg.iu.rab_assign_addr_enc;
diff --git a/src/sgsn/sgsn_auth.c b/src/sgsn/sgsn_auth.c
index cbff6f8..2f5bc8c 100644
--- a/src/sgsn/sgsn_auth.c
+++ b/src/sgsn/sgsn_auth.c
@@ -133,9 +133,9 @@
                /* We simply assume that the IMSI exists, as long as it is part
                 * of 'our' network */
                snprintf(mccmnc, sizeof(mccmnc), "%s%s",
-                        osmo_mcc_name(mmctx->ra.mcc),
-                        osmo_mnc_name(mmctx->ra.mnc, mmctx->ra.mnc_3_digits));
-               if (strncmp(mccmnc, mmctx->imsi, mmctx->ra.mnc_3_digits ? 6 : 
5) == 0)
+                        osmo_mcc_name(mmctx->ra.lac.plmn.mcc),
+                        osmo_mnc_name(mmctx->ra.lac.plmn.mnc, 
mmctx->ra.lac.plmn.mnc_3_digits));
+               if (strncmp(mccmnc, mmctx->imsi, 
mmctx->ra.lac.plmn.mnc_3_digits ? 6 : 5) == 0)
                        return SGSN_AUTH_ACCEPTED;
        }

diff --git a/src/sgsn/sgsn_cdr.c b/src/sgsn/sgsn_cdr.c
index 1536c13..1979d92 100644
--- a/src/sgsn/sgsn_cdr.c
+++ b/src/sgsn/sgsn_cdr.c
@@ -92,7 +92,7 @@
                mmctx->imei,
                mmctx->msisdn,
                mmctx->gb.cell_id,
-               mmctx->ra.lac,
+               mmctx->ra.lac.lac,
                mmctx->hlr,
                ev);
        return ret;
@@ -194,7 +194,7 @@
                pdp->mm ? pdp->mm->imei : "N/A",
                pdp->mm ? pdp->mm->msisdn : "N/A",
                pdp->mm ? pdp->mm->gb.cell_id : -1,
-               pdp->mm ? pdp->mm->ra.lac : -1,
+               pdp->mm ? pdp->mm->ra.lac.lac : -1,
                pdp->mm ? pdp->mm->hlr : "N/A",
                ev,
                (unsigned long ) duration,
diff --git a/src/sgsn/sgsn_libgtp.c b/src/sgsn/sgsn_libgtp.c
index 39dcc7a..faf0e7f 100644
--- a/src/sgsn/sgsn_libgtp.c
+++ b/src/sgsn/sgsn_libgtp.c
@@ -143,7 +143,7 @@
                                         uint16_t nsapi,
                                         struct tlv_parsed *tp)
 {
-       struct gprs_ra_id raid;
+       struct osmo_routing_area_id raid = {};
        struct sgsn_pdp_ctx *pctx;
        struct pdp_t *pdp;
        uint64_t imsi_ui64;
@@ -273,9 +273,9 @@
        /* Routing Area Identifier with LAC and RAC fixed values, as
         * requested in 29.006 7.3.1 */
        raid = mmctx->ra;
-       raid.lac = 0xFFFE;
+       raid.lac.lac = 0xFFFE;
        raid.rac = 0xFF;
-       gsm48_encode_ra((struct gsm48_ra_id *)pdp->rai.v, &raid);
+       osmo_routing_area_id_encode_buf(pdp->rai.v, pdp->rai.l, &raid);

        /* Encode User Location Information accordint to TS 29.060 7.7.51 */
        pdp->userloc_given = 1;
@@ -290,12 +290,12 @@
                pdp->userloc_given = 1;
                pdp->userloc.l = 8;
                pdp->userloc.v[0] = 0; /* CGI for GERAN */
-               bssgp_create_cell_id(&pdp->userloc.v[1], &mmctx->ra, 
mmctx->gb.cell_id);
+               bssgp_create_cell_id2(&pdp->userloc.v[1], 8, &mmctx->ra, 
mmctx->gb.cell_id);
                break;
        case MM_CTX_T_UTRAN_Iu:
                pdp->userloc.v[0] = 1; /* SAI for UTRAN */
                /* SAI is like CGI but with SAC instead of CID, so we can abuse 
this function */
-               bssgp_create_cell_id(&pdp->userloc.v[1], &mmctx->ra, 
mmctx->iu.sac);
+               bssgp_create_cell_id2(&pdp->userloc.v[1], 8, &mmctx->ra, 
mmctx->iu.sac);
                break;
        }

@@ -684,7 +684,7 @@
                        rc = osmo_fsm_inst_dispatch(mm->iu.mm_state_fsm, 
E_PMM_RX_GGSN_GTPU_DT_EI, pctx);
                        rc = gtp_update_context_resp(sgsn->gsn, pdp,
                                 GTPCAUSE_ACC_REQ);
-                       ranap_iu_page_ps(mm->imsi, &mm->p_tmsi, mm->ra.lac, 
mm->ra.rac);
+                       ranap_iu_page_ps(mm->imsi, &mm->p_tmsi, mm->ra.lac.lac, 
mm->ra.rac);
                        return rc;
                }
 #endif
@@ -828,7 +828,7 @@
                 * reestablished */
                LOGMMCTXP(LOGL_INFO, mm, "Rx GTP for UE in PMM state %s, paging 
it\n",
                          osmo_fsm_inst_state_name(mm->iu.mm_state_fsm));
-               ranap_iu_page_ps(mm->imsi, &mm->p_tmsi, mm->ra.lac, mm->ra.rac);
+               ranap_iu_page_ps(mm->imsi, &mm->p_tmsi, mm->ra.lac.lac, 
mm->ra.rac);

                return 0;
 #else
@@ -890,7 +890,7 @@
 }

 /* Called by SNDCP when it has received/re-assembled a N-PDU */
-int sgsn_gtp_data_req(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi,
+int sgsn_gtp_data_req(struct osmo_routing_area_id *ra_id, int32_t tlli, 
uint8_t nsapi,
                         struct msgb *msg, uint32_t npdu_len, uint8_t *npdu)
 {
        struct sgsn_mm_ctx *mmctx;
diff --git a/src/sgsn/sgsn_vty.c b/src/sgsn/sgsn_vty.c
index 6ca5a7d..bcb8dc2 100644
--- a/src/sgsn/sgsn_vty.c
+++ b/src/sgsn/sgsn_vty.c
@@ -651,7 +651,7 @@
                pfx, mm->msisdn, id, mm->hlr, VTY_NEWLINE);
        vty_out(vty, "%s  GMM State: %s, Routeing Area: %s, Cell ID: %u%s",
                pfx, osmo_fsm_inst_state_name(mm->gmm_fsm),
-               osmo_rai_name(&mm->ra), mm->gb.cell_id, VTY_NEWLINE);
+               osmo_rai_name2(&mm->ra), mm->gb.cell_id, VTY_NEWLINE);
        vty_out(vty, "%s  MM State: %s, RAN Type: %s%s", pfx, mm_state_name,
                get_value_string(sgsn_ran_type_names, mm->ran_type), 
VTY_NEWLINE);

diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c
index a149b8e..29dad74 100644
--- a/tests/sgsn/sgsn_test.c
+++ b/tests/sgsn/sgsn_test.c
@@ -181,7 +181,7 @@
 /*
  * Create a context and search for it
  */
-static struct sgsn_mm_ctx *alloc_mm_ctx(uint32_t tlli, struct gprs_ra_id *raid)
+static struct sgsn_mm_ctx *alloc_mm_ctx(uint32_t tlli, struct 
osmo_routing_area_id *raid)
 {
        struct sgsn_mm_ctx *ctx, *ictx;
        struct gprs_llc_lle *lle;
@@ -200,7 +200,7 @@
 }

 static void send_0408_message(struct gprs_llc_llme *llme, uint32_t tlli,
-                             const struct gprs_ra_id *bssgp_raid,
+                             const struct osmo_routing_area_id *bssgp_raid,
                              const uint8_t *data, size_t data_len)
 {
        struct msgb *msg;
@@ -210,7 +210,7 @@

        msg = create_msg(data, data_len);
        msgb_tlli(msg) = tlli;
-       bssgp_create_cell_id(msgb_bcid(msg), bssgp_raid, 0);
+       bssgp_create_cell_id2(msgb_bcid(msg), 8, bssgp_raid, 0);
        gsm0408_gprs_rcvmsg_gb(msg, llme, false);
        msgb_free(msg);
 }
@@ -375,7 +375,7 @@
        const char *imsi1 = "1234567890";
        struct gsm_auth_tuple *at;
        struct sgsn_mm_ctx *ctx;
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        uint32_t local_tlli = 0xffeeddcc;

        printf("Testing authentication triplet handling\n");
@@ -455,7 +455,7 @@
        struct gprs_subscr *s1, *s1found;
        const char *imsi1 = "1234567890";
        struct sgsn_mm_ctx *ctx;
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        uint32_t local_tlli = 0xffeeddcc;
        struct sgsn_subscriber_pdp_data *pdpd;
        int rc;
@@ -740,7 +740,7 @@
  */
 static void test_gmm_detach(void)
 {
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        struct sgsn_mm_ctx *ctx, *ictx;
        uint32_t local_tlli;

@@ -782,7 +782,7 @@
  */
 static void test_gmm_detach_power_off(void)
 {
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        struct sgsn_mm_ctx *ctx, *ictx;
        uint32_t local_tlli;

@@ -823,7 +823,7 @@
  */
 static void test_gmm_detach_no_mmctx(void)
 {
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        struct gprs_llc_lle *lle;
        uint32_t local_tlli;

@@ -860,7 +860,7 @@
  */
 static void test_gmm_detach_accept_unexpected(void)
 {
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        struct gprs_llc_lle *lle;
        uint32_t local_tlli;

@@ -897,7 +897,7 @@
  */
 static void test_gmm_status_no_mmctx(void)
 {
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        struct gprs_llc_lle *lle;
        uint32_t local_tlli;

@@ -1092,7 +1092,7 @@
  */
 static void test_gmm_reject(void)
 {
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        struct sgsn_mm_ctx *ctx = NULL;
        uint32_t foreign_tlli;
        struct gprs_llc_lle *lle;
@@ -1237,7 +1237,7 @@
  */
 static void test_gmm_cancel(void)
 {
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        struct sgsn_mm_ctx *ctx = NULL;
        struct sgsn_mm_ctx *ictx;
        uint32_t ptmsi1;
@@ -1446,7 +1446,7 @@
        struct gprs_subscr *s1;
        const char *imsi1 = "1234567890";
        struct sgsn_mm_ctx *ctx;
-       struct gprs_ra_id raid = { 0, };
+       struct osmo_routing_area_id raid = { 0, };
        uint32_t local_tlli = 0xffeeddcc;
        enum gsm48_gsm_cause gsm_cause;
        struct tlv_parsed tp;

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

Gerrit-MessageType: merged
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: Ia41eb8f51d3836b1bc65325ff1ec6bdb16e20c7e
Gerrit-Change-Number: 37860
Gerrit-PatchSet: 4
Gerrit-Owner: lynxis lazus <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: lynxis lazus <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to