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

polish code for SMF API server

parent 1cd1db49
...@@ -162,6 +162,7 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req ...@@ -162,6 +162,7 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req
Logger::smf_api_server().info("Received a SM context update request from AMF"); Logger::smf_api_server().info("Received a SM context update request from AMF");
Logger::smf_api_server().debug("Request body: %s\n",request.body().c_str()); Logger::smf_api_server().debug("Request body: %s\n",request.body().c_str());
//find boundary
std::size_t found = request.body().find("Content-Type"); std::size_t found = request.body().find("Content-Type");
std::string boundary_str = request.body().substr(2, found - 4); std::string boundary_str = request.body().substr(2, found - 4);
Logger::smf_api_server().debug("Boundary: %s", boundary_str.c_str()); Logger::smf_api_server().debug("Boundary: %s", boundary_str.c_str());
...@@ -236,12 +237,12 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req ...@@ -236,12 +237,12 @@ void IndividualSMContextApi::update_sm_context_handler(const Pistache::Rest::Req
} catch (nlohmann::detail::exception &e) { } catch (nlohmann::detail::exception &e) {
//send a 400 error //send a 400 error
Logger::smf_api_server().warn("Error in parsing json, send a msg with a 400 error code to AMF"); Logger::smf_api_server().warn("Error in parsing json (error: %s), send a msg with a 400 error code to AMF", e.what());
response.send(Pistache::Http::Code::Bad_Request, e.what()); response.send(Pistache::Http::Code::Bad_Request, e.what());
return; return;
} catch (std::exception &e) { } catch (std::exception &e) {
//send a 500 error //send a 500 error
Logger::smf_api_server().warn("Send a msg with a 500 error code to AMF"); Logger::smf_api_server().warn("Error (%s ), Send a msg with a 500 error code to AMF", e.what());
response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return; return;
} }
......
...@@ -72,9 +72,10 @@ void SMContextsCollectionApi::setupRoutes() { ...@@ -72,9 +72,10 @@ void SMContextsCollectionApi::setupRoutes() {
void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
Logger::smf_api_server().info("Received a SM context create request from AMF"); Logger::smf_api_server().info("\nReceived a SM context create request from AMF");
Logger::smf_api_server().debug("Request body: %s\n",request.body().c_str()); Logger::smf_api_server().debug("Request body: %s",request.body().c_str());
//find boundary
std::size_t found = request.body().find("Content-Type"); std::size_t found = request.body().find("Content-Type");
std::string boundary_str = request.body().substr(2, found - 4); std::string boundary_str = request.body().substr(2, found - 4);
Logger::smf_api_server().debug("Boundary: %s", boundary_str.c_str()); Logger::smf_api_server().debug("Boundary: %s", boundary_str.c_str());
...@@ -127,11 +128,12 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req ...@@ -127,11 +128,12 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req
this->post_sm_contexts(smContextMessage, response); this->post_sm_contexts(smContextMessage, response);
} catch (nlohmann::detail::exception &e) { } catch (nlohmann::detail::exception &e) {
//send a 400 error //send a 400 error
Logger::smf_api_server().warn("Can not parse the json data!"); Logger::smf_api_server().warn("Can not parse the json data (error: %s)!", e.what());
response.send(Pistache::Http::Code::Bad_Request, e.what()); response.send(Pistache::Http::Code::Bad_Request, e.what());
return; return;
} catch (std::exception &e) { } catch (std::exception &e) {
//send a 500 error //send a 500 error
Logger::smf_api_server().warn("Error: %s!", e.what());
response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return; return;
} }
......
...@@ -64,7 +64,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon ...@@ -64,7 +64,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
Logger::smf_api_server().debug("smContextMessage, N1 SM message: %s",n1_sm_msg.c_str()); Logger::smf_api_server().debug("smContextMessage, N1 SM message: %s",n1_sm_msg.c_str());
//Step 2. Create a pdu_session_create_sm_context_request message and store the necessary information //Step 2. Create a pdu_session_create_sm_context_request message and store the necessary information
Logger::smf_api_server().debug("Create a pdu_session_create_sm_context_request message and store the necessary information\n"); Logger::smf_api_server().debug("Create a pdu_session_create_sm_context_request message and store the necessary information");
smf::pdu_session_create_sm_context_request sm_context_req_msg = {}; smf::pdu_session_create_sm_context_request sm_context_req_msg = {};
//set N1 SM Message //set N1 SM Message
...@@ -80,27 +80,27 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon ...@@ -80,27 +80,27 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
smf_string_to_supi(&supi, supi_str.c_str()); smf_string_to_supi(&supi, supi_str.c_str());
sm_context_req_msg.set_supi(supi); sm_context_req_msg.set_supi(supi);
sm_context_req_msg.set_supi_prefix(supi_prefix); sm_context_req_msg.set_supi_prefix(supi_prefix);
Logger::smf_api_server().debug("SmContextCreateData, supi %s, prefix %s, imsi %s \n", smContextCreateData.getSupi().c_str(), supi_prefix.c_str(), supi_str.c_str()); Logger::smf_api_server().debug("SmContextCreateData, supi %s, prefix %s, imsi %s", smContextCreateData.getSupi().c_str(), supi_prefix.c_str(), supi_str.c_str());
//dnn //dnn
Logger::smf_api_server().debug("SmContextCreateData, dnn %s \n", smContextCreateData.getDnn().c_str()); Logger::smf_api_server().debug("SmContextCreateData, dnn %s", smContextCreateData.getDnn().c_str());
sm_context_req_msg.set_dnn(smContextCreateData.getDnn().c_str()); sm_context_req_msg.set_dnn(smContextCreateData.getDnn().c_str());
//S-Nssai //S-Nssai
Logger::smf_api_server().debug("SmContextCreateData, S-NSSAI sst %d, sd %s\n", smContextCreateData.getSNssai().getSst(), smContextCreateData.getSNssai().getSd().c_str()); Logger::smf_api_server().debug("SmContextCreateData, S-NSSAI sst %d, sd %s", smContextCreateData.getSNssai().getSst(), smContextCreateData.getSNssai().getSd().c_str());
snssai_t snssai(smContextCreateData.getSNssai().getSst(), smContextCreateData.getSNssai().getSd().c_str()); snssai_t snssai(smContextCreateData.getSNssai().getSst(), smContextCreateData.getSNssai().getSd().c_str());
sm_context_req_msg.set_snssai(snssai); sm_context_req_msg.set_snssai(snssai);
//PDU session ID //PDU session ID
Logger::smf_api_server().debug("SmContextCreateData, PDU SessionID %d \n", smContextCreateData.getPduSessionId()); Logger::smf_api_server().debug("SmContextCreateData, PDU SessionID %d", smContextCreateData.getPduSessionId());
sm_context_req_msg.set_pdu_session_id(smContextCreateData.getPduSessionId()); sm_context_req_msg.set_pdu_session_id(smContextCreateData.getPduSessionId());
//AMF ID (ServingNFId) //AMF ID (ServingNFId)
Logger::smf_api_server().debug("SmContextCreateDatea, ServingNfId %s\n", smContextCreateData.getServingNfId().c_str()); Logger::smf_api_server().debug("SmContextCreateDatea, ServingNfId %s", smContextCreateData.getServingNfId().c_str());
sm_context_req_msg.set_serving_nf_id(smContextCreateData.getServingNfId().c_str()); //TODO: should be verified that AMF ID is stored in GUAMI or ServingNfId sm_context_req_msg.set_serving_nf_id(smContextCreateData.getServingNfId().c_str()); //TODO: should be verified that AMF ID is stored in GUAMI or ServingNfId
//Request Type //Request Type
Logger::smf_api_server().debug("SmContextCreateData, RequestType %s\n", smContextCreateData.getRequestType().c_str()); Logger::smf_api_server().debug("SmContextCreateData, RequestType %s", smContextCreateData.getRequestType().c_str());
sm_context_req_msg.set_request_type(smContextCreateData.getRequestType()); sm_context_req_msg.set_request_type(smContextCreateData.getRequestType());
//PCF ID //PCF ID
// Priority Access // Priority Access
...@@ -117,7 +117,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon ...@@ -117,7 +117,7 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//PCFId //PCFId
// DNN Selection Mode // DNN Selection Mode
Logger::smf_api_server().debug("SmContextCreateData, SelMode %s\n", smContextCreateData.getSelMode().c_str()); Logger::smf_api_server().debug("SmContextCreateData, SelMode %s", smContextCreateData.getSelMode().c_str());
sm_context_req_msg.set_dnn_selection_mode(smContextCreateData.getSelMode().c_str()); sm_context_req_msg.set_dnn_selection_mode(smContextCreateData.getSelMode().c_str());
//Subscription for PDU Session Status Notification //Subscription for PDU Session Status Notification
......
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