diff --git a/src/bts.cpp b/src/bts.cpp index 30450bc1..e3a5eeb9 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -724,7 +724,7 @@ int bts_rcv_imm_ass_cnf(struct gprs_rlcmac_bts *bts, const uint8_t *data, uint32 } /* Find related TBF and send confirmation signal to FSM */ - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); if (!ms) { LOGP(DTBFDL, LOGL_ERROR, "FN=%u Got IMM.ASS confirm for unknown MS with TLLI=%08x\n", fn, tlli); return -EINVAL; @@ -1212,11 +1212,16 @@ struct GprsMsStorage *bts_ms_store(const struct gprs_rlcmac_bts *bts) return bts->ms_store; } -struct GprsMs *bts_ms_by_tlli(struct gprs_rlcmac_bts *bts, uint32_t tlli, uint32_t old_tlli) +struct GprsMs *bts_get_ms_by_tlli(const struct gprs_rlcmac_bts *bts, uint32_t tlli, uint32_t old_tlli) { return bts_ms_store(bts)->get_ms(tlli, old_tlli); } +struct GprsMs *bts_get_ms_by_imsi(const struct gprs_rlcmac_bts *bts, const char *imsi) +{ + return bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, imsi); +} + /* update TA based on TA provided by PH-DATA-IND */ void update_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, int8_t ta_delta) { @@ -1422,11 +1427,6 @@ void bts_recalc_max_mcs(struct gprs_rlcmac_bts *bts) bts_set_max_mcs_ul(bts, mcs_ul); } -struct GprsMs *bts_ms_by_imsi(struct gprs_rlcmac_bts *bts, const char *imsi) -{ - return bts_ms_store(bts)->get_ms(GSM_RESERVED_TMSI, GSM_RESERVED_TMSI, imsi); -} - const struct llist_head* bts_ms_list(struct gprs_rlcmac_bts *bts) { return bts_ms_store(bts)->ms_list(); diff --git a/src/bts.h b/src/bts.h index a1ea7969..7f6be730 100644 --- a/src/bts.h +++ b/src/bts.h @@ -331,7 +331,8 @@ void bts_send_gsmtap_rach(struct gprs_rlcmac_bts *bts, struct GprsMsStorage *bts_ms_store(const struct gprs_rlcmac_bts *bts); -struct GprsMs *bts_ms_by_tlli(struct gprs_rlcmac_bts *bts, uint32_t tlli, uint32_t old_tlli); +struct GprsMs *bts_get_ms_by_tlli(const struct gprs_rlcmac_bts *bts, uint32_t tlli, uint32_t old_tlli); +struct GprsMs *bts_get_ms_by_imsi(const struct gprs_rlcmac_bts *bts, const char *imsi); static inline struct rate_ctr_group *bts_rate_counters(struct gprs_rlcmac_bts *bts) { @@ -369,7 +370,6 @@ void bts_recalc_initial_cs(struct gprs_rlcmac_bts *bts); void bts_recalc_initial_mcs(struct gprs_rlcmac_bts *bts); void bts_recalc_max_cs(struct gprs_rlcmac_bts *bts); void bts_recalc_max_mcs(struct gprs_rlcmac_bts *bts); -struct GprsMs *bts_ms_by_imsi(struct gprs_rlcmac_bts *bts, const char *imsi); uint8_t bts_max_cs_dl(const struct gprs_rlcmac_bts *bts); uint8_t bts_max_cs_ul(const struct gprs_rlcmac_bts *bts); uint8_t bts_max_mcs_dl(const struct gprs_rlcmac_bts *bts); diff --git a/src/gprs_bssgp_pcu.c b/src/gprs_bssgp_pcu.c index 656342e8..2c5a97a7 100644 --- a/src/gprs_bssgp_pcu.c +++ b/src/gprs_bssgp_pcu.c @@ -244,9 +244,9 @@ static int gprs_bssgp_pcu_rx_paging_cs(struct msgb *msg, const struct tlv_parsed * target MS is using. */ llist_for_each_entry(bts, &the_pcu->bts_list, list) { /* TODO: Match by TMSI before IMSI if present?! */ - ms = bts_ms_by_tlli(bts, req.tlli, req.tlli); + ms = bts_get_ms_by_tlli(bts, req.tlli, req.tlli); if (!ms && req.mi_imsi_present) - ms = bts_ms_by_imsi(bts, req.mi_imsi.imsi); + ms = bts_get_ms_by_imsi(bts, req.mi_imsi.imsi); bts_add_paging(bts, &req, ms); } diff --git a/src/gprs_ms.c b/src/gprs_ms.c index 9ce3d823..909e7f8b 100644 --- a/src/gprs_ms.c +++ b/src/gprs_ms.c @@ -558,7 +558,7 @@ void ms_set_imsi(struct GprsMs *ms, const char *imsi) "Modifying MS object, TLLI = 0x%08x, IMSI '%s' -> '%s'\n", ms_tlli(ms), ms->imsi, imsi); - struct GprsMs *old_ms = bts_ms_by_imsi(ms->bts, imsi); + struct GprsMs *old_ms = bts_get_ms_by_imsi(ms->bts, imsi); /* Check if we are going to store a different MS object with already existing IMSI. This is probably a bug in code calling this function, since it should take care of this explicitly */ diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 577ba570..7068083a 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -1071,7 +1071,7 @@ static int pcu_rx_pag_req(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_pag_req case GSM_MI_TYPE_IMSI: req.mi_imsi = mi; req.mi_imsi_present = true; - ms = bts_ms_by_imsi(bts, req.mi_imsi.imsi); + ms = bts_get_ms_by_imsi(bts, req.mi_imsi.imsi); break; default: LOGP(DL1IF, LOGL_ERROR, "Unexpected MI type %u\n", mi.type); diff --git a/src/pdch.cpp b/src/pdch.cpp index e397a8f7..081c306d 100644 --- a/src/pdch.cpp +++ b/src/pdch.cpp @@ -348,7 +348,7 @@ void gprs_rlcmac_pdch::rcv_control_ack(Packet_Control_Acknowledgement_t *packet, LOGPDCH(this, DRLCMAC, LOGL_NOTICE, "PACKET CONTROL ACK with " "unknown FN=%u TLLI=0x%08x (TRX %d TS %d)\n", fn, tlli, trx_no(), ts_no); - ms = bts_ms_by_tlli(bts(), tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts(), tlli, GSM_RESERVED_TMSI); if (ms) LOGPDCH(this, DRLCMAC, LOGL_NOTICE, "PACKET CONTROL ACK with " "unknown TBF corresponds to MS with IMSI %s, TA %d, " @@ -664,7 +664,7 @@ void gprs_rlcmac_pdch::rcv_resource_request(Packet_Resource_Request_t *request, /* First gather MS from TLLI/DL_TFI/UL_TFI:*/ if (request->ID.UnionType) { /* ID_TYPE = TLLI */ uint32_t tlli = request->ID.u.TLLI; - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); if (!ms) { ms = bts_alloc_ms(bts); ms_set_tlli(ms, tlli); @@ -854,7 +854,7 @@ void gprs_rlcmac_pdch::rcv_measurement_report(Packet_Measurement_Report_t *repor struct pdch_ulc_node *poll; GprsMs *ms; - ms = bts_ms_by_tlli(bts(), report->TLLI, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts(), report->TLLI, GSM_RESERVED_TMSI); if (!ms) { LOGPDCH(this, DRLCMAC, LOGL_NOTICE, "MS send measurement " "but TLLI 0x%08x is unknown\n", report->TLLI); diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index 32822681..4497fbdd 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -559,7 +559,7 @@ static unsigned alloc_many_tbfs(struct gprs_rlcmac_bts *bts, unsigned min_class, enum gprs_rlcmac_tbf_direction dir; uint32_t tlli = counter + 0xc0000000; - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); if (!ms) ms = bts_alloc_ms(bts); ms_set_ms_class(ms, ms_class); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 63074d00..42b6d296 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -139,7 +139,7 @@ static void test_tbf_tlli_update() OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); OSMO_ASSERT(ul_tbf->ms() == ms); - OSMO_ASSERT(bts_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI) == ms); + OSMO_ASSERT(bts_get_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI) == ms); /* * Now check.. that DL changes and that the timing advance @@ -148,20 +148,20 @@ static void test_tbf_tlli_update() ms_confirm_tlli(dl_tbf->ms(), 0x4232); /* It is still there, since the new TLLI has not been used for UL yet */ - ms_new = bts_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI); + ms_new = bts_get_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI); OSMO_ASSERT(ms == ms_new); - ms_new = bts_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI); + ms_new = bts_get_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI); OSMO_ASSERT(ms == ms_new); OSMO_ASSERT(ms_dl_tbf(ms) == dl_tbf); OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); /* Now use the new TLLI for UL */ ms_update_announced_tlli(ms, 0x4232); - ms_new = bts_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI); + ms_new = bts_get_ms_by_tlli(bts, 0x2342, GSM_RESERVED_TMSI); OSMO_ASSERT(ms_new == NULL); - ms_new = bts_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI); + ms_new = bts_get_ms_by_tlli(bts, 0x4232, GSM_RESERVED_TMSI); OSMO_ASSERT(ms_new != NULL); OSMO_ASSERT(ms_ta(ms_new) == 4); @@ -658,7 +658,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_single_phase(struct gprs_rlcmac_bts pdch->rcv_block(&data_msg[0], sizeof(data_msg), *fn, &meas); - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms != NULL); return ul_tbf; @@ -797,7 +797,7 @@ static gprs_rlcmac_ul_tbf *puan_urbb_len_issue(struct gprs_rlcmac_bts *bts, pdch->rcv_block(&data_msg[0], 23, *fn, &meas); - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms != NULL); OSMO_ASSERT(ms_ta(ms) == qta/4); OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); @@ -941,7 +941,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_spb(struct gprs_rlcmac_bts pdch->rcv_block(&data_msg[0], 23, *fn, &meas); - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms != NULL); OSMO_ASSERT(ms_ta(ms) == qta/4); OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); @@ -1430,7 +1430,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_no_length(struct check_tbf(ul_tbf); OSMO_ASSERT(tbf_ul_ack_fi(ul_tbf)->state == TBF_UL_ACK_ST_NONE); - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms != NULL); OSMO_ASSERT(ms_ta(ms) == qta/4); OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); @@ -1511,7 +1511,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_with_length(stru check_tbf(ul_tbf); OSMO_ASSERT(tbf_ul_ack_fi(ul_tbf)->state == TBF_UL_ACK_ST_NONE); - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms != NULL); OSMO_ASSERT(ms_ta(ms) == qta/4); OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); @@ -1593,7 +1593,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_CRBB(struct gprs_rlcm check_tbf(ul_tbf); OSMO_ASSERT(tbf_ul_ack_fi(ul_tbf)->state == TBF_UL_ACK_ST_NONE); - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms != NULL); OSMO_ASSERT(ms_ta(ms) == qta/4); OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); @@ -1670,7 +1670,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase(struct gprs_rlcmac_bts *bt pdch->rcv_block(&data_msg[0], sizeof(data_msg), *fn, &meas); - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms != NULL); OSMO_ASSERT(ms_ta(ms) == qta/4); OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf); @@ -1688,11 +1688,11 @@ static void send_dl_data(struct gprs_rlcmac_bts *bts, uint32_t tlli, const char dl_tbf_handle(bts, tlli, 0, imsi, 0, 0, 1000, data, data_size); - ms = bts_ms_by_imsi(bts, imsi); + ms = bts_get_ms_by_imsi(bts, imsi); OSMO_ASSERT(ms != NULL); if (imsi[0] != '\0') { - ms2 = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms2 = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms == ms2); } } @@ -1704,7 +1704,7 @@ static void transmit_dl_data(struct gprs_rlcmac_bts *bts, uint32_t tlli, uint32_ GprsMs *ms; unsigned ts_no; - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms); dl_tbf = ms_dl_tbf(ms); OSMO_ASSERT(dl_tbf); @@ -2013,14 +2013,14 @@ static void test_tbf_ra_update_rach() * the PCU can see, that both MS objects belong to same MS */ send_dl_data(bts, tlli2, imsi, (const uint8_t *)"DATA", 4); - ms = bts_ms_by_imsi(bts, imsi); + ms = bts_get_ms_by_imsi(bts, imsi); OSMO_ASSERT(ms == ms2); print_ms(ms2, false); - ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); OSMO_ASSERT(ms == NULL); - ms = bts_ms_by_tlli(bts, tlli2, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli2, GSM_RESERVED_TMSI); OSMO_ASSERT(ms == ms2); TALLOC_FREE(the_pcu); @@ -2063,7 +2063,7 @@ static void test_tbf_dl_flow_and_rach_two_phase() /* Get rid of old UL TBF */ tbf_free(ul_tbf); - ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); OSMO_ASSERT(ms1 == ms); /* Now establish a new UL TBF, this will consume one LLC packet */ @@ -2076,7 +2076,7 @@ static void test_tbf_dl_flow_and_rach_two_phase() /* This should be the same MS object */ OSMO_ASSERT(ms2 == ms1); - ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); OSMO_ASSERT(ms2 == ms); /* A DL TBF should still exist */ @@ -2126,7 +2126,7 @@ static void test_tbf_dl_flow_and_rach_single_phase() /* Get rid of old UL TBF */ tbf_free(ul_tbf); - ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); OSMO_ASSERT(ms1 == ms); /* Now establish a new UL TBF */ @@ -2138,7 +2138,7 @@ static void test_tbf_dl_flow_and_rach_single_phase() /* There should be a different MS object */ OSMO_ASSERT(ms2 != ms1); - ms = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); OSMO_ASSERT(ms2 == ms); OSMO_ASSERT(ms1 != ms); @@ -2235,7 +2235,7 @@ static void test_tbf_dl_reuse() request_dl_rlc_block(dl_tbf1, &fn); - ms2 = bts_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); + ms2 = bts_get_ms_by_tlli(bts, tlli1, GSM_RESERVED_TMSI); OSMO_ASSERT(ms2 == ms1); OSMO_ASSERT(ms_dl_tbf(ms2)); OSMO_ASSERT(ms_dl_tbf(ms2)->state_is(TBF_ST_ASSIGN)); @@ -2607,7 +2607,7 @@ static gprs_rlcmac_ul_tbf *tbf_li_decoding(struct gprs_rlcmac_bts *bts, uint8_t data_msg[49] = {0}; - ms = bts_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); + ms = bts_get_ms_by_tlli(bts, tlli, GSM_RESERVED_TMSI); OSMO_ASSERT(ms != NULL); OSMO_ASSERT(ms_ta(ms) == qta/4); OSMO_ASSERT(ms_ul_tbf(ms) == ul_tbf);