use osmo_mobile_identity API everywhere

Depends: If4f7be606e54cfa1c59084cf169785b1cbda5cf5 (libosmocore)
Change-Id: I71c3b4c65dbfdfa51409e09d4868aea83225338a
This commit is contained in:
Neels Hofmeyr 2020-05-29 03:53:59 +02:00
parent 2c61245935
commit a87646cd84
7 changed files with 64 additions and 53 deletions

View File

@ -43,8 +43,9 @@ int rsl_sacch_filling(struct gsm_bts_trx *trx, uint8_t type,
int rsl_tx_chan_activ(struct gsm_lchan *lchan, uint8_t act_type, uint8_t ho_ref); int rsl_tx_chan_activ(struct gsm_lchan *lchan, uint8_t act_type, uint8_t ho_ref);
int rsl_chan_mode_modify_req(struct gsm_lchan *ts); int rsl_chan_mode_modify_req(struct gsm_lchan *ts);
int rsl_encryption_cmd(struct msgb *msg); int rsl_encryption_cmd(struct msgb *msg);
int rsl_paging_cmd(struct gsm_bts *bts, uint8_t paging_group, uint8_t len, int rsl_paging_cmd(struct gsm_bts *bts, uint8_t paging_group,
uint8_t *ms_ident, uint8_t chan_needed, bool is_gprs); const struct osmo_mobile_identity *mi,
uint8_t chan_needed, bool is_gprs);
int rsl_imm_assign_cmd(struct gsm_bts *bts, uint8_t len, uint8_t *val); int rsl_imm_assign_cmd(struct gsm_bts *bts, uint8_t len, uint8_t *val);
int rsl_tx_imm_assignment(struct gsm_lchan *lchan); int rsl_tx_imm_assignment(struct gsm_lchan *lchan);
int rsl_tx_imm_ass_rej(struct gsm_bts *bts, struct gsm48_req_ref *rqd_ref); int rsl_tx_imm_ass_rej(struct gsm_bts *bts, struct gsm48_req_ref *rqd_ref);

View File

@ -39,7 +39,6 @@ int gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
enum gsm48_reject_value value); enum gsm48_reject_value value);
struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value); struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, uint8_t *mi_type);
struct msgb *gsm48_create_loc_upd_rej(uint8_t cause); struct msgb *gsm48_create_loc_upd_rej(uint8_t cause);
struct msgb *gsm48_create_rr_status(uint8_t cause); struct msgb *gsm48_create_rr_status(uint8_t cause);

View File

@ -664,18 +664,29 @@ int rsl_tx_rf_chan_release(struct gsm_lchan *lchan)
return abis_rsl_sendmsg(msg); return abis_rsl_sendmsg(msg);
} }
int rsl_paging_cmd(struct gsm_bts *bts, uint8_t paging_group, uint8_t len, int rsl_paging_cmd(struct gsm_bts *bts, uint8_t paging_group,
uint8_t *ms_ident, uint8_t chan_needed, bool is_gprs) const struct osmo_mobile_identity *mi,
uint8_t chan_needed, bool is_gprs)
{ {
struct abis_rsl_dchan_hdr *dh; struct abis_rsl_dchan_hdr *dh;
struct msgb *msg = rsl_msgb_alloc(); struct msgb *msg = rsl_msgb_alloc();
uint8_t *l;
int rc;
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh)); dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
init_dchan_hdr(dh, RSL_MT_PAGING_CMD); init_dchan_hdr(dh, RSL_MT_PAGING_CMD);
dh->chan_nr = RSL_CHAN_PCH_AGCH; dh->chan_nr = RSL_CHAN_PCH_AGCH;
msgb_tv_put(msg, RSL_IE_PAGING_GROUP, paging_group); msgb_tv_put(msg, RSL_IE_PAGING_GROUP, paging_group);
msgb_tlv_put(msg, RSL_IE_MS_IDENTITY, len-2, ms_ident+2);
l = msgb_tl_put(msg, RSL_IE_MS_IDENTITY);
rc = osmo_mobile_identity_encode_msgb(msg, mi, false);
if (rc < 0) {
msgb_free(msg);
return -EINVAL;
}
*l = rc;
msgb_tv_put(msg, RSL_IE_CHAN_NEEDED, chan_needed); msgb_tv_put(msg, RSL_IE_CHAN_NEEDED, chan_needed);
/* Ericsson wants to have this IE in case a paging message /* Ericsson wants to have this IE in case a paging message

View File

@ -828,20 +828,6 @@ struct msgb *gsm48_create_loc_upd_rej(uint8_t cause)
return msg; return msg;
} }
int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, uint8_t *mi_type)
{
/* Check the size for the classmark */
if (length < 1 + *classmark2_lv)
return -1;
uint8_t *mi_lv = classmark2_lv + *classmark2_lv + 1;
if (length < 2 + *classmark2_lv + mi_lv[0])
return -2;
*mi_type = mi_lv[1] & GSM_MI_TYPE_MASK;
return gsm48_mi_to_string(mi_string, GSM48_MI_SIZE, mi_lv+1, *mi_lv);
}
/* As per TS 03.03 Section 2.2, the IMSI has 'not more than 15 digits' */ /* As per TS 03.03 Section 2.2, the IMSI has 'not more than 15 digits' */
uint64_t str_to_imsi(const char *imsi_str) uint64_t str_to_imsi(const char *imsi_str)
{ {

View File

@ -293,7 +293,7 @@ static int bssmap_handle_paging(struct bsc_msc_data *msc,
struct msgb *msg, unsigned int payload_length) struct msgb *msg, unsigned int payload_length)
{ {
struct tlv_parsed tp; struct tlv_parsed tp;
char mi_string[GSM48_MI_SIZE]; struct osmo_mobile_identity mi_imsi;
uint32_t tmsi = GSM_RESERVED_TMSI; uint32_t tmsi = GSM_RESERVED_TMSI;
uint8_t data_length; uint8_t data_length;
int remain; int remain;
@ -332,8 +332,11 @@ static int bssmap_handle_paging(struct bsc_msc_data *msc,
/* /*
* parse the IMSI * parse the IMSI
*/ */
gsm48_mi_to_string(mi_string, sizeof(mi_string), if (osmo_mobile_identity_decode(&mi_imsi, TLVP_VAL(&tp, GSM0808_IE_IMSI), TLVP_LEN(&tp, GSM0808_IE_IMSI), false)
TLVP_VAL(&tp, GSM0808_IE_IMSI), TLVP_LEN(&tp, GSM0808_IE_IMSI)); || mi_imsi.type != GSM_MI_TYPE_IMSI) {
LOGP(DMSC, LOGL_ERROR, "Paging: could not parse IMSI\n");
return -1;
}
/* /*
* There are various cell identifier list types defined at 3GPP TS § 08.08, we don't support all * There are various cell identifier list types defined at 3GPP TS § 08.08, we don't support all
@ -343,8 +346,8 @@ static int bssmap_handle_paging(struct bsc_msc_data *msc,
data_length = TLVP_LEN(&tp, GSM0808_IE_CELL_IDENTIFIER_LIST); data_length = TLVP_LEN(&tp, GSM0808_IE_CELL_IDENTIFIER_LIST);
data = TLVP_VAL(&tp, GSM0808_IE_CELL_IDENTIFIER_LIST); data = TLVP_VAL(&tp, GSM0808_IE_CELL_IDENTIFIER_LIST);
if (gsm0808_dec_cell_id_list2(&cil, data, data_length) < 0) { if (gsm0808_dec_cell_id_list2(&cil, data, data_length) < 0) {
LOGP(DMSC, LOGL_ERROR, "Paging IMSI %s: Could not parse Cell Identifier List\n", LOGP(DMSC, LOGL_ERROR, "Paging %s: Could not parse Cell Identifier List\n",
mi_string); osmo_mobile_identity_to_str_c(OTC_SELECT, &mi_imsi));
return -1; return -1;
} }
remain = 0; remain = 0;
@ -360,43 +363,45 @@ static int bssmap_handle_paging(struct bsc_msc_data *msc,
switch (cil.id_discr) { switch (cil.id_discr) {
case CELL_IDENT_NO_CELL: case CELL_IDENT_NO_CELL:
page_all_bts(msc, tmsi, mi_string, chan_needed); page_all_bts(msc, tmsi, mi_imsi.imsi, chan_needed);
break; break;
case CELL_IDENT_WHOLE_GLOBAL: case CELL_IDENT_WHOLE_GLOBAL:
page_cgi(msc, &cil, tmsi, mi_string, chan_needed); page_cgi(msc, &cil, tmsi, mi_imsi.imsi, chan_needed);
break; break;
case CELL_IDENT_LAC_AND_CI: case CELL_IDENT_LAC_AND_CI:
page_lac_and_ci(msc, &cil, tmsi, mi_string, chan_needed); page_lac_and_ci(msc, &cil, tmsi, mi_imsi.imsi, chan_needed);
break; break;
case CELL_IDENT_CI: case CELL_IDENT_CI:
page_ci(msc, &cil, tmsi, mi_string, chan_needed); page_ci(msc, &cil, tmsi, mi_imsi.imsi, chan_needed);
break; break;
case CELL_IDENT_LAI_AND_LAC: case CELL_IDENT_LAI_AND_LAC:
page_lai_and_lac(msc, &cil, tmsi, mi_string, chan_needed); page_lai_and_lac(msc, &cil, tmsi, mi_imsi.imsi, chan_needed);
break; break;
case CELL_IDENT_LAC: case CELL_IDENT_LAC:
page_lac(msc, &cil, tmsi, mi_string, chan_needed); page_lac(msc, &cil, tmsi, mi_imsi.imsi, chan_needed);
break; break;
case CELL_IDENT_BSS: case CELL_IDENT_BSS:
if (data_length != 1) { if (data_length != 1) {
LOGP(DMSC, LOGL_ERROR, "Paging IMSI %s: Cell Identifier List for BSS (0x%x)" LOGP(DMSC, LOGL_ERROR, "Paging %s: Cell Identifier List for BSS (0x%x)"
" has invalid length: %u, paging entire BSS anyway (%s)\n", " has invalid length: %u, paging entire BSS anyway (%s)\n",
mi_string, CELL_IDENT_BSS, data_length, osmo_hexdump(data, data_length)); osmo_mobile_identity_to_str_c(OTC_SELECT, &mi_imsi),
CELL_IDENT_BSS, data_length, osmo_hexdump(data, data_length));
} }
page_all_bts(msc, tmsi, mi_string, chan_needed); page_all_bts(msc, tmsi, mi_imsi.imsi, chan_needed);
break; break;
default: default:
LOGP(DMSC, LOGL_NOTICE, "Paging IMSI %s: unimplemented Cell Identifier List (0x%x)," LOGP(DMSC, LOGL_NOTICE, "Paging %s: unimplemented Cell Identifier List (0x%x),"
" paging entire BSS instead (%s)\n", " paging entire BSS instead (%s)\n",
mi_string, cil.id_discr, osmo_hexdump(data, data_length)); osmo_mobile_identity_to_str_c(OTC_SELECT, &mi_imsi),
page_all_bts(msc, tmsi, mi_string, chan_needed); cil.id_discr, osmo_hexdump(data, data_length));
page_all_bts(msc, tmsi, mi_imsi.imsi, chan_needed);
break; break;
} }

View File

@ -78,10 +78,9 @@ static void paging_remove_request(struct gsm_bts_paging_state *paging_bts,
static void page_ms(struct gsm_paging_request *request) static void page_ms(struct gsm_paging_request *request)
{ {
uint8_t mi[128];
unsigned int mi_len;
unsigned int page_group; unsigned int page_group;
struct gsm_bts *bts = request->bts; struct gsm_bts *bts = request->bts;
struct osmo_mobile_identity mi;
log_set_context(LOG_CTX_BSC_SUBSCR, request->bsub); log_set_context(LOG_CTX_BSC_SUBSCR, request->bsub);
@ -89,14 +88,21 @@ static void page_ms(struct gsm_paging_request *request)
"0x%08x for ch. type %d (attempt %d)\n", request->bsub->imsi, "0x%08x for ch. type %d (attempt %d)\n", request->bsub->imsi,
request->bsub->tmsi, request->chan_type, request->attempts); request->bsub->tmsi, request->chan_type, request->attempts);
if (request->bsub->tmsi == GSM_RESERVED_TMSI) if (request->bsub->tmsi == GSM_RESERVED_TMSI) {
mi_len = gsm48_generate_mid_from_imsi(mi, request->bsub->imsi); mi = (struct osmo_mobile_identity){
else .type = GSM_MI_TYPE_IMSI,
mi_len = gsm48_generate_mid_from_tmsi(mi, request->bsub->tmsi); };
OSMO_STRLCPY_ARRAY(mi.imsi, request->bsub->imsi);
} else {
mi = (struct osmo_mobile_identity){
.type = GSM_MI_TYPE_TMSI,
.tmsi = request->bsub->tmsi,
};
}
page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc, page_group = gsm0502_calc_paging_group(&bts->si_common.chan_desc,
str_to_imsi(request->bsub->imsi)); str_to_imsi(request->bsub->imsi));
rsl_paging_cmd(bts, page_group, mi_len, mi, request->chan_type, false); rsl_paging_cmd(bts, page_group, &mi, request->chan_type, false);
log_set_context(LOG_CTX_BSC_SUBSCR, NULL); log_set_context(LOG_CTX_BSC_SUBSCR, NULL);
} }

View File

@ -290,27 +290,30 @@ static int pcu_rx_rr_paging(struct gsm_bts *bts, uint8_t paging_group,
{ {
struct gsm48_paging1 *p1 = (struct gsm48_paging1 *) raw_rr_msg; struct gsm48_paging1 *p1 = (struct gsm48_paging1 *) raw_rr_msg;
uint8_t chan_needed; uint8_t chan_needed;
unsigned int mi_len; struct osmo_mobile_identity mi;
uint8_t *mi;
int rc; int rc;
switch (p1->msg_type) { switch (p1->msg_type) {
case GSM48_MT_RR_PAG_REQ_1: case GSM48_MT_RR_PAG_REQ_1:
chan_needed = (p1->cneed2 << 2) | p1->cneed1; chan_needed = (p1->cneed2 << 2) | p1->cneed1;
mi_len = p1->data[0]; rc = osmo_mobile_identity_decode(&mi, p1->data+1, p1->data[0], false);
mi = p1->data+1; if (rc) {
LOGP(DPCU, LOGL_ERROR, "PCU Sends paging "
"request type %02x (chan_needed=%02x): Unable to decode Mobile Identity\n",
p1->msg_type, chan_needed);
rc = -EINVAL;
break;
}
LOGP(DPCU, LOGL_ERROR, "PCU Sends paging " LOGP(DPCU, LOGL_ERROR, "PCU Sends paging "
"request type %02x (chan_needed=%02x, mi_len=%u, mi=%s)\n", "request type %02x (chan_needed=%02x, mi=%s)\n",
p1->msg_type, chan_needed, mi_len, p1->msg_type, chan_needed, osmo_mobile_identity_to_str_c(OTC_SELECT, &mi));
osmo_hexdump_nospc(mi,mi_len));
/* NOTE: We will have to add 2 to mi_len and subtract 2 from /* NOTE: We will have to add 2 to mi_len and subtract 2 from
* the mi pointer because rsl_paging_cmd() will perform the * the mi pointer because rsl_paging_cmd() will perform the
* reverse operations. This is because rsl_paging_cmd() is * reverse operations. This is because rsl_paging_cmd() is
* normally expected to chop off the element identifier (0xC0) * normally expected to chop off the element identifier (0xC0)
* and the length field. In our parameter, we do not have * and the length field. In our parameter, we do not have
* those fields included. */ * those fields included. */
rc = rsl_paging_cmd(bts, paging_group, mi_len+2, mi-2, rc = rsl_paging_cmd(bts, paging_group, &mi, chan_needed, true);
chan_needed, true);
break; break;
case GSM48_MT_RR_PAG_REQ_2: case GSM48_MT_RR_PAG_REQ_2:
case GSM48_MT_RR_PAG_REQ_3: case GSM48_MT_RR_PAG_REQ_3: