clean paging_opportunity function

master
Francisco Paisana 5 years ago
parent 77f63f7bcd
commit 0f01b0acc2

@ -515,7 +515,7 @@ void rrc::add_paging_id(uint32_t ueid, LIBLTE_S1AP_UEPAGINGID_STRUCT UEPagingID)
// Described in Section 7 of 36.304 // Described in Section 7 of 36.304
bool rrc::is_paging_opportunity(uint32_t tti, uint32_t* payload_len) bool rrc::is_paging_opportunity(uint32_t tti, uint32_t* payload_len)
{ {
int sf_pattern[4][4] = {{9, 4, -1, 0}, {-1, 9, -1, 4}, {-1, -1, -1, 5}, {-1, -1, -1, 9}}; constexpr static int sf_pattern[4][4] = {{9, 4, -1, 0}, {-1, 9, -1, 4}, {-1, -1, -1, 5}, {-1, -1, -1, 9}};
if (pending_paging.empty()) { if (pending_paging.empty()) {
return false; return false;
@ -538,40 +538,46 @@ bool rrc::is_paging_opportunity(uint32_t tti, uint32_t* payload_len)
std::vector<uint32_t> ue_to_remove; std::vector<uint32_t> ue_to_remove;
int n = 0; int n = 0;
for (auto iter = pending_paging.begin(); n < ASN1_RRC_MAX_PAGE_REC && iter != pending_paging.end(); ++iter) { for (auto& item : pending_paging) {
LIBLTE_S1AP_UEPAGINGID_STRUCT u = (LIBLTE_S1AP_UEPAGINGID_STRUCT)iter->second; if (n >= ASN1_RRC_MAX_PAGE_REC) {
uint32_t ueid = ((uint32_t)iter->first) % 1024; break;
}
LIBLTE_S1AP_UEPAGINGID_STRUCT u = (LIBLTE_S1AP_UEPAGINGID_STRUCT)item.second;
uint32_t ueid = ((uint32_t)item.first) % 1024;
uint32_t i_s = (ueid / N) % Ns; uint32_t i_s = (ueid / N) % Ns;
if ((sfn % T) == (T / N) * (ueid % N)) { if ((sfn % T) != (T / N) * (ueid % N)) {
continue;
}
int sf_idx = sf_pattern[i_s % 4][(Ns - 1) % 4]; int sf_idx = sf_pattern[i_s % 4][(Ns - 1) % 4];
if (sf_idx < 0) { if (sf_idx < 0) {
rrc_log->error("SF pattern is N/A for Ns=%d, i_s=%d, imsi_decimal=%d\n", Ns, i_s, ueid); rrc_log->error("SF pattern is N/A for Ns=%d, i_s=%d, imsi_decimal=%d\n", Ns, i_s, ueid);
} else if ((uint32_t)sf_idx == (tti % 10)) { continue;
}
paging_rec->paging_record_list_present = true; if ((uint32_t)sf_idx == (tti % 10)) {
paging_record_s paging_elem; paging_rec->paging_record_list_present = true;
if (u.choice_type == LIBLTE_S1AP_UEPAGINGID_CHOICE_IMSI) { paging_record_s paging_elem;
paging_elem.ue_id.set_imsi(); if (u.choice_type == LIBLTE_S1AP_UEPAGINGID_CHOICE_IMSI) {
paging_elem.ue_id.imsi().resize(u.choice.iMSI.n_octets); paging_elem.ue_id.set_imsi();
memcpy(paging_elem.ue_id.imsi().data(), u.choice.iMSI.buffer, u.choice.iMSI.n_octets); paging_elem.ue_id.imsi().resize(u.choice.iMSI.n_octets);
rrc_log->console("Warning IMSI paging not tested\n"); memcpy(paging_elem.ue_id.imsi().data(), u.choice.iMSI.buffer, u.choice.iMSI.n_octets);
} else { rrc_log->console("Warning IMSI paging not tested\n");
paging_elem.ue_id.set_s_tmsi(); } else {
paging_elem.ue_id.s_tmsi().mmec.from_number(u.choice.s_TMSI.mMEC.buffer[0]); paging_elem.ue_id.set_s_tmsi();
uint32_t m_tmsi = 0; paging_elem.ue_id.s_tmsi().mmec.from_number(u.choice.s_TMSI.mMEC.buffer[0]);
for (int i = 0; i < LIBLTE_S1AP_M_TMSI_OCTET_STRING_LEN; i++) { uint32_t m_tmsi = 0;
m_tmsi |= u.choice.s_TMSI.m_TMSI.buffer[i] << (8u * (LIBLTE_S1AP_M_TMSI_OCTET_STRING_LEN - i - 1)); for (int i = 0; i < LIBLTE_S1AP_M_TMSI_OCTET_STRING_LEN; i++) {
} m_tmsi |= u.choice.s_TMSI.m_TMSI.buffer[i] << (8u * (LIBLTE_S1AP_M_TMSI_OCTET_STRING_LEN - i - 1));
paging_elem.ue_id.s_tmsi().m_tmsi.from_number(m_tmsi);
} }
paging_elem.cn_domain = paging_record_s::cn_domain_e_::ps; paging_elem.ue_id.s_tmsi().m_tmsi.from_number(m_tmsi);
paging_rec->paging_record_list.push_back(paging_elem);
ue_to_remove.push_back(ueid);
n++;
rrc_log->info("Assembled paging for ue_id=%d, tti=%d\n", ueid, tti);
} }
paging_elem.cn_domain = paging_record_s::cn_domain_e_::ps;
paging_rec->paging_record_list.push_back(paging_elem);
ue_to_remove.push_back(ueid);
n++;
rrc_log->info("Assembled paging for ue_id=%d, tti=%d\n", ueid, tti);
} }
} }

Loading…
Cancel
Save