Commit b621e54d authored by liuyu's avatar liuyu

can storage in udsf and cpe can software network

parent 6fd4a8a4
......@@ -404,6 +404,8 @@ void amf_n1::nas_signalling_establishment_request_handle(
{{"Content-ID", "ueSecurityCaplen"},{"Content-Type", "varchar(32)"},{"content", to_string(nc->ueSecurityCaplen)}},
{{"Content-ID", "ueSecurityCapEnc"},{"Content-Type", "varchar(32)"},{"content", to_string(nc->ueSecurityCapEnc)}},
{{"Content-ID", "ueSecurityCapInt"},{"Content-Type", "varchar(32)"},{"content", to_string(nc->ueSecurityCapInt)}},
{{"Content-ID", "ueSecurityCapEEnc"},{"Content-Type", "varchar(32)"},{"content", to_string(nc->ueSecurityCapEEnc)}},
{{"Content-ID", "ueSecurityCapEInt"},{"Content-Type", "varchar(32)"},{"content", to_string(nc->ueSecurityCapEInt)}},
{{"Content-ID", "serving_network"},{"Content-Type", "varchar(32)"},{"content", nc->serving_network}},
{{"Content-ID", "auts"},{"Content-Type", "varchar(32)"},{"content", auts}},
......@@ -415,7 +417,7 @@ void amf_n1::nas_signalling_establishment_request_handle(
{{"Content-ID", "is_common_procedure_for_security_mode_control_running"},{"Content-Type", "varchar(32)"},{"content", to_string(nc->is_common_procedure_for_security_mode_control_running)}},
{{"Content-ID", "is_common_procedure_for_nas_transport_running"},{"Content-Type", "varchar(32)"},{"content", to_string(nc->is_common_procedure_for_nas_transport_running)}},
{{"Content-ID", "Href"},{"Content-Type", "varchar(32)"},{"content", nc->Href}},
{{"Content-ID", "Href"},{"Content-Type", "varchar(1024)"},{"content", nc->Href}},
{{"Content-ID", "is_current_security_available"},{"Content-Type", "varchar(32)"},{"content", to_string(nc->is_current_security_available)}},
{{"Content-ID", "registration_attempt_counter"},{"Content-Type", "varchar(32)"},{"content", to_string(nc->registration_attempt_counter)}},
......@@ -914,8 +916,8 @@ void amf_n1::service_request_handle(bool isNasSig,
Logger::amf_n1().debug("amf_ue_ngap_id %d, ran_ue_ngap_id %d", amf_ue_ngap_id,
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;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************stateless
pdu_session_context *psc1 = new pdu_session_context();
nlohmann::json udsf_response;
......@@ -924,9 +926,11 @@ void amf_n1::service_request_handle(bool isNasSig,
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);
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->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
......@@ -978,6 +982,8 @@ void amf_n1::service_request_handle(bool isNasSig,
} ;
udsf_put_pdu_session_context["blocks"] = nlohmann::json::array({
{{"Content-ID", "isn2sm_avaliable"},{"Content-Type", "varchar(32)"},{"content",to_string(psc.get()->isn2sm_avaliable)}},
{{"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)}}
});
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);
......@@ -1041,6 +1047,24 @@ void amf_n1::service_request_handle(bool isNasSig,
itti_msg->isn2sm_avaliable = false;
Logger::amf_n1().error("Cannot get pdu session information");
}
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)}},
{{"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)}}
});
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_initial_context_setup_request> i =
std::shared_ptr<itti_initial_context_setup_request>(itti_msg);
int ret = itti_inst->send_msg(i);
......@@ -1082,6 +1106,8 @@ void amf_n1::registration_request_handle(bool isNasSig,
nlohmann::json udsf_nas_context;
nlohmann::json is_imsi_present;
nlohmann::json _5gmm_state;
nlohmann::json ueSecurityCapEEnc;
nlohmann::json ueSecurityCapEInt;
RegistrationRequest *regReq = new RegistrationRequest();
regReq->decodefrombuffer(nullptr, (uint8_t *)bdata(reg), blength(reg));
......@@ -1458,14 +1484,23 @@ void amf_n1::registration_request_handle(bool isNasSig,
}
else{
nc.get()->ueSecurityCaplen = regReq->ie_ue_security_capability->getLenght();
nc.get()->ueSecurityCapEEnc = regReq->ie_ue_security_capability->getEEASel();
nc.get()->ueSecurityCapEInt = regReq->ie_ue_security_capability->getEIASel();
ueSecurityCaplen["Content-ID"] = "ueSecurityCaplen";
ueSecurityCaplen["Content-Type"] = "varchar(32)";
ueSecurityCaplen ["content"] = to_string( nc.get()->ueSecurityCaplen);
udsf_nas_context["blocks"].push_back(ueSecurityCaplen);
nc.get()->ueSecurityCapEEnc = regReq->ie_ue_security_capability->getEEASel();
nc.get()->ueSecurityCapEInt = regReq->ie_ue_security_capability->getEIASel();
ueSecurityCapEEnc["Content-ID"] = "ueSecurityCapEEnc";
ueSecurityCapEEnc["Content-Type"] = "varchar(32)";
ueSecurityCapEEnc ["content"] = to_string( nc.get()->ueSecurityCapEEnc);
udsf_nas_context["blocks"].push_back(ueSecurityCapEEnc);
ueSecurityCapEInt["Content-ID"] = "ueSecurityCapEInt";
ueSecurityCapEInt["Content-Type"] = "varchar(32)";
ueSecurityCapEInt["content"] = to_string( nc.get()->ueSecurityCapEInt);
udsf_nas_context["blocks"].push_back(ueSecurityCapEInt);
}
nc.get()->ueSecurityCapEnc = encrypt_alg;
nc.get()->ueSecurityCapInt = integrity_alg;
......@@ -1754,15 +1789,21 @@ void amf_n1::run_registration_procedure(std::shared_ptr<nas_context> &nc) {
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);
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;
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);
// ... identification procedure
IdentityRequest *ir = new IdentityRequest();
// itti_msg->cause = 28;//cause nas(2)--deregister
......@@ -1945,6 +1986,13 @@ void amf_n1::curl_http_client(std::string remoteUri, std::string Method,
bool amf_n1::authentication_vectors_from_ausf(
std::shared_ptr<nas_context> &nc) {
nlohmann::json udsf_nas_context;
nlohmann::json udsf_response;
nlohmann::json Href;
nlohmann::json _5g_av = {};
nlohmann::json _5g_av_m = {};
Logger::amf_n1().debug("authentication_vectors_from_ausf");
std::string ausf_ip =
std::string(inet_ntoa(*((struct in_addr *)&amf_cfg.nausf.addr4)));
......@@ -2035,10 +2083,28 @@ bool amf_n1::authentication_vectors_from_ausf(
print_buffer("amf_n1", "5G AV: hxres*", nc.get()->_5g_av[0].hxresStar, 16);
free_wrapper((void **)&r5gauthdata_hxresstar);
_5g_av["Content-ID"]="_5g_av";
_5g_av["Content-Type"]="JSON";
_5g_av_m["hxresStar"]=to_string(*(nc->_5g_av[0].hxresStar));
_5g_av_m["autn"]=to_string(*(nc->_5g_av[0].autn));
_5g_av_m["rand"]=to_string(*(nc->_5g_av[0].rand));
_5g_av["content"].push_back(_5g_av_m);
udsf_nas_context["blocks"].push_back(_5g_av);
std::map<std::string, LinksValueSchema>::iterator iter;
iter = ueauthenticationctx.getLinks().find("5G_AKA");
if (iter != ueauthenticationctx.getLinks().end()) {
nc.get()->Href = iter->second.getHref();
Href["Content-ID"]="Href";
Href["Content-Type"]="varchar(1024)";
Href["content"] = nc.get()->Href;
udsf_nas_context["blocks"].push_back(Href);
Logger::amf_n1().info("Links is: ", nc.get()->Href);
} else {
Logger::amf_n1().error("Not found 5G_AKA");
......@@ -2048,6 +2114,14 @@ bool amf_n1::authentication_vectors_from_ausf(
// TODO: error handling
return false;
}
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"})}
} ;
amf_n2_inst->curl_http_client_udsf(udsf_url,udsf_nas_context.dump(),"PUT",udsf_response);
return true;
}
......@@ -2094,6 +2168,30 @@ bool amf_n1::_5g_aka_confirmation_from_ausf(std::shared_ptr<nas_context> &nc,
unsigned char *kseaf_hex =
format_string_as_hex(confirmationdataresponse.getKseaf());
memcpy(nc.get()->_5g_av[0].kseaf, kseaf_hex, 32);
nlohmann::json udsf_nas_context;
nlohmann::json udsf_response;
nlohmann::json _5g_av = {};
nlohmann::json _5g_av_m = {};
_5g_av["Content-ID"]="_5g_av";
_5g_av["Content-Type"]="JSON";
_5g_av_m["kseaf"]=to_string(*(nc->_5g_av[0].kseaf));
_5g_av["content"].push_back(_5g_av_m);
udsf_nas_context["blocks"].push_back(_5g_av);
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"})}
} ;
amf_n2_inst->curl_http_client_udsf(udsf_url,udsf_nas_context.dump(),"PUT",udsf_response);
print_buffer("amf_n1", "5G AV: kseaf", nc.get()->_5g_av[0].kseaf, 32);
free_wrapper((void **)&kseaf_hex);
......@@ -2119,6 +2217,12 @@ bool amf_n1::authentication_vectors_generator_in_ausf(
uint8_t inputString[MAX_5GS_AUTH_VECTORS][40];
uint8_t *xresStar[MAX_5GS_AUTH_VECTORS];
uint8_t *rand[MAX_5GS_AUTH_VECTORS];
nlohmann::json udsf_nas_context;
nlohmann::json udsf_response;
nlohmann::json _5g_av = {};
nlohmann::json _5g_av_m = {};
for (int i = 0; i < MAX_5GS_AUTH_VECTORS; i++) {
xresStar[i] = nc.get()->_5g_he_av[i].xresStar;
rand[i] = nc.get()->_5g_he_av[i].rand;
......@@ -2127,19 +2231,46 @@ bool amf_n1::authentication_vectors_generator_in_ausf(
unsigned char sha256Out[Sha256::DIGEST_SIZE];
sha256((unsigned char *)inputString[i], 32, sha256Out);
for (int j = 0; j < 16; j++)
nc.get()->_5g_av[i].hxresStar[j] = (uint8_t)sha256Out[j];
nc.get()->_5g_av[i].hxresStar[j] = (uint8_t)sha256Out[j];
memcpy(nc.get()->_5g_av[i].rand, nc.get()->_5g_he_av[i].rand, 16);
memcpy(nc.get()->_5g_av[i].autn, nc.get()->_5g_he_av[i].autn, 16);
uint8_t kseaf[32];
Authentication_5gaka::derive_kseaf(nc.get()->serving_network,
nc.get()->_5g_he_av[i].kausf, kseaf);
memcpy(nc.get()->_5g_av[i].kseaf, kseaf, 32);
// print_buffer("amf_n1", "5G AV: rand", nc.get()->_5g_av[i].rand, 16);
// print_buffer("amf_n1", "5G AV: autn", nc.get()->_5g_av[i].autn, 16);
// print_buffer("amf_n1", "5G AV: kseaf", nc.get()->_5g_av[i].kseaf, 32);
// print_buffer("amf_n1", "5G AV: hxres*", nc.get()->_5g_av[i].hxresStar,
// 16);
}
_5g_av["Content-ID"]="_5g_av";
_5g_av["Content-Type"]="JSON";
for(int ii=0;ii < MAX_5GS_AUTH_VECTORS;ii++)
{
_5g_av_m["hxresStar"]=to_string(*(nc->_5g_av[ii].hxresStar));
_5g_av_m["kseaf"]=to_string(*(nc->_5g_av[ii].kseaf));
_5g_av["content"].push_back(_5g_av_m);
}
udsf_nas_context["blocks"].push_back(_5g_av);
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"})}
} ;
amf_n2_inst->curl_http_client_udsf(udsf_url,udsf_nas_context.dump(),"PUT",udsf_response);
return true;
}
......@@ -2359,9 +2490,14 @@ void amf_n1::annex_a_4_33501(uint8_t ck[16], uint8_t ik[16], uint8_t *input,
//------------------------------------------------------------------------------
void amf_n1::handle_auth_vector_successful_result(
std::shared_ptr<nas_context> nc) {
nlohmann::json ngKsi;
nlohmann::json udsf_nas_context;
nlohmann::json udsf_response;
nlohmann::json is_auth_vectors_present;
Logger::amf_n1().debug(
"Received security vectors, try to setup security with the UE");
nc.get()->is_auth_vectors_present = true;
ngksi_t ngksi = 0;
if (!nc.get()->security_ctx) {
nc.get()->security_ctx = new nas_secu_ctx();
......@@ -2370,6 +2506,28 @@ void amf_n1::handle_auth_vector_successful_result(
ngksi = (nc.get()->amf_ue_ngap_id + 1) % (NGKSI_MAX_VALUE + 1);
// ensure which vector is available?
nc.get()->ngKsi = ngksi;
/************************hsx add***************************/
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);
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) ;
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***************************/
}
int vindex = nc.get()->security_ctx->vector_pointer;
if (!start_authentication_procedure(nc, vindex, nc.get()->ngKsi)) {
......@@ -2381,11 +2539,19 @@ void amf_n1::handle_auth_vector_successful_result(
} else {
// update mm state -> COMMON-PROCEDURE-INITIATED
}
/************************hsx add***************************/
/************************hsx add***************************/
}
//------------------------------------------------------------------------------
bool amf_n1::start_authentication_procedure(std::shared_ptr<nas_context> nc,
int vindex, uint8_t ngksi) {
nlohmann::json udsf_nas_context;
nlohmann::json udsf_response;
nlohmann::json is_common_procedure_for_authentication_running;
Logger::amf_n1().debug("****Starting authentication procedure****");
if (check_nas_common_procedure_on_going(nc)) {
Logger::amf_n1().error("Existed NAS common procedure on going, reject...");
......@@ -2396,6 +2562,12 @@ bool amf_n1::start_authentication_procedure(std::shared_ptr<nas_context> nc,
}
nc.get()->is_common_procedure_for_authentication_running = true;
is_common_procedure_for_authentication_running["Content-ID"] = "is_common_procedure_for_authentication_running";
is_common_procedure_for_authentication_running["Content-Type"] = "varchar(32)";
is_common_procedure_for_authentication_running["content"] = to_string(nc.get()->is_common_procedure_for_authentication_running);
udsf_nas_context["blocks"].push_back(is_common_procedure_for_authentication_running);
AuthenticationRequest *authReq = new AuthenticationRequest();
authReq->setHeader(PLAIN_5GS_MSG);
authReq->setngKSI(NAS_KEY_SET_IDENTIFIER_NATIVE, ngksi);
......@@ -2428,18 +2600,19 @@ bool amf_n1::start_authentication_procedure(std::shared_ptr<nas_context> nc,
(uint8_t *)bdata(b), blength(b));
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) ;
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_ue_nas_context;
udsf_ue_nas_context["meta"] ["tags"] = {
udsf_nas_context["meta"] ["tags"] = {
{"RECORD_ID",nlohmann::json::array({to_string(nc.get()->amf_ue_ngap_id)})},
{"from_nf",nlohmann::json::array({"AMF_1234"})}
} ;
amf_n2_inst->curl_http_client_udsf(udsf_url,udsf_nas_context.dump(),"PUT",udsf_response);
// 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");
......@@ -2474,6 +2647,9 @@ bool amf_n1::check_nas_common_procedure_on_going(
void amf_n1::authentication_response_handle(uint32_t ran_ue_ngap_id,
long amf_ue_ngap_id,
bstring plain_msg) {
nlohmann::json udsf_nas_context;
nlohmann::json udsf_response;
nlohmann::json is_common_procedure_for_authentication_running;
std::shared_ptr<nas_context> nc;
if (!is_amf_ue_id_2_nas_context(amf_ue_ngap_id)) {
......@@ -2489,6 +2665,12 @@ void amf_n1::authentication_response_handle(uint32_t ran_ue_ngap_id,
nc.get(), amf_ue_ngap_id);
// Stop timer? common procedure finished!
nc.get()->is_common_procedure_for_authentication_running = false;
is_common_procedure_for_authentication_running["Content-ID"] = "is_common_procedure_for_authentication_running";
is_common_procedure_for_authentication_running["Content-Type"] = "varchar(32)";
is_common_procedure_for_authentication_running["content"] = to_string(nc.get()->is_common_procedure_for_authentication_running);
udsf_nas_context["blocks"].push_back(is_common_procedure_for_authentication_running);
// MM state: COMMON-PROCEDURE-INITIATED -> DEREGISTRED
// Decode AUTHENTICATION RESPONSE message
AuthenticationResponse *auth = new AuthenticationResponse();
......@@ -2534,6 +2716,13 @@ void amf_n1::authentication_response_handle(uint32_t ran_ue_ngap_id,
isAuthOk = false;
}
}
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"})}
} ;
amf_n2_inst->curl_http_client_udsf(udsf_url,udsf_nas_context.dump(),"PUT",udsf_response);
}
// If success, start SMC procedure; else if failure, response registration
// reject message with corresponding cause
......@@ -2560,6 +2749,10 @@ void amf_n1::authentication_response_handle(uint32_t ran_ue_ngap_id,
void amf_n1::authentication_failure_handle(uint32_t ran_ue_ngap_id,
long amf_ue_ngap_id,
bstring plain_msg) {
nlohmann::json udsf_nas_context;
nlohmann::json udsf_response;
nlohmann::json auts_json;
nlohmann::json is_common_procedure_for_authentication_running;
std::shared_ptr<nas_context> nc;
if (!is_amf_ue_id_2_nas_context(amf_ue_ngap_id)) {
Logger::amf_n1().error(
......@@ -2571,6 +2764,12 @@ void amf_n1::authentication_failure_handle(uint32_t ran_ue_ngap_id,
}
nc = amf_ue_id_2_nas_context(amf_ue_ngap_id);
nc.get()->is_common_procedure_for_authentication_running = false;
is_common_procedure_for_authentication_running["Content-ID"] = "is_common_procedure_for_authentication_running";
is_common_procedure_for_authentication_running["Content-Type"] = "varchar(32)";
is_common_procedure_for_authentication_running["content"] = to_string(nc.get()->is_common_procedure_for_authentication_running);
udsf_nas_context["blocks"].push_back(is_common_procedure_for_authentication_running);
// 1. decode AUTHENTICATION FAILURE message
AuthenticationFailure *authFail = new AuthenticationFailure();
authFail->decodefrombuffer(NULL, (uint8_t *)bdata(plain_msg),
......@@ -2592,6 +2791,22 @@ void amf_n1::authentication_failure_handle(uint32_t ran_ue_ngap_id,
"IE Authentication Failure Parameter (auts) not received");
}
nc.get()->auts = auts;
/*********************************hsx add**********************************/
string auts_m;
octet_stream_2_hex_stream((uint8_t*) bdata(nc.get()->auts), blength(nc.get()->auts), auts_m);
auts_json["Content-ID"] = "auts";
auts_json["Content-Type"] = "JSON";
auts_json["content"] = auts_m;
udsf_nas_context["blocks"].push_back(auts_json);
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"})}
} ;
amf_n2_inst->curl_http_client_udsf(udsf_url,udsf_nas_context.dump(),"PUT",udsf_response);
/*********************************hsx add**********************************/
printf("Received auts: 0x ");
for (int i = 0; i < blength(auts); i++)
printf("%x ", ((uint8_t *)bdata(auts))[i]);
......@@ -2612,8 +2827,22 @@ void amf_n1::authentication_failure_handle(uint32_t ran_ue_ngap_id,
//------------------------------------------------------------------------------
bool amf_n1::start_security_mode_control_procedure(
std::shared_ptr<nas_context> nc) {
nlohmann::json udsf_nas_context;
nlohmann::json udsf_response;
nlohmann::json is_current_security_available;
nlohmann::json is_common_procedure_for_security_mode_control_running;
Logger::amf_n1().debug("Start Security Mode Control procedure");
nc.get()->is_common_procedure_for_security_mode_control_running = true;
is_common_procedure_for_security_mode_control_running["Content-ID"] = "is_common_procedure_for_security_mode_control_running";
is_common_procedure_for_security_mode_control_running["Content-Type"] = "varchar(32)";
is_common_procedure_for_security_mode_control_running["content"] = to_string(nc.get()->is_common_procedure_for_security_mode_control_running);
udsf_nas_context["blocks"].push_back(is_common_procedure_for_security_mode_control_running);
bool security_context_is_new = false;
uint8_t amf_nea = EA0_5G;
uint8_t amf_nia = IA0_5G;
......@@ -2656,6 +2885,11 @@ bool amf_n1::start_security_mode_control_procedure(
nc.get()->kamf[secu_ctx->vector_pointer], secu_ctx->knas_enc);
security_context_is_new = true;
nc.get()->is_current_security_available = true;
is_current_security_available["Content-ID"] = "is_current_security_available";
is_current_security_available["Content-Type"] = "varchar(32)";
is_current_security_available ["content"] = to_string( nc.get()->is_current_security_available);
udsf_nas_context["blocks"].push_back(is_current_security_available);
}
SecurityModeCommand *smc = new SecurityModeCommand();
......@@ -2673,6 +2907,15 @@ bool amf_n1::start_security_mode_control_procedure(
Logger::amf_n1().error("smc->ie_ue_security_capability is NULL");
}
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"})}
} ;
amf_n2_inst->curl_http_client_udsf(udsf_url,udsf_nas_context.dump(),"PUT",udsf_response);
smc->setIMEISV_Request(0xe1);
smc->setAdditional_5G_Security_Information(true, false);
uint8_t buffer[1024];
......@@ -2844,6 +3087,14 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id,
set_guti_2_nas_context(guti, nc);
nc.get()->is_common_procedure_for_security_mode_control_running = false;
nlohmann::json is_common_procedure_for_security_mode_control_running;
is_common_procedure_for_security_mode_control_running["Content-ID"] = "is_common_procedure_for_security_mode_control_running";
is_common_procedure_for_security_mode_control_running["Content-Type"] = "varchar(32)";
is_common_procedure_for_security_mode_control_running["content"] = to_string(nc.get()->is_common_procedure_for_security_mode_control_running);
udsf_nas_context["blocks"].push_back(is_common_procedure_for_security_mode_control_running);
nas_secu_ctx *secu = nc.get()->security_ctx;
// protect nas message
bstring protectedNas;
......@@ -3503,8 +3754,8 @@ 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;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************stateless
pdu_session_context *psc1 = new pdu_session_context();
nlohmann::json udsf_response;
......@@ -3514,8 +3765,8 @@ void amf_n1::run_mobility_registration_update_procedure(
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);
psc.get()->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)) {
......@@ -3611,19 +3862,20 @@ 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;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************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);
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->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)) {
......@@ -3715,19 +3967,20 @@ 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;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************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);
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->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)) {
......@@ -3760,6 +4013,25 @@ void amf_n1::set_5gmm_state(std::shared_ptr<nas_context> nc,
_5gmm_state_e2str[state].c_str());
std::unique_lock lock(m_nas_context);
nc.get()->_5gmm_state = state;
/*****************************hsx add****************************/
nlohmann::json _5gmm_state;
nlohmann::json udsf_response;
nlohmann::json udsf_nas_context;
_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);
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"})}
} ;
amf_n2_inst->curl_http_client_udsf(udsf_url,udsf_nas_context.dump(),"PUT",udsf_response);
/*****************************hsx add****************************/
// TODO:
}
......
......@@ -160,23 +160,25 @@ void amf_n11::handle_itti_message(
"Send PDU Session Update SM Context Request to SMF (SUPI %s, PDU Session "
"ID %d)",
supi.c_str(), itti_msg.pdu_session_id);
std::shared_ptr<pdu_session_context> psc;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************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)){
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;
return ;
}
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->pdu_session_context_from_json(udsf_response);
//psc = std::shared_ptr<pdu_session_context>(psc1);
}
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);
// psc = supi_to_pdu_ctx(supi);
// } else {
// Logger::amf_n11().error(
// "Could not find psu_session_context with SUPI %s, Failed",
......@@ -194,8 +196,9 @@ void amf_n11::handle_itti_message(
}
std::string smf_ip_addr, remote_uri;
std::shared_ptr<pdu_session_context> context;
context = supi_to_pdu_ctx(supi);
std::shared_ptr<pdu_session_context> context = std::shared_ptr<pdu_session_context>(new pdu_session_context());
context.get()->pdu_session_context_from_json(udsf_response);
//context = supi_to_pdu_ctx(supi);
// remove http port from the URI if existed
std::size_t found_port = smf_addr.find(":");
if (found_port != std::string::npos)
......@@ -230,19 +233,22 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) {
nc = amf_n1_inst->amf_ue_id_2_nas_context(smf.amf_ue_ngap_id);
std::string supi = "imsi-" + nc.get()->imsi;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> 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;
psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
}
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);
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->pdu_session_context_from_json(udsf_response);
//psc = std::shared_ptr<pdu_session_context>(psc1);
}
//***************************stateless
// if (is_supi_to_pdu_ctx(supi)) {
......@@ -398,34 +404,33 @@ void amf_n11::handle_pdu_session_initial_request(
{{"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 }}
{{"Content-ID", "n2sm"},{"Content-Type", "varchar(1024)"},{"content", " "}},
{{"Content-ID", "isn2sm_avaliable"},{"Content-Type", "varchar(32)"},{"content"," "}},
{{"Content-ID", "n1sm"},{"Content-Type", "varchar(1024)"},{"content", " "}},
{{"Content-ID", "isn1sm_avaliable"},{"Content-Type", "varchar(32)"},{"content", " "}},
{{"Content-ID", "remote_smf_addr"},{"Content-Type", "varchar(32)"},{"content", " "}},
{{"Content-ID", "smf_available"},{"Content-Type", "varchar(32)"},{"content", ""}},
{{"Content-ID", "location"},{"Content-Type", "varchar(32)"},{"content",""}},
{{"Content-ID", "smf_context_location"},{"Content-Type", "varchar(1024)"},{"content","" }}
});
nlohmann::json snssai = {};
nlohmann::json plmn = {};
nlohmann::json udsf_response;
snssai["Content-ID"] ="snssai";
snssai["Content-Type"] = "varchar(32)" ;
snssai["Content-Type"] = "JSON" ;
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-Type"] = "JSON" ;
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);
amf_n2_inst->curl_http_client_udsf(udsf_put_url,udsf_pdu_session_context.dump(),"PUT",udsf_response);
/************************hxs add****************/
......@@ -478,20 +483,21 @@ void amf_n11::handle_pdu_session_initial_request(
//------------------------------------------------------------------------------
void amf_n11::handle_itti_message(
itti_nsmf_pdusession_release_sm_context& itti_msg) {
std::shared_ptr<pdu_session_context> psc ;
//std::shared_ptr<pdu_session_context> psc ;
//= supi_to_pdu_ctx(itti_msg.supi);
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************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);
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->pdu_session_context_from_json(udsf_response);
//psc = std::shared_ptr<pdu_session_context>(psc1);
}
//***************************stateless
string smf_addr;
......@@ -590,7 +596,7 @@ void amf_n11::curl_http_client(
uint8_t number_parts = 0;
mime_parser parser = {};
std::string body;
std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************stateless
pdu_session_context *psc1 = new pdu_session_context();
......@@ -601,8 +607,9 @@ void amf_n11::curl_http_client(
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);
//psc1->pdu_session_context_from_json(udsf_response);
//psc = std::shared_ptr<pdu_session_context>(psc1);
psc.get()->pdu_session_context_from_json(udsf_response);
//***************************stateless
// if (is_supi_to_pdu_ctx(supi)) {
......@@ -694,9 +701,10 @@ void amf_n11::curl_http_client(
// establishment request)
return;
}
printf("-----------------%d-----------response.size()\n",response.size());
if (response.size() > 0) {
number_parts = multipart_parser(response, json_data_response, n1sm, n2sm);
printf("-----------------%d-----------number_parts",number_parts);
}
if ((static_cast<http_response_codes_e>(httpCode) !=
......@@ -746,18 +754,37 @@ void amf_n11::curl_http_client(
std::size_t location_pos = header_response.find("Location");
if (location_pos != std::string::npos) {
printf("----------------------------if location_pos != std::string::npos\n");
std::size_t crlf_pos = header_response.find(CRLF, location_pos);
if (crlf_pos != std::string::npos) {
printf("----------------------------crlf_pos != std::string::npos\n");
std::string location = header_response.substr(
location_pos + 10, crlf_pos - (location_pos + 10));
Logger::amf_n11().info(
"Location of the created SMF context: %s", location.c_str());
psc.get()->smf_context_location = location;
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;
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(1024)"},{"content",psc.get()->smf_context_location}},
});
std::string json_part = udsf_put_pdu_session_context.dump();
while(!(amf_n2_inst->curl_http_client_udsf(udsf_put_url,json_part,"PUT",udsf_response)));
}
}
// Transfer N1/N2 to gNB/UE if available
if (number_parts > 1) {
printf("-----------------%d-----------number_parts >>>>> 1");
try {
response_data = nlohmann::json::parse(json_data_response);
} catch (nlohmann::json::exception& e) {
......@@ -791,18 +818,7 @@ 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);
......
......@@ -461,7 +461,7 @@ void amf_n2::handle_itti_message(itti_ng_setup_request& itti_msg) {
{{"Content-ID", "ng_state"},{"Content-Type", "varchar(32)"},{"content", to_string(gc.get()->ng_state )}},
{{"Content-ID", "globalRanNodeId"},{"Content-Type", "varchar(32)"},{"content", to_string( gc->globalRanNodeId)}},
{{"Content-ID", "gnb_name"},{"Content-Type", "varchar(32)"},{"content", gc->gnb_name}},
{{"Content-ID", "ue_radio_cap_ind"},{"Content-Type", "varchar(32)"},{"content", ue_radio_cap_ind}},
{{"Content-ID", "ue_radio_cap_ind"},{"Content-Type", "varchar(1024)"},{"content", ue_radio_cap_ind}},
{{"Content-ID", "mcc"},{"Content-Type", "varchar(32)"},{"content", gnbItem.mcc}},
{{"Content-ID", "mnc"},{"Content-Type", "varchar(32)"},{"content", gnbItem.mnc}},
{{"Content-ID", "tac"},{"Content-Type", "varchar(32)"},{"content", to_string(gnbItem.tac)}}
......@@ -544,7 +544,7 @@ bool amf_n2::curl_http_client_udsf(std::string remoteUrl,std::string jsonData,st
udsf_response = nlohmann::json::parse(response);
//Logger::amf_n2().debug("Get response with jsonData: %s", response_data.dump().c_str());
} catch (nlohmann::json::exception &e) {
Logger::amf_n11().warn("Could not get Json content from the response");
Logger::amf_n11().warn("Could not get Json content from usdf the response");
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
......@@ -999,11 +999,13 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
//bstring n2sm = itti_msg.n2sm;
if (blength(itti_msg.n2sm) != 0) {
Logger::amf_n2().debug("*** test into itti_msg.n2sm ***");
item.pduSessionResourceSetupRequestTransfer.buf =
(uint8_t*) bdata(itti_msg.n2sm);
Logger::amf_n2().debug("*** test into item.pduSessionResourceSetupRequestTransfer.buf ***");
item.pduSessionResourceSetupRequestTransfer.size =
blength(itti_msg.n2sm);
item.pduSessionResourceSetupRequestTransfer.buf = (uint8_t*) bdata(itti_msg.n2sm);
Logger::amf_n2().debug("*** test into item.pduSessionResourceSetupRequestTransfer.buf ***");
string ssaa;
octet_stream_2_hex_stream((uint8_t*) bdata(itti_msg.n2sm), blength(itti_msg.n2sm), ssaa);
printf("----service accept n2sm ----------------(%s)\n",ssaa.c_str());
item.pduSessionResourceSetupRequestTransfer.size = blength(itti_msg.n2sm);
} else {
Logger::amf_n2().error("n2sm empty!");
}
......@@ -1093,19 +1095,20 @@ 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;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************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);
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->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))
......@@ -1347,10 +1350,9 @@ void amf_n2::handle_itti_message(
{"from_nf_ID",nlohmann::json::array({"AMF_1234"})}
} ;
udsf_gnb_update_context["blocks"] = nlohmann::json::array({
{{"Content-ID", "ue_radio_cap_ind"},{"Content-Type", "varchar(32)"},{"content", ue_radio_cap_ind}}
{{"Content-ID", "ue_radio_cap_ind"},{"Content-Type", "varchar(1024)"},{"content", ue_radio_cap_ind}}
});
std::string json_part = udsf_gnb_update_context.dump();
amf_n2_inst->curl_http_client_udsf(udsf_update_url,json_part,"PUT",udsf_response);
amf_n2_inst->curl_http_client_udsf(udsf_update_url,udsf_gnb_update_context.dump(),"PUT",udsf_response);
}
......@@ -1495,21 +1497,22 @@ 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;
//std::shared_ptr<pdu_session_context> psc;
// =
// amf_n11_inst->supi_to_pdu_ctx(supi);
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************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);
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->pdu_session_context_from_json(udsf_response);
// psc = std::shared_ptr<pdu_session_context>(psc1);
}
//***************************stateless
std::vector<PDUSessionResourceSetupRequestItem_t> list;
......
......@@ -30,8 +30,11 @@
#include <nlohmann/json.hpp>
#include "logger.hpp"
#include "Record.h"
#include "conversions.hpp"
using namespace std;
using namespace oai::amf::model;
extern void msg_str_2_msg_hex(std::string msg, bstring& b);
bool get_value_string(const nlohmann::json &j, const string & nm, string &value){
Record record;
......@@ -181,6 +184,34 @@ sctp_stream_id_t gnb_context::gnb_context_instreams_from_json(nlohmann::json j)
}
Logger::amf_server().error("get_value from json is error");
}
void gnb_context::gnb_context_ue_radio_cap_ind_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "ue_radio_cap_ind")
{
string s = it_block->at("content");
//msg_str_2_msg_hex(s.substr(0, s.length()),ue_radio_cap_ind);
unsigned int msg_len = s.length();
char* data = (char*) malloc(msg_len + 1);
memset(data, 0, msg_len + 1);
memcpy((void*) data, (void*) s.c_str(), msg_len);
//printf("data: %s\n", data);
uint8_t* msg_hex = (uint8_t*) malloc(msg_len / 2 + 1);
conv::ascii_to_hex(msg_hex, (const char*) data);
ue_radio_cap_ind = blk2bstr(msg_hex, (msg_len / 2));
return ;
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value n2sm from json is error");
}
bool gnb_context::gnb_context_from_json(nlohmann::json j)
{
//std::shared_ptr<gnb_context> gc1;
......@@ -190,7 +221,7 @@ bool gnb_context::gnb_context_from_json(nlohmann::json j)
ng_state = amf_ng_gnb_state_s(gnb_context_ng_state_from_json(j));
next_sctp_stream = gnb_context_next_sctp_stream_from_json(j);
next_sctp_stream = gnb_context_instreams_from_json(j);
gnb_context_ue_radio_cap_ind_from_json(j);
// printf("gnbname-%s\n",gnb_name.c_str());
// printf("globalgnbid-%d\n",globalRanNodeId);
// printf("next stream-%d\n",next_sctp_stream);
......
......@@ -48,6 +48,7 @@ using namespace std;
enum amf_ng_gnb_state_s { NGAP_INIT, NGAP_RESETING, NGAP_READY, NGAP_SHUTDOWN };
class gnb_context {
public:
void gnb_context_ue_radio_cap_ind_from_json(nlohmann::json j);
uint32_t gnb_context_sctp_assoc_id_from_json(nlohmann::json j);
long gnb_context_globalRanNodeId_from_json(nlohmann::json j);
std::string gnb_context_gnb_name_from_json(nlohmann::json j);
......
......@@ -27,6 +27,15 @@
*/
#include "pdu_session_context.hpp"
#include <nlohmann/json.hpp>
#include "logger.hpp"
#include "Record.h"
#include "conversions.hpp"
using namespace std;
using namespace oai::amf::model;
extern void msg_str_2_msg_hex(std::string msg, bstring& b);
extern void octet_stream_2_hex_stream(uint8_t *buf, int len, std::string &out);
//------------------------------------------------------------------------------
pdu_session_context::pdu_session_context() {
......@@ -36,15 +45,386 @@ pdu_session_context::pdu_session_context() {
}
//------------------------------------------------------------------------------
pdu_session_context::~pdu_session_context() {}
pdu_session_context::~pdu_session_context() {
// bdestroy(n1sm);
// bdestroy(n2sm);
// if(!n2sm)
// printf("null");
// else
// printf("11");
}
uint32_t pdu_session_context::pdu_session_context_ran_ue_ngap_id_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "ran_ue_ngap_id")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value ran ue ngap id from json is error");
}
long pdu_session_context::pdu_session_context_amf_ue_ngap_id_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "amf_ue_ngap_id")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value maf ue ngap id from json is error");
}
uint8_t pdu_session_context::pdu_session_context_req_type_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "req_type")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value req type from json is error");
}
uint8_t pdu_session_context::pdu_session_context_pdu_session_id_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "pdu_session_id")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value pdu session id from json is error");
}
bool pdu_session_context::pdu_session_context_isn2sm_avaliable_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "isn2sm_avaliable")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value n2sm avaliable from json is error");
}
bool pdu_session_context::pdu_session_context_isn1sm_avaliable_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "isn1sm_avaliable")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value n1sm avaliable from json is error");
}
std::string pdu_session_context::pdu_session_context_dnn_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "dnn")
{
string s = it_block->at("content");
return s;
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value dnn from json is error");
}
std::string pdu_session_context::pdu_session_context_remote_smf_addr_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "remote_smf_addr")
{
string s = it_block->at("content");
return s;
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value remot smf addr from json is error");
}
bool pdu_session_context::pdu_session_context_smf_available_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "smf_available")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value smf acailablefrom json is error");
}
std::string pdu_session_context::pdu_session_context_location_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "location")
{
string s = it_block->at("content");
return s;
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value location from json is error");
}
std::string pdu_session_context::pdu_session_context_smf_context_location_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "smf_context_location")
{
string s = it_block->at("content");
return s;
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value smf contexxt location from json is error");
}
void pdu_session_context::pdu_session_context_snssai_from_json(nlohmann::json j,snssai_t &snssai_json)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "snssai")
{
nlohmann::json s;
string j;
s = it_block->at("content");
snssai_json.sD = s.at("sD") ;
j = s.at("sST");
snssai_json.sST = atoi(j.c_str());
//printf("ue_context_tai_from_json %s---mcc %s---mnc %s--\n",s.dump().c_str(),tai_json.mcc,tai_json.mnc);
return ;
// s = nlohmann::json::parse(j);
// s.at("mnc").get_to(tai_json.mnc);
// s.at("mcc").get_to(tai_json.mcc);
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value snassai from json is error");
}
void pdu_session_context::pdu_session_context_plmn_from_json(nlohmann::json j,plmn_t &plmn_json)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "plmn")
{
nlohmann::json s;
string j;
s = it_block->at("content");
plmn_json.mcc = s.at("mcc");
plmn_json.mnc = s.at("mnc") ;
j = s.at("tac");
plmn_json.tac = atoi(j.c_str());
//printf("pdu_session_context_plmn_from_json %s---mcc %s---mnc %s--\n",s.dump().c_str(),plmn_json.mcc,plmn_json.mnc);
return ;
// s = nlohmann::json::parse(j);
// s.at("mnc").get_to(tai_json.mnc);
// s.at("mcc").get_to(tai_json.mcc);
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value plmn from json is error");
}
void pdu_session_context::pdu_session_context_n1sm_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "n1sm")
{
string s = it_block->at("content");
// msg_str_2_msg_hex(s.substr(0, s.length()),n1sm);
unsigned int msg_len = s.length();
char* data = (char*) malloc(msg_len + 1);
memset(data, 0, msg_len + 1);
memcpy((void*) data, (void*) s.c_str(), msg_len);
//printf("data: %s\n", data);
uint8_t* msg_hex = (uint8_t*) malloc(msg_len / 2 + 1);
conv::ascii_to_hex(msg_hex, (const char*) data);
n1sm = blk2bstr(msg_hex, (msg_len / 2));
return ;
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value n1sm from json is error");
}
void pdu_session_context::pdu_session_context_n2sm_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "n2sm")
{
string s = it_block->at("content");
// msg_str_2_msg_hex(s.substr(0, s.length()),n2sm);
//printf("----string n2sm pdu _session----------------(%s)\n",s.c_str());
// msg_str_2_msg_hex(s.c_str(), n2sm);
unsigned int msg_len = s.length();
char* data = (char*) malloc(msg_len + 1);
memset(data, 0, msg_len + 1);
memcpy((void*) data, (void*) s.c_str(), msg_len);
//printf("data: %s\n", data);
uint8_t* msg_hex = (uint8_t*) malloc(msg_len / 2 + 1);
conv::ascii_to_hex(msg_hex, (const char*) data);
n2sm = blk2bstr(msg_hex, (msg_len / 2));
// string ssaa;
// octet_stream_2_hex_stream((uint8_t*) bdata(n2sm), blength(n2sm), ssaa);
// printf("-----bstring n2sm pdu _session----------------(%s)\n",ssaa.c_str());
return ;
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value n2sm from json is error");
}
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);
pdu_session_context_n1sm_from_json(j);
pdu_session_context_n2sm_from_json(j);
ran_ue_ngap_id = pdu_session_context_ran_ue_ngap_id_from_json(j);
amf_ue_ngap_id = pdu_session_context_amf_ue_ngap_id_from_json(j);
req_type = pdu_session_context_req_type_from_json(j);
pdu_session_id = pdu_session_context_pdu_session_id_from_json(j);
isn2sm_avaliable = pdu_session_context_isn2sm_avaliable_from_json(j);
isn1sm_avaliable = pdu_session_context_isn1sm_avaliable_from_json(j);
dnn = pdu_session_context_dnn_from_json(j);
//remote_smf_addr[0] = pdu_session_context_remote_smf_addr_from_json(j);
smf_available = pdu_session_context_smf_available_from_json(j);
location = pdu_session_context_location_from_json(j);
pdu_session_context_snssai_from_json(j,snssai);
pdu_session_context_plmn_from_json(j,plmn);
smf_context_location = pdu_session_context_smf_context_location_from_json(j);
return true;
}
\ No newline at end of file
......@@ -37,7 +37,28 @@ class pdu_session_context {
public:
pdu_session_context();
~pdu_session_context();
void pdu_session_context_n1sm_from_json(nlohmann::json j);
void pdu_session_context_n2sm_from_json(nlohmann::json j);
bool pdu_session_context_from_json(nlohmann::json j);
uint32_t pdu_session_context_ran_ue_ngap_id_from_json(nlohmann::json j);
long pdu_session_context_amf_ue_ngap_id_from_json(nlohmann::json j);
uint8_t pdu_session_context_req_type_from_json(nlohmann::json j);
uint8_t pdu_session_context_pdu_session_id_from_json(nlohmann::json j);
bool pdu_session_context_isn2sm_avaliable_from_json(nlohmann::json j);
bool pdu_session_context_isn1sm_avaliable_from_json(nlohmann::json j);
std::string pdu_session_context_dnn_from_json(nlohmann::json j);
std::string pdu_session_context_remote_smf_addr_from_json(nlohmann::json j);
bool pdu_session_context_smf_available_from_json(nlohmann::json j);
std::string pdu_session_context_location_from_json(nlohmann::json j);
void pdu_session_context_snssai_from_json(nlohmann::json j,snssai_t &snssai_json);
void pdu_session_context_plmn_from_json(nlohmann::json j,plmn_t &plmn_json);
std::string pdu_session_context_smf_context_location_from_json(nlohmann::json j);
uint32_t ran_ue_ngap_id;
long amf_ue_ngap_id;
uint8_t req_type;
......@@ -53,7 +74,6 @@ class pdu_session_context {
snssai_t snssai;
plmn_t plmn;
std::string smf_context_location;
//15
};
#endif
......@@ -52,7 +52,7 @@ uint32_t ue_context::ue_context_ran_ue_ngap_id_from_json(nlohmann::json j)
}
Logger::amf_server().error("get_value from json is error");
}
void ue_context::ue_context_tai_from_json(nlohmann::json j,Tai_t &tai_json)
void ue_context::ue_context_tai_from_json(nlohmann::json j,Tai_t &Tai_json)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
......@@ -67,10 +67,10 @@ void ue_context::ue_context_tai_from_json(nlohmann::json j,Tai_t &tai_json)
string j;
s = it_block->at("content");
tai_json.mcc = s.at("mcc");
tai_json.mnc = s.at("mnc") ;
Tai_json.mcc = s.at("mcc");
Tai_json.mnc = s.at("mnc") ;
j = s.at("tac");
tai_json.tac = atoi(j.c_str());
Tai_json.tac = atoi(j.c_str());
//printf("ue_context_tai_from_json %s---mcc %s---mnc %s--\n",s.dump().c_str(),tai_json.mcc,tai_json.mnc);
return ;
// s = nlohmann::json::parse(j);
......@@ -82,6 +82,9 @@ void ue_context::ue_context_tai_from_json(nlohmann::json j,Tai_t &tai_json)
}
Logger::amf_server().error("get_value from json is error");
}
bool ue_context::ue_context_from_json(nlohmann::json j)
{
//std::shared_ptr<gnb_context> gc1;
......
......@@ -386,8 +386,8 @@ int ngap_amf_handle_pdu_session_resource_setup_response(
std::shared_ptr<nas_context> nct =
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;
// std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************stateless
pdu_session_context *psc1 = new pdu_session_context();
nlohmann::json udsf_response;
......@@ -396,9 +396,12 @@ int ngap_amf_handle_pdu_session_resource_setup_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);
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->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)) {
......
......@@ -87,19 +87,20 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
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;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************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);
else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
psc.get()->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)) {
......@@ -108,7 +109,6 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
// Logger::amf_server().error(
// "Cannot get pdu_session_context with SUPI (%s)", supi.c_str());
// }
bstring n1sm;
msg_str_2_msg_hex(
n1sm_str.substr(0, n1sm_str.length()),
......@@ -126,6 +126,7 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
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;
......@@ -134,9 +135,9 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
{"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", "n2sm"},{"Content-Type", "varchar(1024)"},{"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", "n1sm"},{"Content-Type", "varchar(1024)"},{"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();
......
......@@ -32,16 +32,16 @@ void TestSignallingApiImpl::
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;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************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);
psc.get()->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);
......@@ -97,16 +97,16 @@ void TestSignallingApiImpl::test_signalling_paging(
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;
//std::shared_ptr<pdu_session_context> psc;
std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
//***************************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);
psc.get()->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);
......
......@@ -8,7 +8,6 @@ uint8_t multipart_parser(
// simple parser
mime_parser sp = {};
sp.parse(input);
std::vector<mime_part> parts = {};
sp.get_mime_parts(parts);
uint8_t size = parts.size();
......
......@@ -34,7 +34,9 @@ bool mime_parser::parse(const std::string& str) {
// find boundary
std::size_t content_type_pos = str.find("Content-Type"); // first part
if ((content_type_pos <= 4) or (content_type_pos == std::string::npos))
{
return false;
}
std::string boundary_str =
str.substr(2, content_type_pos - 4); // 2 for -- and 2 for CRLF
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment