Commit d83daf07 authored by aligungr's avatar aligungr

Service reject handling

parent 156c4ac7
......@@ -8,6 +8,7 @@
#include "utils.hpp"
#include <algorithm>
#include <cstring>
namespace nas::utils
......@@ -262,7 +263,7 @@ IEDnn DnnFromApn(const std::string &apn)
return dnn;
}
void AddToPlmnList(IEPlmnList &list, VPlmn item)
void AddToPlmnList(IEPlmnList &list, const VPlmn &item)
{
if (!std::any_of(list.plmns.begin(), list.plmns.end(), [&item](auto &i) { return DeepEqualsV(i, item); }))
list.plmns.push_back(item);
......@@ -381,4 +382,56 @@ bool ServiceAreaListForbidsTai(const VPartialServiceAreaList &list, const VTrack
return false;
}
void AddToTaiList(IE5gsTrackingAreaIdentityList &list, const VTrackingAreaIdentity &tai)
{
if (!TaiListContains(list, tai))
{
VPartialTrackingAreaIdentityList ls{};
ls.list01 = VPartialTrackingAreaIdentityList01{tai.plmn, tai.tac};
ls.present = 1;
list.list.push_back(ls);
}
}
void RemoveFromTaiList(IE5gsTrackingAreaIdentityList &list, const VTrackingAreaIdentity &tai)
{
list.list.erase(std::remove_if(list.list.begin(), list.list.end(),
[&tai](auto &itemList) {
return itemList.present == 1 && DeepEqualsV(itemList.list01->plmn, tai.plmn) &&
(int)itemList.list01->tac == (int)tai.tac;
}),
list.list.end());
for (auto &itemList : list.list)
{
if (itemList.present == 0)
{
auto &list0 = itemList.list00;
if (DeepEqualsV(list0->plmn, tai.plmn))
{
list0->tacs.erase(std::remove_if(list0->tacs.begin(), list0->tacs.end(),
[&tai](auto tac) { return (int)tac == (int)tai.tac; }),
list0->tacs.end());
}
}
else if (itemList.present == 2)
{
auto &list2 = itemList.list10;
list2->tais.erase(
std::remove_if(list2->tais.begin(), list2->tais.end(), [&tai](auto &i) { return DeepEqualsV(i, tai); }),
list2->tais.end());
}
}
list.list.erase(
std::remove_if(list.list.begin(), list.list.end(),
[](auto &itemList) { return itemList.present == 0 && itemList.list00->tacs.empty(); }),
list.list.end());
list.list.erase(
std::remove_if(list.list.begin(), list.list.end(),
[](auto &itemList) { return itemList.present == 2 && itemList.list10->tais.empty(); }),
list.list.end());
}
} // namespace nas::utils
......@@ -24,7 +24,9 @@ SingleSlice SNssaiTo(const IESNssai &v);
bool HasValue(const IEGprsTimer3 &v);
bool HasValue(const IEGprsTimer2 &v);
void AddToPlmnList(IEPlmnList &list, VPlmn item);
void AddToPlmnList(IEPlmnList &list, const VPlmn &item);
void AddToTaiList(nas::IE5gsTrackingAreaIdentityList &list, const VTrackingAreaIdentity &tai);
void RemoveFromTaiList(nas::IE5gsTrackingAreaIdentityList &list, const VTrackingAreaIdentity &tai);
bool PlmnListContains(const IEPlmnList &list, VPlmn item);
bool PlmnListContains(const IEPlmnList &list, Plmn item);
bool TaiListContains(const nas::IE5gsTrackingAreaIdentityList &list, const VTrackingAreaIdentity &tai);
......
......@@ -68,7 +68,10 @@ void NasMm::handlePlmnSearchResponse(const std::vector<UeCellMeasurement> &measu
continue;
}
if (nas::utils::TaiListContains(
m_usim->m_forbiddenTaiList,
m_usim->m_forbiddenTaiListRps,
nas::VTrackingAreaIdentity{nas::utils::PlmnFrom(item.cellId.plmn), octet3{item.tac}}) ||
nas::utils::TaiListContains(
m_usim->m_forbiddenTaiListRoaming,
nas::VTrackingAreaIdentity{nas::utils::PlmnFrom(item.cellId.plmn), octet3{item.tac}}))
{
listedAsForbiddenTai++;
......@@ -185,6 +188,8 @@ void NasMm::handleServingCellChange(const UeCellInfo &servingCell)
m_usim->m_servingCell = servingCell;
m_usim->m_currentPlmn = servingCell.cellId.plmn;
m_usim->m_currentTai =
nas::VTrackingAreaIdentity{nas::utils::PlmnFrom(servingCell.cellId.plmn), octet3{servingCell.tac}};
}
void NasMm::handleRrcConnectionSetup()
......@@ -206,6 +211,7 @@ void NasMm::handleRadioLinkFailure()
m_usim->m_servingCell = std::nullopt;
m_usim->m_currentPlmn = std::nullopt;
m_usim->m_currentTai = std::nullopt;
handleRrcConnectionRelease();
......
......@@ -258,13 +258,13 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
if (cause == nas::EMmCause::TA_NOT_ALLOWED)
{
// TODO: add current tai to 5GS forbidden tracking areas for regional provision of service
nas::utils::AddToTaiList(m_usim->m_forbiddenTaiListRps, *m_usim->m_currentTai);
}
if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
{
// TODO: add current tai to 5GS forbidden tracking areas for roaming
// TODO: remove current tai from stored tai list if present
nas::utils::AddToTaiList(m_usim->m_forbiddenTaiListRoaming, *m_usim->m_currentTai);
nas::utils::RemoveFromTaiList(m_usim->m_taiList, *m_usim->m_currentTai);
}
if (cause == nas::EMmCause::ILLEGAL_UE || cause == nas::EMmCause::ILLEGAL_ME ||
......
......@@ -34,9 +34,11 @@ class Usim
// Plmn related
std::optional<UeCellInfo> m_servingCell{};
std::optional<Plmn> m_currentPlmn{};
std::optional<nas::VTrackingAreaIdentity> m_currentTai{};
std::optional<nas::IE5gsTrackingAreaIdentity> m_lastVisitedRegisteredTai{};
nas::IE5gsTrackingAreaIdentityList m_taiList{};
nas::IE5gsTrackingAreaIdentityList m_forbiddenTaiList{};
nas::IE5gsTrackingAreaIdentityList m_forbiddenTaiListRoaming{}; // 5GS TAs for roaming
nas::IE5gsTrackingAreaIdentityList m_forbiddenTaiListRps{}; // 5GS forbidden TAs for regional provision of service
nas::IEPlmnList m_equivalentPlmnList{};
nas::IEPlmnList m_forbiddenPlmnList{};
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