Commit 4f60cc30 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

applying google style

parent 227a585c
......@@ -20,7 +20,8 @@ namespace api {
using namespace oai::smf_server::helpers;
using namespace oai::smf_server::model;
IndividualPDUSessionHSMFApi::IndividualPDUSessionHSMFApi(std::shared_ptr<Pistache::Rest::Router> rtr) {
IndividualPDUSessionHSMFApi::IndividualPDUSessionHSMFApi(
std::shared_ptr<Pistache::Rest::Router> rtr) {
router = rtr;
}
......@@ -31,20 +32,33 @@ void IndividualPDUSessionHSMFApi::init() {
void IndividualPDUSessionHSMFApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(*router, base + "/pdu-sessions/:pduSessionRef/release", Routes::bind(&IndividualPDUSessionHSMFApi::release_pdu_session_handler, this));
Routes::Post(*router, base + "/pdu-sessions/:pduSessionRef/modify", Routes::bind(&IndividualPDUSessionHSMFApi::update_pdu_session_handler, this));
Routes::Post(
*router,
base + "/pdu-sessions/:pduSessionRef/release",
Routes::bind(&IndividualPDUSessionHSMFApi::release_pdu_session_handler,
this));
Routes::Post(
*router,
base + "/pdu-sessions/:pduSessionRef/modify",
Routes::bind(&IndividualPDUSessionHSMFApi::update_pdu_session_handler,
this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&IndividualPDUSessionHSMFApi::individual_pdu_session_hsmf_api_default_handler, this));
router->addCustomHandler(
Routes::bind(
&IndividualPDUSessionHSMFApi::individual_pdu_session_hsmf_api_default_handler,
this));
}
void IndividualPDUSessionHSMFApi::release_pdu_session_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
void IndividualPDUSessionHSMFApi::release_pdu_session_handler(
const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response) {
// Getting the path params
auto pduSessionRef = request.param(":pduSessionRef").as<std::string>();
// Getting the body param
ReleaseData releaseData = {};
ReleaseData releaseData = { };
try {
nlohmann::json::parse(request.body()).get_to(releaseData);
......@@ -60,13 +74,15 @@ void IndividualPDUSessionHSMFApi::release_pdu_session_handler(const Pistache::Re
}
}
void IndividualPDUSessionHSMFApi::update_pdu_session_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
void IndividualPDUSessionHSMFApi::update_pdu_session_handler(
const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response) {
// Getting the path params
auto pduSessionRef = request.param(":pduSessionRef").as<std::string>();
// Getting the body param
HsmfUpdateData hsmfUpdateData = {};
HsmfUpdateData hsmfUpdateData = { };
try {
nlohmann::json::parse(request.body()).get_to(hsmfUpdateData);
......@@ -83,8 +99,10 @@ void IndividualPDUSessionHSMFApi::update_pdu_session_handler(const Pistache::Res
}
void IndividualPDUSessionHSMFApi::individual_pdu_session_hsmf_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist");
void IndividualPDUSessionHSMFApi::individual_pdu_session_hsmf_api_default_handler(
const Pistache::Rest::Request&, Pistache::Http::ResponseWriter response) {
response.send(Pistache::Http::Code::Not_Found,
"The requested method does not exist");
}
}
......
......@@ -48,9 +48,13 @@ class IndividualPDUSessionHSMFApi {
private:
void setupRoutes();
void release_pdu_session_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void update_pdu_session_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void individual_pdu_session_hsmf_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void release_pdu_session_handler(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
void update_pdu_session_handler(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
void individual_pdu_session_hsmf_api_default_handler(
const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
......@@ -62,7 +66,9 @@ class IndividualPDUSessionHSMFApi {
/// </remarks>
/// <param name="pduSessionRef">PDU session reference</param>
/// <param name="releaseData">representation of the data to be sent to H-SMF when releasing the PDU session (optional)</param>
virtual void release_pdu_session(const std::string &pduSessionRef, const ReleaseData &releaseData, Pistache::Http::ResponseWriter &response) = 0;
virtual void release_pdu_session(
const std::string &pduSessionRef, const ReleaseData &releaseData,
Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Update (initiated by V-SMF)
......@@ -72,7 +78,9 @@ class IndividualPDUSessionHSMFApi {
/// </remarks>
/// <param name="pduSessionRef">PDU session reference</param>
/// <param name="hsmfUpdateData">representation of the updates to apply to the PDU session</param>
virtual void update_pdu_session(const std::string &pduSessionRef, const HsmfUpdateData &hsmfUpdateData, Pistache::Http::ResponseWriter &response) = 0;
virtual void update_pdu_session(const std::string &pduSessionRef,
const HsmfUpdateData &hsmfUpdateData,
Pistache::Http::ResponseWriter &response) = 0;
};
......
......@@ -76,10 +76,15 @@ class IndividualSMContextApi {
private:
void setupRoutes();
void release_sm_context_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void retrieve_sm_context_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void update_sm_context_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void individual_sm_context_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void release_sm_context_handler(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
void retrieve_sm_context_handler(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
void update_sm_context_handler(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
void individual_sm_context_api_default_handler(
const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
......@@ -91,7 +96,10 @@ class IndividualSMContextApi {
/// </remarks>
/// <param name="smContextRef">SM context reference</param>
/// <param name="smContextReleaseData">representation of the data to be sent to the SMF when releasing the SM context (optional)</param>
virtual void release_sm_context(const std::string &smContextRef, const SmContextReleaseMessage &smContextReleaseMessage, Pistache::Http::ResponseWriter &response) = 0;
virtual void release_sm_context(
const std::string &smContextRef,
const SmContextReleaseMessage &smContextReleaseMessage,
Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Retrieve SM Context
......@@ -101,7 +109,10 @@ class IndividualSMContextApi {
/// </remarks>
/// <param name="smContextRef">SM context reference</param>
/// <param name="smContextRetrieveData">parameters used to retrieve the SM context (optional)</param>
virtual void retrieve_sm_context(const std::string &smContextRef, const SmContextRetrieveData &smContextRetrieveData, Pistache::Http::ResponseWriter &response) = 0;
virtual void retrieve_sm_context(
const std::string &smContextRef,
const SmContextRetrieveData &smContextRetrieveData,
Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Update SM Context
......@@ -111,7 +122,10 @@ class IndividualSMContextApi {
/// </remarks>
/// <param name="smContextRef">SM context reference</param>
/// <param name="smContextUpdateData">representation of the updates to apply to the SM context</param>
virtual void update_sm_context(const std::string &smContextRef, const SmContextUpdateMessage &smContextUpdateMessage, Pistache::Http::ResponseWriter &response) = 0;
virtual void update_sm_context(
const std::string &smContextRef,
const SmContextUpdateMessage &smContextUpdateMessage,
Pistache::Http::ResponseWriter &response) = 0;
};
......
......@@ -20,7 +20,8 @@ namespace api {
using namespace oai::smf_server::helpers;
using namespace oai::smf_server::model;
PDUSessionsCollectionApi::PDUSessionsCollectionApi(std::shared_ptr<Pistache::Rest::Router> rtr) {
PDUSessionsCollectionApi::PDUSessionsCollectionApi(
std::shared_ptr<Pistache::Rest::Router> rtr) {
router = rtr;
}
......@@ -31,13 +32,20 @@ void PDUSessionsCollectionApi::init() {
void PDUSessionsCollectionApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(*router, base + "/pdu-sessions", Routes::bind(&PDUSessionsCollectionApi::post_pdu_sessions_handler, this));
Routes::Post(
*router, base + "/pdu-sessions",
Routes::bind(&PDUSessionsCollectionApi::post_pdu_sessions_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&PDUSessionsCollectionApi::pdu_sessions_collection_api_default_handler, this));
router->addCustomHandler(
Routes::bind(
&PDUSessionsCollectionApi::pdu_sessions_collection_api_default_handler,
this));
}
void PDUSessionsCollectionApi::post_pdu_sessions_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
void PDUSessionsCollectionApi::post_pdu_sessions_handler(
const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response) {
// Getting the body param
......@@ -58,8 +66,10 @@ void PDUSessionsCollectionApi::post_pdu_sessions_handler(const Pistache::Rest::R
}
void PDUSessionsCollectionApi::pdu_sessions_collection_api_default_handler(const Pistache::Rest::Request&, Pistache::Http::ResponseWriter response) {
response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist");
void PDUSessionsCollectionApi::pdu_sessions_collection_api_default_handler(
const Pistache::Rest::Request&, Pistache::Http::ResponseWriter response) {
response.send(Pistache::Http::Code::Not_Found,
"The requested method does not exist");
}
}
......
......@@ -46,8 +46,11 @@ class PDUSessionsCollectionApi {
private:
void setupRoutes();
void post_pdu_sessions_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void pdu_sessions_collection_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void post_pdu_sessions_handler(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
void pdu_sessions_collection_api_default_handler(
const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
......@@ -58,7 +61,9 @@ class PDUSessionsCollectionApi {
///
/// </remarks>
/// <param name="pduSessionCreateData">representation of the PDU session to be created in the H-SMF</param>
virtual void post_pdu_sessions(const PduSessionCreateData &pduSessionCreateData, Pistache::Http::ResponseWriter &response) = 0;
virtual void post_pdu_sessions(
const PduSessionCreateData &pduSessionCreateData,
Pistache::Http::ResponseWriter &response) = 0;
};
......
......@@ -53,7 +53,8 @@ namespace api {
using namespace oai::smf_server::helpers;
using namespace oai::smf_server::model;
SMContextsCollectionApi::SMContextsCollectionApi(std::shared_ptr<Pistache::Rest::Router> rtr) {
SMContextsCollectionApi::SMContextsCollectionApi(
std::shared_ptr<Pistache::Rest::Router> rtr) {
router = rtr;
}
......@@ -64,24 +65,32 @@ void SMContextsCollectionApi::init() {
void SMContextsCollectionApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(*router, base + "/sm-contexts", Routes::bind(&SMContextsCollectionApi::post_sm_contexts_handler, this));
Routes::Post(
*router, base + "/sm-contexts",
Routes::bind(&SMContextsCollectionApi::post_sm_contexts_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&SMContextsCollectionApi::sm_contexts_collection_api_default_handler, this));
router->addCustomHandler(
Routes::bind(
&SMContextsCollectionApi::sm_contexts_collection_api_default_handler,
this));
}
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("\nReceived a SM context create request from AMF");
Logger::smf_api_server().debug("Request body: %s",request.body().c_str());
Logger::smf_api_server().info(
"\nReceived a SM context create request from AMF");
Logger::smf_api_server().debug("Request body: %s", request.body().c_str());
//find boundary
std::size_t found = request.body().find("Content-Type");
std::string boundary_str = request.body().substr(2, found - 4);
Logger::smf_api_server().debug("Boundary: %s", boundary_str.c_str());
SmContextMessage smContextMessage = {};
SmContextCreateData smContextCreateData = {};
SmContextMessage smContextMessage = { };
SmContextCreateData smContextCreateData = { };
//step 1. use multipartparser to decode the request
multipartparser_callbacks_init(&g_callbacks);
......@@ -94,11 +103,15 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req
g_callbacks.on_part_end = &on_part_end;
g_callbacks.on_body_end = &on_body_end;
multipartparser parser = {};
multipartparser parser = { };
init_globals();
multipartparser_init(&parser, reinterpret_cast<const char*>(boundary_str.c_str()));
if ((multipartparser_execute(&parser, &g_callbacks, request.body().c_str(), strlen(request.body().c_str())) != strlen(request.body().c_str())) or (!g_body_begin_called)){
Logger::smf_api_server().warn("The received message can not be parsed properly!");
multipartparser_init(&parser,
reinterpret_cast<const char*>(boundary_str.c_str()));
if ((multipartparser_execute(&parser, &g_callbacks, request.body().c_str(),
strlen(request.body().c_str()))
!= strlen(request.body().c_str())) or (!g_body_begin_called)) {
Logger::smf_api_server().warn(
"The received message can not be parsed properly!");
//TODO: fix this issue
//response.send(Pistache::Http::Code::Bad_Request, "");
//return;
......@@ -106,18 +119,23 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req
Logger::smf_api_server().debug("Number of g_parts %d", g_parts.size());
//at least 2 parts for Json data and N1 (+ N2)
if (g_parts.size() < 2){
if (g_parts.size() < 2) {
response.send(Pistache::Http::Code::Bad_Request, "");
return;
}
part p0 = g_parts.front(); g_parts.pop_front();
part p0 = g_parts.front();
g_parts.pop_front();
Logger::smf_api_server().debug("Request body, part 1: \n%s", p0.body.c_str());
part p1 = g_parts.front(); g_parts.pop_front();
Logger::smf_api_server().debug("Request body, part 2: \n %s",p1.body.c_str());
part p1 = g_parts.front();
g_parts.pop_front();
Logger::smf_api_server().debug("Request body, part 2: \n %s",
p1.body.c_str());
if (g_parts.size() > 0) {
part p2 = g_parts.front(); g_parts.pop_front();
Logger::smf_api_server().debug("Request body, part 3: \n %s",p2.body.c_str());
part p2 = g_parts.front();
g_parts.pop_front();
Logger::smf_api_server().debug("Request body, part 3: \n %s",
p2.body.c_str());
}
//step 2. process the request
......@@ -128,7 +146,8 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req
this->post_sm_contexts(smContextMessage, response);
} catch (nlohmann::detail::exception &e) {
//send a 400 error
Logger::smf_api_server().warn("Can not parse the json data (error: %s)!", e.what());
Logger::smf_api_server().warn("Can not parse the json data (error: %s)!",
e.what());
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (std::exception &e) {
......@@ -140,8 +159,10 @@ void SMContextsCollectionApi::post_sm_contexts_handler(const Pistache::Rest::Req
}
void SMContextsCollectionApi::sm_contexts_collection_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist");
void SMContextsCollectionApi::sm_contexts_collection_api_default_handler(
const Pistache::Rest::Request&, Pistache::Http::ResponseWriter response) {
response.send(Pistache::Http::Code::Not_Found,
"The requested method does not exist");
}
}
......
......@@ -36,17 +36,14 @@
* contact@openairinterface.org
*/
#ifndef SMContextsCollectionApi_H_
#define SMContextsCollectionApi_H_
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <pistache/optional.h>
#include "SmContextMessage.h"
#include "ProblemDetails.h"
#include "SmContextCreateError.h"
......@@ -58,10 +55,11 @@ namespace api {
using namespace oai::smf_server::model;
class SMContextsCollectionApi {
class SMContextsCollectionApi {
public:
SMContextsCollectionApi(std::shared_ptr<Pistache::Rest::Router>);
virtual ~SMContextsCollectionApi() {}
virtual ~SMContextsCollectionApi() {
}
void init();
const std::string base = "/nsmf-pdusession/v2";
......@@ -69,8 +67,11 @@ class SMContextsCollectionApi {
private:
void setupRoutes();
void post_sm_contexts_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void sm_contexts_collection_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void post_sm_contexts_handler(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
void sm_contexts_collection_api_default_handler(
const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
......@@ -81,7 +82,8 @@ class SMContextsCollectionApi {
///
/// </remarks>
/// <param name="smContextMessage"></param>
virtual void post_sm_contexts(const SmContextMessage &smContextMessage, Pistache::Http::ResponseWriter &response) = 0;
virtual void post_sm_contexts(const SmContextMessage &smContextMessage,
Pistache::Http::ResponseWriter &response) = 0;
};
......
......@@ -18,20 +18,28 @@ namespace api {
using namespace oai::smf_server::model;
IndividualPDUSessionHSMFApiImpl::IndividualPDUSessionHSMFApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr, smf::smf_app *smf_app_inst, std::string address)
IndividualPDUSessionHSMFApiImpl::IndividualPDUSessionHSMFApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr, smf::smf_app *smf_app_inst,
std::string address)
:
IndividualPDUSessionHSMFApi(rtr),
m_smf_app(smf_app_inst),
m_address(address) {
}
void IndividualPDUSessionHSMFApiImpl::release_pdu_session(const std::string &pduSessionRef, const ReleaseData &releaseData, Pistache::Http::ResponseWriter &response) {
void IndividualPDUSessionHSMFApiImpl::release_pdu_session(
const std::string &pduSessionRef, const ReleaseData &releaseData,
Pistache::Http::ResponseWriter &response) {
Logger::smf_api_server().info("release_pdu_session...");
response.send(Pistache::Http::Code::Ok, "Release_pdu_session API has not been implemented yet!\n");
response.send(Pistache::Http::Code::Ok,
"Release_pdu_session API has not been implemented yet!\n");
}
void IndividualPDUSessionHSMFApiImpl::update_pdu_session(const std::string &pduSessionRef, const HsmfUpdateData &hsmfUpdateData, Pistache::Http::ResponseWriter &response) {
void IndividualPDUSessionHSMFApiImpl::update_pdu_session(
const std::string &pduSessionRef, const HsmfUpdateData &hsmfUpdateData,
Pistache::Http::ResponseWriter &response) {
Logger::smf_api_server().info("update_pdu_session...");
response.send(Pistache::Http::Code::Ok, "Update_pdu_session API has not been implemented yet!\n");
response.send(Pistache::Http::Code::Ok,
"Update_pdu_session API has not been implemented yet!\n");
}
}
......
......@@ -42,14 +42,21 @@ namespace api {
using namespace oai::smf_server::model;
class IndividualPDUSessionHSMFApiImpl : public oai::smf_server::api::IndividualPDUSessionHSMFApi {
class IndividualPDUSessionHSMFApiImpl :
public oai::smf_server::api::IndividualPDUSessionHSMFApi {
public:
IndividualPDUSessionHSMFApiImpl(std::shared_ptr<Pistache::Rest::Router>, smf::smf_app *smf_app_inst, std::string address);
IndividualPDUSessionHSMFApiImpl(std::shared_ptr<Pistache::Rest::Router>,
smf::smf_app *smf_app_inst,
std::string address);
~IndividualPDUSessionHSMFApiImpl() {
}
void release_pdu_session(const std::string &pduSessionRef, const ReleaseData &releaseData, Pistache::Http::ResponseWriter &response);
void update_pdu_session(const std::string &pduSessionRef, const HsmfUpdateData &hsmfUpdateData, Pistache::Http::ResponseWriter &response);
void release_pdu_session(const std::string &pduSessionRef,
const ReleaseData &releaseData,
Pistache::Http::ResponseWriter &response);
void update_pdu_session(const std::string &pduSessionRef,
const HsmfUpdateData &hsmfUpdateData,
Pistache::Http::ResponseWriter &response);
private:
smf::smf_app *m_smf_app;
std::string m_address;
......
......@@ -39,32 +39,41 @@ namespace api {
using namespace oai::smf_server::model;
IndividualSMContextApiImpl::IndividualSMContextApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr, smf::smf_app *smf_app_inst, std::string address)
IndividualSMContextApiImpl::IndividualSMContextApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr, smf::smf_app *smf_app_inst,
std::string address)
:
IndividualSMContextApi(rtr),
m_smf_app(smf_app_inst),
m_address(address) {
}
void IndividualSMContextApiImpl::release_sm_context(const std::string &smContextRef, const SmContextReleaseMessage &smContextReleaseMessage, Pistache::Http::ResponseWriter &response) {
void IndividualSMContextApiImpl::release_sm_context(
const std::string &smContextRef,
const SmContextReleaseMessage &smContextReleaseMessage,
Pistache::Http::ResponseWriter &response) {
//TODO: to be updated as update_sm_context_handler
Logger::smf_api_server().info("release_sm_context...");
//handle Nsmf_PDUSession_UpdateSMContext Request
Logger::smf_api_server().info("Received a PDUSession_UpdateSMContext Request: PDU Session Release request from AMF.");
Logger::smf_api_server().info(
"Received a PDUSession_UpdateSMContext Request: PDU Session Release request from AMF.");
//Get the SmContextUpdateData from this message and process in smf_app
smf::pdu_session_update_sm_context_request sm_context_req_msg = { };
SmContextReleaseData smContextReleaseData = smContextReleaseMessage.getJsonData();
SmContextReleaseData smContextReleaseData = smContextReleaseMessage
.getJsonData();
if (smContextReleaseData.n2SmInfoIsSet()) {
//N2 SM (for Session establishment)
std::string n2_sm_information = smContextReleaseMessage.getBinaryDataN2SmInformation();
std::string n2_sm_information = smContextReleaseMessage
.getBinaryDataN2SmInformation();
//std::string n2_sm_information = (smContextUpdateData.getN2SmInfo()).getContentId();
std::string n2_sm_msg_hex;
m_smf_app->convert_string_2_hex(n2_sm_information, n2_sm_msg_hex);
Logger::smf_api_server().debug("smContextMessage, n2 sm information %s", n2_sm_information.c_str());
Logger::smf_api_server().debug("smContextMessage, n2 sm information %s",
n2_sm_information.c_str());
std::string n2_sm_info_type = smContextReleaseData.getN2SmInfoType();
sm_context_req_msg.set_n2_sm_information(n2_sm_msg_hex);
sm_context_req_msg.set_n2_sm_info_type(n2_sm_info_type);
......@@ -79,31 +88,44 @@ void IndividualSMContextApiImpl::release_sm_context(const std::string &smContext
}
void IndividualSMContextApiImpl::retrieve_sm_context(const std::string &smContextRef, const SmContextRetrieveData &smContextRetrieveData, Pistache::Http::ResponseWriter &response) {
void IndividualSMContextApiImpl::retrieve_sm_context(
const std::string &smContextRef,
const SmContextRetrieveData &smContextRetrieveData,
Pistache::Http::ResponseWriter &response) {
Logger::smf_api_server().info("retrieve_sm_context...");
response.send(Pistache::Http::Code::Ok, "Retrieve_sm_context API has not been implemented yet!\n");
response.send(Pistache::Http::Code::Ok,
"Retrieve_sm_context API has not been implemented yet!\n");
}
void IndividualSMContextApiImpl::update_sm_context(const std::string &smContextRef, const SmContextUpdateMessage &smContextUpdateMessage, Pistache::Http::ResponseWriter &response) {
void IndividualSMContextApiImpl::update_sm_context(
const std::string &smContextRef,
const SmContextUpdateMessage &smContextUpdateMessage,
Pistache::Http::ResponseWriter &response) {
//Get the SmContextUpdateData from this message and process in smf_app
Logger::smf_api_server().info("Received a PDUSession_UpdateSMContext Request from AMF.");
Logger::smf_api_server().info(
"Received a PDUSession_UpdateSMContext Request from AMF.");
smf::pdu_session_update_sm_context_request sm_context_req_msg = { };
SmContextUpdateData smContextUpdateData = smContextUpdateMessage.getJsonData();
SmContextUpdateData smContextUpdateData =
smContextUpdateMessage.getJsonData();
if (smContextUpdateData.n2SmInfoIsSet()) {
//N2 SM (for Session establishment)
std::string n2_sm_information = smContextUpdateMessage.getBinaryDataN2SmInformation();
Logger::smf_api_server().debug("smContextMessage, n2 sm information %s", n2_sm_information.c_str());
std::string n2_sm_information = smContextUpdateMessage
.getBinaryDataN2SmInformation();
Logger::smf_api_server().debug("smContextMessage, n2 sm information %s",
n2_sm_information.c_str());
std::string n2_sm_info_type = smContextUpdateData.getN2SmInfoType();
sm_context_req_msg.set_n2_sm_information(n2_sm_information);
sm_context_req_msg.set_n2_sm_info_type(n2_sm_info_type);
} else if (smContextUpdateData.n1SmMsgIsSet()) {
//N1 SM (for session modification)
std::string n1_sm_message = smContextUpdateMessage.getBinaryDataN1SmMessage();
Logger::smf_api_server().debug("smContextMessage, n1 sm message %s", n1_sm_message.c_str());
std::string n1_sm_message =
smContextUpdateMessage.getBinaryDataN1SmMessage();
Logger::smf_api_server().debug("smContextMessage, n1 sm message %s",
n1_sm_message.c_str());
sm_context_req_msg.set_n1_sm_message(n1_sm_message);
}
//Step 2. TODO: initialize necessary values for sm context req from smContextUpdateData
......@@ -137,7 +159,11 @@ void IndividualSMContextApiImpl::update_sm_context(const std::string &smContextR
//step 7a, SM Context ID, N2 SM information, UE location information
//Step 11, SM Context ID, N1 SM (PDU Session Modification Command ACK), User location
//Step 3. Handle the itti_n11_update_sm_context_request message in smf_app
std::shared_ptr<itti_n11_update_sm_context_request> itti_msg = std::make_shared<itti_n11_update_sm_context_request>(TASK_SMF_N11, TASK_SMF_APP, response, smContextRef);
std::shared_ptr<itti_n11_update_sm_context_request> itti_msg =
std::make_shared<itti_n11_update_sm_context_request>(TASK_SMF_N11,
TASK_SMF_APP,
response,
smContextRef);
itti_msg->req = sm_context_req_msg;
itti_msg->scid = smContextRef;
m_smf_app->handle_pdu_session_update_sm_context_request(itti_msg);
......
......@@ -66,15 +66,24 @@ namespace api {
using namespace oai::smf_server::model;
class IndividualSMContextApiImpl : public oai::smf_server::api::IndividualSMContextApi {
class IndividualSMContextApiImpl :
public oai::smf_server::api::IndividualSMContextApi {
public:
IndividualSMContextApiImpl(std::shared_ptr<Pistache::Rest::Router>, smf::smf_app *smf_app_inst, std::string address);
IndividualSMContextApiImpl(std::shared_ptr<Pistache::Rest::Router>,
smf::smf_app *smf_app_inst, std::string address);
~IndividualSMContextApiImpl() {
}
void release_sm_context(const std::string &smContextRef, const SmContextReleaseMessage &smContextReleaseMessage, Pistache::Http::ResponseWriter &response);
void retrieve_sm_context(const std::string &smContextRef, const SmContextRetrieveData &smContextRetrieveData, Pistache::Http::ResponseWriter &response);
void update_sm_context(const std::string &smContextRef, const SmContextUpdateMessage &smContextUpdateMessage, Pistache::Http::ResponseWriter &response);
void release_sm_context(
const std::string &smContextRef,
const SmContextReleaseMessage &smContextReleaseMessage,
Pistache::Http::ResponseWriter &response);
void retrieve_sm_context(const std::string &smContextRef,
const SmContextRetrieveData &smContextRetrieveData,
Pistache::Http::ResponseWriter &response);
void update_sm_context(const std::string &smContextRef,
const SmContextUpdateMessage &smContextUpdateMessage,
Pistache::Http::ResponseWriter &response);
private:
smf::smf_app *m_smf_app;
std::string m_address;
......
......@@ -18,16 +18,21 @@ namespace api {
using namespace oai::smf_server::model;
PDUSessionsCollectionApiImpl::PDUSessionsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr, smf::smf_app *smf_app_inst, std::string address)
PDUSessionsCollectionApiImpl::PDUSessionsCollectionApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr, smf::smf_app *smf_app_inst,
std::string address)
:
PDUSessionsCollectionApi(rtr),
m_smf_app(smf_app_inst),
m_address(address) {
}
void PDUSessionsCollectionApiImpl::post_pdu_sessions(const PduSessionCreateData &pduSessionCreateData, Pistache::Http::ResponseWriter &response) {
void PDUSessionsCollectionApiImpl::post_pdu_sessions(
const PduSessionCreateData &pduSessionCreateData,
Pistache::Http::ResponseWriter &response) {
Logger::smf_api_server().info("post_pdu_sessions...");
response.send(Pistache::Http::Code::Ok, "Post_pdu_sessions API has not been implemented yet!\n");
response.send(Pistache::Http::Code::Ok,
"Post_pdu_sessions API has not been implemented yet!\n");
}
......
......@@ -40,13 +40,16 @@ namespace api {
using namespace oai::smf_server::model;
class PDUSessionsCollectionApiImpl : public oai::smf_server::api::PDUSessionsCollectionApi {
class PDUSessionsCollectionApiImpl :
public oai::smf_server::api::PDUSessionsCollectionApi {
public:
PDUSessionsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router>, smf::smf_app *smf_app_inst, std::string address);
PDUSessionsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router>,
smf::smf_app *smf_app_inst, std::string address);
~PDUSessionsCollectionApiImpl() {
}
void post_pdu_sessions(const PduSessionCreateData &pduSessionCreateData, Pistache::Http::ResponseWriter &response);
void post_pdu_sessions(const PduSessionCreateData &pduSessionCreateData,
Pistache::Http::ResponseWriter &response);
private:
smf::smf_app *m_smf_app;
std::string m_address;
......
......@@ -43,7 +43,9 @@ namespace api {
using namespace oai::smf_server::model;
SMContextsCollectionApiImpl::SMContextsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr, smf::smf_app *smf_app_inst, std::string address)
SMContextsCollectionApiImpl::SMContextsCollectionApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr, smf::smf_app *smf_app_inst,
std::string address)
:
SMContextsCollectionApi(rtr),
m_smf_app(smf_app_inst),
......@@ -52,7 +54,9 @@ SMContextsCollectionApiImpl::SMContextsCollectionApiImpl(std::shared_ptr<Pistach
{
}
void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smContextMessage, Pistache::Http::ResponseWriter &response) {
void SMContextsCollectionApiImpl::post_sm_contexts(
const SmContextMessage &smContextMessage,
Pistache::Http::ResponseWriter &response) {
Logger::smf_api_server().info("PDU Session Create SM Context Request ...");
......@@ -64,10 +68,12 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
std::string n1_sm_msg = smContextMessage.getBinaryDataN1SmMessage();
std::string n1_sm_msg_hex;
m_smf_app->convert_string_2_hex(n1_sm_msg, n1_sm_msg_hex);
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
Logger::smf_api_server().debug("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");
smf::pdu_session_create_sm_context_request sm_context_req_msg = { };
//set N1 SM Message
......@@ -83,27 +89,39 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
smf_string_to_supi(&supi, supi_str.c_str());
sm_context_req_msg.set_supi(supi);
sm_context_req_msg.set_supi_prefix(supi_prefix);
Logger::smf_api_server().debug("SmContextCreateData, supi %s, prefix %s, imsi %s", 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
Logger::smf_api_server().debug("SmContextCreateData, dnn %s", 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());
//S-Nssai
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());
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());
sm_context_req_msg.set_snssai(snssai);
//PDU session ID
Logger::smf_api_server().debug("SmContextCreateData, PDU SessionID %d", smContextCreateData.getPduSessionId());
Logger::smf_api_server().debug("SmContextCreateData, PDU SessionID %d",
smContextCreateData.getPduSessionId());
sm_context_req_msg.set_pdu_session_id(smContextCreateData.getPduSessionId());
//AMF ID (ServingNFId)
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
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
//Request Type
Logger::smf_api_server().debug("SmContextCreateData, RequestType %s", 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());
//PCF ID
// Priority Access
......@@ -120,8 +138,10 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//PCFId
// DNN Selection Mode
Logger::smf_api_server().debug("SmContextCreateData, SelMode %s", smContextCreateData.getSelMode().c_str());
sm_context_req_msg.set_dnn_selection_mode(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());
//Subscription for PDU Session Status Notification
// Trace requirement
......@@ -135,7 +155,10 @@ void SMContextsCollectionApiImpl::post_sm_contexts(const SmContextMessage &smCon
//Extended protocol configuration options (Optional) e.g, FOR DHCP
//Step 3. Handle the pdu_session_create_sm_context_request message in smf_app
std::shared_ptr<itti_n11_create_sm_context_request> itti_msg = std::make_shared<itti_n11_create_sm_context_request>(TASK_SMF_N11, TASK_SMF_APP, response);
std::shared_ptr<itti_n11_create_sm_context_request> itti_msg =
std::make_shared<itti_n11_create_sm_context_request>(TASK_SMF_N11,
TASK_SMF_APP,
response);
itti_msg->req = sm_context_req_msg;
m_smf_app->handle_pdu_session_create_sm_context_request(itti_msg);
......
......@@ -60,13 +60,16 @@ namespace api {
using namespace oai::smf_server::model;
class SMContextsCollectionApiImpl : public oai::smf_server::api::SMContextsCollectionApi {
class SMContextsCollectionApiImpl :
public oai::smf_server::api::SMContextsCollectionApi {
public:
SMContextsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router>, smf::smf_app *smf_app_inst, std::string address);
SMContextsCollectionApiImpl(std::shared_ptr<Pistache::Rest::Router>,
smf::smf_app *smf_app_inst, std::string address);
~SMContextsCollectionApiImpl() {
}
void post_sm_contexts(const SmContextMessage &smContextMessage, Pistache::Http::ResponseWriter &response);
void post_sm_contexts(const SmContextMessage &smContextMessage,
Pistache::Http::ResponseWriter &response);
private:
smf::smf_app *m_smf_app;
std::string m_address;
......
......@@ -54,10 +54,15 @@ class SMFApiServer {
m_httpEndpoint(std::make_shared<Pistache::Http::Endpoint>(address)) {
m_router = std::make_shared<Pistache::Rest::Router>();
m_address = address.host() + ":" + (address.port()).toString();
m_individualPDUSessionHSMFApiImpl = std::make_shared<IndividualPDUSessionHSMFApiImpl>(m_router, smf_app_inst, m_address);
m_individualSMContextApiImpl = std::make_shared<IndividualSMContextApiImpl>(m_router, smf_app_inst, m_address);
m_pduSessionsCollectionApiImpl = std::make_shared<PDUSessionsCollectionApiImpl>(m_router, smf_app_inst, m_address);
m_smContextsCollectionApiImpl = std::make_shared<SMContextsCollectionApiImpl>(m_router, smf_app_inst, m_address);
m_individualPDUSessionHSMFApiImpl = std::make_shared<
IndividualPDUSessionHSMFApiImpl>(m_router, smf_app_inst, m_address);
m_individualSMContextApiImpl = std::make_shared<IndividualSMContextApiImpl>(
m_router, smf_app_inst, m_address);
m_pduSessionsCollectionApiImpl = std::make_shared<
PDUSessionsCollectionApiImpl>(m_router, smf_app_inst, m_address);
m_smContextsCollectionApiImpl =
std::make_shared<SMContextsCollectionApiImpl>(m_router, smf_app_inst,
m_address);
}
void init(size_t thr = 1);
......
......@@ -148,8 +148,12 @@ typedef struct protocol_configuration_options_s {
typedef uint8_t packet_flow_identifier_t;
int encode_packet_flow_identifier_ie(packet_flow_identifier_t *packetflowidentifier, const bool iei_present, uint8_t *buffer, const uint32_t len);
int decode_packet_flow_identifier_ie(packet_flow_identifier_t *packetflowidentifier, const bool iei_present, uint8_t *buffer, const uint32_t len);
int encode_packet_flow_identifier_ie(
packet_flow_identifier_t *packetflowidentifier, const bool iei_present,
uint8_t *buffer, const uint32_t len);
int decode_packet_flow_identifier_ie(
packet_flow_identifier_t *packetflowidentifier, const bool iei_present,
uint8_t *buffer, const uint32_t len);
//------------------------------------------------------------------------------
// 10.5.6.12 Traffic Flow Template
......
......@@ -60,8 +60,14 @@ struct pfcp_exception : public std::exception {
struct pfcp_msg_bad_length_exception : public pfcp_exception {
public:
pfcp_msg_bad_length_exception(const uint8_t msg_type, const uint16_t hdr_size, const uint16_t ie_size, const uint16_t check_ie_size, const char *file, const int line) throw () {
phrase = fmt::format("PFCP msg {} Bad Length hdr.length {}/ sum ie {} / check sum ie {} Exception {}:{}", msg_type, hdr_size, ie_size, check_ie_size, file, line);
pfcp_msg_bad_length_exception(const uint8_t msg_type, const uint16_t hdr_size,
const uint16_t ie_size,
const uint16_t check_ie_size, const char *file,
const int line) throw () {
phrase =
fmt::format(
"PFCP msg {} Bad Length hdr.length {}/ sum ie {} / check sum ie {} Exception {}:{}",
msg_type, hdr_size, ie_size, check_ie_size, file, line);
}
pfcp_msg_bad_length_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -72,8 +78,12 @@ struct pfcp_msg_bad_length_exception : public pfcp_exception {
struct pfcp_msg_unimplemented_ie_exception : public pfcp_exception {
public:
pfcp_msg_unimplemented_ie_exception(const uint8_t msg_type, const uint16_t ie_type, const uint8_t instance = 0) throw () {
phrase = fmt::format("PFCP msg {} Unimplemented {} IE Instance {} Exception", msg_type, ie_type, instance);
pfcp_msg_unimplemented_ie_exception(const uint8_t msg_type,
const uint16_t ie_type,
const uint8_t instance = 0) throw () {
phrase = fmt::format(
"PFCP msg {} Unimplemented {} IE Instance {} Exception", msg_type,
ie_type, instance);
}
pfcp_msg_unimplemented_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -84,8 +94,10 @@ struct pfcp_msg_unimplemented_ie_exception : public pfcp_exception {
struct pfcp_msg_illegal_ie_exception : public pfcp_exception {
public:
pfcp_msg_illegal_ie_exception(const uint8_t msg_type, const uint16_t ie_type, const char *file, const int line) throw () {
phrase = fmt::format("PFCP msg {} Illegal IE {} Exception {}:{}", msg_type, ie_type, file, line);
pfcp_msg_illegal_ie_exception(const uint8_t msg_type, const uint16_t ie_type,
const char *file, const int line) throw () {
phrase = fmt::format("PFCP msg {} Illegal IE {} Exception {}:{}", msg_type,
ie_type, file, line);
}
pfcp_msg_illegal_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -130,10 +142,12 @@ struct pfcp_tlv_exception : public pfcp_ie_exception {
struct pfcp_tlv_bad_length_exception : public pfcp_tlv_exception {
public:
pfcp_tlv_bad_length_exception(uint16_t ie_type, uint16_t ie_length, const char *file, const int line) throw ()
pfcp_tlv_bad_length_exception(uint16_t ie_type, uint16_t ie_length,
const char *file, const int line) throw ()
:
pfcp_tlv_exception(ie_type) {
phrase = fmt::format("PFCP IE TLV {} Bad Length {} Exception {}:{}", ie_type, ie_length, file, line);
phrase = fmt::format("PFCP IE TLV {} Bad Length {} Exception {}:{}",
ie_type, ie_length, file, line);
}
virtual ~pfcp_tlv_bad_length_exception() throw () {
}
......@@ -144,7 +158,8 @@ struct pfcp_ie_value_exception : public pfcp_ie_exception {
pfcp_ie_value_exception(uint16_t ie_type, const char *field) throw ()
:
pfcp_ie_exception(ie_type) {
phrase = fmt::format("PFCP IE {} Bad Value of {} Exception", ie_type, field);
phrase = fmt::format("PFCP IE {} Bad Value of {} Exception", ie_type,
field);
}
virtual ~pfcp_ie_value_exception() throw () {
}
......@@ -402,9 +417,13 @@ struct fteid_s {
uint8_t choose_id;
bool operator==(const struct fteid_s &f) const {
return (teid == f.teid) and (ipv4_address.s_addr == f.ipv4_address.s_addr) and (chid == f.chid) and (ch == f.ch) and (choose_id == f.choose_id)
and (ipv6_address.s6_addr32[0] == f.ipv6_address.s6_addr32[0]) and (ipv6_address.s6_addr32[1] == f.ipv6_address.s6_addr32[1]) and (ipv6_address.s6_addr32[2] == f.ipv6_address.s6_addr32[2])
and (ipv6_address.s6_addr32[3] == f.ipv6_address.s6_addr32[3]) and (v4 == f.v4) and (v6 == f.v6);
return (teid == f.teid) and (ipv4_address.s_addr == f.ipv4_address.s_addr)
and (chid == f.chid) and (ch == f.ch) and (choose_id == f.choose_id)
and (ipv6_address.s6_addr32[0] == f.ipv6_address.s6_addr32[0])
and (ipv6_address.s6_addr32[1] == f.ipv6_address.s6_addr32[1])
and (ipv6_address.s6_addr32[2] == f.ipv6_address.s6_addr32[2])
and (ipv6_address.s6_addr32[3] == f.ipv6_address.s6_addr32[3])
and (v4 == f.v4) and (v6 == f.v6);
}
bool is_zero() const {
return ((!v4) and (!v6));
......@@ -813,8 +832,12 @@ typedef struct fseid_s {
struct in6_addr ipv6_address;
bool operator==(const struct fseid_s &i) const {
if ((i.seid == this->seid) && (i.v4 == this->v4) && (i.ipv4_address.s_addr == this->ipv4_address.s_addr) && (i.v6 == this->v6) && (i.ipv6_address.s6_addr32[0] == this->ipv6_address.s6_addr32[0])
&& (i.ipv6_address.s6_addr32[1] == this->ipv6_address.s6_addr32[1]) && (i.ipv6_address.s6_addr32[2] == this->ipv6_address.s6_addr32[2])
if ((i.seid == this->seid) && (i.v4 == this->v4)
&& (i.ipv4_address.s_addr == this->ipv4_address.s_addr)
&& (i.v6 == this->v6)
&& (i.ipv6_address.s6_addr32[0] == this->ipv6_address.s6_addr32[0])
&& (i.ipv6_address.s6_addr32[1] == this->ipv6_address.s6_addr32[1])
&& (i.ipv6_address.s6_addr32[2] == this->ipv6_address.s6_addr32[2])
&& (i.ipv6_address.s6_addr32[3] == this->ipv6_address.s6_addr32[3])) {
return true;
} else {
......@@ -835,15 +858,19 @@ typedef struct fseid_s {
} else if (this->v4)
return true;
if (i.v6 == this->v6) {
uint64_t i64 = ((uint64_t) i.ipv6_address.s6_addr32[0] << 32) | ((uint64_t) i.ipv6_address.s6_addr32[1]);
uint64_t this64 = ((uint64_t) this->ipv6_address.s6_addr32[0] << 32) | ((uint64_t) this->ipv6_address.s6_addr32[1]);
uint64_t i64 = ((uint64_t) i.ipv6_address.s6_addr32[0] << 32)
| ((uint64_t) i.ipv6_address.s6_addr32[1]);
uint64_t this64 = ((uint64_t) this->ipv6_address.s6_addr32[0] << 32)
| ((uint64_t) this->ipv6_address.s6_addr32[1]);
if (i64 < this64)
return true;
else if (i64 > this64)
return false;
i64 = ((uint64_t) i.ipv6_address.s6_addr32[2] << 32) | ((uint64_t) i.ipv6_address.s6_addr32[3]);
this64 = ((uint64_t) this->ipv6_address.s6_addr32[2] << 32) | ((uint64_t) this->ipv6_address.s6_addr32[3]);
i64 = ((uint64_t) i.ipv6_address.s6_addr32[2] << 32)
| ((uint64_t) i.ipv6_address.s6_addr32[3]);
this64 = ((uint64_t) this->ipv6_address.s6_addr32[2] << 32)
| ((uint64_t) this->ipv6_address.s6_addr32[3]);
if (i64 < this64)
return true;
else if (i64 > this64)
......@@ -873,9 +900,13 @@ struct node_id_s {
} u1;
std::string fqdn; // should be in union but problem with virtual ~
bool operator==(const struct node_id_s &i) const {
if ((i.node_id_type == this->node_id_type) && (i.u1.ipv4_address.s_addr == this->u1.ipv4_address.s_addr) && (i.fqdn == this->fqdn)
&& (i.u1.ipv6_address.s6_addr32[0] == this->u1.ipv6_address.s6_addr32[0]) && (i.u1.ipv6_address.s6_addr32[1] == this->u1.ipv6_address.s6_addr32[1])
&& (i.u1.ipv6_address.s6_addr32[2] == this->u1.ipv6_address.s6_addr32[2]) && (i.u1.ipv6_address.s6_addr32[3] == this->u1.ipv6_address.s6_addr32[3])) {
if ((i.node_id_type == this->node_id_type)
&& (i.u1.ipv4_address.s_addr == this->u1.ipv4_address.s_addr)
&& (i.fqdn == this->fqdn)
&& (i.u1.ipv6_address.s6_addr32[0] == this->u1.ipv6_address.s6_addr32[0])
&& (i.u1.ipv6_address.s6_addr32[1] == this->u1.ipv6_address.s6_addr32[1])
&& (i.u1.ipv6_address.s6_addr32[2] == this->u1.ipv6_address.s6_addr32[2])
&& (i.u1.ipv6_address.s6_addr32[3] == this->u1.ipv6_address.s6_addr32[3])) {
return true;
} else {
return false;
......@@ -2017,7 +2048,9 @@ struct hash<pfcp::fseid_t> {
return h;
}
if (k.v6) {
h = k.seid ^ (k.ipv6_address.s6_addr32[0] ^ k.ipv6_address.s6_addr32[1] ^ k.ipv6_address.s6_addr32[2] ^ k.ipv6_address.s6_addr32[3]);
h = k.seid
^ (k.ipv6_address.s6_addr32[0] ^ k.ipv6_address.s6_addr32[1]
^ k.ipv6_address.s6_addr32[2] ^ k.ipv6_address.s6_addr32[3]);
return h;
}
return k.seid;
......@@ -2038,7 +2071,8 @@ class hash<pfcp::node_id_t> {
return h;
break;
case pfcp::NODE_ID_TYPE_IPV6_ADDRESS:
h = k.u1.ipv6_address.s6_addr32[0] ^ k.u1.ipv6_address.s6_addr32[1] ^ k.u1.ipv6_address.s6_addr32[2] ^ k.u1.ipv6_address.s6_addr32[3];
h = k.u1.ipv6_address.s6_addr32[0] ^ k.u1.ipv6_address.s6_addr32[1]
^ k.u1.ipv6_address.s6_addr32[2] ^ k.u1.ipv6_address.s6_addr32[3];
return h;
break;
case pfcp::NODE_ID_TYPE_FQDN:
......
......@@ -62,8 +62,10 @@ struct gtpc_exception : public std::exception {
struct gtpc_msg_bad_length_exception : public gtpc_exception {
public:
gtpc_msg_bad_length_exception(const uint8_t msg_type, const uint16_t msg_size) throw () {
phrase = fmt::format("GTPV2-C msg {} Bad Length {} Exception", msg_type, msg_size);
gtpc_msg_bad_length_exception(const uint8_t msg_type,
const uint16_t msg_size) throw () {
phrase = fmt::format("GTPV2-C msg {} Bad Length {} Exception", msg_type,
msg_size);
}
gtpc_msg_bad_length_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -74,8 +76,12 @@ struct gtpc_msg_bad_length_exception : public gtpc_exception {
struct gtpc_msg_unimplemented_ie_exception : public gtpc_exception {
public:
gtpc_msg_unimplemented_ie_exception(const uint8_t msg_type, const uint8_t ie_type, const uint8_t instance = 0) throw () {
phrase = fmt::format("GTPV2-C msg {} Unimplemented {} IE Instance {} Exception", msg_type, ie_type, instance);
gtpc_msg_unimplemented_ie_exception(const uint8_t msg_type,
const uint8_t ie_type,
const uint8_t instance = 0) throw () {
phrase = fmt::format(
"GTPV2-C msg {} Unimplemented {} IE Instance {} Exception", msg_type,
ie_type, instance);
}
gtpc_msg_unimplemented_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -86,8 +92,10 @@ struct gtpc_msg_unimplemented_ie_exception : public gtpc_exception {
struct gtpc_msg_illegal_ie_exception : public gtpc_exception {
public:
gtpc_msg_illegal_ie_exception(const uint8_t msg_type, const uint8_t ie_type, const char *file, const int line) throw () {
phrase = fmt::format("GTPV2-C msg {} Illegal IE {} Exception {}:{}", msg_type, ie_type, file, line);
gtpc_msg_illegal_ie_exception(const uint8_t msg_type, const uint8_t ie_type,
const char *file, const int line) throw () {
phrase = fmt::format("GTPV2-C msg {} Illegal IE {} Exception {}:{}",
msg_type, ie_type, file, line);
}
gtpc_msg_illegal_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -111,10 +119,12 @@ struct gtpc_ie_exception : public gtpc_exception {
struct gtpc_missing_ie_exception : public gtpc_exception {
public:
gtpc_missing_ie_exception(uint8_t gtpc_msg, uint8_t ie_type) throw () {
phrase = fmt::format("GTPV2-C msg {} missing IE {} Exception", gtpc_msg, ie_type);
phrase = fmt::format("GTPV2-C msg {} missing IE {} Exception", gtpc_msg,
ie_type);
}
gtpc_missing_ie_exception(const char *gtpc_msg, const char *ie_type) throw () {
phrase = fmt::format("GTPV2-C msg {} missing IE {} Exception", gtpc_msg, ie_type);
phrase = fmt::format("GTPV2-C msg {} missing IE {} Exception", gtpc_msg,
ie_type);
}
gtpc_missing_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -161,7 +171,8 @@ struct gtpc_tlv_bad_instance_exception : public gtpc_tlv_exception {
gtpc_tlv_bad_instance_exception(uint8_t ie_type, uint8_t ie_instance) throw ()
:
gtpc_tlv_exception(ie_type) {
phrase = fmt::format("GTPV2-C IE TLV {} Bad Instance {} Exception", ie_type, ie_instance);
phrase = fmt::format("GTPV2-C IE TLV {} Bad Instance {} Exception", ie_type,
ie_instance);
}
virtual ~gtpc_tlv_bad_instance_exception() throw () {
}
......@@ -172,7 +183,8 @@ struct gtpc_ie_value_exception : public gtpc_ie_exception {
gtpc_ie_value_exception(uint8_t ie_type, const char *field) throw ()
:
gtpc_ie_exception(ie_type) {
phrase = fmt::format("GTPV2-C IE {} Bad Value of {} Exception", ie_type, field);
phrase = fmt::format("GTPV2-C IE {} Bad Value of {} Exception", ie_type,
field);
}
virtual ~gtpc_ie_value_exception() throw () {
}
......@@ -928,7 +940,8 @@ enum pdn_type_e {
PDN_TYPE_E_IPV4V6 = 3,
PDN_TYPE_E_NON_IP = 4,
};
static const std::vector<std::string> pdn_type_e2str = { "Error", "IPV4", "IPV6", "IPV4V6", "NON_IP" };
static const std::vector<std::string> pdn_type_e2str = { "Error", "IPV4",
"IPV6", "IPV4V6", "NON_IP" };
typedef struct pdn_type_s {
uint8_t pdn_type;
......@@ -973,7 +986,8 @@ struct paa_s {
return false;
break;
case PDN_TYPE_E_IPV6:
if (ipv6_address.s6_addr32[0] | ipv6_address.s6_addr32[1] | ipv6_address.s6_addr32[2] | ipv6_address.s6_addr32[3])
if (ipv6_address.s6_addr32[0] | ipv6_address.s6_addr32[1]
| ipv6_address.s6_addr32[2] | ipv6_address.s6_addr32[3])
return true;
return false;
break;
......@@ -981,7 +995,8 @@ struct paa_s {
// TODO
if (ipv4_address.s_addr)
return true;
if (ipv6_address.s6_addr32[0] | ipv6_address.s6_addr32[1] | ipv6_address.s6_addr32[2] | ipv6_address.s6_addr32[3])
if (ipv6_address.s6_addr32[0] | ipv6_address.s6_addr32[1]
| ipv6_address.s6_addr32[2] | ipv6_address.s6_addr32[3])
return true;
return false;
break;
......@@ -1013,7 +1028,8 @@ typedef struct bearer_qos_s {
uint64_t guaranted_bit_rate_for_downlink;
bool operator==(const struct bearer_qos_s &q) const {
return ((q.label_qci == label_qci) && (q.pl == pl) && (q.pvi == pvi) && (q.pci == pci));
return ((q.label_qci == label_qci) && (q.pl == pl) && (q.pvi == pvi)
&& (q.pci == pci));
}
//------------------------------------------------------------------------------
std::string toString() const {
......@@ -1021,7 +1037,8 @@ typedef struct bearer_qos_s {
s.append("MBR UL=").append(std::to_string(maximum_bit_rate_for_uplink));
s.append(", MBR DL=").append(std::to_string(maximum_bit_rate_for_downlink));
s.append(", GBR UL=").append(std::to_string(guaranted_bit_rate_for_uplink));
s.append(", GBR DL=").append(std::to_string(guaranted_bit_rate_for_downlink));
s.append(", GBR DL=").append(
std::to_string(guaranted_bit_rate_for_downlink));
s.append(", PCI=").append(std::to_string(pci));
s.append(", PL=").append(std::to_string(pl));
s.append(", PVI=").append(std::to_string(pvi));
......@@ -1181,9 +1198,12 @@ typedef struct gtpc2c_ecgi_field_s {
std::string mncs = conv::mncToString(mnc_digit_1, mnc_digit_2, mnc_digit_3);
s.append("mcc=").append(mccs).append(", MNC=").append(mncs);
s.append(", ECI=").append(std::to_string(eci));
uint32_t we_utran_cell_identifier = static_cast<uint32_t>(e_utran_cell_identifier[0]) << 16;
we_utran_cell_identifier |= (static_cast<uint32_t>(e_utran_cell_identifier[1]) << 8);
we_utran_cell_identifier |= static_cast<uint32_t>(e_utran_cell_identifier[2]);
uint32_t we_utran_cell_identifier =
static_cast<uint32_t>(e_utran_cell_identifier[0]) << 16;
we_utran_cell_identifier |=
(static_cast<uint32_t>(e_utran_cell_identifier[1]) << 8);
we_utran_cell_identifier |=
static_cast<uint32_t>(e_utran_cell_identifier[2]);
s.append(", EUCI=").append(std::to_string(we_utran_cell_identifier));
return s;
}
......@@ -1315,7 +1335,8 @@ struct interface_type_s {
//------------------------------------------------------------------------------
std::string toString() const {
if ((interface_type >= INTERFACE_TYPE_MIN) && (interface_type <= INTERFACE_TYPE_MAX)) {
if ((interface_type >= INTERFACE_TYPE_MIN)
&& (interface_type <= INTERFACE_TYPE_MAX)) {
return std::string(interface_type2char[interface_type]);
} else {
return std::to_string(interface_type);
......@@ -1333,15 +1354,26 @@ struct fully_qualified_tunnel_endpoint_identifier_s {
struct in_addr ipv4_address;
struct in6_addr ipv6_address;
bool operator<(const struct fully_qualified_tunnel_endpoint_identifier_s &f) const {
return (teid_gre_key < f.teid_gre_key) or (ipv4_address.s_addr < f.ipv4_address.s_addr) or (interface_type < f.interface_type) or (v4 == f.v4) or (v6 == f.v6)
or (ipv6_address.s6_addr32[0] == f.ipv6_address.s6_addr32[0]) or (ipv6_address.s6_addr32[1] == f.ipv6_address.s6_addr32[1]) or (ipv6_address.s6_addr32[2] == f.ipv6_address.s6_addr32[2])
bool operator<(
const struct fully_qualified_tunnel_endpoint_identifier_s &f) const {
return (teid_gre_key < f.teid_gre_key)
or (ipv4_address.s_addr < f.ipv4_address.s_addr)
or (interface_type < f.interface_type) or (v4 == f.v4) or (v6 == f.v6)
or (ipv6_address.s6_addr32[0] == f.ipv6_address.s6_addr32[0])
or (ipv6_address.s6_addr32[1] == f.ipv6_address.s6_addr32[1])
or (ipv6_address.s6_addr32[2] == f.ipv6_address.s6_addr32[2])
or (ipv6_address.s6_addr32[3] == f.ipv6_address.s6_addr32[3]);
}
bool operator==(const struct fully_qualified_tunnel_endpoint_identifier_s &f) const {
return (teid_gre_key == f.teid_gre_key) and (ipv4_address.s_addr == f.ipv4_address.s_addr) and (interface_type == f.interface_type) and (ipv6_address.s6_addr32[0] == f.ipv6_address.s6_addr32[0])
and (ipv6_address.s6_addr32[1] == f.ipv6_address.s6_addr32[1]) and (ipv6_address.s6_addr32[2] == f.ipv6_address.s6_addr32[2]) and (ipv6_address.s6_addr32[3] == f.ipv6_address.s6_addr32[3])
bool operator==(
const struct fully_qualified_tunnel_endpoint_identifier_s &f) const {
return (teid_gre_key == f.teid_gre_key)
and (ipv4_address.s_addr == f.ipv4_address.s_addr)
and (interface_type == f.interface_type)
and (ipv6_address.s6_addr32[0] == f.ipv6_address.s6_addr32[0])
and (ipv6_address.s6_addr32[1] == f.ipv6_address.s6_addr32[1])
and (ipv6_address.s6_addr32[2] == f.ipv6_address.s6_addr32[2])
and (ipv6_address.s6_addr32[3] == f.ipv6_address.s6_addr32[3])
and (v4 == f.v4) and (v6 == f.v6);
}
//------------------------------------------------------------------------------
......
......@@ -60,8 +60,10 @@ struct gtpu_exception : public std::exception {
struct gtpu_msg_bad_length_exception : public gtpu_exception {
public:
gtpu_msg_bad_length_exception(const uint8_t msg_type, const uint16_t msg_size) throw () {
phrase = fmt::format("GTPV1-U msg {} Bad Length {} Exception", msg_type, msg_size);
gtpu_msg_bad_length_exception(const uint8_t msg_type,
const uint16_t msg_size) throw () {
phrase = fmt::format("GTPV1-U msg {} Bad Length {} Exception", msg_type,
msg_size);
}
gtpu_msg_bad_length_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -72,8 +74,12 @@ struct gtpu_msg_bad_length_exception : public gtpu_exception {
struct gtpu_msg_unimplemented_ie_exception : public gtpu_exception {
public:
gtpu_msg_unimplemented_ie_exception(const uint8_t msg_type, const uint8_t ie_type, const uint8_t instance = 0) throw () {
phrase = fmt::format("GTPV1-U msg {} Unimplemented {} IE Instance {} Exception", msg_type, ie_type, instance);
gtpu_msg_unimplemented_ie_exception(const uint8_t msg_type,
const uint8_t ie_type,
const uint8_t instance = 0) throw () {
phrase = fmt::format(
"GTPV1-U msg {} Unimplemented {} IE Instance {} Exception", msg_type,
ie_type, instance);
}
gtpu_msg_unimplemented_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -84,8 +90,10 @@ struct gtpu_msg_unimplemented_ie_exception : public gtpu_exception {
struct gtpu_msg_illegal_ie_exception : public gtpu_exception {
public:
gtpu_msg_illegal_ie_exception(const uint8_t msg_type, const uint8_t ie_type) throw () {
phrase = fmt::format("GTPV1-U msg {} Illegal {} Exception", msg_type, ie_type);
gtpu_msg_illegal_ie_exception(const uint8_t msg_type,
const uint8_t ie_type) throw () {
phrase = fmt::format("GTPV1-U msg {} Illegal {} Exception", msg_type,
ie_type);
}
gtpu_msg_illegal_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
......@@ -144,7 +152,8 @@ struct gtpu_ie_value_exception : public gtpu_ie_exception {
gtpu_ie_value_exception(uint8_t ie_type, const char *field) throw ()
:
gtpu_ie_exception(ie_type) {
phrase = fmt::format("GTPV1-U IE {} Bad Value of {} Exception", ie_type, field);
phrase = fmt::format("GTPV1-U IE {} Bad Value of {} Exception", ie_type,
field);
}
virtual ~gtpu_ie_value_exception() throw () {
}
......
......@@ -23,7 +23,7 @@
#define FILE_3GPP_29_502_SMF_SEEN
enum pdu_session_application_error_e {
PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR = 1,
PDU_SESSION_APPLICATION_ERROR_N1_SM_ERROR = 1,
PDU_SESSION_APPLICATION_ERROR_SNSSAI_DENIED = 2,
PDU_SESSION_APPLICATION_ERROR_DNN_DENIED = 3,
PDU_SESSION_APPLICATION_ERROR_PDUTYPE_DENIED = 4,
......@@ -60,105 +60,63 @@ enum pdu_session_application_error_e {
};
static const std::vector<std::string> pdu_session_application_error_e2str = {
"UNKNOWN ERROR",
"N1_SM_ERROR",
"SNSSAI_DENIED",
"DNN_DENIED",
"PDUTYPE_DENIED",
"SSC_DENIED",
"SUBSCRIPTION_DENIED",
"DNN_NOT_SUPPORTED",
"PDUTYPE_NOT_SUPPORTED",
"SSC_NOT_SUPPORTED",
"HOME_ROUTED_ROAMING_REQUIRED",
"OUT_OF_LADN_SERVICE_AREA",
"N2_SM_ERROR",
"PRIORITIZED_SERVICES_ONLY",
"PDU_SESSION_ANCHOR_CHANGE",
"TARGET_MME_CAPABILITY",
"NO_EPS_5GS_CONTINUITY",
"UNABLE_TO_PAGE_UE",
"UE_NOT_RESPONDING",
"REJECTED_BY_UE",
"REJECTED_DUE_VPLMN_POLICY",
"HO_TAU_IN_PROGRESS",
"INTEGRITY_PROTECTED_MDR_NOT_ACCEPTABLE",
"EBI_EXHAUSTED",
"EBI_REJECTED_LOCAL_POLICY",
"EBI_REJECTED_NO_N26",
"DEFAULT_EPS_BEARER_INACTIVE",
"HANDOVER_RESOURCE_ALLOCATION_FAILURE",
"CONTEXT_NOT_FOUND",
"INSUFFICIENT_RESOURCES_SLICE",
"INSUFFICIENT_RESOURCES_SLICE_DNN",
"DNN_CONGESTION",
"S_NSSAI_CONGESTION",
"PEER_NOT_RESPONDING",
"NETWORK_FAILURE"
};
"UNKNOWN ERROR", "N1_SM_ERROR", "SNSSAI_DENIED", "DNN_DENIED",
"PDUTYPE_DENIED", "SSC_DENIED", "SUBSCRIPTION_DENIED", "DNN_NOT_SUPPORTED",
"PDUTYPE_NOT_SUPPORTED", "SSC_NOT_SUPPORTED",
"HOME_ROUTED_ROAMING_REQUIRED", "OUT_OF_LADN_SERVICE_AREA", "N2_SM_ERROR",
"PRIORITIZED_SERVICES_ONLY", "PDU_SESSION_ANCHOR_CHANGE",
"TARGET_MME_CAPABILITY", "NO_EPS_5GS_CONTINUITY", "UNABLE_TO_PAGE_UE",
"UE_NOT_RESPONDING", "REJECTED_BY_UE", "REJECTED_DUE_VPLMN_POLICY",
"HO_TAU_IN_PROGRESS", "INTEGRITY_PROTECTED_MDR_NOT_ACCEPTABLE",
"EBI_EXHAUSTED", "EBI_REJECTED_LOCAL_POLICY", "EBI_REJECTED_NO_N26",
"DEFAULT_EPS_BEARER_INACTIVE", "HANDOVER_RESOURCE_ALLOCATION_FAILURE",
"CONTEXT_NOT_FOUND", "INSUFFICIENT_RESOURCES_SLICE",
"INSUFFICIENT_RESOURCES_SLICE_DNN", "DNN_CONGESTION", "S_NSSAI_CONGESTION",
"PEER_NOT_RESPONDING", "NETWORK_FAILURE" };
//6.1.6.3.12 Enumeration: N2SmInfoType @3GPP TS 29.502 V16.0.0
enum class n2_sm_info_type_e {
PDU_RES_SETUP_REQ = 1, //PDU Session Resource Setup Request Transfer
PDU_RES_SETUP_RSP = 2, //PDU Session Resource Setup Response Transfer
PDU_RES_SETUP_FAIL = 3, //PDU Session Resource Setup Unsuccessful Transfer
PDU_RES_REL_CMD = 4, //PDU Session Resource Release Command Transfer
PDU_RES_REL_RSP = 5, //PDU Session Resource Release Response Transfer
PDU_RES_MOD_REQ = 6, //PDU Session Resource Modify Request Transfer
PDU_RES_MOD_RSP = 7, //PDU Session Resource Modify Response Transfer
PDU_RES_MOD_FAIL = 8, //PDU Session Resource Modify Unsuccessful Transfer
PDU_RES_NTY = 9, //PDU Session Resource Notify Transfer
PDU_RES_NTY_REL = 10, //PDU Session Resource Notify Released Transfer
PDU_RES_MOD_IND = 11, //PDU Session Resource Modify Indication Transfer
PDU_RES_MOD_CFM = 12, //PDU Session Resource Modify Confirm Transfer
PATH_SWITCH_REQ = 13, //Path Switch Request Transfer
PATH_SWITCH_SETUP_FAIL = 14, //Path Switch Request Setup Failed Transfer
PATH_SWITCH_REQ_ACK = 15, //Path Switch Request Acknowledge Transfer
PATH_SWITCH_REQ_FAIL = 16, //Path Switch Request Unsuccessful Transfer
HANDOVER_REQUIRED = 17, //Handover Required Transfer
HANDOVER_CMD = 18, //Handover Command Transfer
HANDOVER_PREP_FAIL = 19, //Handover Preparation Unsuccessful Transfer
HANDOVER_REQ_ACK = 20, //Handover Request Acknowledge Transfer
HANDOVER_RES_ALLOC_FAIL = 21, //Handover Resource Allocation Unsuccessful Transfer
SECONDARY_RAT_USAGE = 22 //Secondary RAT Data Usage Report Transfer
PDU_RES_SETUP_REQ = 1, //PDU Session Resource Setup Request Transfer
PDU_RES_SETUP_RSP = 2, //PDU Session Resource Setup Response Transfer
PDU_RES_SETUP_FAIL = 3, //PDU Session Resource Setup Unsuccessful Transfer
PDU_RES_REL_CMD = 4, //PDU Session Resource Release Command Transfer
PDU_RES_REL_RSP = 5, //PDU Session Resource Release Response Transfer
PDU_RES_MOD_REQ = 6, //PDU Session Resource Modify Request Transfer
PDU_RES_MOD_RSP = 7, //PDU Session Resource Modify Response Transfer
PDU_RES_MOD_FAIL = 8, //PDU Session Resource Modify Unsuccessful Transfer
PDU_RES_NTY = 9, //PDU Session Resource Notify Transfer
PDU_RES_NTY_REL = 10, //PDU Session Resource Notify Released Transfer
PDU_RES_MOD_IND = 11, //PDU Session Resource Modify Indication Transfer
PDU_RES_MOD_CFM = 12, //PDU Session Resource Modify Confirm Transfer
PATH_SWITCH_REQ = 13, //Path Switch Request Transfer
PATH_SWITCH_SETUP_FAIL = 14, //Path Switch Request Setup Failed Transfer
PATH_SWITCH_REQ_ACK = 15, //Path Switch Request Acknowledge Transfer
PATH_SWITCH_REQ_FAIL = 16, //Path Switch Request Unsuccessful Transfer
HANDOVER_REQUIRED = 17, //Handover Required Transfer
HANDOVER_CMD = 18, //Handover Command Transfer
HANDOVER_PREP_FAIL = 19, //Handover Preparation Unsuccessful Transfer
HANDOVER_REQ_ACK = 20, //Handover Request Acknowledge Transfer
HANDOVER_RES_ALLOC_FAIL = 21, //Handover Resource Allocation Unsuccessful Transfer
SECONDARY_RAT_USAGE = 22 //Secondary RAT Data Usage Report Transfer
};
static const std::vector<std::string> n2_sm_info_type_e2str = {
"UNKNOWN_TYPE",
"PDU_RES_SETUP_REQ",
"PDU_RES_SETUP_RSP",
"PDU_RES_SETUP_FAIL",
"PDU_RES_REL_CMD",
"PDU_RES_REL_RSP",
"PDU_RES_MOD_REQ",
"PDU_RES_MOD_RSP",
"PDU_RES_MOD_FAIL",
"PDU_RES_NTY",
"PDU_RES_NTY_REL",
"PDU_RES_MOD_IND",
"PDU_RES_MOD_CFM",
"PATH_SWITCH_REQ",
"PATH_SWITCH_SETUP_FAIL",
"PATH_SWITCH_REQ_ACK",
"PATH_SWITCH_REQ_FAIL",
"HANDOVER_REQUIRED",
"HANDOVER_CMD",
"HANDOVER_PREP_FAIL",
"HANDOVER_REQ_ACK",
"HANDOVER_RES_ALLOC_FAIL",
"SECONDARY_RAT_USAGE"
};
static const std::vector<std::string> n2_sm_info_type_e2str = { "UNKNOWN_TYPE",
"PDU_RES_SETUP_REQ", "PDU_RES_SETUP_RSP", "PDU_RES_SETUP_FAIL",
"PDU_RES_REL_CMD", "PDU_RES_REL_RSP", "PDU_RES_MOD_REQ", "PDU_RES_MOD_RSP",
"PDU_RES_MOD_FAIL", "PDU_RES_NTY", "PDU_RES_NTY_REL", "PDU_RES_MOD_IND",
"PDU_RES_MOD_CFM", "PATH_SWITCH_REQ", "PATH_SWITCH_SETUP_FAIL",
"PATH_SWITCH_REQ_ACK", "PATH_SWITCH_REQ_FAIL", "HANDOVER_REQUIRED",
"HANDOVER_CMD", "HANDOVER_PREP_FAIL", "HANDOVER_REQ_ACK",
"HANDOVER_RES_ALLOC_FAIL", "SECONDARY_RAT_USAGE" };
enum class upCnx_state_e {
UPCNX_STATE_ACTIVATED = 0,
UPCNX_STATE_DEACTIVATED = 1,
UPCNX_STATE_ACTIVATING =2
UPCNX_STATE_DEACTIVATED = 1,
UPCNX_STATE_ACTIVATING = 2
};
static const std::vector<std::string> upCnx_state_e2str = {
"UPCNX_STATE_ACTIVATED",
"UPCNX_STATE_DEACTIVATED",
"UPCNX_STATE_ACTIVATING"
};
static const std::vector<std::string> upCnx_state_e2str =
{ "UPCNX_STATE_ACTIVATED", "UPCNX_STATE_DEACTIVATED",
"UPCNX_STATE_ACTIVATING" };
#endif
......@@ -30,7 +30,8 @@ enum ssc_mode_e {
SSC_MODE_2 = 2,
SSC_MODE_3 = 3,
};
static const std::vector<std::string> ssc_mode_e2str = { "Error", "SSC_MODE_1", "SSC_MODE_2", "SSC_MODE_3" };
static const std::vector<std::string> ssc_mode_e2str = { "Error", "SSC_MODE_1",
"SSC_MODE_2", "SSC_MODE_3" };
typedef struct ssc_mode_s {
uint8_t ssc_mode;
......
......@@ -32,7 +32,8 @@ enum preemtion_capability_e {
MAY_PREEMPT = 2
};
static const std::vector<std::string> preemtion_capability_e2str = { "Error", "NOT_PREEMPT", "MAY_PREEMPT" };
static const std::vector<std::string> preemtion_capability_e2str = { "Error",
"NOT_PREEMPT", "MAY_PREEMPT" };
//see section 5.5.4.1@TS 29.571
typedef struct arp_5gc_s {
......@@ -53,6 +54,7 @@ enum reflective_qos_attribute_e {
NO_RQOS = 2
};
static const std::vector<std::string> reflective_qos_attribute_e2str = { "ERROR", "RQOS", "NO_RQOS" };
static const std::vector<std::string> reflective_qos_attribute_e2str = {
"ERROR", "RQOS", "NO_RQOS" };
#endif
......@@ -24,7 +24,8 @@
Logger *Logger::m_singleton = NULL;
void Logger::_init(const char *app, const bool log_stdout, bool const log_rot_file) {
void Logger::_init(const char *app, const bool log_stdout,
bool const log_rot_file) {
int num_sinks = 0;
spdlog::set_async_mode(2048);
#if TRACE_IS_ON
......@@ -38,12 +39,16 @@ void Logger::_init(const char *app, const bool log_stdout, bool const log_rot_fi
#endif
if (log_stdout) {
std::string filename = fmt::format("./{}.log", app);
m_sinks.push_back(std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>());
m_sinks.push_back(
std::make_shared<spdlog::sinks::ansicolor_stdout_sink_mt>());
m_sinks[num_sinks++].get()->set_level(llevel);
}
if (log_rot_file) {
std::string filename = fmt::format("./{}.log", app);
m_sinks.push_back(std::make_shared<spdlog::sinks::rotating_file_sink_mt>(filename, 5 * 1024 * 1024, 3));
m_sinks.push_back(
std::make_shared<spdlog::sinks::rotating_file_sink_mt>(filename,
5 * 1024 * 1024,
3));
m_sinks[num_sinks++].get()->set_level(llevel);
}
......@@ -68,7 +73,8 @@ void Logger::_init(const char *app, const bool log_stdout, bool const log_rot_fi
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
_Logger::_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks, const char *pattern)
_Logger::_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks,
const char *pattern)
:
m_log(category, sinks.begin(), sinks.end()) {
m_log.set_pattern(pattern);
......
......@@ -41,7 +41,8 @@ class LoggerException : public std::runtime_error {
class _Logger {
public:
_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks, const char *pattern);
_Logger(const char *category, std::vector<spdlog::sink_ptr> &sinks,
const char *pattern);
void trace(const char *format, ...);
void trace(const std::string &format, ...);
......@@ -76,10 +77,12 @@ class _Logger {
class Logger {
public:
static void init(const char *app, const bool log_stdout, const bool log_rot_file) {
static void init(const char *app, const bool log_stdout,
const bool log_rot_file) {
singleton()._init(app, log_stdout, log_rot_file);
}
static void init(const std::string &app, const bool log_stdout, const bool log_rot_file) {
static void init(const std::string &app, const bool log_stdout,
const bool log_rot_file) {
init(app.c_str(), log_stdout, log_rot_file);
}
......
......@@ -20,29 +20,46 @@
*/
/*! \file itti_async_shell_cmd.hpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_ITTI_ASYNC_SHELL_CMD_SEEN
#define FILE_ITTI_ASYNC_SHELL_CMD_SEEN
#include "itti_msg.hpp"
class itti_async_shell_cmd : public itti_msg {
public:
itti_async_shell_cmd(const task_id_t origin, const task_id_t destination, const std::string& system_cmd, bool is_abort_on_error, const char * src_file, const int src_line):
itti_msg( ASYNC_SHELL_CMD, origin, destination), system_command(system_cmd), is_abort_on_error(is_abort_on_error), src_file(src_file), src_line(src_line) {}
itti_async_shell_cmd(const itti_async_shell_cmd& i) :
itti_msg(i), system_command(i.system_command), is_abort_on_error(i.is_abort_on_error), src_file(i.src_file), src_line(i.src_line) {}
const char* get_msg_name() {return typeid( itti_msg_ping).name();};
std::string system_command;
bool is_abort_on_error;
class itti_async_shell_cmd : public itti_msg {
public:
itti_async_shell_cmd(const task_id_t origin, const task_id_t destination,
const std::string &system_cmd, bool is_abort_on_error,
const char *src_file, const int src_line)
:
itti_msg(ASYNC_SHELL_CMD, origin, destination),
system_command(system_cmd),
is_abort_on_error(is_abort_on_error),
src_file(src_file),
src_line(src_line) {
}
itti_async_shell_cmd(const itti_async_shell_cmd &i)
:
itti_msg(i),
system_command(i.system_command),
is_abort_on_error(i.is_abort_on_error),
src_file(i.src_file),
src_line(i.src_line) {
}
const char* get_msg_name() {
return typeid(itti_msg_ping).name();
}
;
std::string system_command;
bool is_abort_on_error;
// debug
std::string src_file;
int src_line;
} ;
std::string src_file;
int src_line;
};
#endif /* FILE_ITTI_ASYNC_SHELL_CMD_SEEN */
This diff is collapsed.
This diff is collapsed.
......@@ -35,16 +35,29 @@
class itti_n4_restore : public itti_msg {
public:
itti_n4_restore(const task_id_t origin, const task_id_t destination):
itti_msg(RESTORE_N4_SESSIONS, origin, destination), sessions() {}
itti_n4_restore(const itti_n4_restore& i) : itti_msg(i), sessions(i.sessions) {}
itti_n4_restore(const itti_n4_restore& i, const task_id_t orig, const task_id_t dest) : itti_n4_restore(i) {
itti_n4_restore(const task_id_t origin, const task_id_t destination)
:
itti_msg(RESTORE_N4_SESSIONS, origin, destination),
sessions() {
}
itti_n4_restore(const itti_n4_restore &i)
:
itti_msg(i),
sessions(i.sessions) {
}
itti_n4_restore(const itti_n4_restore &i, const task_id_t orig,
const task_id_t dest)
:
itti_n4_restore(i) {
origin = orig;
destination = dest;
}
const char* get_msg_name() {return "N4_RESTORE";};
const char* get_msg_name() {
return "N4_RESTORE";
}
;
std::set<pfcp::fseid_t> sessions;
std::set<pfcp::fseid_t> sessions;
};
#endif /* ITTI_MSG_N4_RESTORE_HPP_INCLUDED_ */
......@@ -34,15 +34,20 @@
#include "pistache/http.h"
class itti_nx_msg : public itti_msg {
public:
itti_nx_msg(const itti_msg_type_t msg_type, const task_id_t orig, const task_id_t dest):
itti_msg(msg_type, orig, dest) {
public:
itti_nx_msg(const itti_msg_type_t msg_type, const task_id_t orig,
const task_id_t dest)
:
itti_msg(msg_type, orig, dest) {
}
itti_nx_msg(const itti_nx_msg& i) : itti_msg(i) {}
itti_nx_msg(const itti_nx_msg& i, const task_id_t orig, const task_id_t dest) :
itti_nx_msg(i)
{
itti_nx_msg(const itti_nx_msg &i)
:
itti_msg(i) {
}
itti_nx_msg(const itti_nx_msg &i, const task_id_t orig, const task_id_t dest)
:
itti_nx_msg(i) {
origin = orig;
destination = dest;
}
......@@ -51,13 +56,27 @@ public:
//-----------------------------------------------------------------------------
class itti_nx_modify_pdu_session_request_network_requested : public itti_nx_msg {
public:
itti_nx_modify_pdu_session_request_network_requested(const task_id_t orig, const task_id_t dest):
itti_nx_msg(NX_SESSION_MODIFICATION_REQUEST_NETWORK_REQUESTED, orig, dest) {}
itti_nx_modify_pdu_session_request_network_requested(const itti_nx_modify_pdu_session_request_network_requested& i) : itti_nx_msg(i) {}
itti_nx_modify_pdu_session_request_network_requested(const itti_nx_modify_pdu_session_request_network_requested& i, const task_id_t orig, const task_id_t dest) :
itti_nx_msg(i, orig, dest){}
const char* get_msg_name() {return "NX_SESSION_MODIFICATION_REQUEST_NETWORK_REQUESTED";};
public:
itti_nx_modify_pdu_session_request_network_requested(const task_id_t orig,
const task_id_t dest)
:
itti_nx_msg(NX_SESSION_MODIFICATION_REQUEST_NETWORK_REQUESTED, orig, dest) {
}
itti_nx_modify_pdu_session_request_network_requested(
const itti_nx_modify_pdu_session_request_network_requested &i)
:
itti_nx_msg(i) {
}
itti_nx_modify_pdu_session_request_network_requested(
const itti_nx_modify_pdu_session_request_network_requested &i,
const task_id_t orig, const task_id_t dest)
:
itti_nx_msg(i, orig, dest) {
}
const char* get_msg_name() {
return "NX_SESSION_MODIFICATION_REQUEST_NETWORK_REQUESTED";
}
;
// smf::pdu_session_create_sm_context_request req;
};
......
......@@ -40,7 +40,9 @@ int check_NGAP_pdu_constraints(Ngap_NGAP_PDU_t *pdu) {
int ngap_amf_decode_pdu(Ngap_NGAP_PDU_t *pdu, const_bstring const raw) {
Ngap_NGAP_PDU_t *decoded_pdu = pdu;
asn_dec_rval_t rc = asn_decode(NULL, ATS_ALIGNED_CANONICAL_PER, &asn_DEF_Ngap_NGAP_PDU, (void**) &decoded_pdu, bdata(raw), blength(raw));
asn_dec_rval_t rc = asn_decode(NULL, ATS_ALIGNED_CANONICAL_PER,
&asn_DEF_Ngap_NGAP_PDU, (void**) &decoded_pdu,
bdata(raw), blength(raw));
if (rc.code != RC_OK) {
printf("asn_decode failed(%d)\n", rc.code);
return rc.code;
......
......@@ -299,7 +299,9 @@
if (mandatory) DevAssert(ie != NULL); \
} while(0)
typedef int (*ngap_message_decoded_callback)(const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, struct Ngap_NGAP_PDU *message_p);
typedef int (*ngap_message_decoded_callback)(const sctp_assoc_id_t assoc_id,
const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU *message_p);
int check_NGAP_pdu_constraints(Ngap_NGAP_PDU_t *pdu);
......
......@@ -93,7 +93,8 @@ enum pdu_session_type_e {
PDU_SESSION_TYPE_E_RESERVED = 7,
};
static const std::vector<std::string> pdu_session_type_e2str = { "Error", "IPV4", "IPV6", "IPV4V6", "UNSTRUCTURED", "ETHERNET", "IPV4V6", "RESERVED" };
static const std::vector<std::string> pdu_session_type_e2str = { "Error",
"IPV4", "IPV6", "IPV4V6", "UNSTRUCTURED", "ETHERNET", "IPV4V6", "RESERVED" };
typedef struct pdu_session_type_s {
uint8_t pdu_session_type;
......@@ -166,12 +167,22 @@ enum class session_management_procedures_type_e {
PDU_SESSION_TEST = 13
};
static const std::vector<std::string> session_management_procedures_type_e2str = { "PDU_SESSION_ESTABLISHMENT_UE_REQUESTED", "SERVICE_REQUEST_UE_TRIGGERED_STEP1", "SERVICE_REQUEST_UE_TRIGGERED_STEP2",
"SERVICE_REQUEST_NETWORK_TRIGGERED", "PDU_SESSION_MODIFICATION_UE_INITIATED_STEP1", "PDU_SESSION_MODIFICATION_UE_INITIATED_STEP2", "PDU_SESSION_MODIFICATION_UE_INITIATED_STEP3",
"PDU_SESSION_MODIFICATION_SMF_REQUESTED", "PDU_SESSION_MODIFICATION_AN_REQUESTED", "PDU_SESSION_RELEASE_UE_REQUESTED_STEP1", "PDU_SESSION_RELEASE_UE_REQUESTED_STEP2",
"PDU_SESSION_RELEASE_UE_REQUESTED_STEP3", "PDU_SESSION_RELEASE_NETWORK_REQUESTED"
};
static const std::vector<std::string> session_management_procedures_type_e2str =
{ "PDU_SESSION_ESTABLISHMENT_UE_REQUESTED",
"SERVICE_REQUEST_UE_TRIGGERED_STEP1",
"SERVICE_REQUEST_UE_TRIGGERED_STEP2",
"SERVICE_REQUEST_NETWORK_TRIGGERED",
"PDU_SESSION_MODIFICATION_UE_INITIATED_STEP1",
"PDU_SESSION_MODIFICATION_UE_INITIATED_STEP2",
"PDU_SESSION_MODIFICATION_UE_INITIATED_STEP3",
"PDU_SESSION_MODIFICATION_SMF_REQUESTED",
"PDU_SESSION_MODIFICATION_AN_REQUESTED",
"PDU_SESSION_RELEASE_UE_REQUESTED_STEP1",
"PDU_SESSION_RELEASE_UE_REQUESTED_STEP2",
"PDU_SESSION_RELEASE_UE_REQUESTED_STEP3",
"PDU_SESSION_RELEASE_NETWORK_REQUESTED"
};
typedef struct qos_profile_gbr_s {
gfbr_t gfbr; //Guaranteed Flow Bit Rate
......@@ -203,7 +214,8 @@ enum class multipart_related_content_part_e {
NGAP = 2
};
static const std::vector<std::string> multipart_related_content_part_e2str = { "JSON", "NAS", "NGAP" };
static const std::vector<std::string> multipart_related_content_part_e2str = {
"JSON", "NAS", "NGAP" };
#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
......
......@@ -34,7 +34,8 @@
#include <inttypes.h>
//------------------------------------------------------------------------------
void xgpp_conv::paa_to_pfcp_ue_ip_address(const paa_t &paa, pfcp::ue_ip_address_t &ue_ip_address) {
void xgpp_conv::paa_to_pfcp_ue_ip_address(
const paa_t &paa, pfcp::ue_ip_address_t &ue_ip_address) {
switch (paa.pdn_type.pdn_type) {
case PDN_TYPE_E_IPV4:
ue_ip_address.v4 = 1;
......@@ -56,7 +57,9 @@ void xgpp_conv::paa_to_pfcp_ue_ip_address(const paa_t &paa, pfcp::ue_ip_address_
}
}
//------------------------------------------------------------------------------
void xgpp_conv::pdn_ip_to_pfcp_ue_ip_address(const pdn_type_t &pdn_type, const struct in_addr &ipv4_address, const struct in6_addr ipv6_address, pfcp::ue_ip_address_t &ue_ip_address) {
void xgpp_conv::pdn_ip_to_pfcp_ue_ip_address(
const pdn_type_t &pdn_type, const struct in_addr &ipv4_address,
const struct in6_addr ipv6_address, pfcp::ue_ip_address_t &ue_ip_address) {
switch (pdn_type.pdn_type) {
case PDN_TYPE_E_IPV4:
ue_ip_address.v4 = 1;
......@@ -78,7 +81,8 @@ void xgpp_conv::pdn_ip_to_pfcp_ue_ip_address(const pdn_type_t &pdn_type, const s
}
}
//------------------------------------------------------------------------------
void xgpp_conv::pfcp_to_core_fteid(const pfcp::fteid_t &pfteid, fteid_t &fteid) {
void xgpp_conv::pfcp_to_core_fteid(const pfcp::fteid_t &pfteid,
fteid_t &fteid) {
fteid.v4 = pfteid.v4;
fteid.v6 = pfteid.v6;
fteid.ipv4_address.s_addr = pfteid.ipv4_address.s_addr;
......@@ -86,7 +90,8 @@ void xgpp_conv::pfcp_to_core_fteid(const pfcp::fteid_t &pfteid, fteid_t &fteid)
fteid.teid_gre_key = pfteid.teid;
}
//------------------------------------------------------------------------------
void xgpp_conv::pfcp_from_core_fteid(pfcp::fteid_t &pfteid, const fteid_t &fteid) {
void xgpp_conv::pfcp_from_core_fteid(pfcp::fteid_t &pfteid,
const fteid_t &fteid) {
pfteid.chid = 0;
pfteid.ch = 0;
pfteid.choose_id = 0;
......@@ -128,17 +133,20 @@ void xgpp_conv::pfcp_cause_to_core_cause(const pfcp::cause_t &pc, cause_t &c) {
}
//------------------------------------------------------------------------------
bool xgpp_conv::endpoint_to_gtp_u_peer_address(const endpoint &ep, gtp_u_peer_address_t &peer_address) {
bool xgpp_conv::endpoint_to_gtp_u_peer_address(
const endpoint &ep, gtp_u_peer_address_t &peer_address) {
switch (ep.family()) {
case AF_INET: {
const struct sockaddr_in *const sin = reinterpret_cast<const sockaddr_in* const >(&ep.addr_storage);
const struct sockaddr_in *const sin =
reinterpret_cast<const sockaddr_in* const >(&ep.addr_storage);
peer_address.ipv4_address.s_addr = sin->sin_addr.s_addr;
peer_address.is_v4 = true;
return true;
}
break;
case AF_INET6: {
const struct sockaddr_in6 *const sin6 = reinterpret_cast<const sockaddr_in6* const >(&ep.addr_storage);
const struct sockaddr_in6 *const sin6 =
reinterpret_cast<const sockaddr_in6* const >(&ep.addr_storage);
peer_address.ipv6_address = sin6->sin6_addr;
peer_address.is_v4 = false;
return true;
......
......@@ -35,12 +35,17 @@
namespace xgpp_conv {
void paa_to_pfcp_ue_ip_address(const paa_t &paa, pfcp::ue_ip_address_t &ue_ip_address);
void pdn_ip_to_pfcp_ue_ip_address(const pdn_type_t &pdn_type, const struct in_addr &ipv4_address, const struct in6_addr ipv6_address, pfcp::ue_ip_address_t &ue_ip_address);
void paa_to_pfcp_ue_ip_address(const paa_t &paa,
pfcp::ue_ip_address_t &ue_ip_address);
void pdn_ip_to_pfcp_ue_ip_address(const pdn_type_t &pdn_type,
const struct in_addr &ipv4_address,
const struct in6_addr ipv6_address,
pfcp::ue_ip_address_t &ue_ip_address);
void pfcp_to_core_fteid(const pfcp::fteid_t &pfteid, fteid_t &fteid);
void pfcp_from_core_fteid(pfcp::fteid_t &pfteid, const fteid_t &fteid);
void pfcp_cause_to_core_cause(const pfcp::cause_t &pc, cause_t &c);
bool endpoint_to_gtp_u_peer_address(const endpoint &ep, gtp_u_peer_address_t &gpa);
bool endpoint_to_gtp_u_peer_address(const endpoint &ep,
gtp_u_peer_address_t &gpa);
}
#endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
......@@ -54,7 +54,8 @@ void async_cmd_task(void*);
void async_cmd_task(void *args_p) {
const task_id_t task_id = TASK_ASYNC_SHELL_CMD;
const thread_sched_params *const sched_params = (const util::thread_sched_params* const ) args_p;
const thread_sched_params *const sched_params =
(const util::thread_sched_params* const ) args_p;
sched_params->apply(task_id, Logger::async_cmd());
itti_inst->notify_task_ready(task_id);
......@@ -69,9 +70,13 @@ void async_cmd_task(void *args_p) {
int rc = system((const char*) to->system_command.c_str());
if (rc) {
Logger::async_cmd().error("Failed cmd from %d: %s ", to->origin, (const char*) to->system_command.c_str());
Logger::async_cmd().error("Failed cmd from %d: %s ", to->origin,
(const char*) to->system_command.c_str());
if (to->is_abort_on_error) {
Logger::async_cmd().error("Terminate cause failed cmd %s at %s:%d", to->system_command.c_str(), to->src_file.c_str(), to->src_line);
Logger::async_cmd().error(
"Terminate cause failed cmd %s at %s:%d",
to->system_command.c_str(), to->src_file.c_str(),
to->src_line);
itti_inst->send_terminate_msg(to->origin);
}
}
......@@ -85,7 +90,8 @@ void async_cmd_task(void *args_p) {
break;
case TERMINATE:
if (itti_msg_terminate *terminate = dynamic_cast<itti_msg_terminate*>(msg)) {
if (itti_msg_terminate *terminate =
dynamic_cast<itti_msg_terminate*>(msg)) {
Logger::async_cmd().info("Received terminate message");
return;
}
......@@ -105,7 +111,8 @@ void async_cmd_task(void *args_p) {
async_shell_cmd::async_shell_cmd(util::thread_sched_params &sched_params) {
Logger::async_cmd().startup("Starting...");
if (itti_inst->create_task(TASK_ASYNC_SHELL_CMD, async_cmd_task, &sched_params)) {
if (itti_inst->create_task(TASK_ASYNC_SHELL_CMD, async_cmd_task,
&sched_params)) {
Logger::async_cmd().error("Cannot create task TASK_ASYNC_SHELL_CMD");
throw std::runtime_error("Cannot create task TASK_ASYNC_SHELL_CMD");
}
......@@ -113,12 +120,18 @@ async_shell_cmd::async_shell_cmd(util::thread_sched_params &sched_params) {
}
//------------------------------------------------------------------------------
int async_shell_cmd::run_command(const task_id_t sender_itti_task, const bool is_abort_on_error, const char *src_file, const int src_line, const std::string &cmd_str) {
itti_async_shell_cmd cmd(sender_itti_task, TASK_ASYNC_SHELL_CMD, cmd_str, is_abort_on_error, src_file, src_line);
std::shared_ptr<itti_async_shell_cmd> msg = std::make_shared<itti_async_shell_cmd>(cmd);
int async_shell_cmd::run_command(const task_id_t sender_itti_task,
const bool is_abort_on_error,
const char *src_file, const int src_line,
const std::string &cmd_str) {
itti_async_shell_cmd cmd(sender_itti_task, TASK_ASYNC_SHELL_CMD, cmd_str,
is_abort_on_error, src_file, src_line);
std::shared_ptr<itti_async_shell_cmd> msg = std::make_shared<
itti_async_shell_cmd>(cmd);
int ret = itti_inst->send_msg(msg);
if (RETURNok != ret) {
Logger::async_cmd().error("Could not send ITTI message to task TASK_ASYNC_SHELL_CMD");
Logger::async_cmd().error(
"Could not send ITTI message to task TASK_ASYNC_SHELL_CMD");
return RETURNerror ;
}
return RETURNok ;
......
......@@ -50,7 +50,9 @@ class async_shell_cmd {
async_shell_cmd(async_shell_cmd const&) = delete;
void operator=(async_shell_cmd const&) = delete;
int run_command(const task_id_t sender_itti_task, const bool is_abort_on_error, const char *src_file, const int src_line, const std::string &cmd_str);
int run_command(const task_id_t sender_itti_task,
const bool is_abort_on_error, const char *src_file,
const int src_line, const std::string &cmd_str);
};
......
......@@ -20,10 +20,10 @@
*/
/*! \file conversions.cpp
\brief
\author Sebastien ROUX
\company Eurecom
*/
\brief
\author Sebastien ROUX
\company Eurecom
*/
#include "conversions.hpp"
#include <stdlib.h>
......@@ -33,28 +33,24 @@
#include <inttypes.h>
#include <arpa/inet.h>
static const char hex_to_ascii_table[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
};
static const signed char ascii_to_hex_table[0x100] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
static const char hex_to_ascii_table[16] = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', };
static const signed char ascii_to_hex_table[0x100] = { -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1,
10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1 };
void conv::hexa_to_ascii(uint8_t *from, char *to, size_t length) {
size_t i;
......@@ -102,7 +98,8 @@ int conv::ascii_to_hex(uint8_t *dst, const char *h) {
}
//------------------------------------------------------------------------------
std::string conv::mccToString(const uint8_t digit1, const uint8_t digit2, const uint8_t digit3) {
std::string conv::mccToString(const uint8_t digit1, const uint8_t digit2,
const uint8_t digit3) {
std::string s = { };
uint16_t mcc16 = digit1 * 100 + digit2 * 10 + digit3;
//s.append(std::to_string(digit1)).append(std::to_string(digit2)).append(std::to_string(digit3));
......@@ -110,7 +107,8 @@ std::string conv::mccToString(const uint8_t digit1, const uint8_t digit2, const
return s;
}
//------------------------------------------------------------------------------
std::string conv::mncToString(const uint8_t digit1, const uint8_t digit2, const uint8_t digit3) {
std::string conv::mncToString(const uint8_t digit1, const uint8_t digit2,
const uint8_t digit3) {
std::string s = { };
uint16_t mcc16 = 0;
......@@ -145,7 +143,8 @@ std::string conv::toString(const struct in_addr &inaddr) {
std::string conv::toString(const struct in6_addr &in6addr) {
std::string s = { };
char str[INET6_ADDRSTRLEN] = { };
if (inet_ntop(AF_INET6, (const void*) &in6addr, str, INET6_ADDRSTRLEN) == nullptr) {
if (inet_ntop(AF_INET6, (const void*) &in6addr, str, INET6_ADDRSTRLEN)
== nullptr) {
s.append("Error in6_addr");
} else {
s.append(str);
......
......@@ -57,7 +57,9 @@ class conv {
static struct in_addr fromString(const std::string addr4);
static std::string toString(const struct in_addr &inaddr);
static std::string toString(const struct in6_addr &in6addr);
static std::string mccToString(const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
static std::string mncToString(const uint8_t digit1, const uint8_t digit2, const uint8_t digit3);
static std::string mccToString(const uint8_t digit1, const uint8_t digit2,
const uint8_t digit3);
static std::string mncToString(const uint8_t digit1, const uint8_t digit2,
const uint8_t digit3);
};
#endif /* FILE_CONVERSIONS_HPP_SEEN */
This diff is collapsed.
This diff is collapsed.
......@@ -36,12 +36,15 @@ using namespace std;
//------------------------------------------------------------------------------
bool util::get_iface_l2_addr(const std::string &iface, std::string &mac) {
std::string mac_address_path = fmt::format("/sys/class/net/{}/address", iface);
std::ifstream mac_address_in(mac_address_path.c_str(), ios_base::in | ios_base::binary);
std::string mac_address_path = fmt::format("/sys/class/net/{}/address",
iface);
std::ifstream mac_address_in(mac_address_path.c_str(),
ios_base::in | ios_base::binary);
char wb[32];
mac_address_in.get(wb, 32);
mac.assign(wb);
Logger::pfcp_switch().error("Found IFace %s MAC %s", iface.c_str(), mac.c_str());
Logger::pfcp_switch().error("Found IFace %s MAC %s", iface.c_str(),
mac.c_str());
mac.erase(std::remove(mac.begin(), mac.end(), ':'), mac.end());
return true;
// ifr = {};
......@@ -91,7 +94,8 @@ bool util::get_gateway_and_iface(std::string &gw, std::string &iface) {
/* 1 Sec Timeout to avoid stall */
tv.tv_sec = 1;
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (struct timeval*) &tv, sizeof(struct timeval));
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (struct timeval*) &tv,
sizeof(struct timeval));
/* send msg */
if (send(sock, nlmsg, nlmsg->nlmsg_len, 0) < 0) {
perror("send failed");
......@@ -109,7 +113,8 @@ bool util::get_gateway_and_iface(std::string &gw, std::string &iface) {
nlh = (struct nlmsghdr*) ptr;
/* Check if the header is valid */
if ((NLMSG_OK(nlmsg, received_bytes) == 0) || (nlmsg->nlmsg_type == NLMSG_ERROR)) {
if ((NLMSG_OK(nlmsg, received_bytes) == 0)
|| (nlmsg->nlmsg_type == NLMSG_ERROR)) {
perror("Error in received packet");
return false;
}
......@@ -140,13 +145,15 @@ bool util::get_gateway_and_iface(std::string &gw, std::string &iface) {
route_attribute_len = RTM_PAYLOAD(nlh);
/* Loop through all attributes */
for (; RTA_OK(route_attribute, route_attribute_len); route_attribute = RTA_NEXT(route_attribute, route_attribute_len)) {
for (; RTA_OK(route_attribute, route_attribute_len); route_attribute =
RTA_NEXT(route_attribute, route_attribute_len)) {
switch (route_attribute->rta_type) {
case RTA_OIF:
if_indextoname(*(int*) RTA_DATA(route_attribute), interface);
break;
case RTA_GATEWAY:
inet_ntop(AF_INET, RTA_DATA(route_attribute), gateway_address, sizeof(gateway_address));
inet_ntop(AF_INET, RTA_DATA(route_attribute), gateway_address,
sizeof(gateway_address));
break;
default:
break;
......
......@@ -66,7 +66,8 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
/* 1 Sec Timeout to avoid stall */
tv.tv_sec = 1;
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (struct timeval*) &tv, sizeof(struct timeval));
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (struct timeval*) &tv,
sizeof(struct timeval));
/* send msg */
if (send(sock, nlmsg, nlmsg->nlmsg_len, 0) < 0) {
Logger::system().error("send socket raw/NETLINK_ROUTE failed");
......@@ -84,7 +85,8 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
nlh = (struct nlmsghdr*) ptr;
/* Check if the header is valid */
if ((NLMSG_OK(nlmsg, received_bytes) == 0) || (nlmsg->nlmsg_type == NLMSG_ERROR)) {
if ((NLMSG_OK(nlmsg, received_bytes) == 0)
|| (nlmsg->nlmsg_type == NLMSG_ERROR)) {
Logger::system().error("recv msg raw/NETLINK_ROUTE failed");
return EXIT_FAILURE;
}
......@@ -115,13 +117,15 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
route_attribute_len = RTM_PAYLOAD(nlh);
/* Loop through all attributes */
for (; RTA_OK(route_attribute, route_attribute_len); route_attribute = RTA_NEXT(route_attribute, route_attribute_len)) {
for (; RTA_OK(route_attribute, route_attribute_len); route_attribute =
RTA_NEXT(route_attribute, route_attribute_len)) {
switch (route_attribute->rta_type) {
case RTA_OIF:
if_indextoname(*(int*) RTA_DATA(route_attribute), interface);
break;
case RTA_GATEWAY:
inet_ntop(AF_INET, RTA_DATA(route_attribute), gateway_address, sizeof(gateway_address));
inet_ntop(AF_INET, RTA_DATA(route_attribute), gateway_address,
sizeof(gateway_address));
break;
default:
break;
......@@ -143,7 +147,8 @@ int get_gateway_and_iface(std::string *gw, std::string *iface) {
}
//------------------------------------------------------------------------------
int get_inet_addr_from_iface(const std::string &if_name, struct in_addr &inet_addr) {
int get_inet_addr_from_iface(const std::string &if_name,
struct in_addr &inet_addr) {
struct ifreq ifr;
char str[INET_ADDRSTRLEN];
......@@ -154,13 +159,15 @@ int get_inet_addr_from_iface(const std::string &if_name, struct in_addr &inet_ad
strcpy(ifr.ifr_name, (const char*) if_name.c_str());
if (ioctl(fd, SIOCGIFADDR, &ifr)) {
close(fd);
Logger::system().error("Failed to probe %s inet addr: error %s\n", if_name.c_str(), strerror(errno));
Logger::system().error("Failed to probe %s inet addr: error %s\n",
if_name.c_str(), strerror(errno));
return RETURNerror ;
}
close(fd);
struct sockaddr_in *ipaddr = (struct sockaddr_in*) &ifr.ifr_addr;
// check
if (inet_ntop(AF_INET, (const void*) &ipaddr->sin_addr, str, INET_ADDRSTRLEN) == NULL) {
if (inet_ntop(AF_INET, (const void*) &ipaddr->sin_addr, str,
INET_ADDRSTRLEN) == NULL) {
return RETURNerror ;
}
inet_addr.s_addr = ipaddr->sin_addr.s_addr;
......@@ -177,7 +184,8 @@ int get_mtu_from_iface(const std::string &if_name, uint32_t &mtu) {
strcpy(ifr.ifr_name, (const char*) if_name.c_str());
if (ioctl(fd, SIOCGIFMTU, &ifr)) {
close(fd);
Logger::system().error("Failed to probe %s MTU: error %s\n", if_name.c_str(), strerror(errno));
Logger::system().error("Failed to probe %s MTU: error %s\n",
if_name.c_str(), strerror(errno));
return RETURNerror ;
}
close(fd);
......@@ -186,7 +194,10 @@ int get_mtu_from_iface(const std::string &if_name, uint32_t &mtu) {
}
//------------------------------------------------------------------------------
int get_inet_addr_infos_from_iface(const std::string &if_name, struct in_addr &inet_addr, struct in_addr &inet_network, unsigned int &mtu) {
int get_inet_addr_infos_from_iface(const std::string &if_name,
struct in_addr &inet_addr,
struct in_addr &inet_network,
unsigned int &mtu) {
struct ifreq ifr;
char str[INET_ADDRSTRLEN];
......@@ -201,12 +212,14 @@ int get_inet_addr_infos_from_iface(const std::string &if_name, struct in_addr &i
strcpy(ifr.ifr_name, (const char*) if_name.c_str());
if (ioctl(fd, SIOCGIFADDR, &ifr)) {
close(fd);
Logger::system().error("Failed to probe %s inet addr: error %s\n", if_name.c_str(), strerror(errno));
Logger::system().error("Failed to probe %s inet addr: error %s\n",
if_name.c_str(), strerror(errno));
return RETURNerror ;
}
struct sockaddr_in *ipaddr = (struct sockaddr_in*) &ifr.ifr_addr;
// check
if (inet_ntop(AF_INET, (const void*) &ipaddr->sin_addr, str, INET_ADDRSTRLEN) == NULL) {
if (inet_ntop(AF_INET, (const void*) &ipaddr->sin_addr, str,
INET_ADDRSTRLEN) == NULL) {
close(fd);
return RETURNerror ;
}
......@@ -218,12 +231,14 @@ int get_inet_addr_infos_from_iface(const std::string &if_name, struct in_addr &i
strcpy(ifr.ifr_name, (const char*) if_name.c_str());
if (ioctl(fd, SIOCGIFNETMASK, &ifr)) {
close(fd);
Logger::system().error("Failed to probe %s inet netmask: error %s\n", if_name.c_str(), strerror(errno));
Logger::system().error("Failed to probe %s inet netmask: error %s\n",
if_name.c_str(), strerror(errno));
return RETURNerror ;
}
ipaddr = (struct sockaddr_in*) &ifr.ifr_netmask;
// check
if (inet_ntop(AF_INET, (const void*) &ipaddr->sin_addr, str, INET_ADDRSTRLEN) == NULL) {
if (inet_ntop(AF_INET, (const void*) &ipaddr->sin_addr, str,
INET_ADDRSTRLEN) == NULL) {
close(fd);
return RETURNerror ;
}
......@@ -234,7 +249,8 @@ int get_inet_addr_infos_from_iface(const std::string &if_name, struct in_addr &i
//strncpy(ifr.ifr_name, (const char *)if_name.c_str(), IFNAMSIZ-1);
strcpy(ifr.ifr_name, (const char*) if_name.c_str());
if (ioctl(fd, SIOCGIFMTU, &ifr)) {
Logger::system().error("Failed to probe %s MTU: error %s\n", if_name.c_str(), strerror(errno));
Logger::system().error("Failed to probe %s MTU: error %s\n",
if_name.c_str(), strerror(errno));
} else {
mtu = ifr.ifr_mtu;
}
......
......@@ -30,8 +30,12 @@
# include <string>
int get_gateway_and_iface(std::string *gw /*OUT*/, std::string *iface /*OUT*/);
int get_inet_addr_from_iface(const std::string &if_name, struct in_addr &inet_addr);
int get_inet_addr_from_iface(const std::string &if_name,
struct in_addr &inet_addr);
int get_mtu_from_iface(const std::string &if_name, uint32_t &mtu);
int get_inet_addr_infos_from_iface(const std::string &if_name, struct in_addr &inet_addr, struct in_addr &inet_netmask, unsigned int &mtu);
int get_inet_addr_infos_from_iface(const std::string &if_name,
struct in_addr &inet_addr,
struct in_addr &inet_netmask,
unsigned int &mtu);
#endif /* FILE_IF_HPP_SEEN */
......@@ -41,7 +41,8 @@
int g_fd_pid_file = -1;
__pid_t g_pid = -1;
//------------------------------------------------------------------------------
std::string util::get_exe_absolute_path(const std::string &basepath, const unsigned int instance) {
std::string util::get_exe_absolute_path(const std::string &basepath,
const unsigned int instance) {
#define MAX_FILE_PATH_LENGTH 255
char pid_file_name[MAX_FILE_PATH_LENGTH + 1] = { 0 };
char *exe_basename = NULL;
......@@ -61,7 +62,8 @@ std::string util::get_exe_absolute_path(const std::string &basepath, const unsig
if (num_chars > MAX_FILE_PATH_LENGTH) {
num_chars = MAX_FILE_PATH_LENGTH;
}
snprintf(pid_file_name, num_chars, "%s/%s%02u.pid", basepath.c_str(), exe_basename, instance);
snprintf(pid_file_name, num_chars, "%s/%s%02u.pid", basepath.c_str(),
exe_basename, instance);
return std::string(pid_file_name);
}
......@@ -79,12 +81,14 @@ bool util::is_pid_file_lock_success(const char *pid_file_name) {
O_RDWR | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* Read/write by owner, read by grp, others */
if (0 > g_fd_pid_file) {
Logger::smf_app().error("open filename %s failed %d:%s\n", pid_file_name, errno, strerror(errno));
Logger::smf_app().error("open filename %s failed %d:%s\n", pid_file_name,
errno, strerror(errno));
return false;
}
if (0 > util::lockfile(g_fd_pid_file, F_TLOCK)) {
Logger::smf_app().error("lockfile filename %s failed %d:%s\n", pid_file_name, errno, strerror(errno));
Logger::smf_app().error("lockfile filename %s failed %d:%s\n",
pid_file_name, errno, strerror(errno));
if ( EACCES == errno || EAGAIN == errno) {
close(g_fd_pid_file);
}
......@@ -92,7 +96,8 @@ bool util::is_pid_file_lock_success(const char *pid_file_name) {
}
// fruncate file content
if (ftruncate(g_fd_pid_file, 0)) {
Logger::smf_app().error("truncate %s failed %d:%s\n", pid_file_name, errno, strerror(errno));
Logger::smf_app().error("truncate %s failed %d:%s\n", pid_file_name, errno,
strerror(errno));
close(g_fd_pid_file);
return false;
}
......@@ -100,7 +105,8 @@ bool util::is_pid_file_lock_success(const char *pid_file_name) {
g_pid = getpid();
snprintf(pid_dec, 64 /* should be big enough */, "%ld", (long) g_pid);
if ((ssize_t) -1 == write(g_fd_pid_file, pid_dec, strlen(pid_dec))) {
Logger::smf_app().error("write PID to filename %s failed %d:%s\n", pid_file_name, errno, strerror(errno));
Logger::smf_app().error("write PID to filename %s failed %d:%s\n",
pid_file_name, errno, strerror(errno));
return false;
}
return true;
......
......@@ -39,7 +39,8 @@ namespace util {
*
* @return a string for the exe absolute path.
*/
std::string get_exe_absolute_path(const std::string &base_path, const unsigned int instance);
std::string get_exe_absolute_path(const std::string &base_path,
const unsigned int instance);
bool is_pid_file_lock_success(const char *pid_file_name);
......
......@@ -67,13 +67,19 @@ std::string util::string_format(const char *format, ...) {
// trim from start
std::string& util::ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
s.erase(
s.begin(),
std::find_if(s.begin(), s.end(),
std::not1(std::ptr_fun<int, int>(std::isspace))));
return s;
}
// trim from end
std::string& util::rtrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
s.erase(
std::find_if(s.rbegin(), s.rend(),
std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
s.end());
return s;
}
......
......@@ -28,12 +28,15 @@
#include "thread_sched.hpp"
//------------------------------------------------------------------------------
void util::thread_sched_params::apply(const int task_id, _Logger &logger) const {
void util::thread_sched_params::apply(const int task_id,
_Logger &logger) const {
if (cpu_id >= 0) {
cpu_set_t cpuset;
CPU_SET(cpu_id, &cpuset);
if (int rc = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset)) {
logger.warn("Could not set affinity to ITTI task %d, err=%d", task_id, rc);
if (int rc = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t),
&cpuset)) {
logger.warn("Could not set affinity to ITTI task %d, err=%d", task_id,
rc);
}
}
......@@ -41,6 +44,7 @@ void util::thread_sched_params::apply(const int task_id, _Logger &logger) const
memset(&sparam, 0, sizeof(sparam));
sparam.sched_priority = sched_priority;
if (int rc = pthread_setschedparam(pthread_self(), sched_policy, &sparam)) {
logger.warn("Could not set schedparam to ITTI task %d, err=%d", task_id, rc);
logger.warn("Could not set schedparam to ITTI task %d, err=%d", task_id,
rc);
}
}
......@@ -20,9 +20,9 @@
*/
/*! \file uint_uid_generator.hpp
\author Lionel GAUTHIER
\date 2019
\email: lionel.gauthier@eurecom.fr
\author Lionel GAUTHIER
\date 2019
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_UINT_GENERATOR_HPP_SEEN
......@@ -33,26 +33,28 @@
namespace util {
template <class UINT> class uint_generator {
template<class UINT> class uint_generator {
private:
UINT uid_generator;
std::mutex m_uid_generator;
std::set<UINT> uid_generated;
std::mutex m_uid_generated;
UINT uid_generator;
std::mutex m_uid_generator;
std::set<UINT> uid_generated;
std::mutex m_uid_generated;
public:
uint_generator() : m_uid_generator() , m_uid_generated() {
uint_generator()
:
m_uid_generator(),
m_uid_generated() {
uid_generator = 0;
uid_generated = {};
};
uid_generated = { };
}
;
uint_generator(uint_generator const&) = delete;
void operator=(uint_generator const&) = delete;
UINT get_uid()
{
UINT get_uid() {
std::unique_lock<std::mutex> lr(m_uid_generator);
UINT uid = ++uid_generator;
while (true) {
......@@ -68,39 +70,40 @@ template <class UINT> class uint_generator {
}
}
void free_uid(UINT uid)
{
void free_uid(UINT uid) {
std::unique_lock<std::mutex> l(m_uid_generated);
uid_generated.erase(uid);
l.unlock();
}
};
template <class UINT> class uint_uid_generator {
template<class UINT> class uint_uid_generator {
private:
UINT uid_generator;
std::mutex m_uid_generator;
UINT uid_generator;
std::mutex m_uid_generator;
std::set<UINT> uid_generated;
std::mutex m_uid_generated;
std::set<UINT> uid_generated;
std::mutex m_uid_generated;
uint_uid_generator() : m_uid_generator() , m_uid_generated() {
uint_uid_generator()
:
m_uid_generator(),
m_uid_generated() {
uid_generator = 0;
uid_generated = {};
};
uid_generated = { };
}
;
public:
static uint_uid_generator& get_instance()
{
static uint_uid_generator instance;
static uint_uid_generator& get_instance() {
static uint_uid_generator instance;
return instance;
}
uint_uid_generator(uint_uid_generator const&) = delete;
void operator=(uint_uid_generator const&) = delete;
UINT get_uid()
{
UINT get_uid() {
std::unique_lock<std::mutex> lr(m_uid_generator);
UINT uid = ++uid_generator;
while (true) {
......@@ -116,8 +119,7 @@ template <class UINT> class uint_uid_generator {
}
}
void free_uid(UINT uid)
{
void free_uid(UINT uid) {
std::unique_lock<std::mutex> l(m_uid_generated);
uid_generated.erase(uid);
l.unlock();
......
......@@ -199,8 +199,10 @@ enum request_type_e {
#ifdef __cplusplus
}
static const std::vector<std::string> request_type_e2str = { "ERROR", "INITIAL REQUEST", "EXISTING_PDU_SESSION", "INITIAL_EMERGENCY_REQUEST", "EXISTING_EMERGENCY_PDU_SESSION", "MODIFICATION_REQUEST",
"MA_PDU_REQUEST", "RESERVED" };
static const std::vector<std::string> request_type_e2str = { "ERROR",
"INITIAL REQUEST", "EXISTING_PDU_SESSION", "INITIAL_EMERGENCY_REQUEST",
"EXISTING_EMERGENCY_PDU_SESSION", "MODIFICATION_REQUEST", "MA_PDU_REQUEST",
"RESERVED" };
enum class cause_value_5gsm_e {
CAUSE_0_UNKNOWN = 0,
......@@ -314,7 +316,9 @@ enum class pdu_session_status_e {
PDU_SESSION_ACTIVE = 4
};
static const std::vector<std::string> pdu_session_status_e2str = { "PDU_SESSION_INACTIVE", "PDU_SESSION_INACTIVE_PENDING", "PDU_SESSION_MODIFICATION_PENDING", "PDU_SESSION_ACTIVE" };
static const std::vector<std::string> pdu_session_status_e2str = {
"PDU_SESSION_INACTIVE", "PDU_SESSION_INACTIVE_PENDING",
"PDU_SESSION_MODIFICATION_PENDING", "PDU_SESSION_ACTIVE" };
//see Table 9.11.4.12.1: QoS flow descriptions information element
typedef struct flow_bit_rate_type_s {
......@@ -340,7 +344,8 @@ enum notification_control_e {
NOT_REQUESTED = 2
};
static const std::vector<std::string> notification_control_e2str = { "ERROR", "REQUESTED", "NOT_REQUESTED" };
static const std::vector<std::string> notification_control_e2str = { "ERROR",
"REQUESTED", "NOT_REQUESTED" };
#endif
......
This diff is collapsed.
......@@ -81,8 +81,11 @@ typedef struct nas_message_decode_status_s {
int fivegmm_cause;
} nas_message_decode_status_t;
int nas_message_encode(unsigned char *buffer, const nas_message_t *const msg, size_t length, void *security);
int nas_message_encode(unsigned char *buffer, const nas_message_t *const msg,
size_t length, void *security);
int nas_message_decode(const unsigned char *const buffer, nas_message_t *msg, size_t length, void *security, nas_message_decode_status_t *status);
int nas_message_decode(const unsigned char *const buffer, nas_message_t *msg,
size_t length, void *security,
nas_message_decode_status_t *status);
#endif
......@@ -50,7 +50,11 @@ typedef struct pdu_session_authentication_command_msg_tag {
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_authentication_command_msg;
int decode_pdu_session_authentication_command(pdu_session_authentication_command_msg *pdusessionauthenticationcommand, uint8_t *buffer, uint32_t len);
int encode_pdu_session_authentication_command(pdu_session_authentication_command_msg *pdusessionauthenticationcommand, uint8_t *buffer, uint32_t len);
int decode_pdu_session_authentication_command(
pdu_session_authentication_command_msg *pdusessionauthenticationcommand,
uint8_t *buffer, uint32_t len);
int encode_pdu_session_authentication_command(
pdu_session_authentication_command_msg *pdusessionauthenticationcommand,
uint8_t *buffer, uint32_t len);
#endif
......@@ -50,7 +50,11 @@ typedef struct pdu_session_authentication_complete_msg_tag {
ExtendedProtocolConfigurationOptions extendedprotocolconfigurationoptions;
} pdu_session_authentication_complete_msg;
int decode_pdu_session_authentication_complete(pdu_session_authentication_complete_msg *pdusessionauthenticationcomplete, uint8_t *buffer, uint32_t len);
int encode_pdu_session_authentication_complete(pdu_session_authentication_complete_msg *pdusessionauthenticationcomplete, uint8_t *buffer, uint32_t len);
int decode_pdu_session_authentication_complete(
pdu_session_authentication_complete_msg *pdusessionauthenticationcomplete,
uint8_t *buffer, uint32_t len);
int encode_pdu_session_authentication_complete(
pdu_session_authentication_complete_msg *pdusessionauthenticationcomplete,
uint8_t *buffer, uint32_t len);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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