From 15ed01db1a377714912cdc6d848c9558d24ca3fe Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 25 Dec 2015 19:12:21 +0100 Subject: prepare sgsn_mm_ctx for Gb and Iu mode (UMTS) Let's explicitly mark those sgsn_mm_ctx members that apply for Gb mode and (upcoming) Iu mode, respectively. --- openbsc/include/openbsc/gprs_sgsn.h | 61 ++++++++++++++++++++++++++++++------- openbsc/src/gprs/gprs_gmm.c | 46 ++++++++++++++-------------- openbsc/src/gprs/gprs_llc.c | 8 ++--- openbsc/src/gprs/gprs_sgsn.c | 16 +++++----- openbsc/src/gprs/sgsn_cdr.c | 4 +-- openbsc/src/gprs/sgsn_libgtp.c | 20 ++++++------ openbsc/src/gprs/sgsn_vty.c | 4 +-- 7 files changed, 99 insertions(+), 60 deletions(-) diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index 61120b1e3..ea838506d 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -93,11 +93,22 @@ struct sgsn_ggsn_lookup { uint8_t ti; }; +enum sgsn_ran_type { + /* GPRS/EDGE via Gb */ + MM_CTX_T_GERAN_Gb, + /* UMTS via Iu */ + MM_CTX_T_UTRAN_Iu, + /* GPRS/EDGE via Iu */ + MM_CTX_T_GERAN_Iu, +}; + /* According to TS 03.60, Table 5: SGSN MM and PDP Contexts */ /* Extended by 3GPP TS 23.060, Table 6: SGSN MM and PDP Contexts */ struct sgsn_mm_ctx { struct llist_head list; + enum sgsn_ran_type ran_type; + char imsi[GSM_IMSI_LENGTH]; enum gprs_mm_state mm_state; uint32_t p_tmsi; @@ -107,10 +118,30 @@ struct sgsn_mm_ctx { /* Opt: Software Version Numbber / TS 23.195 */ char msisdn[GSM_EXTENSION_LENGTH]; struct gprs_ra_id ra; - uint16_t cell_id; - uint32_t cell_id_age; - uint16_t sac; /* Iu: Service Area Code */ - uint32_t sac_age;/* Iu: Service Area Code age */ + struct { + uint16_t cell_id; /* Gb only */ + uint32_t cell_id_age; /* Gb only */ + uint8_t radio_prio_sms; + + /* Additional bits not present in the GSM TS */ + uint16_t nsei; + uint16_t bvci; + struct gprs_llc_llme *llme; + uint32_t tlli; + uint32_t tlli_new; + } gb; + struct { + int imsi_unauthenticated; + uint16_t sac; /* Iu: Service Area Code */ + uint32_t sac_age; /* Iu: Service Area Code age */ + /* CSG ID */ + /* CSG Membership */ + /* Access Mode */ + /* Seelected CN Operator ID (TS 23.251) */ + /* CSG Subscription Data */ + /* LIPA Allowed */ + /* Voice Support Match Indicator */ + } iu; /* VLR number */ uint32_t new_sgsn_addr; /* Authentication Triplet */ @@ -119,30 +150,38 @@ struct sgsn_mm_ctx { /* Iu: CK, IK, KSI */ /* CKSN */ enum gprs_ciph_algo ciph_algo; + struct { uint8_t len; uint8_t buf[50]; /* GSM 04.08 10.5.5.12a, extended in TS 24.008 */ } ms_radio_access_capa; + /* Supported Codecs (SRVCC) */ struct { uint8_t len; uint8_t buf[8]; /* GSM 04.08 10.5.5.12, extended in TS 24.008 */ } ms_network_capa; + /* UE Netowrk Capability (E-UTRAN) */ uint16_t drx_parms; + /* Active Time value for PSM */ int mnrg; /* MS reported to HLR? */ int ngaf; /* MS reported to MSC/VLR? */ int ppf; /* paging for GPRS + non-GPRS? */ + /* Subscribed Charging Characteristics */ + /* Trace Reference */ + /* Trace Type */ + /* Trigger ID */ + /* OMC Identity */ /* SMS Parameters */ int recovery; - uint8_t radio_prio_sms; + /* Access Restriction */ + /* GPRS CSI (CAMEL) */ + /* MG-CSI (CAMEL) */ + /* Subscribed UE-AMBR */ + /* UE-AMBR */ + /* APN Subscribed */ struct llist_head pdp_list; - /* Additional bits not present in the GSM TS */ - struct gprs_llc_llme *llme; - uint32_t tlli; - uint32_t tlli_new; - uint16_t nsei; - uint16_t bvci; struct rate_ctr_group *ctrg; struct osmo_timer_list timer; unsigned int T; /* Txxxx number */ diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 7d3e3de75..e6bb67547 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -151,16 +151,16 @@ static void gmm_copy_id(struct msgb *msg, const struct msgb *old) /* Store BVCI/NSEI in MM context */ static void msgid2mmctx(struct sgsn_mm_ctx *mm, const struct msgb *msg) { - mm->bvci = msgb_bvci(msg); - mm->nsei = msgb_nsei(msg); + mm->gb.bvci = msgb_bvci(msg); + mm->gb.nsei = msgb_nsei(msg); } /* Store BVCI/NSEI in MM context */ static void mmctx2msgid(struct msgb *msg, const struct sgsn_mm_ctx *mm) { - msgb_tlli(msg) = mm->tlli; - msgb_bvci(msg) = mm->bvci; - msgb_nsei(msg) = mm->nsei; + msgb_tlli(msg) = mm->gb.tlli; + msgb_bvci(msg) = mm->gb.bvci; + msgb_nsei(msg) = mm->gb.nsei; } static void mm_ctx_cleanup_free(struct sgsn_mm_ctx *ctx, const char *log_text) @@ -903,8 +903,8 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg, strncpy(ctx->imsi, mi_string, sizeof(ctx->imsi) - 1); #endif } - ctx->tlli = msgb_tlli(msg); - ctx->llme = llme; + ctx->gb.tlli = msgb_tlli(msg); + ctx->gb.llme = llme; msgid2mmctx(ctx, msg); break; case GSM_MI_TYPE_TMSI: @@ -919,8 +919,8 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg, ctx = sgsn_mm_ctx_alloc(msgb_tlli(msg), &ra_id); ctx->p_tmsi = tmsi; } - ctx->tlli = msgb_tlli(msg); - ctx->llme = llme; + ctx->gb.tlli = msgb_tlli(msg); + ctx->gb.llme = llme; msgid2mmctx(ctx, msg); break; default: @@ -931,7 +931,7 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg, } /* Update MM Context with currient RA and Cell ID */ ctx->ra = ra_id; - ctx->cell_id = cid; + ctx->gb.cell_id = cid; /* Update MM Context with other data */ ctx->drx_parms = drx_par; ctx->ms_radio_access_capa.len = ms_ra_acc_cap_len; @@ -951,10 +951,10 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg, #endif /* Even if there is no P-TMSI allocated, the MS will switch from * foreign TLLI to local TLLI */ - ctx->tlli_new = gprs_tmsi2tlli(ctx->p_tmsi, TLLI_LOCAL); + ctx->gb.tlli_new = gprs_tmsi2tlli(ctx->p_tmsi, TLLI_LOCAL); /* Inform LLC layer about new TLLI but keep old active */ - gprs_llgmm_assign(ctx->llme, ctx->tlli, ctx->tlli_new, + gprs_llgmm_assign(ctx->gb.llme, ctx->gb.tlli, ctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); ctx->pending_req = GSM48_MT_GMM_ATTACH_REQ; @@ -1186,7 +1186,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 */ bssgp_parse_cell_id(&mmctx->ra, msgb_bcid(msg)); /* Update the MM context with the new (i.e. foreign) TLLI */ - mmctx->tlli = msgb_tlli(msg); + mmctx->gb.tlli = msgb_tlli(msg); /* FIXME: Update the MM context with the MS radio acc capabilities */ /* FIXME: Update the MM context with the MS network capabilities */ @@ -1213,10 +1213,10 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg, #endif /* Even if there is no P-TMSI allocated, the MS will switch from * foreign TLLI to local TLLI */ - mmctx->tlli_new = gprs_tmsi2tlli(mmctx->p_tmsi, TLLI_LOCAL); + mmctx->gb.tlli_new = gprs_tmsi2tlli(mmctx->p_tmsi, TLLI_LOCAL); /* Inform LLC layer about new TLLI but keep old active */ - gprs_llgmm_assign(mmctx->llme, mmctx->tlli, mmctx->tlli_new, + gprs_llgmm_assign(mmctx->gb.llme, mmctx->gb.tlli, mmctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); /* Look at PDP Context Status IE and see if MS's view of @@ -1336,8 +1336,8 @@ static int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg, mmctx->p_tmsi_old = 0; mmctx->pending_req = 0; /* Unassign the old TLLI */ - mmctx->tlli = mmctx->tlli_new; - gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new, + mmctx->gb.tlli = mmctx->gb.tlli_new; + gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); mmctx->mm_state = GMM_REGISTERED_NORMAL; rc = 0; @@ -1354,8 +1354,8 @@ static int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg, mmctx->p_tmsi_old = 0; mmctx->pending_req = 0; /* Unassign the old TLLI */ - mmctx->tlli = mmctx->tlli_new; - gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new, + mmctx->gb.tlli = mmctx->gb.tlli_new; + gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); mmctx->mm_state = GMM_REGISTERED_NORMAL; rc = 0; @@ -1371,8 +1371,8 @@ static int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg, mmctx->p_tmsi_old = 0; mmctx->pending_req = 0; /* Unassign the old TLLI */ - mmctx->tlli = mmctx->tlli_new; - //gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new, GPRS_ALGO_GEA0, NULL); + mmctx->gb.tlli = mmctx->gb.tlli_new; + //gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); rc = 0; break; case GSM48_MT_GMM_AUTH_CIPH_RESP: @@ -2043,7 +2043,7 @@ int gsm0408_gprs_force_reattach_oldmsg(struct msgb *msg) int gsm0408_gprs_force_reattach(struct sgsn_mm_ctx *mmctx) { int rc; - gprs_llgmm_reset(mmctx->llme); + gprs_llgmm_reset(mmctx->gb.llme); rc = gsm48_tx_gmm_detach_req( mmctx, GPRS_DET_T_MT_REATT_REQ, GMM_CAUSE_IMPL_DETACHED); @@ -2067,7 +2067,7 @@ int gsm0408_gprs_rcvmsg(struct msgb *msg, struct gprs_llc_llme *llme) if (mmctx) { msgid2mmctx(mmctx, msg); rate_ctr_inc(&mmctx->ctrg->ctr[GMM_CTR_PKTS_SIG_IN]); - mmctx->llme = llme; + mmctx->gb.llme = llme; } /* MMCTX can be NULL */ diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c index 936354a09..837c07827 100644 --- a/openbsc/src/gprs/gprs_llc.c +++ b/openbsc/src/gprs/gprs_llc.c @@ -71,10 +71,10 @@ static int _bssgp_tx_dl_ud(struct msgb *msg, struct sgsn_mm_ctx *mmctx) dup.ms_ra_cap.v = mmctx->ms_radio_access_capa.buf; /* make sure we only send it to the right llme */ - OSMO_ASSERT(msgb_tlli(msg) == mmctx->llme->tlli - || msgb_tlli(msg) == mmctx->llme->old_tlli - || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->tlli - || tlli_foreign2local(msgb_tlli(msg)) == mmctx->llme->old_tlli); + OSMO_ASSERT(msgb_tlli(msg) == mmctx->gb.llme->tlli + || msgb_tlli(msg) == mmctx->gb.llme->old_tlli + || tlli_foreign2local(msgb_tlli(msg)) == mmctx->gb.llme->tlli + || tlli_foreign2local(msgb_tlli(msg)) == mmctx->gb.llme->old_tlli); } memcpy(&dup.qos_profile, qos_profile_default, sizeof(qos_profile_default)); diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index c4dc9d7ec..f3180f343 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -111,7 +111,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli, int tlli_type; llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) { - if (tlli == ctx->tlli && + if (tlli == ctx->gb.tlli && ra_id_equals(raid, &ctx->ra)) return ctx; } @@ -122,14 +122,14 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli, llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) { if ((ctx->p_tmsi | 0xC0000000) == tlli || (ctx->p_tmsi_old && (ctx->p_tmsi_old | 0xC0000000) == tlli)) { - ctx->tlli = tlli; + ctx->gb.tlli = tlli; return ctx; } } break; case TLLI_FOREIGN: llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) { - if (tlli == tlli_foreign(ctx->tlli) && + if (tlli == tlli_foreign(ctx->gb.tlli) && ra_id_equals(raid, &ctx->ra)) return ctx; } @@ -176,7 +176,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli, return NULL; memcpy(&ctx->ra, raid, sizeof(ctx->ra)); - ctx->tlli = tlli; + ctx->gb.tlli = tlli; ctx->mm_state = GMM_DEREGISTERED; ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, tlli); @@ -207,8 +207,8 @@ static void sgsn_mm_ctx_free(struct sgsn_mm_ctx *mm) void sgsn_mm_ctx_cleanup_free(struct sgsn_mm_ctx *mm) { - struct gprs_llc_llme *llme = mm->llme; - uint32_t tlli = mm->tlli; + struct gprs_llc_llme *llme = mm->gb.llme; + uint32_t tlli = mm->gb.tlli; struct sgsn_pdp_ctx *pdp, *pdp2; struct sgsn_signal_data sig_data; @@ -319,7 +319,7 @@ void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp) LOGPDPCTXP(LOGL_INFO, pdp, "Forcing release of PDP context\n"); /* Force the deactivation of the SNDCP layer */ - sndcp_sm_deactivate_ind(&pdp->mm->llme->lle[pdp->sapi], pdp->nsapi); + sndcp_sm_deactivate_ind(&pdp->mm->gb.llme->lle[pdp->sapi], pdp->nsapi); memset(&sig_data, 0, sizeof(sig_data)); sig_data.pdp = pdp; @@ -762,7 +762,7 @@ static void sgsn_llme_cleanup_free(struct gprs_llc_llme *llme) struct sgsn_mm_ctx *mmctx = NULL; llist_for_each_entry(mmctx, &sgsn_mm_ctxts, list) { - if (llme == mmctx->llme) { + if (llme == mmctx->gb.llme) { gsm0408_gprs_access_cancelled(mmctx, SGSN_ERROR_CAUSE_NONE); return; } diff --git a/openbsc/src/gprs/sgsn_cdr.c b/openbsc/src/gprs/sgsn_cdr.c index d0cb71235..bf0d6f704 100644 --- a/openbsc/src/gprs/sgsn_cdr.c +++ b/openbsc/src/gprs/sgsn_cdr.c @@ -94,7 +94,7 @@ static void cdr_log_mm(struct sgsn_instance *inst, const char *ev, mmctx->imsi, mmctx->imei, mmctx->msisdn, - mmctx->cell_id, + mmctx->gb.cell_id, mmctx->ra.lac, mmctx->hlr, ev); @@ -179,7 +179,7 @@ static void cdr_log_pdp(struct sgsn_instance *inst, const char *ev, pdp->mm ? pdp->mm->imsi : "N/A", pdp->mm ? pdp->mm->imei : "N/A", pdp->mm ? pdp->mm->msisdn : "N/A", - pdp->mm ? pdp->mm->cell_id : -1, + pdp->mm ? pdp->mm->gb.cell_id : -1, pdp->mm ? pdp->mm->ra.lac : -1, pdp->mm ? pdp->mm->hlr : "N/A", ev, diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index aff2f91a1..cfebe1dc6 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -239,7 +239,7 @@ 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->cell_id); + bssgp_create_cell_id(&pdp->userloc.v[1], &mmctx->ra, mmctx->gb.cell_id); /* include the IMEI(SV) */ pdp->imeisv_given = 1; @@ -341,7 +341,7 @@ static int create_pdp_conf(struct pdp_t *pdp, void *cbp, int cause) } /* Activate the SNDCP layer */ - sndcp_sm_activate_ind(&pctx->mm->llme->lle[pctx->sapi], pctx->nsapi); + sndcp_sm_activate_ind(&pctx->mm->gb.llme->lle[pctx->sapi], pctx->nsapi); /* Inform others about it */ memset(&sig_data, 0, sizeof(sig_data)); @@ -388,7 +388,7 @@ static int delete_pdp_conf(struct pdp_t *pdp, void *cbp, int cause) if (pctx->mm) { /* Deactivate the SNDCP layer */ - sndcp_sm_deactivate_ind(&pctx->mm->llme->lle[pctx->sapi], pctx->nsapi); + sndcp_sm_deactivate_ind(&pctx->mm->gb.llme->lle[pctx->sapi], pctx->nsapi); /* Confirm deactivation of PDP context to MS */ rc = gsm48_tx_gsm_deact_pdp_acc(pctx); @@ -521,9 +521,9 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len) ud = msgb_put(msg, len); memcpy(ud, packet, len); - msgb_tlli(msg) = mm->tlli; - msgb_bvci(msg) = mm->bvci; - msgb_nsei(msg) = mm->nsei; + msgb_tlli(msg) = mm->gb.tlli; + msgb_bvci(msg) = mm->gb.bvci; + msgb_nsei(msg) = mm->gb.nsei; switch (mm->mm_state) { case GMM_REGISTERED_SUSPENDED: @@ -531,12 +531,12 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len) memset(&pinfo, 0, sizeof(pinfo)); pinfo.mode = BSSGP_PAGING_PS; pinfo.scope = BSSGP_PAGING_BVCI; - pinfo.bvci = mm->bvci; + pinfo.bvci = mm->gb.bvci; pinfo.imsi = mm->imsi; pinfo.ptmsi = &mm->p_tmsi; pinfo.drx_params = mm->drx_parms; pinfo.qos[0] = 0; // FIXME - bssgp_tx_paging(mm->nsei, 0, &pinfo); + bssgp_tx_paging(mm->gb.nsei, 0, &pinfo); rate_ctr_inc(&mm->ctrg->ctr[GMM_CTR_PAGING_PS]); /* FIXME: queue the packet we received from GTP */ break; @@ -544,7 +544,7 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len) break; default: LOGP(DGPRS, LOGL_ERROR, "GTP DATA IND for TLLI %08X in state " - "%u\n", mm->tlli, mm->mm_state); + "%u\n", mm->gb.tlli, mm->mm_state); msgb_free(msg); return -1; } @@ -557,7 +557,7 @@ static int cb_data_ind(struct pdp_t *lib, void *packet, unsigned int len) /* It is easier to have a global count */ pdp->cdr_bytes_out += len; - return sndcp_unitdata_req(msg, &mm->llme->lle[pdp->sapi], + return sndcp_unitdata_req(msg, &mm->gb.llme->lle[pdp->sapi], pdp->nsapi, mm); } diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index 3f6116393..00c2761d6 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -431,12 +431,12 @@ static void vty_dump_mmctx(struct vty *vty, const char *pfx, vty_out(vty, "%sMM Context for IMSI %s, IMEI %s, P-TMSI %08x%s", pfx, mm->imsi, mm->imei, mm->p_tmsi, VTY_NEWLINE); vty_out(vty, "%s MSISDN: %s, TLLI: %08x%s HLR: %s", - pfx, mm->msisdn, mm->tlli, mm->hlr, VTY_NEWLINE); + pfx, mm->msisdn, mm->gb.tlli, mm->hlr, VTY_NEWLINE); vty_out(vty, "%s MM State: %s, Routeing Area: %u-%u-%u-%u, " "Cell ID: %u%s", pfx, get_value_string(gprs_mm_st_strs, mm->mm_state), mm->ra.mcc, mm->ra.mnc, mm->ra.lac, mm->ra.rac, - mm->cell_id, VTY_NEWLINE); + mm->gb.cell_id, VTY_NEWLINE); vty_out_rate_ctr_group(vty, " ", mm->ctrg); -- cgit v1.2.3