Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-AMF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-AMF
Commits
af0865a5
Commit
af0865a5
authored
Jun 28, 2021
by
liuyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decouple pdu_session_context without test
parent
ffa3bb5b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
2072 additions
and
168 deletions
+2072
-168
.vscode/settings.json
.vscode/settings.json
+61
-1
src/amf-app/amf_app.cpp
src/amf-app/amf_app.cpp
+199
-1
src/amf-app/amf_app.hpp
src/amf-app/amf_app.hpp
+10
-2
src/amf-app/amf_n1.cpp
src/amf-app/amf_n1.cpp
+281
-64
src/amf-app/amf_n11.cpp
src/amf-app/amf_n11.cpp
+148
-19
src/amf-app/amf_n2.cpp
src/amf-app/amf_n2.cpp
+36
-7
src/amf-app/amf_profile.cpp
src/amf-app/amf_profile.cpp
+540
-0
src/amf-app/amf_profile.hpp
src/amf-app/amf_profile.hpp
+586
-0
src/contexts/pdu_session_context.cpp
src/contexts/pdu_session_context.cpp
+11
-0
src/contexts/pdu_session_context.hpp
src/contexts/pdu_session_context.hpp
+4
-2
src/ngap/ngap_app/ngap_message_callback.hpp
src/ngap/ngap_app/ngap_message_callback.hpp
+36
-8
src/sbi/amf_server/impl/N1N2MessageCollectionDocumentApiImpl.cpp
.../amf_server/impl/N1N2MessageCollectionDocumentApiImpl.cpp
+44
-8
src/sbi/amf_server/impl/TestSignallingApiImpl.cpp
src/sbi/amf_server/impl/TestSignallingApiImpl.cpp
+116
-56
No files found.
.vscode/settings.json
View file @
af0865a5
...
...
@@ -8,6 +8,66 @@
"istream"
:
"cpp"
,
"functional"
:
"cpp"
,
"tuple"
:
"cpp"
,
"utility"
:
"cpp"
"utility"
:
"cpp"
,
"cctype"
:
"cpp"
,
"clocale"
:
"cpp"
,
"cmath"
:
"cpp"
,
"csignal"
:
"cpp"
,
"cstdarg"
:
"cpp"
,
"cstddef"
:
"cpp"
,
"cstdio"
:
"cpp"
,
"cstdlib"
:
"cpp"
,
"cstring"
:
"cpp"
,
"ctime"
:
"cpp"
,
"cwchar"
:
"cpp"
,
"cwctype"
:
"cpp"
,
"atomic"
:
"cpp"
,
"strstream"
:
"cpp"
,
"bitset"
:
"cpp"
,
"chrono"
:
"cpp"
,
"codecvt"
:
"cpp"
,
"complex"
:
"cpp"
,
"condition_variable"
:
"cpp"
,
"cstdint"
:
"cpp"
,
"deque"
:
"cpp"
,
"forward_list"
:
"cpp"
,
"list"
:
"cpp"
,
"unordered_map"
:
"cpp"
,
"unordered_set"
:
"cpp"
,
"vector"
:
"cpp"
,
"exception"
:
"cpp"
,
"algorithm"
:
"cpp"
,
"iterator"
:
"cpp"
,
"map"
:
"cpp"
,
"memory_resource"
:
"cpp"
,
"numeric"
:
"cpp"
,
"optional"
:
"cpp"
,
"random"
:
"cpp"
,
"ratio"
:
"cpp"
,
"regex"
:
"cpp"
,
"set"
:
"cpp"
,
"string"
:
"cpp"
,
"string_view"
:
"cpp"
,
"system_error"
:
"cpp"
,
"type_traits"
:
"cpp"
,
"fstream"
:
"cpp"
,
"initializer_list"
:
"cpp"
,
"iomanip"
:
"cpp"
,
"iosfwd"
:
"cpp"
,
"iostream"
:
"cpp"
,
"limits"
:
"cpp"
,
"mutex"
:
"cpp"
,
"new"
:
"cpp"
,
"ostream"
:
"cpp"
,
"shared_mutex"
:
"cpp"
,
"sstream"
:
"cpp"
,
"stdexcept"
:
"cpp"
,
"streambuf"
:
"cpp"
,
"thread"
:
"cpp"
,
"cfenv"
:
"cpp"
,
"cinttypes"
:
"cpp"
,
"typeindex"
:
"cpp"
,
"typeinfo"
:
"cpp"
,
"valarray"
:
"cpp"
}
}
\ No newline at end of file
src/amf-app/amf_app.cpp
View file @
af0865a5
...
...
@@ -27,7 +27,8 @@
*/
#include "amf_app.hpp"
#include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <cstdlib>
#include <iostream>
#include <stdexcept>
...
...
@@ -45,6 +46,7 @@
using
namespace
ngap
;
using
namespace
nas
;
//using namespace amf ;
using
namespace
amf_application
;
using
namespace
config
;
...
...
@@ -437,3 +439,199 @@ bool amf_app::generate_5g_guti(
golbal_tmsi
++
;
return
true
;
}
// void amf_app::generate_amf_profile() {
// // TODO: remove hardcoded values
// // generate UUID
// generate_uuid();
// nf_instance_profile.set_nf_instance_id(amf_instance_id);
// nf_instance_profile.set_nf_instance_name("OAI-AMF");
// nf_instance_profile.set_nf_type("SMF");
// nf_instance_profile.set_nf_status("REGISTERED");
// nf_instance_profile.set_nf_heartBeat_timer(50);
// nf_instance_profile.set_nf_priority(1);
// nf_instance_profile.set_nf_capacity(100);
// nf_instance_profile.add_nf_ipv4_addresses(amf_cfg.n11.addr4);
// // // NF services
// // nf_service_t nf_service = {};
// // nf_service.service_instance_id = "nsmf-pdusession";
// // nf_service.service_name = "nsmf-pdusession";
// // nf_service_version_t version = {};
// // version.api_version_in_uri = "v1";
// // version.api_full_version = "1.0.0"; // TODO: to be updated
// // nf_service.versions.push_back(version);
// // nf_service.scheme = "http";
// // nf_service.nf_service_status = "REGISTERED";
// // // IP Endpoint
// // ip_endpoint_t endpoint = {};
// // std::vector<struct in_addr> addrs;
// // nf_instance_profile.get_nf_ipv4_addresses(addrs);
// // endpoint.ipv4_address = addrs[0]; // TODO: use first IP ADDR for now
// // endpoint.transport = "TCP";
// // endpoint.port = smf_cfg.sbi.port;
// // nf_service.ip_endpoints.push_back(endpoint);
// // nf_instance_profile.add_nf_service(nf_service);
// // // TODO: custom info
// // int i = 0;
// // for (auto sms : smf_cfg.session_management_subscription) {
// // if (i < smf_cfg.num_session_management_subscription)
// // i++;
// // else
// // break;
// // // SNSSAIS
// // snssai_t snssai = {};
// // snssai.sD = sms.single_nssai.sD;
// // snssai.sST = sms.single_nssai.sST;
// // // Verify if this SNSSAI exist
// // std::vector<snssai_t> ss = {};
// // nf_instance_profile.get_nf_snssais(ss);
// // bool found = false;
// // for (auto it : ss) {
// // if ((it.sD == snssai.sD) and (it.sST == snssai.sST)) {
// // found = true;
// // break;
// // }
// // }
// // if (!found) nf_instance_profile.add_snssai(snssai);
// // // SMF info
// // dnn_smf_info_item_t dnn_item = {.dnn = sms.dnn};
// // snssai_smf_info_item_t smf_info_item = {};
// // smf_info_item.dnn_smf_info_list.push_back(dnn_item);
// // smf_info_item.snssai.sD = sms.single_nssai.sD;
// // smf_info_item.snssai.sST = sms.single_nssai.sST;
// // nf_instance_profile.add_smf_info_item(smf_info_item);
// // }
// // // Display the profile
// // nf_instance_profile.display();
// }
// //---------------------------------------------------------------------------------------------
// void amf_app::register_to_nrf() {
// // Create a NF profile to this instance
// generate_amf_profile();
// // Send request to N11 to send NF registration to NRF
// //trigger_nf_registration_request();
// }
// //------------------------------------------------------------------------------
// void amf_app::generate_uuid() {
// amf_instance_id = to_string(boost::uuids::random_generator()());
// }
// //------------------------------------------------------------------------------
// // void smf_app::trigger_nf_registration_request() {
// // Logger::smf_app().debug(
// // "Send ITTI msg to N11 task to trigger the registration request to NRF");
// // std::shared_ptr<itti_n11_register_nf_instance_request> itti_msg =
// // std::make_shared<itti_n11_register_nf_instance_request>(
// // TASK_SMF_APP, TASK_SMF_SBI);
// // itti_msg->profile = nf_instance_profile;
// // int ret = itti_inst->send_msg(itti_msg);
// // if (RETURNok != ret) {
// // Logger::smf_app().error(
// // "Could not send ITTI message %s to task TASK_SMF_SBI",
// // itti_msg->get_msg_name());
// // }
// // }
// void amf_app::register_nf_instance() {
// Logger::amf_app().debug(
// "Send NF Instance Registration to NRF ");
// nlohmann::json json_data = {};
// msg->profile.to_json(json_data);
// std::string url =
// std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.nrf_addr.ipv4_addr))) +
// ":" + std::to_string(smf_cfg.nrf_addr.port) + NNRF_NFM_BASE +
// smf_cfg.nrf_addr.api_version + NNRF_NF_REGISTER_URL +
// msg->profile.get_nf_instance_id();
// Logger::smf_sbi().debug(
// "Send NF Instance Registration to NRF, NRF URL %s", url.c_str());
// std::string body = json_data.dump();
// Logger::smf_sbi().debug(
// "Send NF Instance Registration to NRF, msg body: \n %s", body.c_str());
// curl_global_init(CURL_GLOBAL_ALL);
// CURL* curl = curl = curl_easy_init();
// if (curl) {
// CURLcode res = {};
// struct curl_slist* headers = nullptr;
// // headers = curl_slist_append(headers, "charsets: utf-8");
// headers = curl_slist_append(headers, "content-type: application/json");
// curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
// curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
// curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
// curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
// curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, NRF_CURL_TIMEOUT_MS);
// if (msg->http_version == 2) {
// curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// // we use a self-signed test server, skip verification during debugging
// curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
// curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
// curl_easy_setopt(
// curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
// }
// // Response information.
// long httpCode = {0};
// std::unique_ptr<std::string> httpData(new std::string());
// curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
// curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
// curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, body.length());
// curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
// res = curl_easy_perform(curl);
// curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
// Logger::smf_sbi().debug(
// "NF Instance Registration, response from NRF, HTTP Code: %d", httpCode);
// if (static_cast<http_response_codes_e>(httpCode) ==
// http_response_codes_e::HTTP_RESPONSE_CODE_CREATED) {
// json response_data = {};
// try {
// response_data = json::parse(*httpData.get());
// } catch (json::exception& e) {
// Logger::smf_sbi().warn(
// "NF Instance Registration, could not parse json from the NRF "
// "response");
// }
// Logger::smf_sbi().debug(
// "NF Instance Registration, response from NRF, json data: \n %s",
// response_data.dump().c_str());
// // send response to APP to process
// std::shared_ptr<itti_n11_register_nf_instance_response> itti_msg =
// std::make_shared<itti_n11_register_nf_instance_response>(
// TASK_SMF_SBI, TASK_SMF_APP);
// itti_msg->http_response_code = httpCode;
// itti_msg->http_version = msg->http_version;
// Logger::smf_app().debug("Registered SMF profile (from NRF)");
// itti_msg->profile.from_json(response_data);
// int ret = itti_inst->send_msg(itti_msg);
// if (RETURNok != ret) {
// Logger::smf_sbi().error(
// "Could not send ITTI message %s to task TASK_SMF_APP",
// itti_msg->get_msg_name());
// }
// } else {
// Logger::smf_sbi().warn(
// "NF Instance Registration, could not get response from NRF");
// }
// curl_slist_free_all(headers);
// curl_easy_cleanup(curl);
// }
// curl_global_cleanup();
// }
\ No newline at end of file
src/amf-app/amf_app.hpp
View file @
af0865a5
...
...
@@ -36,9 +36,9 @@
#include "amf_module_from_config.hpp"
#include "itti_msg_amf_app.hpp"
#include "ue_context.hpp"
//#include "amf_profile.hpp"
using
namespace
config
;
//using namespace amf ;
static
uint32_t
amf_app_ue_ngap_id_generator
=
1
;
namespace
amf_application
{
...
...
@@ -80,6 +80,14 @@ class amf_app {
bool
generate_5g_guti
(
uint32_t
ranid
,
long
amfid
,
std
::
string
&
mcc
,
std
::
string
&
mnc
,
uint32_t
&
tmsi
);
// void register_to_nrf();
// void generate_uuid();
// void generate_amf_profile();
// void register_nf_instance();
// amf_profile nf_instance_profile; // SMF profile
// std::string amf_instance_id; // SMF instance id
};
}
// namespace amf_application
...
...
src/amf-app/amf_n1.cpp
View file @
af0865a5
...
...
@@ -442,7 +442,7 @@ void amf_n1::nas_signalling_establishment_request_handle(
udsf_nas_context
[
"blocks"
].
push_back
(
requestedNssai
);
//auc_vector_t _vector[MAX_5GS_AUTH_VECTORS]
//_5g_he_av、_5g_av和kamf未整理
nlohmann
::
json
_vector
=
{};
nlohmann
::
json
_vector_m
=
{};
_vector
[
"Content-ID"
]
=
"_vector"
;
...
...
@@ -457,7 +457,56 @@ void amf_n1::nas_signalling_establishment_request_handle(
_vector
[
"content"
].
push_back
(
_vector_m
);
}
udsf_nas_context
[
"blocks"
].
push_back
(
_vector
);
udsf_nas_context
[
"blocks"
].
push_back
(
_vector
);
//_5g_he_av
nlohmann
::
json
_5g_he_av
=
{};
nlohmann
::
json
_5g_he_av_m
=
{};
_5g_he_av
[
"Content-ID"
]
=
"_5g_he_av"
;
_5g_he_av
[
"Content-Type"
]
=
"JSON"
;
for
(
int
i
=
0
;
i
<
MAX_5GS_AUTH_VECTORS
;
i
++
)
{
_5g_he_av_m
[
"avType"
]
=
to_string
(
nc
->
_5g_he_av
[
i
].
avType
);
_5g_he_av_m
[
"rand"
]
=
to_string
(
*
(
nc
->
_5g_he_av
[
i
].
rand
));
_5g_he_av_m
[
"xres"
]
=
to_string
(
*
nc
->
_5g_he_av
[
i
].
xres
);
_5g_he_av_m
[
"autn"
]
=
to_string
(
*
nc
->
_5g_he_av
[
i
].
autn
);
_5g_he_av_m
[
"xresStar"
]
=
to_string
(
*
nc
->
_5g_he_av
[
i
].
xresStar
);
_5g_he_av_m
[
"kausf"
]
=
to_string
(
*
nc
->
_5g_he_av
[
i
].
kausf
);
_5g_he_av
[
"content"
].
push_back
(
_5g_he_av_m
);
}
udsf_nas_context
[
"blocks"
].
push_back
(
_5g_he_av
);
//_5g_av
nlohmann
::
json
_5g_av
=
{};
nlohmann
::
json
_5g_av_m
=
{};
_5g_av
[
"Content-ID"
]
=
"_5g_av"
;
_5g_av
[
"Content-Type"
]
=
"JSON"
;
for
(
int
i
=
0
;
i
<
MAX_5GS_AUTH_VECTORS
;
i
++
)
{
_5g_av_m
[
"avType"
]
=
to_string
(
nc
->
_5g_av
[
i
].
avType
);
_5g_av_m
[
"rand"
]
=
to_string
(
*
(
nc
->
_5g_av
[
i
].
rand
));
_5g_av_m
[
"hxres"
]
=
to_string
(
*
nc
->
_5g_av
[
i
].
hxres
);
_5g_av_m
[
"autn"
]
=
to_string
(
*
nc
->
_5g_av
[
i
].
autn
);
_5g_av_m
[
"hxresStar"
]
=
to_string
(
*
nc
->
_5g_av
[
i
].
hxresStar
);
_5g_av_m
[
"kseaf"
]
=
to_string
(
*
nc
->
_5g_av
[
i
].
kseaf
);
_5g_av
[
"content"
].
push_back
(
_5g_av_m
);
}
udsf_nas_context
[
"blocks"
].
push_back
(
_5g_av
);
//kamf
nlohmann
::
json
kamf
=
{};
nlohmann
::
json
kamf_m
=
{};
kamf
[
"Content-ID"
]
=
"kamf"
;
kamf
[
"Content-Type"
]
=
"JSON"
;
for
(
int
i
=
0
;
i
<
MAX_5GS_AUTH_VECTORS
;
i
++
){
for
(
int
j
=
0
;
j
<
32
;
j
++
)
{
kamf_m
=
to_string
(
nc
->
kamf
[
i
][
j
]);
}
kamf
[
"content"
].
push_back
(
kamf_m
);
}
udsf_nas_context
[
"blocks"
].
push_back
(
kamf
);
//security_context_t _security和nas_secu_ctx* security_ctx
nlohmann
::
json
_security
=
{};
...
...
@@ -749,6 +798,57 @@ void amf_n1::identity_response_handle(uint32_t ran_ue_ngap_id,
nc
.
get
()
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
nc
.
get
()
->
is_imsi_present
=
true
;
nc
.
get
()
->
imsi
=
supi
;
/***************************hsx add************************/
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"nas_context/records/"
)
+
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)
;
nlohmann
::
json
udsf_nas_context
;
nlohmann
::
json
udsf_response
;
udsf_nas_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
amf_ue_ngap_id
})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
nlohmann
::
json
ctx_avaliability_ind
;
ctx_avaliability_ind
[
"Content-ID"
]
=
"ctx_avaliability_ind"
;
ctx_avaliability_ind
[
"Content-Type"
]
=
"JSON"
;
ctx_avaliability_ind
[
"content"
]
=
nc
.
get
()
->
ctx_avaliability_ind
;
udsf_nas_context
[
"blocks"
].
push_back
(
ctx_avaliability_ind
);
nlohmann
::
json
nas_status
;
nas_status
[
"Content-ID"
]
=
"nas_status"
;
nas_status
[
"Content-Type"
]
=
"JSON"
;
nas_status
[
"content"
]
=
nc
.
get
()
->
nas_status
;
udsf_nas_context
[
"blocks"
].
push_back
(
nas_status
);
nlohmann
::
json
amf_ue_ngap_id_m
;
amf_ue_ngap_id_m
[
"Content-ID"
]
=
"amf_ue_ngap_id"
;
amf_ue_ngap_id_m
[
"Content-Type"
]
=
"JSON"
;
amf_ue_ngap_id_m
[
"content"
]
=
nc
.
get
()
->
amf_ue_ngap_id
;
udsf_nas_context
[
"blocks"
].
push_back
(
amf_ue_ngap_id_m
);
nlohmann
::
json
ran_ue_ngap_id_m
;
ran_ue_ngap_id_m
[
"Content-ID"
]
=
"ran_ue_ngap_id"
;
ran_ue_ngap_id_m
[
"Content-Type"
]
=
"JSON"
;
ran_ue_ngap_id_m
[
"content"
]
=
nc
.
get
()
->
ran_ue_ngap_id
;
udsf_nas_context
[
"blocks"
].
push_back
(
ran_ue_ngap_id_m
);
nlohmann
::
json
is_imsi_present
;
is_imsi_present
[
"Content-ID"
]
=
"is_imsi_present"
;
is_imsi_present
[
"Content-Type"
]
=
"JSON"
;
is_imsi_present
[
"content"
]
=
nc
.
get
()
->
is_imsi_present
;
udsf_nas_context
[
"blocks"
].
push_back
(
is_imsi_present
);
nlohmann
::
json
imsi
;
imsi
[
"Content-ID"
]
=
"imsi"
;
imsi
[
"Content-Type"
]
=
"JSON"
;
imsi
[
"content"
]
=
nc
.
get
()
->
imsi
;
udsf_nas_context
[
"blocks"
].
push_back
(
imsi
);
std
::
string
json_part
=
udsf_nas_context
.
dump
();
//nlohmann::json udsf_response;
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
json_part
,
"PUT"
,
udsf_response
);
/***************************hsx add************************/
supi2amfId
[(
"imsi-"
+
nc
.
get
()
->
imsi
)]
=
amf_ue_ngap_id
;
supi2ranId
[(
"imsi-"
+
nc
.
get
()
->
imsi
)]
=
ran_ue_ngap_id
;
if
(
nc
.
get
()
->
to_be_register_by_new_suci
)
{
...
...
@@ -815,25 +915,42 @@ void amf_n1::service_request_handle(bool isNasSig,
ran_ue_ngap_id
);
Logger
::
amf_n1
().
debug
(
"Key for pdu session context: SUPI %s"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
if
(
!
psc
)
{
Logger
::
amf_n1
().
error
(
"Cannot get pdu_session_context"
);
delete
serReq
;
delete
serApt
;
return
;
}
psc
.
get
()
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
psc
.
get
()
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
}
else
{
Logger
::
amf_n1
().
error
(
"Cannot get pdu_session_context with SUPI %s"
,
supi
.
c_str
());
}
if
(
!
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
)
||
!
psc
.
get
()
->
isn2sm_avaliable
)
{
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
bool
is_supi_to_pdu_ctx_udsf
=
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
);
if
(
!
is_supi_to_pdu_ctx_udsf
){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
psc
.
get
()
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
psc
.
get
()
->
amf_ue_ngap_id
=
amf_ue_ngap_id
;
//***************************stateless
// if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
// psc = amf_n11_inst->supi_to_pdu_ctx(supi);
// if (!psc) {
// Logger::amf_n1().error("Cannot get pdu_session_context");
// delete serReq;
// delete serApt;
// return;
// }
// psc.get()->ran_ue_ngap_id = ran_ue_ngap_id;
// psc.get()->amf_ue_ngap_id = amf_ue_ngap_id;
// } else {
// Logger::amf_n1().error("Cannot get pdu_session_context with SUPI %s",
// supi.c_str());
// }
if
(
!
is_supi_to_pdu_ctx_udsf
||
!
psc
.
get
()
->
isn2sm_avaliable
)
{
//if (!amf_n11_inst->is_supi_to_pdu_ctx(supi) || !psc.get()->isn2sm_avaliable) {
Logger
::
amf_n1
().
error
(
"Cannot get pdu session information with supi(%s)"
,
supi
.
c_str
());
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
//if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
if
(
is_supi_to_pdu_ctx_udsf
)
{
psc
.
get
()
->
isn2sm_avaliable
=
true
;
}
serApt
->
setPDU_session_status
(
0x0000
);
...
...
@@ -851,6 +968,21 @@ void amf_n1::service_request_handle(bool isNasSig,
Authentication_5gaka
::
derive_kgnb
(
ulcount
,
0x01
,
kamf
,
kgnb
);
bstring
kgnb_bs
=
blk2bstr
(
kgnb
,
32
);
std
::
string
udsf_put_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
nlohmann
::
json
udsf_put_pdu_session_context
;
// nlohmann::json udsf_response;
udsf_put_pdu_session_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
supi
})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_put_pdu_session_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
{{
"Content-ID"
,
"isn2sm_avaliable"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
isn2sm_avaliable
)}},
});
std
::
string
json_part
=
udsf_put_pdu_session_context
.
dump
();
amf_n2_inst
->
curl_http_client_udsf
(
udsf_put_url
,
json_part
,
"PUT"
,
udsf_response
);
itti_initial_context_setup_request
*
itti_msg
=
new
itti_initial_context_setup_request
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_msg
->
ran_ue_ngap_id
=
ran_ue_ngap_id
;
...
...
@@ -949,6 +1081,7 @@ void amf_n1::registration_request_handle(bool isNasSig,
nlohmann
::
json
requestedNssai_json
;
nlohmann
::
json
udsf_nas_context
;
nlohmann
::
json
is_imsi_present
;
nlohmann
::
json
_5gmm_state
;
RegistrationRequest
*
regReq
=
new
RegistrationRequest
();
regReq
->
decodefrombuffer
(
nullptr
,
(
uint8_t
*
)
bdata
(
reg
),
blength
(
reg
));
...
...
@@ -1044,10 +1177,15 @@ void amf_n1::registration_request_handle(bool isNasSig,
stacs
.
update_ue_info
(
ueItem
);
set_5gmm_state
(
nc
,
_5GMM_COMMON_PROCEDURE_INITIATED
);
nc
.
get
()
->
is_stacs_available
=
true
;
is_stacs_available
[
"Content-ID"
]
=
"is_stacs_available"
;
is_stacs_available
[
"Content-ID"
]
=
"is_stacs_available"
;
is_stacs_available
[
"Content-Type"
]
=
"varchar(32)"
;
is_stacs_available
[
"content"
]
=
to_string
(
nc
.
get
()
->
is_stacs_available
);
udsf_nas_context
[
"blocks"
].
push_back
(
is_stacs_available
);
_5gmm_state
[
"Content-ID"
]
=
"_5gmm_state"
;
_5gmm_state
[
"Content-Type"
]
=
"varchar(32)"
;
_5gmm_state
[
"content"
]
=
to_string
(
nc
.
get
()
->
_5gmm_state
);
udsf_nas_context
[
"blocks"
].
push_back
(
_5gmm_state
);
/*
bool add_new_ue = true;
for(int i=0; i< stacs.ues.size(); i++){
...
...
@@ -1066,7 +1204,8 @@ void amf_n1::registration_request_handle(bool isNasSig,
}
if(add_new_ue)
stacs.ues.push_back(ueItem);
*/
}
*/
}
// nc.get()->imsi = //need interface to transfer SUCI_imsi_t to string
}
}
break
;
...
...
@@ -1096,7 +1235,7 @@ void amf_n1::registration_request_handle(bool isNasSig,
nc
.
get
()
->
is_auth_vectors_present
=
false
;
nc
.
get
()
->
is_current_security_available
=
false
;
nc
.
get
()
->
security_ctx
->
sc_type
=
SECURITY_CTX_TYPE_NOT_AVAILABLE
;
is_auth_vectors_present
[
"Content-ID"
]
=
"is_auth_vectors_present"
;
is_auth_vectors_present
[
"Content-ID"
]
=
"is_auth_vectors_present"
;
is_auth_vectors_present
[
"Content-Type"
]
=
"varchar(32)"
;
is_auth_vectors_present
[
"content"
]
=
to_string
(
nc
.
get
()
->
is_auth_vectors_present
);
udsf_nas_context
[
"blocks"
].
push_back
(
is_auth_vectors_present
);
...
...
@@ -1137,7 +1276,7 @@ void amf_n1::registration_request_handle(bool isNasSig,
nc
.
get
()
->
ngKsi
=
100
;
// supi2amfId[("imsi-"+nc.get()->imsi)] = amf_ue_ngap_id;
// supi2ranId[("imsi-"+nc.get()->imsi)] = ran_ue_ngap_id;
ctx_avaliability_ind
[
"Content-ID"
]
=
"ctx_avaliability_ind"
;
ctx_avaliability_ind
[
"Content-ID"
]
=
"ctx_avaliability_ind"
;
ctx_avaliability_ind
[
"Content-Type"
]
=
"varchar(32)"
;
ctx_avaliability_ind
[
"content"
]
=
to_string
(
nc
.
get
()
->
ctx_avaliability_ind
);
udsf_nas_context
[
"blocks"
].
push_back
(
ctx_avaliability_ind
);
...
...
@@ -1272,7 +1411,7 @@ void amf_n1::registration_request_handle(bool isNasSig,
nc
.
get
()
->
registration_type
=
reg_type
;
nc
.
get
()
->
follow_on_req_pending_ind
=
is_follow_on_req_pending
;
registration_type
[
"Content-ID"
]
=
"registration_type"
;
registration_type
[
"Content-ID"
]
=
"registration_type"
;
registration_type
[
"Content-Type"
]
=
"varchar(32)"
;
registration_type
[
"content"
]
=
to_string
(
nc
.
get
()
->
registration_type
);
udsf_nas_context
[
"blocks"
].
push_back
(
registration_type
);
...
...
@@ -1305,7 +1444,7 @@ void amf_n1::registration_request_handle(bool isNasSig,
Logger
::
amf_n1
().
warn
(
"No Optional IE 5GMMCapability available"
);
}
nc
.
get
()
->
mmCapability
=
_5g_mm_cap
;
mmCapability
[
"Content-ID"
]
=
"mmCapability"
;
mmCapability
[
"Content-ID"
]
=
"mmCapability"
;
mmCapability
[
"Content-Type"
]
=
"varchar(32)"
;
mmCapability
[
"content"
]
=
to_string
(
nc
.
get
()
->
mmCapability
);
udsf_nas_context
[
"blocks"
].
push_back
(
mmCapability
);
...
...
@@ -1565,11 +1704,21 @@ void amf_n1::response_registration_reject_msg(uint8_t cause_value,
// specific procedures running logic
void
amf_n1
::
run_registration_procedure
(
std
::
shared_ptr
<
nas_context
>
&
nc
)
{
Logger
::
amf_n1
().
debug
(
"Start to run registration procedure"
);
nlohmann
::
json
udsf_nas_context
;
nlohmann
::
json
udsf_response
;
nlohmann
::
json
is_specific_procedure_for_registration_running
;
nlohmann
::
json
is_auth_vectors_present
;
nlohmann
::
json
ngksi
;
if
(
!
nc
.
get
()
->
ctx_avaliability_ind
)
{
Logger
::
amf_n1
().
error
(
"NAS context is not available"
);
return
;
}
nc
.
get
()
->
is_specific_procedure_for_registration_running
=
true
;
is_specific_procedure_for_registration_running
[
"Content-ID"
]
=
"is_specific_procedure_for_registration_running"
;
is_specific_procedure_for_registration_running
[
"Content-Type"
]
=
"varchar(32)"
;
is_specific_procedure_for_registration_running
[
"content"
]
=
to_string
(
nc
.
get
()
->
is_stacs_available
);
udsf_nas_context
[
"blocks"
].
push_back
(
is_specific_procedure_for_registration_running
);
if
(
nc
.
get
()
->
is_imsi_present
)
{
Logger
::
amf_n1
().
debug
(
"SUCI SUPI format IMSI is available"
);
if
(
!
nc
.
get
()
->
is_auth_vectors_present
)
{
...
...
@@ -1604,6 +1753,13 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context> &nc) {
nc
.
get
()
->
ngKsi
=
ngksi
;
handle_auth_vector_successful_result
(
nc
);
}
// ngksi["Content-ID"] = "ngKsi";
// ngksi["Content-Type"] = "varchar(32)";
// ngksi["content"] = to_string(nc.get()->ngKsi);
// udsf_nas_context["blocks"].push_back(ngksi);
// std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("nas_context/records/") + to_string(nc.get()->amf_ue_ngap_id) ;
// amf_n2_inst->curl_http_client_udsf(udsf_url,udsf_nas_context.dump(),"PUT",udsf_response);
}
else
if
(
nc
.
get
()
->
is_5g_guti_present
)
{
Logger
::
amf_n1
().
debug
(
"Start to run identification procedure"
);
nc
.
get
()
->
is_auth_vectors_present
=
false
;
...
...
@@ -1615,27 +1771,23 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context> &nc) {
uint8_t
buffer
[
100
];
int
encoded_size
=
ir
->
encode2buffer
(
buffer
,
100
);
delete
ir
;
itti_dl_nas_transport
*
dnt
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
itti_dl_nas_transport
*
dnt
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
dnt
->
nas
=
blk2bstr
(
buffer
,
encoded_size
);
dnt
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
dnt
->
ran_ue_ngap_id
=
nc
.
get
()
->
ran_ue_ngap_id
;
//*************************hsx add**************************
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"nas_context/records/"
)
+
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)
;
nlohmann
::
json
udsf_nas_context
;
nlohmann
::
json
udsf_response
;
udsf_nas_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_nas_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
{{
"Content-ID"
,
"is_auth_vectors_present"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
nc
.
get
()
->
is_auth_vectors_present
)}}
});
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
udsf_nas_context
.
dump
(),
"PUT"
,
udsf_response
);
//*************************hsx add**************************
/*************************hsx add**************************/
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"nas_context/records/"
)
+
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)
;
udsf_nas_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_nas_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
{{
"Content-ID"
,
"is_auth_vectors_present"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
nc
.
get
()
->
is_auth_vectors_present
)}}
});
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
udsf_nas_context
.
dump
(),
"PUT"
,
udsf_response
);
/*************************hsx add**************************/
std
::
shared_ptr
<
itti_dl_nas_transport
>
i
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
(
dnt
);
std
::
shared_ptr
<
itti_dl_nas_transport
>
i
=
std
::
shared_ptr
<
itti_dl_nas_transport
>
(
dnt
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
Logger
::
amf_n1
().
error
(
...
...
@@ -2277,14 +2429,18 @@ bool amf_n1::start_authentication_procedure(std::shared_ptr<nas_context> nc,
Logger
::
amf_n1
().
debug
(
"amf_ue_ngap_id 0x%x"
,
nc
.
get
()
->
amf_ue_ngap_id
);
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"ue_nas_context/records/"
)
+
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)
;
nlohmann
::
json
udsf_ue_nas_context
;
udsf_ue_nas_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)})},
{
"from_nf"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
// udsf_ue_nas_context["blocks"] =;
std
::
string
json_part
=
udsf_ue_nas_context
.
dump
();
//amf_n2_inst->curl_http_client_udsf(udsf_url,json_part,"PUT");
nlohmann
::
json
udsf_ue_nas_context
;
udsf_ue_nas_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)})},
{
"from_nf"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
// udsf_ue_nas_context["blocks"] =;
//_5g_av.rand
//nc.get()->_5g_av[0].autn
// nc.get()->_5g_av[0].hxresStar
// nc.get()->Href
std
::
string
json_part
=
udsf_ue_nas_context
.
dump
();
//amf_n2_inst->curl_http_client_udsf(udsf_url,json_part,"PUT");
itti_send_dl_nas_buffer_to_task_n2
(
b
,
nc
.
get
()
->
ran_ue_ngap_id
,
...
...
@@ -2559,6 +2715,7 @@ int amf_n1::security_select_algorithms(uint8_t nea, uint8_t nia,
void
amf_n1
::
security_mode_complete_handle
(
uint32_t
ran_ue_ngap_id
,
long
amf_ue_ngap_id
,
bstring
nas_msg
)
{
nlohmann
::
json
udsf_nas_context
;
Logger
::
amf_n1
().
debug
(
"Handling security mode complete ..."
);
string
ue_context_key
=
"app_ue_ranid_"
+
to_string
(
ran_ue_ngap_id
)
+
"-amfid_"
+
to_string
(
amf_ue_ngap_id
);
...
...
@@ -2676,7 +2833,12 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id,
// "REGISTRATION-REGISTRED", ran_ue_ngap_id, amf_ue_ngap_id,
// nc.get()->imsi, "", mcc, mnc, uc.get()->cgi.nrCellID);
// stacs.ues.push_back(ueItem);
nlohmann
::
json
is_stacs_available
;
nc
.
get
()
->
is_stacs_available
=
true
;
is_stacs_available
[
"Content-ID"
]
=
"is_stacs_available"
;
is_stacs_available
[
"Content-Type"
]
=
"varchar(32)"
;
is_stacs_available
[
"content"
]
=
to_string
(
nc
.
get
()
->
is_stacs_available
);
udsf_nas_context
[
"blocks"
].
push_back
(
is_stacs_available
);
}
set_5gmm_state
(
nc
,
_5GMM_REGISTERED
);
...
...
@@ -2703,6 +2865,18 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id,
itti_msg
->
kgnb
=
kgnb_bs
;
itti_msg
->
nas
=
protectedNas
;
itti_msg
->
is_sr
=
false
;
// TODO: for Setup Request procedure
/****************************hsx add*****************************/
std
::
string
udsf_url
=
"http://10.28.234.76:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"nas_context/records/"
)
+
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)
;
nlohmann
::
json
udsf_response
;
udsf_nas_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
to_string
(
nc
.
get
()
->
amf_ue_ngap_id
)})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
udsf_nas_context
.
dump
(),
"PUT"
,
udsf_response
);
/****************************hsx add*****************************/
std
::
shared_ptr
<
itti_initial_context_setup_request
>
i
=
std
::
shared_ptr
<
itti_initial_context_setup_request
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
...
...
@@ -2712,6 +2886,7 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id,
i
->
get_msg_name
());
}
}
}
//------------------------------------------------------------------------------
...
...
@@ -3329,12 +3504,26 @@ void amf_n1::run_mobility_registration_update_procedure(
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
Logger
::
amf_n1
().
debug
(
"Key for pdu session context SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
}
else
{
Logger
::
amf_n1
().
error
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
// if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
// psc = amf_n11_inst->supi_to_pdu_ctx(supi);
// } else {
// Logger::amf_n1().error("Cannot get pdu_session_context with SUPI (%s)",
// supi.c_str());
// }
uint8_t
*
kamf
=
nc
.
get
()
->
kamf
[
secu
->
vector_pointer
];
uint8_t
kgnb
[
32
];
...
...
@@ -3423,12 +3612,26 @@ void amf_n1::run_periodic_registration_update_procedure(
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
Logger
::
amf_n1
().
debug
(
"Key for pdu session context SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
}
else
{
Logger
::
amf_n1
().
error
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
// if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
// psc = amf_n11_inst->supi_to_pdu_ctx(supi);
// } else {
// Logger::amf_n1().error("Cannot get pdu_session_context with SUPI (%s)",
// supi.c_str());
// }
itti_dl_nas_transport
*
itti_msg
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
...
...
@@ -3513,12 +3716,26 @@ void amf_n1::run_periodic_registration_update_procedure(
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
Logger
::
amf_n1
().
debug
(
"Key for pdu session context SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
}
else
{
Logger
::
amf_n1
().
error
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
// if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
// psc = amf_n11_inst->supi_to_pdu_ctx(supi);
// } else {
// Logger::amf_n1().error("Cannot get pdu_session_context with SUPI (%s)",
// supi.c_str());
// }
itti_dl_nas_transport
*
itti_msg
=
new
itti_dl_nas_transport
(
TASK_AMF_N1
,
TASK_AMF_N2
);
...
...
src/amf-app/amf_n11.cpp
View file @
af0865a5
...
...
@@ -27,7 +27,7 @@
*/
#include "amf_n11.hpp"
#include "amf_n2.hpp"
#include <curl/curl.h>
#include <nlohmann/json.hpp>
...
...
@@ -61,6 +61,7 @@ extern itti_mw* itti_inst;
extern
amf_config
amf_cfg
;
extern
amf_n11
*
amf_n11_inst
;
extern
amf_n1
*
amf_n1_inst
;
extern
amf_n2
*
amf_n2_inst
;
extern
void
msg_str_2_msg_hex
(
std
::
string
msg
,
bstring
&
b
);
extern
void
convert_string_2_hex
(
std
::
string
&
input
,
std
::
string
&
output
);
...
...
@@ -160,14 +161,28 @@ void amf_n11::handle_itti_message(
"ID %d)"
,
supi
.
c_str
(),
itti_msg
.
pdu_session_id
);
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
supi_to_pdu_ctx
(
supi
);
}
else
{
Logger
::
amf_n11
().
error
(
"Could not find psu_session_context with SUPI %s, Failed"
,
supi
.
c_str
());
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
// if (is_supi_to_pdu_ctx(supi)) {
// psc = supi_to_pdu_ctx(supi);
// } else {
// Logger::amf_n11().error(
// "Could not find psu_session_context with SUPI %s, Failed",
// supi.c_str());
// return;
// }
std
::
string
smf_addr
;
if
(
!
psc
.
get
()
->
smf_available
)
{
if
(
!
smf_selection_from_configuration
(
smf_addr
))
{
...
...
@@ -216,12 +231,26 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) {
std
::
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
supi_to_pdu_ctx
(
supi
);
}
else
{
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
new
pdu_session_context
());
set_supi_to_pdu_ctx
(
supi
,
psc
);
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
// if (is_supi_to_pdu_ctx(supi)) {
// psc = supi_to_pdu_ctx(supi);
// } else {
// psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
// set_supi_to_pdu_ctx(supi, psc);
// }
pduid2supi
[
smf
.
pdu_sess_id
]
=
supi
;
psc
.
get
()
->
amf_ue_ngap_id
=
nc
.
get
()
->
amf_ue_ngap_id
;
...
...
@@ -354,6 +383,55 @@ void amf_n11::handle_pdu_session_initial_request(
"Handle PDU Session Establishment Request (SUPI %s, PDU Session ID %d)"
,
supi
.
c_str
(),
psc
.
get
()
->
pdu_session_id
);
/***************************hxs add**************/
//send udsf to storage us_ngap_context recordid=ran+ue_ngap_id
std
::
string
udsf_put_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
nlohmann
::
json
udsf_pdu_session_context
;
// nlohmann::json udsf_response;
udsf_pdu_session_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
supi
})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_pdu_session_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
{{
"Content-ID"
,
"ran_ue_ngap_id"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
ran_ue_ngap_id
)}},
{{
"Content-ID"
,
"amf_ue_ngap_id"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
amf_ue_ngap_id
)}},
{{
"Content-ID"
,
"req_type"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
req_type
)}},
{{
"Content-ID"
,
"pdu_session_id"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
pdu_session_id
)}},
{{
"Content-ID"
,
"dnn"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
psc
.
get
()
->
dnn
}},
{{
"Content-ID"
,
"n2sm"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
""
}},
{{
"Content-ID"
,
"isn2sm_avaliable"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
isn2sm_avaliable
)}},
{{
"Content-ID"
,
"n1sm"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
""
}},
{{
"Content-ID"
,
"isn1sm_avaliable"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
isn1sm_avaliable
)}},
{{
"Content-ID"
,
"remote_smf_addr"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
psc
.
get
()
->
remote_smf_addr
[
0
]}},
{{
"Content-ID"
,
"smf_available"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
smf_available
)}},
{{
"Content-ID"
,
"location"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
psc
.
get
()
->
location
}},
{{
"Content-ID"
,
"smf_context_location"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
psc
.
get
()
->
smf_context_location
}}
});
nlohmann
::
json
snssai
=
{};
nlohmann
::
json
plmn
=
{};
nlohmann
::
json
udsf_response
;
snssai
[
"Content-ID"
]
=
"snssai"
;
snssai
[
"Content-Type"
]
=
"varchar(32)"
;
snssai
[
"content"
][
"sST"
]
=
to_string
(
psc
.
get
()
->
snssai
.
sST
)
;
snssai
[
"content"
][
"sD"
]
=
psc
.
get
()
->
snssai
.
sD
;
plmn
[
"Content-ID"
]
=
"plmn"
;
plmn
[
"Content-Type"
]
=
"varchar(32)"
;
plmn
[
"content"
][
"mcc"
]
=
psc
.
get
()
->
plmn
.
mcc
;
plmn
[
"content"
][
"mnc"
]
=
psc
.
get
()
->
plmn
.
mnc
;
plmn
[
"content"
][
"tac"
]
=
to_string
(
psc
.
get
()
->
plmn
.
tac
)
;
udsf_pdu_session_context
[
"blocks"
].
push_back
(
snssai
);
udsf_pdu_session_context
[
"blocks"
].
push_back
(
plmn
);
std
::
string
json_part_udsf
=
udsf_pdu_session_context
.
dump
();
amf_n2_inst
->
curl_http_client_udsf
(
udsf_put_url
,
json_part_udsf
,
"PUT"
,
udsf_response
);
/************************hxs add****************/
// TODO: Remove hardcoded values
std
::
string
remote_uri
=
smf_addr
+
"/nsmf-pdusession/v2/sm-contexts"
;
// TODO
...
...
@@ -388,12 +466,34 @@ void amf_n11::handle_pdu_session_initial_request(
octet_stream_2_hex_stream
((
uint8_t
*
)
bdata
(
sm_msg
),
blength
(
sm_msg
),
n1SmMsg
);
curl_http_client
(
remote_uri
,
json_part
,
n1SmMsg
,
""
,
supi
,
psc
.
get
()
->
pdu_session_id
);
}
//------------------------------------------------------------------------------
void
amf_n11
::
handle_itti_message
(
itti_nsmf_pdusession_release_sm_context
&
itti_msg
)
{
std
::
shared_ptr
<
pdu_session_context
>
psc
=
supi_to_pdu_ctx
(
itti_msg
.
supi
);
std
::
shared_ptr
<
pdu_session_context
>
psc
;
//= supi_to_pdu_ctx(itti_msg.supi);
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
itti_msg
.
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
string
smf_addr
;
if
(
!
psc
.
get
()
->
smf_available
)
{
if
(
!
smf_selection_from_configuration
(
smf_addr
))
{
...
...
@@ -492,13 +592,26 @@ void amf_n11::curl_http_client(
std
::
string
body
;
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
supi_to_pdu_ctx
(
supi
);
}
else
{
Logger
::
amf_n11
().
warn
(
"PDU Session context for SUPI %s doesn't exit!"
,
supi
.
c_str
());
// TODO:
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
// if (is_supi_to_pdu_ctx(supi)) {
// psc = supi_to_pdu_ctx(supi);
// } else {
// Logger::amf_n11().warn(
// "PDU Session context for SUPI %s doesn't exit!", supi.c_str());
// // TODO:
// }
if
((
n1SmMsg
.
size
()
>
0
)
and
(
n2SmMsg
.
size
()
>
0
))
{
// prepare the body content for Curl
...
...
@@ -677,6 +790,22 @@ void amf_n11::curl_http_client(
itti_msg
->
supi
=
supi
;
itti_msg
->
pdu_session_id
=
pdu_session_id
;
std
::
string
udsf_put_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
nlohmann
::
json
udsf_put_pdu_session_context
;
nlohmann
::
json
udsf_response
;
udsf_put_pdu_session_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
supi
})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_put_pdu_session_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
{{
"Content-ID"
,
"smf_context_location"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
psc
.
get
()
->
smf_context_location
}},
});
std
::
string
json_part
=
udsf_put_pdu_session_context
.
dump
();
amf_n2_inst
->
curl_http_client_udsf
(
udsf_put_url
,
json_part
,
"PUT"
,
udsf_response
);
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
);
...
...
src/amf-app/amf_n2.cpp
View file @
af0865a5
...
...
@@ -1094,12 +1094,26 @@ void amf_n2::handle_itti_message(
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
Logger
::
amf_n2
().
debug
(
"SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
}
else
{
Logger
::
amf_n2
().
warn
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
// nlohmann::json udsf_response;
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
// if (amf_n11_inst->is_supi_to_pdu_ctx(supi))
// psc = amf_n11_inst->supi_to_pdu_ctx(supi);
// } else {
// Logger::amf_n2().warn(
// "Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
// }
// item.s_nssai.sst = std::to_string(psc.get()->snssai.sST);
// item.s_nssai.sd = psc.get()->snssai.sD;
...
...
@@ -1481,8 +1495,23 @@ void amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
// handoverrequest->setSourceToTarget_TransparentContainer(sourceTotarget);
string
supi
=
"imsi-"
+
nc
.
get
()
->
imsi
;
std
::
shared_ptr
<
pdu_session_context
>
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
std
::
shared_ptr
<
pdu_session_context
>
psc
;
// =
// amf_n11_inst->supi_to_pdu_ctx(supi);
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
std
::
vector
<
PDUSessionResourceSetupRequestItem_t
>
list
;
PDUSessionResourceSetupRequestItem_t
item
;
item
.
pduSessionId
=
psc
.
get
()
->
pdu_session_id
;
...
...
src/amf-app/amf_profile.cpp
0 → 100755
View file @
af0865a5
/*
* 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
*/
/*! \file amf_profile.cpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include "logger.hpp"
#include "amf_profile.hpp"
#include "string.hpp"
using
namespace
std
;
using
namespace
amf
;
//------------------------------------------------------------------------------
void
nf_profile
::
set_nf_instance_id
(
const
std
::
string
&
instance_id
)
{
nf_instance_id
=
instance_id
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
get_nf_instance_id
(
std
::
string
&
instance_id
)
const
{
instance_id
=
nf_instance_id
;
}
//------------------------------------------------------------------------------
std
::
string
nf_profile
::
get_nf_instance_id
()
const
{
return
nf_instance_id
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
set_nf_instance_name
(
const
std
::
string
&
instance_name
)
{
nf_instance_name
=
instance_name
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
get_nf_instance_name
(
std
::
string
&
instance_name
)
const
{
instance_name
=
nf_instance_name
;
}
//------------------------------------------------------------------------------
std
::
string
nf_profile
::
get_nf_instance_name
()
const
{
return
nf_instance_name
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
set_nf_type
(
const
std
::
string
&
type
)
{
nf_type
=
type
;
}
//------------------------------------------------------------------------------
std
::
string
nf_profile
::
get_nf_type
()
const
{
return
nf_type
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
set_nf_status
(
const
std
::
string
&
status
)
{
nf_status
=
status
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
get_nf_status
(
std
::
string
&
status
)
const
{
status
=
nf_status
;
}
//------------------------------------------------------------------------------
std
::
string
nf_profile
::
get_nf_status
()
const
{
return
nf_status
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
set_nf_heartBeat_timer
(
const
int32_t
&
timer
)
{
heartBeat_timer
=
timer
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
get_nf_heartBeat_timer
(
int32_t
&
timer
)
const
{
timer
=
heartBeat_timer
;
}
//------------------------------------------------------------------------------
int32_t
nf_profile
::
get_nf_heartBeat_timer
()
const
{
return
heartBeat_timer
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
set_nf_priority
(
const
uint16_t
&
p
)
{
priority
=
p
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
get_nf_priority
(
uint16_t
&
p
)
const
{
p
=
priority
;
}
//------------------------------------------------------------------------------
uint16_t
nf_profile
::
get_nf_priority
()
const
{
return
priority
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
set_nf_capacity
(
const
uint16_t
&
c
)
{
capacity
=
c
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
get_nf_capacity
(
uint16_t
&
c
)
const
{
c
=
capacity
;
}
//------------------------------------------------------------------------------
uint16_t
nf_profile
::
get_nf_capacity
()
const
{
return
capacity
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
set_nf_snssais
(
const
std
::
vector
<
snssai_t
>&
s
)
{
snssais
=
s
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
get_nf_snssais
(
std
::
vector
<
snssai_t
>&
s
)
const
{
s
=
snssais
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
add_snssai
(
const
snssai_t
&
s
)
{
snssais
.
push_back
(
s
);
}
//------------------------------------------------------------------------------
void
nf_profile
::
set_nf_ipv4_addresses
(
const
std
::
vector
<
struct
in_addr
>&
a
)
{
ipv4_addresses
=
a
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
add_nf_ipv4_addresses
(
const
struct
in_addr
&
a
)
{
ipv4_addresses
.
push_back
(
a
);
}
//------------------------------------------------------------------------------
void
nf_profile
::
get_nf_ipv4_addresses
(
std
::
vector
<
struct
in_addr
>&
a
)
const
{
a
=
ipv4_addresses
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
display
()
const
{
Logger
::
amf_app
().
debug
(
"NF instance info"
);
Logger
::
amf_app
().
debug
(
"
\t
Instance ID: %s"
,
nf_instance_id
.
c_str
());
Logger
::
amf_app
().
debug
(
"
\t
Instance name: %s"
,
nf_instance_name
.
c_str
());
Logger
::
amf_app
().
debug
(
"
\t
Instance type: %s"
,
nf_type
.
c_str
());
Logger
::
amf_app
().
debug
(
"
\t
Status: %s"
,
nf_status
.
c_str
());
Logger
::
amf_app
().
debug
(
"
\t
HeartBeat timer: %d"
,
heartBeat_timer
);
Logger
::
amf_app
().
debug
(
"
\t
Priority: %d"
,
priority
);
Logger
::
amf_app
().
debug
(
"
\t
Capacity: %d"
,
capacity
);
// SNSSAIs
if
(
snssais
.
size
()
>
0
)
{
Logger
::
amf_app
().
debug
(
"
\t
SNSSAI:"
);
}
for
(
auto
s
:
snssais
)
{
Logger
::
amf_app
().
debug
(
"
\t\t
SST, SD: %d, %s"
,
s
.
sST
,
s
.
sD
.
c_str
());
}
// IPv4 Addresses
if
(
ipv4_addresses
.
size
()
>
0
)
{
Logger
::
amf_app
().
debug
(
"
\t
IPv4 Addr:"
);
}
for
(
auto
address
:
ipv4_addresses
)
{
Logger
::
amf_app
().
debug
(
"
\t\t
%s"
,
inet_ntoa
(
address
));
}
}
//------------------------------------------------------------------------------
void
nf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
data
[
"nfInstanceId"
]
=
nf_instance_id
;
data
[
"nfInstanceName"
]
=
nf_instance_name
;
data
[
"nfType"
]
=
nf_type
;
data
[
"nfStatus"
]
=
nf_status
;
data
[
"heartBeatTimer"
]
=
heartBeat_timer
;
// SNSSAIs
data
[
"sNssais"
]
=
nlohmann
::
json
::
array
();
for
(
auto
s
:
snssais
)
{
nlohmann
::
json
tmp
=
{};
tmp
[
"sst"
]
=
s
.
sST
;
tmp
[
"sd"
]
=
s
.
sD
;
data
[
"sNssais"
].
push_back
(
tmp
);
}
// ipv4_addresses
data
[
"ipv4Addresses"
]
=
nlohmann
::
json
::
array
();
for
(
auto
address
:
ipv4_addresses
)
{
data
[
"ipv4Addresses"
].
push_back
(
inet_ntoa
(
address
));
}
data
[
"priority"
]
=
priority
;
data
[
"capacity"
]
=
capacity
;
}
//------------------------------------------------------------------------------
void
nf_profile
::
from_json
(
const
nlohmann
::
json
&
data
)
{
if
(
data
.
find
(
"nfInstanceId"
)
!=
data
.
end
())
{
nf_instance_id
=
data
[
"nfInstanceId"
].
get
<
std
::
string
>
();
}
if
(
data
.
find
(
"nfInstanceName"
)
!=
data
.
end
())
{
nf_instance_name
=
data
[
"nfInstanceName"
].
get
<
std
::
string
>
();
}
if
(
data
.
find
(
"nfType"
)
!=
data
.
end
())
{
nf_type
=
data
[
"nfType"
].
get
<
std
::
string
>
();
}
if
(
data
.
find
(
"nfStatus"
)
!=
data
.
end
())
{
nf_status
=
data
[
"nfStatus"
].
get
<
std
::
string
>
();
}
if
(
data
.
find
(
"heartBeatTimer"
)
!=
data
.
end
())
{
heartBeat_timer
=
data
[
"heartBeatTimer"
].
get
<
int
>
();
}
// sNssais
if
(
data
.
find
(
"sNssais"
)
!=
data
.
end
())
{
for
(
auto
it
:
data
[
"sNssais"
])
{
snssai_t
s
=
{};
s
.
sST
=
it
[
"sst"
].
get
<
int
>
();
s
.
sD
=
it
[
"sd"
].
get
<
std
::
string
>
();
snssais
.
push_back
(
s
);
}
}
if
(
data
.
find
(
"ipv4Addresses"
)
!=
data
.
end
())
{
nlohmann
::
json
addresses
=
data
[
"ipv4Addresses"
];
for
(
auto
it
:
addresses
)
{
struct
in_addr
addr4
=
{};
std
::
string
address
=
it
.
get
<
std
::
string
>
();
unsigned
char
buf_in_addr
[
sizeof
(
struct
in_addr
)];
if
(
inet_pton
(
AF_INET
,
util
::
trim
(
address
).
c_str
(),
buf_in_addr
)
==
1
)
{
memcpy
(
&
addr4
,
buf_in_addr
,
sizeof
(
struct
in_addr
));
}
else
{
Logger
::
amf_app
().
warn
(
"Address conversion: Bad value %s"
,
util
::
trim
(
address
).
c_str
());
}
add_nf_ipv4_addresses
(
addr4
);
}
}
if
(
data
.
find
(
"priority"
)
!=
data
.
end
())
{
priority
=
data
[
"priority"
].
get
<
int
>
();
}
if
(
data
.
find
(
"capacity"
)
!=
data
.
end
())
{
capacity
=
data
[
"capacity"
].
get
<
int
>
();
}
}
//------------------------------------------------------------------------------
void
amf_profile
::~
amf_profile
()
{}
void
amf_profile
::
set_nf_services
(
const
std
::
vector
<
nf_service_t
>&
n
)
{
nf_services
=
n
;
}
//------------------------------------------------------------------------------
void
amf_profile
::
add_nf_service
(
const
nf_service_t
&
n
)
{
nf_services
.
push_back
(
n
);
}
//------------------------------------------------------------------------------
void
amf_profile
::
get_nf_services
(
std
::
vector
<
nf_service_t
>&
n
)
const
{
n
=
nf_services
;
}
//------------------------------------------------------------------------------
void
amf_profile
::
set_custom_info
(
const
nlohmann
::
json
&
c
)
{
custom_info
=
c
;
}
//------------------------------------------------------------------------------
void
amf_profile
::
get_custom_info
(
nlohmann
::
json
&
c
)
const
{
c
=
custom_info
;
}
//------------------------------------------------------------------------------
void
amf_profile
::
set_amf_info
(
const
amf_info_t
&
s
)
{
amf_info
=
s
;
}
//------------------------------------------------------------------------------
void
amf_profile
::
add_amf_info_item
(
const
snssai_amf_info_item_t
&
s
)
{
amf_info
.
snssai_amf_info_list
.
push_back
(
s
);
}
//------------------------------------------------------------------------------
void
amf_profile
::
get_amf_info
(
amf_info_t
&
s
)
const
{
s
=
amf_info
;
}
//------------------------------------------------------------------------------
void
amf_profile
::
display
()
const
{
// display NF part
nf_profile
::
display
();
// NF services
if
(
nf_services
.
size
()
>
0
)
{
Logger
::
amf_app
().
debug
(
"
\t
NF Service"
);
}
for
(
auto
service
:
nf_services
)
{
Logger
::
amf_app
().
debug
(
"
\t\t
%s"
,
service
.
to_string
().
c_str
());
}
if
(
!
custom_info
.
empty
())
{
Logger
::
amf_app
().
debug
(
"
\t
Custom info: %s"
,
custom_info
.
dump
().
c_str
());
}
// amf info
if
(
amf_info
.
snssai_amf_info_list
.
size
()
>
0
)
{
Logger
::
amf_app
().
debug
(
"
\t
amf Info:"
);
}
for
(
auto
s
:
amf_info
.
snssai_amf_info_list
)
{
Logger
::
amf_app
().
debug
(
"
\t\t
Parameters supported by the amf:"
);
Logger
::
amf_app
().
debug
(
"
\t\t\t
SNSSAI (SST %d, SD %s)"
,
s
.
snssai
.
sST
,
s
.
snssai
.
sD
.
c_str
());
for
(
auto
d
:
s
.
dnn_amf_info_list
)
{
Logger
::
amf_app
().
debug
(
"
\t\t\t
DNN %s"
,
d
.
dnn
.
c_str
());
}
}
}
//------------------------------------------------------------------------------
void
amf_profile
::
to_json
(
nlohmann
::
json
&
data
)
const
{
nf_profile
::
to_json
(
data
);
// NF services
data
[
"nfServices"
]
=
nlohmann
::
json
::
array
();
for
(
auto
service
:
nf_services
)
{
nlohmann
::
json
srv_tmp
=
{};
srv_tmp
[
"serviceInstanceId"
]
=
service
.
service_instance_id
;
srv_tmp
[
"serviceName"
]
=
service
.
service_name
;
srv_tmp
[
"versions"
]
=
nlohmann
::
json
::
array
();
for
(
auto
v
:
service
.
versions
)
{
nlohmann
::
json
v_tmp
=
{};
v_tmp
[
"apiVersionInUri"
]
=
v
.
api_version_in_uri
;
v_tmp
[
"apiFullVersion"
]
=
v
.
api_full_version
;
srv_tmp
[
"versions"
].
push_back
(
v_tmp
);
}
srv_tmp
[
"scheme"
]
=
service
.
scheme
;
srv_tmp
[
"nfServiceStatus"
]
=
service
.
nf_service_status
;
// IP endpoints
srv_tmp
[
"ipEndPoints"
]
=
nlohmann
::
json
::
array
();
for
(
auto
endpoint
:
service
.
ip_endpoints
)
{
nlohmann
::
json
ep_tmp
=
{};
ep_tmp
[
"ipv4Address"
]
=
inet_ntoa
(
endpoint
.
ipv4_address
);
ep_tmp
[
"transport"
]
=
endpoint
.
transport
;
ep_tmp
[
"port"
]
=
endpoint
.
port
;
srv_tmp
[
"ipEndPoints"
].
push_back
(
ep_tmp
);
}
data
[
"nfServices"
].
push_back
(
srv_tmp
);
}
data
[
"custom_info"
]
=
custom_info
;
// amf info
data
[
"amfInfo"
]
=
{};
data
[
"amfInfo"
][
"sNssaiAmfInfoList"
]
=
nlohmann
::
json
::
array
();
for
(
auto
s
:
amf_info
.
snssai_amf_info_list
)
{
nlohmann
::
json
tmp
=
{};
tmp
[
"sNssai"
][
"sst"
]
=
s
.
snssai
.
sST
;
tmp
[
"sNssai"
][
"sd"
]
=
s
.
snssai
.
sD
;
tmp
[
"dnnAmfInfoList"
]
=
nlohmann
::
json
::
array
();
for
(
auto
d
:
s
.
dnn_amf_info_list
)
{
nlohmann
::
json
dnn_json
=
{};
dnn_json
[
"dnn"
]
=
d
.
dnn
;
tmp
[
"dnnAmfInfoList"
].
push_back
(
dnn_json
);
}
data
[
"amfInfo"
][
"sNssaiAmfInfoList"
].
push_back
(
tmp
);
}
Logger
::
amf_app
().
debug
(
"amf profile to json:
\n
%s"
,
data
.
dump
().
c_str
());
}
//------------------------------------------------------------------------------
void
amf_profile
::
from_json
(
const
nlohmann
::
json
&
data
)
{
nf_profile
::
from_json
(
data
);
// TODO: custom_info;
// amf info
if
(
data
.
find
(
"amfInfo"
)
!=
data
.
end
())
{
nlohmann
::
json
info
=
data
[
"amfInfo"
];
dnn_amf_info_item_t
dnn_item
=
{};
if
(
info
.
find
(
"sNssaiAmfInfoList"
)
!=
info
.
end
())
{
nlohmann
::
json
snssai_amf_info_list
=
data
[
"amfInfo"
][
"sNssaiAmfInfoList"
];
for
(
auto
it
:
snssai_amf_info_list
)
{
snssai_amf_info_item_t
amf_info_item
=
{};
if
(
it
.
find
(
"sNssai"
)
!=
it
.
end
())
{
if
(
it
[
"sNssai"
].
find
(
"sst"
)
!=
it
[
"sNssai"
].
end
())
amf_info_item
.
snssai
.
sST
=
it
[
"sNssai"
][
"sst"
].
get
<
int
>
();
if
(
it
[
"sNssai"
].
find
(
"sd"
)
!=
it
[
"sNssai"
].
end
())
amf_info_item
.
snssai
.
sD
=
it
[
"sNssai"
][
"sd"
].
get
<
std
::
string
>
();
}
if
(
it
.
find
(
"dnnAmfInfoList"
)
!=
it
.
end
())
{
for
(
auto
d
:
it
[
"dnnAmfInfoList"
])
{
if
(
d
.
find
(
"dnn"
)
!=
d
.
end
())
{
dnn_item
.
dnn
=
d
[
"dnn"
].
get
<
std
::
string
>
();
amf_info_item
.
dnn_amf_info_list
.
push_back
(
dnn_item
);
}
}
}
amf_info
.
snssai_amf_info_list
.
push_back
(
amf_info_item
);
}
}
}
display
();
}
//------------------------------------------------------------------------------
void
amf_profile
::
handle_heartbeart_timeout
(
uint64_t
ms
)
{
Logger
::
amf_app
().
info
(
"Handle heartbeart timeout profile %s, time %d"
,
nf_instance_id
.
c_str
(),
ms
);
set_nf_status
(
"SUSPENDED"
);
}
// //------------------------------------------------------------------------------
// void upf_profile::add_upf_info_item(const snssai_upf_info_item_t& s) {
// upf_info.snssai_upf_info_list.push_back(s);
// }
// //------------------------------------------------------------------------------
// void upf_profile::get_upf_info(upf_info_t& s) const {
// s = upf_info;
// }
// //------------------------------------------------------------------------------
// void upf_profile::display() const {
// // display NF part
// nf_profile::display();
// // UPF info
// if (upf_info.snssai_upf_info_list.size() > 0) {
// Logger::amf_app().debug("\tUPF Info:");
// }
// for (auto s : upf_info.snssai_upf_info_list) {
// Logger::amf_app().debug("\t\tParameters supported by the UPF:");
// Logger::amf_app().debug(
// "\t\t\tSNSSAI (SST %d, SD %s)", s.snssai.sST, s.snssai.sD.c_str());
// for (auto d : s.dnn_upf_info_list) {
// Logger::amf_app().debug("\t\t\tDNN %s", d.dnn.c_str());
// }
// }
// }
// //------------------------------------------------------------------------------
// void upf_profile::to_json(nlohmann::json& data) const {
// nf_profile::to_json(data);
// // UPF info
// data["upfInfo"] = {};
// data["upfInfo"]["sNssaiUpfInfoList"] = nlohmann::json::array();
// for (auto s : upf_info.snssai_upf_info_list) {
// nlohmann::json tmp = {};
// tmp["sNssai"]["sst"] = s.snssai.sST;
// tmp["sNssai"]["sd"] = s.snssai.sD;
// tmp["dnnAmfInfoList"] = nlohmann::json::array();
// for (auto d : s.dnn_upf_info_list) {
// nlohmann::json dnn_json = {};
// dnn_json["dnn"] = d.dnn;
// tmp["dnnAmfInfoList"].push_back(dnn_json);
// }
// data["upfInfo"]["sNssaiUpfInfoList"].push_back(tmp);
// }
// Logger::amf_app().debug("UPF profile to json:\n %s", data.dump().c_str());
// }
// //------------------------------------------------------------------------------
// void upf_profile::from_json(const nlohmann::json& data) {
// nf_profile::from_json(data);
// // UPF info
// if (data.find("upfInfo") != data.end()) {
// nlohmann::json info = data["upfInfo"];
// dnn_upf_info_item_t dnn_item = {};
// if (info.find("sNssaiUpfInfoList") != info.end()) {
// nlohmann::json snssai_upf_info_list =
// data["upfInfo"]["sNssaiUpfInfoList"];
// for (auto it : snssai_upf_info_list) {
// snssai_upf_info_item_t upf_info_item = {};
// if (it.find("sNssai") != it.end()) {
// if (it["sNssai"].find("sst") != it["sNssai"].end())
// upf_info_item.snssai.sST = it["sNssai"]["sst"].get<int>();
// if (it["sNssai"].find("sd") != it["sNssai"].end())
// upf_info_item.snssai.sD = it["sNssai"]["sd"].get<std::string>();
// }
// if (it.find("dnnUpfInfoList") != it.end()) {
// for (auto d : it["dnnUpfInfoList"]) {
// if (d.find("dnn") != d.end()) {
// dnn_item.dnn = d["dnn"].get<std::string>();
// upf_info_item.dnn_upf_info_list.push_back(dnn_item);
// }
// }
// }
// upf_info.snssai_upf_info_list.push_back(upf_info_item);
// }
// }
// }
// display();
// }
src/amf-app/amf_profile.hpp
0 → 100755
View file @
af0865a5
/*
* 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
*/
/*! \file amf_profile.hpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2021
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef FILE_AMF_PROFILE_HPP_SEEN
#define FILE_AMF_PROFILE_HPP_SEEN
#include <arpa/inet.h>
#include <netinet/in.h>
#include <map>
#include <memory>
#include <nlohmann/json.hpp>
#include <shared_mutex>
#include <utility>
#include <vector>
#include "logger.hpp"
//#include "smf.h"
namespace
amf
{
using
namespace
std
;
class
nf_profile
:
public
std
::
enable_shared_from_this
<
nf_profile
>
{
public:
nf_profile
()
:
nf_type
(
"NF_TYPE_UNKNOWN"
),
heartBeat_timer
(
0
),
snssais
(),
ipv4_addresses
(),
priority
(
0
),
capacity
(
0
)
{
nf_instance_name
=
""
;
nf_status
=
""
;
}
nf_profile
(
const
std
::
string
&
id
)
:
nf_instance_id
(
id
),
heartBeat_timer
(
0
),
snssais
(),
ipv4_addresses
(),
priority
(
0
),
capacity
(
0
),
nf_type
(
"NF_TYPE_UNKNOWN"
)
{
nf_instance_name
=
""
;
nf_status
=
""
;
}
nf_profile
&
operator
=
(
const
nf_profile
&
s
)
{
nf_instance_id
=
s
.
nf_instance_id
;
heartBeat_timer
=
s
.
heartBeat_timer
;
snssais
=
s
.
snssais
;
ipv4_addresses
=
s
.
ipv4_addresses
;
priority
=
s
.
priority
;
capacity
=
s
.
capacity
;
nf_type
=
s
.
nf_type
;
nf_instance_name
=
s
.
nf_instance_name
;
nf_status
=
s
.
nf_status
;
return
*
this
;
}
// nf_profile(nf_profile &b) = delete;
/*
* Set NF instance ID
* @param [const std::string &] instance_id: instance id
* @return void
*/
void
set_nf_instance_id
(
const
std
::
string
&
instance_id
);
/*
* Get NF instance ID
* @param [std::string &] instance_id: store instance id
* @return void:
*/
void
get_nf_instance_id
(
std
::
string
&
instance_id
)
const
;
/*
* Get NF instance ID
* @param [std::string &] instance_id: store instance id
* @return void:
*/
std
::
string
get_nf_instance_id
()
const
;
/*
* Set NF instance name
* @param [const std::string &] instance_name: instance name
* @return void
*/
void
set_nf_instance_name
(
const
std
::
string
&
instance_name
);
/*
* Get NF instance ID
* @param [std::string &] instance_name: store instance name
* @return void:
*/
void
get_nf_instance_name
(
std
::
string
&
instance_name
)
const
;
/*
* Get NF instance name
* @param
* @return [std::string] instance name
*/
std
::
string
get_nf_instance_name
()
const
;
/*
* Set NF instance status
* @param [const std::string &] status: instance status
* @return void
*/
void
set_nf_status
(
const
std
::
string
&
status
);
/*
* Get NF instance status
* @param [std::string &] status: store instance status
* @return void:
*/
void
get_nf_status
(
std
::
string
&
status
)
const
;
/*
* Get NF status
* @param
* @return [std::string] instance status
*/
std
::
string
get_nf_status
()
const
;
/*
* Get NF type
* @param
* @return [std::string] nf type
*/
std
::
string
get_nf_type
()
const
;
/*
* Set NF type
* @param [const nf_type_t &] type: nf type
* @return void
*/
void
set_nf_type
(
const
std
::
string
&
type
);
/*
* Set NF instance heartBeat_timer
* @param [const std::string &] timer: heartBeat_timer
* @return void
*/
void
set_nf_heartBeat_timer
(
const
int32_t
&
timer
);
/*
* Get NF instance heartBeat_timer
* @param [std::string &] timer: store heartBeat_timer
* @return void:
*/
void
get_nf_heartBeat_timer
(
int32_t
&
timer
)
const
;
/*
* Get NF heartBeat_timer
* @param void
* @return heartBeat_timer
*/
int32_t
get_nf_heartBeat_timer
()
const
;
/*
* Set NF instance priority
* @param [const uint16_t] p: instance priority
* @return void
*/
void
set_nf_priority
(
const
uint16_t
&
p
);
/*
* Get NF instance priority
* @param [uint16_t] p: store instance priority
* @return void:
*/
void
get_nf_priority
(
uint16_t
&
p
)
const
;
/*
* Get NF instance priority
* @param void
* @return [uint16_t] instance priority
*/
uint16_t
get_nf_priority
()
const
;
/*
* Set NF instance capacity
* @param [const uint16_t] c: instance capacity
* @return void
*/
void
set_nf_capacity
(
const
uint16_t
&
c
);
/*
* Get NF instance priority
* @param [uint16_t ] c: store instance capacity
* @return void:
*/
void
get_nf_capacity
(
uint16_t
&
c
)
const
;
/*
* Get NF instance priority
* @param void
* @return [uint16_t ] instance capacity
*/
uint16_t
get_nf_capacity
()
const
;
/*
* Set NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: SNSSAIs
* @return void
*/
void
set_nf_snssais
(
const
std
::
vector
<
snssai_t
>&
s
);
/*
* Add SNSSAI
* @param [snssai_t &] s: SNSSAI
* @return void
*/
void
add_snssai
(
const
snssai_t
&
s
);
/*
* Get NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: store instance's SNSSAIs
* @return void:
*/
void
get_nf_snssais
(
std
::
vector
<
snssai_t
>&
s
)
const
;
/*
* Set NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: ipv4_addresses
* @return void
*/
void
set_nf_ipv4_addresses
(
const
std
::
vector
<
struct
in_addr
>&
a
);
/*
* Add an IPv4 address to the list of addresses
* @param [const struct in_addr &] a: ipv4_address
* @return void
*/
void
add_nf_ipv4_addresses
(
const
struct
in_addr
&
a
);
/*
* Get NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: store instance's ipv4_addresses
* @return void:
*/
void
get_nf_ipv4_addresses
(
std
::
vector
<
struct
in_addr
>&
a
)
const
;
/*
* Print related-information for NF profile
* @param void
* @return void:
*/
virtual
void
display
()
const
;
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
virtual
void
to_json
(
nlohmann
::
json
&
data
)
const
;
/*
* Covert from a json represetation to amf profile
* @param [nlohmann::json &] data: Json data
* @return void
*/
virtual
void
from_json
(
const
nlohmann
::
json
&
data
);
protected:
// From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06))
std
::
string
nf_instance_id
;
std
::
string
nf_instance_name
;
std
::
string
nf_type
;
std
::
string
nf_status
;
int32_t
heartBeat_timer
;
std
::
vector
<
snssai_t
>
snssais
;
std
::
vector
<
struct
in_addr
>
ipv4_addresses
;
uint16_t
priority
;
uint16_t
capacity
;
};
typedef
struct
nf_service_version_s
{
std
::
string
api_version_in_uri
;
// apiVersionInUri
std
::
string
api_full_version
;
// apiFullVersion
nf_service_version_s
&
operator
=
(
const
nf_service_version_s
&
s
)
{
api_version_in_uri
=
s
.
api_version_in_uri
;
api_full_version
=
s
.
api_full_version
;
return
*
this
;
}
std
::
string
to_string
()
const
{
std
::
string
s
=
{};
s
.
append
(
", Version ("
);
s
.
append
(
"apiVersionInUri: "
);
s
.
append
(
api_version_in_uri
);
s
.
append
(
", apiFullVersion: "
);
s
.
append
(
api_full_version
);
s
.
append
(
" )"
);
return
s
;
}
}
nf_service_version_t
;
typedef
struct
ip_endpoint_s
{
// struct in6_addr ipv6_address;
struct
in_addr
ipv4_address
;
std
::
string
transport
;
// TCP
unsigned
int
port
;
std
::
string
to_string
()
const
{
std
::
string
s
=
{};
s
.
append
(
"Ipv4 Address: "
);
s
.
append
(
inet_ntoa
(
ipv4_address
));
s
.
append
(
", TransportProtocol: "
);
s
.
append
(
transport
);
s
.
append
(
", Port: "
);
s
.
append
(
std
::
to_string
(
port
));
return
s
;
}
}
ip_endpoint_t
;
typedef
struct
nf_service_s
{
std
::
string
service_instance_id
;
std
::
string
service_name
;
std
::
vector
<
nf_service_version_t
>
versions
;
std
::
string
scheme
;
std
::
string
nf_service_status
;
std
::
vector
<
ip_endpoint_t
>
ip_endpoints
;
std
::
string
to_string
()
const
{
std
::
string
s
=
{};
s
.
append
(
"Service Instance ID: "
);
s
.
append
(
service_instance_id
);
s
.
append
(
", Service name: "
);
s
.
append
(
service_name
);
for
(
auto
v
:
versions
)
{
s
.
append
(
v
.
to_string
());
}
s
.
append
(
", Scheme: "
);
s
.
append
(
scheme
);
s
.
append
(
", Service status: "
);
s
.
append
(
nf_service_status
);
s
.
append
(
", IpEndPoints: "
);
for
(
auto
endpoint
:
ip_endpoints
)
{
s
.
append
(
endpoint
.
to_string
());
}
return
s
;
}
}
nf_service_t
;
typedef
struct
dnn_amf_info_item_s
{
std
::
string
dnn
;
}
dnn_amf_info_item_t
;
typedef
struct
snssai_amf_info_item_s
{
snssai_t
snssai
;
std
::
vector
<
dnn_amf_info_item_t
>
dnn_amf_info_list
;
}
snssai_amf_info_item_t
;
typedef
struct
amf_info_s
{
std
::
vector
<
snssai_amf_info_item_t
>
snssai_amf_info_list
;
}
amf_info_t
;
class
amf_profile
:
public
nf_profile
{
public:
amf_profile
()
:
nf_profile
()
{
custom_info
=
{};
}
amf_profile
(
const
std
::
string
&
id
)
:
nf_profile
(
id
)
{
custom_info
=
{};
}
amf_profile
&
operator
=
(
const
amf_profile
&
s
)
{
nf_instance_id
=
s
.
nf_instance_id
;
heartBeat_timer
=
s
.
heartBeat_timer
;
snssais
=
s
.
snssais
;
ipv4_addresses
=
s
.
ipv4_addresses
;
priority
=
s
.
priority
;
capacity
=
s
.
capacity
;
nf_type
=
s
.
nf_type
;
nf_instance_name
=
s
.
nf_instance_name
;
nf_status
=
s
.
nf_status
;
custom_info
=
s
.
custom_info
;
amf_info
=
s
.
amf_info
;
nf_services
=
s
.
nf_services
;
return
*
this
;
}
// amf_profile(amf_profile &b) = delete;
//virtual ~amf_profile() {
~
amf_profile
()
{
Logger
::
amf_app
().
debug
(
"Delete amf Profile instance..."
);
}
/*
* Set NF instance services
* @param [std::vector<nf_service_t> &] n: nf_service
* @return void
*/
void
set_nf_services
(
const
std
::
vector
<
nf_service_t
>&
n
);
/*
* Add nf service
* @param [snssai_t &] n: nf service
* @return void
*/
void
add_nf_service
(
const
nf_service_t
&
n
);
/*
* Get NF services
* @param [std::vector<snssai_t> &] n: store instance's nf services
* @return void:
*/
void
get_nf_services
(
std
::
vector
<
nf_service_t
>&
n
)
const
;
/*
* Set custom info
* @param [const nlohmann::json &] c: custom info to be set
* @return void
*/
void
set_custom_info
(
const
nlohmann
::
json
&
c
);
/*
* Get custom info
* @param [nlohmann::json &] c: Store custom info
* @return void
*/
void
get_custom_info
(
nlohmann
::
json
&
c
)
const
;
/*
* Set amf info
* @param [amf_info_t &] s: amf info
* @return void
*/
void
set_amf_info
(
const
amf_info_t
&
s
);
/*
* Add an snssai_amf_info_item to the amf info
* @param [const snssai_amf_info_item_t &] s: snssai_amf_info_item
* @return void
*/
void
add_amf_info_item
(
const
snssai_amf_info_item_t
&
s
);
/*
* Get NF instance amf info
* @param [amf_info_t &] s: store instance's amf info
* @return void:
*/
void
get_amf_info
(
amf_info_t
&
s
)
const
;
/*
* Print related-information for NF profile
* @param void
* @return void:
*/
void
display
()
const
;
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
void
to_json
(
nlohmann
::
json
&
data
)
const
;
/*
* Covert from a json represetation to amf profile
* @param [nlohmann::json &] data: Json data
* @return void
*/
void
from_json
(
const
nlohmann
::
json
&
data
);
/*
* Handle heartbeart timeout event
* @param [uint64_t] ms: current time
* @return void
*/
void
handle_heartbeart_timeout
(
uint64_t
ms
);
protected:
std
::
vector
<
nf_service_t
>
nf_services
;
nlohmann
::
json
custom_info
;
// store extra json data
amf_info_t
amf_info
;
};
// class upf_profile : public nf_profile {
// public:
// upf_profile() : nf_profile() { // custom_info = {};
// nf_type = "UPF";
// }
// upf_profile(const std::string& id) : nf_profile(id) { // custom_info = {};
// }
// upf_profile& operator=(const upf_profile& s) {
// nf_instance_id = s.nf_instance_id;
// heartBeat_timer = s.heartBeat_timer;
// snssais = s.snssais;
// ipv4_addresses = s.ipv4_addresses;
// priority = s.priority;
// capacity = s.capacity;
// nf_type = s.nf_type;
// nf_instance_name = s.nf_instance_name;
// nf_status = s.nf_status;
// // custom_info = s.custom_info;
// upf_info = s.upf_info;
// return *this;
// }
// // upf_profile(upf_profile &b) = delete;
// virtual ~upf_profile() {
// Logger::amf_app().debug("Delete UPF Profile instance...");
// }
// /*
// * Set upf info
// * @param [upf_info_t &] s: upf info
// * @return void
// */
// void set_upf_info(const upf_info_t& s);
// /*
// * Add an snssai_upf_info_item to the upf info
// * @param [const snssai_upf_info_item_t &] s: snssai_upf_info_item
// * @return void
// */
// void add_upf_info_item(const snssai_upf_info_item_t& s);
// /*
// * Get NF instance upf info
// * @param [upf_info_t &] s: store instance's upf info
// * @return void:
// */
// void get_upf_info(upf_info_t& s) const;
// /*
// * Print related-information for NF profile
// * @param void
// * @return void:
// */
// void display() const;
// /*
// * Represent NF profile as json object
// * @param [nlohmann::json &] data: Json data
// * @return void
// */
// void to_json(nlohmann::json& data) const;
// /*
// * Covert from a json represetation to amf profile
// * @param [nlohmann::json &] data: Json data
// * @return void
// */
// void from_json(const nlohmann::json& data);
// /*
// * Handle heartbeart timeout event
// * @param [uint64_t] ms: current time
// * @return void
// */
// void handle_heartbeart_timeout(uint64_t ms);
// protected:
// nlohmann::json custom_info; // store extra json data
// upf_info_t upf_info;
// };
}
// namespace amf
#endif
src/contexts/pdu_session_context.cpp
View file @
af0865a5
...
...
@@ -37,3 +37,14 @@ pdu_session_context::pdu_session_context() {
//------------------------------------------------------------------------------
pdu_session_context
::~
pdu_session_context
()
{}
bool
pdu_session_context
::
pdu_session_context_from_json
(
nlohmann
::
json
j
)
{
//std::shared_ptr<gnb_context> gc1;
// printf("gnbname-%s\n",gnb_name.c_str());
// printf("globalgnbid-%d\n",globalRanNodeId);
// printf("next stream-%d\n",next_sctp_stream);
return
true
;
}
\ No newline at end of file
src/contexts/pdu_session_context.hpp
View file @
af0865a5
...
...
@@ -32,12 +32,12 @@
#include <string>
#include "bstrlib.h"
#include "amf.hpp"
#include <nlohmann/json.hpp>
class
pdu_session_context
{
public:
pdu_session_context
();
~
pdu_session_context
();
bool
pdu_session_context_from_json
(
nlohmann
::
json
j
);
uint32_t
ran_ue_ngap_id
;
long
amf_ue_ngap_id
;
uint8_t
req_type
;
...
...
@@ -53,5 +53,7 @@ class pdu_session_context {
snssai_t
snssai
;
plmn_t
plmn
;
std
::
string
smf_context_location
;
//15
};
#endif
src/ngap/ngap_app/ngap_message_callback.hpp
View file @
af0865a5
...
...
@@ -44,7 +44,7 @@
#include "InitialContextSetupResponse.hpp"
#include "pdu_session_context.hpp"
#include "nas_context.hpp"
#include "amf_n2.hpp"
using
namespace
sctp
;
using
namespace
ngap
;
using
namespace
amf_application
;
...
...
@@ -52,7 +52,7 @@ using namespace amf_application;
extern
itti_mw
*
itti_inst
;
extern
amf_n1
*
amf_n1_inst
;
extern
amf_n11
*
amf_n11_inst
;
extern
amf_n2
*
amf_n2_inst
;
typedef
int
(
*
ngap_message_decoded_callback
)(
const
sctp_assoc_id_t
assoc_id
,
const
sctp_stream_id_t
stream
,
struct
Ngap_NGAP_PDU
*
message_p
);
...
...
@@ -387,14 +387,42 @@ int ngap_amf_handle_pdu_session_resource_setup_response(
amf_n1_inst
->
amf_ue_id_2_nas_context
(
amf_ue_ngap_id
);
string
supi
=
"imsi-"
+
nct
.
get
()
->
imsi
;
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
if
(
!
psc
)
{
Logger
::
amf_n1
().
error
(
"connot get pdu_session_context"
);
return
0
;
}
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
0
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
// if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
// psc = amf_n11_inst->supi_to_pdu_ctx(supi);
// if (!psc) {
// Logger::amf_n1().error("connot get pdu_session_context");
// return 0;
// }
// }
psc
.
get
()
->
isn2sm_avaliable
=
false
;
std
::
string
udsf_put_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
nlohmann
::
json
udsf_put_pdu_session_context
;
//nlohmann::json udsf_response;
udsf_put_pdu_session_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
supi
})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_put_pdu_session_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
{{
"Content-ID"
,
"isn2sm_avaliable"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
isn2sm_avaliable
)}}
});
std
::
string
json_part
=
udsf_put_pdu_session_context
.
dump
();
amf_n2_inst
->
curl_http_client_udsf
(
udsf_put_url
,
json_part
,
"PUT"
,
udsf_response
);
Logger
::
ngap
().
debug
(
"receive pdu session resource setup response fail(multi pdu session "
"id),set pdu session context isn2sm_avaliable = false"
);
...
...
src/sbi/amf_server/impl/N1N2MessageCollectionDocumentApiImpl.cpp
View file @
af0865a5
...
...
@@ -14,7 +14,7 @@
#include "N1N2MessageCollectionDocumentApiImpl.h"
#include "itti.hpp"
//#include "itti_msg_n2.hpp"
#include "amf_n2.hpp"
#include "amf_n11.hpp"
//#include "amf_n2.hpp"
...
...
@@ -24,12 +24,12 @@
using
namespace
amf_application
;
using
namespace
ngap
;
extern
void
octet_stream_2_hex_stream
(
uint8_t
*
buf
,
int
len
,
std
::
string
&
out
);
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
itti_mw
*
itti_inst
;
extern
amf_n11
*
amf_n11_inst
;
extern
amf_n2
*
amf_n2_inst
;
//extern amf_n2* amf_n2_inst;
extern
void
print_buffer
(
...
...
@@ -88,12 +88,26 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
Logger
::
amf_server
().
debug
(
"Key for PDU Session context: SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
}
else
{
Logger
::
amf_server
().
error
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
!
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_n2
().
error
(
"No existing pdu_session_context with assoc_id "
);
return
;
}
Logger
::
amf_n2
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
//***************************stateless
// if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
// psc = amf_n11_inst->supi_to_pdu_ctx(supi);
// } else {
// Logger::amf_server().error(
// "Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
// }
bstring
n1sm
;
msg_str_2_msg_hex
(
...
...
@@ -107,6 +121,28 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
psc
.
get
()
->
isn1sm_avaliable
=
true
;
psc
.
get
()
->
n2sm
=
n2sm
;
psc
.
get
()
->
isn2sm_avaliable
=
true
;
string
n1sm_udsf
;
string
n2sm_udsf
;
octet_stream_2_hex_stream
((
uint8_t
*
)
bdata
(
psc
.
get
()
->
n1sm
),
blength
(
psc
.
get
()
->
n1sm
),
n1sm_udsf
);
octet_stream_2_hex_stream
((
uint8_t
*
)
bdata
(
psc
.
get
()
->
n2sm
),
blength
(
psc
.
get
()
->
n2sm
),
n2sm_udsf
);
std
::
string
udsf_put_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
nlohmann
::
json
udsf_put_pdu_session_context
;
//nlohmann::json udsf_response;
udsf_put_pdu_session_context
[
"meta"
]
[
"tags"
]
=
{
{
"RECORD_ID"
,
nlohmann
::
json
::
array
({
supi
})},
{
"from_nf_ID"
,
nlohmann
::
json
::
array
({
"AMF_1234"
})}
}
;
udsf_put_pdu_session_context
[
"blocks"
]
=
nlohmann
::
json
::
array
({
{{
"Content-ID"
,
"n2sm"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
n2sm_udsf
}},
{{
"Content-ID"
,
"isn2sm_avaliable"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
isn2sm_avaliable
)}},
{{
"Content-ID"
,
"n1sm"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
n1sm_udsf
}},
{{
"Content-ID"
,
"isn1sm_avaliable"
},{
"Content-Type"
,
"varchar(32)"
},{
"content"
,
to_string
(
psc
.
get
()
->
isn1sm_avaliable
)}},
});
std
::
string
json_part
=
udsf_put_pdu_session_context
.
dump
();
amf_n2_inst
->
curl_http_client_udsf
(
udsf_put_url
,
json_part
,
"PUT"
,
udsf_response
);
Logger
::
amf_server
().
debug
(
"n2sm size in amf_server(%d)"
,
blength
(
psc
.
get
()
->
n2sm
));
...
...
src/sbi/amf_server/impl/TestSignallingApiImpl.cpp
View file @
af0865a5
#include "TestSignallingApiImpl.h"
#include "itti.hpp"
#include "amf_n11.hpp"
#include "TestSignallingApiImpl.h"
#include "itti.hpp"
#include "amf_n2.hpp"
#include "amf_n11.hpp"
#include "pdu_session_context.hpp"
using
namespace
amf_application
;
//using namespace ngap;
//using namespace ngap;
extern
itti_mw
*
itti_inst
;
extern
amf_n11
*
amf_n11_inst
;
extern
amf_n11
*
amf_n11_inst
;
extern
amf_n2
*
amf_n2_inst
;
namespace
oai
{
namespace
amf
{
namespace
api
{
TestSignallingApiImpl
::
TestSignallingApiImpl
(
TestSignallingApiImpl
::
TestSignallingApiImpl
(
std
::
shared_ptr
<
Pistache
::
Rest
::
Router
>
rtr
,
amf_application
::
amf_app
*
amf_app_inst
)
:
TestSignallingApi
(
rtr
),
:
TestSignallingApi
(
rtr
),
m_amf_app
(
amf_app_inst
)
{}
void
TestSignallingApiImpl
::
test_signalling_network_initiated_deregistration
(
const
std
::
string
&
subscriptionId
,
void
TestSignallingApiImpl
::
test_signalling_network_initiated_deregistration
(
const
std
::
string
&
subscriptionId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"test_signalling_network_initiated_deregistration ok!
\n
"
);
std
::
string
supi
=
subscriptionId
;
"test_signalling_network_initiated_deregistration ok!
\n
"
);
std
::
string
supi
=
subscriptionId
;
Logger
::
amf_server
().
debug
(
"Key for PDU Session context: SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
itti_test_signalling_network_initiated_deregistration
*
itti_msg
=
new
itti_test_signalling_network_initiated_deregistration
(
AMF_SERVER
,
TASK_AMF_APP
);
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_server
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
itti_test_signalling_network_initiated_deregistration
*
itti_msg
=
new
itti_test_signalling_network_initiated_deregistration
(
AMF_SERVER
,
TASK_AMF_APP
);
itti_msg
->
ran_ue_ngap_id
=
psc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
psc
.
get
()
->
amf_ue_ngap_id
;
itti_msg
->
ran_ue_ngap_id
=
psc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
psc
.
get
()
->
amf_ue_ngap_id
;
std
::
shared_ptr
<
itti_test_signalling_network_initiated_deregistration
>
i
=
std
::
shared_ptr
<
itti_test_signalling_network_initiated_deregistration
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
Logger
::
amf_server
().
error
(
"Could not send ITTI message %s to task TASK_AMF_APP"
,
i
->
get_msg_name
());
std
::
shared_ptr
<
itti_test_signalling_network_initiated_deregistration
>
i
=
std
::
shared_ptr
<
itti_test_signalling_network_initiated_deregistration
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
Logger
::
amf_server
().
error
(
"Could not send ITTI message %s to task TASK_AMF_APP"
,
i
->
get_msg_name
());
}
}
else
{
Logger
::
amf_server
().
error
(
"No existing pdu_session_context with assoc_id "
);
}
//***************************stateless
// if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
// psc = amf_n11_inst->supi_to_pdu_ctx(supi);
// itti_test_signalling_network_initiated_deregistration* itti_msg =
// new itti_test_signalling_network_initiated_deregistration(AMF_SERVER, TASK_AMF_APP);
// itti_msg->ran_ue_ngap_id = psc.get()->ran_ue_ngap_id;
// itti_msg->amf_ue_ngap_id = psc.get()->amf_ue_ngap_id;
// std::shared_ptr<itti_test_signalling_network_initiated_deregistration> i =
// std::shared_ptr<itti_test_signalling_network_initiated_deregistration>(itti_msg);
// int ret = itti_inst->send_msg(i);
// if (0 != ret) {
// Logger::amf_server().error(
// "Could not send ITTI message %s to task TASK_AMF_APP",
// i->get_msg_name());
// }
// } else {
// Logger::amf_server().error(
// "Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
// }
}
void
TestSignallingApiImpl
::
test_signalling_paging
(
const
std
::
string
&
ueContextId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"test_signalling_paging ok!
\n
"
);
}
else
{
Logger
::
amf_server
().
error
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
}
}
void
TestSignallingApiImpl
::
test_signalling_paging
(
const
std
::
string
&
ueContextId
,
Pistache
::
Http
::
ResponseWriter
&
response
)
{
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"test_signalling_paging ok!
\n
"
);
std
::
string
supi
=
ueContextId
;
Logger
::
amf_server
().
debug
(
"Key for PDU Session context: SUPI (%s)"
,
supi
.
c_str
());
std
::
shared_ptr
<
pdu_session_context
>
psc
;
if
(
amf_n11_inst
->
is_supi_to_pdu_ctx
(
supi
))
{
psc
=
amf_n11_inst
->
supi_to_pdu_ctx
(
supi
);
itti_test_signalling_paging
*
itti_msg
=
new
itti_test_signalling_paging
(
AMF_SERVER
,
TASK_AMF_APP
);
//***************************stateless
pdu_session_context
*
psc1
=
new
pdu_session_context
();
nlohmann
::
json
udsf_response
;
std
::
string
udsf_url
=
"http://10.112.202.24:7123/nudsf-dr/v1/amfdata/"
+
std
::
string
(
"pdu_session_context/records/"
)
+
supi
;
if
(
amf_n2_inst
->
curl_http_client_udsf
(
udsf_url
,
""
,
"GET"
,
udsf_response
)){
Logger
::
amf_server
().
debug
(
"udsf_response: %s"
,
udsf_response
.
dump
().
c_str
());
psc1
->
pdu_session_context_from_json
(
udsf_response
);
psc
=
std
::
shared_ptr
<
pdu_session_context
>
(
psc1
);
itti_test_signalling_paging
*
itti_msg
=
new
itti_test_signalling_paging
(
AMF_SERVER
,
TASK_AMF_APP
);
itti_msg
->
ran_ue_ngap_id
=
psc
.
get
()
->
ran_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
psc
.
get
()
->
amf_ue_ngap_id
;
itti_msg
->
amf_ue_ngap_id
=
psc
.
get
()
->
amf_ue_ngap_id
;
std
::
shared_ptr
<
itti_test_signalling_paging
>
i
=
std
::
shared_ptr
<
itti_test_signalling_paging
>
(
itti_msg
);
std
::
shared_ptr
<
itti_test_signalling_paging
>
i
=
std
::
shared_ptr
<
itti_test_signalling_paging
>
(
itti_msg
);
int
ret
=
itti_inst
->
send_msg
(
i
);
if
(
0
!=
ret
)
{
Logger
::
amf_server
().
error
(
"Could not send ITTI message %s to task TASK_AMF_APP"
,
i
->
get_msg_name
());
}
}
else
{
Logger
::
amf_server
().
error
(
"No existing pdu_session_context with assoc_id "
);
}
//***************************stateless
// if (amf_n11_inst->is_supi_to_pdu_ctx(supi)) {
// psc = amf_n11_inst->supi_to_pdu_ctx(supi);
}
else
{
Logger
::
amf_server
().
error
(
"Cannot get pdu_session_context with SUPI (%s)"
,
supi
.
c_str
());
}
}
// itti_test_signalling_paging* itti_msg =
// new itti_test_signalling_paging(AMF_SERVER, TASK_AMF_APP);
// itti_msg->ran_ue_ngap_id = psc.get()->ran_ue_ngap_id;
// itti_msg->amf_ue_ngap_id = psc.get()->amf_ue_ngap_id;
// std::shared_ptr<itti_test_signalling_paging> i =
// std::shared_ptr<itti_test_signalling_paging>(itti_msg);
// int ret = itti_inst->send_msg(i);
// if (0 != ret) {
// Logger::amf_server().error(
// "Could not send ITTI message %s to task TASK_AMF_APP",
// i->get_msg_name());
// }
// } else {
// Logger::amf_server().error(
// "Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
// }
}
}
// namespace api
}
// namespace amf
}
// namespace oai
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment