From 12ed86d17a3c2da43317def79073d5259dd61053 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Sun, 4 Aug 2024 22:09:37 +0200 Subject: [PATCH] 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 --- include/osmocom/sgsn/gprs_gmm.h | 5 ++-- include/osmocom/sgsn/gprs_sndcp.h | 2 +- include/osmocom/sgsn/gtp.h | 2 +- include/osmocom/sgsn/mmctx.h | 8 +++--- src/sgsn/gprs_bssgp.c | 8 ++++-- src/sgsn/gprs_gmm.c | 42 +++++++++++++++---------------- src/sgsn/gprs_sndcp.c | 2 +- src/sgsn/gprs_subscriber.c | 4 +-- src/sgsn/mmctx.c | 12 ++++----- src/sgsn/sgsn_auth.c | 6 ++--- src/sgsn/sgsn_cdr.c | 4 +-- src/sgsn/sgsn_libgtp.c | 16 ++++++------ src/sgsn/sgsn_vty.c | 2 +- tests/sgsn/sgsn_test.c | 26 +++++++++---------- 14 files changed, 72 insertions(+), 67 deletions(-) diff --git a/include/osmocom/sgsn/gprs_gmm.h b/include/osmocom/sgsn/gprs_gmm.h index 71dd1fa7f..6fca77e05 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_denied(struct sgsn_mm_ctx *mmctx, int gmm_cause); 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 30ea05308..058cb2952 100644 --- a/include/osmocom/sgsn/gprs_sndcp.h +++ b/include/osmocom/sgsn/gprs_sndcp.h @@ -47,7 +47,7 @@ struct gprs_sndcp_entity { 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 1d76243ce..ed6cbf508 100644 --- a/include/osmocom/sgsn/gtp.h +++ b/include/osmocom/sgsn/gtp.h @@ -23,7 +23,7 @@ struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn, 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 5e4662f06..03bb8452e 100644 --- a/include/osmocom/sgsn/mmctx.h +++ b/include/osmocom/sgsn/mmctx.h @@ -105,7 +105,7 @@ struct sgsn_mm_ctx { 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 @@ static inline bool sgsn_mm_ctx_is_authenticated(struct sgsn_mm_ctx *ctx) /* 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 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_llme(const struct gprs_llc_llme *llme); /* 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 5db751cce..0a9bb915b 100644 --- a/src/sgsn/gprs_bssgp.c +++ b/src/sgsn/gprs_bssgp.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -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 @@ int sgsn_bssgp_rx_prim(struct osmo_prim_hdr *oph) } 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 911d42d7d..7f702607b 100644 --- a/src/sgsn/gprs_gmm.c +++ b/src/sgsn/gprs_gmm.c @@ -312,7 +312,7 @@ int gsm48_tx_gmm_att_ack(struct sgsn_mm_ctx *mm) 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 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg, 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 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg, 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 @@ static int gsm48_tx_gmm_ra_upd_ack(struct sgsn_mm_ctx *mm) 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 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg, 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 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg, 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 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg, 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 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg, 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 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg, 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 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg, /* 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 @@ int gsm0408_gprs_force_reattach(struct sgsn_mm_ctx *mmctx) 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 @@ int gprs_gmm_rx_suspend(struct gprs_ra_id *raid, uint32_t tlli) 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 @@ int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme, 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 3eae127fc..636fe2e4b 100644 --- a/src/sgsn/gprs_sndcp.c +++ b/src/sgsn/gprs_sndcp.c @@ -834,7 +834,7 @@ int sndcp_ll_unitdata_ind(struct msgb *msg, struct gprs_llc_lle *lle, 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 a52abe8f1..07ea4c26c 100644 --- a/src/sgsn/gprs_subscriber.c +++ b/src/sgsn/gprs_subscriber.c @@ -877,8 +877,8 @@ struct gprs_subscr *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mmctx 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 459f6cfe1..e0af4edd0 100644 --- a/src/sgsn/mmctx.c +++ b/src/sgsn/mmctx.c @@ -122,13 +122,13 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_llme(const struct gprs_llc_llme *llme) /* 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(uint32_t tlli, } 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 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli_and_ptmsi(uint32_t tlli, 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 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t rate_ctr_id) } /* 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 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx) 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 cbff6f8ba..2f5bc8cf9 100644 --- a/src/sgsn/sgsn_auth.c +++ b/src/sgsn/sgsn_auth.c @@ -133,9 +133,9 @@ enum sgsn_auth_state sgsn_auth_state(struct sgsn_mm_ctx *mmctx) /* 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 1536c135a..1979d9261 100644 --- a/src/sgsn/sgsn_cdr.c +++ b/src/sgsn/sgsn_cdr.c @@ -92,7 +92,7 @@ static int cdr_snprintf_mm(char *buf, size_t size, const char *ev, mmctx->imei, mmctx->msisdn, mmctx->gb.cell_id, - mmctx->ra.lac, + mmctx->ra.lac.lac, mmctx->hlr, ev); return ret; @@ -194,7 +194,7 @@ static int cdr_snprintf_pdp(char *buf, size_t size, const char *ev, 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 39dcc7a03..faf0e7f57 100644 --- a/src/sgsn/sgsn_libgtp.c +++ b/src/sgsn/sgsn_libgtp.c @@ -143,7 +143,7 @@ struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn, 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 @@ struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn, /* 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 @@ struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn, 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 @@ static int cb_update_context_ind(struct pdp_t *pdp) 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 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len) * 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 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len) } /* 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 6ca5a7d25..bcb8dc208 100644 --- a/src/sgsn/sgsn_vty.c +++ b/src/sgsn/sgsn_vty.c @@ -651,7 +651,7 @@ static void vty_dump_mmctx(struct vty *vty, const char *pfx, 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 a149b8e2c..29dad74f0 100644 --- a/tests/sgsn/sgsn_test.c +++ b/tests/sgsn/sgsn_test.c @@ -181,7 +181,7 @@ static struct msgb *create_msg(const uint8_t *data, size_t len) /* * 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 struct sgsn_mm_ctx *alloc_mm_ctx(uint32_t tlli, struct gprs_ra_id *raid) } 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 @@ static void send_0408_message(struct gprs_llc_llme *llme, uint32_t tlli, 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 @@ static void test_auth_triplets(void) 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 @@ static void test_subscriber_gsup(void) 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 @@ int my_gsup_client_send_dummy(struct osmo_gsup_client *gsupc, struct msgb *msg) */ 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(void) */ 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_power_off(void) */ 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_no_mmctx(void) */ 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_detach_accept_unexpected(void) */ 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 @@ int my_gsup_client_send(struct osmo_gsup_client *gsupc, struct msgb *msg) */ 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_reject(void) */ 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 @@ static void test_ggsn_selection(void) 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;