Commit db31bdad authored by aligungr's avatar aligungr

L3 RRC/NAS developments

parent b0ff6730
...@@ -18,6 +18,7 @@ namespace nas ...@@ -18,6 +18,7 @@ namespace nas
* - Items are unique, if already exists, deletes the previous one * - Items are unique, if already exists, deletes the previous one
* - List have fixed size, if capacity is full, oldest item is deleted * - List have fixed size, if capacity is full, oldest item is deleted
* - Automatically cleared after specified period * - Automatically cleared after specified period
* - Can be asked if it has a changes after the last one
*/ */
template <typename T> template <typename T>
class NasListT1 class NasListT1
...@@ -29,17 +30,20 @@ class NasListT1 ...@@ -29,17 +30,20 @@ class NasListT1
std::vector<T> m_data; std::vector<T> m_data;
size_t m_size; size_t m_size;
int64_t m_lastAutoCleared; int64_t m_lastAutoCleared;
int64_t m_lastChange;
int64_t m_lastChangeQueried;
public: public:
NasListT1(size_t sizeLimit, int64_t autoClearingPeriod) NasListT1(size_t sizeLimit, int64_t autoClearingPeriod)
: m_sizeLimit{sizeLimit}, m_autoClearingPeriod{autoClearingPeriod}, m_data{sizeLimit}, m_size{}, : m_sizeLimit{sizeLimit}, m_autoClearingPeriod{autoClearingPeriod}, m_data{sizeLimit}, m_size{},
m_lastAutoCleared{::utils::CurrentTimeMillis()} m_lastAutoCleared{::utils::CurrentTimeMillis()}, m_lastChange{}, m_lastChangeQueried{}
{ {
} }
public: public:
void add(const T &item) void add(const T &item)
{ {
touch();
autoClearIfNecessary(); autoClearIfNecessary();
remove(item); remove(item);
makeSlotForNewItem(); makeSlotForNewItem();
...@@ -50,6 +54,7 @@ class NasListT1 ...@@ -50,6 +54,7 @@ class NasListT1
void add(T &&item) void add(T &&item)
{ {
touch();
autoClearIfNecessary(); autoClearIfNecessary();
remove(item); remove(item);
makeSlotForNewItem(); makeSlotForNewItem();
...@@ -70,6 +75,7 @@ class NasListT1 ...@@ -70,6 +75,7 @@ class NasListT1
void remove(const T &item) void remove(const T &item)
{ {
touch();
autoClearIfNecessary(); autoClearIfNecessary();
size_t index = ~0u; size_t index = ~0u;
...@@ -91,13 +97,28 @@ class NasListT1 ...@@ -91,13 +97,28 @@ class NasListT1
{ {
autoClearIfNecessary(); autoClearIfNecessary();
for (size_t i = 0; i < m_size; i++)
fun((const T &)m_data[i]);
}
template <typename Functor>
void mutateForEach(Functor &&fun)
{
touch();
autoClearIfNecessary();
for (size_t i = 0; i < m_size; i++) for (size_t i = 0; i < m_size; i++)
fun(m_data[i]); fun(m_data[i]);
} }
void clear() void clear()
{ {
autoClearIfNecessary(); touch();
int64_t currentTime = ::utils::CurrentTimeMillis();
if (currentTime - m_lastAutoCleared >= m_autoClearingPeriod)
m_lastAutoCleared = currentTime;
m_data.clear(); m_data.clear();
m_size = 0; m_size = 0;
...@@ -110,6 +131,16 @@ class NasListT1 ...@@ -110,6 +131,16 @@ class NasListT1
return m_data.size(); return m_data.size();
} }
bool hasChange()
{
if (m_lastChangeQueried == 0 || m_lastChangeQueried != m_lastChange)
{
m_lastChangeQueried = m_lastChange;
return true;
}
return false;
}
private: private:
void autoClearIfNecessary() void autoClearIfNecessary()
{ {
...@@ -129,10 +160,17 @@ class NasListT1 ...@@ -129,10 +160,17 @@ class NasListT1
void removeAt(size_t index) void removeAt(size_t index)
{ {
touch();
for (size_t i = index; i < m_size; ++i) for (size_t i = index; i < m_size; ++i)
m_data[i] = i + 1 < m_sizeLimit ? m_data[i + 1] : T{}; m_data[i] = i + 1 < m_sizeLimit ? m_data[i + 1] : T{};
m_size--; m_size--;
} }
void touch()
{
m_lastChange = utils::CurrentTimeMillis();
}
}; };
} // namespace nas } // namespace nas
...@@ -247,7 +247,13 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi ...@@ -247,7 +247,13 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi
if (cause == nas::EMmCause::TA_NOT_ALLOWED || cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || if (cause == nas::EMmCause::TA_NOT_ALLOWED || cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA ||
cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA) cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
{ {
nas::utils::AddToTaiList(m_usim->m_forbiddenTaiListRoaming, *m_usim->m_currentTai); Tai tai;
tai.plmn.mcc = m_usim->m_currentTai->plmn.mcc;
tai.plmn.mnc = m_usim->m_currentTai->plmn.mnc;
tai.plmn.isLongMnc = m_usim->m_currentTai->plmn.isLongMnc;
tai.tac = (int)m_usim->m_currentTai->tac;
m_storage.m_forbiddenTaiListRoaming.add(tai);
} }
if (cause == nas::EMmCause::ILLEGAL_UE || cause == nas::EMmCause::FIVEG_SERVICES_NOT_ALLOWED) if (cause == nas::EMmCause::ILLEGAL_UE || cause == nas::EMmCause::FIVEG_SERVICES_NOT_ALLOWED)
......
...@@ -563,7 +563,13 @@ void NasMm::receiveInitialRegistrationReject(const nas::RegistrationReject &msg) ...@@ -563,7 +563,13 @@ void NasMm::receiveInitialRegistrationReject(const nas::RegistrationReject &msg)
if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA) if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
{ {
nas::utils::AddToTaiList(m_usim->m_forbiddenTaiListRoaming, *m_usim->m_currentTai); Tai tai;
tai.plmn.mcc = m_usim->m_currentTai->plmn.mcc;
tai.plmn.mnc = m_usim->m_currentTai->plmn.mnc;
tai.plmn.isLongMnc = m_usim->m_currentTai->plmn.isLongMnc;
tai.tac = (int)m_usim->m_currentTai->tac;
m_storage.m_forbiddenTaiListRoaming.add(tai);
} }
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED) if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
...@@ -721,7 +727,13 @@ void NasMm::receiveMobilityRegistrationReject(const nas::RegistrationReject &msg ...@@ -721,7 +727,13 @@ void NasMm::receiveMobilityRegistrationReject(const nas::RegistrationReject &msg
if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA) if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
{ {
nas::utils::AddToTaiList(m_usim->m_forbiddenTaiListRoaming, *m_usim->m_currentTai); Tai tai;
tai.plmn.mcc = m_usim->m_currentTai->plmn.mcc;
tai.plmn.mnc = m_usim->m_currentTai->plmn.mnc;
tai.plmn.isLongMnc = m_usim->m_currentTai->plmn.isLongMnc;
tai.tac = (int)m_usim->m_currentTai->tac;
m_storage.m_forbiddenTaiListRoaming.add(tai);
} }
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED) if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
......
...@@ -310,12 +310,25 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg) ...@@ -310,12 +310,25 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
if (cause == nas::EMmCause::TA_NOT_ALLOWED) if (cause == nas::EMmCause::TA_NOT_ALLOWED)
{ {
nas::utils::AddToTaiList(m_usim->m_forbiddenTaiListRps, *m_usim->m_currentTai); Tai tai;
tai.plmn.mcc = m_usim->m_currentTai->plmn.mcc;
tai.plmn.mnc = m_usim->m_currentTai->plmn.mnc;
tai.plmn.isLongMnc = m_usim->m_currentTai->plmn.isLongMnc;
tai.tac = (int)m_usim->m_currentTai->tac;
m_storage.m_forbiddenTaiListRps.add(tai);
} }
if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA) if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
{ {
nas::utils::AddToTaiList(m_usim->m_forbiddenTaiListRoaming, *m_usim->m_currentTai); Tai tai;
tai.plmn.mcc = m_usim->m_currentTai->plmn.mcc;
tai.plmn.mnc = m_usim->m_currentTai->plmn.mnc;
tai.plmn.isLongMnc = m_usim->m_currentTai->plmn.isLongMnc;
tai.tac = (int)m_usim->m_currentTai->tac;
m_storage.m_forbiddenTaiListRoaming.add(tai);
nas::utils::RemoveFromTaiList(m_usim->m_taiList, *m_usim->m_currentTai); nas::utils::RemoveFromTaiList(m_usim->m_taiList, *m_usim->m_currentTai);
} }
......
...@@ -40,8 +40,6 @@ class Usim ...@@ -40,8 +40,6 @@ class Usim
std::optional<nas::VTrackingAreaIdentity> m_currentTai{}; std::optional<nas::VTrackingAreaIdentity> m_currentTai{};
std::optional<nas::IE5gsTrackingAreaIdentity> m_lastVisitedRegisteredTai{}; std::optional<nas::IE5gsTrackingAreaIdentity> m_lastVisitedRegisteredTai{};
nas::IE5gsTrackingAreaIdentityList m_taiList{}; nas::IE5gsTrackingAreaIdentityList m_taiList{};
nas::IE5gsTrackingAreaIdentityList m_forbiddenTaiListRoaming{}; // 5GS forbidden TAs for roaming
nas::IE5gsTrackingAreaIdentityList m_forbiddenTaiListRps{}; // 5GS forbidden TAs for regional provision of service
nas::IEPlmnList m_equivalentPlmnList{}; nas::IEPlmnList m_equivalentPlmnList{};
nas::IEPlmnList m_forbiddenPlmnList{}; nas::IEPlmnList m_forbiddenPlmnList{};
nas::IEServiceAreaList m_serviceAreaList{}; nas::IEServiceAreaList m_serviceAreaList{};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment