Commit 173b501c authored by aligungr's avatar aligungr

L3 RRC/NAS developments

parent 0792a7da
...@@ -81,8 +81,7 @@ void NasMm::sendInitialRegistration(EInitialRegCause regCause) ...@@ -81,8 +81,7 @@ void NasMm::sendInitialRegistration(EInitialRegCause regCause)
// Assign other fields // Assign other fields
request->mobileIdentity = getOrGeneratePreferredId(); request->mobileIdentity = getOrGeneratePreferredId();
if (m_storage->lastVisitedRegisteredTai->get().hasValue()) if (m_storage->lastVisitedRegisteredTai->get().hasValue())
request->lastVisitedRegisteredTai = request->lastVisitedRegisteredTai = nas::IE5gsTrackingAreaIdentity{m_storage->lastVisitedRegisteredTai->get()};
nas::IE5gsTrackingAreaIdentity{m_storage->lastVisitedRegisteredTai->get()};
if (!requestedNssai.slices.empty()) if (!requestedNssai.slices.empty())
request->requestedNSSAI = nas::utils::NssaiFrom(requestedNssai); request->requestedNSSAI = nas::utils::NssaiFrom(requestedNssai);
request->ueSecurityCapability = createSecurityCapabilityIe(); request->ueSecurityCapability = createSecurityCapabilityIe();
...@@ -176,8 +175,7 @@ void NasMm::sendMobilityRegistration(ERegUpdateCause updateCause) ...@@ -176,8 +175,7 @@ void NasMm::sendMobilityRegistration(ERegUpdateCause updateCause)
// Assign other fields // Assign other fields
if (m_storage->lastVisitedRegisteredTai->get().hasValue()) if (m_storage->lastVisitedRegisteredTai->get().hasValue())
request->lastVisitedRegisteredTai = request->lastVisitedRegisteredTai = nas::IE5gsTrackingAreaIdentity{m_storage->lastVisitedRegisteredTai->get()};
nas::IE5gsTrackingAreaIdentity{m_storage->lastVisitedRegisteredTai->get()};
request->mobileIdentity = getOrGeneratePreferredId(); request->mobileIdentity = getOrGeneratePreferredId();
if (!requestedNssai.slices.empty()) if (!requestedNssai.slices.empty())
request->requestedNSSAI = nas::utils::NssaiFrom(requestedNssai); request->requestedNSSAI = nas::utils::NssaiFrom(requestedNssai);
...@@ -236,8 +234,7 @@ void NasMm::receiveInitialRegistrationAccept(const nas::RegistrationAccept &msg) ...@@ -236,8 +234,7 @@ void NasMm::receiveInitialRegistrationAccept(const nas::RegistrationAccept &msg)
// Store the TAI list as a registration area // Store the TAI list as a registration area
m_usim->m_taiList = msg.taiList.value_or(nas::IE5gsTrackingAreaIdentityList{}); m_usim->m_taiList = msg.taiList.value_or(nas::IE5gsTrackingAreaIdentityList{});
Tai currentTai = m_base->shCtx.getCurrentTai(); Tai currentTai = m_base->shCtx.getCurrentTai();
if (currentTai.hasValue() && if (currentTai.hasValue() && nas::utils::TaiListContains(m_usim->m_taiList, nas::VTrackingAreaIdentity{currentTai}))
nas::utils::TaiListContains(m_usim->m_taiList, nas::VTrackingAreaIdentity{currentTai}))
m_storage->lastVisitedRegisteredTai->set(currentTai); m_storage->lastVisitedRegisteredTai->set(currentTai);
// Store the service area list // Store the service area list
......
...@@ -15,28 +15,40 @@ ...@@ -15,28 +15,40 @@
template <typename TInput, typename TOutput> template <typename TInput, typename TOutput>
class LightSync class LightSync
{ {
const int64_t m_validUntil; private:
const int64_t m_validUntilForProducer;
const int64_t m_validUntilForConsumer;
const std::unique_ptr<TInput> m_input; const std::unique_ptr<TInput> m_input;
std::atomic_bool m_processed; std::atomic_bool m_processed;
std::shared_ptr<TOutput> m_output; std::shared_ptr<TOutput> m_output;
public: public:
LightSync(int validForMs, std::unique_ptr<TInput> &&input) LightSync(int validForMs, int estimatedProcessMs, std::unique_ptr<TInput> &&input)
: m_validUntil{utils::CurrentTimeMillis() + static_cast<int64_t>(validForMs)}, m_input{std::move(input)}, : m_validUntilForProducer{utils::CurrentTimeMillis() + static_cast<int64_t>(validForMs)},
m_processed{}, m_output{} m_validUntilForConsumer{utils::CurrentTimeMillis() + static_cast<int64_t>(validForMs + estimatedProcessMs)},
m_input{std::move(input)}, m_processed{}, m_output{}
{ {
if (validForMs >= 2500) if (validForMs >= 2500)
throw std::runtime_error("LightSync timeout is too large"); throw std::runtime_error("LightSync timeout is too large");
if (estimatedProcessMs >= 50)
throw std::runtime_error("LightSync estimated process time is too large");
} }
const TInput &getInput() private:
bool isExpiredForConsumer()
{
return utils::CurrentTimeMillis() > m_validUntilForConsumer;
}
public:
const TInput &input()
{ {
return *m_input; return *m_input;
} }
bool isValid() bool isExpiredForProducer()
{ {
return utils::CurrentTimeMillis() <= m_validUntil; return utils::CurrentTimeMillis() > m_validUntilForProducer;
} }
// Only producer can call at most once // Only producer can call at most once
...@@ -53,11 +65,17 @@ class LightSync ...@@ -53,11 +65,17 @@ class LightSync
{ {
while (true) while (true)
{ {
if (!isValid()) if (isExpiredForConsumer())
return nullptr; return nullptr;
if (m_processed) if (m_processed)
return m_output; return m_output;
} }
} }
static std::shared_ptr<LightSync<TInput, TOutput>> MakeShared(int validForMs, int estimatedProcessMs,
std::unique_ptr<TInput> &&input)
{
return std::make_shared<LightSync<TInput, TOutput>>(validForMs, estimatedProcessMs, std::move(input));
}
}; };
\ No newline at end of file
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