Commit b7ad7e84 authored by liuyu's avatar liuyu

cpe can ping amf can jixufuwu

parent b621e54d
......@@ -331,7 +331,9 @@ void amf_app::handle_itti_message(
}
/********************** hxs add *******************************/
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + ue_context_key ;
std::string record_id = "RECORD_ID=\'" + ue_context_key + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + record_id ;
nlohmann::json udsf_ue_context;
nlohmann::json cgi;
cgi["Content-ID"] = "cgi";
......@@ -422,7 +424,8 @@ bool amf_app::generate_5g_guti(
// uc = ran_amf_id_2_ue_context(ue_context_key);
ue_context *uc1 = new ue_context();
nlohmann::json udsf_response;
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + ue_context_key ;
std::string record_id = "RECORD_ID=\'" + ue_context_key + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + record_id;
if(!amf_n2_inst->curl_http_client_udsf(udsf_url,"","GET",udsf_response)){
Logger::amf_n2().error("No existing gNG context with assoc_id");
return false;
......
This diff is collapsed.
......@@ -91,6 +91,12 @@ class amf_n1 {
void set_guti_2_nas_context(
const std::string& guti, std::shared_ptr<nas_context> nc);
bool is_guti_2_nas_context_in_udsf(const std::string& guti);
std::shared_ptr<nas_context> guti_2_nas_context_in_udsf(const std::string& guti) const;
bool is_amf_ue_id_2_nas_context_in_udsf(const long& amf_ue_ngap_id) const;
std::shared_ptr<nas_context> amf_ue_id_2_nas_context_in_udsf(const long& amf_ue_ngap_id) const;
mutable std::shared_mutex m_amfueid2nas_context;
bool is_amf_ue_id_2_nas_context(const long& amf_ue_ngap_id) const;
std::shared_ptr<nas_context> amf_ue_id_2_nas_context(
......
......@@ -155,17 +155,20 @@ void amf_n11::handle_itti_message(
//------------------------------------------------------------------------------
void amf_n11::handle_itti_message(
itti_nsmf_pdusession_update_sm_context& itti_msg) {
std::string supi = pduid2supi.at(itti_msg.pdu_session_id);
Logger::amf_n11().debug(
"Send PDU Session Update SM Context Request to SMF (SUPI %s, PDU Session "
"ID %d)",
supi.c_str(), itti_msg.pdu_session_id);
//std::string supi = pduid2supi.at(itti_msg.pdu_session_id);
// Logger::amf_n11().debug(
// "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>(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 ;
std::string record_id = "pdu_session_id=\'" + to_string(itti_msg.pdu_session_id) + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id ;
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 ;
......@@ -173,8 +176,18 @@ void amf_n11::handle_itti_message(
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);
}
// std::shared_ptr<nas_context> nc = std::shared_ptr<nas_context>(new nas_context());
// if (amf_n1_inst->is_amf_ue_id_2_nas_context_in_udsf(psc.get()->amf_ue_ngap_id))
// nc = amf_n1_inst->amf_ue_id_2_nas_context_in_udsf(psc.get()->amf_ue_ngap_id);
std::string supi =psc.get()->supi;
Logger::amf_n11().debug(
"Send PDU Session Update SM Context Request to SMF (SUPI %s, PDU Session "
"ID %d)",
supi.c_str(), itti_msg.pdu_session_id);
//***************************stateless
// if (is_supi_to_pdu_ctx(supi)) {
......@@ -238,7 +251,11 @@ void amf_n11::handle_itti_message(itti_smf_services_consumer& smf) {
//***************************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 ;
std::string record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id;
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 ");
psc = std::shared_ptr<pdu_session_context>(new pdu_session_context());
......@@ -391,7 +408,9 @@ void amf_n11::handle_pdu_session_initial_request(
/***************************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 ;
std::string record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_put_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id ;
nlohmann::json udsf_pdu_session_context;
// nlohmann::json udsf_response;
udsf_pdu_session_context["meta"] ["tags"] = {
......@@ -403,6 +422,7 @@ void amf_n11::handle_pdu_session_initial_request(
{{"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", "supi"},{"Content-Type", "varchar(32)"},{"content", supi}},
{{"Content-ID", "dnn"},{"Content-Type", "varchar(32)"},{"content", psc.get()->dnn}},
{{"Content-ID", "n2sm"},{"Content-Type", "varchar(1024)"},{"content", " "}},
{{"Content-ID", "isn2sm_avaliable"},{"Content-Type", "varchar(32)"},{"content"," "}},
......@@ -411,7 +431,7 @@ void amf_n11::handle_pdu_session_initial_request(
{{"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","" }}
{{"Content-ID", "smf_context_location"},{"Content-Type", "varchar(128)"},{"content","" }}
});
nlohmann::json snssai = {};
nlohmann::json plmn = {};
......@@ -489,7 +509,9 @@ void amf_n11::handle_itti_message(
//***************************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 ;
std::string record_id = "RECORD_ID=\'" +itti_msg.supi + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id ;
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 ");
}
......@@ -599,9 +621,9 @@ void amf_n11::curl_http_client(
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 ;
std::string record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id;
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;
......@@ -701,10 +723,8 @@ 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) !=
......@@ -754,27 +774,24 @@ 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 ;
std::string record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_put_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id ;
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}},
{{"Content-ID", "smf_context_location"},{"Content-Type", "varchar(128)"},{"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)));
......@@ -784,7 +801,6 @@ void amf_n11::curl_http_client(
// 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) {
......
This diff is collapsed.
This diff is collapsed.
......@@ -65,12 +65,65 @@ class nas_context {
public:
nas_context();
~nas_context();
//
//ctx_avaliability_ind = true;
// nc.get()->is_imsi_present = true;
// nc.get()->imsi = supi;
//nc.get()->imsi = supi;
bool nas_context_from_json(nlohmann::json j);
uint32_t nas_context_ran_ue_ngap_id_from_json(nlohmann::json j);
long nas_context_amf_ue_ngap_id_from_json(nlohmann::json j);
bool nas_context_ctx_avaliability_ind_from_json(nlohmann::json j);
bool nas_context_is_stacs_available_from_json(nlohmann::json j);
long nas_context_amf_ue_ngap_id_from_json(nlohmann::json j);
uint32_t nas_context_ran_ue_ngap_id_from_json(nlohmann::json j);
std::string nas_context_nas_status_from_json(nlohmann::json j);
int nas_context__5gmm_state_from_json(nlohmann::json j);
uint8_t nas_context_registration_type_from_json(nlohmann::json j);
bool nas_context_follow_on_req_pending_ind_from_json(nlohmann::json j);
uint8_t nas_context_ngKsi_from_json(nlohmann::json j);
std::string nas_context_imsi_from_json(nlohmann::json j); //ok
// uint8_t mmCapability;
// uint8_t ueSecurityCaplen;
// uint8_t ueSecurityCapEnc;
// uint8_t ueSecurityCapInt;
// uint8_t ueSecurityCapEEnc;
// uint8_t ueSecurityCapEInt;
//void nas_context_requestedNssai_from_json(nlohmann::json j);
std::string nas_context_serving_network_from_json(nlohmann::json j);
void nas_context_auts_from_json(nlohmann::json j);
bool nas_context_is_specific_procedure_for_registration_running_from_json(nlohmann::json j);
bool nas_context_is_specific_procedure_for_deregistration_running_from_json(nlohmann::json j);
bool nas_context_is_specific_procedure_for_eCell_inactivity_running_from_json(nlohmann::json j);
bool nas_context_is_common_procedure_for_authentication_running_from_json(nlohmann::json j);
bool nas_context_is_common_procedure_for_identification_running_from_json(nlohmann::json j);
bool nas_context_is_common_procedure_for_security_mode_control_running_from_json(nlohmann::json j);
bool nas_context_is_common_procedure_for_nas_transport_running_from_json(nlohmann::json j);
void nas_context__vector_from_json(nlohmann::json j);
void nas_context__5g_he_av_from_json(nlohmann::json j);
void nas_context__5g_av_from_json(nlohmann::json j);
std::string nas_context_Href_from_json(nlohmann::json j);
void nas_context_kamf_from_json(nlohmann::json j);
void nas_context__security_from_json(nlohmann::json j);
void nas_context_security_ctx_from_json(nlohmann::json j);
bool nas_context_is_current_security_available_from_json(nlohmann::json j);
int nas_context_registration_attempt_counter_from_json(nlohmann::json j);
bool nas_context_is_imsi_present_from_json(nlohmann::json j);
bool nas_context_is_5g_guti_present_from_json(nlohmann::json j);
bool nas_context_is_auth_vectors_present_from_json(nlohmann::json j);
bool nas_context_to_be_register_by_new_suci_from_json(nlohmann::json j);
std::string nas_context_guti_from_json(nlohmann::json j);
bool ctx_avaliability_ind;
bool is_stacs_available;
long amf_ue_ngap_id;
......@@ -124,6 +177,9 @@ class nas_context {
bool is_5g_guti_present;
bool is_auth_vectors_present;
bool to_be_register_by_new_suci;
std::string guti ;
};
#endif
......@@ -191,7 +191,24 @@ std::string pdu_session_context::pdu_session_context_dnn_from_json(nlohmann::jso
}
Logger::amf_server().error("get_value dnn from json is error");
}
std::string pdu_session_context::pdu_session_context_supi_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") == "supi")
{
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)
{
......@@ -415,6 +432,7 @@ bool pdu_session_context::pdu_session_context_from_json(nlohmann::json j)
isn1sm_avaliable = pdu_session_context_isn1sm_avaliable_from_json(j);
dnn = pdu_session_context_dnn_from_json(j);
supi = pdu_session_context_supi_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);
......
......@@ -48,6 +48,7 @@ class pdu_session_context {
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_supi_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);
......@@ -74,6 +75,8 @@ class pdu_session_context {
snssai_t snssai;
plmn_t plmn;
std::string smf_context_location;
std::string supi;
//15
};
#endif
......@@ -391,7 +391,9 @@ std::shared_ptr<pdu_session_context> psc = std::shared_ptr<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 ;
std::string record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id ;
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 ;
......@@ -413,7 +415,9 @@ std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(
// }
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 ;
record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_put_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id;
nlohmann::json udsf_put_pdu_session_context;
//nlohmann::json udsf_response;
udsf_put_pdu_session_context["meta"] ["tags"] = {
......
......@@ -90,9 +90,11 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(
//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 ;
std::string record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id ;
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 ");
}
......@@ -127,7 +129,9 @@ std::shared_ptr<pdu_session_context> psc = std::shared_ptr<pdu_session_context>(
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 ;
record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_put_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id ;
nlohmann::json udsf_put_pdu_session_context;
//nlohmann::json udsf_response;
udsf_put_pdu_session_context["meta"] ["tags"] = {
......
......@@ -37,7 +37,9 @@ std::shared_ptr<pdu_session_context> psc = std::shared_ptr<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 ;
std::string record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id ;
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());
psc.get()->pdu_session_context_from_json(udsf_response);
......@@ -102,7 +104,9 @@ std::shared_ptr<pdu_session_context> psc = std::shared_ptr<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 ;
std::string record_id = "RECORD_ID=\'" +supi + "\'";
std::string udsf_url = "http://10.112.202.24:7123/nudsf-dr/v1/amfdata/" + std::string("pdu_session_context/records/") + record_id;
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());
psc.get()->pdu_session_context_from_json(udsf_response);
......
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