Commit dc4e7d18 authored by chen2022's avatar chen2022

smf openxg-smf/v1/uemsg接口补充

parent 27426420
...@@ -21,11 +21,14 @@ ...@@ -21,11 +21,14 @@
#ifndef FILE_SMF_SEEN #ifndef FILE_SMF_SEEN
#define FILE_SMF_SEEN #define FILE_SMF_SEEN
#include <iostream>
#include "3gpp_29.274.h" #include "3gpp_29.274.h"
#include "3gpp_29.571.h" #include "3gpp_29.571.h"
#include "3gpp_24.501.h" #include "3gpp_24.501.h"
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <list>
typedef uint64_t supi64_t; typedef uint64_t supi64_t;
#define SUPI_64_FMT "%" SCNu64 #define SUPI_64_FMT "%" SCNu64
...@@ -330,4 +333,12 @@ typedef struct guami_5g_s { ...@@ -330,4 +333,12 @@ typedef struct guami_5g_s {
std::string amf_id; std::string amf_id;
} guami_5g_t; } guami_5g_t;
typedef struct uemsg {
std::string imsi;
std::string ueip;
std::string timestamp;
} UeMsg;
#endif #endif
...@@ -50,6 +50,12 @@ ...@@ -50,6 +50,12 @@
#include "ProblemDetails.h" #include "ProblemDetails.h"
#include "3gpp_24.501.h" #include "3gpp_24.501.h"
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<cstdio>
using namespace pfcp; using namespace pfcp;
using namespace smf; using namespace smf;
using namespace std; using namespace std;
...@@ -314,6 +320,7 @@ int session_create_sm_context_procedure::run( ...@@ -314,6 +320,7 @@ int session_create_sm_context_procedure::run(
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
std::list<UeMsg> UeMsgList;
void session_create_sm_context_procedure::handle_itti_msg( void session_create_sm_context_procedure::handle_itti_msg(
itti_n4_session_establishment_response& resp, itti_n4_session_establishment_response& resp,
std::shared_ptr<smf::smf_context> sc) { std::shared_ptr<smf::smf_context> sc) {
...@@ -504,6 +511,52 @@ void session_create_sm_context_procedure::handle_itti_msg( ...@@ -504,6 +511,52 @@ void session_create_sm_context_procedure::handle_itti_msg(
"Could not send ITTI message %s to task TASK_SMF_SBI", "Could not send ITTI message %s to task TASK_SMF_SBI",
n11_triggered_pending->get_msg_name()); n11_triggered_pending->get_msg_name());
} }
// smf
struct in_addr ue_addr = n11_triggered_pending->res.get_paa().ipv4_address;
Logger::smf_app().info("=======获取 imsi--%s ueip--%s",smf_supi_to_string(supi).c_str(),(char *)inet_ntoa(ue_addr));
//处理时间
//timestap
time_t nowtime;
nowtime = time(NULL);
char timestamp[64];
strftime(timestamp,sizeof(timestamp),"%Y-%m-%d %H:%M:%S",localtime(&nowtime));
//timestapimsi
UeMsgData.imsi = smf_supi_to_string(supi).c_str();
//ueip
UeMsgData.ueip = (char *)inet_ntoa(ue_addr);
//timestamp
UeMsgData.timestamp = timestamp;
//去重
if(!UeMsgList.empty()){
int i=0;
nlohmann::json json_array = nlohmann::json::array();
for (std::list<UeMsg>::iterator it = UeMsgList.begin(); it != UeMsgList.end(); it++)
{
if(UeMsgData.imsi.compare(it->imsi)==0){
UeMsgList.erase(it++);
}
i++;
}
}
//添加新值
UeMsgList.push_back(UeMsgData);
// if(smf_cfg.agent.enable)
// {
// nlohmann::json smf_agent_json_data = {};
// smf_agent_json_data["supi"] = supi_str.c_str();
// struct in_addr ue_addr = n11_triggered_pending->res.get_paa().ipv4_address;
// smf_agent_json_data["adIpv4Addr"] = (char *)inet_ntoa(ue_addr);
// Logger::smf_app().info(
// "================smf_procedure 获取supi adIpv4Addr============== %s",
// supi_str.c_str());
// }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
#include "msg_pfcp.hpp" #include "msg_pfcp.hpp"
#include "smf_msg.hpp" #include "smf_msg.hpp"
#include "uint_generator.hpp" #include "uint_generator.hpp"
#include <list>
#include "smf.h"
namespace smf { namespace smf {
class smf_context; class smf_context;
...@@ -51,12 +52,11 @@ class smf_pdu_session; ...@@ -51,12 +52,11 @@ class smf_pdu_session;
class smf_procedure { class smf_procedure {
private: private:
static uint64_t trxn_id_generator; static uint64_t trxn_id_generator;
static uint64_t generate_trxn_id() { static uint64_t generate_trxn_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid(); return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
} }
public: public:
UeMsg UeMsgData;
uint64_t trxn_id; uint64_t trxn_id;
smf_procedure() { trxn_id = generate_trxn_id(); } smf_procedure() { trxn_id = generate_trxn_id(); }
explicit smf_procedure(uint64_t tx) { trxn_id = tx; } explicit smf_procedure(uint64_t tx) { trxn_id = tx; }
......
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