Commit 5cc80e85 authored by Niuhaiwen's avatar Niuhaiwen

fix bugs

parent 2bfc95f2
......@@ -174,9 +174,9 @@ void amf_app_task(void*) {
//------------------------------------------------------------------------------
long amf_app::generate_amf_ue_ngap_id() {
long tmp = 0;
tmp = __sync_fetch_and_add(&amf_app_ue_ngap_id_generator, 1);
//tmp = __sync_fetch_and_add(&amf_app_ue_ngap_id_generator, 1);
//srand(time(NULL));
//tmp = rand()%1000 + 1;
tmp = rand()%1000 + 1;
//return tmp & 0xffffffffff;
return tmp;
}
......@@ -317,7 +317,7 @@ void amf_app::handle_itti_message(
string ue_context_key = "app_ue_ranid_" + to_string(itti_msg.ran_ue_ngap_id) + "-amfid_" + to_string(amf_ue_ngap_id);
std::string record_id = "amf_ue_ngap_id=\'" + to_string(amf_ue_ngap_id) + "\'";
//std::string udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + record_id ;
std::string udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + "RECORD_ID = \'" + ue_context_key + "\'";
std::string udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + "RECORD_ID=\'" + ue_context_key + "\'";
if(!amf_n2_inst->curl_http_client_udsf(udsf_url,"","GET",udsf_response)){
Logger::amf_n2().error("No existing ue_context with ue_context_key ...");
}else if(udsf_response.dump().length()<8){
......@@ -343,7 +343,7 @@ void amf_app::handle_itti_message(
Logger::amf_app().debug("Update ue_context to UDSF");
record_id = "amf_ue_ngap_id=\'" + to_string(amf_ue_ngap_id) + "\'";
//udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + record_id ;
udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + "RECORD_ID = \'" + ue_context_key + "\'";
udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + "RECORD_ID=\'" + ue_context_key + "\'";
nlohmann::json udsf_ue_context;
nlohmann::json cgi;
cgi["Content-ID"] = "cgi";
......@@ -563,7 +563,7 @@ bool amf_app::generate_5g_guti(
std::string record_id = "RECORD_ID=\'" + to_string(amfid) + "\'";
//std::string record_id = "RECORD_ID=\'" + ue_context_key + "\'";
//std::string udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + record_id;
std::string udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + "RECORD_ID = \'" + ue_context_key + "\'";
std::string udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + "RECORD_ID=\'" + ue_context_key + "\'";
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;
......
......@@ -3203,7 +3203,21 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id,
string ue_context_key = "app_ue_ranid_" + to_string(ran_ue_ngap_id) +
"-amfid_" + to_string(amf_ue_ngap_id);
std::shared_ptr<ue_context> uc;
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
//uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
nlohmann::json udsf_response;
std::string udsf_url = "http://10.103.239.53:7123/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + "RECORD_ID=\'" + ue_context_key + "\'";
if(!amf_n2_inst->curl_http_client_udsf(udsf_url,"","GET",udsf_response)){
Logger::amf_n2().error("No existing ue_context with ue_context_key ...");
}else if(udsf_response.dump().length()<8){
Logger::amf_n2().error("No existing ue_context with ue_context_key .....");
}else{
Logger::amf_n2().debug("udsf_response: %s", udsf_response.dump().c_str());
uc = std::shared_ptr<ue_context>(new ue_context());
uc.get()->ue_context_from_json(udsf_response);
}
amf_app_inst->set_ran_amf_id_2_ue_context(ue_context_key, uc);
if (uc.get() == nullptr) {
// TODO:
Logger::amf_n1().error(
......
......@@ -83,7 +83,24 @@ 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_isUeContextRequest_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") == "isUeContextRequest")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value from json is error");
}
bool ue_context::ue_context_from_json(nlohmann::json j)
{
......@@ -93,6 +110,7 @@ bool ue_context::ue_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);
isUeContextRequest = ue_context_isUeContextRequest_from_json(j);
ue_context_tai_from_json(j,tai);
ran_ue_ngap_id = ue_context_ran_ue_ngap_id_from_json(j);
// printf("gnbname-%s\n",gnb_name.c_str());
......
......@@ -43,6 +43,9 @@ class ue_context {
public:
void ue_context_tai_from_json(nlohmann::json j,Tai_t &tai_json);
bool ue_context_from_json(nlohmann::json j);
bool ue_context_isUeContextRequest_from_json(nlohmann::json j);
uint32_t ue_context_ran_ue_ngap_id_from_json(nlohmann::json j);
uint32_t ran_ue_ngap_id; // 32bits
long amf_ue_ngap_id : 40; // 40bits
......
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