Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
UERANSIM
Commits
847fbaab
Commit
847fbaab
authored
Oct 08, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
S-TMSI handling in UE RRC connection setup
parent
35cd3779
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
4 deletions
+53
-4
src/ue/rrc/connection.cpp
src/ue/rrc/connection.cpp
+33
-2
src/ue/types.hpp
src/ue/types.hpp
+2
-2
src/utils/common_types.cpp
src/utils/common_types.cpp
+6
-0
src/utils/common_types.hpp
src/utils/common_types.hpp
+2
-0
src/utils/octet.hpp
src/utils/octet.hpp
+10
-0
No files found.
src/ue/rrc/connection.cpp
View file @
847fbaab
...
...
@@ -41,6 +41,7 @@ static ASN_RRC_UL_CCCH_Message *ConstructSetupRequest(ASN_RRC_InitialUE_Identity
void
UeRrcTask
::
startConnectionEstablishment
(
OctetString
&&
nasPdu
)
{
/* Check the protocol state */
if
(
m_state
!=
ERrcState
::
RRC_IDLE
)
{
m_logger
->
err
(
"RRC establishment could not start, UE not in RRC-IDLE state"
);
...
...
@@ -48,6 +49,7 @@ void UeRrcTask::startConnectionEstablishment(OctetString &&nasPdu)
return
;
}
/* Check the current cell */
int
activeCell
=
m_base
->
shCtx
.
currentCell
.
get
<
int
>
([](
auto
&
item
)
{
return
item
.
cellId
;
});
if
(
activeCell
==
0
)
{
...
...
@@ -56,11 +58,28 @@ void UeRrcTask::startConnectionEstablishment(OctetString &&nasPdu)
return
;
}
m_initialId
.
present
=
ASN_RRC_InitialUE_Identity_PR_randomValue
;
asn
::
SetBitStringLong
<
39
>
(
Random
::
Mixed
(
m_base
->
config
->
getNodeName
()).
nextL
(),
m_initialId
.
choice
.
randomValue
);
/* Handle Initial UE Identity (S-TMSI or 39-bit random value) */
std
::
optional
<
GutiMobileIdentity
>
gutiOrTmsi
=
m_base
->
shCtx
.
providedGuti
.
get
();
if
(
!
gutiOrTmsi
)
gutiOrTmsi
=
m_base
->
shCtx
.
providedTmsi
.
get
();
if
(
gutiOrTmsi
)
{
m_initialId
.
present
=
ASN_RRC_InitialUE_Identity_PR_ng_5G_S_TMSI_Part1
;
asn
::
SetBitStringLong
<
39
>
(
static_cast
<
int64_t
>
(
gutiOrTmsi
->
tmsi
)
|
(
static_cast
<
int64_t
>
((
gutiOrTmsi
->
amfPointer
&
0b1111111
))
<<
39ull
),
m_initialId
.
choice
.
ng_5G_S_TMSI_Part1
);
}
else
{
m_initialId
.
present
=
ASN_RRC_InitialUE_Identity_PR_randomValue
;
asn
::
SetBitStringLong
<
39
>
(
Random
::
Mixed
(
m_base
->
config
->
getNodeName
()).
nextL
(),
m_initialId
.
choice
.
randomValue
);
}
/* Set the Initial NAS PDU */
m_initialNasPdu
=
std
::
move
(
nasPdu
);
/* Send the message */
m_logger
->
debug
(
"Sending RRC Setup Request"
);
auto
*
rrcSetupRequest
=
...
...
@@ -93,6 +112,18 @@ void UeRrcTask::receiveRrcSetup(int cellId, const ASN_RRC_RRCSetup &msg)
ies
->
selectedPLMN_Identity
=
1
;
asn
::
SetOctetString
(
ies
->
dedicatedNAS_Message
,
m_initialNasPdu
);
/* Send S-TMSI if available */
std
::
optional
<
GutiMobileIdentity
>
gutiOrTmsi
=
m_base
->
shCtx
.
providedGuti
.
get
();
if
(
!
gutiOrTmsi
)
gutiOrTmsi
=
m_base
->
shCtx
.
providedTmsi
.
get
();
if
(
gutiOrTmsi
)
{
auto
&
sTmsi
=
setupComplete
->
criticalExtensions
.
choice
.
rrcSetupComplete
->
ng_5G_S_TMSI_Value
=
asn
::
New
<
ASN_RRC_RRCSetupComplete_IEs
::
ASN_RRC_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value
>
();
sTmsi
->
present
=
ASN_RRC_RRCSetupComplete_IEs__ng_5G_S_TMSI_Value_PR_ng_5G_S_TMSI
;
asn
::
SetBitStringLong
<
48
>
(
gutiOrTmsi
->
toTmsiValue
(),
sTmsi
->
choice
.
ng_5G_S_TMSI
);
}
m_initialNasPdu
=
{};
sendRrcMessage
(
pdu
);
...
...
src/ue/types.hpp
View file @
847fbaab
...
...
@@ -178,8 +178,8 @@ struct UeSharedContext
Locked
<
ActiveCellInfo
>
currentCell
;
Locked
<
std
::
vector
<
Tai
>>
forbiddenTaiRoaming
;
Locked
<
std
::
vector
<
Tai
>>
forbiddenTaiRps
;
Locked
<
GutiMobileIdentity
>
providedGuti
;
Locked
<
GutiMobileIdentity
>
providedTmsi
;
Locked
<
std
::
optional
<
GutiMobileIdentity
>
>
providedGuti
;
Locked
<
std
::
optional
<
GutiMobileIdentity
>
>
providedTmsi
;
Plmn
getCurrentPlmn
();
Tai
getCurrentTai
();
...
...
src/utils/common_types.cpp
View file @
847fbaab
...
...
@@ -29,6 +29,12 @@ Supi Supi::Parse(const std::string &supi)
throw
std
::
runtime_error
(
"invalid SUPI value"
);
}
int64_t
GutiMobileIdentity
::
toTmsiValue
()
const
{
return
(
static_cast
<
int64_t
>
(
this
->
tmsi
))
|
(
static_cast
<
int64_t
>
(
this
->
amfPointer
)
<<
38LL
)
|
(
static_cast
<
int64_t
>
(
this
->
amfSetId
)
<<
48LL
);
}
GutiMobileIdentity
GutiMobileIdentity
::
FromSTmsi
(
int64_t
sTmsi
)
{
GutiMobileIdentity
res
;
...
...
src/utils/common_types.hpp
View file @
847fbaab
...
...
@@ -91,6 +91,8 @@ struct GutiMobileIdentity
{
}
[[
nodiscard
]]
int64_t
toTmsiValue
()
const
;
static
GutiMobileIdentity
FromSTmsi
(
int64_t
sTmsi
);
};
...
...
src/utils/octet.hpp
View file @
847fbaab
...
...
@@ -177,6 +177,16 @@ struct octet4
return
value
;
}
inline
explicit
constexpr
operator
int64_t
()
const
{
return
static_cast
<
int64_t
>
(
value
);
}
inline
explicit
constexpr
operator
uint64_t
()
const
{
return
static_cast
<
int64_t
>
(
value
);
}
inline
bool
operator
==
(
const
octet4
&
other
)
const
{
return
value
==
other
.
value
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment