diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2020-08-21 15:44:58 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2020-08-21 16:40:14 +0200 |
commit | 0052051c07af63da98137c9f8e3b3119642eb587 (patch) | |
tree | 2364f800198176b6130aa22af0b8e7cd5c30d24c | |
parent | b75c27febdfaf1020f4a55d55646ec5c10b2050a (diff) |
use new osmo_mobile_identity api (avoid deprecation)
Note: subsequent patch Iad845acb0096b75dc453105c9c16b2252879b4ca will change to
passing a struct osmo_mobile_identity in the Paging code path, instead of
passing the encoded IE data.
Change-Id: Ibb03b8e601160427944f434761ca59811d1fc12f
-rw-r--r-- | src/bts.cpp | 10 | ||||
-rw-r--r-- | src/gprs_bssgp_pcu.cpp | 30 | ||||
-rw-r--r-- | src/gprs_rlcmac.cpp | 9 | ||||
-rw-r--r-- | src/pdch.cpp | 9 |
4 files changed, 37 insertions, 21 deletions
diff --git a/src/bts.cpp b/src/bts.cpp index 22b4c083..c415dd43 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -369,9 +369,13 @@ int BTS::add_paging(uint8_t chan_needed, const uint8_t *mi, uint8_t mi_len) NULL }; - - LOGP(DRLCMAC, LOGL_INFO, "Add RR paging: chan-needed=%d MI=%s\n", - chan_needed, osmo_mi_name(mi, mi_len)); + if (log_check_level(DRLCMAC, LOGL_INFO)) { + struct osmo_mobile_identity omi = {}; + char str[64]; + osmo_mobile_identity_decode(&omi, mi, mi_len, true); + osmo_mobile_identity_to_str_buf(str, sizeof(str), &omi); + LOGP(DRLCMAC, LOGL_INFO, "Add RR paging: chan-needed=%d MI=%s\n", chan_needed, str); + } /* collect slots to page * Mark slots for every TBF, but only mark one of it. diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index a4bcff31..a46852a3 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -87,11 +87,16 @@ static int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp) uint32_t tlli_old = 0; uint8_t *data; uint16_t len; - char imsi[OSMO_IMSI_BUF_SIZE] = "000"; uint8_t ms_class = 0; uint8_t egprs_ms_class = 0; int rc; MS_Radio_Access_capability_t rac; + /* TODO: is it really necessary to initialize this as a "000" IMSI? It seems, the function should just return an + * error if no IMSI IE was found. */ + struct osmo_mobile_identity mi_imsi = { + .type = GSM_MI_TYPE_TMSI, + }; + OSMO_STRLCPY_ARRAY(mi_imsi.imsi, "000"); budh = (struct bssgp_ud_hdr *)msgb_bssgph(msg); tlli = ntohl(budh->tlli); @@ -116,10 +121,9 @@ static int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp) * will listen to all paging blocks. */ if (TLVP_PRESENT(tp, BSSGP_IE_IMSI)) { - /* gsm48_mi_to_string() returns number of bytes written, including '\0' */ - rc = gsm48_mi_to_string(imsi, sizeof(imsi), TLVP_VAL(tp, BSSGP_IE_IMSI), - TLVP_LEN(tp, BSSGP_IE_IMSI)); - if (rc != GSM23003_IMSI_MAX_DIGITS + 1) { + rc = osmo_mobile_identity_decode(&mi_imsi, TLVP_VAL(tp, BSSGP_IE_IMSI), TLVP_LEN(tp, BSSGP_IE_IMSI), + true); + if (rc < 0 || mi_imsi.type != GSM_MI_TYPE_TMSI) { LOGP(DBSSGP, LOGL_NOTICE, "Failed to parse IMSI IE (rc=%d)\n", rc); return bssgp_tx_status(BSSGP_CAUSE_COND_IE_ERR, NULL, msg); } @@ -160,9 +164,9 @@ static int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp) "TLLI (old) IE\n"); } - LOGP(DBSSGP, LOGL_INFO, "LLC [SGSN -> PCU] = TLLI: 0x%08x IMSI: %s len: %d\n", tlli, imsi, len); + LOGP(DBSSGP, LOGL_INFO, "LLC [SGSN -> PCU] = TLLI: 0x%08x IMSI: %s len: %d\n", tlli, mi_imsi.imsi, len); - return gprs_rlcmac_dl_tbf::handle(the_pcu.bts, tlli, tlli_old, imsi, + return gprs_rlcmac_dl_tbf::handle(the_pcu.bts, tlli, tlli_old, mi_imsi.imsi, ms_class, egprs_ms_class, delay_csec, data, len); } @@ -212,7 +216,7 @@ static int gprs_bssgp_pcu_rx_paging_cs(struct msgb *msg, struct tlv_parsed *tp) static int gprs_bssgp_pcu_rx_paging_ps(struct msgb *msg, struct tlv_parsed *tp) { - char imsi[OSMO_IMSI_BUF_SIZE]; + struct osmo_mobile_identity mi_imsi; uint16_t pgroup; const uint8_t *mi; uint8_t mi_len; @@ -223,16 +227,14 @@ static int gprs_bssgp_pcu_rx_paging_ps(struct msgb *msg, struct tlv_parsed *tp) return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg); } - /* gsm48_mi_to_string() returns number of bytes written, including '\0' */ - rc = gsm48_mi_to_string(imsi, sizeof(imsi), TLVP_VAL(tp, BSSGP_IE_IMSI), - TLVP_LEN(tp, BSSGP_IE_IMSI)); - if (rc != GSM23003_IMSI_MAX_DIGITS + 1) { + rc = osmo_mobile_identity_decode(&mi_imsi, TLVP_VAL(tp, BSSGP_IE_IMSI), TLVP_LEN(tp, BSSGP_IE_IMSI), true); + if (rc < 0 || mi_imsi.type != GSM_MI_TYPE_IMSI) { LOGP(DBSSGP, LOGL_NOTICE, "Failed to parse IMSI IE (rc=%d)\n", rc); return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg); } - pgroup = imsi2paging_group(imsi); + pgroup = imsi2paging_group(mi_imsi.imsi); if (pgroup > 999) { - LOGP(DBSSGP, LOGL_NOTICE, "Failed to compute IMSI %s paging group\n", imsi); + LOGP(DBSSGP, LOGL_NOTICE, "Failed to compute IMSI %s paging group\n", mi_imsi.imsi); return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg); } diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp index c8900214..879ea85d 100644 --- a/src/gprs_rlcmac.cpp +++ b/src/gprs_rlcmac.cpp @@ -34,8 +34,13 @@ extern void *tall_pcu_ctx; int gprs_rlcmac_paging_request(const uint8_t *mi, uint8_t mi_len, uint16_t pgroup) { - LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] Paging Request (CCCH) MI=%s\n", - osmo_mi_name(mi, mi_len)); + if (log_check_level(DRLCMAC, LOGL_NOTICE)) { + struct osmo_mobile_identity omi = {}; + char str[64]; + osmo_mobile_identity_decode(&omi, mi, mi_len, true); + osmo_mobile_identity_to_str_buf(str, sizeof(str), &omi); + LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] Paging Request (CCCH) MI=%s\n", str); + } bitvec *paging_request = bitvec_alloc(22, tall_pcu_ctx); bitvec_unhex(paging_request, DUMMY_VEC); int plen = Encoding::write_paging_request(paging_request, mi, mi_len); diff --git a/src/pdch.cpp b/src/pdch.cpp index b34f5328..af847241 100644 --- a/src/pdch.cpp +++ b/src/pdch.cpp @@ -205,8 +205,13 @@ struct msgb *gprs_rlcmac_pdch::packet_paging_request() /* loop until message is full */ while (pag) { - LOGP(DRLCMAC, LOGL_DEBUG, "Paging MI - %s\n", - osmo_mi_name(pag->identity_lv + 1, pag->identity_lv[0])); + if (log_check_level(DRLCMAC, LOGL_DEBUG)) { + struct osmo_mobile_identity omi = {}; + char str[64]; + osmo_mobile_identity_decode(&omi, pag->identity_lv + 1, pag->identity_lv[0], true); + osmo_mobile_identity_to_str_buf(str, sizeof(str), &omi); + LOGP(DRLCMAC, LOGL_DEBUG, "Paging MI - %s\n", str); + } /* try to add paging */ if ((pag->identity_lv[1] & GSM_MI_TYPE_MASK) == GSM_MI_TYPE_TMSI) { |