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
4ec4a785
Commit
4ec4a785
authored
Dec 23, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NTS memory leak fix
parent
8e368396
Changes
53
Hide whitespace changes
Inline
Side-by-side
Showing
53 changed files
with
408 additions
and
455 deletions
+408
-455
src/gnb/app/cmd_handler.cpp
src/gnb/app/cmd_handler.cpp
+2
-2
src/gnb/app/task.cpp
src/gnb/app/task.cpp
+7
-9
src/gnb/gnb.cpp
src/gnb/gnb.cpp
+1
-1
src/gnb/gtp/task.cpp
src/gnb/gtp/task.cpp
+14
-16
src/gnb/ngap/context.cpp
src/gnb/ngap/context.cpp
+8
-8
src/gnb/ngap/interface.cpp
src/gnb/ngap/interface.cpp
+5
-5
src/gnb/ngap/nas.cpp
src/gnb/ngap/nas.cpp
+2
-2
src/gnb/ngap/radio.cpp
src/gnb/ngap/radio.cpp
+5
-5
src/gnb/ngap/session.cpp
src/gnb/ngap/session.cpp
+4
-4
src/gnb/ngap/task.cpp
src/gnb/ngap/task.cpp
+15
-17
src/gnb/ngap/transport.cpp
src/gnb/ngap/transport.cpp
+4
-4
src/gnb/rls/ctl_task.cpp
src/gnb/rls/ctl_task.cpp
+27
-29
src/gnb/rls/task.cpp
src/gnb/rls/task.cpp
+34
-36
src/gnb/rls/udp_task.cpp
src/gnb/rls/udp_task.cpp
+6
-6
src/gnb/rrc/channel.cpp
src/gnb/rrc/channel.cpp
+10
-10
src/gnb/rrc/connection.cpp
src/gnb/rrc/connection.cpp
+2
-2
src/gnb/rrc/handler.cpp
src/gnb/rrc/handler.cpp
+4
-4
src/gnb/rrc/task.cpp
src/gnb/rrc/task.cpp
+10
-12
src/gnb/sctp/task.cpp
src/gnb/sctp/task.cpp
+29
-31
src/lib/app/cli_base.hpp
src/lib/app/cli_base.hpp
+6
-5
src/lib/rlc/test.cpp
src/lib/rlc/test.cpp
+5
-6
src/lib/udp/server_task.cpp
src/lib/udp/server_task.cpp
+1
-1
src/ue.cpp
src/ue.cpp
+7
-7
src/ue/app/cmd_handler.cpp
src/ue/app/cmd_handler.cpp
+2
-2
src/ue/app/task.cpp
src/ue/app/task.cpp
+21
-22
src/ue/nas/mm/access.cpp
src/ue/nas/mm/access.cpp
+2
-2
src/ue/nas/mm/base.cpp
src/ue/nas/mm/base.cpp
+3
-3
src/ue/nas/mm/dereg.cpp
src/ue/nas/mm/dereg.cpp
+1
-1
src/ue/nas/mm/messaging.cpp
src/ue/nas/mm/messaging.cpp
+2
-2
src/ue/nas/mm/radio.cpp
src/ue/nas/mm/radio.cpp
+3
-3
src/ue/nas/sm/establishment.cpp
src/ue/nas/sm/establishment.cpp
+2
-2
src/ue/nas/sm/resource.cpp
src/ue/nas/sm/resource.cpp
+2
-2
src/ue/nas/sm/sap.cpp
src/ue/nas/sm/sap.cpp
+4
-4
src/ue/nas/task.cpp
src/ue/nas/task.cpp
+19
-21
src/ue/rls/ctl_task.cpp
src/ue/rls/ctl_task.cpp
+25
-27
src/ue/rls/task.cpp
src/ue/rls/task.cpp
+39
-42
src/ue/rls/udp_task.cpp
src/ue/rls/udp_task.cpp
+4
-4
src/ue/rrc/cells.cpp
src/ue/rrc/cells.cpp
+4
-4
src/ue/rrc/channel.cpp
src/ue/rrc/channel.cpp
+6
-6
src/ue/rrc/connection.cpp
src/ue/rrc/connection.cpp
+3
-3
src/ue/rrc/failures.cpp
src/ue/rrc/failures.cpp
+1
-1
src/ue/rrc/handler.cpp
src/ue/rrc/handler.cpp
+2
-2
src/ue/rrc/idle.cpp
src/ue/rrc/idle.cpp
+4
-4
src/ue/rrc/nas.cpp
src/ue/rrc/nas.cpp
+2
-2
src/ue/rrc/sap.cpp
src/ue/rrc/sap.cpp
+2
-2
src/ue/rrc/state.cpp
src/ue/rrc/state.cpp
+1
-1
src/ue/rrc/task.cpp
src/ue/rrc/task.cpp
+8
-10
src/ue/tun/task.cpp
src/ue/tun/task.cpp
+9
-11
src/ue/ue.cpp
src/ue/ue.cpp
+1
-1
src/utils/logger.cpp
src/utils/logger.cpp
+2
-2
src/utils/logger.hpp
src/utils/logger.hpp
+1
-1
src/utils/nts.cpp
src/utils/nts.cpp
+14
-26
src/utils/nts.hpp
src/utils/nts.hpp
+11
-20
No files found.
src/gnb/app/cmd_handler.cpp
View file @
4ec4a785
...
...
@@ -25,12 +25,12 @@ namespace nr::gnb
void
GnbCmdHandler
::
sendResult
(
const
InetAddress
&
address
,
const
std
::
string
&
output
)
{
m_base
->
cliCallbackTask
->
push
(
new
app
::
NwCliSendResponse
(
address
,
output
,
false
));
m_base
->
cliCallbackTask
->
push
(
std
::
make_unique
<
app
::
NwCliSendResponse
>
(
address
,
output
,
false
));
}
void
GnbCmdHandler
::
sendError
(
const
InetAddress
&
address
,
const
std
::
string
&
output
)
{
m_base
->
cliCallbackTask
->
push
(
new
app
::
NwCliSendResponse
(
address
,
output
,
true
));
m_base
->
cliCallbackTask
->
push
(
std
::
make_unique
<
app
::
NwCliSendResponse
>
(
address
,
output
,
true
));
}
void
GnbCmdHandler
::
pauseTasks
()
...
...
src/gnb/app/task.cpp
View file @
4ec4a785
...
...
@@ -25,34 +25,32 @@ void GnbAppTask::onStart()
void
GnbAppTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
GNB_STATUS_UPDATE
:
{
auto
*
w
=
dynamic_cast
<
NmGnbStatusUpdate
*>
(
msg
);
switch
(
w
->
what
)
auto
&
w
=
dynamic_cast
<
NmGnbStatusUpdate
&>
(
*
msg
);
switch
(
w
.
what
)
{
case
NmGnbStatusUpdate
:
:
NGAP_IS_UP
:
m_statusInfo
.
isNgapUp
=
w
->
isNgapUp
;
m_statusInfo
.
isNgapUp
=
w
.
isNgapUp
;
break
;
}
break
;
}
case
NtsMessageType
:
:
GNB_CLI_COMMAND
:
{
auto
*
w
=
dynamic_cast
<
NmGnbCliCommand
*>
(
msg
);
auto
&
w
=
dynamic_cast
<
NmGnbCliCommand
&>
(
*
msg
);
GnbCmdHandler
handler
{
m_base
};
handler
.
handleCmd
(
*
w
);
handler
.
handleCmd
(
w
);
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
void
GnbAppTask
::
onQuit
()
...
...
src/gnb/gnb.cpp
View file @
4ec4a785
...
...
@@ -70,7 +70,7 @@ void GNodeB::start()
void
GNodeB
::
pushCommand
(
std
::
unique_ptr
<
app
::
GnbCliCommand
>
cmd
,
const
InetAddress
&
address
)
{
taskBase
->
appTask
->
push
(
new
NmGnbCliCommand
(
std
::
move
(
cmd
),
address
));
taskBase
->
appTask
->
push
(
std
::
make_unique
<
NmGnbCliCommand
>
(
std
::
move
(
cmd
),
address
));
}
}
// namespace nr::gnb
src/gnb/gtp/task.cpp
View file @
4ec4a785
...
...
@@ -48,55 +48,53 @@ void GtpTask::onQuit()
void
GtpTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
GNB_NGAP_TO_GTP
:
{
auto
*
w
=
dynamic_cast
<
NmGnbNgapToGtp
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbNgapToGtp
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbNgapToGtp
:
:
UE_CONTEXT_UPDATE
:
{
handleUeContextUpdate
(
*
w
->
update
);
handleUeContextUpdate
(
*
w
.
update
);
break
;
}
case
NmGnbNgapToGtp
:
:
UE_CONTEXT_RELEASE
:
{
handleUeContextDelete
(
w
->
ueId
);
handleUeContextDelete
(
w
.
ueId
);
break
;
}
case
NmGnbNgapToGtp
:
:
SESSION_CREATE
:
{
handleSessionCreate
(
w
->
resource
);
handleSessionCreate
(
w
.
resource
);
break
;
}
case
NmGnbNgapToGtp
:
:
SESSION_RELEASE
:
{
handleSessionRelease
(
w
->
ueId
,
w
->
psi
);
handleSessionRelease
(
w
.
ueId
,
w
.
psi
);
break
;
}
}
break
;
}
case
NtsMessageType
:
:
GNB_RLS_TO_GTP
:
{
auto
*
w
=
dynamic_cast
<
NmGnbRlsToGtp
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbRlsToGtp
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbRlsToGtp
:
:
DATA_PDU_DELIVERY
:
{
handleUplinkData
(
w
->
ueId
,
w
->
psi
,
std
::
move
(
w
->
pdu
));
handleUplinkData
(
w
.
ueId
,
w
.
psi
,
std
::
move
(
w
.
pdu
));
break
;
}
}
break
;
}
case
NtsMessageType
:
:
UDP_SERVER_RECEIVE
:
handleUdpReceive
(
*
dynamic_cast
<
udp
::
NwUdpServerReceive
*>
(
msg
));
handleUdpReceive
(
dynamic_cast
<
udp
::
NwUdpServerReceive
&>
(
*
msg
));
break
;
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
void
GtpTask
::
handleUeContextUpdate
(
const
GtpUeContextUpdate
&
msg
)
...
...
@@ -243,11 +241,11 @@ void GtpTask::handleUdpReceive(const udp::NwUdpServerReceive &msg)
if
(
m_rateLimiter
->
allowDownlinkPacket
(
sessionInd
,
gtp
->
payload
.
length
()))
{
auto
*
w
=
new
NmGnbGtpToRls
(
NmGnbGtpToRls
::
DATA_PDU_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmGnbGtpToRls
>
(
NmGnbGtpToRls
::
DATA_PDU_DELIVERY
);
w
->
ueId
=
GetUeId
(
sessionInd
);
w
->
psi
=
GetPsi
(
sessionInd
);
w
->
pdu
=
std
::
move
(
gtp
->
payload
);
m_base
->
rlsTask
->
push
(
w
);
m_base
->
rlsTask
->
push
(
std
::
move
(
w
)
);
}
delete
gtp
;
...
...
src/gnb/ngap/context.cpp
View file @
4ec4a785
...
...
@@ -64,9 +64,9 @@ void NgapTask::receiveInitialContextSetup(int amfId, ASN_NGAP_InitialContextSetu
if
(
ue
==
nullptr
)
return
;
auto
*
w
=
new
NmGnbNgapToGtp
(
NmGnbNgapToGtp
::
UE_CONTEXT_UPDATE
);
auto
w
=
std
::
make_unique
<
NmGnbNgapToGtp
>
(
NmGnbNgapToGtp
::
UE_CONTEXT_UPDATE
);
w
->
update
=
std
::
make_unique
<
GtpUeContextUpdate
>
(
true
,
ue
->
ctxId
,
ue
->
ueAmbr
);
m_base
->
gtpTask
->
push
(
w
);
m_base
->
gtpTask
->
push
(
std
::
move
(
w
)
);
auto
*
reqIe
=
asn
::
ngap
::
GetProtocolIe
(
msg
,
ASN_NGAP_ProtocolIE_ID_id_UEAggregateMaximumBitRate
);
if
(
reqIe
)
...
...
@@ -237,14 +237,14 @@ void NgapTask::receiveContextRelease(int amfId, ASN_NGAP_UEContextReleaseCommand
return
;
// Notify RRC task
auto
*
w1
=
new
NmGnbNgapToRrc
(
NmGnbNgapToRrc
::
AN_RELEASE
);
auto
w1
=
std
::
make_unique
<
NmGnbNgapToRrc
>
(
NmGnbNgapToRrc
::
AN_RELEASE
);
w1
->
ueId
=
ue
->
ctxId
;
m_base
->
rrcTask
->
push
(
w1
);
m_base
->
rrcTask
->
push
(
std
::
move
(
w1
)
);
// Notify GTP task
auto
*
w2
=
new
NmGnbNgapToGtp
(
NmGnbNgapToGtp
::
UE_CONTEXT_RELEASE
);
auto
w2
=
std
::
make_unique
<
NmGnbNgapToGtp
>
(
NmGnbNgapToGtp
::
UE_CONTEXT_RELEASE
);
w2
->
ueId
=
ue
->
ctxId
;
m_base
->
gtpTask
->
push
(
w2
);
m_base
->
gtpTask
->
push
(
std
::
move
(
w2
)
);
auto
*
response
=
asn
::
ngap
::
NewMessagePdu
<
ASN_NGAP_UEContextReleaseComplete
>
({});
sendNgapUeAssociated
(
ue
->
ctxId
,
response
);
...
...
@@ -278,9 +278,9 @@ void NgapTask::receiveContextModification(int amfId, ASN_NGAP_UEContextModificat
auto
*
response
=
asn
::
ngap
::
NewMessagePdu
<
ASN_NGAP_UEContextModificationResponse
>
({});
sendNgapUeAssociated
(
ue
->
ctxId
,
response
);
auto
*
w
=
new
NmGnbNgapToGtp
(
NmGnbNgapToGtp
::
UE_CONTEXT_UPDATE
);
auto
w
=
std
::
make_unique
<
NmGnbNgapToGtp
>
(
NmGnbNgapToGtp
::
UE_CONTEXT_UPDATE
);
w
->
update
=
std
::
make_unique
<
GtpUeContextUpdate
>
(
false
,
ue
->
ctxId
,
ue
->
ueAmbr
);
m_base
->
gtpTask
->
push
(
w
);
m_base
->
gtpTask
->
push
(
std
::
move
(
w
)
);
}
void
NgapTask
::
sendContextRelease
(
int
ueId
,
NgapCause
cause
)
...
...
src/gnb/ngap/interface.cpp
View file @
4ec4a785
...
...
@@ -99,9 +99,9 @@ void NgapTask::handleAssociationShutdown(int amfId)
amf
->
state
=
EAmfState
::
NOT_CONNECTED
;
auto
*
w
=
new
NmGnbSctp
(
NmGnbSctp
::
CONNECTION_CLOSE
);
auto
w
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
CONNECTION_CLOSE
);
w
->
clientId
=
amfId
;
m_base
->
sctpTask
->
push
(
w
);
m_base
->
sctpTask
->
push
(
std
::
move
(
w
)
);
deleteAmfContext
(
amfId
);
}
...
...
@@ -193,11 +193,11 @@ void NgapTask::receiveNgSetupResponse(int amfId, ASN_NGAP_NGSetupResponse *msg)
{
m_isInitialized
=
true
;
auto
*
update
=
new
NmGnbStatusUpdate
(
NmGnbStatusUpdate
::
NGAP_IS_UP
);
auto
update
=
std
::
make_unique
<
NmGnbStatusUpdate
>
(
NmGnbStatusUpdate
::
NGAP_IS_UP
);
update
->
isNgapUp
=
true
;
m_base
->
appTask
->
push
(
update
);
m_base
->
appTask
->
push
(
std
::
move
(
update
)
);
m_base
->
rrcTask
->
push
(
new
NmGnbNgapToRrc
(
NmGnbNgapToRrc
::
RADIO_POWER_ON
));
m_base
->
rrcTask
->
push
(
std
::
make_unique
<
NmGnbNgapToRrc
>
(
NmGnbNgapToRrc
::
RADIO_POWER_ON
));
}
}
...
...
src/gnb/ngap/nas.cpp
View file @
4ec4a785
...
...
@@ -97,10 +97,10 @@ void NgapTask::handleInitialNasTransport(int ueId, const OctetString &nasPdu, in
void
NgapTask
::
deliverDownlinkNas
(
int
ueId
,
OctetString
&&
nasPdu
)
{
auto
*
w
=
new
NmGnbNgapToRrc
(
NmGnbNgapToRrc
::
NAS_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmGnbNgapToRrc
>
(
NmGnbNgapToRrc
::
NAS_DELIVERY
);
w
->
ueId
=
ueId
;
w
->
pdu
=
std
::
move
(
nasPdu
);
m_base
->
rrcTask
->
push
(
w
);
m_base
->
rrcTask
->
push
(
std
::
move
(
w
)
);
}
void
NgapTask
::
handleUplinkNasTransport
(
int
ueId
,
const
OctetString
&
nasPdu
)
...
...
src/gnb/ngap/radio.cpp
View file @
4ec4a785
...
...
@@ -22,9 +22,9 @@ namespace nr::gnb
void
NgapTask
::
handleRadioLinkFailure
(
int
ueId
)
{
// Notify GTP task
auto
*
w2
=
new
NmGnbNgapToGtp
(
NmGnbNgapToGtp
::
UE_CONTEXT_RELEASE
);
w
2
->
ueId
=
ueId
;
m_base
->
gtpTask
->
push
(
w2
);
auto
w
=
std
::
make_unique
<
NmGnbNgapToGtp
>
(
NmGnbNgapToGtp
::
UE_CONTEXT_RELEASE
);
w
->
ueId
=
ueId
;
m_base
->
gtpTask
->
push
(
std
::
move
(
w
)
);
// Notify AMF
sendContextRelease
(
ueId
,
NgapCause
::
RadioNetwork_radio_connection_with_ue_lost
);
...
...
@@ -48,12 +48,12 @@ void NgapTask::receivePaging(int amfId, ASN_NGAP_Paging *msg)
return
;
}
auto
*
w
=
new
NmGnbNgapToRrc
(
NmGnbNgapToRrc
::
PAGING
);
auto
w
=
std
::
make_unique
<
NmGnbNgapToRrc
>
(
NmGnbNgapToRrc
::
PAGING
);
w
->
uePagingTmsi
=
asn
::
UniqueCopy
(
*
ieUePagingIdentity
->
UEPagingIdentity
.
choice
.
fiveG_S_TMSI
,
asn_DEF_ASN_NGAP_FiveG_S_TMSI
);
w
->
taiListForPaging
=
asn
::
UniqueCopy
(
ieTaiListForPaging
->
TAIListForPaging
,
asn_DEF_ASN_NGAP_TAIListForPaging
);
m_base
->
rrcTask
->
push
(
w
);
m_base
->
rrcTask
->
push
(
std
::
move
(
w
)
);
}
}
// namespace nr::gnb
src/gnb/ngap/session.cpp
View file @
4ec4a785
...
...
@@ -238,9 +238,9 @@ std::optional<NgapCause> NgapTask::setupPduSessionResource(NgapUeContext *ue, Pd
resource
->
downTunnel
.
address
=
utils
::
IpToOctetString
(
gtpIp
);
resource
->
downTunnel
.
teid
=
++
m_downlinkTeidCounter
;
auto
*
w
=
new
NmGnbNgapToGtp
(
NmGnbNgapToGtp
::
SESSION_CREATE
);
auto
w
=
std
::
make_unique
<
NmGnbNgapToGtp
>
(
NmGnbNgapToGtp
::
SESSION_CREATE
);
w
->
resource
=
resource
;
m_base
->
gtpTask
->
push
(
w
);
m_base
->
gtpTask
->
push
(
std
::
move
(
w
)
);
ue
->
pduSessions
.
insert
(
resource
->
psi
);
...
...
@@ -281,10 +281,10 @@ void NgapTask::receiveSessionResourceReleaseCommand(int amfId, ASN_NGAP_PDUSessi
// Perform release
for
(
auto
&
psi
:
psIds
)
{
auto
*
w
=
new
NmGnbNgapToGtp
(
NmGnbNgapToGtp
::
SESSION_RELEASE
);
auto
w
=
std
::
make_unique
<
NmGnbNgapToGtp
>
(
NmGnbNgapToGtp
::
SESSION_RELEASE
);
w
->
ueId
=
ue
->
ctxId
;
w
->
psi
=
psi
;
m_base
->
gtpTask
->
push
(
w
);
m_base
->
gtpTask
->
push
(
std
::
move
(
w
)
);
ue
->
pduSessions
.
erase
(
psi
);
}
...
...
src/gnb/ngap/task.cpp
View file @
4ec4a785
...
...
@@ -30,7 +30,7 @@ void NgapTask::onStart()
for
(
auto
&
amfCtx
:
m_amfCtx
)
{
auto
*
msg
=
new
NmGnbSctp
(
NmGnbSctp
::
CONNECTION_REQUEST
);
auto
msg
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
CONNECTION_REQUEST
);
msg
->
clientId
=
amfCtx
.
second
->
ctxId
;
msg
->
localAddress
=
m_base
->
config
->
ngapIp
;
msg
->
localPort
=
0
;
...
...
@@ -38,63 +38,61 @@ void NgapTask::onStart()
msg
->
remotePort
=
amfCtx
.
second
->
port
;
msg
->
ppid
=
sctp
::
PayloadProtocolId
::
NGAP
;
msg
->
associatedTask
=
this
;
m_base
->
sctpTask
->
push
(
msg
);
m_base
->
sctpTask
->
push
(
std
::
move
(
msg
)
);
}
}
void
NgapTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
GNB_RRC_TO_NGAP
:
{
auto
*
w
=
dynamic_cast
<
NmGnbRrcToNgap
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbRrcToNgap
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbRrcToNgap
:
:
INITIAL_NAS_DELIVERY
:
{
handleInitialNasTransport
(
w
->
ueId
,
w
->
pdu
,
w
->
rrcEstablishmentCause
,
w
->
sTmsi
);
handleInitialNasTransport
(
w
.
ueId
,
w
.
pdu
,
w
.
rrcEstablishmentCause
,
w
.
sTmsi
);
break
;
}
case
NmGnbRrcToNgap
:
:
UPLINK_NAS_DELIVERY
:
{
handleUplinkNasTransport
(
w
->
ueId
,
w
->
pdu
);
handleUplinkNasTransport
(
w
.
ueId
,
w
.
pdu
);
break
;
}
case
NmGnbRrcToNgap
:
:
RADIO_LINK_FAILURE
:
{
handleRadioLinkFailure
(
w
->
ueId
);
handleRadioLinkFailure
(
w
.
ueId
);
break
;
}
}
break
;
}
case
NtsMessageType
:
:
GNB_SCTP
:
{
auto
*
w
=
dynamic_cast
<
NmGnbSctp
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbSctp
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbSctp
:
:
ASSOCIATION_SETUP
:
handleAssociationSetup
(
w
->
clientId
,
w
->
associationId
,
w
->
inStreams
,
w
->
outStreams
);
handleAssociationSetup
(
w
.
clientId
,
w
.
associationId
,
w
.
inStreams
,
w
.
outStreams
);
break
;
case
NmGnbSctp
:
:
RECEIVE_MESSAGE
:
handleSctpMessage
(
w
->
clientId
,
w
->
stream
,
w
->
buffer
);
handleSctpMessage
(
w
.
clientId
,
w
.
stream
,
w
.
buffer
);
break
;
case
NmGnbSctp
:
:
ASSOCIATION_SHUTDOWN
:
handleAssociationShutdown
(
w
->
clientId
);
handleAssociationShutdown
(
w
.
clientId
);
break
;
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
break
;
}
default:
{
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
}
delete
msg
;
}
void
NgapTask
::
onQuit
()
...
...
src/gnb/ngap/transport.cpp
View file @
4ec4a785
...
...
@@ -109,11 +109,11 @@ void NgapTask::sendNgapNonUe(int associatedAmf, ASN_NGAP_NGAP_PDU *pdu)
m_logger
->
err
(
"NGAP APER encoding failed"
);
else
{
auto
*
msg
=
new
NmGnbSctp
(
NmGnbSctp
::
SEND_MESSAGE
);
auto
msg
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
SEND_MESSAGE
);
msg
->
clientId
=
amf
->
ctxId
;
msg
->
stream
=
0
;
msg
->
buffer
=
UniqueBuffer
{
buffer
,
static_cast
<
size_t
>
(
encoded
)};
m_base
->
sctpTask
->
push
(
msg
);
m_base
->
sctpTask
->
push
(
std
::
move
(
msg
)
);
if
(
m_base
->
nodeListener
)
{
...
...
@@ -200,11 +200,11 @@ void NgapTask::sendNgapUeAssociated(int ueId, ASN_NGAP_NGAP_PDU *pdu)
m_logger
->
err
(
"NGAP APER encoding failed"
);
else
{
auto
*
msg
=
new
NmGnbSctp
(
NmGnbSctp
::
SEND_MESSAGE
);
auto
msg
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
SEND_MESSAGE
);
msg
->
clientId
=
amf
->
ctxId
;
msg
->
stream
=
ue
->
uplinkStream
;
msg
->
buffer
=
UniqueBuffer
{
buffer
,
static_cast
<
size_t
>
(
encoded
)};
m_base
->
sctpTask
->
push
(
msg
);
m_base
->
sctpTask
->
push
(
std
::
move
(
msg
)
);
if
(
m_base
->
nodeListener
)
{
...
...
src/gnb/rls/ctl_task.cpp
View file @
4ec4a785
...
...
@@ -43,45 +43,45 @@ void RlsControlTask::onStart()
void
RlsControlTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
GNB_RLS_TO_RLS
:
{
auto
*
w
=
dynamic_cast
<
NmGnbRlsToRls
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbRlsToRls
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbRlsToRls
:
:
SIGNAL_DETECTED
:
handleSignalDetected
(
w
->
ueId
);
handleSignalDetected
(
w
.
ueId
);
break
;
case
NmGnbRlsToRls
:
:
SIGNAL_LOST
:
handleSignalLost
(
w
->
ueId
);
handleSignalLost
(
w
.
ueId
);
break
;
case
NmGnbRlsToRls
:
:
RECEIVE_RLS_MESSAGE
:
handleRlsMessage
(
w
->
ueId
,
*
w
->
msg
);
handleRlsMessage
(
w
.
ueId
,
*
w
.
msg
);
break
;
case
NmGnbRlsToRls
:
:
DOWNLINK_DATA
:
handleDownlinkDataDelivery
(
w
->
ueId
,
w
->
psi
,
std
::
move
(
w
->
data
));
handleDownlinkDataDelivery
(
w
.
ueId
,
w
.
psi
,
std
::
move
(
w
.
data
));
break
;
case
NmGnbRlsToRls
:
:
DOWNLINK_RRC
:
handleDownlinkRrcDelivery
(
w
->
ueId
,
w
->
pduId
,
w
->
rrcChannel
,
std
::
move
(
w
->
data
));
handleDownlinkRrcDelivery
(
w
.
ueId
,
w
.
pduId
,
w
.
rrcChannel
,
std
::
move
(
w
.
data
));
break
;
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
break
;
}
case
NtsMessageType
:
:
TIMER_EXPIRED
:
{
auto
*
w
=
dynamic_cast
<
NmTimerExpired
*>
(
msg
);
if
(
w
->
timerId
==
TIMER_ID_ACK_CONTROL
)
auto
&
w
=
dynamic_cast
<
NmTimerExpired
&>
(
*
msg
);
if
(
w
.
timerId
==
TIMER_ID_ACK_CONTROL
)
{
setTimer
(
TIMER_ID_ACK_CONTROL
,
TIMER_PERIOD_ACK_CONTROL
);
onAckControlTimerExpired
();
}
else
if
(
w
->
timerId
==
TIMER_ID_ACK_SEND
)
else
if
(
w
.
timerId
==
TIMER_ID_ACK_SEND
)
{
setTimer
(
TIMER_ID_ACK_SEND
,
TIMER_PERIOD_ACK_SEND
);
onAckSendTimerExpired
();
...
...
@@ -89,11 +89,9 @@ void RlsControlTask::onLoop()
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
void
RlsControlTask
::
onQuit
()
...
...
@@ -102,16 +100,16 @@ void RlsControlTask::onQuit()
void
RlsControlTask
::
handleSignalDetected
(
int
ueId
)
{
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
SIGNAL_DETECTED
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
SIGNAL_DETECTED
);
w
->
ueId
=
ueId
;
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
}
void
RlsControlTask
::
handleSignalLost
(
int
ueId
)
{
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
SIGNAL_LOST
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
SIGNAL_LOST
);
w
->
ueId
=
ueId
;
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
}
void
RlsControlTask
::
handleRlsMessage
(
int
ueId
,
rls
::
RlsMessage
&
msg
)
...
...
@@ -130,19 +128,19 @@ void RlsControlTask::handleRlsMessage(int ueId, rls::RlsMessage &msg)
if
(
m
.
pduType
==
rls
::
EPduType
::
DATA
)
{
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
UPLINK_DATA
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
UPLINK_DATA
);
w
->
ueId
=
ueId
;
w
->
psi
=
static_cast
<
int
>
(
m
.
payload
);
w
->
data
=
std
::
move
(
m
.
pdu
);
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
}
else
if
(
m
.
pduType
==
rls
::
EPduType
::
RRC
)
{
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
UPLINK_RRC
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
UPLINK_RRC
);
w
->
ueId
=
ueId
;
w
->
rrcChannel
=
static_cast
<
rrc
::
RrcChannel
>
(
m
.
payload
);
w
->
data
=
std
::
move
(
m
.
pdu
);
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
}
else
{
...
...
@@ -169,9 +167,9 @@ void RlsControlTask::handleDownlinkRrcDelivery(int ueId, uint32_t pduId, rrc::Rr
{
m_pduMap
.
clear
();
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
RADIO_LINK_FAILURE
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
RADIO_LINK_FAILURE
);
w
->
rlfCause
=
rls
::
ERlfCause
::
PDU_ID_EXISTS
;
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
return
;
}
...
...
@@ -179,9 +177,9 @@ void RlsControlTask::handleDownlinkRrcDelivery(int ueId, uint32_t pduId, rrc::Rr
{
m_pduMap
.
clear
();
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
RADIO_LINK_FAILURE
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
RADIO_LINK_FAILURE
);
w
->
rlfCause
=
rls
::
ERlfCause
::
PDU_ID_FULL
;
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
return
;
}
...
...
@@ -234,9 +232,9 @@ void RlsControlTask::onAckControlTimerExpired()
if
(
!
transmissionFailures
.
empty
())
{
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
TRANSMISSION_FAILURE
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
TRANSMISSION_FAILURE
);
w
->
pduList
=
std
::
move
(
transmissionFailures
);
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
}
}
...
...
src/gnb/rls/task.cpp
View file @
4ec4a785
...
...
@@ -36,44 +36,44 @@ void GnbRlsTask::onStart()
void
GnbRlsTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
GNB_RLS_TO_RLS
:
{
auto
*
w
=
dynamic_cast
<
NmGnbRlsToRls
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbRlsToRls
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbRlsToRls
:
:
SIGNAL_DETECTED
:
{
auto
*
m
=
new
NmGnbRlsToRrc
(
NmGnbRlsToRrc
::
SIGNAL_DETECTED
);
m
->
ueId
=
w
->
ueId
;
m_base
->
rrcTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmGnbRlsToRrc
>
(
NmGnbRlsToRrc
::
SIGNAL_DETECTED
);
m
->
ueId
=
w
.
ueId
;
m_base
->
rrcTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmGnbRlsToRls
:
:
SIGNAL_LOST
:
{
m_logger
->
debug
(
"UE[%d] signal lost"
,
w
->
ueId
);
m_logger
->
debug
(
"UE[%d] signal lost"
,
w
.
ueId
);
break
;
}
case
NmGnbRlsToRls
:
:
UPLINK_DATA
:
{
auto
*
m
=
new
NmGnbRlsToGtp
(
NmGnbRlsToGtp
::
DATA_PDU_DELIVERY
);
m
->
ueId
=
w
->
ueId
;
m
->
psi
=
w
->
psi
;
m
->
pdu
=
std
::
move
(
w
->
data
);
m_base
->
gtpTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmGnbRlsToGtp
>
(
NmGnbRlsToGtp
::
DATA_PDU_DELIVERY
);
m
->
ueId
=
w
.
ueId
;
m
->
psi
=
w
.
psi
;
m
->
pdu
=
std
::
move
(
w
.
data
);
m_base
->
gtpTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmGnbRlsToRls
:
:
UPLINK_RRC
:
{
auto
*
m
=
new
NmGnbRlsToRrc
(
NmGnbRlsToRrc
::
UPLINK_RRC
);
m
->
ueId
=
w
->
ueId
;
m
->
rrcChannel
=
w
->
rrcChannel
;
m
->
data
=
std
::
move
(
w
->
data
);
m_base
->
rrcTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmGnbRlsToRrc
>
(
NmGnbRlsToRrc
::
UPLINK_RRC
);
m
->
ueId
=
w
.
ueId
;
m
->
rrcChannel
=
w
.
rrcChannel
;
m
->
data
=
std
::
move
(
w
.
data
);
m_base
->
rrcTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmGnbRlsToRls
:
:
RADIO_LINK_FAILURE
:
{
m_logger
->
debug
(
"radio link failure [%d]"
,
(
int
)
w
->
rlfCause
);
m_logger
->
debug
(
"radio link failure [%d]"
,
(
int
)
w
.
rlfCause
);
break
;
}
case
NmGnbRlsToRls
:
:
TRANSMISSION_FAILURE
:
{
...
...
@@ -81,49 +81,47 @@ void GnbRlsTask::onLoop()
break
;
}
default:
{
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
}
break
;
}
case
NtsMessageType
:
:
GNB_RRC_TO_RLS
:
{
auto
*
w
=
dynamic_cast
<
NmGnbRrcToRls
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbRrcToRls
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbRrcToRls
:
:
RRC_PDU_DELIVERY
:
{
auto
*
m
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
DOWNLINK_RRC
);
m
->
ueId
=
w
->
ueId
;
m
->
rrcChannel
=
w
->
channel
;
auto
m
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
DOWNLINK_RRC
);
m
->
ueId
=
w
.
ueId
;
m
->
rrcChannel
=
w
.
channel
;
m
->
pduId
=
0
;
m
->
data
=
std
::
move
(
w
->
pdu
);
m_ctlTask
->
push
(
m
);
m
->
data
=
std
::
move
(
w
.
pdu
);
m_ctlTask
->
push
(
std
::
move
(
m
)
);
break
;
}
}
break
;
}
case
NtsMessageType
:
:
GNB_GTP_TO_RLS
:
{
auto
*
w
=
dynamic_cast
<
NmGnbGtpToRls
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbGtpToRls
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbGtpToRls
:
:
DATA_PDU_DELIVERY
:
{
auto
*
m
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
DOWNLINK_DATA
);
m
->
ueId
=
w
->
ueId
;
m
->
psi
=
w
->
psi
;
m
->
data
=
std
::
move
(
w
->
pdu
);
m_ctlTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
DOWNLINK_DATA
);
m
->
ueId
=
w
.
ueId
;
m
->
psi
=
w
.
psi
;
m
->
data
=
std
::
move
(
w
.
pdu
);
m_ctlTask
->
push
(
std
::
move
(
m
)
);
break
;
}
}
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
void
GnbRlsTask
::
onQuit
()
...
...
src/gnb/rls/udp_task.cpp
View file @
4ec4a785
...
...
@@ -115,9 +115,9 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls
m_ueMap
[
ueId
].
address
=
addr
;
m_ueMap
[
ueId
].
lastSeen
=
utils
::
CurrentTimeMillis
();
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
SIGNAL_DETECTED
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
SIGNAL_DETECTED
);
w
->
ueId
=
ueId
;
m_ctlTask
->
push
(
w
);
m_ctlTask
->
push
(
std
::
move
(
w
)
);
}
rls
::
RlsHeartBeatAck
ack
{
m_sti
};
...
...
@@ -133,10 +133,10 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls
return
;
}
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
RECEIVE_RLS_MESSAGE
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
RECEIVE_RLS_MESSAGE
);
w
->
ueId
=
m_stiToUe
[
msg
->
sti
];
w
->
msg
=
std
::
move
(
msg
);
m_ctlTask
->
push
(
w
);
m_ctlTask
->
push
(
std
::
move
(
w
)
);
}
void
RlsUdpTask
::
sendRlsPdu
(
const
InetAddress
&
addr
,
const
rls
::
RlsMessage
&
msg
)
...
...
@@ -169,9 +169,9 @@ void RlsUdpTask::heartbeatCycle(int64_t time)
for
(
int
ueId
:
lostUeId
)
{
auto
*
w
=
new
NmGnbRlsToRls
(
NmGnbRlsToRls
::
SIGNAL_LOST
);
auto
w
=
std
::
make_unique
<
NmGnbRlsToRls
>
(
NmGnbRlsToRls
::
SIGNAL_LOST
);
w
->
ueId
=
ueId
;
m_ctlTask
->
push
(
w
);
m_ctlTask
->
push
(
std
::
move
(
w
)
);
}
}
...
...
src/gnb/rrc/channel.cpp
View file @
4ec4a785
...
...
@@ -74,11 +74,11 @@ void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_BCH_Message *msg)
return
;
}
auto
*
w
=
new
NmGnbRrcToRls
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmGnbRrcToRls
>
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
w
->
ueId
=
0
;
w
->
channel
=
rrc
::
RrcChannel
::
BCCH_BCH
;
w
->
pdu
=
std
::
move
(
pdu
);
m_base
->
rlsTask
->
push
(
w
);
m_base
->
rlsTask
->
push
(
std
::
move
(
w
)
);
}
void
GnbRrcTask
::
sendRrcMessage
(
ASN_RRC_BCCH_DL_SCH_Message
*
msg
)
...
...
@@ -90,11 +90,11 @@ void GnbRrcTask::sendRrcMessage(ASN_RRC_BCCH_DL_SCH_Message *msg)
return
;
}
auto
*
w
=
new
NmGnbRrcToRls
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmGnbRrcToRls
>
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
w
->
ueId
=
0
;
w
->
channel
=
rrc
::
RrcChannel
::
BCCH_DL_SCH
;
w
->
pdu
=
std
::
move
(
pdu
);
m_base
->
rlsTask
->
push
(
w
);
m_base
->
rlsTask
->
push
(
std
::
move
(
w
)
);
}
void
GnbRrcTask
::
sendRrcMessage
(
int
ueId
,
ASN_RRC_DL_CCCH_Message
*
msg
)
...
...
@@ -106,11 +106,11 @@ void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_DL_CCCH_Message *msg)
return
;
}
auto
*
w
=
new
NmGnbRrcToRls
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmGnbRrcToRls
>
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
w
->
ueId
=
ueId
;
w
->
channel
=
rrc
::
RrcChannel
::
DL_CCCH
;
w
->
pdu
=
std
::
move
(
pdu
);
m_base
->
rlsTask
->
push
(
w
);
m_base
->
rlsTask
->
push
(
std
::
move
(
w
)
);
}
void
GnbRrcTask
::
sendRrcMessage
(
int
ueId
,
ASN_RRC_DL_DCCH_Message
*
msg
)
...
...
@@ -122,11 +122,11 @@ void GnbRrcTask::sendRrcMessage(int ueId, ASN_RRC_DL_DCCH_Message *msg)
return
;
}
auto
*
w
=
new
NmGnbRrcToRls
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmGnbRrcToRls
>
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
w
->
ueId
=
ueId
;
w
->
channel
=
rrc
::
RrcChannel
::
DL_DCCH
;
w
->
pdu
=
std
::
move
(
pdu
);
m_base
->
rlsTask
->
push
(
w
);
m_base
->
rlsTask
->
push
(
std
::
move
(
w
)
);
}
void
GnbRrcTask
::
sendRrcMessage
(
ASN_RRC_PCCH_Message
*
msg
)
...
...
@@ -138,11 +138,11 @@ void GnbRrcTask::sendRrcMessage(ASN_RRC_PCCH_Message *msg)
return
;
}
auto
*
w
=
new
NmGnbRrcToRls
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmGnbRrcToRls
>
(
NmGnbRrcToRls
::
RRC_PDU_DELIVERY
);
w
->
ueId
=
0
;
w
->
channel
=
rrc
::
RrcChannel
::
PCCH
;
w
->
pdu
=
std
::
move
(
pdu
);
m_base
->
rlsTask
->
push
(
w
);
m_base
->
rlsTask
->
push
(
std
::
move
(
w
)
);
}
void
GnbRrcTask
::
receiveRrcMessage
(
int
ueId
,
ASN_RRC_BCCH_BCH_Message
*
msg
)
...
...
src/gnb/rrc/connection.cpp
View file @
4ec4a785
...
...
@@ -121,13 +121,13 @@ void GnbRrcTask::receiveRrcSetupComplete(int ueId, const ASN_RRC_RRCSetupComplet
}
}
auto
*
w
=
new
NmGnbRrcToNgap
(
NmGnbRrcToNgap
::
INITIAL_NAS_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmGnbRrcToNgap
>
(
NmGnbRrcToNgap
::
INITIAL_NAS_DELIVERY
);
w
->
ueId
=
ueId
;
w
->
pdu
=
asn
::
GetOctetString
(
setupComplete
->
dedicatedNAS_Message
);
w
->
rrcEstablishmentCause
=
ue
->
establishmentCause
;
w
->
sTmsi
=
ue
->
sTmsi
;
m_base
->
ngapTask
->
push
(
w
);
m_base
->
ngapTask
->
push
(
std
::
move
(
w
)
);
}
}
// namespace nr::gnb
src/gnb/rrc/handler.cpp
View file @
4ec4a785
...
...
@@ -59,10 +59,10 @@ void GnbRrcTask::handleDownlinkNasDelivery(int ueId, const OctetString &nasPdu)
void
GnbRrcTask
::
deliverUplinkNas
(
int
ueId
,
OctetString
&&
nasPdu
)
{
auto
*
w
=
new
NmGnbRrcToNgap
(
NmGnbRrcToNgap
::
UPLINK_NAS_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmGnbRrcToNgap
>
(
NmGnbRrcToNgap
::
UPLINK_NAS_DELIVERY
);
w
->
ueId
=
ueId
;
w
->
pdu
=
std
::
move
(
nasPdu
);
m_base
->
ngapTask
->
push
(
w
);
m_base
->
ngapTask
->
push
(
std
::
move
(
w
)
);
}
void
GnbRrcTask
::
receiveUplinkInformationTransfer
(
int
ueId
,
const
ASN_RRC_ULInformationTransfer
&
msg
)
...
...
@@ -95,9 +95,9 @@ void GnbRrcTask::releaseConnection(int ueId)
void
GnbRrcTask
::
handleRadioLinkFailure
(
int
ueId
)
{
// Notify NGAP task
auto
*
w
=
new
NmGnbRrcToNgap
(
NmGnbRrcToNgap
::
RADIO_LINK_FAILURE
);
auto
w
=
std
::
make_unique
<
NmGnbRrcToNgap
>
(
NmGnbRrcToNgap
::
RADIO_LINK_FAILURE
);
w
->
ueId
=
ueId
;
m_base
->
ngapTask
->
push
(
w
);
m_base
->
ngapTask
->
push
(
std
::
move
(
w
)
);
// Delete UE RRC context
m_ueCtx
.
erase
(
ueId
);
...
...
src/gnb/rrc/task.cpp
View file @
4ec4a785
...
...
@@ -39,19 +39,19 @@ void GnbRrcTask::onQuit()
void
GnbRrcTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
GNB_RLS_TO_RRC
:
{
handleRlsSapMessage
(
*
dynamic_cast
<
NmGnbRlsToRrc
*>
(
msg
));
handleRlsSapMessage
(
dynamic_cast
<
NmGnbRlsToRrc
&>
(
*
msg
));
break
;
}
case
NtsMessageType
:
:
GNB_NGAP_TO_RRC
:
{
auto
*
w
=
dynamic_cast
<
NmGnbNgapToRrc
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbNgapToRrc
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbNgapToRrc
:
:
RADIO_POWER_ON
:
{
m_isBarred
=
false
;
...
...
@@ -59,22 +59,22 @@ void GnbRrcTask::onLoop()
break
;
}
case
NmGnbNgapToRrc
:
:
NAS_DELIVERY
:
{
handleDownlinkNasDelivery
(
w
->
ueId
,
w
->
pdu
);
handleDownlinkNasDelivery
(
w
.
ueId
,
w
.
pdu
);
break
;
}
case
NmGnbNgapToRrc
:
:
AN_RELEASE
:
{
releaseConnection
(
w
->
ueId
);
releaseConnection
(
w
.
ueId
);
break
;
}
case
NmGnbNgapToRrc
:
:
PAGING
:
handlePaging
(
w
->
uePagingTmsi
,
w
->
taiListForPaging
);
handlePaging
(
w
.
uePagingTmsi
,
w
.
taiListForPaging
);
break
;
}
break
;
}
case
NtsMessageType
:
:
TIMER_EXPIRED
:
{
auto
*
w
=
dynamic_cast
<
NmTimerExpired
*>
(
msg
);
if
(
w
->
timerId
==
TIMER_ID_SI_BROADCAST
)
auto
w
=
dynamic_cast
<
NmTimerExpired
&>
(
*
msg
);
if
(
w
.
timerId
==
TIMER_ID_SI_BROADCAST
)
{
setTimer
(
TIMER_ID_SI_BROADCAST
,
TIMER_PERIOD_SI_BROADCAST
);
onBroadcastTimerExpired
();
...
...
@@ -82,11 +82,9 @@ void GnbRrcTask::onLoop()
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
}
// namespace nr::gnb
src/gnb/sctp/task.cpp
View file @
4ec4a785
...
...
@@ -55,19 +55,19 @@ class SctpHandler : public sctp::ISctpHandler
private:
void
onAssociationSetup
(
int
associationId
,
int
inStreams
,
int
outStreams
)
override
{
auto
*
w
=
new
NmGnbSctp
(
NmGnbSctp
::
ASSOCIATION_SETUP
);
auto
w
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
ASSOCIATION_SETUP
);
w
->
clientId
=
clientId
;
w
->
associationId
=
associationId
;
w
->
inStreams
=
inStreams
;
w
->
outStreams
=
outStreams
;
sctpTask
->
push
(
w
);
sctpTask
->
push
(
std
::
move
(
w
)
);
}
void
onAssociationShutdown
()
override
{
auto
*
w
=
new
NmGnbSctp
(
NmGnbSctp
::
ASSOCIATION_SHUTDOWN
);
auto
w
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
ASSOCIATION_SHUTDOWN
);
w
->
clientId
=
clientId
;
sctpTask
->
push
(
w
);
sctpTask
->
push
(
std
::
move
(
w
)
);
}
void
onMessage
(
const
uint8_t
*
buffer
,
size_t
length
,
uint16_t
stream
)
override
...
...
@@ -75,25 +75,25 @@ class SctpHandler : public sctp::ISctpHandler
auto
*
data
=
new
uint8_t
[
length
];
std
::
memcpy
(
data
,
buffer
,
length
);
auto
*
w
=
new
NmGnbSctp
(
NmGnbSctp
::
RECEIVE_MESSAGE
);
auto
w
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
RECEIVE_MESSAGE
);
w
->
clientId
=
clientId
;
w
->
buffer
=
UniqueBuffer
{
data
,
length
};
w
->
stream
=
stream
;
sctpTask
->
push
(
w
);
sctpTask
->
push
(
std
::
move
(
w
)
);
}
void
onUnhandledNotification
()
override
{
auto
*
w
=
new
NmGnbSctp
(
NmGnbSctp
::
UNHANDLED_NOTIFICATION
);
auto
w
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
UNHANDLED_NOTIFICATION
);
w
->
clientId
=
clientId
;
sctpTask
->
push
(
w
);
sctpTask
->
push
(
std
::
move
(
w
)
);
}
void
onConnectionReset
()
override
{
auto
*
w
=
new
NmGnbSctp
(
NmGnbSctp
::
UNHANDLED_NOTIFICATION
);
auto
w
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
UNHANDLED_NOTIFICATION
);
w
->
clientId
=
clientId
;
sctpTask
->
push
(
w
);
sctpTask
->
push
(
std
::
move
(
w
)
);
}
};
...
...
@@ -119,57 +119,55 @@ void SctpTask::onStart()
void
SctpTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
GNB_SCTP
:
{
auto
*
w
=
dynamic_cast
<
NmGnbSctp
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmGnbSctp
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmGnbSctp
:
:
CONNECTION_REQUEST
:
{
receiveSctpConnectionSetupRequest
(
w
->
clientId
,
w
->
localAddress
,
w
->
localPort
,
w
->
remoteAddress
,
w
->
remotePort
,
w
->
ppid
,
w
->
associatedTask
);
receiveSctpConnectionSetupRequest
(
w
.
clientId
,
w
.
localAddress
,
w
.
localPort
,
w
.
remoteAddress
,
w
.
remotePort
,
w
.
ppid
,
w
.
associatedTask
);
break
;
}
case
NmGnbSctp
:
:
CONNECTION_CLOSE
:
{
receiveConnectionClose
(
w
->
clientId
);
receiveConnectionClose
(
w
.
clientId
);
break
;
}
case
NmGnbSctp
:
:
ASSOCIATION_SETUP
:
{
receiveAssociationSetup
(
w
->
clientId
,
w
->
associationId
,
w
->
inStreams
,
w
->
outStreams
);
receiveAssociationSetup
(
w
.
clientId
,
w
.
associationId
,
w
.
inStreams
,
w
.
outStreams
);
break
;
}
case
NmGnbSctp
:
:
ASSOCIATION_SHUTDOWN
:
{
receiveAssociationShutdown
(
w
->
clientId
);
receiveAssociationShutdown
(
w
.
clientId
);
break
;
}
case
NmGnbSctp
:
:
RECEIVE_MESSAGE
:
{
receiveClientReceive
(
w
->
clientId
,
w
->
stream
,
std
::
move
(
w
->
buffer
));
receiveClientReceive
(
w
.
clientId
,
w
.
stream
,
std
::
move
(
w
.
buffer
));
break
;
}
case
NmGnbSctp
:
:
SEND_MESSAGE
:
{
receiveSendMessage
(
w
->
clientId
,
w
->
stream
,
std
::
move
(
w
->
buffer
));
receiveSendMessage
(
w
.
clientId
,
w
.
stream
,
std
::
move
(
w
.
buffer
));
break
;
}
case
NmGnbSctp
:
:
UNHANDLED_NOTIFICATION
:
{
receiveUnhandledNotification
(
w
->
clientId
);
receiveUnhandledNotification
(
w
.
clientId
);
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
void
SctpTask
::
onQuit
()
...
...
@@ -249,12 +247,12 @@ void SctpTask::receiveAssociationSetup(int clientId, int associationId, int inSt
}
// Notify the relevant task
auto
*
msg
=
new
NmGnbSctp
(
NmGnbSctp
::
ASSOCIATION_SETUP
);
auto
msg
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
ASSOCIATION_SETUP
);
msg
->
clientId
=
clientId
;
msg
->
associationId
=
associationId
;
msg
->
inStreams
=
inStreams
;
msg
->
outStreams
=
outStreams
;
entry
->
associatedTask
->
push
(
msg
);
entry
->
associatedTask
->
push
(
std
::
move
(
msg
)
);
}
void
SctpTask
::
receiveAssociationShutdown
(
int
clientId
)
...
...
@@ -269,9 +267,9 @@ void SctpTask::receiveAssociationShutdown(int clientId)
}
// Notify the relevant task
auto
*
msg
=
new
NmGnbSctp
(
NmGnbSctp
::
ASSOCIATION_SHUTDOWN
);
auto
msg
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
ASSOCIATION_SHUTDOWN
);
msg
->
clientId
=
clientId
;
entry
->
associatedTask
->
push
(
msg
);
entry
->
associatedTask
->
push
(
std
::
move
(
msg
)
);
}
void
SctpTask
::
receiveClientReceive
(
int
clientId
,
uint16_t
stream
,
UniqueBuffer
&&
buffer
)
...
...
@@ -284,11 +282,11 @@ void SctpTask::receiveClientReceive(int clientId, uint16_t stream, UniqueBuffer
}
// Notify the relevant task
auto
*
msg
=
new
NmGnbSctp
(
NmGnbSctp
::
RECEIVE_MESSAGE
);
auto
msg
=
std
::
make_unique
<
NmGnbSctp
>
(
NmGnbSctp
::
RECEIVE_MESSAGE
);
msg
->
clientId
=
clientId
;
msg
->
stream
=
stream
;
msg
->
buffer
=
std
::
move
(
buffer
);
entry
->
associatedTask
->
push
(
msg
);
entry
->
associatedTask
->
push
(
std
::
move
(
msg
)
);
}
void
SctpTask
::
receiveUnhandledNotification
(
int
clientId
)
...
...
src/lib/app/cli_base.hpp
View file @
4ec4a785
...
...
@@ -123,19 +123,20 @@ class CliResponseTask : public NtsTask
void
onStart
()
override
{
}
void
onLoop
()
override
{
auto
*
msg
=
take
();
auto
msg
=
take
();
if
(
msg
==
nullptr
)
return
;
if
(
msg
->
msgType
==
NtsMessageType
::
CLI_SEND_RESPONSE
)
{
auto
*
w
=
dynamic_cast
<
NwCliSendResponse
*>
(
msg
);
cliServer
->
sendMessage
(
w
->
isError
?
CliMessage
::
Error
(
w
->
address
,
w
->
output
)
:
CliMessage
::
Result
(
w
->
address
,
w
->
output
));
auto
&
w
=
dynamic_cast
<
NwCliSendResponse
&>
(
*
msg
);
cliServer
->
sendMessage
(
w
.
isError
?
CliMessage
::
Error
(
w
.
address
,
w
.
output
)
:
CliMessage
::
Result
(
w
.
address
,
w
.
output
));
}
delete
msg
;
}
void
onQuit
()
override
{
}
...
...
src/lib/rlc/test.cpp
View file @
4ec4a785
...
...
@@ -92,14 +92,13 @@ struct RlcTask : NtsTask, IRlcConsumer
void
onLoop
()
override
{
NtsMessage
*
msg
=
poll
();
auto
msg
=
poll
();
if
(
msg
)
{
if
(
msg
->
msgType
==
NtsMessageType
::
RESERVED_END
)
{
auto
w
=
((
NwRadioUplink
*
)
msg
);
m_pEntity
->
receivePdu
(
w
->
data
,
w
->
size
);
delete
w
;
auto
w
=
((
NwRadioUplink
&
)
*
msg
);
m_pEntity
->
receivePdu
(
w
.
data
,
w
.
size
);
}
}
...
...
@@ -111,10 +110,10 @@ struct RlcTask : NtsTask, IRlcConsumer
auto
written
=
m_pEntity
->
createPdu
(
buffer
,
opSize
);
if
(
written
)
{
auto
uplink
=
new
NwRadioUplink
();
auto
uplink
=
std
::
make_unique
<
NwRadioUplink
>
();
uplink
->
size
=
written
;
uplink
->
data
=
buffer
;
pair
->
push
(
uplink
);
pair
->
push
(
std
::
move
(
uplink
)
);
}
if
(
continueTesting
)
...
...
src/lib/udp/server_task.cpp
View file @
4ec4a785
...
...
@@ -41,7 +41,7 @@ void udp::UdpServerTask::onLoop()
{
std
::
vector
<
uint8_t
>
v
(
size
);
std
::
memcpy
(
v
.
data
(),
buffer
,
size
);
targetTask
->
push
(
new
NwUdpServerReceive
(
OctetString
{
std
::
move
(
v
)},
peerAddress
));
targetTask
->
push
(
std
::
make_unique
<
NwUdpServerReceive
>
(
OctetString
{
std
::
move
(
v
)},
peerAddress
));
}
}
...
...
src/ue.cpp
View file @
4ec4a785
...
...
@@ -62,18 +62,18 @@ class UeControllerTask : public NtsTask
void
onLoop
()
override
{
auto
*
msg
=
take
();
auto
msg
=
take
();
if
(
msg
==
nullptr
)
return
;
if
(
msg
->
msgType
==
NtsMessageType
::
UE_CTL_COMMAND
)
{
auto
*
w
=
dynamic_cast
<
NwUeControllerCmd
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NwUeControllerCmd
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NwUeControllerCmd
:
:
PERFORM_SWITCH_OFF
:
{
std
::
string
key
{};
g_ueMap
.
invokeForeach
([
&
key
,
&
w
](
auto
&
item
)
{
if
(
item
.
second
==
w
->
ue
)
if
(
item
.
second
==
w
.
ue
)
key
=
item
.
first
;
});
...
...
@@ -83,7 +83,7 @@ class UeControllerTask : public NtsTask
if
(
g_ueMap
.
removeAndGetSize
(
key
)
==
0
)
exit
(
0
);
delete
w
->
ue
;
delete
w
.
ue
;
break
;
}
}
...
...
@@ -446,9 +446,9 @@ static class UeController : public app::IUeController
public:
void
performSwitchOff
(
nr
::
ue
::
UserEquipment
*
ue
)
override
{
auto
*
w
=
new
NwUeControllerCmd
(
NwUeControllerCmd
::
PERFORM_SWITCH_OFF
);
auto
w
=
std
::
make_unique
<
NwUeControllerCmd
>
(
NwUeControllerCmd
::
PERFORM_SWITCH_OFF
);
w
->
ue
=
ue
;
g_controllerTask
->
push
(
w
);
g_controllerTask
->
push
(
std
::
move
(
w
)
);
}
}
g_ueController
;
...
...
src/ue/app/cmd_handler.cpp
View file @
4ec4a785
...
...
@@ -36,12 +36,12 @@ namespace nr::ue
void
UeCmdHandler
::
sendResult
(
const
InetAddress
&
address
,
const
std
::
string
&
output
)
{
m_base
->
cliCallbackTask
->
push
(
new
app
::
NwCliSendResponse
(
address
,
output
,
false
));
m_base
->
cliCallbackTask
->
push
(
std
::
make_unique
<
app
::
NwCliSendResponse
>
(
address
,
output
,
false
));
}
void
UeCmdHandler
::
sendError
(
const
InetAddress
&
address
,
const
std
::
string
&
output
)
{
m_base
->
cliCallbackTask
->
push
(
new
app
::
NwCliSendResponse
(
address
,
output
,
true
));
m_base
->
cliCallbackTask
->
push
(
std
::
make_unique
<
app
::
NwCliSendResponse
>
(
address
,
output
,
true
));
}
void
UeCmdHandler
::
pauseTasks
()
...
...
src/ue/app/task.cpp
View file @
4ec4a785
...
...
@@ -45,46 +45,46 @@ void UeAppTask::onQuit()
void
UeAppTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
UE_TUN_TO_APP
:
{
auto
*
w
=
dynamic_cast
<
NmUeTunToApp
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeTunToApp
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeTunToApp
:
:
DATA_PDU_DELIVERY
:
{
auto
*
m
=
new
NmUeAppToNas
(
NmUeAppToNas
::
UPLINK_DATA_DELIVERY
);
m
->
psi
=
w
->
psi
;
m
->
data
=
std
::
move
(
w
->
data
);
m_base
->
nasTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmUeAppToNas
>
(
NmUeAppToNas
::
UPLINK_DATA_DELIVERY
);
m
->
psi
=
w
.
psi
;
m
->
data
=
std
::
move
(
w
.
data
);
m_base
->
nasTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmUeTunToApp
:
:
TUN_ERROR
:
{
m_logger
->
err
(
"TUN failure [%s]"
,
w
->
error
.
c_str
());
m_logger
->
err
(
"TUN failure [%s]"
,
w
.
error
.
c_str
());
break
;
}
}
break
;
}
case
NtsMessageType
:
:
UE_NAS_TO_APP
:
{
auto
*
w
=
dynamic_cast
<
NmUeNasToApp
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeNasToApp
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeNasToApp
:
:
PERFORM_SWITCH_OFF
:
{
setTimer
(
SWITCH_OFF_TIMER_ID
,
SWITCH_OFF_DELAY
);
break
;
}
case
NmUeNasToApp
:
:
DOWNLINK_DATA_DELIVERY
:
{
auto
*
tunTask
=
m_tunTasks
[
w
->
psi
];
auto
*
tunTask
=
m_tunTasks
[
w
.
psi
];
if
(
tunTask
)
{
auto
*
m
=
new
NmAppToTun
(
NmAppToTun
::
DATA_PDU_DELIVERY
);
m
->
psi
=
w
->
psi
;
m
->
data
=
std
::
move
(
w
->
data
);
tunTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmAppToTun
>
(
NmAppToTun
::
DATA_PDU_DELIVERY
);
m
->
psi
=
w
.
psi
;
m
->
data
=
std
::
move
(
w
.
data
);
tunTask
->
push
(
std
::
move
(
m
)
);
}
break
;
}
...
...
@@ -92,18 +92,18 @@ void UeAppTask::onLoop()
break
;
}
case
NtsMessageType
:
:
UE_STATUS_UPDATE
:
{
receiveStatusUpdate
(
*
dynamic_cast
<
NmUeStatusUpdate
*>
(
msg
));
receiveStatusUpdate
(
dynamic_cast
<
NmUeStatusUpdate
&>
(
*
msg
));
break
;
}
case
NtsMessageType
:
:
UE_CLI_COMMAND
:
{
auto
*
w
=
dynamic_cast
<
NmUeCliCommand
*>
(
msg
);
auto
&
w
=
dynamic_cast
<
NmUeCliCommand
&>
(
*
msg
);
UeCmdHandler
handler
{
m_base
};
handler
.
handleCmd
(
*
w
);
handler
.
handleCmd
(
w
);
break
;
}
case
NtsMessageType
:
:
TIMER_EXPIRED
:
{
auto
*
w
=
dynamic_cast
<
NmTimerExpired
*>
(
msg
);
if
(
w
->
timerId
==
SWITCH_OFF_TIMER_ID
)
auto
&
w
=
dynamic_cast
<
NmTimerExpired
&>
(
*
msg
);
if
(
w
.
timerId
==
SWITCH_OFF_TIMER_ID
)
{
m_logger
->
info
(
"UE device is switching off"
);
m_base
->
ueController
->
performSwitchOff
(
m_base
->
ue
);
...
...
@@ -111,10 +111,9 @@ void UeAppTask::onLoop()
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
void
UeAppTask
::
receiveStatusUpdate
(
NmUeStatusUpdate
&
msg
)
...
...
src/ue/nas/mm/access.cpp
View file @
4ec4a785
...
...
@@ -267,9 +267,9 @@ EUacResult NasMm::performUac()
auto
uacCtl
=
LightSync
<
UacInput
,
UacOutput
>::
MakeShared
(
100
,
0
,
std
::
move
(
uacInput
));
auto
*
w
=
new
NmUeNasToRrc
(
NmUeNasToRrc
::
PERFORM_UAC
);
auto
w
=
std
::
make_unique
<
NmUeNasToRrc
>
(
NmUeNasToRrc
::
PERFORM_UAC
);
w
->
uacCtl
=
uacCtl
;
m_base
->
rrcTask
->
push
(
w
);
m_base
->
rrcTask
->
push
(
std
::
move
(
w
)
);
auto
uacOutput
=
uacCtl
->
waitForProcess
();
...
...
src/ue/nas/mm/base.cpp
View file @
4ec4a785
...
...
@@ -81,7 +81,7 @@ void NasMm::onQuit()
void
NasMm
::
triggerMmCycle
()
{
m_base
->
nasTask
->
push
(
new
NmUeNasToNas
(
NmUeNasToNas
::
PERFORM_MM_CYCLE
));
m_base
->
nasTask
->
push
(
std
::
make_unique
<
NmUeNasToNas
>
(
NmUeNasToNas
::
PERFORM_MM_CYCLE
));
}
void
NasMm
::
performMmCycle
()
...
...
@@ -267,9 +267,9 @@ void NasMm::switchCmState(ECmState state)
onSwitchCmState
(
oldState
,
m_cmState
);
auto
*
statusUpdate
=
new
NmUeStatusUpdate
(
NmUeStatusUpdate
::
CM_STATE
);
auto
statusUpdate
=
std
::
make_unique
<
NmUeStatusUpdate
>
(
NmUeStatusUpdate
::
CM_STATE
);
statusUpdate
->
cmState
=
m_cmState
;
m_base
->
appTask
->
push
(
st
atusUpdate
);
m_base
->
appTask
->
push
(
st
d
::
move
(
statusUpdate
)
);
if
(
m_base
->
nodeListener
)
{
...
...
src/ue/nas/mm/dereg.cpp
View file @
4ec4a785
...
...
@@ -104,7 +104,7 @@ EProcRc NasMm::sendDeregistration(EDeregCause deregCause)
if
(
deregCause
==
EDeregCause
::
SWITCH_OFF
)
{
onSwitchOff
();
m_base
->
appTask
->
push
(
new
NmUeNasToApp
(
NmUeNasToApp
::
PERFORM_SWITCH_OFF
));
m_base
->
appTask
->
push
(
std
::
make_unique
<
NmUeNasToApp
>
(
NmUeNasToApp
::
PERFORM_SWITCH_OFF
));
}
else
if
(
deregCause
==
EDeregCause
::
USIM_REMOVAL
)
{
...
...
src/ue/nas/mm/messaging.cpp
View file @
4ec4a785
...
...
@@ -182,10 +182,10 @@ EProcRc NasMm::sendNasMessage(const nas::PlainMmMessage &msg)
}
}
auto
*
m
=
new
NmUeNasToRrc
(
NmUeNasToRrc
::
UPLINK_NAS_DELIVERY
);
auto
m
=
std
::
make_unique
<
NmUeNasToRrc
>
(
NmUeNasToRrc
::
UPLINK_NAS_DELIVERY
);
m
->
pduId
=
0
;
m
->
nasPdu
=
std
::
move
(
pdu
);
m_base
->
rrcTask
->
push
(
m
);
m_base
->
rrcTask
->
push
(
std
::
move
(
m
)
);
return
EProcRc
::
OK
;
}
...
...
src/ue/nas/mm/radio.cpp
View file @
4ec4a785
...
...
@@ -106,7 +106,7 @@ void NasMm::performPlmnSelection()
else
if
(
lastSelectedPlmn
!=
selected
)
{
m_logger
->
info
(
"Selected plmn[%s]"
,
ToJson
(
selected
).
str
().
c_str
());
m_base
->
rrcTask
->
push
(
new
NmUeNasToRrc
(
NmUeNasToRrc
::
RRC_NOTIFY
));
m_base
->
rrcTask
->
push
(
std
::
make_unique
<
NmUeNasToRrc
>
(
NmUeNasToRrc
::
RRC_NOTIFY
));
resetRegAttemptCounter
();
}
...
...
@@ -273,9 +273,9 @@ void NasMm::localReleaseConnection(bool treatBarred)
if
(
m_cmState
!=
ECmState
::
CM_IDLE
)
m_logger
->
info
(
"Performing local release of NAS connection"
);
auto
*
w
=
new
NmUeNasToRrc
(
NmUeNasToRrc
::
LOCAL_RELEASE_CONNECTION
);
auto
w
=
std
::
make_unique
<
NmUeNasToRrc
>
(
NmUeNasToRrc
::
LOCAL_RELEASE_CONNECTION
);
w
->
treatBarred
=
treatBarred
;
m_base
->
rrcTask
->
push
(
w
);
m_base
->
rrcTask
->
push
(
std
::
move
(
w
)
);
}
void
NasMm
::
handlePaging
(
const
std
::
vector
<
GutiMobileIdentity
>
&
tmsiIds
)
...
...
src/ue/nas/sm/establishment.cpp
View file @
4ec4a785
...
...
@@ -170,9 +170,9 @@ void NasSm::receiveEstablishmentAccept(const nas::PduSessionEstablishmentAccept
else
pduSession
->
pduAddress
=
{};
auto
*
statusUpdate
=
new
NmUeStatusUpdate
(
NmUeStatusUpdate
::
SESSION_ESTABLISHMENT
);
auto
statusUpdate
=
std
::
make_unique
<
NmUeStatusUpdate
>
(
NmUeStatusUpdate
::
SESSION_ESTABLISHMENT
);
statusUpdate
->
pduSession
=
pduSession
;
m_base
->
appTask
->
push
(
st
atusUpdate
);
m_base
->
appTask
->
push
(
st
d
::
move
(
statusUpdate
)
);
m_logger
->
info
(
"PDU Session establishment is successful PSI[%d]"
,
pduSession
->
psi
);
}
...
...
src/ue/nas/sm/resource.cpp
View file @
4ec4a785
...
...
@@ -39,9 +39,9 @@ void NasSm::localReleaseSession(int psi)
if
(
isEstablished
)
{
auto
*
statusUpdate
=
new
NmUeStatusUpdate
(
NmUeStatusUpdate
::
SESSION_RELEASE
);
auto
statusUpdate
=
std
::
make_unique
<
NmUeStatusUpdate
>
(
NmUeStatusUpdate
::
SESSION_RELEASE
);
statusUpdate
->
psi
=
psi
;
m_base
->
appTask
->
push
(
st
atusUpdate
);
m_base
->
appTask
->
push
(
st
d
::
move
(
statusUpdate
)
);
}
}
...
...
src/ue/nas/sm/sap.cpp
View file @
4ec4a785
...
...
@@ -70,10 +70,10 @@ void NasSm::handleUplinkDataRequest(int psi, OctetString &&data)
handleUplinkStatusChange
(
psi
,
false
);
}
auto
*
m
=
new
NmUeNasToRls
(
NmUeNasToRls
::
DATA_PDU_DELIVERY
);
auto
m
=
std
::
make_unique
<
NmUeNasToRls
>
(
NmUeNasToRls
::
DATA_PDU_DELIVERY
);
m
->
psi
=
psi
;
m
->
pdu
=
std
::
move
(
data
);
m_base
->
rlsTask
->
push
(
m
);
m_base
->
rlsTask
->
push
(
std
::
move
(
m
)
);
}
else
{
...
...
@@ -97,11 +97,11 @@ void NasSm::handleDownlinkDataRequest(int psi, OctetString &&data)
state
!=
EMmSubState
::
MM_SERVICE_REQUEST_INITIATED_PS
)
return
;
auto
*
w
=
new
NmUeNasToApp
(
NmUeNasToApp
::
DOWNLINK_DATA_DELIVERY
);
auto
w
=
std
::
make_unique
<
NmUeNasToApp
>
(
NmUeNasToApp
::
DOWNLINK_DATA_DELIVERY
);
w
->
psi
=
psi
;
w
->
data
=
std
::
move
(
data
);
m_base
->
appTask
->
push
(
w
);
m_base
->
appTask
->
push
(
std
::
move
(
w
)
);
}
}
// namespace nr::ue
src/ue/nas/task.cpp
View file @
4ec4a785
...
...
@@ -50,29 +50,29 @@ void NasTask::onQuit()
void
NasTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
UE_RRC_TO_NAS
:
{
mm
->
handleRrcEvent
(
*
dynamic_cast
<
NmUeRrcToNas
*>
(
msg
));
mm
->
handleRrcEvent
(
dynamic_cast
<
NmUeRrcToNas
&>
(
*
msg
));
break
;
}
case
NtsMessageType
:
:
UE_NAS_TO_NAS
:
{
auto
*
w
=
dynamic_cast
<
NmUeNasToNas
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeNasToNas
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeNasToNas
:
:
PERFORM_MM_CYCLE
:
{
mm
->
handleNasEvent
(
*
w
);
mm
->
handleNasEvent
(
w
);
break
;
}
case
NmUeNasToNas
:
:
NAS_TIMER_EXPIRE
:
{
if
(
w
->
timer
->
isMmTimer
())
mm
->
handleNasEvent
(
*
w
);
if
(
w
.
timer
->
isMmTimer
())
mm
->
handleNasEvent
(
w
);
else
sm
->
handleNasEvent
(
*
w
);
sm
->
handleNasEvent
(
w
);
break
;
}
default:
...
...
@@ -81,11 +81,11 @@ void NasTask::onLoop()
break
;
}
case
NtsMessageType
:
:
UE_APP_TO_NAS
:
{
auto
*
w
=
dynamic_cast
<
NmUeAppToNas
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeAppToNas
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeAppToNas
:
:
UPLINK_DATA_DELIVERY
:
{
sm
->
handleUplinkDataRequest
(
w
->
psi
,
std
::
move
(
w
->
data
));
sm
->
handleUplinkDataRequest
(
w
.
psi
,
std
::
move
(
w
.
data
));
break
;
}
default:
...
...
@@ -94,11 +94,11 @@ void NasTask::onLoop()
break
;
}
case
NtsMessageType
:
:
UE_RLS_TO_NAS
:
{
auto
*
w
=
dynamic_cast
<
NmUeRlsToNas
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeRlsToNas
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeRlsToNas
:
:
DATA_PDU_DELIVERY
:
{
sm
->
handleDownlinkDataRequest
(
w
->
psi
,
std
::
move
(
w
->
pdu
));
sm
->
handleDownlinkDataRequest
(
w
.
psi
,
std
::
move
(
w
.
pdu
));
break
;
}
}
...
...
@@ -106,8 +106,8 @@ void NasTask::onLoop()
break
;
}
case
NtsMessageType
:
:
TIMER_EXPIRED
:
{
auto
*
w
=
dynamic_cast
<
NmTimerExpired
*>
(
msg
);
int
timerId
=
w
->
timerId
;
auto
&
w
=
dynamic_cast
<
NmTimerExpired
&>
(
*
msg
);
int
timerId
=
w
.
timerId
;
if
(
timerId
==
NTS_TIMER_ID_NAS_TIMER_CYCLE
)
{
setTimer
(
NTS_TIMER_ID_NAS_TIMER_CYCLE
,
NTS_TIMER_INTERVAL_NAS_TIMER_CYCLE
);
...
...
@@ -121,19 +121,17 @@ void NasTask::onLoop()
break
;
}
default:
logger
->
unhandledNts
(
msg
);
logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
void
NasTask
::
performTick
()
{
auto
sendExpireMsg
=
[
this
](
UeTimer
*
timer
)
{
auto
*
m
=
new
NmUeNasToNas
(
NmUeNasToNas
::
NAS_TIMER_EXPIRE
);
auto
m
=
std
::
make_unique
<
NmUeNasToNas
>
(
NmUeNasToNas
::
NAS_TIMER_EXPIRE
);
m
->
timer
=
timer
;
push
(
m
);
push
(
std
::
move
(
m
)
);
};
if
(
timers
.
t3346
.
performTick
())
...
...
src/ue/rls/ctl_task.cpp
View file @
4ec4a785
...
...
@@ -42,45 +42,45 @@ void RlsControlTask::onStart()
void
RlsControlTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
UE_RLS_TO_RLS
:
{
auto
*
w
=
dynamic_cast
<
NmUeRlsToRls
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeRlsToRls
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeRlsToRls
:
:
SIGNAL_CHANGED
:
handleSignalChange
(
w
->
cellId
,
w
->
dbm
);
handleSignalChange
(
w
.
cellId
,
w
.
dbm
);
break
;
case
NmUeRlsToRls
:
:
RECEIVE_RLS_MESSAGE
:
handleRlsMessage
(
w
->
cellId
,
*
w
->
msg
);
handleRlsMessage
(
w
.
cellId
,
*
w
.
msg
);
break
;
case
NmUeRlsToRls
:
:
UPLINK_DATA
:
handleUplinkDataDelivery
(
w
->
psi
,
std
::
move
(
w
->
data
));
handleUplinkDataDelivery
(
w
.
psi
,
std
::
move
(
w
.
data
));
break
;
case
NmUeRlsToRls
:
:
UPLINK_RRC
:
handleUplinkRrcDelivery
(
w
->
cellId
,
w
->
pduId
,
w
->
rrcChannel
,
std
::
move
(
w
->
data
));
handleUplinkRrcDelivery
(
w
.
cellId
,
w
.
pduId
,
w
.
rrcChannel
,
std
::
move
(
w
.
data
));
break
;
case
NmUeRlsToRls
:
:
ASSIGN_CURRENT_CELL
:
m_servingCell
=
w
->
cellId
;
m_servingCell
=
w
.
cellId
;
break
;
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
break
;
}
case
NtsMessageType
:
:
TIMER_EXPIRED
:
{
auto
*
w
=
dynamic_cast
<
NmTimerExpired
*>
(
msg
);
if
(
w
->
timerId
==
TIMER_ID_ACK_CONTROL
)
auto
&
w
=
dynamic_cast
<
NmTimerExpired
&>
(
*
msg
);
if
(
w
.
timerId
==
TIMER_ID_ACK_CONTROL
)
{
setTimer
(
TIMER_ID_ACK_CONTROL
,
TIMER_PERIOD_ACK_CONTROL
);
onAckControlTimerExpired
();
}
else
if
(
w
->
timerId
==
TIMER_ID_ACK_SEND
)
else
if
(
w
.
timerId
==
TIMER_ID_ACK_SEND
)
{
setTimer
(
TIMER_ID_ACK_SEND
,
TIMER_PERIOD_ACK_SEND
);
onAckSendTimerExpired
();
...
...
@@ -88,11 +88,9 @@ void RlsControlTask::onLoop()
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
void
RlsControlTask
::
onQuit
()
...
...
@@ -122,18 +120,18 @@ void RlsControlTask::handleRlsMessage(int cellId, rls::RlsMessage &msg)
return
;
}
auto
*
w
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
DOWNLINK_DATA
);
auto
w
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
DOWNLINK_DATA
);
w
->
psi
=
static_cast
<
int
>
(
m
.
payload
);
w
->
data
=
std
::
move
(
m
.
pdu
);
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
}
else
if
(
m
.
pduType
==
rls
::
EPduType
::
RRC
)
{
auto
*
w
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
DOWNLINK_RRC
);
auto
w
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
DOWNLINK_RRC
);
w
->
cellId
=
cellId
;
w
->
rrcChannel
=
static_cast
<
rrc
::
RrcChannel
>
(
m
.
payload
);
w
->
data
=
std
::
move
(
m
.
pdu
);
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
}
else
{
...
...
@@ -148,10 +146,10 @@ void RlsControlTask::handleRlsMessage(int cellId, rls::RlsMessage &msg)
void
RlsControlTask
::
handleSignalChange
(
int
cellId
,
int
dbm
)
{
auto
*
w
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
SIGNAL_CHANGED
);
auto
w
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
SIGNAL_CHANGED
);
w
->
cellId
=
cellId
;
w
->
dbm
=
dbm
;
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
}
void
RlsControlTask
::
handleUplinkRrcDelivery
(
int
cellId
,
uint32_t
pduId
,
rrc
::
RrcChannel
channel
,
OctetString
&&
data
)
...
...
@@ -162,9 +160,9 @@ void RlsControlTask::handleUplinkRrcDelivery(int cellId, uint32_t pduId, rrc::Rr
{
m_pduMap
.
clear
();
auto
*
w
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
RADIO_LINK_FAILURE
);
auto
w
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
RADIO_LINK_FAILURE
);
w
->
rlfCause
=
rls
::
ERlfCause
::
PDU_ID_EXISTS
;
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
return
;
}
...
...
@@ -172,9 +170,9 @@ void RlsControlTask::handleUplinkRrcDelivery(int cellId, uint32_t pduId, rrc::Rr
{
m_pduMap
.
clear
();
auto
*
w
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
RADIO_LINK_FAILURE
);
auto
w
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
RADIO_LINK_FAILURE
);
w
->
rlfCause
=
rls
::
ERlfCause
::
PDU_ID_FULL
;
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
return
;
}
...
...
@@ -227,9 +225,9 @@ void RlsControlTask::onAckControlTimerExpired()
if
(
!
transmissionFailures
.
empty
())
{
auto
*
w
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
TRANSMISSION_FAILURE
);
auto
w
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
TRANSMISSION_FAILURE
);
w
->
pduList
=
std
::
move
(
transmissionFailures
);
m_mainTask
->
push
(
w
);
m_mainTask
->
push
(
std
::
move
(
w
)
);
}
}
...
...
src/ue/rls/task.cpp
View file @
4ec4a785
...
...
@@ -12,7 +12,6 @@
#include <ue/nas/task.hpp>
#include <ue/rrc/task.hpp>
#include <utils/common.hpp>
#include <utils/constants.hpp>
#include <utils/random.hpp>
namespace
nr
::
ue
...
...
@@ -40,72 +39,72 @@ void UeRlsTask::onStart()
void
UeRlsTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
UE_RLS_TO_RLS
:
{
auto
*
w
=
dynamic_cast
<
NmUeRlsToRls
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeRlsToRls
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeRlsToRls
:
:
SIGNAL_CHANGED
:
{
auto
*
m
=
new
NmUeRlsToRrc
(
NmUeRlsToRrc
::
SIGNAL_CHANGED
);
m
->
cellId
=
w
->
cellId
;
m
->
dbm
=
w
->
dbm
;
m_base
->
rrcTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmUeRlsToRrc
>
(
NmUeRlsToRrc
::
SIGNAL_CHANGED
);
m
->
cellId
=
w
.
cellId
;
m
->
dbm
=
w
.
dbm
;
m_base
->
rrcTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmUeRlsToRls
:
:
DOWNLINK_DATA
:
{
auto
*
m
=
new
NmUeRlsToNas
(
NmUeRlsToNas
::
DATA_PDU_DELIVERY
);
m
->
psi
=
w
->
psi
;
m
->
pdu
=
std
::
move
(
w
->
data
);
m_base
->
nasTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmUeRlsToNas
>
(
NmUeRlsToNas
::
DATA_PDU_DELIVERY
);
m
->
psi
=
w
.
psi
;
m
->
pdu
=
std
::
move
(
w
.
data
);
m_base
->
nasTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmUeRlsToRls
:
:
DOWNLINK_RRC
:
{
auto
*
m
=
new
NmUeRlsToRrc
(
NmUeRlsToRrc
::
DOWNLINK_RRC_DELIVERY
);
m
->
cellId
=
w
->
cellId
;
m
->
channel
=
w
->
rrcChannel
;
m
->
pdu
=
std
::
move
(
w
->
data
);
m_base
->
rrcTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmUeRlsToRrc
>
(
NmUeRlsToRrc
::
DOWNLINK_RRC_DELIVERY
);
m
->
cellId
=
w
.
cellId
;
m
->
channel
=
w
.
rrcChannel
;
m
->
pdu
=
std
::
move
(
w
.
data
);
m_base
->
rrcTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmUeRlsToRls
:
:
RADIO_LINK_FAILURE
:
{
auto
*
m
=
new
NmUeRlsToRrc
(
NmUeRlsToRrc
::
RADIO_LINK_FAILURE
);
m
->
rlfCause
=
w
->
rlfCause
;
m_base
->
rrcTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmUeRlsToRrc
>
(
NmUeRlsToRrc
::
RADIO_LINK_FAILURE
);
m
->
rlfCause
=
w
.
rlfCause
;
m_base
->
rrcTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmUeRlsToRls
:
:
TRANSMISSION_FAILURE
:
{
m_logger
->
debug
(
"transmission failure [%d]"
,
w
->
pduList
.
size
());
m_logger
->
debug
(
"transmission failure [%d]"
,
w
.
pduList
.
size
());
break
;
}
default:
{
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
}
break
;
}
case
NtsMessageType
:
:
UE_RRC_TO_RLS
:
{
auto
*
w
=
dynamic_cast
<
NmUeRrcToRls
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeRrcToRls
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeRrcToRls
:
:
ASSIGN_CURRENT_CELL
:
{
auto
*
m
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
ASSIGN_CURRENT_CELL
);
m
->
cellId
=
w
->
cellId
;
m_ctlTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
ASSIGN_CURRENT_CELL
);
m
->
cellId
=
w
.
cellId
;
m_ctlTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmUeRrcToRls
:
:
RRC_PDU_DELIVERY
:
{
auto
*
m
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
UPLINK_RRC
);
m
->
cellId
=
w
->
cellId
;
m
->
rrcChannel
=
w
->
channel
;
m
->
pduId
=
w
->
pduId
;
m
->
data
=
std
::
move
(
w
->
pdu
);
m_ctlTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
UPLINK_RRC
);
m
->
cellId
=
w
.
cellId
;
m
->
rrcChannel
=
w
.
channel
;
m
->
pduId
=
w
.
pduId
;
m
->
data
=
std
::
move
(
w
.
pdu
);
m_ctlTask
->
push
(
std
::
move
(
m
)
);
break
;
}
case
NmUeRrcToRls
:
:
RESET_STI
:
{
...
...
@@ -116,25 +115,23 @@ void UeRlsTask::onLoop()
break
;
}
case
NtsMessageType
:
:
UE_NAS_TO_RLS
:
{
auto
*
w
=
dynamic_cast
<
NmUeNasToRls
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeNasToRls
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeNasToRls
:
:
DATA_PDU_DELIVERY
:
{
auto
*
m
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
UPLINK_DATA
);
m
->
psi
=
w
->
psi
;
m
->
data
=
std
::
move
(
w
->
pdu
);
m_ctlTask
->
push
(
m
);
auto
m
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
UPLINK_DATA
);
m
->
psi
=
w
.
psi
;
m
->
data
=
std
::
move
(
w
.
pdu
);
m_ctlTask
->
push
(
std
::
move
(
m
)
);
break
;
}
}
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
void
UeRlsTask
::
onQuit
()
...
...
src/ue/rls/udp_task.cpp
View file @
4ec4a785
...
...
@@ -118,10 +118,10 @@ void RlsUdpTask::receiveRlsPdu(const InetAddress &addr, std::unique_ptr<rls::Rls
return
;
}
auto
*
w
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
RECEIVE_RLS_MESSAGE
);
auto
w
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
RECEIVE_RLS_MESSAGE
);
w
->
cellId
=
m_cells
[
msg
->
sti
].
cellId
;
w
->
msg
=
std
::
move
(
msg
);
m_ctlTask
->
push
(
w
);
m_ctlTask
->
push
(
std
::
move
(
w
)
);
}
void
RlsUdpTask
::
onSignalChangeOrLost
(
int
cellId
)
...
...
@@ -133,10 +133,10 @@ void RlsUdpTask::onSignalChangeOrLost(int cellId)
dbm
=
m_cells
[
sti
].
dbm
;
}
auto
*
w
=
new
NmUeRlsToRls
(
NmUeRlsToRls
::
SIGNAL_CHANGED
);
auto
w
=
std
::
make_unique
<
NmUeRlsToRls
>
(
NmUeRlsToRls
::
SIGNAL_CHANGED
);
w
->
cellId
=
cellId
;
w
->
dbm
=
dbm
;
m_ctlTask
->
push
(
w
);
m_ctlTask
->
push
(
std
::
move
(
w
)
);
}
void
RlsUdpTask
::
heartbeatCycle
(
uint64_t
time
,
const
Vector3
&
simPos
)
...
...
src/ue/rrc/cells.cpp
View file @
4ec4a785
...
...
@@ -70,9 +70,9 @@ void UeRrcTask::notifyCellLost(int cellId)
declareRadioLinkFailure
(
rls
::
ERlfCause
::
SIGNAL_LOST_TO_CONNECTED_CELL
);
else
{
auto
w
2
=
new
NmUeRrcToNas
(
NmUeRrcToNas
::
ACTIVE_CELL_CHANGED
);
w
2
->
previousTai
=
Tai
{
lastActiveCell
.
plmn
,
lastActiveCell
.
tac
};
m_base
->
nasTask
->
push
(
w2
);
auto
w
=
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
ACTIVE_CELL_CHANGED
);
w
->
previousTai
=
Tai
{
lastActiveCell
.
plmn
,
lastActiveCell
.
tac
};
m_base
->
nasTask
->
push
(
std
::
move
(
w
)
);
}
}
...
...
@@ -98,7 +98,7 @@ void UeRrcTask::updateAvailablePlmns()
value
.
insert
(
cellDesc
.
second
.
sib1
.
plmn
);
});
m_base
->
nasTask
->
push
(
new
NmUeRrcToNas
(
NmUeRrcToNas
::
NAS_NOTIFY
));
m_base
->
nasTask
->
push
(
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
NAS_NOTIFY
));
}
}
// namespace nr::ue
src/ue/rrc/channel.cpp
View file @
4ec4a785
...
...
@@ -93,11 +93,11 @@ void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg)
return
;
}
auto
*
m
=
new
NmUeRrcToRls
(
NmUeRrcToRls
::
RRC_PDU_DELIVERY
);
auto
m
=
std
::
make_unique
<
NmUeRrcToRls
>
(
NmUeRrcToRls
::
RRC_PDU_DELIVERY
);
m
->
cellId
=
cellId
;
m
->
channel
=
rrc
::
RrcChannel
::
UL_CCCH
;
m
->
pdu
=
std
::
move
(
pdu
);
m_base
->
rlsTask
->
push
(
m
);
m_base
->
rlsTask
->
push
(
std
::
move
(
m
)
);
}
void
UeRrcTask
::
sendRrcMessage
(
int
cellId
,
ASN_RRC_UL_CCCH1_Message
*
msg
)
...
...
@@ -109,11 +109,11 @@ void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg)
return
;
}
auto
*
m
=
new
NmUeRrcToRls
(
NmUeRrcToRls
::
RRC_PDU_DELIVERY
);
auto
m
=
std
::
make_unique
<
NmUeRrcToRls
>
(
NmUeRrcToRls
::
RRC_PDU_DELIVERY
);
m
->
cellId
=
cellId
;
m
->
channel
=
rrc
::
RrcChannel
::
UL_CCCH1
;
m
->
pdu
=
std
::
move
(
pdu
);
m_base
->
rlsTask
->
push
(
m
);
m_base
->
rlsTask
->
push
(
std
::
move
(
m
)
);
}
void
UeRrcTask
::
sendRrcMessage
(
ASN_RRC_UL_DCCH_Message
*
msg
)
...
...
@@ -125,11 +125,11 @@ void UeRrcTask::sendRrcMessage(ASN_RRC_UL_DCCH_Message *msg)
return
;
}
auto
*
m
=
new
NmUeRrcToRls
(
NmUeRrcToRls
::
RRC_PDU_DELIVERY
);
auto
m
=
std
::
make_unique
<
NmUeRrcToRls
>
(
NmUeRrcToRls
::
RRC_PDU_DELIVERY
);
m
->
cellId
=
m_base
->
shCtx
.
currentCell
.
get
<
int
>
([](
auto
&
value
)
{
return
value
.
cellId
;
});
m
->
channel
=
rrc
::
RrcChannel
::
UL_DCCH
;
m
->
pdu
=
std
::
move
(
pdu
);
m_base
->
rlsTask
->
push
(
m
);
m_base
->
rlsTask
->
push
(
std
::
move
(
m
)
);
}
void
UeRrcTask
::
receiveRrcMessage
(
int
cellId
,
ASN_RRC_BCCH_BCH_Message
*
msg
)
...
...
src/ue/rrc/connection.cpp
View file @
4ec4a785
...
...
@@ -129,7 +129,7 @@ void UeRrcTask::receiveRrcSetup(int cellId, const ASN_RRC_RRCSetup &msg)
m_logger
->
info
(
"RRC connection established"
);
switchState
(
ERrcState
::
RRC_CONNECTED
);
m_base
->
nasTask
->
push
(
new
NmUeRrcToNas
(
NmUeRrcToNas
::
RRC_CONNECTION_SETUP
));
m_base
->
nasTask
->
push
(
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
RRC_CONNECTION_SETUP
));
}
void
UeRrcTask
::
receiveRrcReject
(
int
cellId
,
const
ASN_RRC_RRCReject
&
msg
)
...
...
@@ -146,12 +146,12 @@ void UeRrcTask::receiveRrcRelease(const ASN_RRC_RRCRelease &msg)
{
m_logger
->
debug
(
"RRC Release received"
);
m_state
=
ERrcState
::
RRC_IDLE
;
m_base
->
nasTask
->
push
(
new
NmUeRrcToNas
(
NmUeRrcToNas
::
RRC_CONNECTION_RELEASE
));
m_base
->
nasTask
->
push
(
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
RRC_CONNECTION_RELEASE
));
}
void
UeRrcTask
::
handleEstablishmentFailure
()
{
m_base
->
nasTask
->
push
(
new
NmUeRrcToNas
(
NmUeRrcToNas
::
RRC_ESTABLISHMENT_FAILURE
));
m_base
->
nasTask
->
push
(
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
RRC_ESTABLISHMENT_FAILURE
));
}
}
// namespace nr::ue
src/ue/rrc/failures.cpp
View file @
4ec4a785
...
...
@@ -23,7 +23,7 @@ void UeRrcTask::declareRadioLinkFailure(rls::ERlfCause cause)
void
UeRrcTask
::
handleRadioLinkFailure
(
rls
::
ERlfCause
cause
)
{
m_state
=
ERrcState
::
RRC_IDLE
;
m_base
->
nasTask
->
push
(
new
NmUeRrcToNas
(
NmUeRrcToNas
::
RADIO_LINK_FAILURE
));
m_base
->
nasTask
->
push
(
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
RADIO_LINK_FAILURE
));
}
}
// namespace nr::ue
\ No newline at end of file
src/ue/rrc/handler.cpp
View file @
4ec4a785
...
...
@@ -51,9 +51,9 @@ void UeRrcTask::receivePaging(const ASN_RRC_Paging &msg)
}
});
auto
*
w
=
new
NmUeRrcToNas
(
NmUeRrcToNas
::
PAGING
);
auto
w
=
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
PAGING
);
w
->
pagingTmsi
=
std
::
move
(
tmsiIds
);
m_base
->
nasTask
->
push
(
w
);
m_base
->
nasTask
->
push
(
std
::
move
(
w
)
);
}
}
// namespace nr::ue
\ No newline at end of file
src/ue/rrc/idle.cpp
View file @
4ec4a785
...
...
@@ -100,13 +100,13 @@ void UeRrcTask::performCellSelection()
if
(
selectedCell
!=
lastCell
.
cellId
)
{
auto
*
w1
=
new
NmUeRrcToRls
(
NmUeRrcToRls
::
ASSIGN_CURRENT_CELL
);
auto
w1
=
std
::
make_unique
<
NmUeRrcToRls
>
(
NmUeRrcToRls
::
ASSIGN_CURRENT_CELL
);
w1
->
cellId
=
selectedCell
;
m_base
->
rlsTask
->
push
(
w1
);
m_base
->
rlsTask
->
push
(
std
::
move
(
w1
)
);
auto
w2
=
new
NmUeRrcToNas
(
NmUeRrcToNas
::
ACTIVE_CELL_CHANGED
);
auto
w2
=
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
ACTIVE_CELL_CHANGED
);
w2
->
previousTai
=
Tai
{
lastCell
.
plmn
,
lastCell
.
tac
};
m_base
->
nasTask
->
push
(
w2
);
m_base
->
nasTask
->
push
(
std
::
move
(
w2
)
);
}
}
...
...
src/ue/rrc/nas.cpp
View file @
4ec4a785
...
...
@@ -64,9 +64,9 @@ void UeRrcTask::receiveDownlinkInformationTransfer(const ASN_RRC_DLInformationTr
OctetString
nasPdu
=
asn
::
GetOctetString
(
*
msg
.
criticalExtensions
.
choice
.
dlInformationTransfer
->
dedicatedNAS_Message
);
auto
*
m
=
new
NmUeRrcToNas
(
NmUeRrcToNas
::
NAS_DELIVERY
);
auto
m
=
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
NAS_DELIVERY
);
m
->
nasPdu
=
std
::
move
(
nasPdu
);
m_base
->
nasTask
->
push
(
m
);
m_base
->
nasTask
->
push
(
std
::
move
(
m
)
);
}
}
// namespace nr::ue
\ No newline at end of file
src/ue/rrc/sap.cpp
View file @
4ec4a785
...
...
@@ -48,8 +48,8 @@ void UeRrcTask::handleNasSapMessage(NmUeNasToRrc &msg)
(
void
)
msg
.
treatBarred
;
switchState
(
ERrcState
::
RRC_IDLE
);
m_base
->
rlsTask
->
push
(
new
NmUeRrcToRls
(
NmUeRrcToRls
::
RESET_STI
));
m_base
->
nasTask
->
push
(
new
NmUeRrcToNas
(
NmUeRrcToNas
::
RRC_CONNECTION_RELEASE
));
m_base
->
rlsTask
->
push
(
std
::
make_unique
<
NmUeRrcToRls
>
(
NmUeRrcToRls
::
RESET_STI
));
m_base
->
nasTask
->
push
(
std
::
make_unique
<
NmUeRrcToNas
>
(
NmUeRrcToNas
::
RRC_CONNECTION_RELEASE
));
break
;
}
case
NmUeNasToRrc
:
:
RRC_NOTIFY
:
{
...
...
src/ue/rrc/state.cpp
View file @
4ec4a785
...
...
@@ -18,7 +18,7 @@ namespace nr::ue
void
UeRrcTask
::
triggerCycle
()
{
push
(
new
NmUeRrcToRrc
(
NmUeRrcToRrc
::
TRIGGER_CYCLE
));
push
(
std
::
make_unique
<
NmUeRrcToRrc
>
(
NmUeRrcToRrc
::
TRIGGER_CYCLE
));
}
void
UeRrcTask
::
performCycle
()
...
...
src/ue/rrc/task.cpp
View file @
4ec4a785
...
...
@@ -46,23 +46,23 @@ void UeRrcTask::onQuit()
void
UeRrcTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
UE_NAS_TO_RRC
:
{
handleNasSapMessage
(
*
dynamic_cast
<
NmUeNasToRrc
*>
(
msg
));
handleNasSapMessage
(
dynamic_cast
<
NmUeNasToRrc
&>
(
*
msg
));
break
;
}
case
NtsMessageType
:
:
UE_RLS_TO_RRC
:
{
handleRlsSapMessage
(
*
dynamic_cast
<
NmUeRlsToRrc
*>
(
msg
));
handleRlsSapMessage
(
dynamic_cast
<
NmUeRlsToRrc
&>
(
*
msg
));
break
;
}
case
NtsMessageType
:
:
UE_RRC_TO_RRC
:
{
auto
*
w
=
dynamic_cast
<
NmUeRrcToRrc
*>
(
msg
);
switch
(
w
->
present
)
auto
&
w
=
dynamic_cast
<
NmUeRrcToRrc
&>
(
*
msg
);
switch
(
w
.
present
)
{
case
NmUeRrcToRrc
:
:
TRIGGER_CYCLE
:
performCycle
();
...
...
@@ -71,8 +71,8 @@ void UeRrcTask::onLoop()
break
;
}
case
NtsMessageType
:
:
TIMER_EXPIRED
:
{
auto
*
w
=
dynamic_cast
<
NmTimerExpired
*>
(
msg
);
if
(
w
->
timerId
==
TIMER_ID_MACHINE_CYCLE
)
auto
&
w
=
dynamic_cast
<
NmTimerExpired
&>
(
*
msg
);
if
(
w
.
timerId
==
TIMER_ID_MACHINE_CYCLE
)
{
setTimer
(
TIMER_ID_MACHINE_CYCLE
,
TIMER_PERIOD_MACHINE_CYCLE
);
performCycle
();
...
...
@@ -80,11 +80,9 @@ void UeRrcTask::onLoop()
break
;
}
default:
m_logger
->
unhandledNts
(
msg
);
m_logger
->
unhandledNts
(
*
msg
);
break
;
}
delete
msg
;
}
}
// namespace nr::ue
\ No newline at end of file
src/ue/tun/task.cpp
View file @
4ec4a785
...
...
@@ -35,9 +35,9 @@ static std::string GetErrorMessage(const std::string &cause)
return
what
;
}
static
nr
::
ue
::
NmUeTunToApp
*
NmError
(
std
::
string
&&
error
)
static
std
::
unique_ptr
<
nr
::
ue
::
NmUeTunToApp
>
NmError
(
std
::
string
&&
error
)
{
auto
*
m
=
new
nr
::
ue
::
NmUeTunToApp
(
nr
::
ue
::
NmUeTunToApp
::
TUN_ERROR
);
auto
m
=
std
::
make_unique
<
nr
::
ue
::
NmUeTunToApp
>
(
nr
::
ue
::
NmUeTunToApp
::
TUN_ERROR
);
m
->
error
=
std
::
move
(
error
);
return
m
;
}
...
...
@@ -63,10 +63,10 @@ static void ReceiverThread(ReceiverArgs *args)
if
(
n
>
0
)
{
auto
*
m
=
new
nr
::
ue
::
NmUeTunToApp
(
nr
::
ue
::
NmUeTunToApp
::
DATA_PDU_DELIVERY
);
auto
m
=
std
::
make_unique
<
nr
::
ue
::
NmUeTunToApp
>
(
nr
::
ue
::
NmUeTunToApp
::
DATA_PDU_DELIVERY
);
m
->
psi
=
psi
;
m
->
data
=
OctetString
::
FromArray
(
buffer
,
static_cast
<
size_t
>
(
n
));
targetTask
->
push
(
m
);
targetTask
->
push
(
std
::
move
(
m
)
);
}
}
}
...
...
@@ -96,28 +96,26 @@ void TunTask::onQuit()
void
TunTask
::
onLoop
()
{
NtsMessage
*
msg
=
take
();
auto
msg
=
take
();
if
(
!
msg
)
return
;
switch
(
msg
->
msgType
)
{
case
NtsMessageType
:
:
UE_APP_TO_TUN
:
{
auto
*
w
=
dynamic_cast
<
NmAppToTun
*>
(
msg
);
ssize_t
res
=
::
write
(
m_fd
,
w
->
data
.
data
(),
w
->
data
.
length
());
auto
&
w
=
dynamic_cast
<
NmAppToTun
&>
(
*
msg
);
ssize_t
res
=
::
write
(
m_fd
,
w
.
data
.
data
(),
w
.
data
.
length
());
if
(
res
<
0
)
push
(
NmError
(
GetErrorMessage
(
"TUN device could not write"
)));
else
if
(
res
!=
w
->
data
.
length
())
else
if
(
res
!=
w
.
data
.
length
())
push
(
NmError
(
GetErrorMessage
(
"TUN device partially written"
)));
delete
w
;
break
;
}
case
NtsMessageType
:
:
UE_TUN_TO_APP
:
{
m_base
->
appTask
->
push
(
msg
);
m_base
->
appTask
->
push
(
std
::
move
(
msg
)
);
break
;
}
default:
delete
msg
;
break
;
}
}
...
...
src/ue/ue.cpp
View file @
4ec4a785
...
...
@@ -62,7 +62,7 @@ void UserEquipment::start()
void
UserEquipment
::
pushCommand
(
std
::
unique_ptr
<
app
::
UeCliCommand
>
cmd
,
const
InetAddress
&
address
)
{
taskBase
->
appTask
->
push
(
new
NmUeCliCommand
(
std
::
move
(
cmd
),
address
));
taskBase
->
appTask
->
push
(
std
::
make_unique
<
NmUeCliCommand
>
(
std
::
move
(
cmd
),
address
));
}
}
// namespace nr::ue
src/utils/logger.cpp
View file @
4ec4a785
...
...
@@ -55,9 +55,9 @@ void Logger::flush()
logger
->
flush
();
}
void
Logger
::
unhandledNts
(
NtsMessage
*
msg
)
void
Logger
::
unhandledNts
(
const
NtsMessage
&
msg
)
{
err
(
"Unhandled NTS message received with type %d"
,
(
int
)
msg
->
msgType
);
err
(
"Unhandled NTS message received with type %d"
,
(
int
)
msg
.
msgType
);
}
LogBase
::
LogBase
(
const
std
::
string
&
filename
)
...
...
src/utils/logger.hpp
View file @
4ec4a785
...
...
@@ -105,7 +105,7 @@ class Logger
void
flush
();
/* Specific logs */
void
unhandledNts
(
NtsMessage
*
msg
);
void
unhandledNts
(
const
NtsMessage
&
msg
);
};
class
LogBase
...
...
src/utils/nts.cpp
View file @
4ec4a785
...
...
@@ -14,9 +14,9 @@
#define WAIT_TIME_IF_NO_TIMER 500
#define PAUSE_POLLING_PERIOD 20
static
NtsMessage
*
TimerExpiredMessage
(
TimerInfo
*
timerInfo
)
static
std
::
unique_ptr
<
NtsMessage
>
TimerExpiredMessage
(
TimerInfo
*
timerInfo
)
{
return
timerInfo
?
new
NmTimerExpired
(
timerInfo
->
timerId
)
:
nullptr
;
return
timerInfo
?
std
::
make_unique
<
NmTimerExpired
>
(
timerInfo
->
timerId
)
:
nullptr
;
}
void
TimerBase
::
setTimerAbsolute
(
int
timerId
,
int64_t
timeMs
)
...
...
@@ -62,34 +62,28 @@ TimerBase::~TimerBase()
}
}
bool
NtsTask
::
push
(
NtsMessage
*
msg
)
bool
NtsTask
::
push
(
std
::
unique_ptr
<
NtsMessage
>
&&
msg
)
{
if
(
isQuiting
)
{
delete
msg
;
return
false
;
}
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
msgQueue
.
push_back
(
msg
);
msgQueue
.
push_back
(
std
::
move
(
msg
)
);
}
cv
.
notify_one
();
return
true
;
}
bool
NtsTask
::
pushFront
(
NtsMessage
*
msg
)
bool
NtsTask
::
pushFront
(
std
::
unique_ptr
<
NtsMessage
>
&&
msg
)
{
if
(
isQuiting
)
{
delete
msg
;
return
false
;
}
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
msgQueue
.
push_front
(
msg
);
msgQueue
.
push_front
(
std
::
move
(
msg
)
);
}
cv
.
notify_one
();
...
...
@@ -115,13 +109,13 @@ bool NtsTask::setTimerAbsolute(int timerId, int64_t timeMs)
return
true
;
}
NtsMessage
*
NtsTask
::
poll
()
std
::
unique_ptr
<
NtsMessage
>
NtsTask
::
poll
()
{
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
if
(
!
msgQueue
.
empty
())
{
NtsMessage
*
ret
=
msgQueue
.
front
(
);
auto
ret
=
std
::
move
(
msgQueue
.
front
()
);
msgQueue
.
pop_front
();
return
ret
;
}
...
...
@@ -138,14 +132,14 @@ NtsMessage *NtsTask::poll()
if
(
expiredTimer
!=
nullptr
)
{
NtsMessage
*
msg
=
TimerExpiredMessage
(
expiredTimer
);
auto
msg
=
TimerExpiredMessage
(
expiredTimer
);
delete
expiredTimer
;
return
msg
;
}
return
nullptr
;
}
NtsMessage
*
NtsTask
::
poll
(
int64_t
timeout
)
std
::
unique_ptr
<
NtsMessage
>
NtsTask
::
poll
(
int64_t
timeout
)
{
timeout
=
std
::
min
(
timeout
,
(
int64_t
)
WAIT_TIME_IF_NO_TIMER
);
...
...
@@ -156,7 +150,7 @@ NtsMessage *NtsTask::poll(int64_t timeout)
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
if
(
!
msgQueue
.
empty
())
{
NtsMessage
*
ret
=
msgQueue
.
front
(
);
auto
ret
=
std
::
move
(
msgQueue
.
front
()
);
msgQueue
.
pop_front
();
return
ret
;
}
...
...
@@ -170,7 +164,7 @@ NtsMessage *NtsTask::poll(int64_t timeout)
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
if
(
!
msgQueue
.
empty
())
{
NtsMessage
*
ret
=
msgQueue
.
front
(
);
auto
ret
=
std
::
move
(
msgQueue
.
front
()
);
msgQueue
.
pop_front
();
return
ret
;
}
...
...
@@ -184,14 +178,14 @@ NtsMessage *NtsTask::poll(int64_t timeout)
if
(
expiredTimer
!=
nullptr
)
{
NtsMessage
*
msg
=
TimerExpiredMessage
(
expiredTimer
);
auto
msg
=
TimerExpiredMessage
(
expiredTimer
);
delete
expiredTimer
;
return
msg
;
}
return
nullptr
;
}
NtsMessage
*
NtsTask
::
take
()
std
::
unique_ptr
<
NtsMessage
>
NtsTask
::
take
()
{
return
poll
(
WAIT_TIME_IF_NO_TIMER
);
}
...
...
@@ -237,13 +231,7 @@ void NtsTask::quit()
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
mutex
);
while
(
!
msgQueue
.
empty
())
{
NtsMessage
*
msg
=
msgQueue
.
front
();
msgQueue
.
pop_front
();
// Since we have the ownership at this time, we should delete the messages.
delete
msg
;
}
}
onQuit
();
...
...
src/utils/nts.hpp
View file @
4ec4a785
...
...
@@ -14,6 +14,7 @@
#include <chrono>
#include <condition_variable>
#include <deque>
#include <memory>
#include <mutex>
#include <queue>
#include <thread>
...
...
@@ -50,14 +51,14 @@ enum class NtsMessageType
UE_TUN_TO_APP
,
UE_RRC_TO_NAS
,
UE_NAS_TO_RRC
,
UE_RRC_TO_RLS
,
UE_RRC_TO_RRC
,
UE_RRC_TO_RLS
,
UE_RRC_TO_RRC
,
UE_NAS_TO_NAS
,
UE_RLS_TO_RRC
,
UE_RLS_TO_NAS
,
UE_RLS_TO_RLS
,
UE_NAS_TO_APP
,
UE_NAS_TO_RLS
,
UE_NAS_TO_APP
,
UE_NAS_TO_RLS
,
};
struct
NtsMessage
...
...
@@ -114,7 +115,7 @@ class TimerBase
class
NtsTask
{
private:
std
::
deque
<
NtsMessage
*
>
msgQueue
{};
std
::
deque
<
std
::
unique_ptr
<
NtsMessage
>
>
msgQueue
{};
TimerBase
timerBase
{};
std
::
mutex
mutex
{};
std
::
condition_variable
cv
{};
...
...
@@ -128,25 +129,15 @@ class NtsTask
virtual
~
NtsTask
()
=
default
;
// NtsTask takes the ownership of NtsMessage* after somebody pushes the message.
bool
push
(
NtsMessage
*
msg
);
// NtsTask takes the ownership of NtsMessage* after somebody pushes the message.
bool
pushFront
(
NtsMessage
*
msg
);
bool
push
(
std
::
unique_ptr
<
NtsMessage
>
&&
msg
);
bool
pushFront
(
std
::
unique_ptr
<
NtsMessage
>
&&
msg
);
bool
setTimer
(
int
timerId
,
int64_t
delayMs
);
bool
setTimerAbsolute
(
int
timerId
,
int64_t
timeMs
);
protected:
// NtsTask gives the ownership of NtsMessage* to the taker (actually almost always it's its itself)
NtsMessage
*
poll
();
// NtsTask gives the ownership of NtsMessage* to the taker (actually almost always it's its itself)
NtsMessage
*
poll
(
int64_t
timeout
);
// NtsTask gives the ownership of NtsMessage* to the taker (actually almost always it's its itself)
NtsMessage
*
take
();
std
::
unique_ptr
<
NtsMessage
>
poll
();
std
::
unique_ptr
<
NtsMessage
>
poll
(
int64_t
timeout
);
std
::
unique_ptr
<
NtsMessage
>
take
();
protected:
// Called exactly once after start() called and before onLoop() callbacks.
...
...
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