Commit 6674bd27 authored by Shivam Gandhi's avatar Shivam Gandhi

Merge branch 'develop' into 'amf-event-exposure'

# Conflicts:
#   src/amf-app/amf_app.hpp
parents 8bf0ea17 58efab83
# RELEASE NOTES: # # RELEASE NOTES: #
## v1.1.0 -- July 2021 ##
* Session Release
* NRF registration
- with FQDN DNS resolution
* Multiple PDU support
* Bug fixes
* Full support for Ubuntu18 and RHEL8
## v1.0.0 -- September 2020 ## ## v1.0.0 -- September 2020 ##
* Initial release * Initial release
......
...@@ -147,7 +147,7 @@ pipeline { ...@@ -147,7 +147,7 @@ pipeline {
sh 'sed -e "s#AMF_IMAGE_TAG#' + amfTag + '#" ci-scripts/dsTesterDockerCompose/docker-compose.tplt > ci-scripts/dsTesterDockerCompose/docker-compose.yml' sh 'sed -e "s#AMF_IMAGE_TAG#' + amfTag + '#" ci-scripts/dsTesterDockerCompose/docker-compose.tplt > ci-scripts/dsTesterDockerCompose/docker-compose.yml'
dir('ci-scripts/dsTesterDockerCompose') { dir('ci-scripts/dsTesterDockerCompose') {
sh 'docker-compose up -d > ../../archives/compose_amf_up.log 2>&1' sh 'docker-compose up -d > ../../archives/compose_amf_up.log 2>&1'
sh 'sleep 60' sh 'sleep 100'
// Do a check on number of healthy containers // Do a check on number of healthy containers
// 2 == mysql + amf // 2 == mysql + amf
ret = sh returnStdout: true, script: 'docker-compose ps -a | grep -v unhealthy | grep -c healthy || true' ret = sh returnStdout: true, script: 'docker-compose ps -a | grep -v unhealthy | grep -c healthy || true'
......
...@@ -67,7 +67,9 @@ pipeline { ...@@ -67,7 +67,9 @@ pipeline {
"Build RHEL8 AMF Image", "Build RHEL8 AMF Image",
"Static Code Analysis", "Static Code Analysis",
"Code Formatting Checker", "Code Formatting Checker",
"Test with DsTester" "Bracket Test with DsTester",
"Test with DsTester on Docker environment",
"Test with DsTester on OC environment"
]) ])
} }
...@@ -367,10 +369,12 @@ pipeline { ...@@ -367,10 +369,12 @@ pipeline {
} }
} }
} }
stage ('Testing in CN-5G-FED environment') { stage('Testing whole 5g Core Network Functions') {
parallel {
stage ('Testing in CN-5G-FED Docker environment') {
steps { steps {
script { script {
gitlabCommitStatus(name: "Test with DsTester") { gitlabCommitStatus(name: "Test with DsTester on Docker environment") {
localStatus = build job: params.CN5G_FED_PipelineName, localStatus = build job: params.CN5G_FED_PipelineName,
parameters: [ parameters: [
string(name: 'AMF_TAG', value: String.valueOf(amf_tag)), string(name: 'AMF_TAG', value: String.valueOf(amf_tag)),
...@@ -379,9 +383,9 @@ pipeline { ...@@ -379,9 +383,9 @@ pipeline {
localResult = localStatus.getResult() localResult = localStatus.getResult()
if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) { if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
echo "Federation Test Job is OK" echo "Docker Federation Test Job is OK"
} else { } else {
echo "Federation Test Job is KO" echo "Docker Federation Test Job is KO"
sh "ci-scripts/fail.sh" sh "ci-scripts/fail.sh"
} }
} }
...@@ -397,6 +401,38 @@ pipeline { ...@@ -397,6 +401,38 @@ pipeline {
} }
} }
} }
stage ('Testing in CN-5G-FED OC environment') {
steps {
script {
gitlabCommitStatus(name: "Test with DsTester on OC environment") {
localStatus = build job: params.CN5G_FED_OC_PipelineName,
parameters: [
string(name: 'AMF_TAG', value: String.valueOf(amf_tag)),
string(name: 'AMF_BRANCH', value: String.valueOf(amf_branch))
], propagate: false
localResult = localStatus.getResult()
if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
echo "OC Federation Test Job is OK"
} else {
echo "OC Federation Test Job is KO"
sh "ci-scripts/fail.sh"
}
}
}
}
post {
always {
script {
copyArtifacts(projectName: params.CN5G_FED_OC_PipelineName,
filter: '*_results_oai_cn5g_oc.html',
selector: lastCompleted())
}
}
}
}
}
}
} }
post { post {
success { success {
...@@ -472,6 +508,10 @@ pipeline { ...@@ -472,6 +508,10 @@ pipeline {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' *_results_oai_amf_bt.html" sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' *_results_oai_amf_bt.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' *_results_oai_amf_bt.html" sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' *_results_oai_amf_bt.html"
} }
if (fileExists('test_results_oai_cn5g_oc.html')) {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' *_results_oai_cn5g_oc.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' *_results_oai_cn5g_oc.html"
}
} else { } else {
sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${GIT_BRANCH} --git_src_commit=${GIT_COMMIT}" sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${GIT_BRANCH} --git_src_commit=${GIT_COMMIT}"
} }
...@@ -488,6 +528,10 @@ pipeline { ...@@ -488,6 +528,10 @@ pipeline {
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' *_results_oai_amf_bt.html" sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' *_results_oai_amf_bt.html"
archiveArtifacts artifacts: '*_results_oai_amf_bt.html' archiveArtifacts artifacts: '*_results_oai_amf_bt.html'
} }
if (fileExists('test_results_oai_cn5g_oc.html')) {
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' *_results_oai_cn5g_oc.html"
archiveArtifacts artifacts: '*_results_oai_cn5g_oc.html'
}
// Sending email to commiter // Sending email to commiter
if (params.sendToCommitterEmail != null) { if (params.sendToCommitterEmail != null) {
......
...@@ -76,6 +76,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 . ...@@ -76,6 +76,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 .
WORKDIR /usr/local/lib WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_chrono.so.1.67.0 .
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so . COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
RUN ldconfig RUN ldconfig
......
...@@ -97,6 +97,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 . ...@@ -97,6 +97,7 @@ COPY --from=oai-amf-builder /usr/lib/x86_64-linux-gnu/libpsl.so.5 .
WORKDIR /usr/local/lib WORKDIR /usr/local/lib
COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_system.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 . COPY --from=oai-amf-builder /usr/lib/libboost_thread.so.1.67.0 .
COPY --from=oai-amf-builder /usr/lib/libboost_chrono.so.1.67.0 .
COPY --from=oai-amf-builder /usr/local/lib/libpistache.so . COPY --from=oai-amf-builder /usr/local/lib/libpistache.so .
RUN ldconfig RUN ldconfig
......
...@@ -45,7 +45,7 @@ Based on document **3GPP TS 23.501 V16.0.0 §6.2.1**. ...@@ -45,7 +45,7 @@ Based on document **3GPP TS 23.501 V16.0.0 §6.2.1**.
| 4 | Registration management | :heavy_check_mark: | | | 4 | Registration management | :heavy_check_mark: | |
| 5 | Connection management | :heavy_check_mark: | | | 5 | Connection management | :heavy_check_mark: | |
| 6 | Reachability management | :x: | | | 6 | Reachability management | :x: | |
| 7 | Mobility Management | :x: | | | 7 | Mobility Management | :heavy_check_mark: | (Experimental) Support N2 Handover |
| 8 | Lawful intercept (for AMF events and interface to LI System) | :x: | | | 8 | Lawful intercept (for AMF events and interface to LI System) | :x: | |
| 9 | Provide transport for SM messages between UE and SMF | :heavy_check_mark: | | | 9 | Provide transport for SM messages between UE and SMF | :heavy_check_mark: | |
| 10 | Transparent proxy for routing SM messages | :x: | | | 10 | Transparent proxy for routing SM messages | :x: | |
......
...@@ -102,8 +102,8 @@ AMF = ...@@ -102,8 +102,8 @@ AMF =
# STRING, {"yes", "no"}, # STRING, {"yes", "no"},
NF_REGISTRATION = "@NF_REGISTRATION@"; # Set to yes if AMF resgisters to an NRF NF_REGISTRATION = "@NF_REGISTRATION@"; # Set to yes if AMF resgisters to an NRF
SMF_SELECTION = "@SMF_SELECTION@"; # Set to yes to enable SMF discovery and selection SMF_SELECTION = "@SMF_SELECTION@"; # Set to yes to enable SMF discovery and selection
EXTERNAL_AUSF = "no"; # Set to yes if AMF works with an external AUSF EXTERNAL_AUSF = "@EXTERNAL_AUSF@"; # Set to yes if AMF works with an external AUSF
EXTERNAL_UDM = "no"; # Set to yes if AMF works with an external UDM EXTERNAL_UDM = "@EXTERNAL_UDM@"; # Set to yes if AMF works with an external UDM
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AMF relies on a DNS to resolve NRF/SMF/UDM/AUSF's FQDN USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if AMF relies on a DNS to resolve NRF/SMF/UDM/AUSF's FQDN
} }
......
...@@ -4,6 +4,10 @@ set -euo pipefail ...@@ -4,6 +4,10 @@ set -euo pipefail
CONFIG_DIR="/openair-amf/etc" CONFIG_DIR="/openair-amf/etc"
# Default values
EXTERNAL_AUSF=${EXTERNAL_AUSF:-no}
EXTERNAL_UDM=${EXTERNAL_UDM:-no}
for c in ${CONFIG_DIR}/*.conf; do for c in ${CONFIG_DIR}/*.conf; do
# grep variable names (format: ${VAR}) from template to be rendered # grep variable names (format: ${VAR}) from template to be rendered
VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs) VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs)
......
...@@ -64,7 +64,15 @@ void amf_app_task(void*); ...@@ -64,7 +64,15 @@ void amf_app_task(void*);
uint32_t golbal_tmsi = 1; uint32_t golbal_tmsi = 1;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
amf_app::amf_app(const amf_config& amf_cfg) { amf_app::amf_app(const amf_config& amf_cfg)
: m_amf_ue_ngap_id2ue_ctx(),
m_ue_ctx_key(),
m_supi2ue_ctx(),
m_curl_handle_responses_n2_sm() {
amf_ue_ngap_id2ue_ctx = {};
ue_ctx_key = {};
supi2ue_ctx = {};
curl_handle_responses_n2_sm = {};
Logger::amf_app().startup("Creating AMF application functionality layer"); Logger::amf_app().startup("Creating AMF application functionality layer");
if (itti_inst->create_task(TASK_AMF_APP, amf_app_task, nullptr)) { if (itti_inst->create_task(TASK_AMF_APP, amf_app_task, nullptr)) {
Logger::amf_app().error("Cannot create task TASK_AMF_APP"); Logger::amf_app().error("Cannot create task TASK_AMF_APP");
...@@ -207,6 +215,7 @@ void amf_app::set_supi_2_ue_context( ...@@ -207,6 +215,7 @@ void amf_app::set_supi_2_ue_context(
supi2ue_ctx[supi] = uc; supi2ue_ctx[supi] = uc;
} }
//------------------------------------------------------------------------------
bool amf_app::find_pdu_session_context( bool amf_app::find_pdu_session_context(
const string& supi, const std::uint8_t pdu_session_id, const string& supi, const std::uint8_t pdu_session_id,
std::shared_ptr<pdu_session_context>& psc) { std::shared_ptr<pdu_session_context>& psc) {
...@@ -217,6 +226,7 @@ bool amf_app::find_pdu_session_context( ...@@ -217,6 +226,7 @@ bool amf_app::find_pdu_session_context(
return true; return true;
} }
//------------------------------------------------------------------------------
bool amf_app::get_pdu_sessions_context( bool amf_app::get_pdu_sessions_context(
const string& supi, const string& supi,
std::vector<std::shared_ptr<pdu_session_context>>& sessions_ctx) { std::vector<std::shared_ptr<pdu_session_context>>& sessions_ctx) {
...@@ -305,6 +315,7 @@ void amf_app::handle_itti_message( ...@@ -305,6 +315,7 @@ void amf_app::handle_itti_message(
} else { } else {
unc = amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id); unc = amf_n2_inst->ran_ue_id_2_ue_ngap_context(itti_msg.ran_ue_ngap_id);
unc.get()->amf_ue_ngap_id = amf_ue_ngap_id; unc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
amf_n2_inst->set_amf_ue_ngap_id_2_ue_ngap_context(amf_ue_ngap_id, unc);
} }
if (uc.get() == nullptr) { if (uc.get() == nullptr) {
...@@ -645,3 +656,24 @@ void amf_app::trigger_nf_deregistration() { ...@@ -645,3 +656,24 @@ void amf_app::trigger_nf_deregistration() {
itti_msg->get_msg_name()); itti_msg->get_msg_name());
} }
} }
//---------------------------------------------------------------------------------------------
void amf_app::add_promise(
uint32_t id, boost::shared_ptr<boost::promise<std::string>>& p) {
std::unique_lock lock(m_curl_handle_responses_n2_sm);
curl_handle_responses_n2_sm.emplace(id, p);
}
//------------------------------------------------------------------------------
void amf_app::trigger_process_response(uint32_t pid, std::string n2_sm) {
Logger::amf_app().debug(
"Trigger process response: Set promise with ID %u "
"to ready",
pid);
std::unique_lock lock(m_curl_handle_responses_n2_sm);
if (curl_handle_responses_n2_sm.count(pid) > 0) {
curl_handle_responses_n2_sm[pid]->set_value(n2_sm);
// Remove this promise from list
curl_handle_responses_n2_sm.erase(pid);
}
}
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <boost/thread/future.hpp> #include <boost/thread/future.hpp>
#include "uint_generator.hpp"
#include <boost/thread.hpp>
#include <boost/thread/future.hpp>
using namespace config; using namespace config;
static uint32_t amf_app_ue_ngap_id_generator = 1; static uint32_t amf_app_ue_ngap_id_generator = 1;
...@@ -80,8 +84,6 @@ class amf_app { ...@@ -80,8 +84,6 @@ class amf_app {
void handle_itti_message(itti_nas_signalling_establishment_request& itti_msg); void handle_itti_message(itti_nas_signalling_establishment_request& itti_msg);
void handle_itti_message(itti_n1n2_message_transfer_request& itti_msg); void handle_itti_message(itti_n1n2_message_transfer_request& itti_msg);
mutable std::shared_mutex m_amf_event_subscriptions;
bool is_amf_ue_id_2_ue_context(const long& amf_ue_ngap_id) const; bool is_amf_ue_id_2_ue_context(const long& amf_ue_ngap_id) const;
std::shared_ptr<ue_context> amf_ue_id_2_ue_context( std::shared_ptr<ue_context> amf_ue_id_2_ue_context(
const long& amf_ue_ngap_id) const; const long& amf_ue_ngap_id) const;
......
...@@ -84,7 +84,6 @@ extern statistics stacs; ...@@ -84,7 +84,6 @@ extern statistics stacs;
extern void convert_string_2_hex(std::string& input, std::string& output); extern void convert_string_2_hex(std::string& input, std::string& output);
extern unsigned char* format_string_as_hex(std::string str); extern unsigned char* format_string_as_hex(std::string str);
extern int ncc;
Sha256 ctx; Sha256 ctx;
random_state_t random_state; random_state_t random_state;
static uint8_t no_random_delta = 0; static uint8_t no_random_delta = 0;
...@@ -210,7 +209,6 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) { ...@@ -210,7 +209,6 @@ void amf_n1::handle_itti_message(itti_downlink_nas_transfer& itti_msg) {
uint32_t ulcount = uint32_t ulcount =
secu->ul_count.seq_num | (secu->ul_count.overflow << 8); secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Authentication_5gaka::derive_kgnb(0, 0x01, kamf, kgnb); Authentication_5gaka::derive_kgnb(0, 0x01, kamf, kgnb);
ncc = 1;
print_buffer("amf_n1", "kamf", kamf, 32); print_buffer("amf_n1", "kamf", kamf, 32);
// Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb); // Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
bstring kgnb_bs = blk2bstr(kgnb, 32); bstring kgnb_bs = blk2bstr(kgnb, 32);
...@@ -457,58 +455,6 @@ void amf_n1::nas_signalling_establishment_request_handle( ...@@ -457,58 +455,6 @@ void amf_n1::nas_signalling_establishment_request_handle(
} }
} }
//------------------------------------------------------------------------------
void amf_n1::uplink_nas_msg_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg) {
uint8_t* buf = (uint8_t*) bdata(plain_msg);
uint8_t message_type = *(buf + 2);
switch (message_type) {
case AUTHENTICATION_RESPONSE: {
Logger::amf_n1().debug(
"Received authentication response message, handling...");
authentication_response_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case AUTHENTICATION_FAILURE: {
Logger::amf_n1().debug(
"Received authentication failure message, handling...");
authentication_failure_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case SECURITY_MODE_COMPLETE: {
Logger::amf_n1().debug(
"Received security mode complete message, handling...");
security_mode_complete_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case SECURITY_MODE_REJECT: {
Logger::amf_n1().debug(
"Received security mode reject message, handling...");
security_mode_reject_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case UL_NAS_TRANSPORT: {
Logger::amf_n1().debug("Received UL NAS transport message, handling...");
ul_nas_transport_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case UE_INIT_DEREGISTER: {
Logger::amf_n1().debug(
"Received de-registration request message, handling...");
ue_initiate_de_registration_handle(
ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case IDENTITY_RESPONSE: {
Logger::amf_n1().debug("received identity response message , handle ...");
identity_response_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
} break;
case REGISTRATION_COMPLETE: {
Logger::amf_n1().debug(
"Received registration complete message, handling...");
registration_complete_handle(ran_ue_ngap_id, amf_ue_ngap_id, plain_msg);
// TODO
} break;
default: {
// TODO:
}
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n1::uplink_nas_msg_handle( void amf_n1::uplink_nas_msg_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg,
...@@ -1082,15 +1028,16 @@ void amf_n1::registration_request_handle( ...@@ -1082,15 +1028,16 @@ void amf_n1::registration_request_handle(
if (!regReq->getUeSecurityCapability( if (!regReq->getUeSecurityCapability(
encrypt_alg, integrity_alg, security_cap_eea, security_cap_eia)) { encrypt_alg, integrity_alg, security_cap_eea, security_cap_eia)) {
Logger::amf_n1().warn("No Optional IE UESecurityCapability available"); Logger::amf_n1().warn("No Optional IE UESecurityCapability available");
} else {
nc.get()->ueSecurityCaplen = regReq->ie_ue_security_capability->getLength();
} }
nc.get()->ueSecurityCapEnc = encrypt_alg; nc.get()->ueSecurityCapEnc = encrypt_alg;
nc.get()->ueSecurityCapInt = integrity_alg; nc.get()->ueSecurityCapInt = integrity_alg;
nc.get()->ueSecurityCapEEA = security_cap_eea; nc.get()->ueSecurityCapEEA = security_cap_eea;
nc.get()->ueSecurityCapEIA = security_cap_eia; nc.get()->ueSecurityCapEIA = security_cap_eia;
nc.get()->ueSecurityCaplen = regReq->ie_ue_security_capability->getLength();
// Get Requested NSSAI (Optional IE), if provided // Get Requested NSSAI (Optional IE), if provided
std::vector<SNSSAI_t> requestedNssai = {}; std::vector<SNSSAI_t> requestedNssai = {};
if (!regReq->getRequestedNssai(requestedNssai)) { if (!regReq->getRequestedNssai(requestedNssai)) {
...@@ -1422,9 +1369,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf( ...@@ -1422,9 +1369,9 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
Logger::amf_n1().debug("_5g_aka_confirmation_from_ausf"); Logger::amf_n1().debug("_5g_aka_confirmation_from_ausf");
std::string remoteUri = nc.get()->Href; std::string remoteUri = nc.get()->Href;
std::string msgBody; std::string msgBody = {};
std::string Response; std::string response = {};
std::string resStar_string; std::string resStar_string = {};
std::map<std::string, std::string>::iterator iter; std::map<std::string, std::string>::iterator iter;
iter = rand_record.find(nc.get()->imsi); iter = rand_record.find(nc.get()->imsi);
...@@ -1450,12 +1397,12 @@ bool amf_n1::_5g_aka_confirmation_from_ausf( ...@@ -1450,12 +1397,12 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(
msgBody = confirmationdata_j.dump(); msgBody = confirmationdata_j.dump();
// TODO: Should be updated // TODO: Should be updated
amf_n11_inst->curl_http_client(remoteUri, "PUT", msgBody, Response); amf_n11_inst->curl_http_client(remoteUri, "PUT", msgBody, response);
free_wrapper((void**) &resStar_s); free_wrapper((void**) &resStar_s);
try { try {
ConfirmationDataResponse confirmationdataresponse; ConfirmationDataResponse confirmationdataresponse;
nlohmann::json::parse(Response.c_str()).get_to(confirmationdataresponse); nlohmann::json::parse(response.c_str()).get_to(confirmationdataresponse);
unsigned char* kseaf_hex = unsigned char* kseaf_hex =
format_string_as_hex(confirmationdataresponse.getKseaf()); format_string_as_hex(confirmationdataresponse.getKseaf());
memcpy(nc.get()->_5g_av[0].kseaf, kseaf_hex, 32); memcpy(nc.get()->_5g_av[0].kseaf, kseaf_hex, 32);
...@@ -2004,7 +1951,6 @@ bool amf_n1::start_security_mode_control_procedure( ...@@ -2004,7 +1951,6 @@ bool amf_n1::start_security_mode_control_procedure(
nc.get()->is_current_security_available = true; nc.get()->is_current_security_available = true;
} }
// SecurityModeCommand* smc = new SecurityModeCommand();
std::unique_ptr<SecurityModeCommand> smc = std::unique_ptr<SecurityModeCommand> smc =
std::make_unique<SecurityModeCommand>(); std::make_unique<SecurityModeCommand>();
smc->setHeader(PLAIN_5GS_MSG); smc->setHeader(PLAIN_5GS_MSG);
...@@ -2201,7 +2147,6 @@ void amf_n1::security_mode_complete_handle( ...@@ -2201,7 +2147,6 @@ void amf_n1::security_mode_complete_handle(
uint8_t kgnb[32]; uint8_t kgnb[32];
uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8); uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Authentication_5gaka::derive_kgnb(0, 0x01, kamf, kgnb); Authentication_5gaka::derive_kgnb(0, 0x01, kamf, kgnb);
ncc = 1;
print_buffer("amf_n1", "kamf", kamf, 32); print_buffer("amf_n1", "kamf", kamf, 32);
// Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb); // Authentication_5gaka::derive_kgnb(ulcount, 0x01, kamf, kgnb);
bstring kgnb_bs = blk2bstr(kgnb, 32); bstring kgnb_bs = blk2bstr(kgnb, 32);
...@@ -2587,10 +2532,8 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2587,10 +2532,8 @@ void amf_n1::ul_nas_transport_handle(
Logger::amf_n1().error("Cannot decode Payload Container"); Logger::amf_n1().error("Cannot decode Payload Container");
return; return;
} }
// send_itti_to_smf_services_consumer(ran_ue_ngap_id, amf_ue_ngap_id, itti_nsmf_pdusession_create_sm_context* itti_msg =
// request_type, pdu_session_id, dnn, sm_msg); new itti_nsmf_pdusession_create_sm_context(TASK_AMF_N1, TASK_AMF_N11);
itti_smf_services_consumer* itti_msg =
new itti_smf_services_consumer(TASK_AMF_N1, TASK_AMF_N11);
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id; itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id; itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->req_type = request_type; itti_msg->req_type = request_type;
...@@ -2599,8 +2542,8 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2599,8 +2542,8 @@ void amf_n1::ul_nas_transport_handle(
itti_msg->sm_msg = sm_msg; itti_msg->sm_msg = sm_msg;
itti_msg->snssai.sST = snssai.sst; itti_msg->snssai.sST = snssai.sst;
itti_msg->snssai.sD = std::to_string(snssai.sd); itti_msg->snssai.sD = std::to_string(snssai.sd);
std::shared_ptr<itti_smf_services_consumer> i = std::shared_ptr<itti_nsmf_pdusession_create_sm_context> i =
std::shared_ptr<itti_smf_services_consumer>(itti_msg); std::shared_ptr<itti_nsmf_pdusession_create_sm_context>(itti_msg);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::amf_n1().error( Logger::amf_n1().error(
...@@ -2638,10 +2581,8 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2638,10 +2581,8 @@ void amf_n1::ul_nas_transport_handle(
Logger::amf_n1().error("Cannot decode Payload Container"); Logger::amf_n1().error("Cannot decode Payload Container");
return; return;
} }
// send_itti_to_smf_services_consumer(ran_ue_ngap_id, amf_ue_ngap_id, itti_nsmf_pdusession_create_sm_context* itti_msg =
// request_type, pdu_session_id, dnn, sm_msg); new itti_nsmf_pdusession_create_sm_context(TASK_AMF_N1, TASK_AMF_N11);
itti_smf_services_consumer* itti_msg =
new itti_smf_services_consumer(TASK_AMF_N1, TASK_AMF_N11);
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id; itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id; itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->req_type = request_type; itti_msg->req_type = request_type;
...@@ -2652,8 +2593,8 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2652,8 +2593,8 @@ void amf_n1::ul_nas_transport_handle(
itti_msg->snssai.sD = std::to_string(snssai.sd); itti_msg->snssai.sD = std::to_string(snssai.sd);
itti_msg->plmn.mnc = plmn.mnc; itti_msg->plmn.mnc = plmn.mnc;
itti_msg->plmn.mcc = plmn.mcc; itti_msg->plmn.mcc = plmn.mcc;
std::shared_ptr<itti_smf_services_consumer> i = std::shared_ptr<itti_nsmf_pdusession_create_sm_context> i =
std::shared_ptr<itti_smf_services_consumer>(itti_msg); std::shared_ptr<itti_nsmf_pdusession_create_sm_context>(itti_msg);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::amf_n1().error( Logger::amf_n1().error(
...@@ -2665,28 +2606,6 @@ void amf_n1::ul_nas_transport_handle( ...@@ -2665,28 +2606,6 @@ void amf_n1::ul_nas_transport_handle(
} }
} }
//------------------------------------------------------------------------------
void amf_n1::send_itti_to_smf_services_consumer(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, uint8_t request_type,
uint8_t pdu_session_id, bstring dnn, bstring sm_msg) {
itti_smf_services_consumer* itti_msg =
new itti_smf_services_consumer(TASK_AMF_N1, TASK_AMF_N11);
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->req_type = request_type;
itti_msg->pdu_sess_id = pdu_session_id;
itti_msg->dnn = dnn;
itti_msg->sm_msg = sm_msg;
std::shared_ptr<itti_smf_services_consumer> i =
std::shared_ptr<itti_smf_services_consumer>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_n1().error(
"Could not send ITTI message %s to task TASK_AMF_N11",
i->get_msg_name());
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n1::dump_nas_message(uint8_t* buf, int len) { void amf_n1::dump_nas_message(uint8_t* buf, int len) {
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)
......
...@@ -69,8 +69,6 @@ class amf_n1 { ...@@ -69,8 +69,6 @@ class amf_n1 {
SecurityHeaderType type, std::shared_ptr<nas_context> nc, SecurityHeaderType type, std::shared_ptr<nas_context> nc,
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg,
std::string snn, uint8_t ulCount); std::string snn, uint8_t ulCount);
void uplink_nas_msg_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg);
void uplink_nas_msg_handle( void uplink_nas_msg_handle(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg,
plmn_t plmn); plmn_t plmn);
...@@ -152,9 +150,6 @@ class amf_n1 { ...@@ -152,9 +150,6 @@ class amf_n1 {
void annex_a_4_33501( void annex_a_4_33501(
uint8_t ck[16], uint8_t ik[16], uint8_t* input, uint8_t rand[16], uint8_t ck[16], uint8_t ik[16], uint8_t* input, uint8_t rand[16],
std::string serving_network, uint8_t* output); std::string serving_network, uint8_t* output);
void send_itti_to_smf_services_consumer(
uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, uint8_t request_type,
uint8_t pdu_session_id, bstring dnn, bstring sm_msg);
void set_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t state); void set_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t state);
void get_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t& state); void get_5gmm_state(std::shared_ptr<nas_context> nc, _5gmm_state_t& state);
......
...@@ -95,10 +95,7 @@ void octet_stream_2_hex_stream(uint8_t* buf, int len, std::string& out) { ...@@ -95,10 +95,7 @@ void octet_stream_2_hex_stream(uint8_t* buf, int len, std::string& out) {
printf("n1sm buffer: %s\n", out.c_str()); printf("n1sm buffer: %s\n", out.c_str());
} }
/****************************************************/ //------------------------------------------------------------------------------
/** used to run NF(s) consumer, like smf_client ****/
/***************************************************/
void amf_n11_task(void*); void amf_n11_task(void*);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n11_task(void*) { void amf_n11_task(void*) {
...@@ -108,10 +105,10 @@ void amf_n11_task(void*) { ...@@ -108,10 +105,10 @@ void amf_n11_task(void*) {
std::shared_ptr<itti_msg> shared_msg = itti_inst->receive_msg(task_id); std::shared_ptr<itti_msg> shared_msg = itti_inst->receive_msg(task_id);
auto* msg = shared_msg.get(); auto* msg = shared_msg.get();
switch (msg->msg_type) { switch (msg->msg_type) {
case SMF_SERVICES_CONSUMER: { case NSMF_PDU_SESSION_CREATE_SM_CTX: {
Logger::amf_n11().info("Running SMF_SERVICES_CONSUMER"); Logger::amf_n11().info("Running ITTI_SMF_PDU_SESSION_CREATE_SM_CTX");
itti_smf_services_consumer* m = itti_nsmf_pdusession_create_sm_context* m =
dynamic_cast<itti_smf_services_consumer*>(msg); dynamic_cast<itti_nsmf_pdusession_create_sm_context*>(msg);
amf_n11_inst->handle_itti_message(ref(*m)); amf_n11_inst->handle_itti_message(ref(*m));
} break; } break;
case NSMF_PDU_SESSION_UPDATE_SM_CTX: { case NSMF_PDU_SESSION_UPDATE_SM_CTX: {
...@@ -121,9 +118,9 @@ void amf_n11_task(void*) { ...@@ -121,9 +118,9 @@ void amf_n11_task(void*) {
dynamic_cast<itti_nsmf_pdusession_update_sm_context*>(msg); dynamic_cast<itti_nsmf_pdusession_update_sm_context*>(msg);
amf_n11_inst->handle_itti_message(ref(*m)); amf_n11_inst->handle_itti_message(ref(*m));
} break; } break;
case PDU_SESS_RES_SET_RESP: { case PDU_SESSION_RESOURCE_SETUP_RESPONSE: {
Logger::amf_n11().info( Logger::amf_n11().info(
"Receive PDU Session Resource Setup Response, handling ..."); "Receive PDU Session Resource Setup response, handling ...");
itti_pdu_session_resource_setup_response* m = itti_pdu_session_resource_setup_response* m =
dynamic_cast<itti_pdu_session_resource_setup_response*>(msg); dynamic_cast<itti_pdu_session_resource_setup_response*>(msg);
amf_n11_inst->handle_itti_message(ref(*m)); amf_n11_inst->handle_itti_message(ref(*m));
...@@ -165,10 +162,10 @@ void amf_n11::handle_itti_message( ...@@ -165,10 +162,10 @@ void amf_n11::handle_itti_message(
itti_nsmf_pdusession_update_sm_context& itti_msg) { itti_nsmf_pdusession_update_sm_context& itti_msg) {
string ue_context_key = "app_ue_ranid_" + to_string(itti_msg.ran_ue_ngap_id) + string ue_context_key = "app_ue_ranid_" + to_string(itti_msg.ran_ue_ngap_id) +
":amfid_" + to_string(itti_msg.amf_ue_ngap_id); ":amfid_" + to_string(itti_msg.amf_ue_ngap_id);
std::shared_ptr<ue_context> uc; std::shared_ptr<ue_context> uc = {};
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key); uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
std::string supi;
std::string supi = {};
if (uc.get() != nullptr) { if (uc.get() != nullptr) {
supi = uc->supi; supi = uc->supi;
} }
...@@ -180,13 +177,13 @@ void amf_n11::handle_itti_message( ...@@ -180,13 +177,13 @@ void amf_n11::handle_itti_message(
std::shared_ptr<pdu_session_context> psc = {}; std::shared_ptr<pdu_session_context> psc = {};
if (!uc.get()->find_pdu_session_context(itti_msg.pdu_session_id, psc)) { if (!uc.get()->find_pdu_session_context(itti_msg.pdu_session_id, psc)) {
Logger::amf_n11().error( Logger::amf_n11().error(
"Could not find psu_session_context with SUPI %s, Failed", "Could not find pdu_session_context with SUPI %s, Failed",
supi.c_str()); supi.c_str());
return; return;
} }
std::string smf_addr; std::string smf_addr = {};
std::string smf_api_version; std::string smf_api_version = {};
if (!psc.get()->smf_available) { if (!psc.get()->smf_available) {
Logger::amf_n11().error("No SMF is available for this PDU session"); Logger::amf_n11().error("No SMF is available for this PDU session");
...@@ -195,7 +192,8 @@ void amf_n11::handle_itti_message( ...@@ -195,7 +192,8 @@ void amf_n11::handle_itti_message(
smf_api_version = psc->smf_api_version; smf_api_version = psc->smf_api_version;
} }
std::string smf_ip_addr, remote_uri; std::string smf_ip_addr = {};
std::string remote_uri = {};
// remove http port from the URI if existed // remove http port from the URI if existed
std::size_t found_port = smf_addr.find(":"); std::size_t found_port = smf_addr.find(":");
...@@ -217,31 +215,42 @@ void amf_n11::handle_itti_message( ...@@ -217,31 +215,42 @@ void amf_n11::handle_itti_message(
pdu_session_update_request["n2SmInfoType"] = itti_msg.n2sm_info_type; pdu_session_update_request["n2SmInfoType"] = itti_msg.n2sm_info_type;
pdu_session_update_request["n2SmInfo"]["contentId"] = "n2msg"; pdu_session_update_request["n2SmInfo"]["contentId"] = "n2msg";
std::string json_part = pdu_session_update_request.dump(); std::string json_part = pdu_session_update_request.dump();
std::string n2SmMsg; std::string n2SmMsg = {};
octet_stream_2_hex_stream( octet_stream_2_hex_stream(
(uint8_t*) bdata(itti_msg.n2sm), blength(itti_msg.n2sm), n2SmMsg); (uint8_t*) bdata(itti_msg.n2sm), blength(itti_msg.n2sm), n2SmMsg);
// For N2 HO
if (itti_msg.n2sm_info_type.compare("HANDOVER_REQUIRED") == 0) {
pdu_session_update_request["hoState"] = "PREPARING";
} else if (itti_msg.n2sm_info_type.compare("HANDOVER_REQ_ACK") == 0) {
pdu_session_update_request["hoState"] = "PREPARED";
} else if (itti_msg.n2sm_info_type.compare("SECONDARY_RAT_USAGE") == 0) {
pdu_session_update_request["hoState"] = "COMPLETED";
}
curl_http_client( curl_http_client(
remote_uri, json_part, "", n2SmMsg, supi, itti_msg.pdu_session_id); remote_uri, json_part, "", n2SmMsg, supi, itti_msg.pdu_session_id,
itti_msg.promise_id);
stacs.display(); stacs.display();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) { void amf_n11::handle_itti_message(itti_nsmf_pdusession_create_sm_context& smf) {
Logger::amf_n11().debug("Handle ITTI_SMF_SERVICES_CONSUMER"); Logger::amf_n11().debug("Handle ITTI SMF_PDU_SESSION_CREATE_SM_CTX");
std::shared_ptr<nas_context> nc;
std::shared_ptr<nas_context> nc = {};
nc = amf_n1_inst->amf_ue_id_2_nas_context(smf.amf_ue_ngap_id); nc = amf_n1_inst->amf_ue_id_2_nas_context(smf.amf_ue_ngap_id);
std::string supi = "imsi-" + nc.get()->imsi; std::string supi = "imsi-" + nc.get()->imsi;
string ue_context_key = "app_ue_ranid_" + string ue_context_key = "app_ue_ranid_" +
to_string(nc.get()->ran_ue_ngap_id) + ":amfid_" + to_string(nc.get()->ran_ue_ngap_id) + ":amfid_" +
to_string(nc.get()->amf_ue_ngap_id); to_string(nc.get()->amf_ue_ngap_id);
std::shared_ptr<ue_context> uc; std::shared_ptr<ue_context> uc = {};
Logger::amf_n11().info( Logger::amf_n11().info(
"Find ue_context in amf_app using UE Context Key: %s", "Find ue_context in amf_app using UE Context Key: %s",
ue_context_key.c_str()); ue_context_key.c_str());
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key); uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
std::shared_ptr<pdu_session_context> psc; std::shared_ptr<pdu_session_context> psc = {};
if (!uc.get()->find_pdu_session_context(smf.pdu_sess_id, psc)) { if (!uc.get()->find_pdu_session_context(smf.pdu_sess_id, psc)) {
psc = std::shared_ptr<pdu_session_context>(new pdu_session_context()); psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
uc.get()->add_pdu_session_context(smf.pdu_sess_id, psc); uc.get()->add_pdu_session_context(smf.pdu_sess_id, psc);
...@@ -258,7 +267,7 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) { ...@@ -258,7 +267,7 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) {
psc.get()->plmn.mnc = smf.plmn.mnc; psc.get()->plmn.mnc = smf.plmn.mnc;
// parse binary dnn and store // parse binary dnn and store
std::string dnn = "default"; std::string dnn = "default"; // If DNN doesn't available, use "default"
if ((smf.dnn != nullptr) && (blength(smf.dnn) > 0)) { if ((smf.dnn != nullptr) && (blength(smf.dnn) > 0)) {
char* tmp = bstring2charString(smf.dnn); char* tmp = bstring2charString(smf.dnn);
dnn = tmp; dnn = tmp;
...@@ -268,8 +277,8 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) { ...@@ -268,8 +277,8 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) {
Logger::amf_n11().debug("Requested DNN: %s", dnn.c_str()); Logger::amf_n11().debug("Requested DNN: %s", dnn.c_str());
psc.get()->dnn = dnn; psc.get()->dnn = dnn;
std::string smf_addr; std::string smf_addr = {};
std::string smf_api_version; std::string smf_api_version = {};
if (!psc.get()->smf_available) { if (!psc.get()->smf_available) {
if (amf_cfg.enable_smf_selection) { if (amf_cfg.enable_smf_selection) {
// use NRF to find suitable SMF based on snssai, plmn and dnn // use NRF to find suitable SMF based on snssai, plmn and dnn
...@@ -303,37 +312,6 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) { ...@@ -303,37 +312,6 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) {
psc.get()->isn2sm_avaliable = false; psc.get()->isn2sm_avaliable = false;
handle_pdu_session_initial_request( handle_pdu_session_initial_request(
supi, psc, smf_addr, smf_api_version, smf.sm_msg, dnn); supi, psc, smf_addr, smf_api_version, smf.sm_msg, dnn);
/*
if (psc.get()->isn1sm_avaliable && psc.get()->isn2sm_avaliable) {
// TODO: should be removed
itti_n1n2_message_transfer_request* itti_msg =
new itti_n1n2_message_transfer_request(TASK_AMF_N11, TASK_AMF_APP);
itti_msg->supi = supi;
uint8_t accept_len = blength(psc.get()->n1sm);
uint8_t* accept = (uint8_t*) calloc(1, accept_len);
memcpy(accept, (uint8_t*) bdata(psc.get()->n1sm), accept_len);
accept[2] = pti;
itti_msg->n1sm = blk2bstr(accept, accept_len);
free(accept);
itti_msg->is_n1sm_set = true;
itti_msg->n2sm = psc.get()->n2sm;
itti_msg->is_n2sm_set = true;
itti_msg->pdu_session_id = psc.get()->pdu_session_id;
std::shared_ptr<itti_n1n2_message_transfer_request> i =
std::shared_ptr<itti_n1n2_message_transfer_request>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_n11().error(
"Could not send ITTI message %s to task TASK_AMF_APP",
i->get_msg_name());
}
} else {
psc.get()->isn2sm_avaliable = false;
handle_pdu_session_initial_request(
supi, psc, smf_addr, smf_api_version, smf.sm_msg, dnn);
}
*/
} break; } break;
case EXISTING_PDU_SESSION: { case EXISTING_PDU_SESSION: {
// TODO: // TODO:
...@@ -359,7 +337,8 @@ void amf_n11::send_pdu_session_update_sm_context_request( ...@@ -359,7 +337,8 @@ void amf_n11::send_pdu_session_update_sm_context_request(
"ID %d)", "ID %d)",
supi.c_str(), psc.get()->pdu_session_id); supi.c_str(), psc.get()->pdu_session_id);
std::string smf_ip_addr, remote_uri; std::string smf_ip_addr = {};
std::string remote_uri = {};
// remove http port from the URI if existed // remove http port from the URI if existed
std::size_t found_port = smf_addr.find(":"); std::size_t found_port = smf_addr.find(":");
if (found_port != std::string::npos) if (found_port != std::string::npos)
...@@ -379,7 +358,7 @@ void amf_n11::send_pdu_session_update_sm_context_request( ...@@ -379,7 +358,7 @@ void amf_n11::send_pdu_session_update_sm_context_request(
pdu_session_update_request["n1SmMsg"]["contentId"] = "n1SmMsg"; pdu_session_update_request["n1SmMsg"]["contentId"] = "n1SmMsg";
std::string json_part = pdu_session_update_request.dump(); std::string json_part = pdu_session_update_request.dump();
std::string n1SmMsg; std::string n1SmMsg = {};
octet_stream_2_hex_stream((uint8_t*) bdata(sm_msg), blength(sm_msg), n1SmMsg); octet_stream_2_hex_stream((uint8_t*) bdata(sm_msg), blength(sm_msg), n1SmMsg);
curl_http_client( curl_http_client(
remote_uri, json_part, n1SmMsg, "", supi, psc.get()->pdu_session_id); remote_uri, json_part, n1SmMsg, "", supi, psc.get()->pdu_session_id);
...@@ -425,8 +404,9 @@ void amf_n11::handle_pdu_session_initial_request( ...@@ -425,8 +404,9 @@ void amf_n11::handle_pdu_session_initial_request(
["contentId"] = "n1SmMsg"; ["contentId"] = "n1SmMsg";
std::string json_part = pdu_session_establishment_request.dump(); std::string json_part = pdu_session_establishment_request.dump();
std::string n1SmMsg; std::string n1SmMsg = {};
octet_stream_2_hex_stream((uint8_t*) bdata(sm_msg), blength(sm_msg), n1SmMsg); octet_stream_2_hex_stream((uint8_t*) bdata(sm_msg), blength(sm_msg), n1SmMsg);
curl_http_client( curl_http_client(
remote_uri, json_part, n1SmMsg, "", supi, psc.get()->pdu_session_id); remote_uri, json_part, n1SmMsg, "", supi, psc.get()->pdu_session_id);
} }
...@@ -444,7 +424,8 @@ void amf_n11::handle_itti_message( ...@@ -444,7 +424,8 @@ void amf_n11::handle_itti_message(
return; return;
} }
string smf_addr, smf_api_version; string smf_addr = {};
std::string smf_api_version = {};
if (!psc.get()->smf_available) { if (!psc.get()->smf_available) {
Logger::amf_n11().error("No SMF is available for this PDU session"); Logger::amf_n11().error("No SMF is available for this PDU session");
...@@ -526,13 +507,14 @@ void amf_n11::handle_post_sm_context_response_error( ...@@ -526,13 +507,14 @@ void amf_n11::handle_post_sm_context_response_error(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n11::curl_http_client( void amf_n11::curl_http_client(
std::string remoteUri, std::string jsonData, std::string n1SmMsg, std::string remoteUri, std::string jsonData, std::string n1SmMsg,
std::string n2SmMsg, std::string supi, uint8_t pdu_session_id) { std::string n2SmMsg, std::string supi, uint8_t pdu_session_id,
uint32_t promise_id) {
Logger::amf_n11().debug("Call SMF service: %s", remoteUri.c_str()); Logger::amf_n11().debug("Call SMF service: %s", remoteUri.c_str());
uint8_t number_parts = 0; uint8_t number_parts = 0;
mime_parser parser = {}; mime_parser parser = {};
std::string body; std::string body = {};
std::shared_ptr<pdu_session_context> psc; std::shared_ptr<pdu_session_context> psc = {};
if (!amf_app_inst->find_pdu_session_context(supi, pdu_session_id, psc)) { if (!amf_app_inst->find_pdu_session_context(supi, pdu_session_id, psc)) {
Logger::amf_n11().warn( Logger::amf_n11().warn(
...@@ -580,12 +562,12 @@ void amf_n11::curl_http_client( ...@@ -580,12 +562,12 @@ void amf_n11::curl_http_client(
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, SMF_CURL_TIMEOUT_MS); curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, SMF_CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str()); curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
// Response information. // Response information
long httpCode = {0}; long httpCode = {0};
std::unique_ptr<std::string> httpData(new std::string()); std::unique_ptr<std::string> httpData(new std::string());
std::unique_ptr<std::string> httpHeaderData(new std::string()); std::unique_ptr<std::string> httpHeaderData(new std::string());
// Hook up data handling function. // Hook up data handling function
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get()); curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
curl_easy_setopt(curl, CURLOPT_HEADERDATA, httpHeaderData.get()); curl_easy_setopt(curl, CURLOPT_HEADERDATA, httpHeaderData.get());
...@@ -598,14 +580,14 @@ void amf_n11::curl_http_client( ...@@ -598,14 +580,14 @@ void amf_n11::curl_http_client(
// get cause from the response // get cause from the response
std::string response = *httpData.get(); std::string response = *httpData.get();
std::string json_data_response = ""; std::string json_data_response = {};
std::string n1sm = ""; std::string n1sm = {};
std::string n2sm = ""; std::string n2sm = {};
nlohmann::json response_data = {}; nlohmann::json response_data = {};
bstring n1sm_hex, n2sm_hex; bstring n1sm_hex, n2sm_hex;
Logger::amf_n11().debug("Get response with HTTP code (%d)", httpCode); Logger::amf_n11().debug("Get response with HTTP code (%d)", httpCode);
Logger::amf_n11().debug("Response body %s", response.c_str()); Logger::amf_n11().debug("response body %s", response.c_str());
if (static_cast<http_response_codes_e>(httpCode) == if (static_cast<http_response_codes_e>(httpCode) ==
http_response_codes_e::HTTP_RESPONSE_CODE_0) { http_response_codes_e::HTTP_RESPONSE_CODE_0) {
...@@ -615,6 +597,8 @@ void amf_n11::curl_http_client( ...@@ -615,6 +597,8 @@ void amf_n11::curl_http_client(
// free curl before returning // free curl before returning
curl_slist_free_all(headers); curl_slist_free_all(headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup();
free_wrapper((void**) &body_data);
return; return;
} }
...@@ -633,9 +617,12 @@ void amf_n11::curl_http_client( ...@@ -633,9 +617,12 @@ void amf_n11::curl_http_client(
Logger::amf_n11().error("There's no content in the response"); Logger::amf_n11().error("There's no content in the response");
curl_slist_free_all(headers); curl_slist_free_all(headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup();
free_wrapper((void**) &body_data);
// TODO: send context response error // TODO: send context response error
return; return;
} }
// TODO: HO
// Transfer N1 to gNB/UE if available // Transfer N1 to gNB/UE if available
if (number_parts > 1) { if (number_parts > 1) {
...@@ -657,8 +644,7 @@ void amf_n11::curl_http_client( ...@@ -657,8 +644,7 @@ void amf_n11::curl_http_client(
std::string cause = response_data["error"]["cause"]; std::string cause = response_data["error"]["cause"];
Logger::amf_n11().debug( Logger::amf_n11().debug(
"Call Network Function services failure (with cause %s)", "Network Function services failure (with cause %s)", cause.c_str());
cause.c_str());
// if (!cause.compare("DNN_DENIED")) // if (!cause.compare("DNN_DENIED"))
handle_post_sm_context_response_error( handle_post_sm_context_response_error(
httpCode, cause, n1sm_hex, supi, pdu_session_id); httpCode, cause, n1sm_hex, supi, pdu_session_id);
...@@ -682,19 +668,45 @@ void amf_n11::curl_http_client( ...@@ -682,19 +668,45 @@ void amf_n11::curl_http_client(
} }
} }
// Transfer N1/N2 to gNB/UE if available
if (number_parts > 1) {
try { try {
response_data = nlohmann::json::parse(json_data_response); response_data = nlohmann::json::parse(json_data_response);
} catch (nlohmann::json::exception& e) { } catch (nlohmann::json::exception& e) {
Logger::amf_n11().warn( Logger::amf_n11().warn("Could not get Json content from the response");
"Could not get Json content from the response");
curl_slist_free_all(headers); curl_slist_free_all(headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_global_cleanup();
free_wrapper((void**) &body_data);
// TODO: // TODO:
return; return;
} }
// For N2 HO
bool is_ho_procedure = false;
std::string promise_result = {};
if (response_data.find("hoState") != response_data.end()) {
is_ho_procedure = true;
std::string ho_state = {};
response_data.at("hoState").get_to(ho_state);
if (ho_state.compare("COMPLETED") == 0) {
if (response_data.find("pduSessionId") != response_data.end())
response_data.at("pduSessionId").get_to(promise_result);
} else if (number_parts > 1) {
promise_result = n1sm; // actually, N2 SM Info
}
}
// Notify to the result
if ((promise_id > 0) and (is_ho_procedure)) {
amf_app_inst->trigger_process_response(promise_id, promise_result);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
free_wrapper((void**) &body_data);
return;
}
// Transfer N1/N2 to gNB/UE if available
if (number_parts > 1) {
itti_n1n2_message_transfer_request* itti_msg = itti_n1n2_message_transfer_request* itti_msg =
new itti_n1n2_message_transfer_request(TASK_AMF_N11, TASK_AMF_APP); new itti_n1n2_message_transfer_request(TASK_AMF_N11, TASK_AMF_APP);
...@@ -768,7 +780,7 @@ bool amf_n11::discover_smf( ...@@ -768,7 +780,7 @@ bool amf_n11::discover_smf(
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, NRF_CURL_TIMEOUT_MS); curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, NRF_CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str()); curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
// Response information. // Response information
long httpCode = {0}; long httpCode = {0};
std::unique_ptr<std::string> httpData(new std::string()); std::unique_ptr<std::string> httpData(new std::string());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
...@@ -963,7 +975,7 @@ bool amf_n11::send_ue_authentication_request( ...@@ -963,7 +975,7 @@ bool amf_n11::send_ue_authentication_request(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE); curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
} }
// Response information. // Response information
long httpCode = {0}; long httpCode = {0};
std::unique_ptr<std::string> httpData(new std::string()); std::unique_ptr<std::string> httpData(new std::string());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
...@@ -1008,8 +1020,8 @@ bool amf_n11::send_ue_authentication_request( ...@@ -1008,8 +1020,8 @@ bool amf_n11::send_ue_authentication_request(
// From AMF_N1, need to be reworked // From AMF_N1, need to be reworked
void amf_n11::curl_http_client( void amf_n11::curl_http_client(
std::string remoteUri, std::string Method, std::string msgBody, std::string remoteUri, std::string Method, std::string msgBody,
std::string& Response) { std::string& response) {
Logger::amf_n1().info("Send HTTP message with body %s", msgBody.c_str()); Logger::amf_n11().info("Send HTTP message with body %s", msgBody.c_str());
uint32_t str_len = msgBody.length(); uint32_t str_len = msgBody.length();
char* body_data = (char*) malloc(str_len + 1); char* body_data = (char*) malloc(str_len + 1);
...@@ -1040,8 +1052,6 @@ void amf_n11::curl_http_client( ...@@ -1040,8 +1052,6 @@ void amf_n11::curl_http_client(
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT_MS); curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1); curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str()); curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
// Logger::amf_n1().info("[CURL] request sent by interface " +
// udm_cfg.nudr.if_name);
// Response information. // Response information.
long httpCode = {0}; long httpCode = {0};
...@@ -1062,14 +1072,14 @@ void amf_n11::curl_http_client( ...@@ -1062,14 +1072,14 @@ void amf_n11::curl_http_client(
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
// get the response // get the response
std::string response = *httpData.get(); response = *httpData.get();
std::string json_data_response = ""; std::string json_data_response = {};
std::string resMsg = ""; std::string resMsg = {};
bool is_response_ok = true; bool is_response_ok = true;
Logger::amf_n1().info("Get response with httpcode (%d)", httpCode); Logger::amf_n11().info("Get response with httpcode (%d)", httpCode);
if (httpCode == 0) { if (httpCode == 0) {
Logger::amf_n1().info( Logger::amf_n11().info(
"Cannot get response when calling %s", remoteUri.c_str()); "Cannot get response when calling %s", remoteUri.c_str());
// free curl before returning // free curl before returning
curl_slist_free_all(headers); curl_slist_free_all(headers);
...@@ -1082,34 +1092,33 @@ void amf_n11::curl_http_client( ...@@ -1082,34 +1092,33 @@ void amf_n11::curl_http_client(
if (httpCode != 200 && httpCode != 201 && httpCode != 204) { if (httpCode != 200 && httpCode != 201 && httpCode != 204) {
is_response_ok = false; is_response_ok = false;
if (response.size() < 1) { if (response.size() < 1) {
Logger::amf_n1().info("There's no content in the response"); Logger::amf_n11().info("There's no content in the response");
// TODO: send context response error // TODO: send context response error
return; return;
} }
Logger::amf_n1().info("Wrong response code"); Logger::amf_n11().debug("Error with response code %d", httpCode);
return; return;
} }
else { else {
Response = *httpData.get(); response = *httpData.get();
} }
if (!is_response_ok) { if (!is_response_ok) {
try { try {
response_data = nlohmann::json::parse(json_data_response); response_data = nlohmann::json::parse(json_data_response);
} catch (nlohmann::json::exception& e) { } catch (nlohmann::json::exception& e) {
Logger::amf_n1().info("Could not get Json content from the response"); Logger::amf_n11().info("Could not get Json content from the response");
// Set the default Cause // Set the default Cause
response_data["error"]["cause"] = "504 Gateway Timeout"; response_data["error"]["cause"] = "504 Gateway Timeout";
} }
Logger::amf_n1().info( Logger::amf_n11().info(
"Get response with jsonData: %s", json_data_response.c_str()); "Get response with jsonData: %s", json_data_response.c_str());
std::string cause = response_data["error"]["cause"]; std::string cause = response_data["error"]["cause"];
Logger::amf_n1().info("Call Network Function services failure"); Logger::amf_n11().info("Call Network Function services failure");
Logger::amf_n1().info("Cause value: %s", cause.c_str()); Logger::amf_n11().info("Cause value: %s", cause.c_str());
} }
curl_slist_free_all(headers); curl_slist_free_all(headers);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
......
...@@ -45,7 +45,7 @@ class amf_n11 { ...@@ -45,7 +45,7 @@ class amf_n11 {
amf_n11(); amf_n11();
~amf_n11(); ~amf_n11();
void handle_itti_message(itti_smf_services_consumer&); void handle_itti_message(itti_nsmf_pdusession_create_sm_context&);
void handle_pdu_session_initial_request( void handle_pdu_session_initial_request(
std::string supi, std::shared_ptr<pdu_session_context> psc, std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, std::string smf_api_version, bstring sm_msg, std::string smf_addr, std::string smf_api_version, bstring sm_msg,
...@@ -66,11 +66,12 @@ class amf_n11 { ...@@ -66,11 +66,12 @@ class amf_n11 {
void curl_http_client( void curl_http_client(
std::string remoteUri, std::string jsonData, std::string n1SmMsg, std::string remoteUri, std::string jsonData, std::string n1SmMsg,
std::string n2SmMsg, std::string supi, uint8_t pdu_session_id); std::string n2SmMsg, std::string supi, uint8_t pdu_session_id,
uint32_t promise_id = 0);
void curl_http_client( void curl_http_client(
std::string remoteUri, std::string Method, std::string msgBody, std::string remoteUri, std::string Method, std::string msgBody,
std::string& Response); std::string& response);
bool discover_smf( bool discover_smf(
std::string& smf_addr, std::string& smf_api_version, std::string& smf_addr, std::string& smf_api_version,
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "PduSessionResourceReleaseCommand.hpp" #include "PduSessionResourceReleaseCommand.hpp"
#include "PduSessionResourceSetupRequest.hpp" #include "PduSessionResourceSetupRequest.hpp"
#include "UEContextReleaseCommand.hpp" #include "UEContextReleaseCommand.hpp"
#include "HandoverPreparationFailure.hpp"
#include "amf_app.hpp" #include "amf_app.hpp"
#include "amf_config.hpp" #include "amf_config.hpp"
#include "amf_n1.hpp" #include "amf_n1.hpp"
...@@ -51,6 +52,11 @@ ...@@ -51,6 +52,11 @@
#include "logger.hpp" #include "logger.hpp"
#include "sctp_server.hpp" #include "sctp_server.hpp"
#include <boost/chrono.hpp>
#include <boost/chrono/chrono.hpp>
#include <boost/chrono/duration.hpp>
#include <boost/chrono/system_clocks.hpp>
extern "C" { extern "C" {
#include "dynamic_memory_check.h" #include "dynamic_memory_check.h"
} }
...@@ -69,12 +75,6 @@ extern statistics stacs; ...@@ -69,12 +75,6 @@ extern statistics stacs;
extern void print_buffer( extern void print_buffer(
const std::string app, const std::string commit, uint8_t* buf, int len); const std::string app, const std::string commit, uint8_t* buf, int len);
uint32_t ran_id_Global = 0;
uint32_t AMF_TARGET_ran_id_global = 0;
sctp_assoc_id_t downlink_sctp_assoc_id = 0;
sctp_assoc_id_t source_assoc_id = 0;
int ncc = 0;
void amf_n2_task(void*); void amf_n2_task(void*);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -175,7 +175,10 @@ void amf_n2_task(void* args_p) { ...@@ -175,7 +175,10 @@ void amf_n2_task(void* args_p) {
case HANDOVER_REQUIRED: { case HANDOVER_REQUIRED: {
Logger::amf_n2().info("Received HANDOVER_REQUIRED message,handling"); Logger::amf_n2().info("Received HANDOVER_REQUIRED message,handling");
itti_handover_required* m = dynamic_cast<itti_handover_required*>(msg); itti_handover_required* m = dynamic_cast<itti_handover_required*>(msg);
amf_n2_inst->handle_itti_message(ref(*m)); if (!amf_n2_inst->handle_itti_message(ref(*m)))
amf_n2_inst->send_handover_preparation_failure(
m->handoverReq->getAmfUeNgapId(),
m->handoverReq->getRanUeNgapId(), m->assoc_id);
} break; } break;
case HANDOVER_REQUEST_ACK: { case HANDOVER_REQUEST_ACK: {
Logger::amf_n2().info("Received HANDOVER_REQUEST_ACK message,handling"); Logger::amf_n2().info("Received HANDOVER_REQUEST_ACK message,handling");
...@@ -188,11 +191,11 @@ void amf_n2_task(void* args_p) { ...@@ -188,11 +191,11 @@ void amf_n2_task(void* args_p) {
itti_handover_notify* m = dynamic_cast<itti_handover_notify*>(msg); itti_handover_notify* m = dynamic_cast<itti_handover_notify*>(msg);
amf_n2_inst->handle_itti_message(ref(*m)); amf_n2_inst->handle_itti_message(ref(*m));
} break; } break;
case UPLINKRANSTATUSTRANSFER: { case UPLINK_RAN_STATUS_TRANSFER: {
Logger::amf_n2().info( Logger::amf_n2().info(
"Received UPLINKRANSTATUSTRANSFER message,handling"); "Received UPLINK_RAN_STATUS_TRANSFER message,handling");
itti_uplinkranstatsutransfer* m = itti_uplink_ran_status_transfer* m =
dynamic_cast<itti_uplinkranstatsutransfer*>(msg); dynamic_cast<itti_uplink_ran_status_transfer*>(msg);
amf_n2_inst->handle_itti_message(ref(*m)); amf_n2_inst->handle_itti_message(ref(*m));
} break; } break;
default: default:
...@@ -667,6 +670,7 @@ void amf_n2::handle_itti_message(itti_dl_nas_transport& dl_nas_transport) { ...@@ -667,6 +670,7 @@ void amf_n2::handle_itti_message(itti_dl_nas_transport& dl_nas_transport) {
return; return;
} }
unc.get()->amf_ue_ngap_id = dl_nas_transport.amf_ue_ngap_id; unc.get()->amf_ue_ngap_id = dl_nas_transport.amf_ue_ngap_id;
set_amf_ue_ngap_id_2_ue_ngap_context(unc.get()->amf_ue_ngap_id, unc);
unc.get()->ng_ue_state = NGAP_UE_CONNECTED; unc.get()->ng_ue_state = NGAP_UE_CONNECTED;
DownLinkNasTransportMsg* ngap_msg = new DownLinkNasTransportMsg(); DownLinkNasTransportMsg* ngap_msg = new DownLinkNasTransportMsg();
ngap_msg->setMessageType(); ngap_msg->setMessageType();
...@@ -690,6 +694,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) { ...@@ -690,6 +694,7 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
"Illegal UE with ran_ue_ngap_id (0x%x)", itti_msg.ran_ue_ngap_id); "Illegal UE with ran_ue_ngap_id (0x%x)", itti_msg.ran_ue_ngap_id);
return; return;
} }
unc.get()->ncc = 1;
std::shared_ptr<gnb_context> gc; std::shared_ptr<gnb_context> gc;
gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id); gc = assoc_id_2_gnb_context(unc.get()->gnb_assoc_id);
if (gc.get() == nullptr) { if (gc.get() == nullptr) {
...@@ -1045,115 +1050,123 @@ void amf_n2::handle_itti_message( ...@@ -1045,115 +1050,123 @@ void amf_n2::handle_itti_message(
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_handover_required& itti_msg) { bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
// TODO: to be tesbed/clean up // TODO: Experimental procedure, to be tested
ncc++; unsigned long amf_ue_ngap_id = itti_msg.handoverReq->getAmfUeNgapId();
unsigned long amf_ue_ngap_id = itti_msg.handvoerRequ->getAmfUeNgapId(); uint32_t ran_ue_ngap_id = itti_msg.handoverReq->getRanUeNgapId();
uint32_t ran_ue_ngap_id = itti_msg.handvoerRequ->getRanUeNgapId();
ran_id_Global = ran_ue_ngap_id; std::shared_ptr<gnb_context> gc = {};
source_assoc_id = itti_msg.assoc_id;
std::shared_ptr<gnb_context> gc;
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) { if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"gNB with assoc_id (%d) is illegal", itti_msg.assoc_id); "gNB with assoc_id (%d) is illegal", itti_msg.assoc_id);
return; return false;
} }
gc = assoc_id_2_gnb_context(itti_msg.assoc_id); gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
std::shared_ptr<ue_ngap_context> unc;
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) { std::shared_ptr<ue_ngap_context> unc = {};
Logger::amf_n2().error(
"UE with ran_ue_ngap_id (0x%x) is not attached to gNB with "
"assoc_id (%d)",
ran_ue_ngap_id, itti_msg.assoc_id);
return;
}
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) { if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"No UE NGAP context with ran_ue_ngap_id(%d)", ran_ue_ngap_id); "No UE NGAP context with ran_ue_ngap_id (0x%x)", ran_ue_ngap_id);
return; return false;
} }
unc = ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id); unc = ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id);
if (unc.get()->amf_ue_ngap_id != amf_ue_ngap_id) { if (unc.get()->amf_ue_ngap_id != amf_ue_ngap_id) {
Logger::amf_n2().error( Logger::amf_n2().error(
"The requested UE (amf_ue_ngap_id:0x%x) is not valid, existed UE " "The requested UE (amf_ue_ngap_id:0x%x) is not valid, existed UE "
"which's amf_ue_ngap_id(0x%x)", "with amf_ue_ngap_id (0x%x)",
amf_ue_ngap_id, unc.get()->amf_ue_ngap_id); amf_ue_ngap_id, unc.get()->amf_ue_ngap_id);
return false;
} }
if (itti_msg.handvoerRequ->getHandoverType() != Ngap_HandoverType_intra5gs) {
Logger::amf_n2().error( if (itti_msg.handoverReq->getHandoverType() != Ngap_HandoverType_intra5gs) {
"Received Handover Required message,but handover type is not " Logger::amf_n2().error("Handover Type is not supported");
"Ngap_HandoverType_intra5gs"); return false;
return;
} }
if (itti_msg.handvoerRequ->getChoiceOfCause() != Ngap_Cause_PR_radioNetwork) {
Logger::amf_n2().error( if (itti_msg.handoverReq->getChoiceOfCause() != Ngap_Cause_PR_radioNetwork) {
"Received Handover Required message,but Cause Of Choice is wrong"); Logger::amf_n2().error("CHOICE Cause Group is not supported");
return; return false;
} }
if (itti_msg.handvoerRequ->getCauseValue() !=
if (itti_msg.handoverReq->getCauseValue() !=
Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason) { Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason) {
Logger::amf_n2().error( Logger::amf_n2().error("Radio Network Layer Cause is not supported");
"Received Handover Required message, but value of Cause is wrong"); return false;
return;
} }
if (itti_msg.handvoerRequ->getDirectForwardingPathAvailability() !=
if (itti_msg.handoverReq->getDirectForwardingPathAvailability() !=
Ngap_DirectForwardingPathAvailability_direct_path_available) { Ngap_DirectForwardingPathAvailability_direct_path_available) {
Logger::amf_n2().error( Logger::amf_n2().error(
"Received Handover Required message, but " "DirectForwardingPathAvailability must be "
"DirectForwardingPathAvailability is wrong"); "Ngap_DirectForwardingPathAvailability_direct_path_available!");
return; return false;
} }
unc.get()->gnb_assoc_id = itti_msg.assoc_id;
unc.get()->ncc++;
unc.get()->ng_ue_state = NGAP_UE_HANDOVER;
GlobalgNBId* TargetGlobalgNBId = new GlobalgNBId(); GlobalgNBId* TargetGlobalgNBId = new GlobalgNBId();
itti_msg.handvoerRequ->getGlobalRanNodeId(TargetGlobalgNBId); itti_msg.handoverReq->getGlobalRanNodeId(TargetGlobalgNBId);
PlmnId* plmn = new PlmnId(); PlmnId* plmn = new PlmnId();
GNB_ID* gnbid = new GNB_ID(); GNB_ID* gnbid = new GNB_ID();
TargetGlobalgNBId->getGlobalgNBId(plmn, gnbid); TargetGlobalgNBId->getGlobalgNBId(plmn, gnbid);
string mcc, mnc; std::string mcc = {};
std::string mnc = {};
plmn->getMcc(mcc); plmn->getMcc(mcc);
plmn->getMnc(mnc); plmn->getMnc(mnc);
printf(
"Handover required: Target ID GlobalRanNodeID PLmn (mcc: %s, mnc: %s, " Logger::amf_n2().debug(
"gnbid: %ld)\n", "Handover Required: Target ID GlobalRanNodeID PLmn (mcc: %s, mnc: %s, "
"gnbid: %ld)",
mcc.c_str(), mnc.c_str(), gnbid->getValue()); mcc.c_str(), mnc.c_str(), gnbid->getValue());
TAI* tai = new TAI(); TAI* tai = new TAI();
itti_msg.handvoerRequ->getTAI(tai); itti_msg.handoverReq->getTAI(tai);
PlmnId* plmnOfTAI = new PlmnId(); PlmnId* plmnOfTAI = new PlmnId();
TAC* tac = new TAC(); TAC* tac = new TAC();
tai->getTAI(plmnOfTAI, tac); tai->getTAI(plmnOfTAI, tac);
string mccOfselectTAI, mncOfselectTAI; string mccOfselectTAI, mncOfselectTAI;
plmn->getMcc(mccOfselectTAI); plmn->getMcc(mccOfselectTAI);
plmn->getMnc(mncOfselectTAI); plmn->getMnc(mncOfselectTAI);
printf( Logger::amf_n2().debug(
"Handover required:Target ID selectedTAI PLmn=mcc%s mnc%s tac=%x\n", "Handover Required: Target ID selected TAI PLMN (mcc %s, mnc %s, tac %x)",
mccOfselectTAI.c_str(), mncOfselectTAI.c_str(), tac->getTac()); mccOfselectTAI.c_str(), mncOfselectTAI.c_str(), tac->getTac());
std::vector<PDUSessionResourceItem_t> List_HORqd;
if (!itti_msg.handvoerRequ->getPDUSessionResourceList(List_HORqd)) {
Logger::ngap().error(
"Decoding HandoverRequiredMsg getPDUSessionResourceList IE error");
return;
}
OCTET_STRING_t sourceTotarget; OCTET_STRING_t sourceTotarget;
sourceTotarget = sourceTotarget =
itti_msg.handvoerRequ->getSourceToTarget_TransparentContainer(); itti_msg.handoverReq->getSourceToTarget_TransparentContainer();
// send handover request to target gnb // TODO: T-AMF selection, for now use the same AMF
std::unique_ptr<HandoverRequest> handoverrequest =
// Create HandoverRequest message to be sent to target gNB
std::unique_ptr<HandoverRequest> handover_request =
std::make_unique<HandoverRequest>(); std::make_unique<HandoverRequest>();
handoverrequest->setMessageType(); handover_request->setMessageType();
handoverrequest->setAmfUeNgapId(amf_ue_ngap_id); handover_request->setAmfUeNgapId(amf_ue_ngap_id);
handoverrequest->setHandoverType(0); handover_request->setHandoverType(0);
handoverrequest->setCause( handover_request->setCause(
Ngap_Cause_PR_radioNetwork, Ngap_Cause_PR_radioNetwork,
Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason); Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason);
handoverrequest->setUEAggregateMaximumBitRate(300000000, 100000000); handover_request->setUEAggregateMaximumBitRate(
handoverrequest->setUESecurityCapabilities(0xe000, 0xe000, 0xe000, 0xe000); 300000000, 100000000); // TODO: remove hardcoded values
handover_request->setUESecurityCapabilities(
0xe000, 0xe000, 0xe000, 0xe000); // TODO: remove hardcoded values
S_NSSAI s_nssai; // Allowed NSSAI
s_nssai.setSst("01");
std::vector<S_NSSAI> Allowed_Nssai; std::vector<S_NSSAI> Allowed_Nssai;
for (int i = 0; i < amf_cfg.plmn_list.size(); i++) {
for (int j = 0; j < amf_cfg.plmn_list[i].slice_list.size(); j++) {
SliceSupportItem_t s_tmp;
S_NSSAI s_nssai = {};
s_nssai.setSst(amf_cfg.plmn_list[i].slice_list[j].sST);
s_nssai.setSd(amf_cfg.plmn_list[i].slice_list[j].sD);
Allowed_Nssai.push_back(s_nssai); Allowed_Nssai.push_back(s_nssai);
// handoverrequest->setAllowedNSSAI(Allowed_Nssai); }
Guami_t guami; }
Guami_t guami = {};
guami.mcc = amf_cfg.guami.mcc; guami.mcc = amf_cfg.guami.mcc;
guami.mnc = amf_cfg.guami.mnc; guami.mnc = amf_cfg.guami.mnc;
guami.regionID = amf_cfg.guami.regionID; guami.regionID = amf_cfg.guami.regionID;
...@@ -1167,9 +1180,6 @@ void amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1167,9 +1180,6 @@ void amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
m_aMFRegionID->setAMFRegionID(guami.regionID); m_aMFRegionID->setAMFRegionID(guami.regionID);
m_aMFSetID->setAMFSetID(guami.AmfSetID); m_aMFSetID->setAMFSetID(guami.AmfSetID);
m_aMFPointer->setAMFPointer(guami.AmfPointer); m_aMFPointer->setAMFPointer(guami.AmfPointer);
// handoverrequest->setMobilityRestrictionList(m_plmnId);
// handoverrequest->setGUAMI(m_plmnId, m_aMFRegionID, m_aMFSetID,
// m_aMFPointer);
std::shared_ptr<nas_context> nc = std::shared_ptr<nas_context> nc =
amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id); amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
...@@ -1177,15 +1187,14 @@ void amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1177,15 +1187,14 @@ void amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
uint8_t* kamf = nc.get()->kamf[secu->vector_pointer]; uint8_t* kamf = nc.get()->kamf[secu->vector_pointer];
uint8_t kgnb[32]; uint8_t kgnb[32];
uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8); uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Logger::amf_n1().debug("uplink count(%d)", secu->ul_count.seq_num); Logger::amf_n1().debug("Uplink count (%d)", secu->ul_count.seq_num);
uint8_t knh[32]; uint8_t knh[32];
Authentication_5gaka::handover_ncc_derive_knh( Authentication_5gaka::handover_ncc_derive_knh(
ulcount, 0x01, kamf, kgnb, knh, ncc); ulcount, 0x01, kamf, kgnb, knh, unc.get()->ncc);
bstring knh_bs = blk2bstr(knh, 32); bstring knh_bs = blk2bstr(knh, 32);
handoverrequest->setSecurityContext( handover_request->setSecurityContext(
ncc /*NCC count*/, (uint8_t*) bdata(knh_bs)); unc.get()->ncc /*NCC count*/, (uint8_t*) bdata(knh_bs));
// handoverrequest->setSourceToTarget_TransparentContainer(sourceTotarget);
string supi = "imsi-" + nc.get()->imsi; string supi = "imsi-" + nc.get()->imsi;
// Get all the active PDU sessions // Get all the active PDU sessions
...@@ -1194,182 +1203,364 @@ void amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1194,182 +1203,364 @@ void amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
Logger::amf_n2().warn("Error when retrieving the active PDU Sessions!"); Logger::amf_n2().warn("Error when retrieving the active PDU Sessions!");
} }
std::vector<PDUSessionResourceItem_t> pdu_session_resource_list;
if (!itti_msg.handoverReq->getPDUSessionResourceList(
pdu_session_resource_list)) {
Logger::ngap().warn(
"Decoding PDU Session Resource List IE error or IE missing");
}
std::vector<PDUSessionResourceSetupRequestItem_t> list; std::vector<PDUSessionResourceSetupRequestItem_t> list;
PDUSessionResourceSetupRequestItem_t item; PDUSessionResourceSetupRequestItem_t item = {};
std::map<uint8_t, boost::shared_future<std::string>> curl_responses;
for (auto pdu_session_resource : pdu_session_resource_list) {
std::shared_ptr<pdu_session_context> psc = {};
if (amf_app_inst->find_pdu_session_context(
supi, pdu_session_resource.pduSessionId, psc)) {
/* item.pduSessionId = psc.get()->pdu_session_id;
item.s_nssai.sst = psc.get()->snssai.sST;
item.s_nssai.sd = psc.get()->snssai.sD;
item.pduSessionNAS_PDU = nullptr;
if (pdu_sessions.size() > 0) {
for (auto pdu_session : pdu_sessions) {
if (pdu_session.get() != nullptr) {
item.pduSessionId = pdu_session.get()->pdu_session_id;
item.s_nssai.sst = pdu_session.get()->snssai.sST;
item.s_nssai.sd = pdu_session.get()->snssai.sD;
item.pduSessionNAS_PDU = NULL;
bstring n2sm = pdu_session.get()->n2sm;
if (blength(pdu_session.get()->n2sm) != 0) {
item.pduSessionResourceSetupRequestTransfer.buf = item.pduSessionResourceSetupRequestTransfer.buf =
(uint8_t*) bdata(pdu_session.get()->n2sm); pdu_session_resource.HandoverRequiredTransfer.buf;
item.pduSessionResourceSetupRequestTransfer.size = item.pduSessionResourceSetupRequestTransfer.size =
blength(pdu_session.get()->n2sm); pdu_session_resource.HandoverRequiredTransfer.size;
} else { list.push_back(item);
Logger::amf_n2().error("n2sm empty!"); */
// Send PDUSessionUpdateSMContextRequest to SMF for each active PDU
// sessions
// Generate a promise and associate this promise to the curl handle
uint32_t promise_id = amf_app_inst->generate_promise_id();
Logger::amf_n2().debug("Promise ID generated %d", promise_id);
boost::shared_ptr<boost::promise<std::string>> p =
boost::make_shared<boost::promise<std::string>>();
boost::shared_future<std::string> f = p->get_future();
amf_app_inst->add_promise(promise_id, p);
curl_responses.emplace(psc.get()->pdu_session_id, f);
Logger::amf_n2().debug(
"Sending ITTI to trigger PDUSessionUpdateSMContextRequest to SMF to "
"task TASK_AMF_N11");
itti_nsmf_pdusession_update_sm_context* itti_msg =
new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_msg->pdu_session_id = item.pduSessionId;
itti_msg->n2sm = blk2bstr(
pdu_session_resource.HandoverRequiredTransfer.buf,
pdu_session_resource.HandoverRequiredTransfer.size);
itti_msg->is_n2sm_set = true;
itti_msg->n2sm_info_type = "HANDOVER_REQUIRED";
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->promise_id = promise_id;
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i =
std::shared_ptr<itti_nsmf_pdusession_update_sm_context>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error(
"Could not send ITTI message %s to task TASK_AMF_N11",
i->get_msg_name());
}
}
} }
// TODO: Handover Response supervision
// Wait until receiving all responses from SMFs before sending Handover
bool result = true;
while (!curl_responses.empty()) {
boost::future_status status;
// wait for timeout or ready
status = curl_responses.begin()->second.wait_for(
boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
if (status == boost::future_status::ready) {
assert(curl_responses.begin()->second.is_ready());
assert(curl_responses.begin()->second.has_value());
assert(!curl_responses.begin()->second.has_exception());
// Wait for the result from APP and send reply to AMF
std::string n2_sm = curl_responses.begin()->second.get();
Logger::ngap().debug(
"Got result for PDU Session ID %d", curl_responses.begin()->first);
if (n2_sm.size() > 0) {
result = result && true;
std::shared_ptr<pdu_session_context> psc = {};
if (amf_app_inst->find_pdu_session_context(
supi, curl_responses.begin()->first, psc)) {
item.pduSessionId = psc.get()->pdu_session_id;
item.s_nssai.sst = psc.get()->snssai.sST;
item.s_nssai.sd = psc.get()->snssai.sD;
item.pduSessionNAS_PDU = nullptr;
unsigned int data_len = n2_sm.length();
unsigned char* data = (unsigned char*) malloc(data_len + 1);
memset(data, 0, data_len + 1);
memcpy((void*) data, (void*) n2_sm.c_str(), data_len);
item.pduSessionResourceSetupRequestTransfer.buf = data;
item.pduSessionResourceSetupRequestTransfer.size = data_len;
list.push_back(item); list.push_back(item);
// free memory
free_wrapper((void**) &data);
} }
} else {
result = false;
}
} else {
result = true;
} }
curl_responses.erase(curl_responses.begin());
} }
// TODO: process result
handoverrequest->setPduSessionResourceSetupList(list); // Request to Target RAN
handoverrequest->setAllowedNSSAI(Allowed_Nssai); handover_request->setPduSessionResourceSetupList(list);
handoverrequest->setSourceToTarget_TransparentContainer(sourceTotarget); handover_request->setAllowedNSSAI(Allowed_Nssai);
handoverrequest->setMobilityRestrictionList(m_plmnId); handover_request->setSourceToTarget_TransparentContainer(sourceTotarget);
handoverrequest->setGUAMI(m_plmnId, m_aMFRegionID, m_aMFSetID, m_aMFPointer); handover_request->setMobilityRestrictionList(m_plmnId);
uint8_t buffer[20240]; handover_request->setGUAMI(m_plmnId, m_aMFRegionID, m_aMFSetID, m_aMFPointer);
int encoded_size = handoverrequest->encode2buffer(buffer, 20240);
uint8_t buffer[BUFFER_SIZE_2048];
int encoded_size = handover_request->encode2buffer(buffer, BUFFER_SIZE_2048);
bstring b = blk2bstr(buffer, encoded_size); bstring b = blk2bstr(buffer, encoded_size);
std::shared_ptr<gnb_context> gc_target; std::shared_ptr<gnb_context> gc_target = {};
gc_target = gnb_id_2_gnb_context(gnbid->getValue()); gc_target = gnb_id_2_gnb_context(gnbid->getValue());
downlink_sctp_assoc_id = gc_target.get()->sctp_assoc_id; unc.get()->target_gnb_assoc_id = gc_target.get()->sctp_assoc_id;
sctp_s_38412.sctp_send_msg(gc_target.get()->sctp_assoc_id, 0, &b); sctp_s_38412.sctp_send_msg(gc_target.get()->sctp_assoc_id, 0, &b);
return true;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
// TODO:remove cout/cleanup // TODO: Experimental procedure, to be tested
unsigned long amf_ue_ngap_id = itti_msg.handoverrequestAck->getAmfUeNgapId(); unsigned long amf_ue_ngap_id = itti_msg.handoverrequestAck->getAmfUeNgapId();
uint32_t ran_ue_ngap_id = itti_msg.handoverrequestAck->getRanUeNgapId(); uint32_t ran_ue_ngap_id = itti_msg.handoverrequestAck->getRanUeNgapId();
AMF_TARGET_ran_id_global = ran_ue_ngap_id; Logger::amf_n2().debug(
Logger::amf_n2().error( "Handover Request Ack ran_ue_ngap_id (0x%d) amf_ue_ngap_id (%d)",
"Handover request Ack ran_ue_ngap_id(0x%d) amf_ue_ngap_id(%d)",
ran_ue_ngap_id, amf_ue_ngap_id); ran_ue_ngap_id, amf_ue_ngap_id);
std::shared_ptr<gnb_context> gc;
std::shared_ptr<gnb_context> gc = {};
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) { if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"gNB with assoc_id(%d) is illegal", itti_msg.assoc_id); "gNB with assoc_id (%d) is illegal", itti_msg.assoc_id);
return; return;
} }
gc = assoc_id_2_gnb_context(itti_msg.assoc_id); gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
std::shared_ptr<ue_ngap_context> unc = {};
if (!is_amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id)) {
Logger::amf_n2().error(
"No UE NGAP context with amf_ue_ngap_id (0x%x)", amf_ue_ngap_id);
return;
}
unc = amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id);
unc.get()->target_ran_ue_ngap_id = ran_ue_ngap_id; // store target RAN ID
std::vector<PDUSessionResourceAdmittedItem_t> list; std::vector<PDUSessionResourceAdmittedItem_t> list;
if (!itti_msg.handoverrequestAck->getPDUSessionResourceAdmittedList(list)) { if (!itti_msg.handoverrequestAck->getPDUSessionResourceAdmittedList(list)) {
Logger::ngap().error( Logger::ngap().error(
"Decoding HandoverRequestACK getPDUSessionResourceList IE error"); "Decoding HandoverRequestACK getPDUSessionResourceList IE error");
return; return;
} }
OCTET_STRING_t targetTosource; OCTET_STRING_t targetTosource;
targetTosource = targetTosource =
itti_msg.handoverrequestAck->getTargetToSource_TransparentContainer(); itti_msg.handoverrequestAck->getTargetToSource_TransparentContainer();
PDUSessionResourceHandoverRequestAckTransfer* PDUHandoverRequestAckTransfer = PDUSessionResourceHandoverRequestAckTransfer* PDUHandoverRequestAckTransfer =
new PDUSessionResourceHandoverRequestAckTransfer(); new PDUSessionResourceHandoverRequestAckTransfer();
uint8_t buf[1024]; uint8_t buf[BUFFER_SIZE_1024];
cout << list[0].handoverRequestAcknowledgeTransfer.buf << endl;
cout << list[0].handoverRequestAcknowledgeTransfer.size << endl;
memcpy( memcpy(
buf, list[0].handoverRequestAcknowledgeTransfer.buf, buf, list[0].handoverRequestAcknowledgeTransfer.buf,
list[0].handoverRequestAcknowledgeTransfer.size); list[0].handoverRequestAcknowledgeTransfer.size);
if (!PDUHandoverRequestAckTransfer->decodefromHandoverRequestAckTransfer( if (!PDUHandoverRequestAckTransfer->decodefromHandoverRequestAckTransfer(
buf, list[0].handoverRequestAcknowledgeTransfer.size)) { buf, list[0].handoverRequestAcknowledgeTransfer.size)) {
cout << "Decode handoverrequestacktransfer error" << endl; Logger::ngap().error("Decode Handover Request Acknowledge Transfer error");
return; return;
} }
GtpTunnel_t* gtptunnel = new GtpTunnel_t(); GtpTunnel_t* gtptunnel = new GtpTunnel_t();
if (!PDUHandoverRequestAckTransfer->getUpTransportLayerInformation2( if (!PDUHandoverRequestAckTransfer->getUpTransportLayerInformation2(
gtptunnel)) { gtptunnel)) {
cout << "Decode GtpTunnel error" << endl; Logger::ngap().error("Decode GtpTunnel error");
return; return;
} }
string n3_ip_address;
uint32_t teid; string n3_ip_address = {};
uint32_t teid = 0;
n3_ip_address = gtptunnel->ip_address; n3_ip_address = gtptunnel->ip_address;
teid = gtptunnel->gtp_teid; teid = gtptunnel->gtp_teid;
std::vector<QosFlowLItemWithDataForwarding_t> QosFlowWithDataForwardinglist; std::vector<QosFlowLItemWithDataForwarding_t> QosFlowWithDataForwardinglist;
PDUHandoverRequestAckTransfer->getqosFlowSetupResponseList( PDUHandoverRequestAckTransfer->getqosFlowSetupResponseList(
QosFlowWithDataForwardinglist); QosFlowWithDataForwardinglist);
long qosflowidentifiervalue; long qosflowidentifiervalue = 0;
qosflowidentifiervalue = qosflowidentifiervalue =
(long) QosFlowWithDataForwardinglist[0].qosFlowIdentifier; (long) QosFlowWithDataForwardinglist[0].qosFlowIdentifier;
cout << "QFI get is " << qosflowidentifiervalue << endl; Logger::ngap().debug("QFI %lu", qosflowidentifiervalue);
std::shared_ptr<nas_context> nc =
amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
string supi = "imsi-" + nc.get()->imsi;
// Send PDUSessionUpdateSMContextRequest to SMF for each active PDU sessions
std::map<uint8_t, boost::shared_future<std::string>> curl_responses;
for (auto pdu_session_resource : list) {
// Generate a promise and associate this promise to the curl handle
uint32_t promise_id = amf_app_inst->generate_promise_id();
Logger::amf_n2().debug("Promise ID generated %d", promise_id);
boost::shared_ptr<boost::promise<std::string>> p =
boost::make_shared<boost::promise<std::string>>();
boost::shared_future<std::string> f = p->get_future();
amf_app_inst->add_promise(promise_id, p);
curl_responses.emplace(pdu_session_resource.pduSessionId, f);
Logger::amf_n2().debug(
"Sending ITTI to trigger PDUSessionUpdateSMContextRequest to SMF to "
"task TASK_AMF_N11");
itti_nsmf_pdusession_update_sm_context* itti_msg =
new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_msg->pdu_session_id = pdu_session_resource.pduSessionId;
itti_msg->n2sm = blk2bstr(
pdu_session_resource.handoverRequestAcknowledgeTransfer.buf,
pdu_session_resource.handoverRequestAcknowledgeTransfer.size);
itti_msg->is_n2sm_set = true;
itti_msg->n2sm_info_type = "HANDOVER_REQ_ACK";
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->promise_id = promise_id;
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i =
std::shared_ptr<itti_nsmf_pdusession_update_sm_context>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error(
"Could not send ITTI message %s to task TASK_AMF_N11",
i->get_msg_name());
}
}
// send HandoverCommandMsg to Source gnb // send HandoverCommandMsg to Source gnb
std::unique_ptr<HandoverCommandMsg> handovercommand = std::unique_ptr<HandoverCommandMsg> handovercommand =
std::make_unique<HandoverCommandMsg>(); std::make_unique<HandoverCommandMsg>();
handovercommand->setMessageType(); handovercommand->setMessageType();
handovercommand->setAmfUeNgapId(amf_ue_ngap_id); handovercommand->setAmfUeNgapId(amf_ue_ngap_id);
handovercommand->setRanUeNgapId(ran_id_Global); handovercommand->setRanUeNgapId(unc.get()->ran_ue_ngap_id);
handovercommand->setHandoverType(Ngap_HandoverType_intra5gs); handovercommand->setHandoverType(Ngap_HandoverType_intra5gs);
std::shared_ptr<nas_context> nc =
amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
// setPduSessionResourceHandoverList_PDYSessionID_handovercommandtransfer
std::vector<PDUSessionResourceHandoverItem_t> handover_list; std::vector<PDUSessionResourceHandoverItem_t> handover_list;
PDUSessionResourceHandoverItem_t item; PDUSessionResourceHandoverItem_t item = {};
// set pdu id
// TODO: wait for response from SMF and transfer T-RAN N3 information/ or
// T-UPF to the source gNB
bool result = true;
while (!curl_responses.empty()) {
boost::future_status status;
// wait for timeout or ready
status = curl_responses.begin()->second.wait_for(
boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
if (status == boost::future_status::ready) {
assert(curl_responses.begin()->second.is_ready());
assert(curl_responses.begin()->second.has_value());
assert(!curl_responses.begin()->second.has_exception());
// Wait for the result from APP and send reply to AMF
std::string n2_sm = curl_responses.begin()->second.get();
Logger::ngap().debug(
"Got result for PDU Session ID %d", curl_responses.begin()->first);
if (n2_sm.size() > 0) {
result = result && true;
item.pduSessionId = curl_responses.begin()->first;
unsigned int data_len = n2_sm.length();
unsigned char* data = (unsigned char*) malloc(data_len + 1);
memset(data, 0, data_len + 1);
memcpy((void*) data, (void*) n2_sm.c_str(), data_len);
item.HandoverCommandTransfer.buf = data;
item.HandoverCommandTransfer.size = data_len;
handover_list.push_back(item);
// free memory
free_wrapper((void**) &data);
std::shared_ptr<pdu_session_context> psc = {};
if (amf_app_inst->find_pdu_session_context(
supi, item.pduSessionId, psc)) {
psc.get()->is_ho_accepted = true;
}
} else {
result = false;
}
} else {
result = true;
}
curl_responses.erase(curl_responses.begin());
}
/*
item.pduSessionId = list[0].pduSessionId; item.pduSessionId = list[0].pduSessionId;
// set qosFLowtobeforwardedlist // qosFLowtobeforwardedlist
std::vector<QosFlowToBeForwardedItem_t> forward_list; std::vector<QosFlowToBeForwardedItem_t> forward_list;
QosFlowToBeForwardedItem_t forward_item; QosFlowToBeForwardedItem_t forward_item;
forward_item.QFI = qosflowidentifiervalue; forward_item.QFI = qosflowidentifiervalue;
forward_list.push_back(forward_item); forward_list.push_back(forward_item);
// set dlforwardingup_tnlinformation // set dlforwardingup_tnlinformation
// TransportLayerAddress *transportlayeraddress = new TransportLayerAddress(); // TransportLayerAddress *transportlayeraddress = new
TransportLayerAddress();
// transportlayeraddress->setTransportLayerAddress(n3_ip_address); // transportlayeraddress->setTransportLayerAddress(n3_ip_address);
// GtpTeid *gtpTeid = new GtpTeid(); // GtpTeid *gtpTeid = new GtpTeid();
// gtpTeid->setGtpTeid(teid); // gtpTeid->setGtpTeid(teid);
PDUSessionResourceHandoverCommandTransfer* handovercommandtransfer = PDUSessionResourceHandoverCommandTransfer* handovercommandtransfer =
new PDUSessionResourceHandoverCommandTransfer(); new PDUSessionResourceHandoverCommandTransfer();
handovercommandtransfer->setQosFlowToBeForwardedList(forward_list); handovercommandtransfer->setQosFlowToBeForwardedList(forward_list);
GtpTunnel_t uptlinfo; GtpTunnel_t uptlinfo = {};
uptlinfo.gtp_teid = teid; uptlinfo.gtp_teid = teid;
uptlinfo.ip_address = n3_ip_address; uptlinfo.ip_address = n3_ip_address;
handovercommandtransfer->setUPTransportLayerInformation(uptlinfo); handovercommandtransfer->setUPTransportLayerInformation(uptlinfo);
// handovercommand->setTargetToSource_TransparentContainer(targetTosource);
uint8_t buffer2[500]; uint8_t buffer_ho_cmd_transfer[BUFFER_SIZE_512];
int encoded_size2 = int encoded_size =
handovercommandtransfer->encodePDUSessionResourceHandoverCommandTransfer( handovercommandtransfer->encodePDUSessionResourceHandoverCommandTransfer(
buffer2, 500); buffer_ho_cmd_transfer, BUFFER_SIZE_512);
OCTET_STRING_t OCT_handovercommandtransfer; item.HandoverCommandTransfer.buf = buffer_ho_cmd_transfer;
OCT_handovercommandtransfer.buf = buffer2; item.HandoverCommandTransfer.size = encoded_size;
OCT_handovercommandtransfer.size = encoded_size2;
item.HandoverCommandTransfer = OCT_handovercommandtransfer;
handover_list.push_back(item); handover_list.push_back(item);
*/
handovercommand->setPduSessionResourceHandoverList(handover_list); handovercommand->setPduSessionResourceHandoverList(handover_list);
handovercommand->setTargetToSource_TransparentContainer(targetTosource); handovercommand->setTargetToSource_TransparentContainer(targetTosource);
// setPduSessionResourceHandoverList_PDYSessionID_handovercommandtransfer-end
uint8_t buffer[10240]; uint8_t buffer[BUFFER_SIZE_1024];
int encoded_size = handovercommand->encode2buffer(buffer, 10240); int encoded_size = handovercommand->encode2buffer(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size); bstring b = blk2bstr(buffer, encoded_size);
std::shared_ptr<ue_ngap_context> unc;
if (!is_ran_ue_id_2_ue_ngap_context(ran_id_Global)) {
Logger::amf_n2().debug(
"Create a new ue ngap context with ran_ue_ngap_id(0x%x)",
ran_id_Global);
unc = std::shared_ptr<ue_ngap_context>(new ue_ngap_context());
set_ran_ue_ngap_id_2_ue_ngap_context(ran_id_Global, unc);
unc.get()->gnb_assoc_id = source_assoc_id;
} else {
unc = ran_ue_id_2_ue_ngap_context(ran_id_Global);
unc.get()->gnb_assoc_id = source_assoc_id;
}
// std::shared_ptr<ue_ngap_context> ngc =
// ran_ue_id_2_ue_ngap_context(nc.get()->ran_ue_ngap_id);
// std::shared_ptr<ue_ngap_context> ngc =
// ran_ue_id_2_ue_ngap_context(ran_id_Global);
// sctp_s_38412.sctp_send_msg(ngc.get()->gnb_assoc_id, 0, &b);
sctp_s_38412.sctp_send_msg(unc.get()->gnb_assoc_id, 0, &b); sctp_s_38412.sctp_send_msg(unc.get()->gnb_assoc_id, 0, &b);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) { void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
// TODO: Experimental procedure, to be tested
unsigned long amf_ue_ngap_id = itti_msg.handovernotify->getAmfUeNgapId(); unsigned long amf_ue_ngap_id = itti_msg.handovernotify->getAmfUeNgapId();
uint32_t ran_ue_ngap_id = itti_msg.handovernotify->getRanUeNgapId(); uint32_t ran_ue_ngap_id = itti_msg.handovernotify->getRanUeNgapId();
Logger::amf_n2().error( Logger::amf_n2().debug(
"Handover notify ran_ue_ngap_id(0x%d) amf_ue_ngap_id(%d)", ran_ue_ngap_id, "Handover Notify ran_ue_ngap_id (0x%d) amf_ue_ngap_id (%lu)",
amf_ue_ngap_id); ran_ue_ngap_id, amf_ue_ngap_id);
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) { if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"gNB with assoc_id(%d) is illegal", itti_msg.assoc_id); "gNB with assoc_id (%d) is illegal", itti_msg.assoc_id);
return;
}
std::shared_ptr<ue_ngap_context> unc = {};
if (!is_amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id)) {
Logger::amf_n2().error(
"No UE NGAP context with amf_ue_ngap_id (0x%x)", amf_ue_ngap_id);
return; return;
} }
unc = amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id);
NrCgi_t NR_CGI = {}; NrCgi_t NR_CGI = {};
Tai_t TAI = {}; Tai_t TAI = {};
if (!itti_msg.handovernotify->getUserLocationInfoNR(NR_CGI, TAI)) { if (!itti_msg.handovernotify->getUserLocationInfoNR(NR_CGI, TAI)) {
...@@ -1377,20 +1568,99 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) { ...@@ -1377,20 +1568,99 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
return; return;
} }
std::shared_ptr<nas_context> nc =
amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
string supi = "imsi-" + nc.get()->imsi;
std::vector<std::shared_ptr<pdu_session_context>> sessions_ctx;
if (!amf_app_inst->get_pdu_sessions_context(supi, sessions_ctx)) {
}
// Send PDUSessionUpdateSMContextRequest to SMF for accepted PDU sessions
std::map<uint8_t, boost::shared_future<std::string>> curl_responses;
for (auto pdu_session : sessions_ctx) {
if (pdu_session.get()->is_ho_accepted) {
// Generate a promise and associate this promise to the curl handle
uint32_t promise_id = amf_app_inst->generate_promise_id();
Logger::amf_n2().debug("Promise ID generated %d", promise_id);
boost::shared_ptr<boost::promise<std::string>> p =
boost::make_shared<boost::promise<std::string>>();
boost::shared_future<std::string> f = p->get_future();
amf_app_inst->add_promise(promise_id, p);
curl_responses.emplace(pdu_session.get()->pdu_session_id, f);
Logger::amf_n2().debug(
"Sending ITTI to trigger PDUSessionUpdateSMContextRequest to SMF to "
"task TASK_AMF_N11");
itti_nsmf_pdusession_update_sm_context* itti_msg =
new itti_nsmf_pdusession_update_sm_context(TASK_NGAP, TASK_AMF_N11);
itti_msg->pdu_session_id = pdu_session.get()->pdu_session_id;
// TODO: Secondary RAT Usage
itti_msg->n2sm = blk2bstr("", 0);
itti_msg->is_n2sm_set = true;
itti_msg->n2sm_info_type = "SECONDARY_RAT_USAGE";
itti_msg->amf_ue_ngap_id = amf_ue_ngap_id;
itti_msg->ran_ue_ngap_id = ran_ue_ngap_id;
itti_msg->promise_id = promise_id;
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i =
std::shared_ptr<itti_nsmf_pdusession_update_sm_context>(itti_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::ngap().error(
"Could not send ITTI message %s to task TASK_AMF_N11",
i->get_msg_name());
}
}
}
bool result = true;
while (!curl_responses.empty()) {
boost::future_status status;
// wait for timeout or ready
status = curl_responses.begin()->second.wait_for(
boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
if (status == boost::future_status::ready) {
assert(curl_responses.begin()->second.is_ready());
assert(curl_responses.begin()->second.has_value());
assert(!curl_responses.begin()->second.has_exception());
// Wait for the result from APP and send reply to AMF
std::string pdu_session_id_str = curl_responses.begin()->second.get();
Logger::ngap().debug(
"Got result for PDU Session ID %d", curl_responses.begin()->first);
if (pdu_session_id_str.size() > 0) {
result = result && true;
} else {
result = false;
}
} else {
result = true;
}
curl_responses.erase(curl_responses.begin());
}
// Send UE Release Command to Source gNB
std::unique_ptr<UEContextReleaseCommandMsg> ueContextReleaseCommand = std::unique_ptr<UEContextReleaseCommandMsg> ueContextReleaseCommand =
std::make_unique<UEContextReleaseCommandMsg>(); std::make_unique<UEContextReleaseCommandMsg>();
ueContextReleaseCommand->setMessageType(); ueContextReleaseCommand->setMessageType();
ueContextReleaseCommand->setUeNgapIdPair(amf_ue_ngap_id, ran_id_Global); ueContextReleaseCommand->setUeNgapIdPair(
amf_ue_ngap_id, unc.get()->ran_ue_ngap_id);
ueContextReleaseCommand->setCauseRadioNetwork( ueContextReleaseCommand->setCauseRadioNetwork(
Ngap_CauseRadioNetwork_successful_handover); Ngap_CauseRadioNetwork_successful_handover);
uint8_t buffer[10240];
int encoded_size = ueContextReleaseCommand->encode2buffer(buffer, 10240); uint8_t buffer[BUFFER_SIZE_1024];
int encoded_size =
ueContextReleaseCommand->encode2buffer(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size); bstring b = blk2bstr(buffer, encoded_size);
std::shared_ptr<nas_context> nc =
amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id); sctp_s_38412.sctp_send_msg(unc.get()->gnb_assoc_id, 0, &b);
std::shared_ptr<ue_ngap_context> ngc =
ran_ue_id_2_ue_ngap_context(nc.get()->ran_ue_ngap_id);
sctp_s_38412.sctp_send_msg(source_assoc_id, 0, &b);
/*std::shared_ptr<nas_context> nc = /*std::shared_ptr<nas_context> nc =
amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id); string supi = "imsi-" + amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id); string supi = "imsi-" +
nc.get()->imsi; std::shared_ptr<pdu_session_context> psc = nc.get()->imsi; std::shared_ptr<pdu_session_context> psc =
...@@ -1401,32 +1671,39 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) { ...@@ -1401,32 +1671,39 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i = std::shared_ptr<itti_nsmf_pdusession_update_sm_context> i =
std::shared_ptr<itti_nsmf_pdusession_update_sm_context>(itti_nsmf_msg); std::shared_ptr<itti_nsmf_pdusession_update_sm_context>(itti_nsmf_msg);
//int ret = itti_inst->send_msg(i);*/ //int ret = itti_inst->send_msg(i);*/
std::shared_ptr<ue_ngap_context> unc;
if (!is_ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id)) { if (!is_amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id)) {
Logger::amf_n2().debug( Logger::amf_n2().error(
"Create a new ue ngap context with ran_ue_ngap_id(0x%x)", "No UE NGAP context with amf_ue_ngap_id (0x%x)", amf_ue_ngap_id);
ran_ue_ngap_id); return;
unc = std::shared_ptr<ue_ngap_context>(new ue_ngap_context());
set_ran_ue_ngap_id_2_ue_ngap_context(ran_ue_ngap_id, unc);
unc.get()->gnb_assoc_id = ngc.get()->gnb_assoc_id;
} }
/*if (0 != ret) unc = amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id);
{ unc.get()->ran_ue_ngap_id = ran_ue_ngap_id; // store new RAN ID
Logger::ngap().error("Could not send ITTI message %s to task TASK_AMF_N11", unc.get()->target_ran_ue_ngap_id = 0; // Clear target RAN ID
i->get_msg_name()); unc.get()->ng_ue_state = NGAP_UE_CONNECTED;
}*/ unc.get()->gnb_assoc_id = itti_msg.assoc_id; // update serving gNB
set_ran_ue_ngap_id_2_ue_ngap_context(ran_ue_ngap_id, unc);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_uplinkranstatsutransfer& itti_msg) { void amf_n2::handle_itti_message(itti_uplink_ran_status_transfer& itti_msg) {
unsigned long amf_ue_ngap_id = itti_msg.uplinkrantransfer->getAmfUeNgapId(); unsigned long amf_ue_ngap_id = itti_msg.uplinkrantransfer->getAmfUeNgapId();
Logger::amf_n2().error( Logger::amf_n2().error(
"uplinkranstatustransfer amf_ue_ngap_id(%d)", amf_ue_ngap_id); "Uplink RAN Status Transfer amf_ue_ngap_id (%d)", amf_ue_ngap_id);
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) { if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"gNB with assoc_id (%d) is illegal", itti_msg.assoc_id); "gNB with assoc_id (%d) is illegal", itti_msg.assoc_id);
return; return;
} }
std::shared_ptr<ue_ngap_context> unc = {};
if (!is_amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id)) {
Logger::amf_n2().error(
"No UE NGAP context with amf_ue_ngap_id (0x%x)", amf_ue_ngap_id);
return;
}
unc = amf_ue_id_2_ue_ngap_context(amf_ue_ngap_id);
RANStatusTransferTransparentContainer* ran_status_transfer = RANStatusTransferTransparentContainer* ran_status_transfer =
(RANStatusTransferTransparentContainer*) calloc( (RANStatusTransferTransparentContainer*) calloc(
1, sizeof(RANStatusTransferTransparentContainer)); 1, sizeof(RANStatusTransferTransparentContainer));
...@@ -1466,15 +1743,33 @@ void amf_n2::handle_itti_message(itti_uplinkranstatsutransfer& itti_msg) { ...@@ -1466,15 +1743,33 @@ void amf_n2::handle_itti_message(itti_uplinkranstatsutransfer& itti_msg) {
std::make_unique<DownlinkRANStatusTransfer>(); std::make_unique<DownlinkRANStatusTransfer>();
downLinkranstatustransfer->setmessagetype(); downLinkranstatustransfer->setmessagetype();
downLinkranstatustransfer->setAmfUeNgapId(amf_ue_ngap_id); downLinkranstatustransfer->setAmfUeNgapId(amf_ue_ngap_id);
downLinkranstatustransfer->setRanUeNgapId(AMF_TARGET_ran_id_global); downLinkranstatustransfer->setRanUeNgapId(unc.get()->target_ran_ue_ngap_id);
downLinkranstatustransfer->setRANStatusTransfer_TransparentContainer( downLinkranstatustransfer->setRANStatusTransfer_TransparentContainer(
amf_drb_id, amf_ul_pdcp, amf_hfn_ul_pdcp, amf_dl_pdcp, amf_hfn_dl_pdcp); amf_drb_id, amf_ul_pdcp, amf_hfn_ul_pdcp, amf_dl_pdcp, amf_hfn_dl_pdcp);
uint8_t buffer[1024]; uint8_t buffer[1024];
int encode_size = downLinkranstatustransfer->encodetobuffer(buffer, 1024); int encode_size = downLinkranstatustransfer->encodetobuffer(buffer, 1024);
bstring b = blk2bstr(buffer, encode_size); bstring b = blk2bstr(buffer, encode_size);
// std::shared_ptr<ue_ngap_context> ngc = sctp_s_38412.sctp_send_msg(unc.get()->target_gnb_assoc_id, 0, &b);
// ran_ue_id_2_ue_ngap_context(AMF_TARGET_ran_id_global); }
sctp_s_38412.sctp_send_msg(downlink_sctp_assoc_id, 0, &b);
//------------------------------------------------------------------------------
void amf_n2::send_handover_preparation_failure(
const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id,
const sctp_assoc_id_t& gnb_assoc_id) {
// Create HandoverPreparationFailure message to be sent to target gNB
std::unique_ptr<HandoverPreparationFailure> hoPreparationFailure =
std::make_unique<HandoverPreparationFailure>();
hoPreparationFailure->setMessageType();
hoPreparationFailure->setAmfUeNgapId(amf_ue_ngap_id);
hoPreparationFailure->setRanUeNgapId(amf_ue_ngap_id);
hoPreparationFailure->setCause(Ngap_Cause_PR_NOTHING);
uint8_t buffer[BUFFER_SIZE_1024];
int encoded_size =
hoPreparationFailure->encode2buffer(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size);
sctp_s_38412.sctp_send_msg(gnb_assoc_id, 0, &b);
} }
// Context management functions // Context management functions
...@@ -1495,12 +1790,32 @@ std::shared_ptr<ue_ngap_context> amf_n2::ran_ue_id_2_ue_ngap_context( ...@@ -1495,12 +1790,32 @@ std::shared_ptr<ue_ngap_context> amf_n2::ran_ue_id_2_ue_ngap_context(
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::set_ran_ue_ngap_id_2_ue_ngap_context( void amf_n2::set_ran_ue_ngap_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc) { const uint32_t& ran_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc) {
std::shared_lock lock(m_ranid2uecontext); std::unique_lock lock(m_ranid2uecontext);
ranid2uecontext[ran_ue_ngap_id] = unc; ranid2uecontext[ran_ue_ngap_id] = unc;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// internal analysis functions std::shared_ptr<ue_ngap_context> amf_n2::amf_ue_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id) const {
std::shared_lock lock(m_amfueid2uecontext);
return amfueid2uecontext.at(amf_ue_ngap_id);
}
//------------------------------------------------------------------------------
bool amf_n2::is_amf_ue_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id) const {
std::shared_lock lock(m_amfueid2uecontext);
return bool{amfueid2uecontext.count(amf_ue_ngap_id) > 0};
}
//------------------------------------------------------------------------------
void amf_n2::set_amf_ue_ngap_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc) {
std::unique_lock lock(m_amfueid2uecontext);
amfueid2uecontext[amf_ue_ngap_id] = unc;
}
//------------------------------------------------------------------------------
bool amf_n2::verifyPlmn(vector<SupportedItem_t> list) { bool amf_n2::verifyPlmn(vector<SupportedItem_t> list) {
for (int i = 0; i < amf_cfg.plmn_list.size(); i++) { for (int i = 0; i < amf_cfg.plmn_list.size(); i++) {
for (int j = 0; j < list.size(); j++) { for (int j = 0; j < list.size(); j++) {
......
...@@ -58,26 +58,40 @@ class amf_n2 : public ngap::ngap_app { ...@@ -58,26 +58,40 @@ class amf_n2 : public ngap::ngap_app {
void handle_itti_message(itti_ue_radio_capability_indication& itti_msg); void handle_itti_message(itti_ue_radio_capability_indication& itti_msg);
void handle_itti_message(itti_ue_context_release_command& itti_msg); void handle_itti_message(itti_ue_context_release_command& itti_msg);
void handle_itti_message(itti_pdu_session_resource_release_command& itti_msg); void handle_itti_message(itti_pdu_session_resource_release_command& itti_msg);
void handle_itti_message(itti_handover_required& itti_msg); bool handle_itti_message(itti_handover_required& itti_msg);
void handle_itti_message(itti_handover_request_Ack& itti_msg); void handle_itti_message(itti_handover_request_Ack& itti_msg);
void handle_itti_message(itti_handover_notify& itti_msg); void handle_itti_message(itti_handover_notify& itti_msg);
void handle_itti_message(itti_uplinkranstatsutransfer& itti_msg); void handle_itti_message(itti_uplink_ran_status_transfer& itti_msg);
void send_handover_preparation_failure(
const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id,
const sctp_assoc_id_t& gnb_assoc_id);
bool verifyPlmn(std::vector<SupportedItem_t> list); bool verifyPlmn(std::vector<SupportedItem_t> list);
std::vector<SupportedItem_t> get_common_plmn( std::vector<SupportedItem_t> get_common_plmn(
std::vector<SupportedItem_t> list); std::vector<SupportedItem_t> list);
std::shared_ptr<ue_ngap_context> ran_ue_id_2_ue_ngap_context( std::shared_ptr<ue_ngap_context> ran_ue_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id) const; const uint32_t& ran_ue_ngap_id) const;
bool is_ran_ue_id_2_ue_ngap_context(const uint32_t& ran_ue_ngap_id) const; bool is_ran_ue_id_2_ue_ngap_context(const uint32_t& ran_ue_ngap_id) const;
void set_ran_ue_ngap_id_2_ue_ngap_context( void set_ran_ue_ngap_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc); const uint32_t& ran_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc);
std::shared_ptr<ue_ngap_context> amf_ue_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id) const;
bool is_amf_ue_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id) const;
void set_amf_ue_ngap_id_2_ue_ngap_context(
const unsigned long& amf_ue_ngap_id,
std::shared_ptr<ue_ngap_context> unc);
private: private:
std::map<uint32_t, std::shared_ptr<ue_ngap_context>> std::map<uint32_t, std::shared_ptr<ue_ngap_context>>
ranid2uecontext; // ran ue ngap id ranid2uecontext; // ran ue ngap id
mutable std::shared_mutex m_ranid2uecontext; mutable std::shared_mutex m_ranid2uecontext;
std::map<unsigned long, std::shared_ptr<ue_ngap_context>>
amfueid2uecontext; // amf ue id
mutable std::shared_mutex m_amfueid2uecontext;
}; };
} // namespace amf_application } // namespace amf_application
......
...@@ -136,8 +136,11 @@ constexpr auto CURL_MIME_BOUNDARY = "----Boundary"; ...@@ -136,8 +136,11 @@ constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#define AUSF_CURL_TIMEOUT_MS 100L #define AUSF_CURL_TIMEOUT_MS 100L
#define CURL_TIMEOUT_MS 100L #define CURL_TIMEOUT_MS 100L
#define BUFFER_SIZE_2048 2048
#define BUFFER_SIZE_1024 1024 #define BUFFER_SIZE_1024 1024
#define BUFFER_SIZE_512 512 #define BUFFER_SIZE_512 512
#define BUFFER_SIZE_256 256 #define BUFFER_SIZE_256 256
#define FUTURE_STATUS_TIMEOUT_MS 100
#endif #endif
...@@ -55,5 +55,7 @@ class pdu_session_context { ...@@ -55,5 +55,7 @@ class pdu_session_context {
snssai_t snssai; snssai_t snssai;
plmn_t plmn; plmn_t plmn;
std::string smf_context_location; std::string smf_context_location;
bool is_ho_accepted;
}; };
#endif #endif
...@@ -48,17 +48,20 @@ class ue_ngap_context { ...@@ -48,17 +48,20 @@ class ue_ngap_context {
public: public:
uint32_t ran_ue_ngap_id; // 32bits uint32_t ran_ue_ngap_id; // 32bits
long amf_ue_ngap_id : 40; // 40bits long amf_ue_ngap_id : 40; // 40bits
uint32_t target_ran_ue_ngap_id; // 32bits, for HO
sctp_stream_id_t sctp_stream_recv; // used to decide which ue in gNB sctp_stream_id_t sctp_stream_recv; // used to decide which ue in gNB
sctp_stream_id_t sctp_stream_send; // used to decide which ue in gNB sctp_stream_id_t sctp_stream_send; // used to decide which ue in gNB
sctp_assoc_id_t gnb_assoc_id; // to find which gnb this UE belongs to sctp_assoc_id_t gnb_assoc_id; // to find which gnb this UE belongs to
sctp_assoc_id_t target_gnb_assoc_id;
bool ueContextRequest; bool ueContextRequest;
uint32_t s_tmsi_5g; uint32_t s_tmsi_5g;
// state management, ue status over the air // state management, ue status over the air
ng_ue_state_t ng_ue_state; ng_ue_state_t ng_ue_state;
uint8_t ncc; // Next Hop Chaining Counter
}; };
#endif #endif
...@@ -78,7 +78,7 @@ typedef enum { ...@@ -78,7 +78,7 @@ typedef enum {
DOWNLINK_NAS_TRANSFER, DOWNLINK_NAS_TRANSFER,
NAS_SIG_ESTAB_REQ, // task amf_app NAS_SIG_ESTAB_REQ, // task amf_app
N1N2_MESSAGE_TRANSFER_REQ, N1N2_MESSAGE_TRANSFER_REQ,
SMF_SERVICES_CONSUMER, NSMF_PDU_SESSION_CREATE_SM_CTX,
NSMF_PDU_SESSION_UPDATE_SM_CTX, NSMF_PDU_SESSION_UPDATE_SM_CTX,
N11_REGISTER_NF_INSTANCE_REQUEST, N11_REGISTER_NF_INSTANCE_REQUEST,
N11_REGISTER_NF_INSTANCE_RESPONSE, N11_REGISTER_NF_INSTANCE_RESPONSE,
...@@ -88,12 +88,12 @@ typedef enum { ...@@ -88,12 +88,12 @@ typedef enum {
SBI_EVENT_EXPOSURE_REQUEST, SBI_EVENT_EXPOSURE_REQUEST,
SBI_NOTIFICATION_DATA, SBI_NOTIFICATION_DATA,
UE_CONTEXT_RELEASE_COMMAND, UE_CONTEXT_RELEASE_COMMAND,
NSMF_PDU_SESS_RELEASE_SMCTX, NSMF_PDU_SESSION_RELEASE_SM_CTX,
HANDOVER_REQUIRED, HANDOVER_REQUIRED,
HANDOVER_REQUEST_ACK, HANDOVER_REQUEST_ACK,
HANDOVER_NOTIFY, HANDOVER_NOTIFY,
UPLINKRANSTATUSTRANSFER, UPLINK_RAN_STATUS_TRANSFER,
PDU_SESS_RES_SET_RESP, PDU_SESSION_RESOURCE_SETUP_RESPONSE,
TIME_OUT, TIME_OUT,
HEALTH_PING, HEALTH_PING,
TERMINATE, TERMINATE,
......
...@@ -45,12 +45,13 @@ class itti_msg_n11 : public itti_msg { ...@@ -45,12 +45,13 @@ class itti_msg_n11 : public itti_msg {
uint32_t ran_ue_ngap_id; uint32_t ran_ue_ngap_id;
}; };
class itti_smf_services_consumer : public itti_msg_n11 { class itti_nsmf_pdusession_create_sm_context : public itti_msg_n11 {
public: public:
itti_smf_services_consumer( itti_nsmf_pdusession_create_sm_context(
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n11(SMF_SERVICES_CONSUMER, origin, destination) {} : itti_msg_n11(NSMF_PDU_SESSION_CREATE_SM_CTX, origin, destination) {}
itti_smf_services_consumer(const itti_smf_services_consumer& i) itti_nsmf_pdusession_create_sm_context(
const itti_nsmf_pdusession_create_sm_context& i)
: itti_msg_n11(i) {} : itti_msg_n11(i) {}
public: public:
...@@ -66,7 +67,8 @@ class itti_pdu_session_resource_setup_response : public itti_msg_n11 { ...@@ -66,7 +67,8 @@ class itti_pdu_session_resource_setup_response : public itti_msg_n11 {
public: public:
itti_pdu_session_resource_setup_response( itti_pdu_session_resource_setup_response(
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n11(PDU_SESS_RES_SET_RESP, origin, destination) {} : itti_msg_n11(PDU_SESSION_RESOURCE_SETUP_RESPONSE, origin, destination) {
}
itti_pdu_session_resource_setup_response( itti_pdu_session_resource_setup_response(
const itti_pdu_session_resource_setup_response& i) const itti_pdu_session_resource_setup_response& i)
: itti_msg_n11(i) {} : itti_msg_n11(i) {}
...@@ -82,6 +84,7 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 { ...@@ -82,6 +84,7 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n11(NSMF_PDU_SESSION_UPDATE_SM_CTX, origin, destination) { : itti_msg_n11(NSMF_PDU_SESSION_UPDATE_SM_CTX, origin, destination) {
is_n2sm_set = false; is_n2sm_set = false;
promise_id = 0;
} }
itti_nsmf_pdusession_update_sm_context( itti_nsmf_pdusession_update_sm_context(
const itti_nsmf_pdusession_update_sm_context& i) const itti_nsmf_pdusession_update_sm_context& i)
...@@ -90,6 +93,8 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 { ...@@ -90,6 +93,8 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
n2sm = i.n2sm; n2sm = i.n2sm;
is_n2sm_set = i.is_n2sm_set; is_n2sm_set = i.is_n2sm_set;
n2sm_info_type = i.n2sm_info_type; n2sm_info_type = i.n2sm_info_type;
promise_id = i.promise_id;
;
} }
public: public:
...@@ -100,13 +105,14 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 { ...@@ -100,13 +105,14 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
std::string n2sm_info_type; std::string n2sm_info_type;
uint32_t ran_ue_ngap_id; uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id; long amf_ue_ngap_id;
uint32_t promise_id;
}; };
class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11 { class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11 {
public: public:
itti_nsmf_pdusession_release_sm_context( itti_nsmf_pdusession_release_sm_context(
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n11(NSMF_PDU_SESS_RELEASE_SMCTX, origin, destination) {} : itti_msg_n11(NSMF_PDU_SESSION_RELEASE_SM_CTX, origin, destination) {}
itti_nsmf_pdusession_release_sm_context( itti_nsmf_pdusession_release_sm_context(
const itti_nsmf_pdusession_update_sm_context& i) const itti_nsmf_pdusession_update_sm_context& i)
: itti_msg_n11(i) {} : itti_msg_n11(i) {}
......
...@@ -218,7 +218,7 @@ class itti_handover_required : public itti_msg_n2 { ...@@ -218,7 +218,7 @@ class itti_handover_required : public itti_msg_n2 {
itti_handover_required(const task_id_t origin, const task_id_t destination) itti_handover_required(const task_id_t origin, const task_id_t destination)
: itti_msg_n2(HANDOVER_REQUIRED, origin, destination) {} : itti_msg_n2(HANDOVER_REQUIRED, origin, destination) {}
itti_handover_required(const itti_handover_required& i) : itti_msg_n2(i) {} itti_handover_required(const itti_handover_required& i) : itti_msg_n2(i) {}
HandoverRequiredMsg* handvoerRequ; HandoverRequiredMsg* handoverReq;
}; };
class itti_handover_request_Ack : public itti_msg_n2 { class itti_handover_request_Ack : public itti_msg_n2 {
...@@ -238,12 +238,12 @@ class itti_handover_notify : public itti_msg_n2 { ...@@ -238,12 +238,12 @@ class itti_handover_notify : public itti_msg_n2 {
HandoverNotifyMsg* handovernotify; HandoverNotifyMsg* handovernotify;
}; };
class itti_uplinkranstatsutransfer : public itti_msg_n2 { class itti_uplink_ran_status_transfer : public itti_msg_n2 {
public: public:
itti_uplinkranstatsutransfer( itti_uplink_ran_status_transfer(
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n2(UPLINKRANSTATUSTRANSFER, origin, destination) {} : itti_msg_n2(UPLINK_RAN_STATUS_TRANSFER, origin, destination) {}
itti_uplinkranstatsutransfer(const itti_uplinkranstatsutransfer& i) itti_uplink_ran_status_transfer(const itti_uplink_ran_status_transfer& i)
: itti_msg_n2(i) {} : itti_msg_n2(i) {}
UplinkRANStatusTransfer* uplinkrantransfer; UplinkRANStatusTransfer* uplinkrantransfer;
}; };
......
...@@ -35,32 +35,32 @@ using namespace nas; ...@@ -35,32 +35,32 @@ using namespace nas;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
RegistrationRequest::RegistrationRequest() { RegistrationRequest::RegistrationRequest() {
plain_header = NULL; plain_header = nullptr;
ie_5gsregistrationtype = NULL; ie_5gsregistrationtype = nullptr;
ie_ngKSI = NULL; ie_ngKSI = nullptr;
ie_5gs_mobility_id = NULL; ie_5gs_mobility_id = nullptr;
ie_non_current_native_nas_ksi = NULL; ie_non_current_native_nas_ksi = nullptr;
ie_5g_mm_capability = NULL; ie_5g_mm_capability = nullptr;
ie_ue_security_capability = NULL; ie_ue_security_capability = nullptr;
ie_requested_NSSAI = NULL; ie_requested_NSSAI = nullptr;
ie_s1_ue_network_capability = NULL; ie_s1_ue_network_capability = nullptr;
ie_uplink_data_status = NULL; ie_uplink_data_status = nullptr;
ie_last_visited_registered_TAI = NULL; ie_last_visited_registered_TAI = nullptr;
ie_PDU_session_status = NULL; ie_PDU_session_status = nullptr;
ie_MICO_indicationl = NULL; ie_MICO_indicationl = nullptr;
ie_ue_status = NULL; ie_ue_status = nullptr;
ie_additional_guti = NULL; ie_additional_guti = nullptr;
ie_allowed_PDU_session_status = NULL; ie_allowed_PDU_session_status = nullptr;
ie_ues_usage_setting = NULL; ie_ues_usage_setting = nullptr;
ie_5gs_drx_parameters = NULL; ie_5gs_drx_parameters = nullptr;
ie_eps_nas_message_container = NULL; ie_eps_nas_message_container = nullptr;
ie_ladn_indication = NULL; ie_ladn_indication = nullptr;
ie_payload_container_type = NULL; ie_payload_container_type = nullptr;
ie_payload_container = NULL; ie_payload_container = nullptr;
ie_network_slicing_indication = NULL; ie_network_slicing_indication = nullptr;
ie_5gs_update_type = NULL; ie_5gs_update_type = nullptr;
ie_nas_message_container = NULL; ie_nas_message_container = nullptr;
ie_eps_bearer_context_status = NULL; ie_eps_bearer_context_status = nullptr;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -94,11 +94,11 @@ void RegistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) { ...@@ -94,11 +94,11 @@ void RegistrationRequest::setngKSI(uint8_t tsc, uint8_t key_set_id) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
uint8_t RegistrationRequest::getngKSI() { uint8_t RegistrationRequest::getngKSI() {
if (ie_ngKSI) { if (ie_ngKSI) {
uint8_t a = 0; return (
a = (ie_ngKSI->getTypeOfSecurityContext()) | ie_ngKSI->getasKeyIdentifier(); (ie_ngKSI->getTypeOfSecurityContext()) |
return a; ie_ngKSI->getasKeyIdentifier());
} else { } else {
return -1; return 0;
} }
} }
...@@ -122,7 +122,7 @@ uint8_t RegistrationRequest::getMobilityIdentityType() { ...@@ -122,7 +122,7 @@ uint8_t RegistrationRequest::getMobilityIdentityType() {
if (ie_5gs_mobility_id) { if (ie_5gs_mobility_id) {
return ie_5gs_mobility_id->gettypeOfIdentity(); return ie_5gs_mobility_id->gettypeOfIdentity();
} else { } else {
return -1; return 0;
} }
} }
...@@ -169,9 +169,9 @@ void RegistrationRequest::setAdditional_GUTI_SUCI_SUPI_format_IMSI( ...@@ -169,9 +169,9 @@ void RegistrationRequest::setAdditional_GUTI_SUCI_SUPI_format_IMSI(
bool RegistrationRequest::getAdditionalGuti(nas::_5G_GUTI_t& guti) { bool RegistrationRequest::getAdditionalGuti(nas::_5G_GUTI_t& guti) {
if (ie_additional_guti) { if (ie_additional_guti) {
ie_additional_guti->get5GGUTI(guti); ie_additional_guti->get5GGUTI(guti);
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -203,7 +203,7 @@ uint8_t RegistrationRequest::getNonCurrentNativeNasKSI() { ...@@ -203,7 +203,7 @@ uint8_t RegistrationRequest::getNonCurrentNativeNasKSI() {
(ie_non_current_native_nas_ksi->getasKeyIdentifier()); (ie_non_current_native_nas_ksi->getasKeyIdentifier());
return a; return a;
} else { } else {
return -1; return 0;
} }
} }
...@@ -217,7 +217,7 @@ uint8_t RegistrationRequest::get5GMMCapability() { ...@@ -217,7 +217,7 @@ uint8_t RegistrationRequest::get5GMMCapability() {
if (ie_5g_mm_capability) if (ie_5g_mm_capability)
return ie_5g_mm_capability->getValue(); return ie_5g_mm_capability->getValue();
else else
return -1; return 0;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -239,7 +239,7 @@ bool RegistrationRequest::getUeSecurityCapability(uint8_t& ea, uint8_t& ia) { ...@@ -239,7 +239,7 @@ bool RegistrationRequest::getUeSecurityCapability(uint8_t& ea, uint8_t& ia) {
ea = ie_ue_security_capability->getEASel(); ea = ie_ue_security_capability->getEASel();
ia = ie_ue_security_capability->getIASel(); ia = ie_ue_security_capability->getIASel();
} else { } else {
return -1; return false;
} }
return true; return true;
} }
...@@ -255,7 +255,7 @@ bool RegistrationRequest::getUeSecurityCapability( ...@@ -255,7 +255,7 @@ bool RegistrationRequest::getUeSecurityCapability(
eia = ie_ue_security_capability->getEIASel(); eia = ie_ue_security_capability->getEIASel();
} }
} else { } else {
return -1; return false;
} }
return true; return true;
} }
...@@ -272,7 +272,7 @@ bool RegistrationRequest::getRequestedNssai( ...@@ -272,7 +272,7 @@ bool RegistrationRequest::getRequestedNssai(
if (ie_requested_NSSAI) { if (ie_requested_NSSAI) {
ie_requested_NSSAI->getValue(nssai); ie_requested_NSSAI->getValue(nssai);
} else { } else {
return -1; return false;
} }
return true; return true;
} }
...@@ -297,7 +297,7 @@ bool RegistrationRequest::getS1UeNetworkCapability(uint8_t& eea, uint8_t& eia) { ...@@ -297,7 +297,7 @@ bool RegistrationRequest::getS1UeNetworkCapability(uint8_t& eea, uint8_t& eia) {
eea = ie_s1_ue_network_capability->getEEASel(); eea = ie_s1_ue_network_capability->getEEASel();
eia = ie_s1_ue_network_capability->getEIASel(); eia = ie_s1_ue_network_capability->getEIASel();
} else { } else {
return -1; return false;
} }
return true; return true;
} }
...@@ -312,7 +312,7 @@ uint16_t RegistrationRequest::getUplinkDataStatus() { ...@@ -312,7 +312,7 @@ uint16_t RegistrationRequest::getUplinkDataStatus() {
if (ie_uplink_data_status) { if (ie_uplink_data_status) {
return ie_uplink_data_status->getValue(); return ie_uplink_data_status->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -326,7 +326,7 @@ uint16_t RegistrationRequest::getPduSessionStatus() { ...@@ -326,7 +326,7 @@ uint16_t RegistrationRequest::getPduSessionStatus() {
if (ie_PDU_session_status) { if (ie_PDU_session_status) {
return ie_PDU_session_status->getValue(); return ie_PDU_session_status->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -340,9 +340,9 @@ bool RegistrationRequest::getMicoIndication(uint8_t& sprti, uint8_t& raai) { ...@@ -340,9 +340,9 @@ bool RegistrationRequest::getMicoIndication(uint8_t& sprti, uint8_t& raai) {
if (ie_PDU_session_status) { if (ie_PDU_session_status) {
sprti = ie_MICO_indicationl->getSPRTI(); sprti = ie_MICO_indicationl->getSPRTI();
raai = ie_MICO_indicationl->getRAAI(); raai = ie_MICO_indicationl->getRAAI();
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -356,9 +356,9 @@ bool RegistrationRequest::getUeStatus(uint8_t& n1ModeReg, uint8_t& s1ModeReg) { ...@@ -356,9 +356,9 @@ bool RegistrationRequest::getUeStatus(uint8_t& n1ModeReg, uint8_t& s1ModeReg) {
if (ie_ue_status) { if (ie_ue_status) {
n1ModeReg = ie_ue_status->getN1(); n1ModeReg = ie_ue_status->getN1();
s1ModeReg = ie_ue_status->getS1(); s1ModeReg = ie_ue_status->getS1();
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -372,7 +372,7 @@ uint16_t RegistrationRequest::getAllowedPduSessionStatus() { ...@@ -372,7 +372,7 @@ uint16_t RegistrationRequest::getAllowedPduSessionStatus() {
if (ie_allowed_PDU_session_status) { if (ie_allowed_PDU_session_status) {
return ie_allowed_PDU_session_status->getValue(); return ie_allowed_PDU_session_status->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -386,7 +386,7 @@ uint8_t RegistrationRequest::getUEsUsageSetting() { ...@@ -386,7 +386,7 @@ uint8_t RegistrationRequest::getUEsUsageSetting() {
if (ie_ues_usage_setting) { if (ie_ues_usage_setting) {
return ie_ues_usage_setting->getValue(); return ie_ues_usage_setting->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -400,7 +400,7 @@ uint8_t RegistrationRequest::get5GSDrxParameters() { ...@@ -400,7 +400,7 @@ uint8_t RegistrationRequest::get5GSDrxParameters() {
if (ie_5gs_drx_parameters) { if (ie_5gs_drx_parameters) {
return ie_5gs_drx_parameters->getValue(); return ie_5gs_drx_parameters->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -413,9 +413,9 @@ void RegistrationRequest::setEPS_NAS_Message_Container(bstring value) { ...@@ -413,9 +413,9 @@ void RegistrationRequest::setEPS_NAS_Message_Container(bstring value) {
bool RegistrationRequest::getEpsNasMessageContainer(bstring& epsNas) { bool RegistrationRequest::getEpsNasMessageContainer(bstring& epsNas) {
if (ie_eps_nas_message_container) { if (ie_eps_nas_message_container) {
ie_eps_nas_message_container->getValue(epsNas); ie_eps_nas_message_container->getValue(epsNas);
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -429,7 +429,7 @@ bool RegistrationRequest::getLadnIndication(std::vector<bstring>& ladnValue) { ...@@ -429,7 +429,7 @@ bool RegistrationRequest::getLadnIndication(std::vector<bstring>& ladnValue) {
if (ie_ladn_indication) { if (ie_ladn_indication) {
return ie_ladn_indication->getValue(ladnValue); return ie_ladn_indication->getValue(ladnValue);
} else { } else {
return -1; return 0;
} }
} }
...@@ -443,7 +443,7 @@ uint8_t RegistrationRequest::getPayloadContainerType() { ...@@ -443,7 +443,7 @@ uint8_t RegistrationRequest::getPayloadContainerType() {
if (ie_payload_container_type) { if (ie_payload_container_type) {
return ie_payload_container_type->getValue(); return ie_payload_container_type->getValue();
} else { } else {
return -1; return 0;
} }
} }
...@@ -458,9 +458,9 @@ bool RegistrationRequest::getPayloadContainer( ...@@ -458,9 +458,9 @@ bool RegistrationRequest::getPayloadContainer(
std::vector<PayloadContainerEntry>& content) { std::vector<PayloadContainerEntry>& content) {
if (ie_payload_container) { if (ie_payload_container) {
ie_payload_container->getValue(content); ie_payload_container->getValue(content);
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -476,9 +476,9 @@ bool RegistrationRequest::getNetworkSlicingIndication( ...@@ -476,9 +476,9 @@ bool RegistrationRequest::getNetworkSlicingIndication(
if (ie_network_slicing_indication) { if (ie_network_slicing_indication) {
dcni = ie_network_slicing_indication->getDCNI(); dcni = ie_network_slicing_indication->getDCNI();
nssci = ie_network_slicing_indication->getNSSCI(); nssci = ie_network_slicing_indication->getNSSCI();
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -498,9 +498,9 @@ bool RegistrationRequest::get5GSUpdateType( ...@@ -498,9 +498,9 @@ bool RegistrationRequest::get5GSUpdateType(
_5gs_pnb_ciot = ie_5gs_update_type->get_5GS_PNB_CIoT(); _5gs_pnb_ciot = ie_5gs_update_type->get_5GS_PNB_CIoT();
ng_ran_rcu = ie_5gs_update_type->getNG_RAN(); ng_ran_rcu = ie_5gs_update_type->getNG_RAN();
sms_requested = ie_5gs_update_type->getSMS(); sms_requested = ie_5gs_update_type->getSMS();
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -513,9 +513,9 @@ void RegistrationRequest::setNAS_Message_Container(bstring value) { ...@@ -513,9 +513,9 @@ void RegistrationRequest::setNAS_Message_Container(bstring value) {
bool RegistrationRequest::getNasMessageContainer(bstring& nas) { bool RegistrationRequest::getNasMessageContainer(bstring& nas) {
if (ie_nas_message_container) { if (ie_nas_message_container) {
ie_nas_message_container->getValue(nas); ie_nas_message_container->getValue(nas);
return 0; return true;
} else { } else {
return -1; return false;
} }
} }
...@@ -529,7 +529,7 @@ uint16_t RegistrationRequest::getEpsBearerContextStatus() { ...@@ -529,7 +529,7 @@ uint16_t RegistrationRequest::getEpsBearerContextStatus() {
if (ie_eps_bearer_context_status) { if (ie_eps_bearer_context_status) {
return ie_eps_bearer_context_status->getValue(); return ie_eps_bearer_context_status->getValue();
} else { } else {
return -1; return 0;
} }
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
*/ */
#include "DownLinkNasTransport.hpp" #include "DownLinkNasTransport.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "asn_codecs.h" #include "asn_codecs.h"
...@@ -83,9 +84,8 @@ void DownLinkNasTransportMsg::setMessageType() { ...@@ -83,9 +84,8 @@ void DownLinkNasTransportMsg::setMessageType() {
&(downLinkNasTransportPdu->choice.initiatingMessage->value.choice &(downLinkNasTransportPdu->choice.initiatingMessage->value.choice
.DownlinkNASTransport); .DownlinkNASTransport);
} else { } else {
cout << "[warning] This information doesn't refer to DownlinkNASTransport " Logger::ngap().warn(
"Message!!!" "This information doesn't refer to DownlinkNASTransport Message");
<< endl;
} }
} }
...@@ -103,13 +103,13 @@ void DownLinkNasTransportMsg::setAmfUeNgapId(unsigned long id) { ...@@ -103,13 +103,13 @@ void DownLinkNasTransportMsg::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID); int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -127,13 +127,13 @@ void DownLinkNasTransportMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) { ...@@ -127,13 +127,13 @@ void DownLinkNasTransportMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID); int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode RAN_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -151,13 +151,13 @@ void DownLinkNasTransportMsg::setOldAmfName(const std::string name) { ...@@ -151,13 +151,13 @@ void DownLinkNasTransportMsg::setOldAmfName(const std::string name) {
int ret = oldAmfName->encode2AmfName(&ie->value.choice.AMFName); int ret = oldAmfName->encode2AmfName(&ie->value.choice.AMFName);
if (!ret) { if (!ret) {
cout << "encode oldAmfName IE error" << endl; Logger::ngap().error("Encode oldAmfName IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode oldAmfName IE error" << endl; if (ret != 0) Logger::ngap().error("Encode oldAmfName IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -176,7 +176,7 @@ void DownLinkNasTransportMsg::setRanPagingPriority(uint8_t pagingPriority) { ...@@ -176,7 +176,7 @@ void DownLinkNasTransportMsg::setRanPagingPriority(uint8_t pagingPriority) {
int ret = ranPagingPriority->encode2RANPagingPriority( int ret = ranPagingPriority->encode2RANPagingPriority(
ie->value.choice.RANPagingPriority); ie->value.choice.RANPagingPriority);
if (!ret) { if (!ret) {
cout << "encode RANPagingPriority IE error" << endl; Logger::ngap().error("Encode RANPagingPriority IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
...@@ -201,13 +201,13 @@ void DownLinkNasTransportMsg::setNasPdu(uint8_t* nas, size_t sizeofnas) { ...@@ -201,13 +201,13 @@ void DownLinkNasTransportMsg::setNasPdu(uint8_t* nas, size_t sizeofnas) {
int ret = nasPdu->encode2octetstring(ie->value.choice.NAS_PDU); int ret = nasPdu->encode2octetstring(ie->value.choice.NAS_PDU);
if (!ret) { if (!ret) {
cout << "encode NAS_PDU IE error" << endl; Logger::ngap().error("Encode NAS_PDU IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode NAS_PDU IE error" << endl; if (ret != 0) Logger::ngap().error("Encode NAS_PDU IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -226,13 +226,13 @@ void DownLinkNasTransportMsg::setIndex2Rat_Frequency_SelectionPriority( ...@@ -226,13 +226,13 @@ void DownLinkNasTransportMsg::setIndex2Rat_Frequency_SelectionPriority(
int ret = indexToRFSP->encode2IndexToRFSP(ie->value.choice.IndexToRFSP); int ret = indexToRFSP->encode2IndexToRFSP(ie->value.choice.IndexToRFSP);
if (!ret) { if (!ret) {
cout << "encode IndexToRFSP IE error" << endl; Logger::ngap().error("Encode IndexToRFSP IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&downLinkNasTransportIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode IndexToRFSP IE error" << endl; if (ret != 0) Logger::ngap().error("Encode IndexToRFSP IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
......
...@@ -30,14 +30,17 @@ extern "C" { ...@@ -30,14 +30,17 @@ extern "C" {
using namespace std; using namespace std;
namespace ngap { namespace ngap {
DownlinkRANStatusTransfer::DownlinkRANStatusTransfer() { DownlinkRANStatusTransfer::DownlinkRANStatusTransfer() {
amfUeNgapId = NULL; amfUeNgapId = nullptr;
ranUeNgapId = NULL; ranUeNgapId = nullptr;
ranStatusTransfer_TransparentContainer = NULL; ranStatusTransfer_TransparentContainer = nullptr;
DownlinkranstatustransferIEs = NULL; DownlinkranstatustransferIEs = nullptr;
DownlinkranstatustransferPDU = NULL; DownlinkranstatustransferPDU = nullptr;
} }
DownlinkRANStatusTransfer::~DownlinkRANStatusTransfer() {} DownlinkRANStatusTransfer::~DownlinkRANStatusTransfer() {}
void DownlinkRANStatusTransfer::setAmfUeNgapId(unsigned long id) { void DownlinkRANStatusTransfer::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID(); if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id); amfUeNgapId->setAMF_UE_NGAP_ID(id);
...@@ -61,6 +64,7 @@ void DownlinkRANStatusTransfer::setAmfUeNgapId(unsigned long id) { ...@@ -61,6 +64,7 @@ void DownlinkRANStatusTransfer::setAmfUeNgapId(unsigned long id) {
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl; if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl;
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void DownlinkRANStatusTransfer::setRanUeNgapId(uint32_t id) { void DownlinkRANStatusTransfer::setRanUeNgapId(uint32_t id) {
if (!ranUeNgapId) ranUeNgapId = new RAN_UE_NGAP_ID(); if (!ranUeNgapId) ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(id); ranUeNgapId->setRanUeNgapId(id);
...@@ -152,6 +156,7 @@ void DownlinkRANStatusTransfer::setRANStatusTransfer_TransparentContainer( ...@@ -152,6 +156,7 @@ void DownlinkRANStatusTransfer::setRANStatusTransfer_TransparentContainer(
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
*/ */
} }
void DownlinkRANStatusTransfer::setmessagetype() { void DownlinkRANStatusTransfer::setmessagetype() {
if (!DownlinkranstatustransferPDU) { if (!DownlinkranstatustransferPDU) {
DownlinkranstatustransferPDU = DownlinkranstatustransferPDU =
...@@ -180,6 +185,7 @@ void DownlinkRANStatusTransfer::setmessagetype() { ...@@ -180,6 +185,7 @@ void DownlinkRANStatusTransfer::setmessagetype() {
<< endl; << endl;
} }
} }
int DownlinkRANStatusTransfer::encodetobuffer(uint8_t* buf, int buf_size) { int DownlinkRANStatusTransfer::encodetobuffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, DownlinkranstatustransferPDU); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, DownlinkranstatustransferPDU);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
*/ */
#include "HandoverCommandMsg.hpp" #include "HandoverCommandMsg.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "Ngap_NGAP-PDU.h" #include "Ngap_NGAP-PDU.h"
#include "Ngap_PDUSessionResourceHandoverItem.h" #include "Ngap_PDUSessionResourceHandoverItem.h"
...@@ -39,28 +41,35 @@ using namespace std; ...@@ -39,28 +41,35 @@ using namespace std;
namespace ngap { namespace ngap {
HandoverCommandMsg::HandoverCommandMsg() { HandoverCommandMsg::HandoverCommandMsg() {
amfUeNgapId = NULL; amfUeNgapId = nullptr;
ranUeNgapId = NULL; ranUeNgapId = nullptr;
ngap_handovertype = NULL; ngap_handovertype = nullptr;
NASSecurityParametersFromNGRAN = NULL; NASSecurityParametersFromNGRAN = nullptr;
PDUSessionResourceHandoverList = NULL; PDUSessionResourceHandoverList = nullptr;
PDUSessionResourceToReleaseListHOCmd = NULL; PDUSessionResourceToReleaseListHOCmd = nullptr;
TargetToSource_TransparentContainer = NULL; TargetToSource_TransparentContainer = nullptr;
CriticalityDiagnostics = NULL; CriticalityDiagnostics = nullptr;
handoverCommandPdu = NULL; handoverCommandPdu = nullptr;
handoverCommandIEs = NULL; handoverCommandIEs = nullptr;
} }
HandoverCommandMsg::~HandoverCommandMsg() {} HandoverCommandMsg::~HandoverCommandMsg() {}
unsigned long HandoverCommandMsg::getAmfUeNgapId() { unsigned long HandoverCommandMsg::getAmfUeNgapId() {
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID(); return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
} }
uint32_t HandoverCommandMsg::getRanUeNgapId() { uint32_t HandoverCommandMsg::getRanUeNgapId() {
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId(); return ranUeNgapId->getRanUeNgapId();
else
return 0;
} }
bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
handoverCommandPdu = ngap_msg_pdu; handoverCommandPdu = ngap_msg_pdu;
if (handoverCommandPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) { if (handoverCommandPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
...@@ -74,11 +83,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -74,11 +83,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value handoverCommandIEs = &handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand; .choice.HandoverCommand;
} else { } else {
cout << "Check HandoverCommand message error!!!" << endl; Logger::ngap().error("Check HandoverCommand message error");
return false; return false;
} }
} else { } else {
cout << "HandoverRequired MessageType error!!!" << endl; Logger::ngap().error("HandoverRequired MessageType error");
return false; return false;
} }
for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++) { for (int i = 0; i < handoverCommandIEs->protocolIEs.list.count; i++) {
...@@ -92,11 +101,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -92,11 +101,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID( if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverCommandIEs->protocolIEs.list.array[i] handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) { ->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -109,11 +118,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -109,11 +118,11 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID( if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverCommandIEs->protocolIEs.list.array[i] handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) { ->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -126,7 +135,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -126,7 +135,7 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i] *ngap_handovertype = handoverCommandIEs->protocolIEs.list.array[i]
->value.choice.HandoverType; ->value.choice.HandoverType;
} else { } else {
cout << "decoded ngap Handover Type IE error" << endl; Logger::ngap().error("Decoded ngap Handover Type IE error");
return false; return false;
} }
} break; } break;
...@@ -136,8 +145,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -136,8 +145,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present == handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList) { Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceHandoverList) {
} else { } else {
cout << "decoded ngap PDUSessionResourceHandoverList IE error" Logger::ngap().error(
<< endl; "Decoded ngap PDUSessionResourceHandoverList IE error");
return false; return false;
} }
} break; } break;
...@@ -147,8 +156,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -147,8 +156,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present == handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd) { Ngap_HandoverCommandIEs__value_PR_PDUSessionResourceToReleaseListHOCmd) {
} else { } else {
cout << "decoded ngap PDUSessionResourceToReleaseListHOCmd IE error" Logger::ngap().error(
<< endl; "Decoded ngap PDUSessionResourceToReleaseListHOCmd IE error");
return false; return false;
} }
} break; } break;
...@@ -158,8 +167,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -158,8 +167,8 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present == handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer) { Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer) {
} else { } else {
cout << "decoded ngap TargetToSource_TransparentContainer IE error" Logger::ngap().error(
<< endl; "Decoded ngap TargetToSource_TransparentContainer IE error");
return false; return false;
} }
} break; } break;
...@@ -169,12 +178,12 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -169,12 +178,12 @@ bool HandoverCommandMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverCommandIEs->protocolIEs.list.array[i]->value.present == handoverCommandIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics) { Ngap_HandoverCommandIEs__value_PR_CriticalityDiagnostics) {
} else { } else {
cout << "decoded ngap CriticalityDiagnostics IE error" << endl; Logger::ngap().error("Decoded ngap CriticalityDiagnostics IE error");
return false; return false;
} }
} break; } break;
default: { default: {
cout << "decoded ngap message pdu error" << endl; Logger::ngap().error("Decoded NGAP message PDU error");
return false; return false;
} }
} }
...@@ -212,9 +221,8 @@ void HandoverCommandMsg::setMessageType() { ...@@ -212,9 +221,8 @@ void HandoverCommandMsg::setMessageType() {
handoverCommandIEs = &(handoverCommandPdu->choice.successfulOutcome->value handoverCommandIEs = &(handoverCommandPdu->choice.successfulOutcome->value
.choice.HandoverCommand); .choice.HandoverCommand);
} else { } else {
cout << "[warning] This information doesn't refer to HandoverCommand " Logger::ngap().warn(
"Message!!!" "This information doesn't refer to HandoverCommand message");
<< endl;
} }
} }
...@@ -230,13 +238,13 @@ void HandoverCommandMsg::setAmfUeNgapId(unsigned long id) { ...@@ -230,13 +238,13 @@ void HandoverCommandMsg::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID); int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -252,13 +260,14 @@ void HandoverCommandMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) { ...@@ -252,13 +260,14 @@ void HandoverCommandMsg::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID); int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode RAN_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -271,7 +280,8 @@ void HandoverCommandMsg::setHandoverType(long type) { ...@@ -271,7 +280,8 @@ void HandoverCommandMsg::setHandoverType(long type) {
ie->value.present = Ngap_HandoverCommandIEs__value_PR_HandoverType; ie->value.present = Ngap_HandoverCommandIEs__value_PR_HandoverType;
ie->value.choice.HandoverType = type; ie->value.choice.HandoverType = type;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode HandoverType IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode HandoverType IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -290,8 +300,10 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList( ...@@ -290,8 +300,10 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList(
item->pDUSessionID = list[i].pduSessionId; item->pDUSessionID = list[i].pduSessionId;
item->handoverCommandTransfer = list[i].HandoverCommandTransfer; item->handoverCommandTransfer = list[i].HandoverCommandTransfer;
int ret = ASN_SEQUENCE_ADD(&PDUSessionResourceHandoverList->list, item); int ret = ASN_SEQUENCE_ADD(&PDUSessionResourceHandoverList->list, item);
if (ret != 0) if (ret != 0)
cout << "encode PDUSessionResourceHandoverListItem IE error" << endl; Logger::ngap().error(
"Encode PDUSessionResourceHandoverListItem IE error");
} }
ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList; ie->id = Ngap_ProtocolIE_ID_id_PDUSessionResourceHandoverList;
...@@ -302,7 +314,8 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList( ...@@ -302,7 +314,8 @@ void HandoverCommandMsg::setPduSessionResourceHandoverList(
*PDUSessionResourceHandoverList; *PDUSessionResourceHandoverList;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) if (ret != 0)
cout << "encode PDUSessionResourceHandoverList IE error" << endl; Logger::ngap().error("Encode PDUSessionResourceHandoverList IE error");
// free_wrapper((void**) &item); // free_wrapper((void**) &item);
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -321,7 +334,7 @@ void HandoverCommandMsg::setTargetToSource_TransparentContainer( ...@@ -321,7 +334,7 @@ void HandoverCommandMsg::setTargetToSource_TransparentContainer(
Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer; Ngap_HandoverCommandIEs__value_PR_TargetToSource_TransparentContainer;
ie->value.choice.TargetToSource_TransparentContainer = targetTosource; ie->value.choice.TargetToSource_TransparentContainer = targetTosource;
int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverCommandIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode HandoverType IE error" << endl; if (ret != 0) Logger::ngap().error("Encode HandoverType IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
......
...@@ -60,8 +60,8 @@ class HandoverCommandMsg { ...@@ -60,8 +60,8 @@ class HandoverCommandMsg {
int encode2buffer(uint8_t* buf, int buf_size); int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu); bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
unsigned long getAmfUeNgapId(); // return -1;(不存在) unsigned long getAmfUeNgapId(); // return -1;
uint32_t getRanUeNgapId(); // return -1;(不存在) uint32_t getRanUeNgapId(); // return -1;
/*void getHandoverType(Ngap_HandoverType_t &handovertype); /*void getHandoverType(Ngap_HandoverType_t &handovertype);
void getCause(Cause cause); void getCause(Cause cause);
void getTargetID(Ngap_TargetID_t targetID); void getTargetID(Ngap_TargetID_t targetID);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
\email: contact@openairinterface.org \email: contact@openairinterface.org
*/ */
#include "HandoverNotifyMsg.hpp" #include "HandoverNotifyMsg.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "asn_codecs.h" #include "asn_codecs.h"
...@@ -51,8 +52,12 @@ HandoverNotifyMsg::HandoverNotifyMsg() { ...@@ -51,8 +52,12 @@ HandoverNotifyMsg::HandoverNotifyMsg() {
HandoverNotifyMsg::~HandoverNotifyMsg(){}; HandoverNotifyMsg::~HandoverNotifyMsg(){};
unsigned long HandoverNotifyMsg::getAmfUeNgapId() { unsigned long HandoverNotifyMsg::getAmfUeNgapId() {
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID(); return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
} }
int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) { int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverNotifyPdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverNotifyPdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
...@@ -60,7 +65,9 @@ int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -60,7 +65,9 @@ int HandoverNotifyMsg::encode2buffer(uint8_t* buf, int buf_size) {
cout << "er.encoded(" << er.encoded << ")" << endl; cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded; return er.encoded;
} }
bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
handoverNotifyPdu = ngap_msg_pdu; handoverNotifyPdu = ngap_msg_pdu;
if (handoverNotifyPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage) { if (handoverNotifyPdu->present == Ngap_NGAP_PDU_PR_initiatingMessage) {
...@@ -74,11 +81,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -74,11 +81,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverNotifyIEs = &handoverNotifyPdu->choice.initiatingMessage->value handoverNotifyIEs = &handoverNotifyPdu->choice.initiatingMessage->value
.choice.HandoverNotify; .choice.HandoverNotify;
} else { } else {
cout << "Check HandoverNotify message error!!!" << endl; Logger::ngap().error("Check HandoverNotify message error!");
return false; return false;
} }
} else { } else {
cout << "HandoverNotify MessageType error!!!" << endl; Logger::ngap().error("HandoverNotify MessageType error!");
return false; return false;
} }
for (int i = 0; i < handoverNotifyIEs->protocolIEs.list.count; i++) { for (int i = 0; i < handoverNotifyIEs->protocolIEs.list.count; i++) {
...@@ -92,11 +99,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -92,11 +99,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID( if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverNotifyIEs->protocolIEs.list.array[i] handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) { ->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -109,11 +116,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -109,11 +116,11 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID( if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverNotifyIEs->protocolIEs.list.array[i] handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) { ->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -126,16 +133,17 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -126,16 +133,17 @@ bool HandoverNotifyMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!userLocationInformation->decodefromUserLocationInformation( if (!userLocationInformation->decodefromUserLocationInformation(
&handoverNotifyIEs->protocolIEs.list.array[i] &handoverNotifyIEs->protocolIEs.list.array[i]
->value.choice.UserLocationInformation)) { ->value.choice.UserLocationInformation)) {
cout << "decoded ngap UserLocationInformation IE error" << endl; Logger::ngap().error(
"Decoded ngap UserLocationInformation IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap UserLocationInformation IE error" << endl; Logger::ngap().error("Decoded ngap UserLocationInformation IE error");
return false; return false;
} }
} break; } break;
default: { default: {
cout << "decoded ngap message pdu error" << endl; Logger::ngap().error("Decoded NGAP message PDU error");
return false; return false;
} }
} }
...@@ -175,20 +183,28 @@ void HandoverNotifyMsg::setUserLocationInfoNR( ...@@ -175,20 +183,28 @@ void HandoverNotifyMsg::setUserLocationInfoNR(
int ret = userLocationInformation->encodefromUserLocationInformation( int ret = userLocationInformation->encodefromUserLocationInformation(
&ie->value.choice.UserLocationInformation); &ie->value.choice.UserLocationInformation);
if (!ret) { if (!ret) {
cout << "encode UserLocationInformation IE error" << endl; Logger::ngap().error("Encode UserLocationInformation IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverNotifyIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverNotifyIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UserLocationInformation IE error" << endl; if (ret != 0) Logger::ngap().error("Encode UserLocationInformation IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
uint32_t HandoverNotifyMsg::getRanUeNgapId() { uint32_t HandoverNotifyMsg::getRanUeNgapId() {
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId(); return ranUeNgapId->getRanUeNgapId();
else
return 0;
} }
bool HandoverNotifyMsg::getUserLocationInfoNR( bool HandoverNotifyMsg::getUserLocationInfoNR(
struct NrCgi_s& cig, struct Tai_s& tai) { struct NrCgi_s& cig, struct Tai_s& tai) {
if (!userLocationInformation) return false;
UserLocationInformationNR* informationNR; UserLocationInformationNR* informationNR;
userLocationInformation->getInformation(informationNR); userLocationInformation->getInformation(informationNR);
if (userLocationInformation->getChoiceOfUserLocationInformation() != if (userLocationInformation->getChoiceOfUserLocationInformation() !=
......
...@@ -48,8 +48,8 @@ class HandoverNotifyMsg { ...@@ -48,8 +48,8 @@ class HandoverNotifyMsg {
int encode2buffer(uint8_t* buf, int buf_size); int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu); bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
void setUserLocationInfoNR(struct NrCgi_s cig, struct Tai_s tai); void setUserLocationInfoNR(struct NrCgi_s cig, struct Tai_s tai);
unsigned long getAmfUeNgapId(); // return -1; unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId(); // return -1; uint32_t getRanUeNgapId();
bool getUserLocationInfoNR(struct NrCgi_s& cig, struct Tai_s& tai); bool getUserLocationInfoNR(struct NrCgi_s& cig, struct Tai_s& tai);
private: private:
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include "HandoverPreparationFailure.hpp"
#include "logger.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h"
#include "constr_TYPE.h"
#include "constraints.h"
#include "dynamic_memory_check.h"
#include "per_decoder.h"
#include "per_encoder.h"
}
#include <iostream>
#include <vector>
using namespace std;
namespace ngap {
HandoverPreparationFailure::HandoverPreparationFailure() {
amfUeNgapId = nullptr;
ranUeNgapId = nullptr;
cause = nullptr;
hoPreparationFailureIEs = nullptr;
CriticalityDiagnostics = nullptr;
}
HandoverPreparationFailure::~HandoverPreparationFailure() {}
unsigned long HandoverPreparationFailure::getAmfUeNgapId() const {
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
}
uint32_t HandoverPreparationFailure::getRanUeNgapId() const {
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId();
else
return 0;
}
bool HandoverPreparationFailure::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
hoPreparationFailurePdu = ngap_msg_pdu;
if (hoPreparationFailurePdu->present ==
Ngap_NGAP_PDU_PR_unsuccessfulOutcome) {
if (hoPreparationFailurePdu->choice.unsuccessfulOutcome &&
hoPreparationFailurePdu->choice.unsuccessfulOutcome->procedureCode ==
Ngap_ProcedureCode_id_HandoverPreparation &&
hoPreparationFailurePdu->choice.unsuccessfulOutcome->criticality ==
Ngap_Criticality_reject &&
hoPreparationFailurePdu->choice.unsuccessfulOutcome->value.present ==
Ngap_UnsuccessfulOutcome__value_PR_HandoverPreparationFailure) {
hoPreparationFailureIEs =
&hoPreparationFailurePdu->choice.unsuccessfulOutcome->value.choice
.HandoverPreparationFailure;
} else {
Logger::ngap().error("Check HandoverPreparationFailure message error");
return false;
}
} else {
Logger::ngap().error("HandoverPreparationFailure MessageType error");
return false;
}
for (int i = 0; i < hoPreparationFailureIEs->protocolIEs.list.count; i++) {
switch (hoPreparationFailureIEs->protocolIEs.list.array[i]->id) {
case Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID: {
if (hoPreparationFailureIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
hoPreparationFailureIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverPreparationFailureIEs__value_PR_AMF_UE_NGAP_ID) {
amfUeNgapId = new AMF_UE_NGAP_ID();
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
hoPreparationFailureIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) {
Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false;
}
} else {
Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID: {
if (hoPreparationFailureIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
hoPreparationFailureIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverPreparationFailureIEs__value_PR_RAN_UE_NGAP_ID) {
ranUeNgapId = new RAN_UE_NGAP_ID();
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
hoPreparationFailureIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) {
Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false;
}
} else {
Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_Cause: {
if (hoPreparationFailureIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
hoPreparationFailureIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverPreparationFailureIEs__value_PR_Cause) {
cause = new Cause();
if (!cause->decodefromCause(
&hoPreparationFailureIEs->protocolIEs.list.array[i]
->value.choice.Cause)) {
Logger::ngap().error("Decoded NGAP Cause IE error");
return false;
}
} else {
Logger::ngap().error("Decoded NGAP Cause IE error");
return false;
}
} break;
case Ngap_ProtocolIE_ID_id_CriticalityDiagnostics: {
if (hoPreparationFailureIEs->protocolIEs.list.array[i]->criticality ==
Ngap_Criticality_ignore &&
hoPreparationFailureIEs->protocolIEs.list.array[i]->value.present ==
Ngap_HandoverPreparationFailureIEs__value_PR_CriticalityDiagnostics) {
} else {
Logger::ngap().error("Decoded NGAP CriticalityDiagnostics IE error");
return false;
}
} break;
default: {
Logger::ngap().error("Decoded NGAP message PDU error");
return false;
}
}
}
return true;
}
int HandoverPreparationFailure::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, hoPreparationFailurePdu);
asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, hoPreparationFailurePdu, buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl;
return er.encoded;
}
void HandoverPreparationFailure::setMessageType() {
if (!hoPreparationFailurePdu)
hoPreparationFailurePdu =
(Ngap_NGAP_PDU_t*) calloc(1, sizeof(Ngap_NGAP_PDU_t));
MessageType hoPreparationFailureMessageTypeIE;
hoPreparationFailureMessageTypeIE.setProcedureCode(
Ngap_ProcedureCode_id_HandoverPreparation);
hoPreparationFailureMessageTypeIE.setTypeOfMessage(
Ngap_NGAP_PDU_PR_unsuccessfulOutcome);
hoPreparationFailureMessageTypeIE.setCriticality(Ngap_Criticality_reject);
hoPreparationFailureMessageTypeIE.setValuePresent(
Ngap_UnsuccessfulOutcome__value_PR_HandoverPreparationFailure);
if (hoPreparationFailureMessageTypeIE.getProcedureCode() ==
Ngap_ProcedureCode_id_HandoverPreparation &&
hoPreparationFailureMessageTypeIE.getTypeOfMessage() ==
Ngap_NGAP_PDU_PR_unsuccessfulOutcome) {
hoPreparationFailureMessageTypeIE.encode2pdu(hoPreparationFailurePdu);
hoPreparationFailureIEs =
&(hoPreparationFailurePdu->choice.unsuccessfulOutcome->value.choice
.HandoverPreparationFailure);
} else {
Logger::ngap().warn(
"This information doesn't refer to HandoverPreparationFailure message");
}
}
void HandoverPreparationFailure::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id);
Ngap_HandoverPreparationFailureIEs_t* ie =
(Ngap_HandoverPreparationFailureIEs_t*) calloc(
1, sizeof(Ngap_HandoverPreparationFailureIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_AMF_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present =
Ngap_HandoverPreparationFailureIEs__value_PR_AMF_UE_NGAP_ID;
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) {
Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&hoPreparationFailureIEs->protocolIEs.list, ie);
if (ret != 0) Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie);
}
void HandoverPreparationFailure::setRanUeNgapId(uint32_t ran_ue_ngap_id) {
if (!ranUeNgapId) ranUeNgapId = new RAN_UE_NGAP_ID();
ranUeNgapId->setRanUeNgapId(ran_ue_ngap_id);
Ngap_HandoverPreparationFailureIEs_t* ie =
(Ngap_HandoverPreparationFailureIEs_t*) calloc(
1, sizeof(Ngap_HandoverPreparationFailureIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_RAN_UE_NGAP_ID;
ie->criticality = Ngap_Criticality_reject;
ie->value.present =
Ngap_HandoverPreparationFailureIEs__value_PR_RAN_UE_NGAP_ID;
int ret = ranUeNgapId->encode2RAN_UE_NGAP_ID(ie->value.choice.RAN_UE_NGAP_ID);
if (!ret) {
Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
free_wrapper((void**) &ie);
return;
}
ret = ASN_SEQUENCE_ADD(&hoPreparationFailureIEs->protocolIEs.list, ie);
if (ret != 0) Logger::ngap().error("Encode RAN_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie);
}
void HandoverPreparationFailure::setCause(
Ngap_Cause_PR m_causePresent, long value) //
{
if (!cause) cause = new Cause;
Ngap_HandoverPreparationFailureIEs_t* ie =
(Ngap_HandoverPreparationFailureIEs_t*) calloc(
1, sizeof(Ngap_HandoverPreparationFailureIEs_t));
ie->id = Ngap_ProtocolIE_ID_id_Cause;
ie->criticality = Ngap_Criticality_ignore;
ie->value.present = Ngap_HandoverPreparationFailureIEs__value_PR_Cause;
cause->setChoiceOfCause(m_causePresent);
if (m_causePresent != Ngap_Cause_PR_NOTHING) cause->setValue(value);
cause->encode2Cause(&(ie->value.choice.Cause));
int ret = ASN_SEQUENCE_ADD(&hoPreparationFailureIEs->protocolIEs.list, ie);
if (ret != 0) Logger::ngap().error("Encode Cause IE error");
// free_wrapper((void**) &ie);
}
Ngap_Cause_PR HandoverPreparationFailure::getChoiceOfCause() const {
if (cause)
return cause->getChoiceOfCause();
else
return Ngap_Cause_PR();
}
} // namespace ngap
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef _HANDOVER_PREPARATION_FAILURE_H_
#define _HANDOVER_PREPARATION_FAILURE_H_
#include "AMF-UE-NGAP-ID.hpp"
#include "Cause.hpp"
#include "MessageType.hpp"
#include "NgapIEsStruct.hpp"
#include "RAN-UE-NGAP-ID.hpp"
extern "C" {
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProtocolIE-Field.h"
}
namespace ngap {
class HandoverPreparationFailure {
public:
HandoverPreparationFailure();
virtual ~HandoverPreparationFailure();
void setMessageType(); // Initialize the PDU and populate the MessageType;
void setAmfUeNgapId(unsigned long id); // 40 bits
unsigned long getAmfUeNgapId() const;
void setRanUeNgapId(uint32_t id); // 32 bits
uint32_t getRanUeNgapId() const;
int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
void getCause(Cause& cause) const;
void setCause(Ngap_Cause_PR m_causePresent, long value = 0);
Ngap_Cause_PR getChoiceOfCause() const;
private:
Ngap_NGAP_PDU_t* hoPreparationFailurePdu;
Ngap_HandoverPreparationFailure_t* hoPreparationFailureIEs;
AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId;
Cause* cause;
Ngap_CriticalityDiagnostics_t* CriticalityDiagnostics;
};
} // namespace ngap
#endif
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#include "HandoverRequest.hpp" #include "HandoverRequest.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "Ngap_NGAP-PDU.h" #include "Ngap_NGAP-PDU.h"
...@@ -39,24 +40,27 @@ using namespace std; ...@@ -39,24 +40,27 @@ using namespace std;
namespace ngap { namespace ngap {
HandoverRequest::HandoverRequest() { HandoverRequest::HandoverRequest() {
amfUeNgapId = NULL; amfUeNgapId = nullptr;
handovertype = NULL; handovertype = nullptr;
cause = NULL; cause = nullptr;
ueAggregateMaximumBitRate = NULL; ueAggregateMaximumBitRate = nullptr;
ueSecurityCapabilities = NULL; ueSecurityCapabilities = nullptr;
SecurityContext = NULL; SecurityContext = nullptr;
PDUSessionResourceSetupList = NULL; PDUSessionResourceSetupList = nullptr;
allowedNSSAI = NULL; allowedNSSAI = nullptr;
SourceToTarget_TransparentContainer = NULL; SourceToTarget_TransparentContainer = nullptr;
mobilityrestrictionlist = NULL; mobilityrestrictionlist = nullptr;
guami = NULL; guami = nullptr;
handoverRequestPdu = NULL; handoverRequestPdu = nullptr;
handoverRequestIEs = NULL; handoverRequestIEs = nullptr;
} }
HandoverRequest::~HandoverRequest() {} HandoverRequest::~HandoverRequest() {}
unsigned long HandoverRequest::getAmfUeNgapId() { unsigned long HandoverRequest::getAmfUeNgapId() {
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID(); return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
} }
/*bool HandoverRequest::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu) /*bool HandoverRequest::decodefrompdu(Ngap_NGAP_PDU_t *ngap_msg_pdu)
...@@ -244,11 +248,11 @@ void HandoverRequest::setMessageType() { ...@@ -244,11 +248,11 @@ void HandoverRequest::setMessageType() {
handoverRequestIEs = &(handoverRequestPdu->choice.initiatingMessage->value handoverRequestIEs = &(handoverRequestPdu->choice.initiatingMessage->value
.choice.HandoverRequest); .choice.HandoverRequest);
} else { } else {
cout << "[warning] This information doesn't refer to HandoverRequest " Logger::ngap().warn(
"Message!!!" "This information doesn't refer to HandoverRequest message!");
<< endl;
} }
} }
void HandoverRequest::setAmfUeNgapId(unsigned long id) { void HandoverRequest::setAmfUeNgapId(unsigned long id) {
if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID(); if (!amfUeNgapId) amfUeNgapId = new AMF_UE_NGAP_ID();
amfUeNgapId->setAMF_UE_NGAP_ID(id); amfUeNgapId->setAMF_UE_NGAP_ID(id);
...@@ -261,13 +265,14 @@ void HandoverRequest::setAmfUeNgapId(unsigned long id) { ...@@ -261,13 +265,14 @@ void HandoverRequest::setAmfUeNgapId(unsigned long id) {
int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID); int ret = amfUeNgapId->encode2AMF_UE_NGAP_ID(ie->value.choice.AMF_UE_NGAP_ID);
if (!ret) { if (!ret) {
cout << "encode AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AMF_UE_NGAP_ID IE error" << endl; if (ret != 0) Logger::ngap().error("Encode AMF_UE_NGAP_ID IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -281,7 +286,7 @@ void HandoverRequest::setHandoverType(long type) // 0--intra5gs ...@@ -281,7 +286,7 @@ void HandoverRequest::setHandoverType(long type) // 0--intra5gs
ie->value.present = Ngap_HandoverRequestIEs__value_PR_HandoverType; ie->value.present = Ngap_HandoverRequestIEs__value_PR_HandoverType;
ie->value.choice.HandoverType = type; ie->value.choice.HandoverType = type;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode HandoverType IE error" << endl; if (ret != 0) Logger::ngap().error("Encode HandoverType IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -298,7 +303,7 @@ void HandoverRequest::setCause(Ngap_Cause_PR m_causePresent, long value) // ...@@ -298,7 +303,7 @@ void HandoverRequest::setCause(Ngap_Cause_PR m_causePresent, long value) //
cause->setValue(value); cause->setValue(value);
cause->encode2Cause(&(ie->value.choice.Cause)); cause->encode2Cause(&(ie->value.choice.Cause));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode Cause IE error" << endl; if (ret != 0) Logger::ngap().error("Encode Cause IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -320,7 +325,8 @@ void HandoverRequest::setUEAggregateMaximumBitRate( ...@@ -320,7 +325,8 @@ void HandoverRequest::setUEAggregateMaximumBitRate(
ie->value.choice.UEAggregateMaximumBitRate); ie->value.choice.UEAggregateMaximumBitRate);
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UEAggregateMaximumBitRate IE error" << endl; if (ret != 0)
Logger::ngap().error("Encode UEAggregateMaximumBitRate IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setUESecurityCapabilities( void HandoverRequest::setUESecurityCapabilities(
...@@ -342,14 +348,14 @@ void HandoverRequest::setUESecurityCapabilities( ...@@ -342,14 +348,14 @@ void HandoverRequest::setUESecurityCapabilities(
(ie->value.choice.UESecurityCapabilities)); (ie->value.choice.UESecurityCapabilities));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode UESecurityCapabilities IE error" << endl; if (ret != 0) Logger::ngap().error("Encode UESecurityCapabilities IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setGUAMI( void HandoverRequest::setGUAMI(
PlmnId* m_plmnId, AMFRegionID* m_aMFRegionID, AMFSetID* m_aMFSetID, PlmnId* m_plmnId, AMFRegionID* m_aMFRegionID, AMFSetID* m_aMFSetID,
AMFPointer* m_aMFPointer) { AMFPointer* m_aMFPointer) {
if (!guami) guami = new GUAMI; if (!guami) guami = new GUAMI();
Ngap_HandoverRequestIEs_t* ie = Ngap_HandoverRequestIEs_t* ie =
(Ngap_HandoverRequestIEs_t*) calloc(1, sizeof(Ngap_HandoverRequestIEs_t)); (Ngap_HandoverRequestIEs_t*) calloc(1, sizeof(Ngap_HandoverRequestIEs_t));
...@@ -360,7 +366,8 @@ void HandoverRequest::setGUAMI( ...@@ -360,7 +366,8 @@ void HandoverRequest::setGUAMI(
guami->encode2GUAMI(&(ie->value.choice.GUAMI)); guami->encode2GUAMI(&(ie->value.choice.GUAMI));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode GUAMI IE error" << endl;
if (ret != 0) Logger::ngap().error("Encode GUAMI IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) { void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
...@@ -374,7 +381,8 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) { ...@@ -374,7 +381,8 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
list[i].encode2S_NSSAI(&item->s_NSSAI); list[i].encode2S_NSSAI(&item->s_NSSAI);
int ret = ASN_SEQUENCE_ADD(&allowedNSSAI->list, item); int ret = ASN_SEQUENCE_ADD(&allowedNSSAI->list, item);
if (ret != 0) if (ret != 0)
cout << "encode PDUSessionResourceHandoverListItem IE error" << endl; Logger::ngap().error(
"Encode PDUSessionResourceHandoverListItem IE error");
} }
asn_fprint(stderr, &asn_DEF_Ngap_AllowedNSSAI, allowedNSSAI); asn_fprint(stderr, &asn_DEF_Ngap_AllowedNSSAI, allowedNSSAI);
Ngap_HandoverRequestIEs_t* ie = Ngap_HandoverRequestIEs_t* ie =
...@@ -384,7 +392,7 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) { ...@@ -384,7 +392,7 @@ void HandoverRequest::setAllowedNSSAI(std::vector<S_NSSAI> list) {
ie->value.present = Ngap_HandoverRequestIEs__value_PR_AllowedNSSAI; ie->value.present = Ngap_HandoverRequestIEs__value_PR_AllowedNSSAI;
ie->value.choice.AllowedNSSAI = *allowedNSSAI; ie->value.choice.AllowedNSSAI = *allowedNSSAI;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode AllowedNSSAI IE error" << endl; if (ret != 0) Logger::ngap().error("Encode AllowedNSSAI IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) { void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) {
...@@ -402,7 +410,7 @@ void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) { ...@@ -402,7 +410,7 @@ void HandoverRequest::setSecurityContext(long count, uint8_t* buffer) {
ie->value.present = Ngap_HandoverRequestIEs__value_PR_SecurityContext; ie->value.present = Ngap_HandoverRequestIEs__value_PR_SecurityContext;
ie->value.choice.SecurityContext = *SecurityContext; ie->value.choice.SecurityContext = *SecurityContext;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode SecurityContext IE error" << endl; if (ret != 0) Logger::ngap().error("Encode SecurityContext IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -438,14 +446,14 @@ void HandoverRequest::setPduSessionResourceSetupList( ...@@ -438,14 +446,14 @@ void HandoverRequest::setPduSessionResourceSetupList(
PDUSessionResourceSetupList->encode2PDUSessionResourceSetupListHOReq( PDUSessionResourceSetupList->encode2PDUSessionResourceSetupListHOReq(
&ie->value.choice.PDUSessionResourceSetupListHOReq); &ie->value.choice.PDUSessionResourceSetupListHOReq);
if (!ret) { if (!ret) {
cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl; Logger::ngap().error("Encode PDUSessionResourceSetupListSUReq IE error");
free_wrapper((void**) &ie); free_wrapper((void**) &ie);
return; return;
} }
ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) if (ret != 0)
cout << "encode PDUSessionResourceSetupListSUReq IE error" << endl; Logger::ngap().error("Encode PDUSessionResourceSetupListSUReq IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
...@@ -464,7 +472,7 @@ void HandoverRequest::setSourceToTarget_TransparentContainer( ...@@ -464,7 +472,7 @@ void HandoverRequest::setSourceToTarget_TransparentContainer(
ie->value.choice.SourceToTarget_TransparentContainer = sourceTotarget; ie->value.choice.SourceToTarget_TransparentContainer = sourceTotarget;
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) if (ret != 0)
cout << "encode SourceToTarget_TransparentContainer IE error" << endl; Logger::ngap().error("Encode SourceToTarget_TransparentContainer IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) { void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) {
...@@ -480,7 +488,7 @@ void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) { ...@@ -480,7 +488,7 @@ void HandoverRequest::setMobilityRestrictionList(PlmnId* m_plmnId) {
mobilityrestrictionlist->encodeMobilityRestrictionList( mobilityrestrictionlist->encodeMobilityRestrictionList(
&(ie->value.choice.MobilityRestrictionList)); &(ie->value.choice.MobilityRestrictionList));
int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie); int ret = ASN_SEQUENCE_ADD(&handoverRequestIEs->protocolIEs.list, ie);
if (ret != 0) cout << "encode MobilityRestrictionList IE error" << endl; if (ret != 0) Logger::ngap().error("Encode MobilityRestrictionList IE error");
// free_wrapper((void**) &ie); // free_wrapper((void**) &ie);
} }
......
...@@ -81,7 +81,7 @@ class HandoverRequest { ...@@ -81,7 +81,7 @@ class HandoverRequest {
private: private:
Ngap_NGAP_PDU_t* handoverRequestPdu; Ngap_NGAP_PDU_t* handoverRequestPdu;
Ngap_HandoverRequest_t* handoverRequestIEs; Ngap_HandoverRequest_t* handoverRequestIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID* amfUeNgapId; AMF_UE_NGAP_ID* amfUeNgapId;
Ngap_HandoverType_t* handovertype; Ngap_HandoverType_t* handovertype;
Cause* cause; Cause* cause;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
#include "HandoverRequestAck.hpp" #include "HandoverRequestAck.hpp"
#include "logger.hpp"
#include "GTP-TEID.hpp" #include "GTP-TEID.hpp"
#include "String2Value.hpp" #include "String2Value.hpp"
#include "TransportLayerAddress.hpp" #include "TransportLayerAddress.hpp"
...@@ -55,7 +55,10 @@ HandoverRequestAck::HandoverRequestAck() { ...@@ -55,7 +55,10 @@ HandoverRequestAck::HandoverRequestAck() {
HandoverRequestAck::~HandoverRequestAck() {} HandoverRequestAck::~HandoverRequestAck() {}
unsigned long HandoverRequestAck::getAmfUeNgapId() { unsigned long HandoverRequestAck::getAmfUeNgapId() {
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID(); return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
} }
void HandoverRequestAck::setMessageType() { void HandoverRequestAck::setMessageType() {
if (!handoverRequestAckPdu) if (!handoverRequestAckPdu)
...@@ -79,16 +82,21 @@ void HandoverRequestAck::setMessageType() { ...@@ -79,16 +82,21 @@ void HandoverRequestAck::setMessageType() {
handoverRequestAckIEs = &(handoverRequestAckPdu->choice.successfulOutcome handoverRequestAckIEs = &(handoverRequestAckPdu->choice.successfulOutcome
->value.choice.HandoverRequestAcknowledge); ->value.choice.HandoverRequestAcknowledge);
} else { } else {
cout << "[warning] This information doesn't refer to HandoverRequest " Logger::ngap().warn(
"Message!!!" "This information doesn't refer to HandoverRequest message");
<< endl;
} }
} }
uint32_t HandoverRequestAck::getRanUeNgapId() { uint32_t HandoverRequestAck::getRanUeNgapId() {
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId(); return ranUeNgapId->getRanUeNgapId();
else
return 0;
} }
OCTET_STRING_t HandoverRequestAck::getTargetToSource_TransparentContainer() { OCTET_STRING_t HandoverRequestAck::getTargetToSource_TransparentContainer() {
if (TargetToSource_TransparentContainer)
return *TargetToSource_TransparentContainer; return *TargetToSource_TransparentContainer;
return OCTET_STRING_t();
} }
bool HandoverRequestAck::getPDUSessionResourceAdmittedList( bool HandoverRequestAck::getPDUSessionResourceAdmittedList(
...@@ -114,6 +122,7 @@ bool HandoverRequestAck::getPDUSessionResourceAdmittedList( ...@@ -114,6 +122,7 @@ bool HandoverRequestAck::getPDUSessionResourceAdmittedList(
} }
bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ngap_msg_pdu) return false;
handoverRequestAckPdu = ngap_msg_pdu; handoverRequestAckPdu = ngap_msg_pdu;
if (handoverRequestAckPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) { if (handoverRequestAckPdu->present == Ngap_NGAP_PDU_PR_successfulOutcome) {
...@@ -127,11 +136,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -127,11 +136,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequestAckIEs = &handoverRequestAckPdu->choice.successfulOutcome handoverRequestAckIEs = &handoverRequestAckPdu->choice.successfulOutcome
->value.choice.HandoverRequestAcknowledge; ->value.choice.HandoverRequestAcknowledge;
} else { } else {
cout << "Check handoverRequestAck message error!!!" << endl; Logger::ngap().error("Check handoverRequestAck message error");
return false; return false;
} }
} else { } else {
cout << "handoverRequestAck MessageType error!!!" << endl; Logger::ngap().error("handoverRequestAck MessageType error");
return false; return false;
} }
for (int i = 0; i < handoverRequestAckIEs->protocolIEs.list.count; i++) { for (int i = 0; i < handoverRequestAckIEs->protocolIEs.list.count; i++) {
...@@ -145,11 +154,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -145,11 +154,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID( if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverRequestAckIEs->protocolIEs.list.array[i] handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) { ->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded NGAP AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -162,11 +171,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -162,11 +171,11 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID( if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverRequestAckIEs->protocolIEs.list.array[i] handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) { ->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded NGAP RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -180,13 +189,13 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -180,13 +189,13 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
->decodefromPDUSessionResourceAdmittedList( ->decodefromPDUSessionResourceAdmittedList(
&handoverRequestAckIEs->protocolIEs.list.array[i] &handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.PDUSessionResourceAdmittedList)) { ->value.choice.PDUSessionResourceAdmittedList)) {
cout << "decoded ngap PDUSessionResourceAdmittedList IE error" Logger::ngap().error(
<< endl; "Decoded NGAP PDUSessionResourceAdmittedList IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap PDUSessionResourceAdmittedList Type IE error" Logger::ngap().error(
<< endl; "Decoded NGAP PDUSessionResourceAdmittedList IE error");
return false; return false;
} }
} break; } break;
...@@ -201,13 +210,14 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -201,13 +210,14 @@ bool HandoverRequestAck::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequestAckIEs->protocolIEs.list.array[i] handoverRequestAckIEs->protocolIEs.list.array[i]
->value.choice.TargetToSource_TransparentContainer; ->value.choice.TargetToSource_TransparentContainer;
} else { } else {
cout << "decoded ngap TargetToSource_TransparentContainer IE error" Logger::ngap().error(
<< endl; "Decoded NGAP TargetToSource_TransparentContainer IE error");
return false; return false;
} }
} break; } break;
default: { default: {
cout << "decoded ngap message pdu error" << endl; Logger::ngap().error("Decoded NGAP Message PDU error");
return false; return false;
} }
} }
......
...@@ -65,7 +65,6 @@ class HandoverRequestAck { ...@@ -65,7 +65,6 @@ class HandoverRequestAck {
private: private:
Ngap_NGAP_PDU_t* handoverRequestAckPdu; Ngap_NGAP_PDU_t* handoverRequestAckPdu;
Ngap_HandoverRequestAcknowledge_t* handoverRequestAckIEs; Ngap_HandoverRequestAcknowledge_t* handoverRequestAckIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID* amfUeNgapId; AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId; RAN_UE_NGAP_ID* ranUeNgapId;
Ngap_HandoverType_t* handovertype; Ngap_HandoverType_t* handovertype;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#include "HandoverRequiredMsg.hpp" #include "HandoverRequiredMsg.hpp"
#include "logger.hpp"
extern "C" { extern "C" {
#include "Ngap_NGAP-PDU.h" #include "Ngap_NGAP-PDU.h"
#include "asn_codecs.h" #include "asn_codecs.h"
...@@ -52,31 +53,55 @@ HandoverRequiredMsg::HandoverRequiredMsg() { ...@@ -52,31 +53,55 @@ HandoverRequiredMsg::HandoverRequiredMsg() {
HandoverRequiredMsg::~HandoverRequiredMsg() {} HandoverRequiredMsg::~HandoverRequiredMsg() {}
unsigned long HandoverRequiredMsg::getAmfUeNgapId() { unsigned long HandoverRequiredMsg::getAmfUeNgapId() {
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID(); return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
} }
uint32_t HandoverRequiredMsg::getRanUeNgapId() { uint32_t HandoverRequiredMsg::getRanUeNgapId() {
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId(); return ranUeNgapId->getRanUeNgapId();
else
return 0;
} }
Ngap_HandoverType_t HandoverRequiredMsg::getHandoverType() { Ngap_HandoverType_t HandoverRequiredMsg::getHandoverType() {
if (handovertype)
return *handovertype; return *handovertype;
else
return Ngap_HandoverType_t();
} }
Ngap_Cause_PR HandoverRequiredMsg::getChoiceOfCause() { Ngap_Cause_PR HandoverRequiredMsg::getChoiceOfCause() {
if (cause)
return cause->getChoiceOfCause(); return cause->getChoiceOfCause();
else
return Ngap_Cause_PR();
} }
long HandoverRequiredMsg::getCauseValue() { long HandoverRequiredMsg::getCauseValue() {
if (cause)
return cause->getValue(); return cause->getValue();
else
return 0;
} }
void HandoverRequiredMsg::getGlobalRanNodeId(GlobalgNBId*& ptr) { void HandoverRequiredMsg::getGlobalRanNodeId(GlobalgNBId*& ptr) {
if (ptr)
ptr->decodefromGlobalgNBId( ptr->decodefromGlobalgNBId(
targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID); targetid->choice.targetRANNodeID->globalRANNodeID.choice.globalGNB_ID);
} }
void HandoverRequiredMsg::getTAI(TAI*& ptr) { void HandoverRequiredMsg::getTAI(TAI*& ptr) {
ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI)); if (ptr) ptr->decodefromTAI(&(targetid->choice.targetRANNodeID->selectedTAI));
} }
OCTET_STRING_t HandoverRequiredMsg::getSourceToTarget_TransparentContainer() { OCTET_STRING_t HandoverRequiredMsg::getSourceToTarget_TransparentContainer() {
if (SourceToTarget_TransparentContainer)
return *SourceToTarget_TransparentContainer; return *SourceToTarget_TransparentContainer;
else
return OCTET_STRING_t();
} }
bool HandoverRequiredMsg::getPDUSessionResourceList( bool HandoverRequiredMsg::getPDUSessionResourceList(
...@@ -103,7 +128,10 @@ bool HandoverRequiredMsg::getPDUSessionResourceList( ...@@ -103,7 +128,10 @@ bool HandoverRequiredMsg::getPDUSessionResourceList(
} }
long HandoverRequiredMsg::getDirectForwardingPathAvailability() { long HandoverRequiredMsg::getDirectForwardingPathAvailability() {
if (directforwardingPathAvailability)
return *directforwardingPathAvailability; return *directforwardingPathAvailability;
else
return 0;
} }
bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
...@@ -120,11 +148,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -120,11 +148,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequiredIEs = &handoverRequiredPdu->choice.initiatingMessage handoverRequiredIEs = &handoverRequiredPdu->choice.initiatingMessage
->value.choice.HandoverRequired; ->value.choice.HandoverRequired;
} else { } else {
cout << "Check HandoverRequired message error!!!" << endl; Logger::ngap().error("Check HandoverRequired message error!");
return false; return false;
} }
} else { } else {
cout << "HandoverRequired MessageType error!!!" << endl; Logger::ngap().error("HandoverRequired MessageType error!");
return false; return false;
} }
for (int i = 0; i < handoverRequiredIEs->protocolIEs.list.count; i++) { for (int i = 0; i < handoverRequiredIEs->protocolIEs.list.count; i++) {
...@@ -138,11 +166,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -138,11 +166,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID( if (!amfUeNgapId->decodefromAMF_UE_NGAP_ID(
handoverRequiredIEs->protocolIEs.list.array[i] handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.AMF_UE_NGAP_ID)) { ->value.choice.AMF_UE_NGAP_ID)) {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap AMF_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap AMF_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -155,11 +183,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -155,11 +183,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID( if (!ranUeNgapId->decodefromRAN_UE_NGAP_ID(
handoverRequiredIEs->protocolIEs.list.array[i] handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.RAN_UE_NGAP_ID)) { ->value.choice.RAN_UE_NGAP_ID)) {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap RAN_UE_NGAP_ID IE error" << endl; Logger::ngap().error("Decoded ngap RAN_UE_NGAP_ID IE error");
return false; return false;
} }
} break; } break;
...@@ -172,7 +200,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -172,7 +200,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*handovertype = handoverRequiredIEs->protocolIEs.list.array[i] *handovertype = handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.HandoverType; ->value.choice.HandoverType;
} else { } else {
cout << "decoded ngap Handover Type IE error" << endl; Logger::ngap().error("Decoded ngap Handover Type error");
return false; return false;
} }
} break; } break;
...@@ -185,11 +213,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -185,11 +213,11 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!cause->decodefromCause( if (!cause->decodefromCause(
&handoverRequiredIEs->protocolIEs.list.array[i] &handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.Cause)) { ->value.choice.Cause)) {
cout << "decoded ngap Cause IE error" << endl; Logger::ngap().error("Decoded ngap Cause IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap Cause IE error" << endl; Logger::ngap().error("Decoded ngap Cause IE error");
return false; return false;
} }
} break; } break;
...@@ -202,7 +230,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -202,7 +230,7 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
*targetid = handoverRequiredIEs->protocolIEs.list.array[i] *targetid = handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.TargetID; ->value.choice.TargetID;
} else { } else {
cout << "decoded ngap TargetID IE error" << endl; Logger::ngap().error("Decoded ngap TargetID IE error");
return false; return false;
} }
} break; } break;
...@@ -217,8 +245,8 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -217,8 +245,8 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequiredIEs->protocolIEs.list.array[i] handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.DirectForwardingPathAvailability; ->value.choice.DirectForwardingPathAvailability;
} else { } else {
cout << "decoded ngap DirectForwardingPathAvailability IE error" Logger::ngap().error(
<< endl; "Decoded ngap DirectForwardingPathAvailability IE error");
return false; return false;
} }
} break; } break;
...@@ -231,12 +259,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -231,12 +259,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
if (!PDUSessionResourceList->decodefromPDUSessionResourceListHORqd( if (!PDUSessionResourceList->decodefromPDUSessionResourceListHORqd(
&handoverRequiredIEs->protocolIEs.list.array[i] &handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.PDUSessionResourceListHORqd)) { ->value.choice.PDUSessionResourceListHORqd)) {
cout << "decoded ngap PDUSessionResourceSetupListCxtRes IE error" Logger::ngap().error(
<< endl; "Decoded ngap PDUSessionResourceSetupListCxtRes IE error");
return false; return false;
} }
} else { } else {
cout << "decoded ngap PDUSessionResourceListHORqd IE error" << endl; Logger::ngap().error(
"Decoded ngap PDUSessionResourceSetupListCxtRes IE error");
return false; return false;
} }
} break; } break;
...@@ -251,13 +280,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) { ...@@ -251,13 +280,13 @@ bool HandoverRequiredMsg::decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
handoverRequiredIEs->protocolIEs.list.array[i] handoverRequiredIEs->protocolIEs.list.array[i]
->value.choice.SourceToTarget_TransparentContainer; ->value.choice.SourceToTarget_TransparentContainer;
} else { } else {
cout << "decoded ngap SourceToTarget_TransparentContainer IE error" Logger::ngap().error(
<< endl; "Decoded ngap SourceToTarget_TransparentContainer IE error");
return false; return false;
} }
} break; } break;
default: { default: {
cout << "decoded ngap message pdu error" << endl; Logger::ngap().error("Decoded ngap message PDU error");
return false; return false;
} }
} }
...@@ -270,7 +299,8 @@ int HandoverRequiredMsg::encode2buffer(uint8_t* buf, int buf_size) { ...@@ -270,7 +299,8 @@ int HandoverRequiredMsg::encode2buffer(uint8_t* buf, int buf_size) {
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequiredPdu); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, handoverRequiredPdu);
asn_enc_rval_t er = aper_encode_to_buffer( asn_enc_rval_t er = aper_encode_to_buffer(
&asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequiredPdu, buf, buf_size); &asn_DEF_Ngap_NGAP_PDU, NULL, handoverRequiredPdu, buf, buf_size);
cout << "er.encoded(" << er.encoded << ")" << endl; // cout << "er.encoded(" << er.encoded << ")" << endl;
Logger::ngap().error("er.encoded( %d )", er.encoded);
return er.encoded; return er.encoded;
} }
......
...@@ -48,9 +48,8 @@ class HandoverRequiredMsg { ...@@ -48,9 +48,8 @@ class HandoverRequiredMsg {
int encode2buffer(uint8_t* buf, int buf_size); int encode2buffer(uint8_t* buf, int buf_size);
bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu); bool decodefrompdu(Ngap_NGAP_PDU_t* ngap_msg_pdu);
unsigned long getAmfUeNgapId(); // return -1;(不存在) unsigned long getAmfUeNgapId();
uint32_t getRanUeNgapId(); // return -1;(不存在) uint32_t getRanUeNgapId();
Ngap_HandoverType_t getHandoverType(); Ngap_HandoverType_t getHandoverType();
Ngap_Cause_PR getChoiceOfCause(); Ngap_Cause_PR getChoiceOfCause();
long getCauseValue(); long getCauseValue();
...@@ -63,7 +62,6 @@ class HandoverRequiredMsg { ...@@ -63,7 +62,6 @@ class HandoverRequiredMsg {
private: private:
Ngap_NGAP_PDU_t* handoverRequiredPdu; Ngap_NGAP_PDU_t* handoverRequiredPdu;
Ngap_HandoverRequired_t* handoverRequiredIEs; Ngap_HandoverRequired_t* handoverRequiredIEs;
/***************** for decoding ****************/
AMF_UE_NGAP_ID* amfUeNgapId; AMF_UE_NGAP_ID* amfUeNgapId;
RAN_UE_NGAP_ID* ranUeNgapId; RAN_UE_NGAP_ID* ranUeNgapId;
Ngap_HandoverType_t* handovertype; Ngap_HandoverType_t* handovertype;
......
...@@ -32,27 +32,38 @@ ...@@ -32,27 +32,38 @@
using namespace std; using namespace std;
namespace ngap { namespace ngap {
UplinkRANStatusTransfer::UplinkRANStatusTransfer() { UplinkRANStatusTransfer::UplinkRANStatusTransfer() {
amfUeNgapId = NULL; amfUeNgapId = nullptr;
ranUeNgapId = NULL; ranUeNgapId = nullptr;
ranStatusTransfer_TransparentContainer = NULL; ranStatusTransfer_TransparentContainer = nullptr;
UplinkRANStatusTransferPDU = nullptr; UplinkRANStatusTransferPDU = nullptr;
UplinkRANStatusTransferIEs = nullptr; UplinkRANStatusTransferIEs = nullptr;
} }
UplinkRANStatusTransfer::~UplinkRANStatusTransfer() {} UplinkRANStatusTransfer::~UplinkRANStatusTransfer() {}
unsigned long UplinkRANStatusTransfer::getAmfUeNgapId() { unsigned long UplinkRANStatusTransfer::getAmfUeNgapId() {
if (amfUeNgapId)
return amfUeNgapId->getAMF_UE_NGAP_ID(); return amfUeNgapId->getAMF_UE_NGAP_ID();
else
return 0;
} }
uint32_t UplinkRANStatusTransfer::getRanUeNgapId() { uint32_t UplinkRANStatusTransfer::getRanUeNgapId() {
if (ranUeNgapId)
return ranUeNgapId->getRanUeNgapId(); return ranUeNgapId->getRanUeNgapId();
else
return 0;
} }
void UplinkRANStatusTransfer::getRANStatusTransfer_TransparentContainer( void UplinkRANStatusTransfer::getRANStatusTransfer_TransparentContainer(
RANStatusTransferTransparentContainer*& RANStatusTransferTransparentContainer*&
ranstatustransfer_transparentcontainer) { ranstatustransfer_transparentcontainer) {
ranstatustransfer_transparentcontainer = ranstatustransfer_transparentcontainer =
ranStatusTransfer_TransparentContainer; ranStatusTransfer_TransparentContainer;
} }
bool UplinkRANStatusTransfer::defromPDU(Ngap_NGAP_PDU_t* ngap_msg_pdu) { bool UplinkRANStatusTransfer::defromPDU(Ngap_NGAP_PDU_t* ngap_msg_pdu) {
UplinkRANStatusTransferPDU = ngap_msg_pdu; UplinkRANStatusTransferPDU = ngap_msg_pdu;
if (UplinkRANStatusTransferPDU->present == if (UplinkRANStatusTransferPDU->present ==
......
...@@ -52,7 +52,6 @@ using namespace amf_application; ...@@ -52,7 +52,6 @@ using namespace amf_application;
extern itti_mw* itti_inst; extern itti_mw* itti_inst;
extern amf_n1* amf_n1_inst; extern amf_n1* amf_n1_inst;
extern amf_n11* amf_n11_inst;
extern amf_app* amf_app_inst; extern amf_app* amf_app_inst;
typedef int (*ngap_message_decoded_callback)( typedef int (*ngap_message_decoded_callback)(
...@@ -158,7 +157,7 @@ int ngap_amf_handle_initial_context_setup_response( ...@@ -158,7 +157,7 @@ int ngap_amf_handle_initial_context_setup_response(
} }
std::vector<PDUSessionResourceSetupResponseItem_t> list; std::vector<PDUSessionResourceSetupResponseItem_t> list;
if (!initCtxResp->getPduSessionResourceSetupResponseList(list)) { if (!initCtxResp->getPduSessionResourceSetupResponseList(list)) {
Logger::ngap().error( Logger::ngap().debug(
"Decode PduSessionResourceSetupResponseList IE error or this IE is not " "Decode PduSessionResourceSetupResponseList IE error or this IE is not "
"available"); "available");
return 0; return 0;
...@@ -543,7 +542,7 @@ int downlink_ue_associated_nappa_transport( ...@@ -543,7 +542,7 @@ int downlink_ue_associated_nappa_transport(
int handover_cancel( int handover_cancel(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug("Sending itti handover cancel to TASK_AMF_N2"); Logger::ngap().debug("Sending ITTI Handover Cancel to TASK_AMF_N2");
return 0; return 0;
} }
...@@ -551,18 +550,18 @@ int handover_cancel( ...@@ -551,18 +550,18 @@ int handover_cancel(
int handover_preparation( int handover_preparation(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug("Sending itti handover preparation to TASK_AMF_N2"); Logger::ngap().debug("Sending ITTI Handover Preparation to TASK_AMF_N2");
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
HandoverRequiredMsg* handoverrequired = new HandoverRequiredMsg(); HandoverRequiredMsg* handover_required = new HandoverRequiredMsg();
if (!handoverrequired->decodefrompdu(message_p)) { if (!handover_required->decodefrompdu(message_p)) {
Logger::ngap().error("decoding HandoverRequired message error"); Logger::ngap().error("Decoding HandoverRequired message error");
return -1; return -1;
} }
itti_handover_required* itti_handover_requ = itti_handover_required* itti_handover_requ =
new itti_handover_required(TASK_NGAP, TASK_AMF_N2); new itti_handover_required(TASK_NGAP, TASK_AMF_N2);
itti_handover_requ->assoc_id = assoc_id; itti_handover_requ->assoc_id = assoc_id;
itti_handover_requ->stream = stream; itti_handover_requ->stream = stream;
itti_handover_requ->handvoerRequ = handoverrequired; itti_handover_requ->handoverReq = handover_required;
std::shared_ptr<itti_handover_required> i = std::shared_ptr<itti_handover_required> i =
std::shared_ptr<itti_handover_required>(itti_handover_requ); std::shared_ptr<itti_handover_required>(itti_handover_requ);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
...@@ -578,11 +577,11 @@ int handover_preparation( ...@@ -578,11 +577,11 @@ int handover_preparation(
int handover_notification( int handover_notification(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug("Sending itti handover Notification to TASK_AMF_N2"); Logger::ngap().debug("Sending ITTI Handover Notification to TASK_AMF_N2");
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
HandoverNotifyMsg* handoverNotify = new HandoverNotifyMsg(); HandoverNotifyMsg* handoverNotify = new HandoverNotifyMsg();
if (!handoverNotify->decodefrompdu(message_p)) { if (!handoverNotify->decodefrompdu(message_p)) {
Logger::ngap().error("decoding handoverNotify message error"); Logger::ngap().error("Decoding HandoverNotify message error");
return -1; return -1;
} }
itti_handover_notify* itti_handover_NOTIFY = itti_handover_notify* itti_handover_NOTIFY =
...@@ -606,12 +605,11 @@ int handover_resource_allocation( ...@@ -606,12 +605,11 @@ int handover_resource_allocation(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug( Logger::ngap().debug(
"Sending itti handover resource allocation to TASK_AMF_N2"); "Sending ITTI Handover Resource Allocation to TASK_AMF_N2");
/*receive handover request acknowedge*/
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
HandoverRequestAck* handoverRequestAck = new HandoverRequestAck(); HandoverRequestAck* handoverRequestAck = new HandoverRequestAck();
if (!handoverRequestAck->decodefrompdu(message_p)) { if (!handoverRequestAck->decodefrompdu(message_p)) {
Logger::ngap().error("decoding handoverRequestAck message error"); Logger::ngap().error("Decoding Handover Request Acknowledge message error");
return -1; return -1;
} }
itti_handover_request_Ack* itti_handover_requ_Ack = itti_handover_request_Ack* itti_handover_requ_Ack =
...@@ -873,22 +871,22 @@ int uplink_ran_status_transfer( ...@@ -873,22 +871,22 @@ int uplink_ran_status_transfer(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug( Logger::ngap().debug(
"Sending itti uplink ran status transfer to TASK_AMF_N2"); "Sending ITTI Uplink RAN Status Transfer to TASK_AMF_N2");
/*receive uplinkranstatustransfer*/
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
UplinkRANStatusTransfer* Uplinkranstatustransfer = UplinkRANStatusTransfer* Uplinkranstatustransfer =
new UplinkRANStatusTransfer(); new UplinkRANStatusTransfer();
if (!Uplinkranstatustransfer->defromPDU(message_p)) { if (!Uplinkranstatustransfer->defromPDU(message_p)) {
Logger::ngap().error("Decoding Uplinkranstatustransfer message error"); Logger::ngap().error("Decoding Uplink RAN Status Transfer message error");
return -1; return -1;
} }
itti_uplinkranstatsutransfer* itti_uplinkran_sta_tran = itti_uplink_ran_status_transfer* itti_uplinkran_sta_tran =
new itti_uplinkranstatsutransfer(TASK_NGAP, TASK_AMF_N2); new itti_uplink_ran_status_transfer(TASK_NGAP, TASK_AMF_N2);
itti_uplinkran_sta_tran->assoc_id = assoc_id; itti_uplinkran_sta_tran->assoc_id = assoc_id;
itti_uplinkran_sta_tran->stream = stream; itti_uplinkran_sta_tran->stream = stream;
itti_uplinkran_sta_tran->uplinkrantransfer = Uplinkranstatustransfer; itti_uplinkran_sta_tran->uplinkrantransfer = Uplinkranstatustransfer;
std::shared_ptr<itti_uplinkranstatsutransfer> i = std::shared_ptr<itti_uplink_ran_status_transfer> i =
std::shared_ptr<itti_uplinkranstatsutransfer>(itti_uplinkran_sta_tran); std::shared_ptr<itti_uplink_ran_status_transfer>(itti_uplinkran_sta_tran);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::ngap().error( Logger::ngap().error(
...@@ -960,8 +958,7 @@ ngap_message_decoded_callback messages_callback[][3] = { ...@@ -960,8 +958,7 @@ ngap_message_decoded_callback messages_callback[][3] = {
{overload_stop, overload_stop, overload_stop}, /*OverloadStop*/ {overload_stop, overload_stop, overload_stop}, /*OverloadStop*/
{paging, paging, paging}, /*Paging*/ {paging, paging, paging}, /*Paging*/
{ngap_amf_handle_path_switch_request, ngap_amf_handle_path_switch_request, {ngap_amf_handle_path_switch_request, ngap_amf_handle_path_switch_request,
ngap_amf_handle_path_switch_request}, //{ngap_amf_handle_path_switch_request,0,0}, ngap_amf_handle_path_switch_request}, /*PathSwitchRequest*/
///*PathSwitchRequest*
{pdu_session_resource_modify, pdu_session_resource_modify, {pdu_session_resource_modify, pdu_session_resource_modify,
pdu_session_resource_modify}, /*PDUSessionResourceModify*/ pdu_session_resource_modify}, /*PDUSessionResourceModify*/
{pdu_session_resource_modify_indication, {pdu_session_resource_modify_indication,
......
...@@ -354,4 +354,4 @@ IF(STATIC_LINKING) ...@@ -354,4 +354,4 @@ IF(STATIC_LINKING)
ENDIF(STATIC_LINKING) ENDIF(STATIC_LINKING)
target_link_libraries(amf ${ASAN} target_link_libraries(amf ${ASAN}
-Wl,--start-group 3GPP_COMMON_TYPES AMF CONTEXTS AMF_SCTP AMF_SECU_5GAKA AMF_SECU_NAS AMF_UTILS AMF_SBI_CLIENT AMF_SBI_SERVER config++ sctp pthread ${NETTLE_LIBRARIES} ${MySQL_LIBRARY} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} boost_system ssl crypt cpprest gmp pistache curl) -Wl,--start-group 3GPP_COMMON_TYPES AMF CONTEXTS AMF_SCTP AMF_SECU_5GAKA AMF_SECU_NAS AMF_UTILS AMF_SBI_CLIENT AMF_SBI_SERVER config++ sctp pthread ${NETTLE_LIBRARIES} ${MySQL_LIBRARY} ${CRYPTO_LIBRARIES} ${OPENSSL_LIBRARIES} boost_system boost_thread boost_chrono ssl crypt cpprest gmp pistache curl)
...@@ -22,7 +22,6 @@ using namespace amf_application; ...@@ -22,7 +22,6 @@ using namespace amf_application;
extern void msg_str_2_msg_hex(std::string msg, bstring& b); extern void msg_str_2_msg_hex(std::string msg, bstring& b);
extern void convert_string_2_hex(std::string& input, std::string& output); extern void convert_string_2_hex(std::string& input, std::string& output);
extern itti_mw* itti_inst; extern itti_mw* itti_inst;
extern amf_n11* amf_n11_inst;
extern amf_app* amf_app_inst; extern amf_app* amf_app_inst;
extern void print_buffer( extern void print_buffer(
const std::string app, const std::string commit, uint8_t* buf, int len); const std::string app, const std::string commit, uint8_t* buf, int len);
......
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