Commit f8d8bb0c authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'dsTest' into 'develop'

Test with dsTester

See merge request oai/oai-cn5g-smf!14
parents 9a00386f 59a46d6e
......@@ -173,11 +173,15 @@ void SMContextsCollectionApiImpl::post_sm_contexts(
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id);
nlohmann::json json_data = { };
response.headers().add < Pistache::Http::Header::Location
> (sm_context_response.get_smf_context_uri()); //Location header
sm_context_response.get_json_data(json_data);
if (!json_data.empty()) {
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType("application/json"));
response.send(Pistache::Http::Code(sm_context_response.get_http_code()), json_data.dump().c_str());
response.headers().add < Pistache::Http::Header::ContentType
> (Pistache::Http::Mime::MediaType("application/json"));
response.send(Pistache::Http::Code(sm_context_response.get_http_code()),
json_data.dump().c_str());
} else {
response.send(Pistache::Http::Code(sm_context_response.get_http_code()));
}
......
......@@ -85,6 +85,7 @@ void SMFApiServer::init(size_t thr) {
}
void SMFApiServer::start() {
Logger::smf_api_server().info("HTTP1 server started");
m_httpEndpoint->setHandler(m_router->handler());
m_httpEndpoint->serve();
......
......@@ -49,8 +49,9 @@ using namespace oai::smf_server::model;
void smf_http2_server::start() {
boost::system::error_code ec;
Logger::smf_api_server().info("HTTP2 server started");
//Create SM Context Request
server.handle("/nsmf-pdusession/v2/sm-contexts",
server.handle(NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL,
[&](const request &request, const response &response) {
request.on_data([&](const uint8_t *data, std::size_t len) {
......@@ -130,7 +131,7 @@ void smf_http2_server::start() {
});
//Update SM Context Request
server.handle("/nsmf-pdusession/v2/sm-contexts/",
server.handle(NSMF_PDU_SESSION_SM_CONTEXT_UPDATE_URL,
[&](const request &request, const response &response) {
request.on_data([&](const uint8_t *data, std::size_t len) {
......
......@@ -76,6 +76,13 @@ typedef struct s_nssai // section 28.4, TS23.003
sST(p.sST),
sD(p.sD) {
}
bool operator==(const struct s_nssai &s) const {
if ((s.sST == this->sST) && (s.sD.compare(this->sD) == 0)) {
return true;
} else {
return false;
}
}
} snssai_t;
......@@ -171,11 +178,15 @@ typedef struct qos_profile_s {
} parameter;
} qos_profile_t;
#define NAMF_COMMUNICATION_N1N2_MESSAGE_TRANSFER_URL "/namf-comm/v2/ue-contexts/{}/n1-n2-messages" //may get from configuration file
#define NUDM_SDM_GET_SM_DATA_URL "/nudm-sdm/v2/{}/sm-data" //may get from configuration file
//URL, N1, N2 (may get from configuration file)
#define NAMF_COMMUNICATION_N1N2_MESSAGE_TRANSFER_URL "/namf-comm/v2/ue-contexts/{}/n1-n2-messages" //context id
#define NUDM_SDM_GET_SM_DATA_URL "/nudm-sdm/v2/{}/sm-data" //ue Id
#define N1_SM_CONTENT_ID "n1SmMsg"
#define N1N2_MESSAGE_CLASS "SM"
#define N2_SM_CONTENT_ID "n2SmMsg"
#define N2_SM_CONTENT_ID "n2msg"
#define NSMF_CALLBACK_N1N2_MESSAGE_TRANSFER_FAILURE "/nsmf-pdusession/v2/callback/N1N2MsgTxfrFailureNotification/{}" //UE Id
#define NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL "/nsmf-pdusession/v2/sm-contexts"
#define NSMF_PDU_SESSION_SM_CONTEXT_UPDATE_URL "/nsmf-pdusession/v2/sm-contexts/"
//for CURL
#define AMF_CURL_TIMEOUT_MS 100L
......
......@@ -119,7 +119,7 @@ void mime_parser::create_multipart_related_content(std::string &body,
body.append(std::string((char*) n1_msg_hex, n1_message.length() / 2) + CRLF);
body.append("--" + boundary + CRLF);
body.append(
"Content-Type: application/vnd.3gpp.ngap" + CRLF + "Content-Id: n2SmMsg"
"Content-Type: application/vnd.3gpp.ngap" + CRLF + "Content-Id: n2msg"
+ CRLF);
body.append(CRLF);
body.append(std::string((char*) n2_msg_hex, n2_message.length() / 2) + CRLF);
......@@ -148,7 +148,7 @@ void mime_parser::create_multipart_related_content(
+ "Content-Id: n1SmMsg" + CRLF);
} else if (content_type == multipart_related_content_part_e::NGAP) { //NGAP
body.append(
"Content-Type: application/vnd.3gpp.ngap" + CRLF + "Content-Id: n2SmMsg"
"Content-Type: application/vnd.3gpp.ngap" + CRLF + "Content-Id: n2msg"
+ CRLF);
}
body.append(CRLF);
......
......@@ -337,7 +337,6 @@ set(NAS_include_files
${SRC_TOP_DIR}/ngap/ies
${SRC_TOP_DIR}/common
)
add_library(NAS ${NAS_src_files} ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES})
set(NGAP_include_files
......@@ -375,9 +374,8 @@ IF(STATIC_LINKING)
SET_TARGET_PROPERTIES(smf PROPERTIES LINK_SEARCH_END_STATIC 1)
# asan do not support static linking
SET(ASAN)
ENDIF(STATIC_LINKING)
ENDIF(STATIC_LINKING)
target_link_libraries (smf ${ASAN}
-Wl,--start-group CN_UTILS SMF UDP GTPV2C PFCP 3GPP_COMMON_TYPES SMF_API -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system pistache curl)
-Wl,--start-group CN_UTILS SMF UDP GTPV2C PFCP 3GPP_COMMON_TYPES SMF_API -lnettle ${NETTLE_LIBRARIES} ${CRYPTO_LIBRARIES} -lnghttp2_asio -lboost_system -lboost_thread -lssl -lcrypto NAS gflags glog dl double-conversion folly -Wl,--end-group pthread m rt config++ event boost_system pistache curl)
\ No newline at end of file
......@@ -46,7 +46,8 @@ itti_mw *itti_inst = nullptr;
async_shell_cmd *async_shell_cmd_inst = nullptr;
smf_app *smf_app_inst = nullptr;
smf_config smf_cfg;
SMFApiServer *smf_api_server_1 = nullptr;
//SMFApiServer *smf_api_server_1 = nullptr;
//smf_http2_server *smf_api_server_2 = nullptr;
void send_heartbeat_to_tasks(const uint32_t sequence);
......@@ -71,12 +72,14 @@ void my_app_signal_handler(int s)
std::cout << "Freeing Allocated memory..." << std::endl;
if (async_shell_cmd_inst) delete async_shell_cmd_inst; async_shell_cmd_inst = nullptr;
std::cout << "Async Shell CMD memory done." << std::endl;
//smf_api_server_1->shutdown();
//if (smf_api_server_1) delete smf_api_server_1; smf_api_server_1 = nullptr;
//if (smf_api_server_2) delete smf_api_server_2; smf_api_server_2 = nullptr;
std::cout << "SMF API Server memory done." << std::endl;
if (itti_inst) delete itti_inst; itti_inst = nullptr;
std::cout << "ITTI memory done." << std::endl;
if (smf_app_inst) delete smf_app_inst; smf_app_inst = nullptr;
std::cout << "SMF APP memory done." << std::endl;
smf_api_server_1->shutdown();
if (smf_api_server_1) delete smf_api_server_1; smf_api_server_1 = nullptr;
std::cout << "Freeing Allocated memory done" << std::endl;
exit(0);
}
......@@ -129,13 +132,14 @@ int main(int argc, char **argv)
Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.sbi.addr4))) , Pistache::Port(smf_cfg.sbi.port));
SMFApiServer *smf_api_server_1 = new SMFApiServer(addr, smf_app_inst);
smf_api_server_1->init(2);
smf_api_server_1->start();
//std::thread smf_api_manager(&SMFApiServer::start, smf_api_server_1);
//smf_api_server_1->start();
std::thread smf_http1_manager(&SMFApiServer::start, smf_api_server_1);
//SMF NGHTTP API server (HTTP2)
smf_http2_server *smf_api_server_2 = new smf_http2_server(conv::toString(smf_cfg.sbi.addr4), smf_cfg.sbi_http2_port, smf_app_inst);
smf_api_server_2->start();
//std::thread smf_api(&smf_http2_server::start, smf_api_server_2);
//smf_api_server_2->start();
std::thread smf_http2_manager(&smf_http2_server::start, smf_api_server_2);
smf_http1_manager.join();
smf_http2_manager.join();
FILE *fp = NULL;
std::string filename = fmt::format("/tmp/smf_{}.status", getpid());
......
This diff is collapsed.
......@@ -119,6 +119,10 @@ class smf_app {
std::map<scid_t, std::shared_ptr<smf_context_ref>> scid2smf_context;
mutable std::shared_mutex m_scid2smf_context;
//Store promise IDs for Create/Update session
mutable std::shared_mutex m_sm_context_create_promises;
mutable std::shared_mutex m_sm_context_update_promises;
mutable std::shared_mutex m_sm_context_release_promises;
std::map<uint32_t,
boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>> sm_context_create_promises;
std::map<uint32_t,
......@@ -390,6 +394,18 @@ class smf_app {
*/
bool is_scid_2_smf_context(const scid_t &scid) const;
/*
* Verify whether a SMF Context Reference with a given ID exist
* @param [const supi64_t &] supi64: Supi64
* @param [const std::string &] dnn: DNN
* @param [const snssai_t &] snssai: S-NSSAI
* @param [const pdu_session_id_t &] pid: PDU Session ID
*
* @return bool: True if a SMF Context Reference exist, otherwise return false
*/
bool is_scid_2_smf_context(const supi64_t &supi, const std::string &dnn, const snssai_t &snssai,
const pdu_session_id_t &pid ) const;
/*
* Find SMF Context Reference by its ID
* @param [const scid_t &] scid: SM Context Reference ID
......@@ -604,6 +620,7 @@ class smf_app {
* @param [const uint32_t &] http_code: Status code of HTTP response
* @param [const oai::smf_server::model::SmContextCreateError &] smContextCreateError: store the json content of response message
* @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void
*/
void trigger_http_response(
......@@ -617,6 +634,7 @@ class smf_app {
* @param [const oai::smf_server::model::SmContextUpdateError &] smContextUpdateError: store the json content of response message
* @param [const std::string &] n1_sm_msg: N1 SM message
* @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void
*/
void trigger_http_response(
......@@ -628,7 +646,7 @@ class smf_app {
* To trigger the response to the HTTP server by set the value of the corresponding promise to ready
* @param [const uint32_t &] http_code: Status code of HTTP response
* @param [uint32_t &] promise_id: Promise Id
* @param [uint8_t] msg_type
* @param [uint8_t] msg_type: Type of HTTP message (Create/Update/Release)
* @return void
*/
void trigger_http_response(const uint32_t &http_code, uint32_t &promise_id,
......
This diff is collapsed.
This diff is collapsed.
......@@ -78,9 +78,9 @@ class smf_n1_n2 {
* @param [uint8_t] msg_type Type of N1 message
* @param [std::string&] nas_msg_str store NAS message in form of string
* @param [uint8_t] sm_cause store NAS Cause
*
* @return boolean: True if the NAS message has been created successfully, otherwise return false
*/
void create_n1_sm_container(pdu_session_msg &msg, uint8_t msg_type,
bool create_n1_sm_container(pdu_session_msg &msg, uint8_t msg_type,
std::string &nas_msg_str,
cause_value_5gsm_e sm_cause);
......@@ -89,9 +89,10 @@ class smf_n1_n2 {
* @param [std::shared_ptr<itti_n11_create_sm_context_response>] sm_context_res
* @param [uint8_t] msg_type Type of N2 message
* @param [std::string&] ngap_msg_str store NGAP message in form of string
* @return boolean: True if the NGAP message has been created successfully, otherwise return false
*
*/
void create_n2_sm_information(pdu_session_msg &msg, uint8_t ngap_msg_type,
bool create_n2_sm_information(pdu_session_msg &msg, uint8_t ngap_msg_type,
n2_sm_info_type_e ngap_ie_type,
std::string &ngap_msg_str);
......
......@@ -465,7 +465,7 @@ void session_create_sm_context_procedure::handle_itti_msg(
if (n11_triggered_pending->res.get_cause() == REQUEST_ACCEPTED) {
json_data["n2InfoContainer"]["n2InformationClass"] =
N1N2_MESSAGE_CLASS;
json_data["n2InfoContainer"]["smInfo"]["PduSessionId"] =
json_data["n2InfoContainer"]["smInfo"]["pduSessionId"] =
n11_triggered_pending->res.get_pdu_session_id();
//N2InfoContent (section 6.1.6.2.27@3GPP TS 29.518)
json_data["n2InfoContainer"]["smInfo"]["n2InfoContent"]["ngapIeType"] =
......@@ -477,6 +477,15 @@ void session_create_sm_context_procedure::handle_itti_msg(
json_data["n2InfoContainer"]["smInfo"]["sNssai"]["sd"] =
n11_triggered_pending->res.get_snssai().sD;
json_data["n2InfoContainer"]["ranInfo"] = "SM";
//N1N2MsgTxfrFailureNotification
std::string callback_uri = std::string(
inet_ntoa(*((struct in_addr*) &smf_cfg.amf_addr.ipv4_addr))) + ":"
+ std::to_string(smf_cfg.amf_addr.port)
+ fmt::format(NSMF_CALLBACK_N1N2_MESSAGE_TRANSFER_FAILURE,
supi_str.c_str());
json_data["n1n2FailureTxfNotifURI"] = callback_uri.c_str();
//json_data["n1n2FailureTxfNotifURI"] = "http://192.168.122.1/namf-comm/callback/N1N2MsgTxfrFailureNotification/imsi-310410000000001-1";
}
//Others information
//n11_triggered_pending->res.n1n2_message_transfer_data["pti"] = 1; //Don't need this info for the moment
......@@ -1025,6 +1034,7 @@ void session_update_sm_context_procedure::handle_itti_msg(
smf_app_inst->trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_403_FORBIDDEN,
smContextUpdateError, n11_triggered_pending->pid);
return;
}
}
break;
......
This diff is collapsed.
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