Commit 210cc695 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup/format

parent 3279fc64
#
# Copyright (c) 2015, EURECOM (www.eurecom.fr)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and documentation are those
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of the FreeBSD Project.
#
# see https://clang.llvm.org/docs/ClangFormatStyleOptions.html for explanation
# of style options
BasedOnStyle: Google
Language: Cpp
IndentWidth: 2
ColumnLimit: 80
IncludeBlocks: Preserve
SortIncludes: false
# alignment
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
DerivePointerAlignment: false
PointerAlignment: Left
# function style
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterReturnType: None
IndentWrappedFunctionNames: false
# template style
AlwaysBreakTemplateDeclarations: Yes
# preprocessor style
IndentPPDirectives: None
# block style
AllowShortBlocksOnASingleLine: false
KeepEmptyLinesAtTheStartOfBlocks: false
# break style
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakStringLiterals: true
CompactNamespaces: false
ContinuationIndentWidth: 4
MaxEmptyLinesToKeep: 1
ReflowComments: true
# spacing style
UseTab: Never
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
# class style
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
# case statements
IndentCaseLabels: true
# cpp
Cpp11BracedListStyle: true
FixNamespaceComments: true
NamespaceIndentation: None
SortUsingDeclarations: true
# todo
# AlwaysBreakBeforeMultilineStrings: bool
# PenaltyBreakAssignment (unsigned)
# PenaltyBreakBeforeFirstCallParameter (unsigned)
# PenaltyBreakComment (unsigned)
# PenaltyBreakFirstLessLess (unsigned)
# PenaltyBreakString (unsigned)
# PenaltyBreakTemplateDeclaration (unsigned)
# PenaltyExcessCharacter (unsigned)
# PenaltyReturnTypeOnItsOwnLine (unsigned)
......@@ -203,7 +203,9 @@ void amf_app::handle_itti_message(
itti_downlink_nas_transfer *dl_msg = new itti_downlink_nas_transfer(
TASK_AMF_APP, TASK_AMF_N1);
dl_msg->dl_nas = dl_nas;
if (itti_msg.is_n2sm_set) {
if (!itti_msg.is_n2sm_set) {
dl_msg->is_n2sm_set = false;
} else {
dl_msg->n2sm = itti_msg.n2sm;
dl_msg->pdu_session_id = itti_msg.pdu_session_id;
dl_msg->is_n2sm_set = true;
......@@ -211,7 +213,7 @@ void amf_app::handle_itti_message(
}
dl_msg->amf_ue_ngap_id = amf_n1_inst->supi2amfId.at(itti_msg.supi);
dl_msg->ran_ue_ngap_id = amf_n1_inst->supi2ranId.at(itti_msg.supi);
std::shared_ptr<itti_downlink_nas_transfer> i = std::shared_ptr
std::shared_ptr < itti_downlink_nas_transfer > i = std::shared_ptr
< itti_downlink_nas_transfer > (dl_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
......@@ -229,7 +231,7 @@ void amf_app::handle_itti_message(
//3. store ue-reated core information
//4. send nas-pdu to task_amf_n1
long amf_ue_ngap_id = 0;
std::shared_ptr<ue_context> uc;
std::shared_ptr < ue_context > uc;
//check ue context with 5g-s-tmsi
if ((amf_ue_ngap_id = itti_msg.amf_ue_ngap_id) == -1) {
......@@ -283,7 +285,7 @@ void amf_app::handle_itti_message(
if (is_guti_valid) {
itti_n1_msg->guti = guti;
}
std::shared_ptr<itti_uplink_nas_data_ind> i = std::shared_ptr
std::shared_ptr < itti_uplink_nas_data_ind > i = std::shared_ptr
< itti_uplink_nas_data_ind > (itti_n1_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
......@@ -309,7 +311,7 @@ bool amf_app::generate_5g_guti(uint32_t ranid, long amfid, string &mcc,
ue_context_key.c_str());
return false;
}
std::shared_ptr<ue_context> uc;
std::shared_ptr < ue_context > uc;
uc = ran_amf_id_2_ue_context(ue_context_key);
mcc = uc.get()->tai.mcc;
mnc = uc.get()->tai.mnc;
......
......@@ -429,7 +429,8 @@ int amf_config::load_thread_sched_params(const Setting &thread_sched_params_cfg,
try {
std::string thread_rd_sched_policy;
thread_sched_params_cfg.lookupValue(
AMF_CONFIG_STRING_THREAD_RD_SCHED_POLICY, thread_rd_sched_policy);
AMF_CONFIG_STRING_THREAD_RD_SCHED_POLICY,
thread_rd_sched_policy);
util::trim(thread_rd_sched_policy);
if (boost::iequals(thread_rd_sched_policy, "SCHED_OTHER")) {
cfg.sched_policy = SCHED_OTHER;
......@@ -454,7 +455,8 @@ int amf_config::load_thread_sched_params(const Setting &thread_sched_params_cfg,
try {
thread_sched_params_cfg.lookupValue(
AMF_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY, cfg.sched_priority);
AMF_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY,
cfg.sched_priority);
if ((cfg.sched_priority > 99) || (cfg.sched_priority < 1)) {
Logger::amf_app().error(
"thread_rd_sched_priority: %d, must be in interval [1..99] in config file",
......
......@@ -68,8 +68,8 @@ int amf_modules::load(const std::string &config_file) {
item.lookupValue(MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_NAME,
msgName);
item.lookupValue(
MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE,
procedure_code);
MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_PROCEDURECODE,
procedure_code);
item.lookupValue(MODULES_CONFIG_STRING_AMF_MODULES_NGAP_MESSAGE_TYPEOFMSG,
typeOfMessage);
procedureCode = (Ngap_ProcedureCode_t) procedure_code;
......
This diff is collapsed.
......@@ -175,7 +175,8 @@ class amf_n1 {
void service_request_handle(bool isNasSig, std::shared_ptr<nas_context> nc,
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id,
bstring nas);
void identity_response_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg);
void identity_response_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id,
bstring plain_msg);
//authentication vector
bool generate_authentication_vector();
......
This diff is collapsed.
......@@ -49,7 +49,7 @@ class amf_n11 {
std::string smf_addr, bstring sm_msg, std::string dnn);
void handle_itti_message(itti_nsmf_pdusession_update_sm_context &itti_msg);
void handle_itti_message(itti_nsmf_pdusession_release_sm_context &itti_msg);
void handle_itti_message(itti_pdu_session_resource_setup_response &itti_msg);
void handle_itti_message(itti_pdu_session_resource_setup_response &itti_msg);
void send_pdu_session_update_sm_context_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, bstring sm_msg, std::string dnn);
......
This diff is collapsed.
......@@ -60,7 +60,7 @@ class amf_n2 : public ngap::ngap_app {
void handle_itti_message(itti_handover_request_Ack &itti_msg);
void handle_itti_message(itti_handover_notify &itti_msg);
void handle_itti_message(itti_uplinkranstatsutransfer &itti_msg);
bool verifyPlmn(std::vector<SupportedItem_t> list);
std::vector<SupportedItem_t> get_common_plmn(
std::vector<SupportedItem_t> list);
......@@ -76,7 +76,6 @@ class amf_n2 : public ngap::ngap_app {
std::map<uint32_t, std::shared_ptr<ue_ngap_context>> ranid2uecontext; // ran ue ngap id
mutable std::shared_mutex m_ranid2uecontext;
};
}
......
......@@ -32,16 +32,19 @@
using namespace nas;
//------------------------------------------------------------------------------
ServiceAccept::ServiceAccept(){
plain_header = NULL;
ie_PDU_session_status = NULL;
ie_session_reactivation_result = NULL;
ServiceAccept::ServiceAccept() {
plain_header = NULL;
ie_PDU_session_status = NULL;
ie_session_reactivation_result = NULL;
}
ServiceAccept::~ServiceAccept(){
if (plain_header) delete plain_header;
if (ie_PDU_session_status) delete ie_PDU_session_status;
if (ie_session_reactivation_result) delete ie_session_reactivation_result;
ServiceAccept::~ServiceAccept() {
if (plain_header)
delete plain_header;
if (ie_PDU_session_status)
delete ie_PDU_session_status;
if (ie_session_reactivation_result)
delete ie_session_reactivation_result;
}
//------------------------------------------------------------------------------
void ServiceAccept::setHeader(uint8_t security_header_type) {
......
......@@ -112,128 +112,109 @@ typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceReleaseResponseTransfer;
} PDUSessionResourceReleasedItem_t;
typedef struct
{
std::string ip_address;
uint32_t gtp_teid;
} GtpTunnel_t;
typedef struct
{
long _5QI;
long *priorityLevelQos;
long *averagingWindow;
long *maximumDataBurstVolume;
} NonDynamic5QI_t;
typedef struct
{
long pERScalar;
long pERExponent;
} PacketErrorRate_t;
typedef struct
{
long priorityLevelQos;
long packetDelayBudget;
PacketErrorRate_t packetErrorRate;
long *_5QI;
e_Ngap_DelayCritical *delayCritical;
long *averagingWindow;
long *maximumDataBurstVolume;
} Dynamic5QI_t;
typedef struct
{
NonDynamic5QI_t *nonDy;
Dynamic5QI_t *dy;
} QosCharacteristics_t;
typedef struct
{
long priorityLevelARP;
e_Ngap_Pre_emptionCapability pre_emptionCapability;
e_Ngap_Pre_emptionVulnerability pre_emptionVulnerability;
} AllocationAndRetentionPriority_t;
typedef struct
{
long maximumFlowBitRateDL;
long maximumFlowBitRateUL;
long guaranteedFlowBitRateDL;
long guaranteedFlowBitRateUL;
e_Ngap_NotificationControl *notificationControl;
long *maximumPacketLossRateDL;
long *maximumPacketLossRateUL;
} GBR_QosInformation_t;
typedef struct
{
QosCharacteristics_t qosc;
AllocationAndRetentionPriority_t arp;
GBR_QosInformation_t *gbr_qos_info;
e_Ngap_ReflectiveQosAttribute *reflectiveQosAttribute;
e_Ngap_AdditionalQosFlowInformation *additionalQosFlowInformation;
} QosFlowLevelQosParameters_t;
typedef struct
{
long qos_flow_id;
QosFlowLevelQosParameters_t qflqp;
} QosFlowSetupReq_t;
typedef struct
{
long qosFlowIdentifier;
e_Ngap_AssociatedQosFlowItem__qosFlowMappingIndication *qosFlowMappingIndication;
} AssociatedQosFlow_t;
typedef struct
{
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupResponseTransfer;
} PDUSessionResourceSetupResponseItem_t;
typedef struct
{
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupUnsuccessfulTransfer;
} PDUSessionResourceFailedToSetupItem_t;
typedef struct
{
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceReleaseCommandTransfer;
} PDUSessionResourceReleaseCommandItem_t;
typedef struct
{
uint8_t pduSessionId;
OCTET_STRING_t HandoverRequiredTransfer;
} PDUSessionResourceItem_t;
typedef struct
{
uint8_t pduSessionId;
S_Nssai s_nssai;
OCTET_STRING_t pduSessionResourceSetupRequestTransfer;
} PDUSessionResourceSetupItem_t;
typedef struct
{
uint8_t pduSessionId;
OCTET_STRING_t handoverRequestAcknowledgeTransfer;
} PDUSessionResourceAdmittedItem_t;
typedef struct
{
Ngap_QosFlowIdentifier_t qosFlowIdentifier;
} QosFlowLItemWithDataForwarding_t;
typedef struct
{
long QFI;
} QosFlowToBeForwardedItem_t;
} // namespace ngap
typedef struct {
std::string ip_address;
uint32_t gtp_teid;
} GtpTunnel_t;
typedef struct {
long _5QI;
long *priorityLevelQos;
long *averagingWindow;
long *maximumDataBurstVolume;
} NonDynamic5QI_t;
typedef struct {
long pERScalar;
long pERExponent;
} PacketErrorRate_t;
typedef struct {
long priorityLevelQos;
long packetDelayBudget;
PacketErrorRate_t packetErrorRate;
long *_5QI;
e_Ngap_DelayCritical *delayCritical;
long *averagingWindow;
long *maximumDataBurstVolume;
} Dynamic5QI_t;
typedef struct {
NonDynamic5QI_t *nonDy;
Dynamic5QI_t *dy;
} QosCharacteristics_t;
typedef struct {
long priorityLevelARP;
e_Ngap_Pre_emptionCapability pre_emptionCapability;
e_Ngap_Pre_emptionVulnerability pre_emptionVulnerability;
} AllocationAndRetentionPriority_t;
typedef struct {
long maximumFlowBitRateDL;
long maximumFlowBitRateUL;
long guaranteedFlowBitRateDL;
long guaranteedFlowBitRateUL;
e_Ngap_NotificationControl *notificationControl;
long *maximumPacketLossRateDL;
long *maximumPacketLossRateUL;
} GBR_QosInformation_t;
typedef struct {
QosCharacteristics_t qosc;
AllocationAndRetentionPriority_t arp;
GBR_QosInformation_t *gbr_qos_info;
e_Ngap_ReflectiveQosAttribute *reflectiveQosAttribute;
e_Ngap_AdditionalQosFlowInformation *additionalQosFlowInformation;
} QosFlowLevelQosParameters_t;
typedef struct {
long qos_flow_id;
QosFlowLevelQosParameters_t qflqp;
} QosFlowSetupReq_t;
typedef struct {
long qosFlowIdentifier;
e_Ngap_AssociatedQosFlowItem__qosFlowMappingIndication *qosFlowMappingIndication;
} AssociatedQosFlow_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupResponseTransfer;
} PDUSessionResourceSetupResponseItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceSetupUnsuccessfulTransfer;
} PDUSessionResourceFailedToSetupItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t pduSessionResourceReleaseCommandTransfer;
} PDUSessionResourceReleaseCommandItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t HandoverRequiredTransfer;
} PDUSessionResourceItem_t;
typedef struct {
uint8_t pduSessionId;
S_Nssai s_nssai;
OCTET_STRING_t pduSessionResourceSetupRequestTransfer;
} PDUSessionResourceSetupItem_t;
typedef struct {
uint8_t pduSessionId;
OCTET_STRING_t handoverRequestAcknowledgeTransfer;
} PDUSessionResourceAdmittedItem_t;
typedef struct {
Ngap_QosFlowIdentifier_t qosFlowIdentifier;
} QosFlowLItemWithDataForwarding_t;
typedef struct {
long QFI;
} QosFlowToBeForwardedItem_t;
} // namespace ngap
#endif
......@@ -48,11 +48,15 @@ UEContextReleaseCommandMsg::UEContextReleaseCommandMsg() {
causeValue = NULL;
}
UEContextReleaseCommandMsg::~UEContextReleaseCommandMsg(){
if(pdu) ASN_STRUCT_FREE(asn_DEF_Ngap_NGAP_PDU,pdu);
if (amfUeNgapId) delete amfUeNgapId;
if (ranUeNgapId) delete ranUeNgapId;
if (causeValue) delete causeValue;
UEContextReleaseCommandMsg::~UEContextReleaseCommandMsg() {
if (pdu)
ASN_STRUCT_FREE(asn_DEF_Ngap_NGAP_PDU, pdu);
if (amfUeNgapId)
delete amfUeNgapId;
if (ranUeNgapId)
delete ranUeNgapId;
if (causeValue)
delete causeValue;
}
//------------------------------------------------------------------------------
......@@ -138,10 +142,11 @@ void UEContextReleaseCommandMsg::setCauseRadioNetwork(
}
void UEContextReleaseCommandMsg::setCauseNas(e_Ngap_CauseNas cause_value) {
if (!causeValue) causeValue = new Cause();
causeValue->setChoiceOfCause(Ngap_Cause_PR_nas);
causeValue->setValue(cause_value);
addCauseIE();
if (!causeValue)
causeValue = new Cause();
causeValue->setChoiceOfCause(Ngap_Cause_PR_nas);
causeValue->setValue(cause_value);
addCauseIE();
}
//------------------------------------------------------------------------------
......
......@@ -39,14 +39,13 @@ extern "C" {
#include "Ngap_ProtocolIE-Field.h"
}
namespace ngap {
namespace ngap{
class UEContextReleaseCommandMsg{
public:
class UEContextReleaseCommandMsg {
public:
UEContextReleaseCommandMsg();
~UEContextReleaseCommandMsg();
public:
public:
void setMessageType();
void setAmfUeNgapId(unsigned long id);
void setUeNgapIdPair(unsigned long amfId, uint32_t ranId);
......@@ -54,9 +53,9 @@ public:
void setCauseRadioNetwork(e_Ngap_CauseRadioNetwork cause_value);
void setCauseNas(e_Ngap_CauseNas cause_value);
int encode2buffer(uint8_t *buf, int buf_size);
public:
public:
bool decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu);
private:
private:
Ngap_NGAP_PDU_t *pdu;
Ngap_UEContextReleaseCommand_t *ies;
......
......@@ -84,7 +84,7 @@ void ngap_app::handle_sctp_new_association(sctp_assoc_id_t assoc_id,
sctp_stream_id_t outstreams) {
Logger::ngap().debug(
"Ready to handle new NGAP SCTP association (id: %d) request", assoc_id);
std::shared_ptr<gnb_context> gc;
std::shared_ptr < gnb_context > gc;
if (!is_assoc_id_2_gnb_context(assoc_id)) {
Logger::ngap().debug("Create a new gNB context with assoc_id (%d)",
assoc_id);
......@@ -143,12 +143,12 @@ void ngap_app::set_assoc_id_2_gnb_context(const sctp_assoc_id_t &assoc_id,
//------------------------------------------------------------------------------
bool ngap_app::is_gnb_id_2_gnb_context(const long &gnb_id) const {
std::shared_lock lock(m_gnbid2gnbContext);
return bool{gnbid2gnbContext.count(gnb_id) > 0};
return bool { gnbid2gnbContext.count(gnb_id) > 0 };
}
//------------------------------------------------------------------------------
std::shared_ptr<gnb_context>
ngap_app::gnb_id_2_gnb_context(const long &gnb_id) const {
std::shared_ptr<gnb_context> ngap_app::gnb_id_2_gnb_context(
const long &gnb_id) const {
std::shared_lock lock(m_gnbid2gnbContext);
return gnbid2gnbContext.at(gnb_id);
}
......
......@@ -65,7 +65,7 @@ class ngap_app : public sctp_application {
std::shared_ptr<gnb_context> gc);
std::shared_ptr<gnb_context> gnb_id_2_gnb_context(const long &gnb_id) const;
protected:
protected:
sctp_server sctp_s_38412;
uint32_t ppid_;
std::map<sctp_assoc_id_t, std::shared_ptr<gnb_context>> assoc2gnbContext;
......@@ -74,6 +74,6 @@ protected:
mutable std::shared_mutex m_gnbid2gnbContext;
};
} // namespace ngap
} // namespace ngap
#endif
This diff is collapsed.
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