Commit 09c7657e authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

First version for allowing SMF to receive notification from NRF

parent fa438400
......@@ -27,112 +27,91 @@
# either expressed or implied, of the FreeBSD Project.
#
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
# see https://clang.llvm.org/docs/ClangFormatStyleOptions.html for explanation
# of style options
BasedOnStyle: Google
Language: Cpp
IndentWidth: 2
ColumnLimit: 80
IncludeBlocks: Preserve
SortIncludes: false
# alignment
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
DerivePointerAlignment: false
PointerAlignment: Left
# function style
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
IndentWrappedFunctionNames: false
# template style
AlwaysBreakTemplateDeclarations: Yes
# preprocessor style
IndentPPDirectives: None
# block style
AllowShortBlocksOnASingleLine: false
KeepEmptyLinesAtTheStartOfBlocks: false
# break style
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakBeforeTernaryOperators: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
ReflowComments: true
# spacing style
UseTab: Never
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
...
# class style
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
# case statements
IndentCaseLabels: true
# cpp
Cpp11BracedListStyle: true
FixNamespaceComments: true
NamespaceIndentation: None
SortUsingDeclarations: true
# todo
# AlwaysBreakBeforeMultilineStrings: bool
# PenaltyBreakAssignment (unsigned)
# PenaltyBreakBeforeFirstCallParameter (unsigned)
# PenaltyBreakComment (unsigned)
# PenaltyBreakFirstLessLess (unsigned)
# PenaltyBreakString (unsigned)
# PenaltyBreakTemplateDeclaration (unsigned)
# PenaltyExcessCharacter (unsigned)
# PenaltyReturnTypeOnItsOwnLine (unsigned)
/**
* Nsmf_EventExposure
* Session Management Event Exposure Service. © 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "NFStatusNotifyApi.h"
#include "Helpers.h"
#include "smf_config.hpp"
extern smf::smf_config smf_cfg;
namespace oai {
namespace smf_server {
namespace api {
using namespace oai::smf_server::helpers;
using namespace oai::smf_server::model;
NFStatusNotifyApi::NFStatusNotifyApi(
std::shared_ptr<Pistache::Rest::Router> rtr) {
router = rtr;
}
void NFStatusNotifyApi::init() {
setupRoutes();
}
void NFStatusNotifyApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Post(
*router, base + smf_cfg.sbi_api_version + "/subscriptions",
Routes::bind(&NFStatusNotifyApi::notify_nf_status_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(
Routes::bind(&NFStatusNotifyApi::notify_nf_status_default_handler, this));
}
void NFStatusNotifyApi::notify_nf_status_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response) {
// Getting the body param
NotificationData notificationData;
try {
nlohmann::json::parse(request.body()).get_to(notificationData);
this->receive_nf_status_notification(notificationData, response);
} catch (nlohmann::detail::exception& e) {
// send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (Pistache::Http::HttpError& e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception& e) {
// send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return;
}
}
void NFStatusNotifyApi::notify_nf_status_default_handler(
const Pistache::Rest::Request&, Pistache::Http::ResponseWriter response) {
response.send(
Pistache::Http::Code::Not_Found, "The requested method does not exist");
}
} // namespace api
} // namespace smf_server
} // namespace oai
/**
* Nsmf_EventExposure
* Session Management Event Exposure Service. © 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* NFStatusNotifyApi.h
*
*
*/
#ifndef NFStatusNotifyApi_H_
#define NFStatusNotifyApi_H_
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <pistache/optional.h>
#include "NotificationData.h"
#include "ProblemDetails.h"
namespace oai {
namespace smf_server {
namespace api {
using namespace oai::smf_server::model;
class NFStatusNotifyApi {
public:
NFStatusNotifyApi(std::shared_ptr<Pistache::Rest::Router>);
virtual ~NFStatusNotifyApi() {}
void init();
const std::string base = "/nsmf_nfstatus_notify/";
private:
void setupRoutes();
void notify_nf_status_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
void notify_nf_status_default_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
/// <summary>
///
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="NotificationData"></param>
virtual void receive_nf_status_notification(
const NotificationData& notificationData,
Pistache::Http::ResponseWriter& response) = 0;
};
} // namespace api
} // namespace smf_server
} // namespace oai
#endif /* NFStatusNotifyApi_H_ */
/**
* Nsmf_EventExposure
* Session Management Event Exposure Service. © 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "NFStatusNotifyApiImpl.h"
#include "logger.hpp"
#include "smf_msg.hpp"
#include "itti_msg_sbi.hpp"
#include "smf_config.hpp"
extern smf::smf_config smf_cfg;
namespace oai {
namespace smf_server {
namespace api {
using namespace oai::smf_server::model;
NFStatusNotifyApiImpl::NFStatusNotifyApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr, smf::smf_app* smf_app_inst,
std::string address)
: NFStatusNotifyApi(rtr), m_smf_app(smf_app_inst), m_address(address) {}
void NFStatusNotifyApiImpl::receive_nf_status_notification(
const NotificationData& notificationData,
Pistache::Http::ResponseWriter& response) {
Logger::smf_api_server().info(
"NFStatusNotifyApiImpl, received a NF status notification...");
smf::data_notification_msg notification_msg = {};
notification_msg.set_notification_event_type(notificationData.getEvent());
notification_msg.set_nf_instance_uri(notificationData.getNfInstanceUri());
std::shared_ptr<smf::nf_profile> p = {};
// Only support UPF for now
if (notificationData.getNfProfile().getNfType() == "UPF")
p = std::make_shared<smf::upf_profile>();
nlohmann::json pj = {};
to_json(pj, notificationData);
p.get()->from_json(pj);
notification_msg.set_profile(p);
// Step 2. Handle the message in smf_app
std::shared_ptr<itti_sbi_notification_data> itti_msg =
std::make_shared<itti_sbi_notification_data>(TASK_SMF_N11, TASK_SMF_APP);
itti_msg->notification_msg = notification_msg;
itti_msg->http_version = 1;
ProblemDetails problem_details = {};
uint8_t http_code = 0;
if (m_smf_app->handle_nf_status_notification(
itti_msg, problem_details, http_code)) {
response.send(Pistache::Http::Code(204));
} else {
nlohmann::json json_data = {};
to_json(json_data, problem_details);
// content type
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType("application/problem+json"));
response.send(Pistache::Http::Code(http_code), json_data.dump().c_str());
}
}
} // namespace api
} // namespace smf_server
} // namespace oai
/**
* Nsmf_EventExposure
* Session Management Event Exposure Service. © 2019, 3GPP Organizational
* Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* NFStatusNotifyApiImpl.h
*
*
*/
#ifndef NF_STATUS_NOTIFY_API_IMPL_H_
#define NF_STATUS_NOTIFY_API_IMPL_H_
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <memory>
#include <NFStatusNotifyApi.h>
#include <pistache/optional.h>
#include "NotificationData.h"
#include "ProblemDetails.h"
#include "smf_app.hpp"
namespace oai {
namespace smf_server {
namespace api {
using namespace oai::smf_server::model;
class NFStatusNotifyApiImpl : public oai::smf_server::api::NFStatusNotifyApi {
public:
NFStatusNotifyApiImpl(
std::shared_ptr<Pistache::Rest::Router>, smf::smf_app* smf_app_inst,
std::string address);
~NFStatusNotifyApiImpl() {}
void receive_nf_status_notification(
const NotificationData& notificationData,
Pistache::Http::ResponseWriter& response);
private:
smf::smf_app* m_smf_app;
std::string m_address;
};
} // namespace api
} // namespace smf_server
} // namespace oai
#endif
......@@ -53,10 +53,10 @@ void from_json(const nlohmann::json &j, NotificationData &o) {
}
}
NotificationEventType NotificationData::getEvent() const {
std::string NotificationData::getEvent() const {
return m_Event;
}
void NotificationData::setEvent(NotificationEventType const &value) {
void NotificationData::setEvent(std::string const &value) {
m_Event = value;
}
std::string NotificationData::getNfInstanceUri() const {
......
......@@ -45,8 +45,8 @@ class NotificationData {
/// <summary>
///
/// </summary>
NotificationEventType getEvent() const;
void setEvent(NotificationEventType const &value);
std::string getEvent() const;
void setEvent(std::string const &value);
/// <summary>
///
/// </summary>
......@@ -70,7 +70,7 @@ class NotificationData {
friend void to_json(nlohmann::json &j, const NotificationData &o);
friend void from_json(const nlohmann::json &j, NotificationData &o);
protected:
NotificationEventType m_Event;
std::string m_Event;
std::string m_NfInstanceUri;
......
......@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -29,6 +29,7 @@
#ifndef ITTI_MSG_N11_HPP_INCLUDED_
#define ITTI_MSG_N11_HPP_INCLUDED_
#include <nlohmann/json.hpp>
#include "itti_msg.hpp"
#include "smf_msg.hpp"
#include "pistache/http.h"
......@@ -37,530 +38,381 @@
class itti_n11_msg : public itti_msg {
public:
itti_n11_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_n11_msg(const itti_n11_msg &i)
:
itti_msg(i) {
}
itti_n11_msg(const itti_n11_msg &i, const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(i) {
origin = orig;
itti_n11_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_n11_msg(const itti_n11_msg& i) : itti_msg(i) {}
itti_n11_msg(
const itti_n11_msg& i, const task_id_t orig, const task_id_t dest)
: itti_n11_msg(i) {
origin = orig;
destination = dest;
}
};
//-----------------------------------------------------------------------------
class itti_n11_create_sm_context_request : public itti_n11_msg {
public:
itti_n11_create_sm_context_request(const task_id_t orig, const task_id_t dest,
uint32_t promise_id)
:
itti_n11_msg(N11_SESSION_CREATE_SM_CONTEXT_REQUEST, orig, dest),
pid(promise_id),
req(),
scid(),
http_version(1) {
}
itti_n11_create_sm_context_request(
const itti_n11_create_sm_context_request &i)
:
itti_n11_msg(i),
pid(),
req(i.req),
scid(),
http_version(1) {
}
const task_id_t orig, const task_id_t dest, uint32_t promise_id)
: itti_n11_msg(N11_SESSION_CREATE_SM_CONTEXT_REQUEST, orig, dest),
pid(promise_id),
req(),
scid(),
http_version(1) {}
itti_n11_create_sm_context_request(
const itti_n11_create_sm_context_request& i)
: itti_n11_msg(i), pid(), req(i.req), scid(), http_version(1) {}
itti_n11_create_sm_context_request(
const itti_n11_create_sm_context_request &i, const task_id_t orig,
const itti_n11_create_sm_context_request& i, const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
pid(i.pid),
req(i.req),
scid(i.scid),
http_version(i.http_version) {
}
: itti_n11_msg(i, orig, dest),
pid(i.pid),
req(i.req),
scid(i.scid),
http_version(i.http_version) {}
const char* get_msg_name() {
return "N11_SESSION_CREATE_SM_CONTEXT_REQUEST";
}
;
void set_scid(scid_t id) {
scid = id;
}
;
};
void set_scid(scid_t id) { scid = id; };
smf::pdu_session_create_sm_context_request req;
scid_t scid; //SM Context ID
uint32_t pid; //Promise Id
scid_t scid; // SM Context ID
uint32_t pid; // Promise Id
uint8_t http_version;
};
//-----------------------------------------------------------------------------
class itti_n11_create_sm_context_response : public itti_n11_msg {
public:
itti_n11_create_sm_context_response(const task_id_t orig,
const task_id_t dest, uint32_t promise_id)
:
itti_n11_msg(N11_SESSION_CREATE_SM_CONTEXT_RESPONSE, orig, dest),
pid(promise_id),
scid(0),
http_version() {
}
itti_n11_create_sm_context_response(
const itti_n11_create_sm_context_response &i)
:
itti_n11_msg(i),
pid(i.pid),
res(i.res),
scid(i.scid),
http_version(i.http_version) {
}
const task_id_t orig, const task_id_t dest, uint32_t promise_id)
: itti_n11_msg(N11_SESSION_CREATE_SM_CONTEXT_RESPONSE, orig, dest),
pid(promise_id),
scid(0),
http_version() {}
itti_n11_create_sm_context_response(
const itti_n11_create_sm_context_response& i)
: itti_n11_msg(i),
pid(i.pid),
res(i.res),
scid(i.scid),
http_version(i.http_version) {}
itti_n11_create_sm_context_response(
const itti_n11_create_sm_context_response &i, const task_id_t orig,
const itti_n11_create_sm_context_response& i, const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
pid(i.pid),
res(i.res),
scid(i.scid),
http_version(i.http_version) {
}
: itti_n11_msg(i, orig, dest),
pid(i.pid),
res(i.res),
scid(i.scid),
http_version(i.http_version) {}
const char* get_msg_name() {
return "N11_SESSION_CREATE_SM_CONTEXT_RESPONSE";
}
;
void set_scid(scid_t id) {
scid = id;
}
;
};
void set_scid(scid_t id) { scid = id; };
smf::pdu_session_create_sm_context_response res;
scid_t scid; //SM Context ID
uint32_t pid; //Promise Id
uint8_t http_version; //HTTP version
scid_t scid; // SM Context ID
uint32_t pid; // Promise Id
uint8_t http_version; // HTTP version
};
//-----------------------------------------------------------------------------
class itti_n11_update_sm_context_request : public itti_n11_msg {
public:
itti_n11_update_sm_context_request(const task_id_t orig, const task_id_t dest,
uint32_t promise_id)
:
itti_n11_msg(N11_SESSION_UPDATE_SM_CONTEXT_REQUEST, orig, dest),
pid(promise_id),
scid(),
req(),
http_version() {
}
itti_n11_update_sm_context_request(const task_id_t orig, const task_id_t dest,
int32_t promise_id, const std::string id)
:
itti_n11_msg(N11_SESSION_UPDATE_SM_CONTEXT_REQUEST, orig, dest),
req(),
pid(promise_id),
scid(id),
http_version() {
}
itti_n11_update_sm_context_request(
const itti_n11_update_sm_context_request &i)
:
itti_n11_msg(i),
req(i.req),
pid(i.pid),
scid(i.scid),
http_version(i.http_version) {
}
const task_id_t orig, const task_id_t dest, uint32_t promise_id)
: itti_n11_msg(N11_SESSION_UPDATE_SM_CONTEXT_REQUEST, orig, dest),
pid(promise_id),
scid(),
req(),
http_version() {}
itti_n11_update_sm_context_request(
const task_id_t orig, const task_id_t dest, int32_t promise_id,
const std::string id)
: itti_n11_msg(N11_SESSION_UPDATE_SM_CONTEXT_REQUEST, orig, dest),
req(),
pid(promise_id),
scid(id),
http_version() {}
itti_n11_update_sm_context_request(
const itti_n11_update_sm_context_request& i)
: itti_n11_msg(i),
req(i.req),
pid(i.pid),
scid(i.scid),
http_version(i.http_version) {}
const char* get_msg_name() {
return "N11_SESSION_UPDATE_SM_CONTEXT_REQUEST";
}
;
};
smf::pdu_session_update_sm_context_request req;
uint32_t pid;
std::string scid; //SM Context ID
std::string scid; // SM Context ID
uint8_t http_version;
};
//-----------------------------------------------------------------------------
class itti_n11_update_sm_context_response : public itti_n11_msg {
public:
itti_n11_update_sm_context_response(const task_id_t orig,
const task_id_t dest, uint32_t promise_id)
:
itti_n11_msg(N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE, orig, dest),
pid(promise_id),
res(),
session_procedure_type() {
}
itti_n11_update_sm_context_response(
const itti_n11_update_sm_context_response &i)
:
itti_n11_msg(i),
res(i.res),
pid(i.pid),
session_procedure_type(i.session_procedure_type) {
}
const task_id_t orig, const task_id_t dest, uint32_t promise_id)
: itti_n11_msg(N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE, orig, dest),
pid(promise_id),
res(),
session_procedure_type() {}
itti_n11_update_sm_context_response(
const itti_n11_update_sm_context_response& i)
: itti_n11_msg(i),
res(i.res),
pid(i.pid),
session_procedure_type(i.session_procedure_type) {}
itti_n11_update_sm_context_response(
const itti_n11_update_sm_context_response &i, const task_id_t orig,
const itti_n11_update_sm_context_response& i, const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
res(i.res),
pid(i.pid),
session_procedure_type(i.session_procedure_type) {
}
: itti_n11_msg(i, orig, dest),
res(i.res),
pid(i.pid),
session_procedure_type(i.session_procedure_type) {}
const char* get_msg_name() {
return "N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE";
}
;
};
smf::pdu_session_update_sm_context_response res;
uint32_t pid; //promise Id
uint32_t pid; // promise Id
session_management_procedures_type_e session_procedure_type;
};
//-----------------------------------------------------------------------------
class itti_n11_update_pdu_session_status : public itti_n11_msg {
public:
itti_n11_update_pdu_session_status(const task_id_t orig, const task_id_t dest)
:
itti_n11_msg(N11_SESSION_UPDATE_PDU_SESSION_STATUS, orig, dest),
scid(0),
pdu_session_status(pdu_session_status_e::PDU_SESSION_INACTIVE) {
}
: itti_n11_msg(N11_SESSION_UPDATE_PDU_SESSION_STATUS, orig, dest),
scid(0),
pdu_session_status(pdu_session_status_e::PDU_SESSION_INACTIVE) {}
itti_n11_update_pdu_session_status(
const itti_n11_update_pdu_session_status &i)
:
itti_n11_msg(i),
scid(i.scid),
pdu_session_status(i.pdu_session_status) {
}
const itti_n11_update_pdu_session_status& i)
: itti_n11_msg(i),
scid(i.scid),
pdu_session_status(i.pdu_session_status) {}
itti_n11_update_pdu_session_status(
const itti_n11_update_pdu_session_status &i, const task_id_t orig,
const itti_n11_update_pdu_session_status& i, const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
scid(i.scid),
pdu_session_status(i.pdu_session_status) {
}
: itti_n11_msg(i, orig, dest),
scid(i.scid),
pdu_session_status(i.pdu_session_status) {}
const char* get_msg_name() {
return "N11_SESSION_UPDATE_PDU_SESSION_STATUS";
}
;
void set_scid(scid_t id) {
scid = id;
}
;
scid_t scid; //SM Context ID
};
void set_scid(scid_t id) { scid = id; };
scid_t scid; // SM Context ID
pdu_session_status_e pdu_session_status;
void set_pdu_session_status(pdu_session_status_e status) {
pdu_session_status = status;
}
;
};
};
//-----------------------------------------------------------------------------
class itti_n11_n1n2_message_transfer_response_status : public itti_n11_msg {
public:
itti_n11_n1n2_message_transfer_response_status(const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS, orig,
dest),
scid(0),
response_code(0),
msg_type(0),
procedure_type(
session_management_procedures_type_e::PROCEDURE_TYPE_UNKNOWN),
seid(0),
trxn_id(0) {
}
itti_n11_n1n2_message_transfer_response_status(
const itti_n11_n1n2_message_transfer_response_status &i)
:
itti_n11_msg(i),
scid(i.scid),
response_code(i.response_code),
msg_type(i.msg_type),
procedure_type(i.procedure_type),
seid(i.seid),
trxn_id(i.trxn_id) {
}
const task_id_t orig, const task_id_t dest)
: itti_n11_msg(
N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS, orig, dest),
scid(0),
response_code(0),
msg_type(0),
procedure_type(
session_management_procedures_type_e::PROCEDURE_TYPE_UNKNOWN),
seid(0),
trxn_id(0) {}
itti_n11_n1n2_message_transfer_response_status(
const itti_n11_n1n2_message_transfer_response_status& i)
: itti_n11_msg(i),
scid(i.scid),
response_code(i.response_code),
msg_type(i.msg_type),
procedure_type(i.procedure_type),
seid(i.seid),
trxn_id(i.trxn_id) {}
itti_n11_n1n2_message_transfer_response_status(
const itti_n11_n1n2_message_transfer_response_status &i,
const itti_n11_n1n2_message_transfer_response_status& i,
const task_id_t orig, const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
scid(i.scid),
response_code(i.response_code),
msg_type(i.msg_type),
procedure_type(i.procedure_type),
seid(i.seid),
trxn_id(i.trxn_id) {
}
: itti_n11_msg(i, orig, dest),
scid(i.scid),
response_code(i.response_code),
msg_type(i.msg_type),
procedure_type(i.procedure_type),
seid(i.seid),
trxn_id(i.trxn_id) {}
const char* get_msg_name() {
return "N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS";
}
;
void set_scid(scid_t id) {
scid = id;
}
;
void set_response_code(int16_t code) {
response_code = code;
}
;
void set_cause(std::string c) {
cause = c;
}
;
void set_msg_type(uint8_t type) {
msg_type = type;
}
;
};
void set_scid(scid_t id) { scid = id; };
void set_response_code(int16_t code) { response_code = code; };
void set_cause(std::string c) { cause = c; };
void set_msg_type(uint8_t type) { msg_type = type; };
void set_procedure_type(session_management_procedures_type_e type) {
procedure_type = type;
}
;
};
void set_seid(const seid_t &s) {
seid = s;
}
;
void set_seid(const seid_t& s) { seid = s; };
void set_trxn_id(uint64_t t) {
trxn_id = t;
}
;
void set_trxn_id(uint64_t t) { trxn_id = t; };
scid_t scid; //SM Context ID
scid_t scid; // SM Context ID
int16_t response_code;
std::string cause;
uint8_t msg_type;
session_management_procedures_type_e procedure_type;
seid_t seid;
uint64_t trxn_id;
};
//-----------------------------------------------------------------------------
class itti_n11_release_sm_context_request : public itti_n11_msg {
public:
itti_n11_release_sm_context_request(const task_id_t orig,
const task_id_t dest, uint32_t promise_id)
:
itti_n11_msg(N11_SESSION_RELEASE_SM_CONTEXT_REQUEST, orig, dest),
pid(promise_id),
http_version(1) {
}
itti_n11_release_sm_context_request(const task_id_t orig,
const task_id_t dest, uint32_t promise_id,
const std::string id)
:
itti_n11_msg(N11_SESSION_RELEASE_SM_CONTEXT_REQUEST, orig, dest),
pid(promise_id),
scid(id),
http_version(1) {
}
itti_n11_release_sm_context_request(
const itti_n11_release_sm_context_request &i)
:
itti_n11_msg(i),
pid(i.pid),
scid(i.scid),
req(i.req),
http_version(i.http_version) {
}
const task_id_t orig, const task_id_t dest, uint32_t promise_id)
: itti_n11_msg(N11_SESSION_RELEASE_SM_CONTEXT_REQUEST, orig, dest),
pid(promise_id),
http_version(1) {}
itti_n11_release_sm_context_request(
const itti_n11_release_sm_context_request &i, const task_id_t orig,
const task_id_t orig, const task_id_t dest, uint32_t promise_id,
const std::string id)
: itti_n11_msg(N11_SESSION_RELEASE_SM_CONTEXT_REQUEST, orig, dest),
pid(promise_id),
scid(id),
http_version(1) {}
itti_n11_release_sm_context_request(
const itti_n11_release_sm_context_request& i)
: itti_n11_msg(i),
pid(i.pid),
scid(i.scid),
req(i.req),
http_version(i.http_version) {}
itti_n11_release_sm_context_request(
const itti_n11_release_sm_context_request& i, const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
pid(i.pid),
scid(i.scid),
req(i.req),
http_version(i.http_version) {
}
: itti_n11_msg(i, orig, dest),
pid(i.pid),
scid(i.scid),
req(i.req),
http_version(i.http_version) {}
const char* get_msg_name() {
return "N11_SESSION_RELEASE_SM_CONTEXT_REQUEST";
}
;
};
smf::pdu_session_release_sm_context_request req;
std::string scid; //SM Context ID
uint32_t pid; //Promise Id
uint8_t http_version; //HTTP version
std::string scid; // SM Context ID
uint32_t pid; // Promise Id
uint8_t http_version; // HTTP version
};
//-----------------------------------------------------------------------------
class itti_n11_release_sm_context_response : public itti_n11_msg {
public:
itti_n11_release_sm_context_response(const task_id_t orig,
const task_id_t dest,
uint32_t promise_id)
:
itti_n11_msg(N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE, orig, dest),
pid(promise_id),
res() {
}
itti_n11_release_sm_context_response(
const itti_n11_release_sm_context_response &i)
:
itti_n11_msg(i),
res(i.res),
pid(i.pid) {
}
const task_id_t orig, const task_id_t dest, uint32_t promise_id)
: itti_n11_msg(N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE, orig, dest),
pid(promise_id),
res() {}
itti_n11_release_sm_context_response(
const itti_n11_release_sm_context_response &i, const task_id_t orig,
const itti_n11_release_sm_context_response& i)
: itti_n11_msg(i), res(i.res), pid(i.pid) {}
itti_n11_release_sm_context_response(
const itti_n11_release_sm_context_response& i, const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
res(i.res),
pid(i.pid) {
}
: itti_n11_msg(i, orig, dest), res(i.res), pid(i.pid) {}
const char* get_msg_name() {
return "N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE";
}
;
};
smf::pdu_session_release_sm_context_response res;
uint32_t pid; //Promise Id
uint32_t pid; // Promise Id
};
//-----------------------------------------------------------------------------
class itti_n11_session_report_request : public itti_n11_msg {
public:
itti_n11_session_report_request(const task_id_t orig, const task_id_t dest)
:
itti_n11_msg(N11_SESSION_REPORT_RESPONSE, orig, dest),
res(),
http_version() {
}
itti_n11_session_report_request(const itti_n11_session_report_request &i)
:
itti_n11_msg(i),
res(i.res),
http_version(i.http_version) {
}
itti_n11_session_report_request(const itti_n11_session_report_request &i,
const task_id_t orig, const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
res(i.res),
http_version(i.http_version) {
}
const char* get_msg_name() {
return "N11_SESSION_REPORT_RESPONSE";
}
;
: itti_n11_msg(N11_SESSION_REPORT_RESPONSE, orig, dest),
res(),
http_version() {}
itti_n11_session_report_request(const itti_n11_session_report_request& i)
: itti_n11_msg(i), res(i.res), http_version(i.http_version) {}
itti_n11_session_report_request(
const itti_n11_session_report_request& i, const task_id_t orig,
const task_id_t dest)
: itti_n11_msg(i, orig, dest), res(i.res), http_version(i.http_version) {}
const char* get_msg_name() { return "N11_SESSION_REPORT_RESPONSE"; };
smf::pdu_session_report_response res;
uint8_t http_version;
};
//-----------------------------------------------------------------------------
class itti_n11_notify_sm_context_status : public itti_n11_msg {
public:
itti_n11_notify_sm_context_status(const task_id_t orig, const task_id_t dest)
:
itti_n11_msg(N11_SESSION_NOTIFY_SM_CONTEXT_STATUS, orig, dest),
scid(0),
sm_context_status(),
amf_status_uri(),
http_version() {
}
: itti_n11_msg(N11_SESSION_NOTIFY_SM_CONTEXT_STATUS, orig, dest),
scid(0),
sm_context_status(),
amf_status_uri(),
http_version() {}
itti_n11_notify_sm_context_status(const itti_n11_notify_sm_context_status& i)
: itti_n11_msg(i),
scid(i.scid),
sm_context_status(i.sm_context_status),
amf_status_uri(i.amf_status_uri),
http_version(i.http_version) {}
itti_n11_notify_sm_context_status(
const itti_n11_notify_sm_context_status &i)
:
itti_n11_msg(i),
scid(i.scid),
sm_context_status(i.sm_context_status),
amf_status_uri (i.amf_status_uri),
http_version(i.http_version) {
}
itti_n11_notify_sm_context_status(
const itti_n11_notify_sm_context_status &i, const task_id_t orig,
const itti_n11_notify_sm_context_status& i, const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
scid(i.scid),
sm_context_status(i.sm_context_status),
amf_status_uri(i.amf_status_uri),
http_version(i.http_version) {
}
const char* get_msg_name() {
return "N11_SESSION_NOTIFY_SM_CONTEXT_STATUS";
}
;
void set_scid(scid_t id) {
scid = id;
}
;
: itti_n11_msg(i, orig, dest),
scid(i.scid),
sm_context_status(i.sm_context_status),
amf_status_uri(i.amf_status_uri),
http_version(i.http_version) {}
const char* get_msg_name() { return "N11_SESSION_NOTIFY_SM_CONTEXT_STATUS"; };
void set_scid(scid_t id) { scid = id; };
void set_sm_context_status(std::string status) {
sm_context_status = status;
}
;
scid_t scid; //SM Context ID
};
scid_t scid; // SM Context ID
std::string sm_context_status;
std::string amf_status_uri;
uint8_t http_version;
};
//-----------------------------------------------------------------------------
class itti_n11_notify_subscribed_event : public itti_n11_msg {
public:
itti_n11_notify_subscribed_event(const task_id_t orig, const task_id_t dest)
:
itti_n11_msg(N11_NOTIFY_SUBSCRIBED_EVENT, orig, dest),
notif_id(),
http_version() {
}
: itti_n11_msg(N11_NOTIFY_SUBSCRIBED_EVENT, orig, dest),
notif_id(),
http_version() {}
itti_n11_notify_subscribed_event(const itti_n11_notify_subscribed_event& i)
: itti_n11_msg(i), notif_id(i.notif_id), http_version(i.http_version) {}
itti_n11_notify_subscribed_event(
const itti_n11_notify_subscribed_event &i)
:
itti_n11_msg(i),
notif_id(i.notif_id),
http_version(i.http_version) {
}
itti_n11_notify_subscribed_event(
const itti_n11_notify_subscribed_event &i, const task_id_t orig,
const itti_n11_notify_subscribed_event& i, const task_id_t orig,
const task_id_t dest)
:
itti_n11_msg(i, orig, dest),
notif_id(i.notif_id),
http_version(i.http_version) {
}
const char* get_msg_name() {
return "N11_NOTIFY_SUBSCRIBED_EVENT";
}
;
: itti_n11_msg(i, orig, dest),
notif_id(i.notif_id),
http_version(i.http_version) {}
const char* get_msg_name() { return "N11_NOTIFY_SUBSCRIBED_EVENT"; };
std::string notif_id;
std::vector<smf::event_notification> event_notifs;
std::vector<smf::event_notification> event_notifs;
uint8_t http_version;
};
//-----------------------------------------------------------------------------
class itti_n11_register_nf_instance_request : public itti_n11_msg {
public:
itti_n11_register_nf_instance_request(const task_id_t orig,
const task_id_t dest)
itti_n11_register_nf_instance_request(
const task_id_t orig, const task_id_t dest)
: itti_n11_msg(N11_REGISTER_NF_INSTANCE_REQUEST, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "N11_REGISTER_NF_INSTANCE_REQUEST"; };
const char* get_msg_name() { return "N11_REGISTER_NF_INSTANCE_REQUEST"; };
smf::smf_profile profile;
uint8_t http_version;
......@@ -569,26 +421,25 @@ class itti_n11_register_nf_instance_request : public itti_n11_msg {
//-----------------------------------------------------------------------------
class itti_n11_register_nf_instance_response : public itti_n11_msg {
public:
itti_n11_register_nf_instance_response(const task_id_t orig,
const task_id_t dest)
itti_n11_register_nf_instance_response(
const task_id_t orig, const task_id_t dest)
: itti_n11_msg(N11_REGISTER_NF_INSTANCE_RESPONSE, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "N11_REGISTER_NF_INSTANCE_RESPONSE"; };
const char* get_msg_name() { return "N11_REGISTER_NF_INSTANCE_RESPONSE"; };
smf::smf_profile profile;
uint8_t http_version;
uint8_t http_response_code;
};
//-----------------------------------------------------------------------------
class itti_n11_update_nf_instance_request : public itti_n11_msg {
public:
itti_n11_update_nf_instance_request(const task_id_t orig,
const task_id_t dest)
itti_n11_update_nf_instance_request(
const task_id_t orig, const task_id_t dest)
: itti_n11_msg(N11_UPDATE_NF_INSTANCE_REQUEST, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "N11_UPDATE_NF_INSTANCE_REQUEST"; };
const char* get_msg_name() { return "N11_UPDATE_NF_INSTANCE_REQUEST"; };
std::vector<oai::smf_server::model::PatchItem> patch_items;
uint8_t http_version;
......@@ -598,29 +449,40 @@ class itti_n11_update_nf_instance_request : public itti_n11_msg {
//-----------------------------------------------------------------------------
class itti_n11_update_nf_instance_response : public itti_n11_msg {
public:
itti_n11_update_nf_instance_response(const task_id_t orig,
const task_id_t dest)
itti_n11_update_nf_instance_response(
const task_id_t orig, const task_id_t dest)
: itti_n11_msg(N11_UPDATE_NF_INSTANCE_RESPONSE, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "N11_UPDATE_NF_INSTANCE_RESPONSE"; };
const char* get_msg_name() { return "N11_UPDATE_NF_INSTANCE_RESPONSE"; };
uint8_t http_version;
std::string smf_instance_id;
uint8_t http_response_code;
};
//-----------------------------------------------------------------------------
class itti_n11_deregister_nf_instance : public itti_n11_msg {
public:
itti_n11_deregister_nf_instance(const task_id_t orig,
const task_id_t dest)
: itti_n11_msg(N11_DEREGISTER_NF_INSTANCE, orig, dest),
http_version(1) {}
const char *get_msg_name() { return "N11_DEREGISTER_NF_INSTANCE"; };
itti_n11_deregister_nf_instance(const task_id_t orig, const task_id_t dest)
: itti_n11_msg(N11_DEREGISTER_NF_INSTANCE, orig, dest), http_version(1) {}
const char* get_msg_name() { return "N11_DEREGISTER_NF_INSTANCE"; };
uint8_t http_version;
std::string smf_instance_id;
};
//-----------------------------------------------------------------------------
class itti_n11_subscribe_upf_status_notify : public itti_n11_msg {
public:
itti_n11_subscribe_upf_status_notify(
const task_id_t orig, const task_id_t dest)
: itti_n11_msg(N11_SUBSCRIBE_UPF_STATUS_NOTIFY, orig, dest),
http_version(1) {}
const char* get_msg_name() { return "N11_SUBSCRIBE_UPF_STATUS_NOTIFY"; };
std::string url;
nlohmann::json json_data;
uint8_t http_version;
};
#endif /* ITTI_MSG_N11_HPP_INCLUDED_ */
......@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
* the OAI Public License, Version 1.1 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -30,64 +30,64 @@
#define ITTI_MSG_SBI_HPP_INCLUDED_
#include "itti_msg.hpp"
#include "smf_msg.hpp"
#include "pistache/http.h"
#include "smf_msg.hpp"
class itti_sbi_msg : public itti_msg {
public:
itti_sbi_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_sbi_msg(const itti_sbi_msg &i)
:
itti_msg(i) {
}
itti_sbi_msg(const itti_sbi_msg &i, const task_id_t orig,
const task_id_t dest)
:
itti_sbi_msg(i) {
origin = orig;
itti_sbi_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_sbi_msg(const itti_sbi_msg& i) : itti_msg(i) {}
itti_sbi_msg(
const itti_sbi_msg& i, const task_id_t orig, const task_id_t dest)
: itti_sbi_msg(i) {
origin = orig;
destination = dest;
}
};
//-----------------------------------------------------------------------------
class itti_sbi_event_exposure_request : public itti_sbi_msg {
public:
itti_sbi_event_exposure_request(const task_id_t orig, const task_id_t dest)
:
itti_sbi_msg(SBI_EVENT_EXPOSURE_REQUEST, orig, dest),
event_exposure(),
http_version(1) {
}
itti_sbi_event_exposure_request(
const itti_sbi_event_exposure_request &i)
:
itti_sbi_msg(i),
event_exposure(i.event_exposure),
http_version(1) {
}
: itti_sbi_msg(SBI_EVENT_EXPOSURE_REQUEST, orig, dest),
event_exposure(),
http_version(1) {}
itti_sbi_event_exposure_request(const itti_sbi_event_exposure_request& i)
: itti_sbi_msg(i), event_exposure(i.event_exposure), http_version(1) {}
itti_sbi_event_exposure_request(
const itti_sbi_event_exposure_request &i, const task_id_t orig,
const itti_sbi_event_exposure_request& i, const task_id_t orig,
const task_id_t dest)
:
itti_sbi_msg(i, orig, dest),
event_exposure(i.event_exposure),
http_version(i.http_version) {
}
const char* get_msg_name() {
return "SBI_EVENT_EXPOSURE_REQUEST";
}
;
: itti_sbi_msg(i, orig, dest),
event_exposure(i.event_exposure),
http_version(i.http_version) {}
const char* get_msg_name() { return "SBI_EVENT_EXPOSURE_REQUEST"; };
smf::event_exposure_msg event_exposure;
uint8_t http_version;
};
//-----------------------------------------------------------------------------
class itti_sbi_notification_data : public itti_sbi_msg {
public:
itti_sbi_notification_data(const task_id_t orig, const task_id_t dest)
: itti_sbi_msg(SBI_NOTIFICATION_DATA, orig, dest),
notification_msg(),
http_version(1) {}
itti_sbi_notification_data(const itti_sbi_notification_data& i)
: itti_sbi_msg(i),
notification_msg(i.notification_msg),
http_version(1) {}
itti_sbi_notification_data(
const itti_sbi_notification_data& i, const task_id_t orig,
const task_id_t dest)
: itti_sbi_msg(i, orig, dest),
notification_msg(i.notification_msg),
http_version(i.http_version) {}
const char* get_msg_name() { return "SBI_NOTIFICATION_DATA"; };
smf::data_notification_msg notification_msg;
uint8_t http_version;
};
#endif /* ITTI_MSG_SBI_HPP_INCLUDED_ */
......@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -22,12 +22,13 @@
#ifndef FILE_SMF_SEEN
#define FILE_SMF_SEEN
#include"3gpp_29.274.h"
#include"3gpp_29.571.h"
#include"3gpp_24.501.h"
#include "3gpp_29.274.h"
#include "3gpp_29.571.h"
#include "3gpp_24.501.h"
#include <nlohmann/json.hpp>
typedef uint64_t supi64_t;
#define SUPI_64_FMT "%" SCNu64
#define SUPI_64_FMT "%" SCNu64
#define SUPI_DIGITS_MAX 15
......@@ -36,8 +37,8 @@ typedef struct {
char data[SUPI_DIGITS_MAX + 1];
} supi_t;
static void smf_string_to_supi(supi_t *const supi, char const *const supi_str) {
//strncpy(supi->data, supi_str, SUPI_DIGITS_MAX + 1);
static void smf_string_to_supi(supi_t* const supi, char const* const supi_str) {
// strncpy(supi->data, supi_str, SUPI_DIGITS_MAX + 1);
memcpy((void*) supi->data, (void*) supi_str, SUPI_DIGITS_MAX + 1);
supi->length = strlen(supi->data);
return;
......@@ -58,25 +59,13 @@ static uint64_t smf_supi_to_u64(supi_t supi) {
typedef struct s_nssai // section 28.4, TS23.003
{
uint8_t sST;
//uint32_t sD:24;
// uint32_t sD:24;
std::string sD;
//s_nssai(const uint8_t& sst, const uint32_t sd) : sST(sst), sD(sd) {}
s_nssai(const uint8_t &sst, const std::string sd)
:
sST(sst),
sD(sd) {
}
s_nssai()
:
sST(),
sD() {
}
s_nssai(const s_nssai &p)
:
sST(p.sST),
sD(p.sD) {
}
bool operator==(const struct s_nssai &s) const {
// s_nssai(const uint8_t& sst, const uint32_t sd) : sST(sst), sD(sd) {}
s_nssai(const uint8_t& sst, const std::string sd) : sST(sst), sD(sd) {}
s_nssai() : sST(), sD() {}
s_nssai(const s_nssai& p) : sST(p.sST), sD(p.sD) {}
bool operator==(const struct s_nssai& s) const {
if ((s.sST == this->sST) && (s.sD.compare(this->sD) == 0)) {
return true;
} else {
......@@ -88,127 +77,126 @@ typedef struct s_nssai // section 28.4, TS23.003
typedef uint8_t pdu_session_id;
//SMF + AMF + 3GPP TS 29.571 (Common data)
// SMF + AMF + 3GPP TS 29.571 (Common data)
enum class http_response_codes_e {
HTTP_RESPONSE_CODE_OK = 200,
HTTP_RESPONSE_CODE_CREATED = 201,
HTTP_RESPONSE_CODE_ACCEPTED = 202,
HTTP_RESPONSE_CODE_NO_CONTENT = 204,
HTTP_RESPONSE_CODE_BAD_REQUEST = 400,
HTTP_RESPONSE_CODE_UNAUTHORIZED = 401,
HTTP_RESPONSE_CODE_FORBIDDEN = 403,
HTTP_RESPONSE_CODE_NOT_FOUND = 404,
HTTP_RESPONSE_CODE_METHOD_NOT_ALLOWED = 405,
HTTP_RESPONSE_CODE_REQUEST_TIMEOUT = 408,
HTTP_RESPONSE_CODE_406_NOT_ACCEPTED = 406,
HTTP_RESPONSE_CODE_CONFLICT = 409,
HTTP_RESPONSE_CODE_GONE = 410,
HTTP_RESPONSE_CODE_LENGTH_REQUIRED = 411,
HTTP_RESPONSE_CODE_PRECONDITION_FAILED = 412,
HTTP_RESPONSE_CODE_PAYLOAD_TOO_LARGE = 413,
HTTP_RESPONSE_CODE_URI_TOO_LONG = 414,
HTTP_RESPONSE_CODE_OK = 200,
HTTP_RESPONSE_CODE_CREATED = 201,
HTTP_RESPONSE_CODE_ACCEPTED = 202,
HTTP_RESPONSE_CODE_NO_CONTENT = 204,
HTTP_RESPONSE_CODE_BAD_REQUEST = 400,
HTTP_RESPONSE_CODE_UNAUTHORIZED = 401,
HTTP_RESPONSE_CODE_FORBIDDEN = 403,
HTTP_RESPONSE_CODE_NOT_FOUND = 404,
HTTP_RESPONSE_CODE_METHOD_NOT_ALLOWED = 405,
HTTP_RESPONSE_CODE_REQUEST_TIMEOUT = 408,
HTTP_RESPONSE_CODE_406_NOT_ACCEPTED = 406,
HTTP_RESPONSE_CODE_CONFLICT = 409,
HTTP_RESPONSE_CODE_GONE = 410,
HTTP_RESPONSE_CODE_LENGTH_REQUIRED = 411,
HTTP_RESPONSE_CODE_PRECONDITION_FAILED = 412,
HTTP_RESPONSE_CODE_PAYLOAD_TOO_LARGE = 413,
HTTP_RESPONSE_CODE_URI_TOO_LONG = 414,
HTTP_RESPONSE_CODE_UNSUPPORTED_MEDIA_TYPE = 415,
HTTP_RESPONSE_CODE_TOO_MANY_REQUESTS = 429,
HTTP_RESPONSE_CODE_INTERNAL_SERVER_ERROR = 500,
HTTP_RESPONSE_CODE_NOT_IMPLEMENTED = 501,
HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE = 503,
HTTP_RESPONSE_CODE_GATEWAY_TIMEOUT = 504
HTTP_RESPONSE_CODE_TOO_MANY_REQUESTS = 429,
HTTP_RESPONSE_CODE_INTERNAL_SERVER_ERROR = 500,
HTTP_RESPONSE_CODE_NOT_IMPLEMENTED = 501,
HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE = 503,
HTTP_RESPONSE_CODE_GATEWAY_TIMEOUT = 504
};
//From 23.502
// From 23.502
enum class session_management_procedures_type_e {
PROCEDURE_TYPE_UNKNOWN = 0,
PDU_SESSION_ESTABLISHMENT_UE_REQUESTED = 1,
SERVICE_REQUEST_UE_TRIGGERED_STEP1 = 2,
SERVICE_REQUEST_UE_TRIGGERED_STEP2 = 3,
SERVICE_REQUEST_NETWORK_TRIGGERED = 4,
PROCEDURE_TYPE_UNKNOWN = 0,
PDU_SESSION_ESTABLISHMENT_UE_REQUESTED = 1,
SERVICE_REQUEST_UE_TRIGGERED_STEP1 = 2,
SERVICE_REQUEST_UE_TRIGGERED_STEP2 = 3,
SERVICE_REQUEST_NETWORK_TRIGGERED = 4,
PDU_SESSION_MODIFICATION_UE_INITIATED_STEP1 = 5,
PDU_SESSION_MODIFICATION_UE_INITIATED_STEP2 = 6,
PDU_SESSION_MODIFICATION_UE_INITIATED_STEP3 = 7,
PDU_SESSION_MODIFICATION_SMF_REQUESTED = 8,
PDU_SESSION_MODIFICATION_AN_REQUESTED = 9,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP1 = 10,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP2 = 11,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP3 = 12,
PDU_SESSION_RELEASE_SMF_INITIATED = 13,
PDU_SESSION_RELEASE_AMF_INITIATED = 14,
PDU_SESSION_RELEASE_AN_INITIATED = 15,
PDU_SESSION_TEST = 16
PDU_SESSION_MODIFICATION_SMF_REQUESTED = 8,
PDU_SESSION_MODIFICATION_AN_REQUESTED = 9,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP1 = 10,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP2 = 11,
PDU_SESSION_RELEASE_UE_REQUESTED_STEP3 = 12,
PDU_SESSION_RELEASE_SMF_INITIATED = 13,
PDU_SESSION_RELEASE_AMF_INITIATED = 14,
PDU_SESSION_RELEASE_AN_INITIATED = 15,
PDU_SESSION_TEST = 16
};
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_SMF_INITIATED",
"PDU_SESSION_RELEASE_AMF_INITIATED", "PDU_SESSION_RELEASE_AN_INITIATED",
"PDU_SESSION_TEST"
};
{"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_SMF_INITIATED",
"PDU_SESSION_RELEASE_AMF_INITIATED",
"PDU_SESSION_RELEASE_AN_INITIATED",
"PDU_SESSION_TEST"
};
enum class sm_context_status_e {
SM_CONTEXT_STATUS_ACTIVE = 0,
SM_CONTEXT_STATUS_ACTIVE = 0,
SM_CONTEXT_STATUS_RELEASED = 1
};
static const std::vector<std::string> sm_context_status_e2str =
{ "ACTIVE",
"RELEASED"
};
static const std::vector<std::string> sm_context_status_e2str = {"ACTIVE",
"RELEASED"};
typedef struct qos_profile_gbr_s {
gfbr_t gfbr; //Guaranteed Flow Bit Rate
gfbr_t gfbr; // Guaranteed Flow Bit Rate
mfbr_t mfbr; // Maximum Flow Bit Rate
// Notification Control
// Maximum Packet Loss Rate (UL/DL)
} qos_profile_gbr_t;
enum class qos_profile_type_e {
NON_GBR = 0,
GBR = 1
};
enum class qos_profile_type_e { NON_GBR = 0, GBR = 1 };
//See Section 5.7.2@3GPP TS 23.501
// See Section 5.7.2@3GPP TS 23.501
typedef struct qos_profile_s {
uint8_t _5qi;
arp_5gc_t arp;
uint8_t priority_level;
qos_profile_type_e profile_type;
union {
reflective_qos_attribute_e rqa; //Reflective QoS Attribute (RQA)
qos_profile_gbr_t qos_profile_gbr; //Attributes for GBR
reflective_qos_attribute_e rqa; // Reflective QoS Attribute (RQA)
qos_profile_gbr_t qos_profile_gbr; // Attributes for GBR
} parameter;
} qos_profile_t;
//URL, N1, N2 (may get from configuration file)
#define NAMF_COMMUNICATION_BASE "/namf-comm/"
#define NAMF_COMMUNICATION_N1N2_MESSAGE_TRANSFER_URL "/ue-contexts/{}/n1-n2-messages" //context id
#define NUDM_SDM_BASE "/nudm-sdm/"
#define NUDM_SDM_GET_SM_DATA_URL "/{}/sm-data" //ue Id
#define N1_SM_CONTENT_ID "n1SmMsg"
#define N1N2_MESSAGE_CLASS "SM"
#define N2_SM_CONTENT_ID "n2msg"
#define NSMF_PDU_SESSION_BASE "/nsmf-pdusession/"
#define NSMF_CALLBACK_N1N2_MESSAGE_TRANSFER_FAILURE "/callback/N1N2MsgTxfrFailureNotification/{}" //UE Id
#define NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL "/sm-contexts"
#define NSMF_PDU_SESSION_SM_CONTEXT_UPDATE_URL "/sm-contexts/"
//NRF
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define NNRF_NF_REGISTER_URL "/nf-instances/"
// URL, N1, N2 (may get from configuration file)
#define NAMF_COMMUNICATION_BASE "/namf-comm/"
#define NAMF_COMMUNICATION_N1N2_MESSAGE_TRANSFER_URL \
"/ue-contexts/{}/n1-n2-messages" // context id
#define NUDM_SDM_BASE "/nudm-sdm/"
#define NUDM_SDM_GET_SM_DATA_URL "/{}/sm-data" // ue Id
#define N1_SM_CONTENT_ID "n1SmMsg"
#define N1N2_MESSAGE_CLASS "SM"
#define N2_SM_CONTENT_ID "n2msg"
#define NSMF_PDU_SESSION_BASE "/nsmf-pdusession/"
#define NSMF_CALLBACK_N1N2_MESSAGE_TRANSFER_FAILURE \
"/callback/N1N2MsgTxfrFailureNotification/{}" // UE Id
#define NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL "/sm-contexts"
#define NSMF_PDU_SESSION_SM_CONTEXT_UPDATE_URL "/sm-contexts/"
// NRF
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define NNRF_NF_REGISTER_URL "/nf-instances/"
#define NNRF_NF_STATUS_SUBSCRIBE_URL "/subscriptions/"
#define NRF_CURL_TIMEOUT_MS 100L
//for CURL
// for CURL
#define AMF_CURL_TIMEOUT_MS 100L
#define AMF_NUMBER_RETRIES 3
#define UDM_CURL_TIMEOUT_MS 100L
......@@ -242,9 +230,9 @@ typedef struct nf_service_version_s {
std::string api_version_in_uri; // apiVersionInUri
std::string api_full_version; // apiFullVersion
nf_service_version_s &operator=(const nf_service_version_s &s) {
nf_service_version_s& operator=(const nf_service_version_s& s) {
api_version_in_uri = s.api_version_in_uri;
api_full_version = s.api_full_version;
api_full_version = s.api_full_version;
}
std::string to_string() const {
......@@ -283,4 +271,34 @@ typedef struct nf_service_s {
}
} nf_service_t;
typedef struct dnn_upf_info_item_s {
std::string dnn;
// std::vector<std::string> dnai_list
// std::vector<std::string> pdu_session_types
} dnn_upf_info_item_t;
typedef struct snssai_upf_info_item_s {
snssai_t snssai;
std::vector<dnn_upf_info_item_t> dnn_upf_info_list;
} snssai_upf_info_item_t;
typedef struct upf_info_s {
std::vector<snssai_upf_info_item_t> snssai_upf_info_list;
} upf_info_t;
typedef struct patch_item_s {
std::string op;
std::string path;
// std::string from;
std::string value;
nlohmann::json to_json() const {
nlohmann::json json_data = {};
json_data["op"] = op;
json_data["path"] = path;
json_data["value"] = value;
return json_data;
}
} patch_item_t;
#endif
......@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -31,7 +31,7 @@
#include <utility>
typedef enum {
TASK_FIRST = 0,
TASK_FIRST = 0,
TASK_ITTI_TIMER = TASK_FIRST,
TASK_ASYNC_SHELL_CMD,
TASK_SMF_APP,
......@@ -54,9 +54,9 @@ typedef enum message_priorities_e {
} message_priorities_t;
typedef enum {
ITTI_MSG_TYPE_NONE = -1,
ITTI_MSG_TYPE_NONE = -1,
ITTI_MSG_TYPE_FIRST = 0,
ASYNC_SHELL_CMD = ITTI_MSG_TYPE_FIRST,
ASYNC_SHELL_CMD = ITTI_MSG_TYPE_FIRST,
RESTORE_N4_SESSIONS,
S11_REMOTE_PEER_NOT_RESPONDING,
S11_CREATE_SESSION_REQUEST,
......@@ -79,7 +79,7 @@ typedef enum {
S1U_ERROR_INDICATION,
S1U_SUPPORTED_EXTENSION_HEADERS_NOTIFICATION,
S1U_END_MARKER,
S1U_G_PDU, // UNUSED
S1U_G_PDU, // UNUSED
N4_HEARTBEAT_REQUEST,
N4_HEARTBEAT_RESPONSE,
N4_PFCP_PFD_MANAGEMENT_REQUEST,
......@@ -121,8 +121,10 @@ typedef enum {
N11_UPDATE_NF_INSTANCE_REQUEST,
N11_UPDATE_NF_INSTANCE_RESPONSE,
N11_DEREGISTER_NF_INSTANCE,
N11_SUBSCRIBE_UPF_STATUS_NOTIFY,
NX_TRIGGER_SESSION_MODIFICATION,
SBI_EVENT_EXPOSURE_REQUEST,
SBI_NOTIFICATION_DATA,
UDP_INIT,
UDP_DATA_REQ,
UDP_DATA_IND,
......@@ -135,13 +137,14 @@ typedef enum {
typedef unsigned long message_number_t;
class itti_msg {
public:
public:
itti_msg();
itti_msg(const itti_msg_type_t msg_type, const task_id_t origin, const task_id_t destination);
itti_msg(
const itti_msg_type_t msg_type, const task_id_t origin,
const task_id_t destination);
itti_msg(const itti_msg& i);
itti_msg& operator=(itti_msg other)
{
itti_msg& operator=(itti_msg other) {
std::swap(msg_num, other.msg_num);
std::swap(origin, other.origin);
std::swap(destination, other.destination);
......@@ -153,36 +156,47 @@ public:
static const char* get_msg_name();
message_number_t msg_num;
task_id_t origin;
task_id_t destination;
itti_msg_type_t msg_type;
task_id_t origin;
task_id_t destination;
itti_msg_type_t msg_type;
};
class itti_msg_timeout : public itti_msg {
public:
itti_msg_timeout(const task_id_t origin, const task_id_t destination, uint32_t timer_id, uint64_t arg1_user, uint64_t arg2_user):
itti_msg(TIME_OUT, origin, destination), timer_id(timer_id), arg1_user(arg1_user), arg2_user(arg2_user) {}
itti_msg_timeout(const itti_msg_timeout& i) : itti_msg(i), timer_id(i.timer_id), arg1_user(i.arg1_user), arg2_user(i.arg2_user) {}
static const char* get_msg_name() {return "TIME_OUT";};
public:
itti_msg_timeout(
const task_id_t origin, const task_id_t destination, uint32_t timer_id,
uint64_t arg1_user, uint64_t arg2_user)
: itti_msg(TIME_OUT, origin, destination),
timer_id(timer_id),
arg1_user(arg1_user),
arg2_user(arg2_user) {}
itti_msg_timeout(const itti_msg_timeout& i)
: itti_msg(i),
timer_id(i.timer_id),
arg1_user(i.arg1_user),
arg2_user(i.arg2_user) {}
static const char* get_msg_name() { return "TIME_OUT"; };
uint32_t timer_id;
uint64_t arg1_user;
uint64_t arg2_user;
};
class itti_msg_ping : public itti_msg {
public:
itti_msg_ping(const task_id_t origin, const task_id_t destination, uint32_t seq): itti_msg(HEALTH_PING, origin, destination), seq(seq) {}
public:
itti_msg_ping(
const task_id_t origin, const task_id_t destination, uint32_t seq)
: itti_msg(HEALTH_PING, origin, destination), seq(seq) {}
itti_msg_ping(const itti_msg_ping& i) : itti_msg(i), seq(i.seq) {}
static const char* get_msg_name() {return "HEALTH_PING";};
static const char* get_msg_name() { return "HEALTH_PING"; };
uint32_t seq;
};
class itti_msg_terminate : public itti_msg {
public:
itti_msg_terminate(const task_id_t origin, const task_id_t destination):
itti_msg(TERMINATE, origin, destination) {}
public:
itti_msg_terminate(const task_id_t origin, const task_id_t destination)
: itti_msg(TERMINATE, origin, destination) {}
itti_msg_terminate(const itti_msg_terminate& i) : itti_msg(i) {}
static const char* get_msg_name() {return "TERMINATE";};
static const char* get_msg_name() { return "TERMINATE"; };
};
#endif /* SRC_ITTI_ITTI_MSG_HPP_INCLUDED_ */
......@@ -68,24 +68,24 @@ extern "C" {
using namespace smf;
extern util::async_shell_cmd *async_shell_cmd_inst;
extern smf_app *smf_app_inst;
extern util::async_shell_cmd* async_shell_cmd_inst;
extern smf_app* smf_app_inst;
extern smf_config smf_cfg;
smf_n4 *smf_n4_inst = nullptr;
smf_n10 *smf_n10_inst = nullptr;
smf_n11 *smf_n11_inst = nullptr;
extern itti_mw *itti_inst;
smf_n4* smf_n4_inst = nullptr;
smf_n10* smf_n10_inst = nullptr;
smf_n11* smf_n11_inst = nullptr;
extern itti_mw* itti_inst;
void smf_app_task(void *);
void smf_app_task(void*);
//------------------------------------------------------------------------------
int smf_app::apply_config(const smf_config &cfg) {
int smf_app::apply_config(const smf_config& cfg) {
Logger::smf_app().info("Apply config...");
for (int ia = 0; ia < cfg.num_dnn; ia++) {
if (cfg.dnn[ia].pool_id_iv4 >= 0) {
int pool_id = cfg.dnn[ia].pool_id_iv4;
int range = be32toh(cfg.ue_pool_range_high[pool_id].s_addr) -
int range = be32toh(cfg.ue_pool_range_high[pool_id].s_addr) -
be32toh(cfg.ue_pool_range_low[pool_id].s_addr);
paa_dynamic::get_instance().add_pool(
cfg.dnn[ia].dnn, pool_id, cfg.ue_pool_range_low[pool_id], range);
......@@ -94,9 +94,9 @@ int smf_app::apply_config(const smf_config &cfg) {
}
if (cfg.dnn[ia].pool_id_iv6 >= 0) {
int pool_id = cfg.dnn[ia].pool_id_iv6;
paa_dynamic::get_instance().add_pool(cfg.dnn[ia].dnn, pool_id,
cfg.paa_pool6_prefix[pool_id],
cfg.paa_pool6_prefix_len[pool_id]);
paa_dynamic::get_instance().add_pool(
cfg.dnn[ia].dnn, pool_id, cfg.paa_pool6_prefix[pool_id],
cfg.paa_pool6_prefix_len[pool_id]);
// TODO: check with dnn_label
}
}
......@@ -118,7 +118,7 @@ uint64_t smf_app::generate_seid() {
}
//------------------------------------------------------------------------------
void smf_app::generate_smf_context_ref(std::string &smf_ref) {
void smf_app::generate_smf_context_ref(std::string& smf_ref) {
smf_ref = std::to_string(sm_context_ref_generator.get_uid());
}
......@@ -128,7 +128,7 @@ scid_t smf_app::generate_smf_context_ref() {
}
//------------------------------------------------------------------------------
void smf_app::generate_ev_subscription_id(std::string &sub_id) {
void smf_app::generate_ev_subscription_id(std::string& sub_id) {
sub_id = std::to_string(evsub_id_generator.get_uid());
}
......@@ -138,27 +138,27 @@ evsub_id_t smf_app::generate_ev_subscription_id() {
}
//------------------------------------------------------------------------------
bool smf_app::is_seid_n4_exist(const uint64_t &seid) const {
bool smf_app::is_seid_n4_exist(const uint64_t& seid) const {
return bool{set_seid_n4.count(seid) > 0};
}
//------------------------------------------------------------------------------
void smf_app::free_seid_n4(const uint64_t &seid) {
void smf_app::free_seid_n4(const uint64_t& seid) {
std::unique_lock<std::mutex> ls(m_seid_n4_generator);
set_seid_n4.erase(seid);
ls.unlock();
}
//------------------------------------------------------------------------------
void smf_app::set_seid_2_smf_context(const seid_t &seid,
std::shared_ptr<smf_context> &pc) {
void smf_app::set_seid_2_smf_context(
const seid_t& seid, std::shared_ptr<smf_context>& pc) {
std::unique_lock lock(m_seid2smf_context);
seid2smf_context[seid] = pc;
}
//------------------------------------------------------------------------------
bool smf_app::seid_2_smf_context(const seid_t &seid,
std::shared_ptr<smf_context> &pc) const {
bool smf_app::seid_2_smf_context(
const seid_t& seid, std::shared_ptr<smf_context>& pc) const {
std::shared_lock lock(m_seid2smf_context);
std::map<seid_t, std::shared_ptr<smf_context>>::const_iterator it =
seid2smf_context.find(seid);
......@@ -177,52 +177,52 @@ void smf_app::delete_smf_context(std::shared_ptr<smf_context> spc) {
}
//------------------------------------------------------------------------------
void smf_app::restore_n4_sessions(const seid_t &seid) const {
void smf_app::restore_n4_sessions(const seid_t& seid) const {
std::shared_lock lock(m_seid2smf_context);
// TODO
}
//------------------------------------------------------------------------------
void smf_app_task(void *) {
void smf_app_task(void*) {
const task_id_t task_id = TASK_SMF_APP;
itti_inst->notify_task_ready(task_id);
do {
std::shared_ptr<itti_msg> shared_msg = itti_inst->receive_msg(task_id);
auto *msg = shared_msg.get();
auto* msg = shared_msg.get();
switch (msg->msg_type) {
case N4_SESSION_ESTABLISHMENT_RESPONSE:
if (itti_n4_session_establishment_response *m =
dynamic_cast<itti_n4_session_establishment_response *>(msg)) {
if (itti_n4_session_establishment_response* m =
dynamic_cast<itti_n4_session_establishment_response*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case N4_SESSION_MODIFICATION_RESPONSE:
if (itti_n4_session_modification_response *m =
dynamic_cast<itti_n4_session_modification_response *>(msg)) {
if (itti_n4_session_modification_response* m =
dynamic_cast<itti_n4_session_modification_response*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case N4_SESSION_DELETION_RESPONSE:
if (itti_n4_session_deletion_response *m =
dynamic_cast<itti_n4_session_deletion_response *>(msg)) {
if (itti_n4_session_deletion_response* m =
dynamic_cast<itti_n4_session_deletion_response*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case N11_SESSION_N1N2_MESSAGE_TRANSFER_RESPONSE_STATUS:
if (itti_n11_n1n2_message_transfer_response_status *m =
dynamic_cast<itti_n11_n1n2_message_transfer_response_status *>(
if (itti_n11_n1n2_message_transfer_response_status* m =
dynamic_cast<itti_n11_n1n2_message_transfer_response_status*>(
msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case N11_SESSION_UPDATE_PDU_SESSION_STATUS:
if (itti_n11_update_pdu_session_status *m =
dynamic_cast<itti_n11_update_pdu_session_status *>(msg)) {
if (itti_n11_update_pdu_session_status* m =
dynamic_cast<itti_n11_update_pdu_session_status*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
......@@ -234,54 +234,54 @@ void smf_app_task(void *) {
break;
case N11_SESSION_CREATE_SM_CONTEXT_RESPONSE:
if (itti_n11_create_sm_context_response *m =
dynamic_cast<itti_n11_create_sm_context_response *>(msg)) {
if (itti_n11_create_sm_context_response* m =
dynamic_cast<itti_n11_create_sm_context_response*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case N11_SESSION_UPDATE_SM_CONTEXT_RESPONSE:
if (itti_n11_update_sm_context_response *m =
dynamic_cast<itti_n11_update_sm_context_response *>(msg)) {
if (itti_n11_update_sm_context_response* m =
dynamic_cast<itti_n11_update_sm_context_response*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE:
if (itti_n11_release_sm_context_response *m =
dynamic_cast<itti_n11_release_sm_context_response *>(msg)) {
if (itti_n11_release_sm_context_response* m =
dynamic_cast<itti_n11_release_sm_context_response*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case N11_REGISTER_NF_INSTANCE_RESPONSE:
if (itti_n11_register_nf_instance_response *m =
dynamic_cast<itti_n11_register_nf_instance_response *>(msg)) {
if (itti_n11_register_nf_instance_response* m =
dynamic_cast<itti_n11_register_nf_instance_response*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case N11_UPDATE_NF_INSTANCE_RESPONSE:
if (itti_n11_update_nf_instance_response *m =
dynamic_cast<itti_n11_update_nf_instance_response *>(msg)) {
if (itti_n11_update_nf_instance_response* m =
dynamic_cast<itti_n11_update_nf_instance_response*>(msg)) {
smf_app_inst->handle_itti_msg(std::ref(*m));
}
break;
case TIME_OUT:
if (itti_msg_timeout *to = dynamic_cast<itti_msg_timeout *>(msg)) {
if (itti_msg_timeout* to = dynamic_cast<itti_msg_timeout*>(msg)) {
Logger::smf_app().info("TIME-OUT event timer id %d", to->timer_id);
switch (to->arg1_user) {
case TASK_SMF_APP_TRIGGER_T3591:
smf_app_inst->timer_t3591_timeout(to->timer_id, to->arg2_user);
break;
case TASK_SMF_APP_TIMEOUT_NRF_HEARTBEAT:
smf_app_inst->timer_nrf_heartbeat_timeout(to->timer_id,
to->arg2_user);
smf_app_inst->timer_nrf_heartbeat_timeout(
to->timer_id, to->arg2_user);
break;
case TASK_SMF_APP_TIMEOUT_NRF_DEREGISTRATION:
smf_app_inst->timer_nrf_deregistration(to->timer_id,
to->arg2_user);
smf_app_inst->timer_nrf_deregistration(
to->timer_id, to->arg2_user);
break;
default:;
}
......@@ -289,8 +289,8 @@ void smf_app_task(void *) {
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::smf_app().info("Received terminate message");
return;
}
......@@ -306,7 +306,7 @@ void smf_app_task(void *) {
}
//------------------------------------------------------------------------------
smf_app::smf_app(const std::string &config_file)
smf_app::smf_app(const std::string& config_file)
: m_seid2smf_context(),
m_supi2smf_context(),
m_scid2smf_context(),
......@@ -315,8 +315,8 @@ smf_app::smf_app(const std::string &config_file)
m_sm_context_release_promises() {
Logger::smf_app().startup("Starting...");
supi2smf_context = {};
set_seid_n4 = {};
supi2smf_context = {};
set_seid_n4 = {};
seid_n4_generator = 0;
apply_config(smf_cfg);
......@@ -327,10 +327,10 @@ smf_app::smf_app(const std::string &config_file)
}
try {
smf_n4_inst = new smf_n4();
smf_n4_inst = new smf_n4();
smf_n10_inst = new smf_n10();
smf_n11_inst = new smf_n11();
} catch (std::exception &e) {
} catch (std::exception& e) {
Logger::smf_app().error("Cannot create SMF_APP: %s", e.what());
throw;
}
......@@ -350,9 +350,9 @@ smf_app::smf_app(const std::string &config_file)
//------------------------------------------------------------------------------
// From SPGWU
void smf_app::start_upf_association(const pfcp::node_id_t &node_id) {
void smf_app::start_upf_association(const pfcp::node_id_t& node_id) {
std::time_t time_epoch = std::time(nullptr);
uint64_t tv_ntp = time_epoch + SECONDS_SINCE_FIRST_EPOCH;
uint64_t tv_ntp = time_epoch + SECONDS_SINCE_FIRST_EPOCH;
pfcp_associations::get_instance().add_peer_candidate_node(node_id);
std::shared_ptr<itti_n4_association_setup_request> n4_asc =
......@@ -361,14 +361,14 @@ void smf_app::start_upf_association(const pfcp::node_id_t &node_id) {
// n4_asc->trxn_id = smf_n4_inst->generate_trxn_id();
pfcp::cp_function_features_s cp_function_features;
cp_function_features = {};
cp_function_features = {};
cp_function_features.load = 1;
cp_function_features.ovrl = 1;
pfcp::node_id_t this_node_id = {};
if (smf_cfg.get_pfcp_node_id(this_node_id) == RETURNok) {
n4_asc->pfcp_ies.set(this_node_id);
pfcp::recovery_time_stamp_t r = {.recovery_time_stamp = (uint32_t)tv_ntp};
pfcp::recovery_time_stamp_t r = {.recovery_time_stamp = (uint32_t) tv_ntp};
n4_asc->pfcp_ies.set(r);
n4_asc->pfcp_ies.set(cp_function_features);
......@@ -388,7 +388,7 @@ void smf_app::start_upf_association(const pfcp::node_id_t &node_id) {
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n4_session_establishment_response &seresp) {
void smf_app::handle_itti_msg(itti_n4_session_establishment_response& seresp) {
std::shared_ptr<smf_context> pc = {};
if (seid_2_smf_context(seresp.seid, pc)) {
pc.get()->handle_itti_msg(seresp);
......@@ -401,7 +401,7 @@ void smf_app::handle_itti_msg(itti_n4_session_establishment_response &seresp) {
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n4_session_modification_response &smresp) {
void smf_app::handle_itti_msg(itti_n4_session_modification_response& smresp) {
std::shared_ptr<smf_context> pc = {};
if (seid_2_smf_context(smresp.seid, pc)) {
pc.get()->handle_itti_msg(smresp);
......@@ -414,7 +414,7 @@ void smf_app::handle_itti_msg(itti_n4_session_modification_response &smresp) {
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n4_session_deletion_response &smresp) {
void smf_app::handle_itti_msg(itti_n4_session_deletion_response& smresp) {
std::shared_ptr<smf_context> pc = {};
if (seid_2_smf_context(smresp.seid, pc)) {
pc.get()->handle_itti_msg(smresp);
......@@ -437,16 +437,16 @@ void smf_app::handle_itti_msg(
if (seid_2_smf_context(snr->seid, pc)) {
pc.get()->handle_itti_msg(snr);
} else {
Logger::smf_app().debug("Received N4 Session Report Request seid" TEID_FMT
" pfcp_tx_id %" PRIX64
", smf_context not found, discarded!",
snr->seid, snr->trxn_id);
Logger::smf_app().debug(
"Received N4 Session Report Request seid" TEID_FMT
" pfcp_tx_id %" PRIX64 ", smf_context not found, discarded!",
snr->seid, snr->trxn_id);
}
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(
itti_n11_n1n2_message_transfer_response_status &m) {
itti_n11_n1n2_message_transfer_response_status& m) {
// see TS29518_Namf_Communication.yaml
Logger::smf_app().info("Process N1N2MessageTransfer Response");
......@@ -467,7 +467,7 @@ void smf_app::handle_itti_msg(
status = pdu_session_status_e::PDU_SESSION_INACTIVE;
} else if (m.msg_type == PDU_SESSION_ESTABLISHMENT_ACCEPT) {
status = pdu_session_status_e::PDU_SESSION_ESTABLISHMENT_PENDING;
state = upCnx_state_e::UPCNX_STATE_ACTIVATING;
state = upCnx_state_e::UPCNX_STATE_ACTIVATING;
}
update_pdu_session_status(m.scid, status);
update_pdu_session_upCnx_state(m.scid, state);
......@@ -478,8 +478,8 @@ void smf_app::handle_itti_msg(
pdu_session_status_e2str[static_cast<int>(status)].c_str());
} else {
// TODO:
Logger::smf_app().debug("Got response from AMF (response code %d)",
m.response_code);
Logger::smf_app().debug(
"Got response from AMF (response code %d)", m.response_code);
}
} break;
case session_management_procedures_type_e::
......@@ -500,9 +500,9 @@ void smf_app::handle_itti_msg(
return;
}
itti_n4_session_failure_indication *itti_n4 =
itti_n4_session_failure_indication* itti_n4 =
new itti_n4_session_failure_indication(TASK_SMF_APP, TASK_SMF_N4);
itti_n4->seid = m.seid;
itti_n4->seid = m.seid;
itti_n4->trxn_id = m.trxn_id;
itti_n4->r_endpoint =
endpoint(up_node_id.u1.ipv4_address, pfcp::default_port);
......@@ -510,8 +510,9 @@ void smf_app::handle_itti_msg(
itti_n4_failure_indication =
std::shared_ptr<itti_n4_session_failure_indication>(itti_n4);
Logger::smf_app().info("Sending ITTI message %s to task TASK_SMF_N4",
itti_n4->get_msg_name());
Logger::smf_app().info(
"Sending ITTI message %s to task TASK_SMF_N4",
itti_n4->get_msg_name());
int ret = itti_inst->send_msg(itti_n4_failure_indication);
if (RETURNok != ret) {
Logger::smf_app().error(
......@@ -528,7 +529,7 @@ void smf_app::handle_itti_msg(
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n11_update_pdu_session_status &m) {
void smf_app::handle_itti_msg(itti_n11_update_pdu_session_status& m) {
Logger::smf_app().info(
"Set PDU Session Status to %s",
pdu_session_status_e2str[static_cast<int>(m.pdu_session_status)].c_str());
......@@ -536,7 +537,7 @@ void smf_app::handle_itti_msg(itti_n11_update_pdu_session_status &m) {
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n11_create_sm_context_response &m) {
void smf_app::handle_itti_msg(itti_n11_create_sm_context_response& m) {
Logger::smf_app().debug(
"PDU Session Create SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_create_sm_context_response sm_context_response = {};
......@@ -549,7 +550,7 @@ void smf_app::handle_itti_msg(itti_n11_create_sm_context_response &m) {
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n11_update_sm_context_response &m) {
void smf_app::handle_itti_msg(itti_n11_update_sm_context_response& m) {
Logger::smf_app().debug(
"PDU Session Update SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_update_sm_context_response sm_context_response = {};
......@@ -562,7 +563,7 @@ void smf_app::handle_itti_msg(itti_n11_update_sm_context_response &m) {
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n11_release_sm_context_response &m) {
void smf_app::handle_itti_msg(itti_n11_release_sm_context_response& m) {
Logger::smf_app().debug(
"PDU Session Release SM Context: Set promise with ID %d to ready", m.pid);
pdu_session_release_sm_context_response sm_context_response = {};
......@@ -575,17 +576,17 @@ void smf_app::handle_itti_msg(itti_n11_release_sm_context_response &m) {
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n11_register_nf_instance_response &r) {
void smf_app::handle_itti_msg(itti_n11_register_nf_instance_response& r) {
Logger::smf_app().debug("NF Instance Registration response");
nf_profile = r.profile;
nf_instance_profile = r.profile;
// Set heartbeat timer
Logger::smf_app().debug("Set NRF Heartbeat timer (%d)",
r.profile.get_nf_heartBeat_timer());
timer_nrf_heartbeat =
itti_inst->timer_setup(r.profile.get_nf_heartBeat_timer(), 0,
TASK_SMF_APP, TASK_SMF_APP_TIMEOUT_NRF_HEARTBEAT,
0); // TODO arg2_user
Logger::smf_app().debug(
"Set NRF Heartbeat timer (%d)", r.profile.get_nf_heartBeat_timer());
timer_nrf_heartbeat = itti_inst->timer_setup(
r.profile.get_nf_heartBeat_timer(), 0, TASK_SMF_APP,
TASK_SMF_APP_TIMEOUT_NRF_HEARTBEAT,
0); // TODO arg2_user
/* //Set timer to send NF Deregistration (for testing purpose)
itti_inst->timer_setup(50, 0,
......@@ -595,15 +596,16 @@ void smf_app::handle_itti_msg(itti_n11_register_nf_instance_response &r) {
}
//------------------------------------------------------------------------------
void smf_app::handle_itti_msg(itti_n11_update_nf_instance_response &u) {
void smf_app::handle_itti_msg(itti_n11_update_nf_instance_response& u) {
Logger::smf_app().debug("NF Update NF response");
Logger::smf_app().debug("Set NRF Heartbeat timer (%d)",
nf_profile.get_nf_heartBeat_timer());
Logger::smf_app().debug(
"Set NRF Heartbeat timer (%d)",
nf_instance_profile.get_nf_heartBeat_timer());
// Set heartbeat timer
// timer_nrf_heartbeat = itti_inst->timer_setup(
// nf_profile.get_nf_heartBeat_timer(), 0, TASK_SMF_APP,
// nf_instance_profile.get_nf_heartBeat_timer(), 0, TASK_SMF_APP,
// TASK_SMF_APP_TIMEOUT_NRF_HEARTBEAT, 0); //TODO arg2_user
}
......@@ -617,8 +619,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// handle PDU Session Create SM Context Request as specified in section 4.3.2
// 3GPP TS 23.502
std::string n1_sm_message, n1_sm_message_hex;
nas_message_t decoded_nas_msg = {};
cause_value_5gsm_e cause_n1 = {cause_value_5gsm_e::CAUSE_0_UNKNOWN};
nas_message_t decoded_nas_msg = {};
cause_value_5gsm_e cause_n1 = {cause_value_5gsm_e::CAUSE_0_UNKNOWN};
pdu_session_type_t pdu_session_type = {.pdu_session_type =
PDU_SESSION_TYPE_E_IPV4};
......@@ -676,10 +678,9 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// TODO: Support IPv4 only for now
if (pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_IPV6) {
cause_n1 = cause_value_5gsm_e::CAUSE_50_PDU_SESSION_TYPE_IPV4_ONLY_ALLOWED;
} else if ((pdu_session_type.pdu_session_type ==
PDU_SESSION_TYPE_E_ETHERNET) or
(pdu_session_type.pdu_session_type ==
PDU_SESSION_TYPE_E_UNSTRUCTURED)) {
} else if (
(pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_ETHERNET) or
(pdu_session_type.pdu_session_type == PDU_SESSION_TYPE_E_UNSTRUCTURED)) {
cause_n1 = cause_value_5gsm_e::CAUSE_28_UNKNOWN_PDU_SESSION_TYPE;
}
if (pdu_session_type.pdu_session_type != PDU_SESSION_TYPE_E_IPV4) {
......@@ -708,12 +709,12 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// TODO: ExtendedProtocolConfigurationOptions
// Get necessary information
supi_t supi = smreq->req.get_supi();
std::string supi_prefix = smreq->req.get_supi_prefix();
supi64_t supi64 = smf_supi_to_u64(supi);
std::string dnn = smreq->req.get_dnn();
snssai_t snssai = smreq->req.get_snssai();
uint8_t message_type = decoded_nas_msg.plain.sm.header.message_type;
supi_t supi = smreq->req.get_supi();
std::string supi_prefix = smreq->req.get_supi_prefix();
supi64_t supi64 = smf_supi_to_u64(supi);
std::string dnn = smreq->req.get_dnn();
snssai_t snssai = smreq->req.get_snssai();
uint8_t message_type = decoded_nas_msg.plain.sm.header.message_type;
std::string request_type = smreq->req.get_request_type();
Logger::smf_app().info(
"Handle a PDU Session Create SM Context Request message from AMF, "
......@@ -730,8 +731,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
if ((pti.procedure_transaction_id ==
PROCEDURE_TRANSACTION_IDENTITY_UNASSIGNED) ||
(pti.procedure_transaction_id > PROCEDURE_TRANSACTION_IDENTITY_LAST)) {
Logger::smf_app().warn("Invalid PTI value (pti = %d)",
pti.procedure_transaction_id);
Logger::smf_app().warn(
"Invalid PTI value (pti = %d)", pti.procedure_transaction_id);
// PDU Session Establishment Reject including cause "#81 Invalid PTI value"
// (section 7.3.1 @3GPP TS 24.501)
if (smf_n1::get_instance().create_n1_pdu_session_establishment_reject(
......@@ -766,8 +767,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// check message type
if (message_type != PDU_SESSION_ESTABLISHMENT_REQUEST) {
Logger::smf_app().warn("Invalid message type (message type = %d)",
message_type);
Logger::smf_app().warn(
"Invalid message type (message type = %d)", message_type);
// PDU Session Establishment Reject
//(24.501 (section 7.4)) implementation dependent->do similar to UE:
// response with a 5GSM STATUS message including cause "#98 message type not
......@@ -792,8 +793,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// check request type
if (request_type.compare("INITIAL_REQUEST") != 0) {
Logger::smf_app().warn("Invalid request type (request type = %s)",
request_type.c_str());
Logger::smf_app().warn(
"Invalid request type (request type = %s)", request_type.c_str());
//"Existing PDU Session", AMF should use PDUSession_UpdateSMContext instead
//(see step 3, section 4.3.2.2.1 @ 3GPP TS 23.502 v16.0.0) ignore the
// message
......@@ -831,8 +832,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// Step 4. create a context for this supi if not existed, otherwise update
std::shared_ptr<smf_context> sc = {};
if (is_supi_2_smf_context(supi64)) {
Logger::smf_app().debug("Update SMF context with SUPI " SUPI_64_FMT "",
supi64);
Logger::smf_app().debug(
"Update SMF context with SUPI " SUPI_64_FMT "", supi64);
sc = supi_2_smf_context(supi64);
sc.get()->set_supi(supi);
} else {
......@@ -852,10 +853,10 @@ void smf_app::handle_pdu_session_create_sm_context_request(
// create a new one and insert to the list
Logger::smf_app().debug(
"Create a DNN context and add to the SMF context");
sd = std::shared_ptr<dnn_context>(new dnn_context(dnn));
sd.get()->in_use = true;
sd = std::shared_ptr<dnn_context>(new dnn_context(dnn));
sd.get()->in_use = true;
sd.get()->dnn_in_use = dnn;
sd.get()->nssai = snssai;
sd.get()->nssai = snssai;
sc.get()->insert_dnn(sd);
}
}
......@@ -883,7 +884,7 @@ void smf_app::handle_pdu_session_create_sm_context_request(
Logger::smf_app().debug(
"The Session Management Subscription data is not available");
session_management_subscription *s =
session_management_subscription* s =
new session_management_subscription(snssai);
std::shared_ptr<session_management_subscription> subscription =
std::shared_ptr<session_management_subscription>(s);
......@@ -925,8 +926,8 @@ void smf_app::handle_pdu_session_create_sm_context_request(
Logger::smf_app().debug(
"Retrieve Session Management Subscription data from local "
"configuration");
if (get_session_management_subscription_data(supi64, dnn, snssai,
subscription)) {
if (get_session_management_subscription_data(
supi64, dnn, snssai, subscription)) {
// update dnn_context with subscription info
sc.get()->insert_dnn_subscription(snssai, subscription);
}
......@@ -938,9 +939,9 @@ void smf_app::handle_pdu_session_create_sm_context_request(
scid_t scid = generate_smf_context_ref();
std::shared_ptr<smf_context_ref> scf =
std::shared_ptr<smf_context_ref>(new smf_context_ref());
scf.get()->supi = supi;
scf.get()->dnn = dnn;
scf.get()->nssai = snssai;
scf.get()->supi = supi;
scf.get()->dnn = dnn;
scf.get()->nssai = snssai;
scf.get()->pdu_session_id = pdu_session_id;
set_scid_2_smf_context(scid, scf);
smreq->set_scid(scid);
......@@ -968,7 +969,7 @@ void smf_app::handle_pdu_session_update_sm_context_request(
scid_t scid = {};
try {
scid = std::stoi(smreq->scid);
} catch (const std::exception &err) {
} catch (const std::exception& err) {
Logger::smf_app().warn(
"Received a PDU Session Update SM Context Request, couldn't retrieve "
"the corresponding SMF context, ignore message!");
......@@ -1006,8 +1007,8 @@ void smf_app::handle_pdu_session_update_sm_context_request(
std::shared_ptr<smf_context> sc = {};
if (is_supi_2_smf_context(supi64)) {
sc = supi_2_smf_context(supi64);
Logger::smf_app().debug("Retrieve SMF context with SUPI " SUPI_64_FMT "",
supi64);
Logger::smf_app().debug(
"Retrieve SMF context with SUPI " SUPI_64_FMT "", supi64);
} else {
// send PDUSession_SMUpdateContext Response to AMF
Logger::smf_app().warn(
......@@ -1055,13 +1056,14 @@ void smf_app::handle_pdu_session_release_sm_context_request(
scid_t scid = {};
try {
scid = std::stoi(smreq->scid);
} catch (const std::exception &err) {
} catch (const std::exception& err) {
Logger::smf_app().warn(
"Received a PDU Session Release SM Context Request, couldn't retrieve "
"the corresponding SMF context, ignore message!");
// trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
smreq->pid, N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE);
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND, smreq->pid,
N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE);
return;
}
......@@ -1073,8 +1075,9 @@ void smf_app::handle_pdu_session_release_sm_context_request(
Logger::smf_app().warn(
"Context associated with this id " SCID_FMT " does not exit!", scid);
// trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
smreq->pid, N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE);
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND, smreq->pid,
N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE);
return;
}
......@@ -1090,8 +1093,8 @@ void smf_app::handle_pdu_session_release_sm_context_request(
std::shared_ptr<smf_context> sc = {};
if (is_supi_2_smf_context(supi64)) {
sc = supi_2_smf_context(supi64);
Logger::smf_app().debug("Retrieve SMF context with SUPI " SUPI_64_FMT "",
supi64);
Logger::smf_app().debug(
"Retrieve SMF context with SUPI " SUPI_64_FMT "", supi64);
} else {
// send PDUSession_SMReleaseContext Response to AMF
Logger::smf_app().warn(
......@@ -1099,8 +1102,9 @@ void smf_app::handle_pdu_session_release_sm_context_request(
"couldn't retrieve the corresponding SMF context, ignore message!",
supi64);
// trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
smreq->pid, N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE);
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND, smreq->pid,
N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE);
return;
}
......@@ -1115,9 +1119,9 @@ void smf_app::handle_pdu_session_release_sm_context_request(
"Received PDU Session Release SM Context Request, couldn't retrieve "
"the corresponding SMF context, ignore message!");
// trigger to send reply to AMF
trigger_http_response(http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND,
smreq->pid,
N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE);
trigger_http_response(
http_status_code_e::HTTP_STATUS_CODE_404_NOT_FOUND, smreq->pid,
N11_SESSION_RELEASE_SM_CONTEXT_RESPONSE);
return;
}
}
......@@ -1128,9 +1132,9 @@ void smf_app::handle_pdu_session_release_sm_context_request(
//------------------------------------------------------------------------------
void smf_app::trigger_pdu_session_modification(
const supi_t &supi, const std::string &dnn,
const pdu_session_id_t pdu_session_id, const snssai_t &snssai,
const pfcp::qfi_t &qfi, const uint8_t &http_version) {
const supi_t& supi, const std::string& dnn,
const pdu_session_id_t pdu_session_id, const snssai_t& snssai,
const pfcp::qfi_t& qfi, const uint8_t& http_version) {
// SMF-requested session modification, see section 4.3.3.2@3GPP TS 23.502
// The SMF may decide to modify PDU Session. This procedure also may be
// triggered based on locally configured policy or triggered from the (R)AN
......@@ -1140,8 +1144,8 @@ void smf_app::trigger_pdu_session_modification(
// 5GC but not synchronized with the UE yet.
std::shared_ptr<itti_nx_trigger_pdu_session_modification> itti_msg =
std::make_shared<itti_nx_trigger_pdu_session_modification>(TASK_SMF_APP,
TASK_SMF_N11);
std::make_shared<itti_nx_trigger_pdu_session_modification>(
TASK_SMF_APP, TASK_SMF_N11);
itti_msg->http_version = http_version;
// step 1. collect the necessary information
......@@ -1157,8 +1161,8 @@ void smf_app::trigger_pdu_session_modification(
if (is_supi_2_smf_context(supi64)) {
sc = supi_2_smf_context(supi64);
Logger::smf_app().debug("Retrieve SMF context with SUPI " SUPI_64_FMT "",
supi64);
Logger::smf_app().debug(
"Retrieve SMF context with SUPI " SUPI_64_FMT "", supi64);
} else {
Logger::smf_app().debug(
"SMF context with SUPI " SUPI_64_FMT "does not exist", supi64);
......@@ -1186,9 +1190,9 @@ evsub_id_t smf_app::handle_event_exposure_subscription(
ss.get()->sub_id = evsub_id;
if (msg->event_exposure.is_supi_is_set()) {
supi64_t supi64 = smf_supi_to_u64(msg->event_exposure.get_supi());
ss.get()->supi = supi64;
ss.get()->supi = supi64;
}
ss.get()->notif_id = msg->event_exposure.get_notif_id();
ss.get()->notif_id = msg->event_exposure.get_notif_id();
ss.get()->notif_uri = msg->event_exposure.get_notif_uri();
std::vector<event_subscription_t> event_subscriptions =
......@@ -1201,50 +1205,105 @@ evsub_id_t smf_app::handle_event_exposure_subscription(
}
//------------------------------------------------------------------------------
bool smf_app::is_supi_2_smf_context(const supi64_t &supi) const {
bool smf_app::handle_nf_status_notification(
std::shared_ptr<itti_sbi_notification_data>& msg,
oai::smf_server::model::ProblemDetails& problem_details,
uint8_t& http_code) {
Logger::smf_app().info(
"Handle a NF status notification from NRF (HTTP version "
"%d)",
msg->http_version);
data_notification_msg notification_msg = msg.get()->notification_msg;
std::string event_type;
notification_msg.get_notification_event_type(event_type);
if (event_type.compare("REGISTERED") == 0) {
std::shared_ptr<nf_profile> profile = {};
notification_msg.get_profile(profile);
if (profile.get() != nullptr) {
std::string nf_type = profile.get()->get_nf_type();
if (nf_type.compare("UPF") == 0) {
// UPF
upf_info_t upf_info = {};
std::static_pointer_cast<upf_profile>(profile).get()->get_upf_info(
upf_info);
// Verify if the UPF is already exist
// if not, add to the DB and send Association request
// UPF N4 ipv4 address
std::vector<struct in_addr> ipv4_addrs = {};
profile.get()->get_nf_ipv4_addresses(ipv4_addrs);
bool found = false;
for (auto node : smf_cfg.upfs) {
if (node.u1.ipv4_address.s_addr == ipv4_addrs[0].s_addr) {
found = false;
break;
}
}
if (!found) {
// Add a new UPF node
Logger::smf_app().debug(
"Add a new UPF node, Ipv4 Addr %s", inet_ntoa(ipv4_addrs[0]));
pfcp::node_id_t n = {};
n.node_id_type = pfcp::NODE_ID_TYPE_IPV4_ADDRESS;
n.u1.ipv4_address.s_addr = ipv4_addrs[0].s_addr;
// memcpy(&n.u1.ipv4_address, &ipv4_addrs[0], sizeof(struct in_addr));
smf_cfg.upfs.push_back(n);
start_upf_association(n);
}
}
} else {
return false;
}
}
return true;
}
//------------------------------------------------------------------------------
bool smf_app::is_supi_2_smf_context(const supi64_t& supi) const {
std::shared_lock lock(m_supi2smf_context);
return bool{supi2smf_context.count(supi) > 0};
}
//------------------------------------------------------------------------------
std::shared_ptr<smf_context> smf_app::supi_2_smf_context(
const supi64_t &supi) const {
const supi64_t& supi) const {
std::shared_lock lock(m_supi2smf_context);
return supi2smf_context.at(supi);
}
//------------------------------------------------------------------------------
void smf_app::set_supi_2_smf_context(const supi64_t &supi,
std::shared_ptr<smf_context> sc) {
void smf_app::set_supi_2_smf_context(
const supi64_t& supi, std::shared_ptr<smf_context> sc) {
std::unique_lock lock(m_supi2smf_context);
supi2smf_context[supi] = sc;
}
//------------------------------------------------------------------------------
void smf_app::set_scid_2_smf_context(const scid_t &id,
std::shared_ptr<smf_context_ref> scf) {
void smf_app::set_scid_2_smf_context(
const scid_t& id, std::shared_ptr<smf_context_ref> scf) {
std::unique_lock lock(m_scid2smf_context);
scid2smf_context[id] = scf;
}
//------------------------------------------------------------------------------
std::shared_ptr<smf_context_ref> smf_app::scid_2_smf_context(
const scid_t &scid) const {
const scid_t& scid) const {
std::shared_lock lock(m_scid2smf_context);
return scid2smf_context.at(scid);
}
//------------------------------------------------------------------------------
bool smf_app::is_scid_2_smf_context(const scid_t &scid) const {
bool smf_app::is_scid_2_smf_context(const scid_t& scid) const {
std::shared_lock lock(m_scid2smf_context);
return bool{scid2smf_context.count(scid) > 0};
}
//------------------------------------------------------------------------------
bool smf_app::is_scid_2_smf_context(const supi64_t &supi,
const std::string &dnn,
const snssai_t &snssai,
const pdu_session_id_t &pid) const {
bool smf_app::is_scid_2_smf_context(
const supi64_t& supi, const std::string& dnn, const snssai_t& snssai,
const pdu_session_id_t& pid) const {
std::shared_lock lock(m_scid2smf_context);
for (auto it : scid2smf_context) {
supi64_t supi64 = smf_supi_to_u64(it.second->supi);
......@@ -1256,8 +1315,8 @@ bool smf_app::is_scid_2_smf_context(const supi64_t &supi,
}
//------------------------------------------------------------------------------
bool smf_app::scid_2_smf_context(const scid_t &scid,
std::shared_ptr<smf_context_ref> &scf) const {
bool smf_app::scid_2_smf_context(
const scid_t& scid, std::shared_ptr<smf_context_ref>& scf) const {
std::shared_lock lock(m_scid2smf_context);
if (scid2smf_context.count(scid) > 0) {
scf = scid2smf_context.at(scid);
......@@ -1268,14 +1327,14 @@ bool smf_app::scid_2_smf_context(const scid_t &scid,
//------------------------------------------------------------------------------
bool smf_app::use_local_configuration_subscription_data(
const std::string &dnn_selection_mode) {
const std::string& dnn_selection_mode) {
// TODO: should be implemented
return smf_cfg.local_configuration;
}
//------------------------------------------------------------------------------
bool smf_app::is_supi_dnn_snssai_subscription_data(
const supi_t &supi, const std::string &dnn, const snssai_t &snssai) const {
const supi_t& supi, const std::string& dnn, const snssai_t& snssai) const {
// TODO: should be implemented
return false; // Session Management Subscription from UDM isn't available
}
......@@ -1287,12 +1346,12 @@ bool smf_app::is_create_sm_context_request_valid() const {
}
//---------------------------------------------------------------------------------------------
void smf_app::convert_string_2_hex(const std::string &input_str,
std::string &output_str) {
void smf_app::convert_string_2_hex(
const std::string& input_str, std::string& output_str) {
Logger::smf_app().debug("Convert string to Hex");
unsigned char *data = (unsigned char *)malloc(input_str.length() + 1);
unsigned char* data = (unsigned char*) malloc(input_str.length() + 1);
memset(data, 0, input_str.length() + 1);
memcpy((void *)data, (void *)input_str.c_str(), input_str.length());
memcpy((void*) data, (void*) input_str.c_str(), input_str.length());
#if DEBUG_IS_ON
Logger::smf_app().debug("Input: ");
......@@ -1301,23 +1360,23 @@ void smf_app::convert_string_2_hex(const std::string &input_str,
}
printf("\n");
#endif
char *datahex = (char *)malloc(input_str.length() * 2 + 1);
char* datahex = (char*) malloc(input_str.length() * 2 + 1);
memset(datahex, 0, input_str.length() * 2 + 1);
for (int i = 0; i < input_str.length(); i++)
sprintf(datahex + i * 2, "%02x", data[i]);
output_str = reinterpret_cast<char *>(datahex);
output_str = reinterpret_cast<char*>(datahex);
Logger::smf_app().debug("Output: \n %s ", output_str.c_str());
// free memory
free_wrapper((void **)&data);
free_wrapper((void **)&datahex);
free_wrapper((void**) &data);
free_wrapper((void**) &datahex);
}
//---------------------------------------------------------------------------------------------
void smf_app::update_pdu_session_status(const scid_t &scid,
const pdu_session_status_e &status) {
void smf_app::update_pdu_session_status(
const scid_t& scid, const pdu_session_status_e& status) {
Logger::smf_app().info("Update PDU Session Status");
// get the smf context
......@@ -1330,16 +1389,16 @@ void smf_app::update_pdu_session_status(const scid_t &scid,
"Context associated with this id " SCID_FMT " does not exit!", scid);
}
supi_t supi = scf.get()->supi;
supi64_t supi64 = smf_supi_to_u64(supi);
supi_t supi = scf.get()->supi;
supi64_t supi64 = smf_supi_to_u64(supi);
pdu_session_id_t pdu_session_id = scf.get()->pdu_session_id;
std::shared_ptr<smf_context> sc = {};
if (is_supi_2_smf_context(supi64)) {
sc = supi_2_smf_context(supi64);
Logger::smf_app().debug("Retrieve SMF context with SUPI " SUPI_64_FMT "",
supi64);
Logger::smf_app().debug(
"Retrieve SMF context with SUPI " SUPI_64_FMT "", supi64);
} else {
Logger::smf_app().warn(
"Could not retrieve the corresponding SMF context with "
......@@ -1371,8 +1430,8 @@ void smf_app::update_pdu_session_status(const scid_t &scid,
}
//---------------------------------------------------------------------------------------------
void smf_app::update_pdu_session_upCnx_state(const scid_t &scid,
const upCnx_state_e &state) {
void smf_app::update_pdu_session_upCnx_state(
const scid_t& scid, const upCnx_state_e& state) {
Logger::smf_app().info("Update UpCnx_State");
// get the smf context
......@@ -1385,16 +1444,16 @@ void smf_app::update_pdu_session_upCnx_state(const scid_t &scid,
"Context associated with this id " SCID_FMT " does not exit!", scid);
}
supi_t supi = scf.get()->supi;
supi64_t supi64 = smf_supi_to_u64(supi);
supi_t supi = scf.get()->supi;
supi64_t supi64 = smf_supi_to_u64(supi);
pdu_session_id_t pdu_session_id = scf.get()->pdu_session_id;
std::shared_ptr<smf_context> sc = {};
if (is_supi_2_smf_context(supi64)) {
sc = supi_2_smf_context(supi64);
Logger::smf_app().debug("Retrieve SMF context with SUPI " SUPI_64_FMT "",
supi64);
Logger::smf_app().debug(
"Retrieve SMF context with SUPI " SUPI_64_FMT "", supi64);
} else {
Logger::smf_app().warn(
"Could not retrieve the corresponding SMF context with "
......@@ -1420,8 +1479,9 @@ void smf_app::update_pdu_session_upCnx_state(const scid_t &scid,
"Could not retrieve the corresponding SMF PDU Session context!");
}
sp.get()->set_upCnx_state(state);
Logger::smf_app().info("Set PDU Session UpCnxState to %s",
upCnx_state_e2str[static_cast<int>(state)].c_str());
Logger::smf_app().info(
"Set PDU Session UpCnxState to %s",
upCnx_state_e2str[static_cast<int>(state)].c_str());
}
//---------------------------------------------------------------------------------------------
void smf_app::timer_t3591_timeout(timer_id_t timer_id, uint64_t arg2_user) {
......@@ -1429,13 +1489,13 @@ void smf_app::timer_t3591_timeout(timer_id_t timer_id, uint64_t arg2_user) {
}
//---------------------------------------------------------------------------------------------
void smf_app::timer_nrf_heartbeat_timeout(timer_id_t timer_id,
uint64_t arg2_user) {
void smf_app::timer_nrf_heartbeat_timeout(
timer_id_t timer_id, uint64_t arg2_user) {
Logger::smf_app().debug("Send ITTI msg to N11 task to trigger NRF Heartbeat");
std::shared_ptr<itti_n11_update_nf_instance_request> itti_msg =
std::make_shared<itti_n11_update_nf_instance_request>(TASK_SMF_APP,
TASK_SMF_N11);
std::make_shared<itti_n11_update_nf_instance_request>(
TASK_SMF_APP, TASK_SMF_N11);
oai::smf_server::model::PatchItem patch_item = {};
//{"op":"replace","path":"/nfStatus", "value": "REGISTERED"}
......@@ -1451,18 +1511,19 @@ void smf_app::timer_nrf_heartbeat_timeout(timer_id_t timer_id,
"Could not send ITTI message %s to task TASK_SMF_N11",
itti_msg->get_msg_name());
} else {
Logger::smf_app().debug("Set a timer to the next Heart-beat (%d)",
nf_profile.get_nf_heartBeat_timer());
timer_nrf_heartbeat =
itti_inst->timer_setup(nf_profile.get_nf_heartBeat_timer(), 0,
TASK_SMF_APP, TASK_SMF_APP_TIMEOUT_NRF_HEARTBEAT,
0); // TODO arg2_user
Logger::smf_app().debug(
"Set a timer to the next Heart-beat (%d)",
nf_instance_profile.get_nf_heartBeat_timer());
timer_nrf_heartbeat = itti_inst->timer_setup(
nf_instance_profile.get_nf_heartBeat_timer(), 0, TASK_SMF_APP,
TASK_SMF_APP_TIMEOUT_NRF_HEARTBEAT,
0); // TODO arg2_user
}
}
//---------------------------------------------------------------------------------------------
void smf_app::timer_nrf_deregistration(timer_id_t timer_id,
uint64_t arg2_user) {
void smf_app::timer_nrf_deregistration(
timer_id_t timer_id, uint64_t arg2_user) {
Logger::smf_app().debug(
"Send ITTI msg to N11 task to trigger NRF Deregistratino");
trigger_nf_deregistration();
......@@ -1470,7 +1531,7 @@ void smf_app::timer_nrf_deregistration(timer_id_t timer_id,
//---------------------------------------------------------------------------------------------
n2_sm_info_type_e smf_app::n2_sm_info_type_str2e(
const std::string &n2_info_type) const {
const std::string& n2_info_type) const {
std::size_t number_of_types = n2_sm_info_type_e2str.size();
for (auto i = 0; i < number_of_types; ++i) {
if (n2_info_type.compare(n2_sm_info_type_e2str[i]) == 0) {
......@@ -1481,7 +1542,7 @@ n2_sm_info_type_e smf_app::n2_sm_info_type_str2e(
//---------------------------------------------------------------------------------------------
bool smf_app::get_session_management_subscription_data(
const supi64_t &supi, const std::string &dnn, const snssai_t &snssai,
const supi64_t& supi, const std::string& dnn, const snssai_t& snssai,
std::shared_ptr<session_management_subscription> subscription) {
Logger::smf_app().debug(
"Get Session Management Subscription from configuration file");
......@@ -1503,12 +1564,14 @@ bool smf_app::get_session_management_subscription_data(
"IPV4") == 0) {
pdu_session_type.pdu_session_type =
pdu_session_type_e::PDU_SESSION_TYPE_E_IPV4;
} else if (smf_cfg.session_management_subscription[i]
.session_type.compare("IPV6") == 0) {
} else if (
smf_cfg.session_management_subscription[i].session_type.compare(
"IPV6") == 0) {
pdu_session_type.pdu_session_type =
pdu_session_type_e::PDU_SESSION_TYPE_E_IPV6;
} else if (smf_cfg.session_management_subscription[i]
.session_type.compare("IPV4V6") == 0) {
} else if (
smf_cfg.session_management_subscription[i].session_type.compare(
"IPV4V6") == 0) {
pdu_session_type.pdu_session_type =
pdu_session_type_e::PDU_SESSION_TYPE_E_IPV4V6;
}
......@@ -1539,9 +1602,10 @@ bool smf_app::get_session_management_subscription_data(
smf_cfg.session_management_subscription[i].session_ambr.uplink;
dnn_configuration->session_ambr.downlink =
smf_cfg.session_management_subscription[i].session_ambr.downlink;
Logger::smf_app().debug("Session AMBR Uplink %s, Downlink %s",
dnn_configuration->session_ambr.uplink.c_str(),
dnn_configuration->session_ambr.downlink.c_str());
Logger::smf_app().debug(
"Session AMBR Uplink %s, Downlink %s",
dnn_configuration->session_ambr.uplink.c_str(),
dnn_configuration->session_ambr.downlink.c_str());
subscription->insert_dnn_configuration(dnn, dnn_configuration);
return true;
......@@ -1553,8 +1617,8 @@ bool smf_app::get_session_management_subscription_data(
//---------------------------------------------------------------------------------------------
void smf_app::add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>
&p) {
boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>&
p) {
std::unique_lock lock(m_sm_context_create_promises);
sm_context_create_promises.emplace(id, p);
}
......@@ -1562,8 +1626,8 @@ void smf_app::add_promise(
//---------------------------------------------------------------------------------------------
void smf_app::add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_update_sm_context_response>>
&p) {
boost::shared_ptr<boost::promise<pdu_session_update_sm_context_response>>&
p) {
std::unique_lock lock(m_sm_context_update_promises);
sm_context_update_promises.emplace(id, p);
}
......@@ -1571,21 +1635,21 @@ void smf_app::add_promise(
//---------------------------------------------------------------------------------------------
void smf_app::add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_release_sm_context_response>>
&p) {
boost::shared_ptr<boost::promise<pdu_session_release_sm_context_response>>&
p) {
std::unique_lock lock(m_sm_context_release_promises);
sm_context_release_promises.emplace(id, p);
}
//---------------------------------------------------------------------------------------------
void smf_app::trigger_create_context_error_response(
const uint32_t &http_code, const uint8_t &cause,
const std::string &n1_sm_msg, uint32_t &promise_id) {
const uint32_t& http_code, const uint8_t& cause,
const std::string& n1_sm_msg, uint32_t& promise_id) {
Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of Server");
oai::smf_server::model::SmContextCreateError sm_context = {};
oai::smf_server::model::ProblemDetails problem_details = {};
oai::smf_server::model::ProblemDetails problem_details = {};
oai::smf_server::model::RefToBinaryData refToBinaryData = {};
Logger::smf_app().warn("Create SmContextCreateError");
problem_details.setCause(pdu_session_application_error_e2str[cause]);
......@@ -1597,14 +1661,14 @@ void smf_app::trigger_create_context_error_response(
std::make_shared<itti_n11_create_sm_context_response>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
pdu_session_create_sm_context_response sm_context_response = {};
nlohmann::json json_data = {};
nlohmann::json json_data = {};
to_json(json_data, sm_context);
sm_context_response.set_json_data(json_data);
sm_context_response.set_json_format("application/problem+json");
sm_context_response.set_n1_sm_message(n1_sm_msg);
sm_context_response.set_http_code(http_code);
itti_msg->res = sm_context_response;
int ret = itti_inst->send_msg(itti_msg);
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
......@@ -1613,14 +1677,13 @@ void smf_app::trigger_create_context_error_response(
}
//---------------------------------------------------------------------------------------------
void smf_app::trigger_update_context_error_response(const uint32_t &http_code,
const uint8_t &cause,
uint32_t &promise_id) {
void smf_app::trigger_update_context_error_response(
const uint32_t& http_code, const uint8_t& cause, uint32_t& promise_id) {
Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of API Server");
oai::smf_server::model::SmContextUpdateError smContextUpdateError = {};
oai::smf_server::model::ProblemDetails problem_details = {};
oai::smf_server::model::ProblemDetails problem_details = {};
problem_details.setCause(pdu_session_application_error_e2str[cause]);
smContextUpdateError.setError(problem_details);
......@@ -1628,13 +1691,13 @@ void smf_app::trigger_update_context_error_response(const uint32_t &http_code,
std::make_shared<itti_n11_update_sm_context_response>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
pdu_session_update_sm_context_response sm_context_response = {};
nlohmann::json json_data = {};
nlohmann::json json_data = {};
to_json(json_data, smContextUpdateError);
sm_context_response.set_json_data(json_data);
sm_context_response.set_json_format("application/problem+json");
sm_context_response.set_http_code(http_code);
itti_msg->res = sm_context_response;
int ret = itti_inst->send_msg(itti_msg);
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
......@@ -1644,13 +1707,13 @@ void smf_app::trigger_update_context_error_response(const uint32_t &http_code,
//---------------------------------------------------------------------------------------------
void smf_app::trigger_update_context_error_response(
const uint32_t &http_code, const uint8_t &cause,
const std::string &n1_sm_msg, uint32_t &promise_id) {
const uint32_t& http_code, const uint8_t& cause,
const std::string& n1_sm_msg, uint32_t& promise_id) {
Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of HTTP Server");
oai::smf_server::model::SmContextUpdateError smContextUpdateError = {};
oai::smf_server::model::ProblemDetails problem_details = {};
oai::smf_server::model::ProblemDetails problem_details = {};
problem_details.setCause(pdu_session_application_error_e2str[cause]);
smContextUpdateError.setError(problem_details);
......@@ -1658,14 +1721,14 @@ void smf_app::trigger_update_context_error_response(
std::make_shared<itti_n11_update_sm_context_response>(
TASK_SMF_N11, TASK_SMF_APP, promise_id);
pdu_session_update_sm_context_response sm_context_response = {};
nlohmann::json json_data = {};
nlohmann::json json_data = {};
to_json(json_data, smContextUpdateError);
sm_context_response.set_json_data(json_data);
sm_context_response.set_json_format("application/problem+json");
sm_context_response.set_n1_sm_message(n1_sm_msg);
sm_context_response.set_http_code(http_code);
itti_msg->res = sm_context_response;
int ret = itti_inst->send_msg(itti_msg);
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
......@@ -1674,8 +1737,8 @@ void smf_app::trigger_update_context_error_response(
}
//---------------------------------------------------------------------------------------------
void smf_app::trigger_http_response(const uint32_t &http_code,
uint32_t &promise_id, uint8_t msg_type) {
void smf_app::trigger_http_response(
const uint32_t& http_code, uint32_t& promise_id, uint8_t msg_type) {
Logger::smf_app().debug(
"Send ITTI msg to SMF APP to trigger the response of HTTP Server");
switch (msg_type) {
......@@ -1686,7 +1749,7 @@ void smf_app::trigger_http_response(const uint32_t &http_code,
pdu_session_release_sm_context_response sm_context_response = {};
sm_context_response.set_http_code(http_code);
itti_msg->res = sm_context_response;
int ret = itti_inst->send_msg(itti_msg);
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
......@@ -1701,7 +1764,7 @@ void smf_app::trigger_http_response(const uint32_t &http_code,
pdu_session_create_sm_context_response sm_context_response = {};
sm_context_response.set_http_code(http_code);
itti_msg->res = sm_context_response;
int ret = itti_inst->send_msg(itti_msg);
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
......@@ -1716,7 +1779,7 @@ void smf_app::trigger_http_response(const uint32_t &http_code,
pdu_session_update_sm_context_response sm_context_response = {};
sm_context_response.set_http_code(http_code);
itti_msg->res = sm_context_response;
int ret = itti_inst->send_msg(itti_msg);
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_APP",
......@@ -1724,15 +1787,17 @@ void smf_app::trigger_http_response(const uint32_t &http_code,
}
} break;
default: { Logger::smf_app().debug("Unknown message type %d", msg_type); }
default: {
Logger::smf_app().debug("Unknown message type %d", msg_type);
}
}
}
//---------------------------------------------------------------------------------------------
void smf_app::add_event_subscription(evsub_id_t sub_id, smf_event_t ev,
std::shared_ptr<smf_subscription> ss) {
Logger::smf_app().debug("Add an Event subscription (Sub ID %d, Event %d)",
sub_id, (uint8_t)ev);
void smf_app::add_event_subscription(
evsub_id_t sub_id, smf_event_t ev, std::shared_ptr<smf_subscription> ss) {
Logger::smf_app().debug(
"Add an Event subscription (Sub ID %d, Event %d)", sub_id, (uint8_t) ev);
std::unique_lock lock(m_smf_event_subscriptions);
smf_event_subscriptions.emplace(std::make_pair(sub_id, ev), ss);
}
......@@ -1740,12 +1805,12 @@ void smf_app::add_event_subscription(evsub_id_t sub_id, smf_event_t ev,
//---------------------------------------------------------------------------------------------
void smf_app::get_ee_subscriptions(
smf_event_t ev,
std::vector<std::shared_ptr<smf_subscription>> &subscriptions) {
for (auto const &i : smf_event_subscriptions) {
if ((uint8_t)std::get<1>(i.first) == (uint8_t)ev) {
std::vector<std::shared_ptr<smf_subscription>>& subscriptions) {
for (auto const& i : smf_event_subscriptions) {
if ((uint8_t) std::get<1>(i.first) == (uint8_t) ev) {
Logger::smf_app().debug(
"Found an event subscription (Event ID %d, Event %d)",
(uint8_t)std::get<0>(i.first), (uint8_t)ev);
(uint8_t) std::get<0>(i.first), (uint8_t) ev);
subscriptions.push_back(i.second);
}
}
......@@ -1754,8 +1819,8 @@ void smf_app::get_ee_subscriptions(
//---------------------------------------------------------------------------------------------
void smf_app::get_ee_subscriptions(
evsub_id_t sub_id,
std::vector<std::shared_ptr<smf_subscription>> &subscriptions) {
for (auto const &i : smf_event_subscriptions) {
std::vector<std::shared_ptr<smf_subscription>>& subscriptions) {
for (auto const& i : smf_event_subscriptions) {
if (i.first.first == sub_id) {
subscriptions.push_back(i.second);
}
......@@ -1765,8 +1830,8 @@ void smf_app::get_ee_subscriptions(
//---------------------------------------------------------------------------------------------
void smf_app::get_ee_subscriptions(
smf_event_t ev, supi64_t supi, pdu_session_id_t pdu_session_id,
std::vector<std::shared_ptr<smf_subscription>> &subscriptions) {
for (auto const &i : smf_event_subscriptions) {
std::vector<std::shared_ptr<smf_subscription>>& subscriptions) {
for (auto const& i : smf_event_subscriptions) {
if ((i.first.second == ev) && (i.second->supi == supi) &&
(i.second->pdu_session_id == pdu_session_id)) {
subscriptions.push_back(i.second);
......@@ -1778,26 +1843,26 @@ void smf_app::get_ee_subscriptions(
void smf_app::generate_smf_profile() {
// generate UUID
generate_uuid();
nf_profile.set_nf_instance_id(smf_instance_id);
nf_profile.set_nf_instance_name("OAI-SMF");
nf_profile.set_nf_type("SMF");
nf_profile.set_nf_status("REGISTERED");
nf_profile.set_nf_heartBeat_timer(50);
nf_profile.set_nf_priority(1);
nf_profile.set_nf_capacity(100);
nf_profile.add_nf_ipv4_addresses(smf_cfg.sbi.addr4);
nf_instance_profile.set_nf_instance_id(smf_instance_id);
nf_instance_profile.set_nf_instance_name("OAI-SMF");
nf_instance_profile.set_nf_type("SMF");
nf_instance_profile.set_nf_status("REGISTERED");
nf_instance_profile.set_nf_heartBeat_timer(50);
nf_instance_profile.set_nf_priority(1);
nf_instance_profile.set_nf_capacity(100);
nf_instance_profile.add_nf_ipv4_addresses(smf_cfg.sbi.addr4);
// NF services
nf_service_t nf_service = {};
nf_service_t nf_service = {};
nf_service.service_instance_id = smf_instance_id;
nf_service.service_name = "nsmf-pdusession";
nf_service_version_t version = {};
version.api_version_in_uri = "v1";
version.api_full_version = "1.0.0"; // TODO: to be updated
nf_service.service_name = "nsmf-pdusession";
nf_service_version_t version = {};
version.api_version_in_uri = "v1";
version.api_full_version = "1.0.0"; // TODO: to be updated
nf_service.versions.push_back(version);
nf_service.scheme = "http";
nf_service.scheme = "http";
nf_service.nf_service_status = "REGISTERED";
nf_profile.add_nf_service(nf_service);
nf_instance_profile.add_nf_service(nf_service);
// TODO: custom info
......@@ -1810,21 +1875,21 @@ void smf_app::generate_smf_profile() {
// SNSSAIS
snssai_t snssai = {};
snssai.sD = s.single_nssai.sD;
snssai.sST = s.single_nssai.sST;
nf_profile.add_snssai(snssai);
snssai.sD = s.single_nssai.sD;
snssai.sST = s.single_nssai.sST;
nf_instance_profile.add_snssai(snssai);
// SMF info
dnn_smf_info_item_t dnn_item = {.dnn = s.dnn};
dnn_smf_info_item_t dnn_item = {.dnn = s.dnn};
snssai_smf_info_item_t smf_info_item = {};
smf_info_item.dnn_smf_info_list.push_back(dnn_item);
smf_info_item.snssai.sD = s.single_nssai.sD;
smf_info_item.snssai.sD = s.single_nssai.sD;
smf_info_item.snssai.sST = s.single_nssai.sST;
nf_profile.add_smf_info_item(smf_info_item);
nf_instance_profile.add_smf_info_item(smf_info_item);
}
// Display the profile
nf_profile.display();
nf_instance_profile.display();
}
//---------------------------------------------------------------------------------------------
......@@ -1846,10 +1911,10 @@ void smf_app::trigger_nf_registration_request() {
"Send ITTI msg to N11 task to trigger the registration request to NRF");
std::shared_ptr<itti_n11_register_nf_instance_request> itti_msg =
std::make_shared<itti_n11_register_nf_instance_request>(TASK_SMF_APP,
TASK_SMF_N11);
itti_msg->profile = nf_profile;
int ret = itti_inst->send_msg(itti_msg);
std::make_shared<itti_n11_register_nf_instance_request>(
TASK_SMF_APP, TASK_SMF_N11);
itti_msg->profile = nf_instance_profile;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
......@@ -1863,10 +1928,47 @@ void smf_app::trigger_nf_deregistration() {
"Send ITTI msg to N11 task to trigger the deregistration request to NRF");
std::shared_ptr<itti_n11_deregister_nf_instance> itti_msg =
std::make_shared<itti_n11_deregister_nf_instance>(TASK_SMF_APP,
TASK_SMF_N11);
std::make_shared<itti_n11_deregister_nf_instance>(
TASK_SMF_APP, TASK_SMF_N11);
itti_msg->smf_instance_id = smf_instance_id;
int ret = itti_inst->send_msg(itti_msg);
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
itti_msg->get_msg_name());
}
}
//------------------------------------------------------------------------------
void smf_app::trigger_upf_status_notification_subscribe() {
Logger::smf_app().debug(
"Send ITTI msg to N11 task to trigger the UPF status notification "
"subscribe to NRF");
std::shared_ptr<itti_n11_subscribe_upf_status_notify> itti_msg =
std::make_shared<itti_n11_subscribe_upf_status_notify>(
TASK_SMF_APP, TASK_SMF_N11);
nlohmann::json json_data = {};
json_data["nfStatusNotificationUri"] =
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.sbi.addr4))) +
":" + std::to_string(smf_cfg.sbi.port) + "/nsmf_nfstatus_notify/" +
smf_cfg.sbi_api_version + "/subscriptions";
json_data["subscrCond"]["NfTypeCond"]["nfType"] = "UPF";
json_data["reqNotifEvents"] = nlohmann::json::array();
json_data["reqNotifEvents"].push_back("NF_REGISTERED");
json_data["reqNotifEvents"].push_back("NF_DEREGISTERED");
json_data["validityTime"] = "20210531T235959";
std::string url =
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.nrf_addr.ipv4_addr))) +
":" + std::to_string(smf_cfg.nrf_addr.port) + NNRF_NFM_BASE +
smf_cfg.nrf_addr.api_version + NNRF_NF_STATUS_SUBSCRIBE_URL;
itti_msg->url = url;
itti_msg->json_data = json_data;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
Logger::smf_app().error(
"Could not send ITTI message %s to task TASK_SMF_N11",
......
......@@ -53,6 +53,7 @@
#include "smf_pco.hpp"
#include "smf_profile.hpp"
#include "smf_subscription.hpp"
#include "ProblemDetails.h"
namespace smf {
......@@ -71,8 +72,8 @@ namespace smf {
typedef enum {
PDU_SESSION_ESTABLISHMENT = 1,
PDU_SESSION_MODIFICATION = 2,
PDU_SESSION_RELEASE = 3
PDU_SESSION_MODIFICATION = 2,
PDU_SESSION_RELEASE = 3
} pdu_session_procedure_t;
class smf_config;
......@@ -82,9 +83,9 @@ class smf_context_ref {
smf_context_ref() { clear(); }
void clear() {
supi = {};
nssai = {};
dnn = "";
supi = {};
nssai = {};
dnn = "";
pdu_session_id = 0;
amf_status_uri = "";
}
......@@ -116,8 +117,8 @@ class smf_app {
std::map<scid_t, std::shared_ptr<smf_context_ref>> scid2smf_context;
util::uint_generator<uint32_t> evsub_id_generator;
std::map<std::pair<evsub_id_t, smf_event_t>,
std::shared_ptr<smf_subscription>>
std::map<
std::pair<evsub_id_t, smf_event_t>, std::shared_ptr<smf_subscription>>
smf_event_subscriptions;
mutable std::shared_mutex m_scid2smf_context;
......@@ -135,12 +136,13 @@ class smf_app {
uint32_t,
boost::shared_ptr<boost::promise<pdu_session_update_sm_context_response>>>
sm_context_update_promises;
std::map<uint32_t, boost::shared_ptr<boost::promise<
pdu_session_release_sm_context_response>>>
std::map<
uint32_t, boost::shared_ptr<
boost::promise<pdu_session_release_sm_context_response>>>
sm_context_release_promises;
smf_profile nf_profile; // SMF profile
std::string smf_instance_id; // SMF instance id
smf_profile nf_instance_profile; // SMF profile
std::string smf_instance_id; // SMF instance id
timer_id_t timer_nrf_heartbeat;
/*
......@@ -148,7 +150,7 @@ class smf_app {
* @param [const smf_config &cfg] cfg
* @return
*/
int apply_config(const smf_config &cfg);
int apply_config(const smf_config& cfg);
/*
* pco_push_protocol_or_container_id
......@@ -157,9 +159,9 @@ class smf_app {
* @return
*/
int pco_push_protocol_or_container_id(
protocol_configuration_options_t &pco,
pco_protocol_or_container_id_t
*const poc_id /* STOLEN_REF poc_id->contents*/);
protocol_configuration_options_t& pco,
pco_protocol_or_container_id_t* const
poc_id /* STOLEN_REF poc_id->contents*/);
/*
* process_pco_request_ipcp
......@@ -168,8 +170,8 @@ class smf_app {
* @return
*/
int process_pco_request_ipcp(
protocol_configuration_options_t &pco_resp,
const pco_protocol_or_container_id_t *const poc_id);
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id);
/*
* process_pco_dns_server_request
......@@ -178,8 +180,8 @@ class smf_app {
* @return
*/
int process_pco_dns_server_request(
protocol_configuration_options_t &pco_resp,
const pco_protocol_or_container_id_t *const poc_id);
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id);
/*
* process_pco_link_mtu_request
......@@ -188,21 +190,20 @@ class smf_app {
* @return
*/
int process_pco_link_mtu_request(
protocol_configuration_options_t &pco_resp,
const pco_protocol_or_container_id_t *const poc_id);
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id);
public:
explicit smf_app(const std::string &config_file);
smf_app(smf_app const &) = delete;
explicit smf_app(const std::string& config_file);
smf_app(smf_app const&) = delete;
virtual ~smf_app() {
Logger::smf_app().debug("Delete SMF_APP instance...");
//TODO: disconnect connections
//Unregister NRF
// TODO: disconnect connections
// Unregister NRF
}
void operator=(smf_app const &) = delete;
void operator=(smf_app const&) = delete;
/*
* Set the association between Seid and SM Context
......@@ -210,8 +211,8 @@ class smf_app {
* @param [std::shared_ptr<smf_context> &] pc : Shared_ptr to a SMF context
* @return
*/
void set_seid_2_smf_context(const seid_t &seid,
std::shared_ptr<smf_context> &pc);
void set_seid_2_smf_context(
const seid_t& seid, std::shared_ptr<smf_context>& pc);
/*
* Find SMF context associated with a Session ID
......@@ -219,8 +220,8 @@ class smf_app {
* @param [std::shared_ptr<smf_context> &] pc : Shared_ptr to a SMF context
* @return bool: True if SMF context found, otherwise return false
*/
bool seid_2_smf_context(const seid_t &seid,
std::shared_ptr<smf_context> &pc) const;
bool seid_2_smf_context(
const seid_t& seid, std::shared_ptr<smf_context>& pc) const;
/*
* Delete the SMF Context
......@@ -236,7 +237,7 @@ class smf_app {
* @param [paa_t &] paa
* @return void
*/
int static_paa_get_free_paa(const std::string &dnn, paa_t &paa);
int static_paa_get_free_paa(const std::string& dnn, paa_t& paa);
/*
* static_paa_get_free_paa
......@@ -244,7 +245,7 @@ class smf_app {
* @param [struct in_addr &] addr
* @return void
*/
int static_paa_release_address(const std::string &dnn, struct in_addr &addr);
int static_paa_release_address(const std::string& dnn, struct in_addr& addr);
/*
* static_paa_get_num_ipv4_pool
......@@ -259,17 +260,17 @@ class smf_app {
* @return pool index
*/
int static_paa_get_ipv4_pool(
const int pool_id, struct in_addr *const range_low,
struct in_addr *const range_high, struct in_addr *const netaddr,
struct in_addr *const netmask,
std::vector<struct in_addr>::iterator &it_out_of_nw);
const int pool_id, struct in_addr* const range_low,
struct in_addr* const range_high, struct in_addr* const netaddr,
struct in_addr* const netmask,
std::vector<struct in_addr>::iterator& it_out_of_nw);
/*
* Get pool ID corresponding to an address
* @param [const struct in_addr &] ue_addr
* @return pool index
*/
int static_paa_get_pool_id(const struct in_addr &ue_addr);
int static_paa_get_pool_id(const struct in_addr& ue_addr);
/*
* process_pco_request
......@@ -278,30 +279,31 @@ class smf_app {
* @param [const protocol_configuration_options_ids_t &] pco_ids
* @return pool index
*/
int process_pco_request(const protocol_configuration_options_t &pco_req,
protocol_configuration_options_t &pco_resp,
protocol_configuration_options_ids_t &pco_ids);
int process_pco_request(
const protocol_configuration_options_t& pco_req,
protocol_configuration_options_t& pco_resp,
protocol_configuration_options_ids_t& pco_ids);
/*
* Handle ITTI message (N4 Session Establishment Response)
* @param [itti_n4_session_modification_response&] sne
* @return void
*/
void handle_itti_msg(itti_n4_session_establishment_response &sne);
void handle_itti_msg(itti_n4_session_establishment_response& sne);
/*
* Handle ITTI message (N4 Session Modification Response)
* @param [itti_n4_session_modification_response&] snm
* @return void
*/
void handle_itti_msg(itti_n4_session_modification_response &snm);
void handle_itti_msg(itti_n4_session_modification_response& snm);
/*
* Handle ITTI message (N4 Session Report Request)
* @param [itti_n4_association_setup_request&] snd
* @return void
*/
void handle_itti_msg(itti_n4_session_deletion_response &snd);
void handle_itti_msg(itti_n4_session_deletion_response& snd);
/*
* Handle ITTI message (N4 Session Report Request)
......@@ -315,14 +317,14 @@ class smf_app {
* @param [itti_n4_association_setup_request&] sna
* @return void
*/
void handle_itti_msg(itti_n4_association_setup_request &sna);
void handle_itti_msg(itti_n4_association_setup_request& sna);
/*
* Handle ITTI message from N11 to update PDU session status
* @param [itti_n11_update_pdu_session_status&] snu
* @return void
*/
void handle_itti_msg(itti_n11_update_pdu_session_status &snu);
void handle_itti_msg(itti_n11_update_pdu_session_status& snu);
/*
* Handle ITTI message N11 Create SM Context Response to trigger the response
......@@ -330,7 +332,7 @@ class smf_app {
* @param [itti_n11_create_sm_context_response&] snc
* @return void
*/
void handle_itti_msg(itti_n11_create_sm_context_response &snc);
void handle_itti_msg(itti_n11_create_sm_context_response& snc);
/*
* Handle ITTI message N11 Update SM Context Response to trigger the response
......@@ -338,7 +340,7 @@ class smf_app {
* @param [itti_n11_update_sm_context_response&] m
* @return void
*/
void handle_itti_msg(itti_n11_update_sm_context_response &m);
void handle_itti_msg(itti_n11_update_sm_context_response& m);
/*
* Handle ITTI message N11 Release SM Context Response to trigger the response
......@@ -346,35 +348,35 @@ class smf_app {
* @param [itti_n11_release_sm_context_response&] m
* @return void
*/
void handle_itti_msg(itti_n11_release_sm_context_response &m);
void handle_itti_msg(itti_n11_release_sm_context_response& m);
/*
* Handle ITTI message from N11 (N1N2MessageTransfer Response)
* @param [itti_n11_n1n2_message_transfer_response_status&] snm
* @return void
*/
void handle_itti_msg(itti_n11_n1n2_message_transfer_response_status &snm);
void handle_itti_msg(itti_n11_n1n2_message_transfer_response_status& snm);
/*
* Handle ITTI message from N11 (NFRegiser Response)
* @param [itti_n11_register_nf_instance_response&] r
* @return void
*/
void handle_itti_msg(itti_n11_register_nf_instance_response &r);
void handle_itti_msg(itti_n11_register_nf_instance_response& r);
/*
* Handle ITTI message from N11 (NFUpdate Response)
* @param [itti_n11_update_nf_instance_response&] u
* @return void
*/
void handle_itti_msg(itti_n11_update_nf_instance_response &u);
void handle_itti_msg(itti_n11_update_nf_instance_response& u);
/*
* Restore a N4 Session
* @param [const seid_t &] seid: Session ID to be restored
* @return void
*/
void restore_n4_sessions(const seid_t &seid) const;
void restore_n4_sessions(const seid_t& seid) const;
/*
* Generate a Session ID
......@@ -388,21 +390,21 @@ class smf_app {
* @param [const uint64_t &] s: Seid ID
* @return bool: True if exist, otherwise false
*/
bool is_seid_n4_exist(const uint64_t &s) const;
bool is_seid_n4_exist(const uint64_t& s) const;
/*
* Free a Seid by its ID
* @param [const uint64_t &] s: Seid ID
* @return void
*/
void free_seid_n4(const uint64_t &seid);
void free_seid_n4(const uint64_t& seid);
/*
* Generate a SMF Context Reference in a form of string
* @param [std::string &] smf_ref: Store the generated reference
* @return void
*/
void generate_smf_context_ref(std::string &smf_ref);
void generate_smf_context_ref(std::string& smf_ref);
/*
* Generate a SMF Context Reference
......@@ -416,7 +418,7 @@ class smf_app {
* @param [std::string &] sub_id: Store the generated reference
* @return void
*/
void generate_ev_subscription_id(std::string &sub_id);
void generate_ev_subscription_id(std::string& sub_id);
/*
* Generate an Event Exposure Subscription ID
......@@ -431,8 +433,8 @@ class smf_app {
* @param [std::shared_ptr<smf_context_ref>] scf: SMF Context
* @return the generated reference
*/
void set_scid_2_smf_context(const scid_t &id,
std::shared_ptr<smf_context_ref> scf);
void set_scid_2_smf_context(
const scid_t& id, std::shared_ptr<smf_context_ref> scf);
/*
* Find SMF Context Reference by its ID
......@@ -440,14 +442,14 @@ class smf_app {
* @return Shared_ptr to a SMF Context Reference if found, otherwise return
* false
*/
std::shared_ptr<smf_context_ref> scid_2_smf_context(const scid_t &scid) const;
std::shared_ptr<smf_context_ref> scid_2_smf_context(const scid_t& scid) const;
/*
* Verify whether a SMF Context Reference with a given ID exist
* @param [const scid_t &] scid: SM Context Reference ID
* @return bool: True if a SMF Context Reference exist, otherwise return false
*/
bool is_scid_2_smf_context(const scid_t &scid) const;
bool is_scid_2_smf_context(const scid_t& scid) const;
/*
* Verify whether a SMF Context Reference with a given ID exist
......@@ -458,9 +460,9 @@ class smf_app {
*
* @return bool: True if a SMF Context Reference exist, otherwise return false
*/
bool is_scid_2_smf_context(const supi64_t &supi, const std::string &dnn,
const snssai_t &snssai,
const pdu_session_id_t &pid) const;
bool is_scid_2_smf_context(
const supi64_t& supi, const std::string& dnn, const snssai_t& snssai,
const pdu_session_id_t& pid) const;
/*
* Find SMF Context Reference by its ID
......@@ -469,8 +471,8 @@ class smf_app {
* Context Reference
* @return bool: True if SMF Context Reference found, otherwise return false
*/
bool scid_2_smf_context(const scid_t &scid,
std::shared_ptr<smf_context_ref> &scf) const;
bool scid_2_smf_context(
const scid_t& scid, std::shared_ptr<smf_context_ref>& scf) const;
/*
* Handle PDUSession_CreateSMContextRequest from AMF
......@@ -505,6 +507,12 @@ class smf_app {
*/
evsub_id_t handle_event_exposure_subscription(
std::shared_ptr<itti_sbi_event_exposure_request> msg);
bool handle_nf_status_notification(
std::shared_ptr<itti_sbi_notification_data>& msg,
oai::smf_server::model::ProblemDetails& problem_details,
uint8_t& http_code);
/*
* Trigger pdu session modification
* @param [const supi_t &] supi
......@@ -514,19 +522,17 @@ class smf_app {
* @param [const pfcp::qfi_t &] qfi
* @return void
*/
void trigger_pdu_session_modification(const supi_t &supi,
const std::string &dnn,
const pdu_session_id_t pdu_session_id,
const snssai_t &snssai,
const pfcp::qfi_t &qfi,
const uint8_t &http_version);
void trigger_pdu_session_modification(
const supi_t& supi, const std::string& dnn,
const pdu_session_id_t pdu_session_id, const snssai_t& snssai,
const pfcp::qfi_t& qfi, const uint8_t& http_version);
/*
* Verify if SM Context is existed for this Supi
* @param [supi_t] supi
* @return True if existed, otherwise false
*/
bool is_supi_2_smf_context(const supi64_t &supi) const;
bool is_supi_2_smf_context(const supi64_t& supi) const;
/*
* Create/Update SMF context with the corresponding supi
......@@ -535,15 +541,15 @@ class smf_app {
* context
* @return True if existed, otherwise false
*/
void set_supi_2_smf_context(const supi64_t &supi,
std::shared_ptr<smf_context> sc);
void set_supi_2_smf_context(
const supi64_t& supi, std::shared_ptr<smf_context> sc);
/*
* Get SM Context
* @param [supi_t] Supi
* @return Shared pointer to SM context
*/
std::shared_ptr<smf_context> supi_2_smf_context(const supi64_t &supi) const;
std::shared_ptr<smf_context> supi_2_smf_context(const supi64_t& supi) const;
/*
* Check whether SMF uses local configuration instead of retrieving Session
......@@ -553,7 +559,7 @@ class smf_app {
* the UE request, False otherwise
*/
bool use_local_configuration_subscription_data(
const std::string &dnn_selection_mode);
const std::string& dnn_selection_mode);
/*
* Verify whether the Session Management Data is existed
......@@ -563,9 +569,8 @@ class smf_app {
* @return True if SMF uses the local configuration to check the validity of
* the UE request, False otherwise
*/
bool is_supi_dnn_snssai_subscription_data(const supi_t &supi,
const std::string &dnn,
const snssai_t &snssai) const;
bool is_supi_dnn_snssai_subscription_data(
const supi_t& supi, const std::string& dnn, const snssai_t& snssai) const;
/*
* Get the Session Management Subscription data from local configuration
......@@ -578,7 +583,7 @@ class smf_app {
* subscription exists, False otherwise
*/
bool get_session_management_subscription_data(
const supi64_t &supi, const std::string &dnn, const snssai_t &snssai,
const supi64_t& supi, const std::string& dnn, const snssai_t& snssai,
std::shared_ptr<session_management_subscription> subscription);
/*
......@@ -595,8 +600,8 @@ class smf_app {
* @param [std::string&] output_str String represents string in hex format
* @return void
*/
void convert_string_2_hex(const std::string &input_str,
std::string &output_str);
void convert_string_2_hex(
const std::string& input_str, std::string& output_str);
/*
* Update PDU session status
......@@ -604,8 +609,8 @@ class smf_app {
* @param [const pdu_session_status_e &] status PDU Session Status
* @return void
*/
void update_pdu_session_status(const scid_t &id,
const pdu_session_status_e &status);
void update_pdu_session_status(
const scid_t& id, const pdu_session_status_e& status);
/*
* Convert N2 Info type representing by a string to n2_sm_info_type_e
......@@ -613,7 +618,7 @@ class smf_app {
* @return representing of N2 info type in a form of emum
*/
n2_sm_info_type_e n2_sm_info_type_str2e(
const std::string &n2_info_type) const;
const std::string& n2_info_type) const;
/*
* Update PDU session UpCnxState
......@@ -621,8 +626,8 @@ class smf_app {
* @param [const upCnx_state_e] status PDU Session UpCnxState
* @return void
*/
void update_pdu_session_upCnx_state(const scid_t &scid,
const upCnx_state_e &state);
void update_pdu_session_upCnx_state(
const scid_t& scid, const upCnx_state_e& state);
/*
* will be executed when timer T3591 expires
......@@ -646,7 +651,7 @@ class smf_app {
* @param [const pfcp::node_id_t] node_id: UPF Node ID
* @return void
*/
void start_upf_association(const pfcp::node_id_t &node_id);
void start_upf_association(const pfcp::node_id_t& node_id);
/*
* To store a promise of a PDU Session Create SM Contex Response to be
......@@ -659,8 +664,8 @@ class smf_app {
*/
void add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>
&p);
boost::shared_ptr<boost::promise<pdu_session_create_sm_context_response>>&
p);
/*
* To store a promise of a PDU Session Update SM Contex Response to be
......@@ -673,8 +678,8 @@ class smf_app {
*/
void add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_update_sm_context_response>>
&p);
boost::shared_ptr<boost::promise<pdu_session_update_sm_context_response>>&
p);
/*
* To store a promise of a PDU Session Release SM Context Response to be
......@@ -687,8 +692,8 @@ class smf_app {
*/
void add_promise(
uint32_t id,
boost::shared_ptr<boost::promise<pdu_session_release_sm_context_response>>
&p);
boost::shared_ptr<
boost::promise<pdu_session_release_sm_context_response>>& p);
/*
* To trigger the response to the HTTP server by set the value of the
......@@ -699,10 +704,9 @@ class smf_app {
* @param [uint32_t &] promise_id: Promise Id
* @return void
*/
void trigger_create_context_error_response(const uint32_t &http_code,
const uint8_t &cause,
const std::string &n1_sm_msg,
uint32_t &promise_id);
void trigger_create_context_error_response(
const uint32_t& http_code, const uint8_t& cause,
const std::string& n1_sm_msg, uint32_t& promise_id);
/*
* To trigger the response to the HTTP server by set the value of the
......@@ -713,9 +717,8 @@ class smf_app {
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void
*/
void trigger_update_context_error_response(const uint32_t &http_code,
const uint8_t &cause,
uint32_t &promise_id);
void trigger_update_context_error_response(
const uint32_t& http_code, const uint8_t& cause, uint32_t& promise_id);
/*
* To trigger the response to the HTTP server by set the value of the
......@@ -727,10 +730,9 @@ class smf_app {
* @param [uint8_t] msg_type: Type of HTTP message (Update/Release)
* @return void
*/
void trigger_update_context_error_response(const uint32_t &http_code,
const uint8_t &cause,
const std::string &n1_sm_msg,
uint32_t &promise_id);
void trigger_update_context_error_response(
const uint32_t& http_code, const uint8_t& cause,
const std::string& n1_sm_msg, uint32_t& promise_id);
/*
* To trigger the response to the HTTP server by set the value of the
......@@ -740,8 +742,8 @@ class smf_app {
* @param [uint8_t] msg_type: Type of HTTP message (Create/Update/Release)
* @return void
*/
void trigger_http_response(const uint32_t &http_code, uint32_t &promise_id,
uint8_t msg_type);
void trigger_http_response(
const uint32_t& http_code, uint32_t& promise_id, uint8_t msg_type);
/*
* Add an Event Subscription to the list
......@@ -751,8 +753,8 @@ class smf_app {
* information of the subscription
* @return void
*/
void add_event_subscription(evsub_id_t sub_id, smf_event_t ev,
std::shared_ptr<smf_subscription> ss);
void add_event_subscription(
evsub_id_t sub_id, smf_event_t ev, std::shared_ptr<smf_subscription> ss);
/*
* Get a list of subscription associated with a particular event
......@@ -763,7 +765,7 @@ class smf_app {
*/
void get_ee_subscriptions(
smf_event_t ev,
std::vector<std::shared_ptr<smf_subscription>> &subscriptions);
std::vector<std::shared_ptr<smf_subscription>>& subscriptions);
/*
* Get a list of subscription associated with a particular event
......@@ -774,7 +776,7 @@ class smf_app {
*/
void get_ee_subscriptions(
evsub_id_t sub_id,
std::vector<std::shared_ptr<smf_subscription>> &subscriptions);
std::vector<std::shared_ptr<smf_subscription>>& subscriptions);
/*
* Get a list of subscription associated with a particular event
......@@ -787,7 +789,7 @@ class smf_app {
*/
void get_ee_subscriptions(
smf_event_t ev, supi64_t supi, pdu_session_id_t pdu_session_id,
std::vector<std::shared_ptr<smf_subscription>> &subscriptions);
std::vector<std::shared_ptr<smf_subscription>>& subscriptions);
/*
* Trigger NF instance registration to NRF
......@@ -824,8 +826,15 @@ class smf_app {
*/
void trigger_nf_deregistration();
/*
* Send request to N11 task to trigger NFSubscribeStatus to NRF
* @param [void]
* @return void
*/
void trigger_upf_status_notification_subscribe();
};
}
} // namespace smf
#include "smf_config.hpp"
#endif /* FILE_SMF_APP_HPP_SEEN */
......@@ -39,20 +39,22 @@ void qos_flow_context_updated::set_cause(const uint8_t cause) {
}
//-----------------------------------------------------------------------------
void qos_flow_context_updated::set_qfi(const pfcp::qfi_t &q) { qfi = q; }
void qos_flow_context_updated::set_qfi(const pfcp::qfi_t& q) {
qfi = q;
}
//-----------------------------------------------------------------------------
void qos_flow_context_updated::set_ul_fteid(const pfcp::fteid_t &teid) {
void qos_flow_context_updated::set_ul_fteid(const pfcp::fteid_t& teid) {
ul_fteid = teid;
}
//-----------------------------------------------------------------------------
void qos_flow_context_updated::set_dl_fteid(const pfcp::fteid_t &teid) {
void qos_flow_context_updated::set_dl_fteid(const pfcp::fteid_t& teid) {
dl_fteid = teid;
}
//-----------------------------------------------------------------------------
void qos_flow_context_updated::add_qos_rule(const QOSRulesIE &rule) {
void qos_flow_context_updated::add_qos_rule(const QOSRulesIE& rule) {
uint8_t rule_id = rule.qosruleidentifer;
if ((rule_id >= QOS_RULE_IDENTIFIER_FIRST) and
(rule_id <= QOS_RULE_IDENTIFIER_LAST)) {
......@@ -65,7 +67,7 @@ void qos_flow_context_updated::add_qos_rule(const QOSRulesIE &rule) {
//-----------------------------------------------------------------------------
void qos_flow_context_updated::set_qos_profile(const qos_profile_t &profile) {
void qos_flow_context_updated::set_qos_profile(const qos_profile_t& profile) {
qos_profile = profile;
}
......@@ -84,21 +86,27 @@ pdu_session_msg_type_t pdu_session_msg::get_msg_type() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_msg_type(const pdu_session_msg_type_t &msg_type) {
void pdu_session_msg::set_msg_type(const pdu_session_msg_type_t& msg_type) {
m_msg_type = msg_type;
}
//-----------------------------------------------------------------------------
supi_t pdu_session_msg::get_supi() const { return m_supi; }
supi_t pdu_session_msg::get_supi() const {
return m_supi;
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_supi(const supi_t &supi) { m_supi = supi; }
void pdu_session_msg::set_supi(const supi_t& supi) {
m_supi = supi;
}
//-----------------------------------------------------------------------------
std::string pdu_session_msg::get_supi_prefix() const { return m_supi_prefix; }
std::string pdu_session_msg::get_supi_prefix() const {
return m_supi_prefix;
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_supi_prefix(const std::string &prefix) {
void pdu_session_msg::set_supi_prefix(const std::string& prefix) {
m_supi_prefix = prefix;
}
......@@ -114,23 +122,33 @@ void pdu_session_msg::set_pdu_session_id(
}
//-----------------------------------------------------------------------------
std::string pdu_session_msg::get_dnn() const { return m_dnn; }
std::string pdu_session_msg::get_dnn() const {
return m_dnn;
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_dnn(const std::string &dnn) { m_dnn = dnn; }
void pdu_session_msg::set_dnn(const std::string& dnn) {
m_dnn = dnn;
}
//-----------------------------------------------------------------------------
snssai_t pdu_session_msg::get_snssai() const { return m_snssai; }
snssai_t pdu_session_msg::get_snssai() const {
return m_snssai;
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_snssai(const snssai_t &snssai) { m_snssai = snssai; }
void pdu_session_msg::set_snssai(const snssai_t& snssai) {
m_snssai = snssai;
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_api_root(const std::string &value) {
void pdu_session_msg::set_api_root(const std::string& value) {
m_api_root = value;
}
std::string pdu_session_msg::get_api_root() const { return m_api_root; }
std::string pdu_session_msg::get_api_root() const {
return m_api_root;
}
//-----------------------------------------------------------------------------
uint8_t pdu_session_msg::get_pdu_session_type() const {
......@@ -138,15 +156,17 @@ uint8_t pdu_session_msg::get_pdu_session_type() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_pdu_session_type(const uint8_t &pdu_session_type) {
void pdu_session_msg::set_pdu_session_type(const uint8_t& pdu_session_type) {
m_pdu_session_type = pdu_session_type;
}
//-----------------------------------------------------------------------------
procedure_transaction_id_t pdu_session_msg::get_pti() const { return m_pti; }
procedure_transaction_id_t pdu_session_msg::get_pti() const {
return m_pti;
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_pti(const procedure_transaction_id_t &pti) {
void pdu_session_msg::set_pti(const procedure_transaction_id_t& pti) {
m_pti = pti;
}
......@@ -156,13 +176,15 @@ std::string pdu_session_msg::get_n1_sm_message() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_n1_sm_message(const std::string &value) {
m_n1_sm_message = value;
void pdu_session_msg::set_n1_sm_message(const std::string& value) {
m_n1_sm_message = value;
m_n1_sm_msg_is_set = true;
}
//-----------------------------------------------------------------------------
bool pdu_session_msg::n1_sm_msg_is_set() const { return m_n1_sm_msg_is_set; }
bool pdu_session_msg::n1_sm_msg_is_set() const {
return m_n1_sm_msg_is_set;
}
//-----------------------------------------------------------------------------
std::string pdu_session_msg::get_n2_sm_information() const {
......@@ -170,13 +192,15 @@ std::string pdu_session_msg::get_n2_sm_information() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_n2_sm_information(const std::string &value) {
void pdu_session_msg::set_n2_sm_information(const std::string& value) {
m_n2_sm_information = value;
m_n2_sm_info_is_set = true;
}
//-----------------------------------------------------------------------------
bool pdu_session_msg::n2_sm_info_is_set() const { return m_n2_sm_info_is_set; }
bool pdu_session_msg::n2_sm_info_is_set() const {
return m_n2_sm_info_is_set;
}
//-----------------------------------------------------------------------------
std::string pdu_session_msg::get_n2_sm_info_type() const {
......@@ -184,8 +208,8 @@ std::string pdu_session_msg::get_n2_sm_info_type() const {
}
//-----------------------------------------------------------------------------
void pdu_session_msg::set_n2_sm_info_type(const std::string &value) {
m_n2_sm_info_type = value;
void pdu_session_msg::set_n2_sm_info_type(const std::string& value) {
m_n2_sm_info_type = value;
m_n2_sm_info_type_is_set = true;
}
......@@ -205,7 +229,7 @@ extended_protocol_discriminator_t pdu_session_sm_context_request::get_epd()
//-----------------------------------------------------------------------------
void pdu_session_sm_context_request::set_epd(
const extended_protocol_discriminator_t &epd) {
const extended_protocol_discriminator_t& epd) {
m_epd = epd;
}
......@@ -216,7 +240,7 @@ uint8_t pdu_session_sm_context_request::get_message_type() const {
//-----------------------------------------------------------------------------
void pdu_session_sm_context_request::set_message_type(
const uint8_t &message_type) {
const uint8_t& message_type) {
m_message_type = message_type;
}
......@@ -229,7 +253,9 @@ void pdu_session_sm_context_response::set_cause(const uint8_t cause) {
}
//-----------------------------------------------------------------------------
uint8_t pdu_session_sm_context_response::get_cause() const { return m_cause; }
uint8_t pdu_session_sm_context_response::get_cause() const {
return m_cause;
}
//-----------------------------------------------------------------------------
void pdu_session_sm_context_response::set_http_code(const uint32_t code) {
......@@ -243,25 +269,25 @@ uint32_t pdu_session_sm_context_response::get_http_code() const {
//-----------------------------------------------------------------------------
void pdu_session_sm_context_response::set_json_data(
const nlohmann::json &data) {
const nlohmann::json& data) {
m_json_data = data;
}
//-----------------------------------------------------------------------------
void pdu_session_sm_context_response::get_json_data(
nlohmann::json &data) const {
nlohmann::json& data) const {
data = m_json_data;
}
//-----------------------------------------------------------------------------
void pdu_session_sm_context_response::set_json_format(
const std::string &format) {
const std::string& format) {
m_json_format = format;
}
//-----------------------------------------------------------------------------
void pdu_session_sm_context_response::get_json_format(
std::string &format) const {
std::string& format) const {
format = m_json_format;
}
......@@ -275,7 +301,7 @@ std::string pdu_session_create_sm_context_request::get_serving_nf_id() const {
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_serving_nf_id(
const std::string &serving_nf_id) {
const std::string& serving_nf_id) {
m_serving_nf_id = serving_nf_id;
}
......@@ -286,13 +312,13 @@ std::string pdu_session_create_sm_context_request::get_request_type() const {
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_request_type(
const std::string &request_type) {
const std::string& request_type) {
m_request_type = request_type;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_dnn_selection_mode(
const std::string &dnn_selection_mode) {
const std::string& dnn_selection_mode) {
m_dnn_selection_mode = dnn_selection_mode;
}
......@@ -304,7 +330,7 @@ std::string pdu_session_create_sm_context_request::get_dnn_selection_mode()
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_request::set_sm_context_status_uri(
const std::string &value) {
const std::string& value) {
m_sm_context_status_uri = value;
}
......@@ -318,16 +344,18 @@ std::string pdu_session_create_sm_context_request::get_sm_context_status_uri()
* class: PDU Session Create SM Context Response
*/
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::set_paa(const paa_t &paa) {
void pdu_session_create_sm_context_response::set_paa(const paa_t& paa) {
m_paa = paa;
}
//-----------------------------------------------------------------------------
paa_t pdu_session_create_sm_context_response::get_paa() const { return m_paa; }
paa_t pdu_session_create_sm_context_response::get_paa() const {
return m_paa;
}
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::set_qos_flow_context(
const qos_flow_context_updated &qos_flow) {
const qos_flow_context_updated& qos_flow) {
m_qos_flow_context = qos_flow;
}
......@@ -339,7 +367,7 @@ pdu_session_create_sm_context_response::get_qos_flow_context() const {
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::set_amf_url(
const std::string &value) {
const std::string& value) {
m_amf_url = value;
}
......@@ -350,7 +378,7 @@ std::string pdu_session_create_sm_context_response::get_amf_url() const {
//-----------------------------------------------------------------------------
void pdu_session_create_sm_context_response::set_smf_context_uri(
const std::string &value) {
const std::string& value) {
m_smf_context_uri = value;
}
......@@ -365,19 +393,19 @@ std::string pdu_session_create_sm_context_response::get_smf_context_uri()
*/
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::add_qfi(const pfcp::qfi_t &qfi) {
void pdu_session_update_sm_context_request::add_qfi(const pfcp::qfi_t& qfi) {
qfis.push_back(qfi);
}
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::add_qfi(const uint8_t &q) {
void pdu_session_update_sm_context_request::add_qfi(const uint8_t& q) {
pfcp::qfi_t qfi(q);
qfis.push_back(qfi);
}
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::get_qfis(
std::vector<pfcp::qfi_t> &q) {
std::vector<pfcp::qfi_t>& q) {
for (auto qfi : qfis) {
q.push_back(qfi);
}
......@@ -385,19 +413,19 @@ void pdu_session_update_sm_context_request::get_qfis(
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_dl_fteid(
const pfcp::fteid_t &t) {
const pfcp::fteid_t& t) {
dl_fteid = t;
}
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::get_dl_fteid(pfcp::fteid_t &t) {
void pdu_session_update_sm_context_request::get_dl_fteid(pfcp::fteid_t& t) {
t = dl_fteid;
}
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_upCnx_state(
const std::string &value) {
m_upCnx_state = value;
const std::string& value) {
m_upCnx_state = value;
m_upCnx_state_is_set = true;
}
......@@ -408,8 +436,8 @@ bool pdu_session_update_sm_context_request::upCnx_state_is_set() const {
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_rat_type(
const std::string &value) {
m_rat_type = value;
const std::string& value) {
m_rat_type = value;
m_rat_type_is_set = true;
}
......@@ -420,8 +448,8 @@ bool pdu_session_update_sm_context_request::rat_type_is_set() const {
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_an_type(
const std::string &value) {
m_an_type = value;
const std::string& value) {
m_an_type = value;
m_an_type_is_set = true;
}
......@@ -437,7 +465,7 @@ bool pdu_session_update_sm_context_request::release_is_set() const {
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_request::set_release(bool value) {
m_release = value;
m_release = value;
m_release_is_set = true;
}
......@@ -446,13 +474,13 @@ void pdu_session_update_sm_context_request::set_release(bool value) {
*/
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_response::add_qos_flow_context_updated(
const qos_flow_context_updated &flow) {
const qos_flow_context_updated& flow) {
if ((flow.qfi.qfi >= QOS_FLOW_IDENTIFIER_FIRST) and
(flow.qfi.qfi <= QOS_FLOW_IDENTIFIER_LAST)) {
qos_flow_context_updateds.erase(flow.qfi.qfi);
qos_flow_context_updateds.insert(
std::pair<uint8_t, qos_flow_context_updated>((uint8_t)flow.qfi.qfi,
flow));
std::pair<uint8_t, qos_flow_context_updated>(
(uint8_t) flow.qfi.qfi, flow));
Logger::smf_app().trace(
"A QoS Flow Context (QFI %d) has been added successfully",
flow.qfi.qfi);
......@@ -464,7 +492,7 @@ void pdu_session_update_sm_context_response::add_qos_flow_context_updated(
//-----------------------------------------------------------------------------
bool pdu_session_update_sm_context_response::get_qos_flow_context_updated(
const pfcp::qfi_t &qfi, qos_flow_context_updated &flow) {
const pfcp::qfi_t& qfi, qos_flow_context_updated& flow) {
for (auto it : qos_flow_context_updateds) {
if (it.second.qfi == qfi) {
flow = it.second;
......@@ -476,10 +504,10 @@ bool pdu_session_update_sm_context_response::get_qos_flow_context_updated(
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_response::get_all_qos_flow_context_updateds(
std::map<uint8_t, qos_flow_context_updated> &all_flows) {
std::map<uint8_t, qos_flow_context_updated>& all_flows) {
for (auto it : qos_flow_context_updateds) {
all_flows.insert(std::pair<uint8_t, qos_flow_context_updated>(
(uint8_t)it.first, it.second));
(uint8_t) it.first, it.second));
}
}
......@@ -491,7 +519,7 @@ void pdu_session_update_sm_context_response::
//-----------------------------------------------------------------------------
void pdu_session_update_sm_context_response::set_smf_context_uri(
const std::string &value) {
const std::string& value) {
m_smf_context_uri = value;
}
......@@ -511,7 +539,9 @@ void pdu_session_release_sm_context_response::set_cause(uint8_t cause) {
}
//-----------------------------------------------------------------------------
uint8_t pdu_session_release_sm_context_response::get_cause() { return m_cause; }
uint8_t pdu_session_release_sm_context_response::get_cause() {
return m_cause;
}
//-----------------------------------------------------------------------------
void pdu_session_release_sm_context_response::set_http_code(
......@@ -529,7 +559,7 @@ uint32_t pdu_session_release_sm_context_response::get_http_code() const {
*/
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::set_amf_url(
const std::string &value) {
const std::string& value) {
amf_url = value;
}
......@@ -540,19 +570,19 @@ std::string pdu_session_modification_network_requested::get_amf_url() const {
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::add_qfi(
const pfcp::qfi_t &qfi) {
const pfcp::qfi_t& qfi) {
qfis.push_back(qfi);
}
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::add_qfi(const uint8_t &q) {
void pdu_session_modification_network_requested::add_qfi(const uint8_t& q) {
pfcp::qfi_t qfi(q);
qfis.push_back(qfi);
}
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::get_qfis(
std::vector<pfcp::qfi_t> &q) {
std::vector<pfcp::qfi_t>& q) {
for (auto qfi : qfis) {
q.push_back(qfi);
}
......@@ -560,37 +590,37 @@ void pdu_session_modification_network_requested::get_qfis(
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::set_json_data(
const nlohmann::json &data) {
const nlohmann::json& data) {
m_json_data = data;
}
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::get_json_data(
nlohmann::json &data) const {
nlohmann::json& data) const {
data = m_json_data;
}
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::set_json_format(
const std::string &format) {
const std::string& format) {
m_json_format = format;
}
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::get_json_format(
std::string &format) const {
std::string& format) const {
format = m_json_format;
}
//-----------------------------------------------------------------------------
void pdu_session_modification_network_requested::add_qos_flow_context_updated(
const qos_flow_context_updated &flow) {
const qos_flow_context_updated& flow) {
if ((flow.qfi.qfi >= QOS_FLOW_IDENTIFIER_FIRST) and
(flow.qfi.qfi <= QOS_FLOW_IDENTIFIER_LAST)) {
qos_flow_context_updateds.erase(flow.qfi.qfi);
qos_flow_context_updateds.insert(
std::pair<uint8_t, qos_flow_context_updated>((uint8_t)flow.qfi.qfi,
flow));
std::pair<uint8_t, qos_flow_context_updated>(
(uint8_t) flow.qfi.qfi, flow));
Logger::smf_app().trace(
"A QoS Flow Context (QFI %d) has been added successfully",
flow.qfi.qfi);
......@@ -602,7 +632,7 @@ void pdu_session_modification_network_requested::add_qos_flow_context_updated(
//-----------------------------------------------------------------------------
bool pdu_session_modification_network_requested::get_qos_flow_context_updated(
const pfcp::qfi_t &qfi, qos_flow_context_updated &flow) {
const pfcp::qfi_t& qfi, qos_flow_context_updated& flow) {
for (auto it : qos_flow_context_updateds) {
if (it.second.qfi == qfi) {
flow = it.second;
......@@ -616,22 +646,24 @@ bool pdu_session_modification_network_requested::get_qos_flow_context_updated(
* class: PDU Session Report Response
*/
//-----------------------------------------------------------------------------
void pdu_session_report_response::set_amf_url(const std::string &value) {
void pdu_session_report_response::set_amf_url(const std::string& value) {
amf_url = value;
}
//-----------------------------------------------------------------------------
std::string pdu_session_report_response::get_amf_url() const { return amf_url; }
std::string pdu_session_report_response::get_amf_url() const {
return amf_url;
}
//-----------------------------------------------------------------------------
void pdu_session_report_response::add_qos_flow_context_updated(
const qos_flow_context_updated &flow) {
const qos_flow_context_updated& flow) {
if ((flow.qfi.qfi >= QOS_FLOW_IDENTIFIER_FIRST) and
(flow.qfi.qfi <= QOS_FLOW_IDENTIFIER_LAST)) {
qos_flow_context_updateds.erase(flow.qfi.qfi);
qos_flow_context_updateds.insert(
std::pair<uint8_t, qos_flow_context_updated>((uint8_t)flow.qfi.qfi,
flow));
std::pair<uint8_t, qos_flow_context_updated>(
(uint8_t) flow.qfi.qfi, flow));
Logger::smf_app().trace(
"A QoS Flow Context (QFI %d) has been added successfully",
flow.qfi.qfi);
......@@ -643,7 +675,7 @@ void pdu_session_report_response::add_qos_flow_context_updated(
//-----------------------------------------------------------------------------
bool pdu_session_report_response::get_qos_flow_context_updated(
const pfcp::qfi_t &qfi, qos_flow_context_updated &flow) {
const pfcp::qfi_t& qfi, qos_flow_context_updated& flow) {
for (auto it : qos_flow_context_updateds) {
if (it.second.qfi == qfi) {
flow = it.second;
......@@ -655,41 +687,51 @@ bool pdu_session_report_response::get_qos_flow_context_updated(
//-----------------------------------------------------------------------------
void pdu_session_report_response::get_all_qos_flow_context_updateds(
std::map<uint8_t, qos_flow_context_updated> &all_flows) {
std::map<uint8_t, qos_flow_context_updated>& all_flows) {
for (auto it : qos_flow_context_updateds) {
all_flows.insert(std::pair<uint8_t, qos_flow_context_updated>(
(uint8_t)it.first, it.second));
(uint8_t) it.first, it.second));
}
}
//-----------------------------------------------------------------------------
void pdu_session_report_response::set_seid(const seid_t &s) { seid = s; }
void pdu_session_report_response::set_seid(const seid_t& s) {
seid = s;
}
//-----------------------------------------------------------------------------
void pdu_session_report_response::set_trxn_id(const uint64_t &t) {
void pdu_session_report_response::set_trxn_id(const uint64_t& t) {
trxn_id = t;
}
//-----------------------------------------------------------------------------
seid_t pdu_session_report_response::get_seid() const { return seid; }
seid_t pdu_session_report_response::get_seid() const {
return seid;
}
//-----------------------------------------------------------------------------
uint64_t pdu_session_report_response::get_trxn_id() const { return trxn_id; }
uint64_t pdu_session_report_response::get_trxn_id() const {
return trxn_id;
}
/*
* class: Event Exposure
*/
//-----------------------------------------------------------------------------
supi_t event_exposure_msg::get_supi() const { return m_supi; }
supi_t event_exposure_msg::get_supi() const {
return m_supi;
}
//-----------------------------------------------------------------------------
void event_exposure_msg::set_supi(const supi_t &value) {
m_supi = value;
void event_exposure_msg::set_supi(const supi_t& value) {
m_supi = value;
m_supi_is_set = true;
}
//-----------------------------------------------------------------------------
bool event_exposure_msg::is_supi_is_set() const { return m_supi_is_set; }
bool event_exposure_msg::is_supi_is_set() const {
return m_supi_is_set;
}
//-----------------------------------------------------------------------------
std::string event_exposure_msg::get_supi_prefix() const {
......@@ -697,7 +739,7 @@ std::string event_exposure_msg::get_supi_prefix() const {
}
//-----------------------------------------------------------------------------
void event_exposure_msg::set_supi_prefix(const std::string &prefix) {
void event_exposure_msg::set_supi_prefix(const std::string& prefix) {
m_supi_prefix = prefix;
}
//-----------------------------------------------------------------------------
......@@ -708,39 +750,49 @@ pdu_session_id_t event_exposure_msg::get_pdu_session_id() const {
//-----------------------------------------------------------------------------
void event_exposure_msg::set_pdu_session_id(const pdu_session_id_t value) {
m_pdu_session_id = value;
m_psi_is_set = true;
m_psi_is_set = true;
}
//-----------------------------------------------------------------------------
bool event_exposure_msg::is_psi_is_set() const { return m_psi_is_set; }
bool event_exposure_msg::is_psi_is_set() const {
return m_psi_is_set;
}
//-----------------------------------------------------------------------------
void event_exposure_msg::set_sub_id(std::string const &value) {
m_sub_id = value;
void event_exposure_msg::set_sub_id(std::string const& value) {
m_sub_id = value;
m_sub_id_is_set = true;
}
//-----------------------------------------------------------------------------
std::string event_exposure_msg::get_sub_id() const { return m_sub_id; }
std::string event_exposure_msg::get_sub_id() const {
return m_sub_id;
}
//-----------------------------------------------------------------------------
bool event_exposure_msg::is_sub_id_is_set() const { return m_sub_id_is_set; }
bool event_exposure_msg::is_sub_id_is_set() const {
return m_sub_id_is_set;
}
//-----------------------------------------------------------------------------
void event_exposure_msg::set_notif_uri(std::string const &value) {
void event_exposure_msg::set_notif_uri(std::string const& value) {
m_notif_uri = value;
}
//-----------------------------------------------------------------------------
std::string event_exposure_msg::get_notif_uri() const { return m_notif_uri; }
std::string event_exposure_msg::get_notif_uri() const {
return m_notif_uri;
}
//-----------------------------------------------------------------------------
void event_exposure_msg::set_notif_id(std::string const &value) {
void event_exposure_msg::set_notif_id(std::string const& value) {
m_notif_id = value;
}
//-----------------------------------------------------------------------------
std::string event_exposure_msg::get_notif_id() const { return m_notif_id; }
std::string event_exposure_msg::get_notif_id() const {
return m_notif_id;
}
//-----------------------------------------------------------------------------
std::vector<event_subscription_t> event_exposure_msg::get_event_subs() const {
......@@ -749,7 +801,7 @@ std::vector<event_subscription_t> event_exposure_msg::get_event_subs() const {
//-----------------------------------------------------------------------------
void event_exposure_msg::set_event_subs(
std::vector<event_subscription_t> const &value) {
std::vector<event_subscription_t> const& value) {
m_event_subs.clear();
for (auto it : value) {
m_event_subs.push_back(it);
......@@ -761,25 +813,33 @@ void event_exposure_msg::set_event_subs(
*/
//-----------------------------------------------------------------------------
void event_notification::set_smf_event(const smf_event_t &ev) { m_event = ev; }
void event_notification::set_smf_event(const smf_event_t& ev) {
m_event = ev;
}
//-----------------------------------------------------------------------------
smf_event_t event_notification::get_smf_event() const { return m_event; }
smf_event_t event_notification::get_smf_event() const {
return m_event;
}
//-----------------------------------------------------------------------------
supi64_t event_notification::get_supi() const { return m_supi; }
supi64_t event_notification::get_supi() const {
return m_supi;
}
//-----------------------------------------------------------------------------
void event_notification::set_supi(const supi64_t &value) {
m_supi = value;
void event_notification::set_supi(const supi64_t& value) {
m_supi = value;
m_supi_is_set = true;
}
//-----------------------------------------------------------------------------
bool event_notification::is_supi_is_set() const { return m_supi_is_set; }
bool event_notification::is_supi_is_set() const {
return m_supi_is_set;
}
//-----------------------------------------------------------------------------
void event_notification::set_ad_ipv4_addr(std::string const &value) {
m_ad_ipv4_addr = value;
void event_notification::set_ad_ipv4_addr(std::string const& value) {
m_ad_ipv4_addr = value;
m_ad_ipv4_addr_is_set = true;
}
......@@ -794,8 +854,8 @@ bool event_notification::is_ad_ipv4_addr_is_set() const {
}
//-----------------------------------------------------------------------------
void event_notification::set_re_ipv4_addr(std::string const &value) {
m_re_ipv4_addr = value;
void event_notification::set_re_ipv4_addr(std::string const& value) {
m_re_ipv4_addr = value;
m_re_ipv4_addr_is_set = true;
}
......@@ -812,7 +872,7 @@ bool event_notification::is_re_ipv4_addr_is_set() const {
//-----------------------------------------------------------------------------
void event_notification::set_pdu_session_id(const pdu_session_id_t value) {
m_pdu_session_id = value;
m_psi_is_set = true;
m_psi_is_set = true;
}
//-----------------------------------------------------------------------------
......@@ -821,20 +881,58 @@ pdu_session_id_t event_notification::get_pdu_session_id() const {
}
//-----------------------------------------------------------------------------
bool event_notification::is_psi_is_set() const { return m_psi_is_set; }
bool event_notification::is_psi_is_set() const {
return m_psi_is_set;
}
//-----------------------------------------------------------------------------
void event_notification::set_notif_uri(std::string const &value) {
void event_notification::set_notif_uri(std::string const& value) {
m_notif_uri = value;
}
//-----------------------------------------------------------------------------
std::string event_notification::get_notif_uri() const { return m_notif_uri; }
std::string event_notification::get_notif_uri() const {
return m_notif_uri;
}
//-----------------------------------------------------------------------------
void event_notification::set_notif_id(std::string const &value) {
void event_notification::set_notif_id(std::string const& value) {
m_notif_id = value;
}
//-----------------------------------------------------------------------------
std::string event_notification::get_notif_id() const { return m_notif_id; }
std::string event_notification::get_notif_id() const {
return m_notif_id;
}
//-----------------------------------------------------------------------------
void data_notification_msg::set_notification_event_type(
const std::string& type) {
notification_event_type = type;
}
//-----------------------------------------------------------------------------
void data_notification_msg::get_notification_event_type(
std::string& type) const {
type = notification_event_type;
}
//-----------------------------------------------------------------------------
void data_notification_msg::set_nf_instance_uri(const std::string& uri) {
nf_instance_uri = uri;
}
//-----------------------------------------------------------------------------
void data_notification_msg::get_nf_instance_uri(std::string& uri) const {
uri = nf_instance_uri;
}
//-----------------------------------------------------------------------------
void data_notification_msg::set_profile(const std::shared_ptr<nf_profile>& p) {
profile = p;
}
//-----------------------------------------------------------------------------
void data_notification_msg::get_profile(std::shared_ptr<nf_profile>& p) const {
p = profile;
}
......@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
......@@ -29,24 +29,25 @@
#ifndef FILE_SMF_MSG_HPP_SEEN
#define FILE_SMF_MSG_HPP_SEEN
#include "pistache/http.h"
#include "smf.h"
#include "3gpp_29.274.h"
#include "3gpp_29.244.h"
#include "3gpp_24.007.h"
#include "3gpp_24.501.h"
#include "3gpp_29.571.h"
#include "3gpp_29.244.h"
#include "3gpp_29.274.h"
#include "3gpp_29.508.h"
#include "3gpp_29.571.h"
#include "Guami.h"
#include "NgRanTargetId.h"
#include "pistache/http.h"
#include "smf_profile.hpp"
extern "C" {
#include "QOSRules.h"
}
typedef enum {
PDU_SESSION_MSG_TYPE_NONE = -1,
PDU_SESSION_MSG_TYPE_FIRST = 0,
PDU_SESSION_MSG_TYPE_NONE = -1,
PDU_SESSION_MSG_TYPE_FIRST = 0,
PDU_SESSION_CREATE_SM_CONTEXT_REQUEST = PDU_SESSION_MSG_TYPE_FIRST,
PDU_SESSION_CREATE_SM_CONTEXT_RESPONSE,
PDU_SESSION_UPDATE_SM_CONTEXT_REQUEST,
......@@ -61,25 +62,23 @@ typedef enum {
namespace smf {
//-----------------------------------------------------------------------------
//QoS flow to be created/modified/removed
// QoS flow to be created/modified/removed
class qos_flow_context_updated {
public:
qos_flow_context_updated()
:
cause_value(),
qfi(),
ul_fteid(),
dl_fteid(),
qos_profile(),
to_be_removed(false) {
}
: cause_value(),
qfi(),
ul_fteid(),
dl_fteid(),
qos_profile(),
to_be_removed(false) {}
void set_cause(const uint8_t cause);
void set_qfi(const pfcp::qfi_t &q);
void set_ul_fteid(const pfcp::fteid_t &teid);
void set_dl_fteid(const pfcp::fteid_t &teid);
void add_qos_rule(const QOSRulesIE &rule);
void set_qos_profile(const qos_profile_t &profile);
void set_qfi(const pfcp::qfi_t& q);
void set_ul_fteid(const pfcp::fteid_t& teid);
void set_dl_fteid(const pfcp::fteid_t& teid);
void add_qos_rule(const QOSRulesIE& rule);
void set_qos_profile(const qos_profile_t& profile);
void set_priority_level(uint8_t p);
uint8_t cause_value;
......@@ -95,73 +94,69 @@ class qos_flow_context_updated {
class pdu_session_msg {
public:
pdu_session_msg()
:
m_msg_type(),
m_supi(),
m_pdu_session_id(),
m_dnn(),
m_snssai(),
m_pdu_session_type(0) {
m_n1_sm_msg_is_set = false;
m_n2_sm_info_is_set = false;
: m_msg_type(),
m_supi(),
m_pdu_session_id(),
m_dnn(),
m_snssai(),
m_pdu_session_type(0) {
m_n1_sm_msg_is_set = false;
m_n2_sm_info_is_set = false;
m_n2_sm_info_type_is_set = false;
}
;
};
pdu_session_msg(pdu_session_msg_type_t msg_type)
:
m_msg_type(msg_type),
m_supi(),
m_pdu_session_id(),
m_dnn(),
m_snssai(),
m_pdu_session_type(0) {
m_n1_sm_msg_is_set = false;
m_n2_sm_info_is_set = false;
: m_msg_type(msg_type),
m_supi(),
m_pdu_session_id(),
m_dnn(),
m_snssai(),
m_pdu_session_type(0) {
m_n1_sm_msg_is_set = false;
m_n2_sm_info_is_set = false;
m_n2_sm_info_type_is_set = false;
}
;
pdu_session_msg(pdu_session_msg_type_t msg_type, supi_t supi,
pdu_session_id_t pdi, std::string dnn, snssai_t snssai)
:
m_msg_type(msg_type),
m_supi(supi),
m_pdu_session_id(pdi),
m_dnn(dnn),
m_snssai(snssai),
m_pdu_session_type(0) {
m_n1_sm_msg_is_set = false;
m_n2_sm_info_is_set = false;
};
pdu_session_msg(
pdu_session_msg_type_t msg_type, supi_t supi, pdu_session_id_t pdi,
std::string dnn, snssai_t snssai)
: m_msg_type(msg_type),
m_supi(supi),
m_pdu_session_id(pdi),
m_dnn(dnn),
m_snssai(snssai),
m_pdu_session_type(0) {
m_n1_sm_msg_is_set = false;
m_n2_sm_info_is_set = false;
m_n2_sm_info_type_is_set = false;
}
virtual ~pdu_session_msg() = default;
pdu_session_msg_type_t get_msg_type() const;
void set_msg_type(const pdu_session_msg_type_t &value);
void set_msg_type(const pdu_session_msg_type_t& value);
supi_t get_supi() const;
void set_supi(const supi_t &value);
void set_supi(const supi_t& value);
std::string get_supi_prefix() const;
void set_supi_prefix(const std::string &value);
void set_supi_prefix(const std::string& value);
pdu_session_id_t get_pdu_session_id() const;
void set_pdu_session_id(const pdu_session_id_t value);
std::string get_dnn() const;
void set_dnn(const std::string &value);
void set_dnn(const std::string& value);
snssai_t get_snssai() const;
void set_snssai(const snssai_t &value);
void set_api_root(const std::string &value);
void set_snssai(const snssai_t& value);
void set_api_root(const std::string& value);
std::string get_api_root() const;
uint8_t get_pdu_session_type() const;
void set_pdu_session_type(const uint8_t &pdu_session_type);
void set_pdu_session_type(const uint8_t& pdu_session_type);
procedure_transaction_id_t get_pti() const;
void set_pti(const procedure_transaction_id_t &pti);
void set_pti(const procedure_transaction_id_t& pti);
std::string get_n2_sm_information() const;
void set_n2_sm_information(const std::string &value);
void set_n2_sm_information(const std::string& value);
std::string get_n1_sm_message() const;
void set_n1_sm_message(const std::string &value);
void set_n1_sm_message(const std::string& value);
bool n1_sm_msg_is_set() const;
bool n2_sm_info_is_set() const;
std::string get_n2_sm_info_type() const;
void set_n2_sm_info_type(const std::string &value);
void set_n2_sm_info_type(const std::string& value);
bool n2_sm_info_type_is_set() const;
private:
......@@ -185,33 +180,27 @@ class pdu_session_msg {
//---------------------------------------------------------------------------------------
class pdu_session_sm_context_request : public pdu_session_msg {
public:
pdu_session_sm_context_request()
:
pdu_session_msg() {
m_epd = EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
pdu_session_sm_context_request() : pdu_session_msg() {
m_epd = EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
m_message_type = PDU_SESSION_MESSAGE_TYPE_UNKNOWN;
}
;
};
pdu_session_sm_context_request(pdu_session_msg_type_t msg_type)
:
pdu_session_msg(msg_type) {
m_epd = EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
: pdu_session_msg(msg_type) {
m_epd = EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
m_message_type = PDU_SESSION_MESSAGE_TYPE_UNKNOWN;
}
;
pdu_session_sm_context_request(pdu_session_msg_type_t msg_type, supi_t supi,
pdu_session_id_t pdi, std::string dnn,
snssai_t snssai)
:
pdu_session_msg(msg_type, supi, pdi, dnn, snssai) {
m_epd = EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
};
pdu_session_sm_context_request(
pdu_session_msg_type_t msg_type, supi_t supi, pdu_session_id_t pdi,
std::string dnn, snssai_t snssai)
: pdu_session_msg(msg_type, supi, pdi, dnn, snssai) {
m_epd = EPD_5GS_SESSION_MANAGEMENT_MESSAGES;
m_message_type = PDU_SESSION_MESSAGE_TYPE_UNKNOWN;
}
extended_protocol_discriminator_t get_epd() const;
void set_epd(const extended_protocol_discriminator_t &epd);
void set_epd(const extended_protocol_discriminator_t& epd);
uint8_t get_message_type() const;
void set_message_type(const uint8_t &message_type);
void set_message_type(const uint8_t& message_type);
private:
extended_protocol_discriminator_t m_epd;
......@@ -222,19 +211,17 @@ class pdu_session_sm_context_request : public pdu_session_msg {
class pdu_session_sm_context_response : public pdu_session_msg {
public:
pdu_session_sm_context_response(pdu_session_msg_type_t msg_type)
:
pdu_session_msg(msg_type) {
m_cause = 0;
m_http_code = 0;
: pdu_session_msg(msg_type) {
m_cause = 0;
m_http_code = 0;
m_json_format = "application/json";
}
pdu_session_sm_context_response(pdu_session_msg_type_t msg_type, supi_t supi,
pdu_session_id_t pdi, std::string dnn,
snssai_t snssai)
:
pdu_session_msg(msg_type, supi, pdi, dnn, snssai) {
m_cause = 0;
m_http_code = 0;
pdu_session_sm_context_response(
pdu_session_msg_type_t msg_type, supi_t supi, pdu_session_id_t pdi,
std::string dnn, snssai_t snssai)
: pdu_session_msg(msg_type, supi, pdi, dnn, snssai) {
m_cause = 0;
m_http_code = 0;
m_json_format = "application/json";
}
......@@ -242,10 +229,10 @@ class pdu_session_sm_context_response : public pdu_session_msg {
uint8_t get_cause() const;
void set_http_code(const uint32_t code);
uint32_t get_http_code() const;
void set_json_data(const nlohmann::json &data);
void get_json_data(nlohmann::json &data) const;
void set_json_format(const std::string &format);
void get_json_format(std::string &format) const;
void set_json_data(const nlohmann::json& data);
void get_json_data(nlohmann::json& data) const;
void set_json_format(const std::string& format);
void get_json_format(std::string& format) const;
private:
uint8_t m_cause;
......@@ -255,69 +242,63 @@ class pdu_session_sm_context_response : public pdu_session_msg {
};
//---------------------------------------------------------------------------------------
class pdu_session_create_sm_context_request :
public pdu_session_sm_context_request {
class pdu_session_create_sm_context_request
: public pdu_session_sm_context_request {
public:
pdu_session_create_sm_context_request()
:
pdu_session_sm_context_request(PDU_SESSION_CREATE_SM_CONTEXT_REQUEST),
m_unauthenticated_supi(true) {
}
pdu_session_create_sm_context_request(supi_t supi, pdu_session_id_t pdi,
std::string dnn, snssai_t snssai)
:
pdu_session_sm_context_request(PDU_SESSION_CREATE_SM_CONTEXT_REQUEST,
supi, pdi, dnn, snssai),
m_unauthenticated_supi(true) {
}
: pdu_session_sm_context_request(PDU_SESSION_CREATE_SM_CONTEXT_REQUEST),
m_unauthenticated_supi(true) {}
pdu_session_create_sm_context_request(
supi_t supi, pdu_session_id_t pdi, std::string dnn, snssai_t snssai)
: pdu_session_sm_context_request(
PDU_SESSION_CREATE_SM_CONTEXT_REQUEST, supi, pdi, dnn, snssai),
m_unauthenticated_supi(true) {}
std::string get_serving_nf_id() const;
void set_serving_nf_id(const std::string &value);
void set_serving_nf_id(const std::string& value);
std::string get_request_type() const;
void set_request_type(const std::string &value);
void set_dnn_selection_mode(const std::string &value);
void set_request_type(const std::string& value);
void set_dnn_selection_mode(const std::string& value);
std::string get_dnn_selection_mode() const;
void set_sm_context_status_uri(const std::string &value);
void set_sm_context_status_uri(const std::string& value);
std::string get_sm_context_status_uri() const;
private:
bool m_unauthenticated_supi;
std::string m_serving_nf_id; //AMF Id
std::string m_serving_nf_id; // AMF Id
std::string m_request_type;
std::string m_rat_type;
std::string m_presence_in_ladn;
std::string m_an_type;
std::string m_dnn_selection_mode; //SelMode
std::string m_dnn_selection_mode; // SelMode
std::string m_sm_context_status_uri;
};
//---------------------------------------------------------------------------------------
class pdu_session_create_sm_context_response :
public pdu_session_sm_context_response {
class pdu_session_create_sm_context_response
: public pdu_session_sm_context_response {
public:
pdu_session_create_sm_context_response()
:
pdu_session_sm_context_response(PDU_SESSION_CREATE_SM_CONTEXT_RESPONSE) {
m_paa = { };
m_qos_flow_context = { };
: pdu_session_sm_context_response(
PDU_SESSION_CREATE_SM_CONTEXT_RESPONSE) {
m_paa = {};
m_qos_flow_context = {};
}
pdu_session_create_sm_context_response(supi_t supi, pdu_session_id_t pdi,
std::string dnn, snssai_t snssai)
:
pdu_session_sm_context_response(PDU_SESSION_CREATE_SM_CONTEXT_RESPONSE,
supi, pdi, dnn, snssai) {
m_paa = { };
m_qos_flow_context = { };
pdu_session_create_sm_context_response(
supi_t supi, pdu_session_id_t pdi, std::string dnn, snssai_t snssai)
: pdu_session_sm_context_response(
PDU_SESSION_CREATE_SM_CONTEXT_RESPONSE, supi, pdi, dnn, snssai) {
m_paa = {};
m_qos_flow_context = {};
}
void set_paa(const paa_t &paa);
void set_paa(const paa_t& paa);
paa_t get_paa() const;
void set_qos_flow_context(const qos_flow_context_updated &qos_flow);
void set_qos_flow_context(const qos_flow_context_updated& qos_flow);
qos_flow_context_updated get_qos_flow_context() const;
void set_amf_url(const std::string &value);
void set_amf_url(const std::string& value);
std::string get_amf_url() const;
void set_smf_context_uri(const std::string &value);
void set_smf_context_uri(const std::string& value);
std::string get_smf_context_uri() const;
private:
......@@ -328,42 +309,40 @@ class pdu_session_create_sm_context_response :
};
//---------------------------------------------------------------------------------------
//see SmContextUpdateData (TS29502_Nsmf_PDUSession.yaml)
class pdu_session_update_sm_context_request :
public pdu_session_sm_context_request {
// see SmContextUpdateData (TS29502_Nsmf_PDUSession.yaml)
class pdu_session_update_sm_context_request
: public pdu_session_sm_context_request {
public:
pdu_session_update_sm_context_request()
:
pdu_session_sm_context_request(PDU_SESSION_UPDATE_SM_CONTEXT_REQUEST) {
m_5gMm_cause_value = 0;
m_data_forwarding = false;
: pdu_session_sm_context_request(PDU_SESSION_UPDATE_SM_CONTEXT_REQUEST) {
m_5gMm_cause_value = 0;
m_data_forwarding = false;
m_upCnx_state_is_set = false;
qfis = { };
dl_fteid = { };
m_release = false;
m_release_is_set = false;
m_an_type_is_set = false;
m_rat_type_is_set = false;
}
;
void add_qfi(const pfcp::qfi_t &qfi);
void add_qfi(const uint8_t &qfi);
void get_qfis(std::vector<pfcp::qfi_t> &q);
void set_dl_fteid(const pfcp::fteid_t &t);
void get_dl_fteid(pfcp::fteid_t &t);
void set_upCnx_state(const std::string &value);
qfis = {};
dl_fteid = {};
m_release = false;
m_release_is_set = false;
m_an_type_is_set = false;
m_rat_type_is_set = false;
};
void add_qfi(const pfcp::qfi_t& qfi);
void add_qfi(const uint8_t& qfi);
void get_qfis(std::vector<pfcp::qfi_t>& q);
void set_dl_fteid(const pfcp::fteid_t& t);
void get_dl_fteid(pfcp::fteid_t& t);
void set_upCnx_state(const std::string& value);
bool upCnx_state_is_set() const;
void set_rat_type(const std::string &value);
void set_rat_type(const std::string& value);
bool rat_type_is_set() const;
void set_an_type(const std::string &value);
void set_an_type(const std::string& value);
bool an_type_is_set() const;
bool release_is_set() const;
void set_release(bool value);
private:
std::vector<pfcp::qfi_t> qfis;
pfcp::fteid_t dl_fteid; //AN Tunnel Info
pfcp::fteid_t dl_fteid; // AN Tunnel Info
std::string m_nf_instanceId;
std::string m_an_type;
bool m_an_type_is_set;
......@@ -377,33 +356,27 @@ class pdu_session_update_sm_context_request :
uint8_t m_5gMm_cause_value;
bool m_release_is_set;
bool m_release;
};
//---------------------------------------------------------------------------------------
//for PDU session update response
class pdu_session_update_sm_context_response :
public pdu_session_sm_context_response {
// for PDU session update response
class pdu_session_update_sm_context_response
: public pdu_session_sm_context_response {
public:
pdu_session_update_sm_context_response()
:
pdu_session_sm_context_response(PDU_SESSION_UPDATE_SM_CONTEXT_RESPONSE) {
}
;
: pdu_session_sm_context_response(
PDU_SESSION_UPDATE_SM_CONTEXT_RESPONSE){};
pdu_session_update_sm_context_response(pdu_session_msg_type_t type)
:
pdu_session_sm_context_response(type) {
}
;
: pdu_session_sm_context_response(type){};
void add_qos_flow_context_updated(const qos_flow_context_updated &qos_flow);
bool get_qos_flow_context_updated(const pfcp::qfi_t &qfi,
qos_flow_context_updated &qos_flow);
void add_qos_flow_context_updated(const qos_flow_context_updated& qos_flow);
bool get_qos_flow_context_updated(
const pfcp::qfi_t& qfi, qos_flow_context_updated& qos_flow);
void get_all_qos_flow_context_updateds(
std::map<uint8_t, qos_flow_context_updated> &all_flows);
std::map<uint8_t, qos_flow_context_updated>& all_flows);
void remove_all_qos_flow_context_updateds();
void set_smf_context_uri(const std::string &value);
void set_smf_context_uri(const std::string& value);
std::string get_smf_context_uri() const;
private:
......@@ -415,32 +388,28 @@ class pdu_session_update_sm_context_response :
class pdu_session_release_sm_context_request : public pdu_session_msg {
public:
pdu_session_release_sm_context_request()
:
pdu_session_msg(PDU_SESSION_RELEASE_SM_CONTEXT_REQUEST) {
}
;
: pdu_session_msg(PDU_SESSION_RELEASE_SM_CONTEXT_REQUEST){};
private:
//From smContextReleaseData
// From smContextReleaseData
// cause:
// ngApCause:
// 5gMmCauseValue:
// ueLocation:
//ueTimeZone:
//addUeLocation:
//vsmfReleaseOnly:
//ismfReleaseOnly:
// ueTimeZone:
// addUeLocation:
// vsmfReleaseOnly:
// ismfReleaseOnly:
};
//---------------------------------------------------------------------------------------
class pdu_session_release_sm_context_response : public pdu_session_msg {
public:
pdu_session_release_sm_context_response()
:
pdu_session_msg(PDU_SESSION_RELEASE_SM_CONTEXT_RESPONSE) {
m_cause = 0;
: pdu_session_msg(PDU_SESSION_RELEASE_SM_CONTEXT_RESPONSE) {
m_cause = 0;
m_http_code = 0;
}
;
};
void set_cause(uint8_t cause);
uint8_t get_cause();
void set_http_code(const uint32_t code);
......@@ -452,29 +421,27 @@ class pdu_session_release_sm_context_response : public pdu_session_msg {
};
//---------------------------------------------------------------------------------------
class pdu_session_modification_network_requested :
public pdu_session_sm_context_request {
class pdu_session_modification_network_requested
: public pdu_session_sm_context_request {
public:
pdu_session_modification_network_requested()
:
pdu_session_sm_context_request(PDU_SESSION_MODIFICATION_SMF_REQUESTED) {
m_json_data = {};
: pdu_session_sm_context_request(PDU_SESSION_MODIFICATION_SMF_REQUESTED) {
m_json_data = {};
m_json_format = "application/json";
}
void set_amf_url(const std::string &value);
void set_amf_url(const std::string& value);
std::string get_amf_url() const;
void add_qfi(const pfcp::qfi_t &qfi);
void add_qfi(const uint8_t &qfi);
void get_qfis(std::vector<pfcp::qfi_t> &q);
void set_json_data(const nlohmann::json &data);
void get_json_data(nlohmann::json &data) const;
void set_json_format(const std::string &format);
void get_json_format(std::string &format) const;
void add_qos_flow_context_updated(const qos_flow_context_updated &qos_flow);
bool get_qos_flow_context_updated(const pfcp::qfi_t &qfi,
qos_flow_context_updated &qos_flow);
void add_qfi(const pfcp::qfi_t& qfi);
void add_qfi(const uint8_t& qfi);
void get_qfis(std::vector<pfcp::qfi_t>& q);
void set_json_data(const nlohmann::json& data);
void get_json_data(nlohmann::json& data) const;
void set_json_format(const std::string& format);
void get_json_format(std::string& format) const;
void add_qos_flow_context_updated(const qos_flow_context_updated& qos_flow);
bool get_qos_flow_context_updated(
const pfcp::qfi_t& qfi, qos_flow_context_updated& qos_flow);
private:
std::string amf_url;
......@@ -488,22 +455,20 @@ class pdu_session_modification_network_requested :
class pdu_session_report_response : public pdu_session_sm_context_response {
public:
pdu_session_report_response()
:
pdu_session_sm_context_response(PDU_SESSION_REPORT_RESPONSE) {
seid = 0;
: pdu_session_sm_context_response(PDU_SESSION_REPORT_RESPONSE) {
seid = 0;
trxn_id = 0;
}
;
};
void set_amf_url(std::string const &value);
void set_amf_url(std::string const& value);
std::string get_amf_url() const;
void add_qos_flow_context_updated(const qos_flow_context_updated &qos_flow);
bool get_qos_flow_context_updated(const pfcp::qfi_t &qfi,
qos_flow_context_updated &qos_flow);
void add_qos_flow_context_updated(const qos_flow_context_updated& qos_flow);
bool get_qos_flow_context_updated(
const pfcp::qfi_t& qfi, qos_flow_context_updated& qos_flow);
void get_all_qos_flow_context_updateds(
std::map<uint8_t, qos_flow_context_updated> &all_flows);
void set_seid(const seid_t &s);
void set_trxn_id(const uint64_t &t);
std::map<uint8_t, qos_flow_context_updated>& all_flows);
void set_seid(const seid_t& s);
void set_trxn_id(const uint64_t& t);
seid_t get_seid() const;
uint64_t get_trxn_id() const;
......@@ -515,83 +480,80 @@ class pdu_session_report_response : public pdu_session_sm_context_response {
};
class event_exposure_msg {
public:
public:
supi_t get_supi() const;
void set_supi(const supi_t &value);
void set_supi(const supi_t& value);
bool is_supi_is_set() const;
std::string get_supi_prefix() const;
void set_supi_prefix(const std::string &value);
void set_supi_prefix(const std::string& value);
void set_pdu_session_id(const pdu_session_id_t value);
pdu_session_id_t get_pdu_session_id() const;
bool is_psi_is_set() const;
void set_sub_id(std::string const &value);
void set_sub_id(std::string const& value);
std::string get_sub_id() const;
bool is_sub_id_is_set() const;
void set_notif_uri(std::string const &value);
void set_notif_uri(std::string const& value);
std::string get_notif_uri() const;
void set_notif_id(std::string const &value);
void set_notif_id(std::string const& value);
std::string get_notif_id() const;
std::vector<event_subscription_t> get_event_subs() const;
void set_event_subs(std::vector<event_subscription_t> const &value);
void set_event_subs(std::vector<event_subscription_t> const& value);
private:
supi_t m_supi;
bool m_supi_is_set;
std::string m_supi_prefix;
pdu_session_id_t m_pdu_session_id; //m_PduSeId;
pdu_session_id_t m_pdu_session_id; // m_PduSeId;
bool m_psi_is_set;
std::string m_sub_id; //m_SubId;
std::string m_sub_id; // m_SubId;
bool m_sub_id_is_set;
std::string m_notif_uri; //m_NotifUri;
std::string m_notif_id; //m_NotifId;
std::vector<event_subscription_t> m_event_subs; //m_EventSubs;
//NotificationMethod m_NotifMethod;
//bool m_NotifMethodIsSet;
//int32_t m_MaxReportNbr;
//bool m_MaxReportNbrIsSet;
//std::string m_Expiry;
//bool m_ExpiryIsSet;
//int32_t m_RepPeriod;
//bool m_RepPeriodIsSet;
//Guami m_Guami;
//bool m_GuamiIsSet;
//std::string m_ServiveName;
//bool m_ServiveNameIsSet;
//std::vector<std::string> m_AltNotifIpv4Addrs;
//bool m_AltNotifIpv4AddrsIsSet;
//std::vector<Ipv6Addr> m_AltNotifIpv6Addrs;
//bool m_AltNotifIpv6AddrsIsSet;
std::string m_notif_uri; // m_NotifUri;
std::string m_notif_id; // m_NotifId;
std::vector<event_subscription_t> m_event_subs; // m_EventSubs;
// NotificationMethod m_NotifMethod;
// bool m_NotifMethodIsSet;
// int32_t m_MaxReportNbr;
// bool m_MaxReportNbrIsSet;
// std::string m_Expiry;
// bool m_ExpiryIsSet;
// int32_t m_RepPeriod;
// bool m_RepPeriodIsSet;
// Guami m_Guami;
// bool m_GuamiIsSet;
// std::string m_ServiveName;
// bool m_ServiveNameIsSet;
// std::vector<std::string> m_AltNotifIpv4Addrs;
// bool m_AltNotifIpv4AddrsIsSet;
// std::vector<Ipv6Addr> m_AltNotifIpv6Addrs;
// bool m_AltNotifIpv6AddrsIsSet;
// bool m_AnyUeInd;
// bool m_AnyUeIndIsSet;
//std::string m_Gpsi;
//bool m_GpsiIsSet;
//std::string m_GroupId;
//bool m_GroupIdIsSet;
//bool m_ImmeRep;
//bool m_ImmeRepIsSet;
//std::string m_SupportedFeatures;
//bool m_SupportedFeaturesIsSet;
// std::string m_Gpsi;
// bool m_GpsiIsSet;
// std::string m_GroupId;
// bool m_GroupIdIsSet;
// bool m_ImmeRep;
// bool m_ImmeRepIsSet;
// std::string m_SupportedFeatures;
// bool m_SupportedFeaturesIsSet;
};
class event_notification {
public:
void set_smf_event(const smf_event_t &ev);
void set_smf_event(const smf_event_t& ev);
smf_event_t get_smf_event() const;
void set_supi(const supi64_t &supi);
void set_supi(const supi64_t& supi);
supi64_t get_supi() const;
bool is_supi_is_set() const;
//m_AdIpv4Addr
void set_ad_ipv4_addr(std::string const &value);
// m_AdIpv4Addr
void set_ad_ipv4_addr(std::string const& value);
std::string get_ad_ipv4_addr() const;
bool is_ad_ipv4_addr_is_set() const;
//m_ReIpv4Addr
void set_re_ipv4_addr(std::string const &value);
// m_ReIpv4Addr
void set_re_ipv4_addr(std::string const& value);
std::string get_re_ipv4_addr() const;
bool is_re_ipv4_addr_is_set() const;
......@@ -599,71 +561,88 @@ class event_notification {
pdu_session_id_t get_pdu_session_id() const;
bool is_psi_is_set() const;
void set_notif_uri(std::string const &value);
void set_notif_uri(std::string const& value);
std::string get_notif_uri() const;
void set_notif_id(std::string const &value);
void set_notif_id(std::string const& value);
std::string get_notif_id() const;
private:
std::string m_notif_uri; //m_NotifUri;
std::string m_notif_id; //m_NotifId;
std::string m_notif_uri; // m_NotifUri;
std::string m_notif_id; // m_NotifId;
smf_event_t m_event; //SmfEvent
//std::string m_TimeStamp;
smf_event_t m_event; // SmfEvent
// std::string m_TimeStamp;
supi64_t m_supi;
bool m_supi_is_set;
//for a UE IP address change
std::string m_ad_ipv4_addr; //m_AdIpv4Addr
bool m_ad_ipv4_addr_is_set; //m_AdIpv4AddrIsSet;
std::string m_re_ipv4_addr; //m_ReIpv4Addr;
bool m_re_ipv4_addr_is_set; //m_ReIpv4AddrIsSet;
// for a UE IP address change
std::string m_ad_ipv4_addr; // m_AdIpv4Addr
bool m_ad_ipv4_addr_is_set; // m_AdIpv4AddrIsSet;
std::string m_re_ipv4_addr; // m_ReIpv4Addr;
bool m_re_ipv4_addr_is_set; // m_ReIpv4AddrIsSet;
//for a PLMN Change
//PlmnId m_PlmnId;
//bool m_PlmnIdIsSet;
// for a PLMN Change
// PlmnId m_PlmnId;
// bool m_PlmnIdIsSet;
//for an access type change
//AccessType m_AccType;
//bool m_AccTypeIsSet;
// for an access type change
// AccessType m_AccType;
// bool m_AccTypeIsSet;
//for a PDU Session Release
pdu_session_id_t m_pdu_session_id; //m_PduSeId;
// for a PDU Session Release
pdu_session_id_t m_pdu_session_id; // m_PduSeId;
bool m_psi_is_set;
//std::string m_Gpsi;
//bool m_GpsiIsSet;
//std::string m_SourceDnai;
//bool m_SourceDnaiIsSet;
//std::string m_TargetDnai;
//bool m_TargetDnaiIsSet;
//DnaiChangeType m_DnaiChgType;
//bool m_DnaiChgTypeIsSet;
//std::string m_TargetUeIpv4Addr;
//bool m_TargetUeIpv4AddrIsSet;
//std::string m_SourceUeIpv4Addr;
//bool m_SourceUeIpv4AddrIsSet;
//Ipv6Prefix m_SourceUeIpv6Prefix;
//bool m_SourceUeIpv6PrefixIsSet;
//Ipv6Prefix m_TargetUeIpv6Prefix;
//bool m_TargetUeIpv6PrefixIsSet;
//RouteToLocation m_SourceTraRouting;
//bool m_SourceTraRoutingIsSet;
//RouteToLocation m_TargetTraRouting;
//bool m_TargetTraRoutingIsSet;
//std::string m_UeMac;
//bool m_UeMacIsSet;
//Ipv6Prefix m_AdIpv6Prefix;
//bool m_AdIpv6PrefixIsSet;
//Ipv6Prefix m_ReIpv6Prefix;
//bool m_ReIpv6PrefixIsSet;
//DddStatus m_DddStatus;
//bool m_DddStatusIsSet;
//std::string m_MaxWaitTime;
//bool m_MaxWaitTimeIsSet;
// std::string m_Gpsi;
// bool m_GpsiIsSet;
// std::string m_SourceDnai;
// bool m_SourceDnaiIsSet;
// std::string m_TargetDnai;
// bool m_TargetDnaiIsSet;
// DnaiChangeType m_DnaiChgType;
// bool m_DnaiChgTypeIsSet;
// std::string m_TargetUeIpv4Addr;
// bool m_TargetUeIpv4AddrIsSet;
// std::string m_SourceUeIpv4Addr;
// bool m_SourceUeIpv4AddrIsSet;
// Ipv6Prefix m_SourceUeIpv6Prefix;
// bool m_SourceUeIpv6PrefixIsSet;
// Ipv6Prefix m_TargetUeIpv6Prefix;
// bool m_TargetUeIpv6PrefixIsSet;
// RouteToLocation m_SourceTraRouting;
// bool m_SourceTraRoutingIsSet;
// RouteToLocation m_TargetTraRouting;
// bool m_TargetTraRoutingIsSet;
// std::string m_UeMac;
// bool m_UeMacIsSet;
// Ipv6Prefix m_AdIpv6Prefix;
// bool m_AdIpv6PrefixIsSet;
// Ipv6Prefix m_ReIpv6Prefix;
// bool m_ReIpv6PrefixIsSet;
// DddStatus m_DddStatus;
// bool m_DddStatusIsSet;
// std::string m_MaxWaitTime;
// bool m_MaxWaitTimeIsSet;
};
class data_notification_msg {
public:
void set_notification_event_type(const std::string& type);
void get_notification_event_type(std::string& type) const;
void set_nf_instance_uri(const std::string& uri);
void get_nf_instance_uri(std::string& uri) const;
void set_profile(const std::shared_ptr<nf_profile>& p);
void get_profile(std::shared_ptr<nf_profile>& p) const;
private:
std::string notification_event_type;
std::string nf_instance_uri;
std::shared_ptr<nf_profile> profile;
// bool m_NfProfileIsSet;
// std::vector<ChangeItem> m_ProfileChanges;
// bool m_ProfileChangesIsSet;
};
}
} // namespace smf
#endif
......@@ -54,27 +54,27 @@ using namespace Pistache::Http::Mime;
using namespace smf;
using json = nlohmann::json;
extern itti_mw *itti_inst;
extern smf_n11 *smf_n11_inst;
extern itti_mw* itti_inst;
extern smf_n11* smf_n11_inst;
extern smf_config smf_cfg;
void smf_n11_task(void *);
void smf_n11_task(void*);
// To read content of the response from AMF
static std::size_t callback(const char *in, std::size_t size, std::size_t num,
std::string *out) {
static std::size_t callback(
const char* in, std::size_t size, std::size_t num, std::string* out) {
const std::size_t totalBytes(size * num);
out->append(in, totalBytes);
return totalBytes;
}
//------------------------------------------------------------------------------
void smf_n11_task(void *args_p) {
void smf_n11_task(void* args_p) {
const task_id_t task_id = TASK_SMF_N11;
itti_inst->notify_task_ready(task_id);
do {
std::shared_ptr<itti_msg> shared_msg = itti_inst->receive_msg(task_id);
auto *msg = shared_msg.get();
auto* msg = shared_msg.get();
switch (msg->msg_type) {
case N11_SESSION_CREATE_SM_CONTEXT_RESPONSE:
smf_n11_inst->send_n1n2_message_transfer_request(
......@@ -124,9 +124,15 @@ void smf_n11_task(void *args_p) {
shared_msg));
break;
case N11_SUBSCRIBE_UPF_STATUS_NOTIFY:
smf_n11_inst->subscribe_upf_status_notify(
std::static_pointer_cast<itti_n11_subscribe_upf_status_notify>(
shared_msg));
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::smf_n11().info("Received terminate message");
return;
}
......@@ -156,8 +162,8 @@ void smf_n11::send_n1n2_message_transfer_request(
"Send Communication_N1N2MessageTransfer to AMF (HTTP version %d)",
sm_context_res->http_version);
mime_parser parser = {};
std::string n1_message = sm_context_res->res.get_n1_sm_message();
mime_parser parser = {};
std::string n1_message = sm_context_res->res.get_n1_sm_message();
nlohmann::json json_data = {};
std::string body;
......@@ -168,8 +174,8 @@ void smf_n11::send_n1n2_message_transfer_request(
if (n2_sm_found > 0) {
std::string n2_message = sm_context_res->res.get_n2_sm_information();
// prepare the body content for Curl
parser.create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY,
n1_message, n2_message);
parser.create_multipart_related_content(
body, json_part, CURL_MIME_BOUNDARY, n1_message, n2_message);
} else {
// prepare the body content for Curl
parser.create_multipart_related_content(
......@@ -181,23 +187,23 @@ void smf_n11::send_n1n2_message_transfer_request(
"Send Communication_N1N2MessageTransfer to AMF, body %s", body.c_str());
uint32_t str_len = body.length();
char *data = (char *)malloc(str_len + 1);
char* data = (char*) malloc(str_len + 1);
memset(data, 0, str_len + 1);
memcpy((void *)data, (void *)body.c_str(), str_len);
memcpy((void*) data, (void*) body.c_str(), str_len);
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = curl_easy_init();
CURL* curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist *headers = nullptr;
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
std::string content_type = "content-type: multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY);
headers = curl_slist_append(headers, content_type.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL,
sm_context_res->res.get_amf_url().c_str());
curl_easy_setopt(
curl, CURLOPT_URL, sm_context_res->res.get_amf_url().c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, AMF_CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str());
......@@ -207,8 +213,8 @@ void smf_n11::send_n1n2_message_transfer_request(
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
curl_easy_setopt(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
}
// Response information.
......@@ -228,18 +234,19 @@ void smf_n11::send_n1n2_message_transfer_request(
json response_data = {};
try {
response_data = json::parse(*httpData.get());
} catch (json::exception &e) {
} catch (json::exception& e) {
Logger::smf_n11().warn("Could not get the cause from the response");
// Set the default Cause
response_data["cause"] = "504 Gateway Timeout";
}
Logger::smf_n11().debug("Response from AMF, Http Code: %d, cause %s",
httpCode, response_data["cause"].dump().c_str());
Logger::smf_n11().debug(
"Response from AMF, Http Code: %d, cause %s", httpCode,
response_data["cause"].dump().c_str());
// send response to APP to process
itti_n11_n1n2_message_transfer_response_status *itti_msg =
new itti_n11_n1n2_message_transfer_response_status(TASK_SMF_N11,
TASK_SMF_APP);
itti_n11_n1n2_message_transfer_response_status* itti_msg =
new itti_n11_n1n2_message_transfer_response_status(
TASK_SMF_N11, TASK_SMF_APP);
itti_msg->set_response_code(httpCode);
itti_msg->set_scid(sm_context_res->scid);
itti_msg->set_procedure_type(session_management_procedures_type_e::
......@@ -264,7 +271,7 @@ void smf_n11::send_n1n2_message_transfer_request(
curl_easy_cleanup(curl);
}
curl_global_cleanup();
free_wrapper((void **)&data);
free_wrapper((void**) &data);
}
//------------------------------------------------------------------------------
......@@ -286,8 +293,8 @@ void smf_n11::send_n1n2_message_transfer_request(
if (n2_sm_found > 0) {
std::string n2_message =
sm_session_modification->msg.get_n2_sm_information();
parser.create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY,
n1_message, n2_message);
parser.create_multipart_related_content(
body, json_part, CURL_MIME_BOUNDARY, n1_message, n2_message);
} else {
parser.create_multipart_related_content(
body, json_part, CURL_MIME_BOUNDARY, n1_message,
......@@ -295,23 +302,23 @@ void smf_n11::send_n1n2_message_transfer_request(
}
uint32_t str_len = body.length();
char *data = (char *)malloc(str_len + 1);
char* data = (char*) malloc(str_len + 1);
memset(data, 0, str_len + 1);
memcpy((void *)data, (void *)body.c_str(), str_len);
memcpy((void*) data, (void*) body.c_str(), str_len);
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = curl_easy_init();
CURL* curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist *headers = nullptr;
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
std::string content_type = "content-type: multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY);
headers = curl_slist_append(headers, content_type.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL,
sm_session_modification->msg.get_amf_url().c_str());
curl_easy_setopt(
curl, CURLOPT_URL, sm_session_modification->msg.get_amf_url().c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, AMF_CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, smf_cfg.sbi.if_name.c_str());
......@@ -321,8 +328,8 @@ void smf_n11::send_n1n2_message_transfer_request(
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
curl_easy_setopt(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
}
// Response information.
......@@ -344,7 +351,7 @@ void smf_n11::send_n1n2_message_transfer_request(
json response_data = {};
try {
response_data = json::parse(*httpData.get());
} catch (json::exception &e) {
} catch (json::exception& e) {
Logger::smf_n11().warn("Could not get the cause from the response");
}
Logger::smf_n11().debug("Response from AMF, Http Code: %d", httpCode);
......@@ -353,7 +360,7 @@ void smf_n11::send_n1n2_message_transfer_request(
curl_easy_cleanup(curl);
}
curl_global_cleanup();
free_wrapper((void **)&data);
free_wrapper((void**) &data);
}
//------------------------------------------------------------------------------
......@@ -363,8 +370,8 @@ void smf_n11::send_n1n2_message_transfer_request(
"Send Communication_N1N2MessageTransfer to AMF (Network-initiated "
"Service Request)");
mime_parser parser = {};
std::string n2_message = report_msg->res.get_n2_sm_information();
mime_parser parser = {};
std::string n2_message = report_msg->res.get_n2_sm_information();
nlohmann::json json_data = {};
std::string body;
report_msg->res.get_json_data(json_data);
......@@ -375,8 +382,8 @@ void smf_n11::send_n1n2_message_transfer_request(
if (n1_sm_found > 0) {
std::string n1_message = report_msg->res.get_n1_sm_message();
// prepare the body content for Curl
parser.create_multipart_related_content(body, json_part, CURL_MIME_BOUNDARY,
n1_message, n2_message);
parser.create_multipart_related_content(
body, json_part, CURL_MIME_BOUNDARY, n1_message, n2_message);
} else {
parser.create_multipart_related_content(
body, json_part, CURL_MIME_BOUNDARY, n2_message,
......@@ -384,16 +391,16 @@ void smf_n11::send_n1n2_message_transfer_request(
}
uint32_t str_len = body.length();
char *data = (char *)malloc(str_len + 1);
char* data = (char*) malloc(str_len + 1);
memset(data, 0, str_len + 1);
memcpy((void *)data, (void *)body.c_str(), str_len);
memcpy((void*) data, (void*) body.c_str(), str_len);
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = curl_easy_init();
CURL* curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist *headers = nullptr;
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
std::string content_type = "content-type: multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY);
......@@ -409,8 +416,8 @@ void smf_n11::send_n1n2_message_transfer_request(
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
curl_easy_setopt(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
}
// Response information.
......@@ -432,18 +439,19 @@ void smf_n11::send_n1n2_message_transfer_request(
json response_data = {};
try {
response_data = json::parse(*httpData.get());
} catch (json::exception &e) {
} catch (json::exception& e) {
Logger::smf_n11().warn("Could not get the cause from the response");
// Set the default Cause
response_data["cause"] = "504 Gateway Timeout";
}
Logger::smf_n11().debug("Response from AMF, Http Code: %d, cause %s",
httpCode, response_data["cause"].dump().c_str());
Logger::smf_n11().debug(
"Response from AMF, Http Code: %d, cause %s", httpCode,
response_data["cause"].dump().c_str());
// send response to APP to process
itti_n11_n1n2_message_transfer_response_status *itti_msg =
new itti_n11_n1n2_message_transfer_response_status(TASK_SMF_N11,
TASK_SMF_APP);
itti_n11_n1n2_message_transfer_response_status* itti_msg =
new itti_n11_n1n2_message_transfer_response_status(
TASK_SMF_N11, TASK_SMF_APP);
itti_msg->set_response_code(httpCode);
itti_msg->set_procedure_type(session_management_procedures_type_e::
SERVICE_REQUEST_NETWORK_TRIGGERED);
......@@ -465,7 +473,7 @@ void smf_n11::send_n1n2_message_transfer_request(
curl_easy_cleanup(curl);
}
curl_global_cleanup();
free_wrapper((void **)&data);
free_wrapper((void**) &data);
}
//------------------------------------------------------------------------------
......@@ -474,8 +482,8 @@ void smf_n11::send_sm_context_status_notification(
Logger::smf_n11().debug(
"Send SM Context Status Notification to AMF(HTTP version %d)",
sm_context_status->http_version);
Logger::smf_n11().debug("AMF URI: %s",
sm_context_status->amf_status_uri.c_str());
Logger::smf_n11().debug(
"AMF URI: %s", sm_context_status->amf_status_uri.c_str());
nlohmann::json json_data = {};
// Fill the json part
......@@ -484,16 +492,16 @@ void smf_n11::send_sm_context_status_notification(
std::string body = json_data.dump();
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = curl = curl_easy_init();
CURL* curl = curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist *headers = nullptr;
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL,
sm_context_status->amf_status_uri.c_str());
curl_easy_setopt(
curl, CURLOPT_URL, sm_context_status->amf_status_uri.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, AMF_CURL_TIMEOUT_MS);
......@@ -502,8 +510,8 @@ void smf_n11::send_sm_context_status_notification(
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
curl_easy_setopt(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
}
// Response information.
......@@ -532,12 +540,12 @@ void smf_n11::notify_subscribed_event(
"Send notification for the subscribed event to the subscription");
int still_running = 0, numfds = 0, res = 0;
CURLMsg *curl_msg = nullptr;
CURL *curl = nullptr;
CURLMsg* curl_msg = nullptr;
CURL* curl = nullptr;
CURLcode return_code = {};
int http_status_code = 0, msgs_left = 0;
CURLM *m_curl_multi = nullptr;
char *url = nullptr;
CURLM* m_curl_multi = nullptr;
char* url = nullptr;
std::unique_ptr<std::string> httpData(new std::string());
std::string data;
......@@ -545,7 +553,7 @@ void smf_n11::notify_subscribed_event(
curl_global_init(CURL_GLOBAL_ALL);
m_curl_multi = curl_multi_init();
// init header
struct curl_slist *headers = NULL;
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
......@@ -553,31 +561,31 @@ void smf_n11::notify_subscribed_event(
std::vector<std::string> bodys = {}; // store body for all the request
for (auto i : msg->event_notifs) {
// Fill the json part
nlohmann::json json_data = {};
json_data["notifId"] = i.get_notif_id();
auto event_notifs = nlohmann::json::array();
nlohmann::json json_data = {};
json_data["notifId"] = i.get_notif_id();
auto event_notifs = nlohmann::json::array();
nlohmann::json event_notif = {};
event_notif["event"] = i.get_smf_event();
event_notif["pduSeId"] = i.get_pdu_session_id();
event_notif["supi"] = std::to_string(i.get_supi());
event_notif["event"] = i.get_smf_event();
event_notif["pduSeId"] = i.get_pdu_session_id();
event_notif["supi"] = std::to_string(i.get_supi());
// timestamp
std::time_t time_epoch_ntp = std::time(nullptr);
uint64_t tv_ntp = time_epoch_ntp + SECONDS_SINCE_FIRST_EPOCH;
event_notif["timeStamp"] = std::to_string(tv_ntp);
uint64_t tv_ntp = time_epoch_ntp + SECONDS_SINCE_FIRST_EPOCH;
event_notif["timeStamp"] = std::to_string(tv_ntp);
event_notifs.push_back(event_notif);
json_data["eventNotifs"] = event_notifs;
std::string body = json_data.dump();
std::string body = json_data.dump();
bodys.push_back(body);
}
int index = 0;
// create and add an easy handle to a multi curl request
for (auto i : msg->event_notifs) {
CURL *curl = curl_easy_init();
CURL* curl = curl_easy_init();
if (curl) {
std::string url = i.get_notif_uri();
Logger::smf_n11().debug("Send notification to NF with URI: %s",
url.c_str());
Logger::smf_n11().debug(
"Send notification to NF with URI: %s", url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPPOST, 1);
......@@ -608,9 +616,9 @@ void smf_n11::notify_subscribed_event(
// read the messages
while ((curl_msg = curl_multi_info_read(m_curl_multi, &msgs_left))) {
if (curl_msg->msg == CURLMSG_DONE) {
curl = curl_msg->easy_handle;
curl = curl_msg->easy_handle;
return_code = curl_msg->data.result;
res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
res = curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &url);
if (return_code != CURLE_OK) {
Logger::smf_n11().debug("CURL error code %d!", curl_msg->data.result);
......@@ -624,22 +632,22 @@ void smf_n11::notify_subscribed_event(
curl_multi_remove_handle(m_curl_multi, curl);
curl_easy_cleanup(curl);
} else {
Logger::smf_n11().debug("Error after curl_multi_info_read(), CURLMsg %s",
curl_msg->msg);
Logger::smf_n11().debug(
"Error after curl_multi_info_read(), CURLMsg %s", curl_msg->msg);
}
}
}
//-----------------------------------------------------------------------------------------------------
CURL *smf_n11::curl_create_handle(event_notification &ev_notif,
std::string *httpData) {
CURL* smf_n11::curl_create_handle(
event_notification& ev_notif, std::string* httpData) {
// create handle for a curl request
struct curl_slist *headers = NULL;
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
CURL *curl = curl_easy_init();
CURL* curl = curl_easy_init();
if (curl) {
std::string url = ev_notif.get_notif_uri();
......@@ -668,24 +676,24 @@ void smf_n11::register_nf_instance(
msg->profile.to_json(json_data);
std::string url =
std::string(inet_ntoa(*((struct in_addr *)&smf_cfg.nrf_addr.ipv4_addr))) +
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.nrf_addr.ipv4_addr))) +
":" + std::to_string(smf_cfg.nrf_addr.port) + NNRF_NFM_BASE +
smf_cfg.nrf_addr.api_version + NNRF_NF_REGISTER_URL +
msg->profile.get_nf_instance_id();
Logger::smf_n11().debug("Send NF Instance Registration to NRF (NRF URL %s)",
url.c_str());
Logger::smf_n11().debug(
"Send NF Instance Registration to NRF (NRF URL %s)", url.c_str());
std::string body = json_data.dump();
Logger::smf_n11().debug(
"Send NF Instance Registration to NRF, msg body: \n %s", body.c_str());
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = curl = curl_easy_init();
CURL* curl = curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist *headers = nullptr;
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
......@@ -699,8 +707,8 @@ void smf_n11::register_nf_instance(
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
curl_easy_setopt(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
}
// Response information.
......@@ -720,18 +728,18 @@ void smf_n11::register_nf_instance(
json response_data = {};
try {
response_data = json::parse(*httpData.get());
} catch (json::exception &e) {
} catch (json::exception& e) {
Logger::smf_n11().warn("Could not parse json from the NRF response");
}
Logger::smf_n11().debug("Response from NRF, Json data: \n %s",
response_data.dump().c_str());
Logger::smf_n11().debug(
"Response from NRF, Json data: \n %s", response_data.dump().c_str());
// send response to APP to process
std::shared_ptr<itti_n11_register_nf_instance_response> itti_msg =
std::make_shared<itti_n11_register_nf_instance_response>(
TASK_SMF_N11, TASK_SMF_APP);
itti_msg->http_response_code = httpCode;
itti_msg->http_version = msg->http_version;
itti_msg->http_version = msg->http_version;
Logger::smf_app().debug("Registered SMF profile (from NRF)");
itti_msg->profile.from_json(response_data);
......@@ -754,8 +762,8 @@ void smf_n11::register_nf_instance(
//-----------------------------------------------------------------------------------------------------
void smf_n11::update_nf_instance(
std::shared_ptr<itti_n11_update_nf_instance_request> msg) {
Logger::smf_n11().debug("Send NF Update to NRF (HTTP version %d)",
msg->http_version);
Logger::smf_n11().debug(
"Send NF Update to NRF (HTTP version %d)", msg->http_version);
nlohmann::json json_data = nlohmann::json::array();
for (auto i : msg->patch_items) {
......@@ -767,7 +775,7 @@ void smf_n11::update_nf_instance(
Logger::smf_n11().debug("Send NF Update to NRF (Msg body %s)", body.c_str());
std::string url =
std::string(inet_ntoa(*((struct in_addr *)&smf_cfg.nrf_addr.ipv4_addr))) +
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.nrf_addr.ipv4_addr))) +
":" + std::to_string(smf_cfg.nrf_addr.port) + NNRF_NFM_BASE +
smf_cfg.nrf_addr.api_version + NNRF_NF_REGISTER_URL +
msg->smf_instance_id;
......@@ -775,11 +783,11 @@ void smf_n11::update_nf_instance(
Logger::smf_n11().debug("Send NF Update to NRF (NRF URL %s)", url.c_str());
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = curl = curl_easy_init();
CURL* curl = curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist *headers = nullptr;
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
......@@ -793,8 +801,8 @@ void smf_n11::update_nf_instance(
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
curl_easy_setopt(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
}
// Response information.
......@@ -818,11 +826,11 @@ void smf_n11::update_nf_instance(
// TODO: in case of response containing NF profile
// send response to APP to process
std::shared_ptr<itti_n11_update_nf_instance_response> itti_msg =
std::make_shared<itti_n11_update_nf_instance_response>(TASK_SMF_N11,
TASK_SMF_APP);
std::make_shared<itti_n11_update_nf_instance_response>(
TASK_SMF_N11, TASK_SMF_APP);
itti_msg->http_response_code = httpCode;
itti_msg->http_version = msg->http_version;
itti_msg->smf_instance_id = msg->smf_instance_id;
itti_msg->http_version = msg->http_version;
itti_msg->smf_instance_id = msg->smf_instance_id;
int ret = itti_inst->send_msg(itti_msg);
if (RETURNok != ret) {
......@@ -843,24 +851,24 @@ void smf_n11::update_nf_instance(
//-----------------------------------------------------------------------------------------------------
void smf_n11::deregister_nf_instance(
std::shared_ptr<itti_n11_deregister_nf_instance> msg) {
Logger::smf_n11().debug("Send NF De-register to NRF (HTTP version %d)",
msg->http_version);
Logger::smf_n11().debug(
"Send NF De-register to NRF (HTTP version %d)", msg->http_version);
std::string url =
std::string(inet_ntoa(*((struct in_addr *)&smf_cfg.nrf_addr.ipv4_addr))) +
std::string(inet_ntoa(*((struct in_addr*) &smf_cfg.nrf_addr.ipv4_addr))) +
":" + std::to_string(smf_cfg.nrf_addr.port) + NNRF_NFM_BASE +
smf_cfg.nrf_addr.api_version + NNRF_NF_REGISTER_URL +
msg->smf_instance_id;
Logger::smf_n11().debug("Send NF De-register to NRF (NRF URL %s)",
url.c_str());
Logger::smf_n11().debug(
"Send NF De-register to NRF (NRF URL %s)", url.c_str());
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl = curl = curl_easy_init();
CURL* curl = curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist *headers = nullptr;
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
......@@ -874,8 +882,8 @@ void smf_n11::deregister_nf_instance(
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION,
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
curl_easy_setopt(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
}
// Response information.
......@@ -903,3 +911,70 @@ void smf_n11::deregister_nf_instance(
}
curl_global_cleanup();
}
//-----------------------------------------------------------------------------------------------------
void smf_n11::subscribe_upf_status_notify(
std::shared_ptr<itti_n11_subscribe_upf_status_notify> msg) {
Logger::smf_n11().debug(
"Send NFSubscribeNotify to NRF to be notified when a new UPF becomes "
"available (HTTP version %d)",
msg->http_version);
Logger::smf_n11().debug(
"Send NF De-register to NRF (NRF URL %s)", msg->url.c_str());
std::string body = msg->json_data.dump();
Logger::smf_n11().debug(
"Send NF Instance Registration to NRF, msg body: \n %s", body.c_str());
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist* headers = nullptr;
// headers = curl_slist_append(headers, "charsets: utf-8");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, msg->url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, NRF_CURL_TIMEOUT_MS);
if (msg->http_version == 2) {
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// we use a self-signed test server, skip verification during debugging
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(
curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE);
}
// Response information.
long httpCode = {0};
std::unique_ptr<std::string> httpData(new std::string());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, body.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
Logger::smf_n11().debug("Response from NRF, Http Code: %d", httpCode);
if ((static_cast<http_response_codes_e>(httpCode) ==
http_response_codes_e::HTTP_RESPONSE_CODE_OK) or
(static_cast<http_response_codes_e>(httpCode) ==
http_response_codes_e::HTTP_RESPONSE_CODE_NO_CONTENT)) {
Logger::smf_n11().debug("Got successful response from NRF");
} else {
Logger::smf_n11().warn("Could not get response from NRF");
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
}
......@@ -48,8 +48,8 @@ class smf_n11 {
public:
smf_n11();
smf_n11(smf_n11 const &) = delete;
void operator=(smf_n11 const &) = delete;
smf_n11(smf_n11 const&) = delete;
void operator=(smf_n11 const&) = delete;
/*
* Send N1N2 Message Transfer Request to AMF
......@@ -123,13 +123,24 @@ class smf_n11 {
*/
void deregister_nf_instance(
std::shared_ptr<itti_n11_deregister_nf_instance> msg);
/*
* Send a NFStatusSubscribe to NRF (to be notified when a new UPF becomes
* available)
* @param [std::shared_ptr<itti_n11_subscribe_upf_status_notify>] msg: Content
* of message to be sent
* @return void
*/
void subscribe_upf_status_notify(
std::shared_ptr<itti_n11_subscribe_upf_status_notify> msg);
/*
* Create Curl handle for multi curl
* @param [event_notification&] ev_notif: content of the event notification
* @param [std::string *] data: data
* @return pointer to the created curl
*/
CURL *curl_create_handle(event_notification &ev_notif, std::string *data);
CURL* curl_create_handle(event_notification& ev_notif, std::string* data);
};
} // namespace smf
#endif /* FILE_SMF_N11_HPP_SEEN */
......@@ -38,144 +38,135 @@ using namespace std;
using namespace smf;
//------------------------------------------------------------------------------
void smf_profile::set_nf_instance_id(const std::string &instance_id) {
void nf_profile::set_nf_instance_id(const std::string& instance_id) {
nf_instance_id = instance_id;
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_instance_id(std::string &instance_id) const {
void nf_profile::get_nf_instance_id(std::string& instance_id) const {
instance_id = nf_instance_id;
}
//------------------------------------------------------------------------------
std::string smf_profile::get_nf_instance_id() const { return nf_instance_id; }
std::string nf_profile::get_nf_instance_id() const {
return nf_instance_id;
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_instance_name(const std::string &instance_name) {
void nf_profile::set_nf_instance_name(const std::string& instance_name) {
nf_instance_name = instance_name;
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_instance_name(std::string &instance_name) const {
void nf_profile::get_nf_instance_name(std::string& instance_name) const {
instance_name = nf_instance_name;
}
//------------------------------------------------------------------------------
std::string smf_profile::get_nf_instance_name() const {
std::string nf_profile::get_nf_instance_name() const {
return nf_instance_name;
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_type(const std::string &type) { nf_type = type; }
void nf_profile::set_nf_type(const std::string& type) {
nf_type = type;
}
//------------------------------------------------------------------------------
std::string smf_profile::get_nf_type() const { return nf_type; }
std::string nf_profile::get_nf_type() const {
return nf_type;
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_status(const std::string &status) {
void nf_profile::set_nf_status(const std::string& status) {
nf_status = status;
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_status(std::string &status) const {
void nf_profile::get_nf_status(std::string& status) const {
status = nf_status;
}
//------------------------------------------------------------------------------
std::string smf_profile::get_nf_status() const { return nf_status; }
std::string nf_profile::get_nf_status() const {
return nf_status;
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_heartBeat_timer(const int32_t &timer) {
void nf_profile::set_nf_heartBeat_timer(const int32_t& timer) {
heartBeat_timer = timer;
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_heartBeat_timer(int32_t &timer) const {
void nf_profile::get_nf_heartBeat_timer(int32_t& timer) const {
timer = heartBeat_timer;
}
//------------------------------------------------------------------------------
int32_t smf_profile::get_nf_heartBeat_timer() const { return heartBeat_timer; }
int32_t nf_profile::get_nf_heartBeat_timer() const {
return heartBeat_timer;
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_priority(const uint16_t &p) { priority = p; }
void nf_profile::set_nf_priority(const uint16_t& p) {
priority = p;
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_priority(uint16_t &p) const { p = priority; }
void nf_profile::get_nf_priority(uint16_t& p) const {
p = priority;
}
//------------------------------------------------------------------------------
uint16_t smf_profile::get_nf_priority() const { return priority; }
uint16_t nf_profile::get_nf_priority() const {
return priority;
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_capacity(const uint16_t &c) { capacity = c; }
void nf_profile::set_nf_capacity(const uint16_t& c) {
capacity = c;
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_capacity(uint16_t &c) const { c = capacity; }
void nf_profile::get_nf_capacity(uint16_t& c) const {
c = capacity;
}
//------------------------------------------------------------------------------
uint16_t smf_profile::get_nf_capacity() const { return capacity; }
uint16_t nf_profile::get_nf_capacity() const {
return capacity;
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_snssais(const std::vector<snssai_t> &s) {
void nf_profile::set_nf_snssais(const std::vector<snssai_t>& s) {
snssais = s;
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_snssais(std::vector<snssai_t> &s) const {
void nf_profile::get_nf_snssais(std::vector<snssai_t>& s) const {
s = snssais;
}
//------------------------------------------------------------------------------
void smf_profile::add_snssai(const snssai_t &s) { snssais.push_back(s); }
void nf_profile::add_snssai(const snssai_t& s) {
snssais.push_back(s);
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_ipv4_addresses(const std::vector<struct in_addr> &a) {
void nf_profile::set_nf_ipv4_addresses(const std::vector<struct in_addr>& a) {
ipv4_addresses = a;
}
//------------------------------------------------------------------------------
void smf_profile::add_nf_ipv4_addresses(const struct in_addr &a) {
void nf_profile::add_nf_ipv4_addresses(const struct in_addr& a) {
ipv4_addresses.push_back(a);
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_ipv4_addresses(std::vector<struct in_addr> &a) const {
void nf_profile::get_nf_ipv4_addresses(std::vector<struct in_addr>& a) const {
a = ipv4_addresses;
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_services(const std::vector<nf_service_t> &n) {
nf_services = n;
}
//------------------------------------------------------------------------------
void smf_profile::add_nf_service(const nf_service_t &n) {
nf_services.push_back(n);
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_services(std::vector<nf_service_t> &n) const {
n = nf_services;
}
//------------------------------------------------------------------------------
void smf_profile::set_custom_info(const nlohmann::json &c) { custom_info = c; }
//------------------------------------------------------------------------------
void smf_profile::get_custom_info(nlohmann::json &c) const { c = custom_info; }
//------------------------------------------------------------------------------
void smf_profile::set_smf_info(const smf_info_t &s) { smf_info = s; }
//------------------------------------------------------------------------------
void smf_profile::add_smf_info_item(const snssai_smf_info_item_t &s) {
smf_info.snssai_smf_info_list.push_back(s);
}
//------------------------------------------------------------------------------
void smf_profile::get_smf_info(smf_info_t &s) const { s = smf_info; }
//------------------------------------------------------------------------------
void smf_profile::display() const {
void nf_profile::display() const {
Logger::smf_app().debug("NF instance info");
Logger::smf_app().debug("\tInstance ID: %s", nf_instance_id.c_str());
Logger::smf_app().debug("\tInstance name: %s", nf_instance_name.c_str());
......@@ -199,46 +190,21 @@ void smf_profile::display() const {
for (auto address : ipv4_addresses) {
Logger::smf_app().debug("\t\t %s", inet_ntoa(address));
}
// NF services
if (nf_services.size() > 0) {
Logger::smf_app().debug("\tNF Service");
}
for (auto service : nf_services) {
Logger::smf_app().debug("\t\t%s", service.to_string().c_str());
}
if (!custom_info.empty()) {
Logger::smf_app().debug("\tCustom info: %s", custom_info.dump().c_str());
}
// SMF info
if (smf_info.snssai_smf_info_list.size() > 0) {
Logger::smf_app().debug("\tSMF Info:");
}
for (auto s : smf_info.snssai_smf_info_list) {
Logger::smf_app().debug("\t\tParameters supported by the SMF:");
Logger::smf_app().debug("\t\t\tSNSSAI (SST %d, SD %s)", s.snssai.sST,
s.snssai.sD.c_str());
for (auto d : s.dnn_smf_info_list) {
Logger::smf_app().debug("\t\t\tDNN %s", d.dnn.c_str());
}
}
}
//------------------------------------------------------------------------------
void smf_profile::to_json(nlohmann::json &data) const {
data["nfInstanceId"] = nf_instance_id;
void nf_profile::to_json(nlohmann::json& data) const {
data["nfInstanceId"] = nf_instance_id;
data["nfInstanceName"] = nf_instance_name;
data["nfType"] = nf_type;
data["nfStatus"] = nf_status;
data["nfType"] = nf_type;
data["nfStatus"] = nf_status;
data["heartBeatTimer"] = heartBeat_timer;
// SNSSAIs
data["sNssais"] = nlohmann::json::array();
for (auto s : snssais) {
nlohmann::json tmp = {};
tmp["sst"] = s.sST;
tmp["sd"] = s.sD;
tmp["sst"] = s.sST;
tmp["sd"] = s.sD;
;
data["sNssais"].push_back(tmp);
}
......@@ -252,47 +218,11 @@ void smf_profile::to_json(nlohmann::json &data) const {
data["priority"] = priority;
data["capacity"] = capacity;
// NF services
data["nfServices"] = nlohmann::json::array();
for (auto service : nf_services) {
nlohmann::json srv_tmp = {};
srv_tmp["serviceInstanceId"] = service.service_instance_id;
srv_tmp["serviceName"] = service.service_name;
srv_tmp["versions"] = nlohmann::json::array();
for (auto v : service.versions) {
nlohmann::json v_tmp = {};
v_tmp["apiVersionInUri"] = v.api_version_in_uri;
v_tmp["apiFullVersion"] = v.api_full_version;
srv_tmp["versions"].push_back(v_tmp);
}
srv_tmp["scheme"] = service.scheme;
srv_tmp["nfServiceStatus"] = service.nf_service_status;
data["nfServices"].push_back(srv_tmp);
}
data["custom_info"] = custom_info;
// SMF info
data["smfInfo"] = {};
data["smfInfo"]["sNssaiSmfInfoList"] = nlohmann::json::array();
for (auto s : smf_info.snssai_smf_info_list) {
nlohmann::json tmp = {};
tmp["sNssai"]["sst"] = s.snssai.sST;
tmp["sNssai"]["sd"] = s.snssai.sD;
tmp["dnnSmfInfoList"] = nlohmann::json::array();
for (auto d : s.dnn_smf_info_list) {
nlohmann::json dnn_json = {};
dnn_json["dnn"] = d.dnn;
tmp["dnnSmfInfoList"].push_back(dnn_json);
}
data["smfInfo"]["sNssaiSmfInfoList"].push_back(tmp);
}
Logger::smf_app().debug("SMF profile to json:\n %s", data.dump().c_str());
// Logger::smf_app().debug("SMF profile to json:\n %s", data.dump().c_str());
}
//------------------------------------------------------------------------------
void smf_profile::from_json(const nlohmann::json &data) {
void nf_profile::from_json(const nlohmann::json& data) {
if (data.find("nfInstanceId") != data.end()) {
nf_instance_id = data["nfInstanceId"].get<std::string>();
}
......@@ -316,8 +246,8 @@ void smf_profile::from_json(const nlohmann::json &data) {
if (data.find("sNssais") != data.end()) {
for (auto it : data["sNssais"]) {
snssai_t s = {};
s.sST = it["sst"].get<int>();
s.sD = it["sd"].get<std::string>();
s.sST = it["sst"].get<int>();
s.sD = it["sd"].get<std::string>();
snssais.push_back(s);
// Logger::smf_app().debug("Added SNSSAI (SST %d, SD %s)", s.sST,
// s.sD.c_str());
......@@ -329,13 +259,13 @@ void smf_profile::from_json(const nlohmann::json &data) {
for (auto it : addresses) {
struct in_addr addr4 = {};
std::string address = it.get<std::string>();
std::string address = it.get<std::string>();
unsigned char buf_in_addr[sizeof(struct in_addr)];
if (inet_pton(AF_INET, util::trim(address).c_str(), buf_in_addr) == 1) {
memcpy(&addr4, buf_in_addr, sizeof(struct in_addr));
} else {
Logger::smf_app().warn("Address conversion: Bad value %s",
util::trim(address).c_str());
Logger::smf_app().warn(
"Address conversion: Bad value %s", util::trim(address).c_str());
}
// Logger::smf_app().debug("\tIPv4 Addr: %s", address.c_str());
add_nf_ipv4_addresses(addr4);
......@@ -349,6 +279,125 @@ void smf_profile::from_json(const nlohmann::json &data) {
if (data.find("capacity") != data.end()) {
capacity = data["capacity"].get<int>();
}
}
//------------------------------------------------------------------------------
void smf_profile::set_nf_services(const std::vector<nf_service_t>& n) {
nf_services = n;
}
//------------------------------------------------------------------------------
void smf_profile::add_nf_service(const nf_service_t& n) {
nf_services.push_back(n);
}
//------------------------------------------------------------------------------
void smf_profile::get_nf_services(std::vector<nf_service_t>& n) const {
n = nf_services;
}
//------------------------------------------------------------------------------
void smf_profile::set_custom_info(const nlohmann::json& c) {
custom_info = c;
}
//------------------------------------------------------------------------------
void smf_profile::get_custom_info(nlohmann::json& c) const {
c = custom_info;
}
//------------------------------------------------------------------------------
void smf_profile::set_smf_info(const smf_info_t& s) {
smf_info = s;
}
//------------------------------------------------------------------------------
void smf_profile::add_smf_info_item(const snssai_smf_info_item_t& s) {
smf_info.snssai_smf_info_list.push_back(s);
}
//------------------------------------------------------------------------------
void smf_profile::get_smf_info(smf_info_t& s) const {
s = smf_info;
}
//------------------------------------------------------------------------------
void smf_profile::display() const {
// display NF part
nf_profile::display();
// NF services
if (nf_services.size() > 0) {
Logger::smf_app().debug("\tNF Service");
}
for (auto service : nf_services) {
Logger::smf_app().debug("\t\t%s", service.to_string().c_str());
}
if (!custom_info.empty()) {
Logger::smf_app().debug("\tCustom info: %s", custom_info.dump().c_str());
}
// SMF info
if (smf_info.snssai_smf_info_list.size() > 0) {
Logger::smf_app().debug("\tSMF Info:");
}
for (auto s : smf_info.snssai_smf_info_list) {
Logger::smf_app().debug("\t\tParameters supported by the SMF:");
Logger::smf_app().debug(
"\t\t\tSNSSAI (SST %d, SD %s)", s.snssai.sST, s.snssai.sD.c_str());
for (auto d : s.dnn_smf_info_list) {
Logger::smf_app().debug("\t\t\tDNN %s", d.dnn.c_str());
}
}
}
//------------------------------------------------------------------------------
void smf_profile::to_json(nlohmann::json& data) const {
nf_profile::to_json(data);
// NF services
data["nfServices"] = nlohmann::json::array();
for (auto service : nf_services) {
nlohmann::json srv_tmp = {};
srv_tmp["serviceInstanceId"] = service.service_instance_id;
srv_tmp["serviceName"] = service.service_name;
srv_tmp["versions"] = nlohmann::json::array();
for (auto v : service.versions) {
nlohmann::json v_tmp = {};
v_tmp["apiVersionInUri"] = v.api_version_in_uri;
v_tmp["apiFullVersion"] = v.api_full_version;
srv_tmp["versions"].push_back(v_tmp);
}
srv_tmp["scheme"] = service.scheme;
srv_tmp["nfServiceStatus"] = service.nf_service_status;
data["nfServices"].push_back(srv_tmp);
}
data["custom_info"] = custom_info;
// SMF info
data["smfInfo"] = {};
data["smfInfo"]["sNssaiSmfInfoList"] = nlohmann::json::array();
for (auto s : smf_info.snssai_smf_info_list) {
nlohmann::json tmp = {};
tmp["sNssai"]["sst"] = s.snssai.sST;
tmp["sNssai"]["sd"] = s.snssai.sD;
tmp["dnnSmfInfoList"] = nlohmann::json::array();
for (auto d : s.dnn_smf_info_list) {
nlohmann::json dnn_json = {};
dnn_json["dnn"] = d.dnn;
tmp["dnnSmfInfoList"].push_back(dnn_json);
}
data["smfInfo"]["sNssaiSmfInfoList"].push_back(tmp);
}
Logger::smf_app().debug("SMF profile to json:\n %s", data.dump().c_str());
}
//------------------------------------------------------------------------------
void smf_profile::from_json(const nlohmann::json& data) {
nf_profile::from_json(data);
// TODO: custom_info;
......@@ -388,7 +437,97 @@ void smf_profile::from_json(const nlohmann::json &data) {
//------------------------------------------------------------------------------
void smf_profile::handle_heartbeart_timeout(uint64_t ms) {
Logger::smf_app().info("Handle heartbeart timeout profile %s, time %d",
nf_instance_id.c_str(), ms);
Logger::smf_app().info(
"Handle heartbeart timeout profile %s, time %d", nf_instance_id.c_str(),
ms);
set_nf_status("SUSPENDED");
}
//------------------------------------------------------------------------------
void upf_profile::add_upf_info_item(const snssai_upf_info_item_t& s) {
upf_info.snssai_upf_info_list.push_back(s);
}
//------------------------------------------------------------------------------
void upf_profile::get_upf_info(upf_info_t& s) const {
s = upf_info;
}
//------------------------------------------------------------------------------
void upf_profile::display() const {
// display NF part
nf_profile::display();
// UPF info
if (upf_info.snssai_upf_info_list.size() > 0) {
Logger::smf_app().debug("\tUPF Info:");
}
for (auto s : upf_info.snssai_upf_info_list) {
Logger::smf_app().debug("\t\tParameters supported by the UPF:");
Logger::smf_app().debug(
"\t\t\tSNSSAI (SST %d, SD %s)", s.snssai.sST, s.snssai.sD.c_str());
for (auto d : s.dnn_upf_info_list) {
Logger::smf_app().debug("\t\t\tDNN %s", d.dnn.c_str());
}
}
}
//------------------------------------------------------------------------------
void upf_profile::to_json(nlohmann::json& data) const {
nf_profile::to_json(data);
// UPF info
data["upfInfo"] = {};
data["upfInfo"]["sNssaiUpfInfoList"] = nlohmann::json::array();
for (auto s : upf_info.snssai_upf_info_list) {
nlohmann::json tmp = {};
tmp["sNssai"]["sst"] = s.snssai.sST;
tmp["sNssai"]["sd"] = s.snssai.sD;
tmp["dnnSmfInfoList"] = nlohmann::json::array();
for (auto d : s.dnn_upf_info_list) {
nlohmann::json dnn_json = {};
dnn_json["dnn"] = d.dnn;
tmp["dnnSmfInfoList"].push_back(dnn_json);
}
data["upfInfo"]["sNssaiUpfInfoList"].push_back(tmp);
}
Logger::smf_app().debug("UPF profile to json:\n %s", data.dump().c_str());
}
//------------------------------------------------------------------------------
void upf_profile::from_json(const nlohmann::json& data) {
nf_profile::from_json(data);
// UPF info
if (data.find("upfInfo") != data.end()) {
nlohmann::json info = data["upfInfo"];
dnn_upf_info_item_t dnn_item = {};
if (info.find("sNssaiUpfInfoList") != info.end()) {
nlohmann::json snssai_upf_info_list =
data["upfInfo"]["sNssaiUpfInfoList"];
for (auto it : snssai_upf_info_list) {
snssai_upf_info_item_t upf_info_item = {};
if (it.find("sNssai") != it.end()) {
if (it["sNssai"].find("sst") != it["sNssai"].end())
upf_info_item.snssai.sST = it["sNssai"]["sst"].get<int>();
if (it["sNssai"].find("sd") != it["sNssai"].end())
upf_info_item.snssai.sD = it["sNssai"]["sd"].get<std::string>();
}
if (it.find("dnnUpfInfoList") != it.end()) {
for (auto d : it["dnnUpfInfoList"]) {
if (d.find("dnn") != d.end()) {
dnn_item.dnn = d["dnn"].get<std::string>();
upf_info_item.dnn_upf_info_list.push_back(dnn_item);
}
}
}
upf_info.snssai_upf_info_list.push_back(upf_info_item);
}
}
}
display();
}
......@@ -45,10 +45,9 @@
namespace smf {
using namespace std;
class smf_profile : public std::enable_shared_from_this<smf_profile> {
class nf_profile : public std::enable_shared_from_this<nf_profile> {
public:
smf_profile()
nf_profile()
: nf_type("NF_TYPE_UNKNOWN"),
heartBeat_timer(0),
snssais(),
......@@ -56,11 +55,10 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
priority(0),
capacity(0) {
nf_instance_name = "";
nf_status = "";
custom_info = {};
nf_status = "";
}
smf_profile(const std::string &id)
nf_profile(const std::string& id)
: nf_instance_id(id),
heartBeat_timer(0),
snssais(),
......@@ -69,42 +67,34 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
capacity(0),
nf_type("NF_TYPE_UNKNOWN") {
nf_instance_name = "";
nf_status = "";
custom_info = {};
nf_status = "";
}
smf_profile &operator=(const smf_profile &s) {
nf_instance_id = s.nf_instance_id;
heartBeat_timer = s.heartBeat_timer;
snssais = s.snssais;
ipv4_addresses = s.ipv4_addresses;
priority = s.priority;
capacity = s.capacity;
nf_type = s.nf_type;
nf_profile& operator=(const nf_profile& s) {
nf_instance_id = s.nf_instance_id;
heartBeat_timer = s.heartBeat_timer;
snssais = s.snssais;
ipv4_addresses = s.ipv4_addresses;
priority = s.priority;
capacity = s.capacity;
nf_type = s.nf_type;
nf_instance_name = s.nf_instance_name;
nf_status = s.nf_status;
custom_info = s.custom_info;
smf_info = s.smf_info;
nf_services = s.nf_services;
}
// smf_profile(smf_profile &b) = delete;
virtual ~smf_profile() {
Logger::smf_app().debug("Delete SMF Profile instance...");
nf_status = s.nf_status;
}
// nf_profile(nf_profile &b) = delete;
/*
* Set NF instance ID
* @param [const std::string &] instance_id: instance id
* @return void
*/
void set_nf_instance_id(const std::string &instance_id);
void set_nf_instance_id(const std::string& instance_id);
/*
* Get NF instance ID
* @param [std::string &] instance_id: store instance id
* @return void:
*/
void get_nf_instance_id(std::string &instance_id) const;
void get_nf_instance_id(std::string& instance_id) const;
/*
* Get NF instance ID
......@@ -118,14 +108,14 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
* @param [const std::string &] instance_name: instance name
* @return void
*/
void set_nf_instance_name(const std::string &instance_name);
void set_nf_instance_name(const std::string& instance_name);
/*
* Get NF instance ID
* @param [std::string &] instance_name: store instance name
* @return void:
*/
void get_nf_instance_name(std::string &instance_name) const;
void get_nf_instance_name(std::string& instance_name) const;
/*
* Get NF instance name
......@@ -139,14 +129,14 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
* @param [const std::string &] status: instance status
* @return void
*/
void set_nf_status(const std::string &status);
void set_nf_status(const std::string& status);
/*
* Get NF instance status
* @param [std::string &] status: store instance status
* @return void:
*/
void get_nf_status(std::string &status) const;
void get_nf_status(std::string& status) const;
/*
* Get NF status
......@@ -167,21 +157,21 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
* @param [const nf_type_t &] type: nf type
* @return void
*/
void set_nf_type(const std::string &type);
void set_nf_type(const std::string& type);
/*
* Set NF instance heartBeat_timer
* @param [const std::string &] timer: heartBeat_timer
* @return void
*/
void set_nf_heartBeat_timer(const int32_t &timer);
void set_nf_heartBeat_timer(const int32_t& timer);
/*
* Get NF instance heartBeat_timer
* @param [std::string &] timer: store heartBeat_timer
* @return void:
*/
void get_nf_heartBeat_timer(int32_t &timer) const;
void get_nf_heartBeat_timer(int32_t& timer) const;
/*
* Get NF heartBeat_timer
......@@ -195,14 +185,14 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
* @param [const uint16_t] p: instance priority
* @return void
*/
void set_nf_priority(const uint16_t &p);
void set_nf_priority(const uint16_t& p);
/*
* Get NF instance priority
* @param [uint16_t] p: store instance priority
* @return void:
*/
void get_nf_priority(uint16_t &p) const;
void get_nf_priority(uint16_t& p) const;
/*
* Get NF instance priority
......@@ -216,14 +206,14 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
* @param [const uint16_t] c: instance capacity
* @return void
*/
void set_nf_capacity(const uint16_t &c);
void set_nf_capacity(const uint16_t& c);
/*
* Get NF instance priority
* @param [uint16_t ] c: store instance capacity
* @return void:
*/
void get_nf_capacity(uint16_t &c) const;
void get_nf_capacity(uint16_t& c) const;
/*
* Get NF instance priority
......@@ -237,98 +227,158 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
* @param [std::vector<snssai_t> &] s: SNSSAIs
* @return void
*/
void set_nf_snssais(const std::vector<snssai_t> &s);
void set_nf_snssais(const std::vector<snssai_t>& s);
/*
* Add SNSSAI
* @param [snssai_t &] s: SNSSAI
* @return void
*/
void add_snssai(const snssai_t &s);
void add_snssai(const snssai_t& s);
/*
* Get NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: store instance's SNSSAIs
* @return void:
*/
void get_nf_snssais(std::vector<snssai_t> &s) const;
void get_nf_snssais(std::vector<snssai_t>& s) const;
/*
* Set NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: ipv4_addresses
* @return void
*/
void set_nf_ipv4_addresses(const std::vector<struct in_addr> &a);
void set_nf_ipv4_addresses(const std::vector<struct in_addr>& a);
/*
* Add an IPv4 address to the list of addresses
* @param [const struct in_addr &] a: ipv4_address
* @return void
*/
void add_nf_ipv4_addresses(const struct in_addr &a);
void add_nf_ipv4_addresses(const struct in_addr& a);
/*
* Get NF instance ipv4_addresses
* @param [std::vector<struct in_addr> &] a: store instance's ipv4_addresses
* @return void:
*/
void get_nf_ipv4_addresses(std::vector<struct in_addr> &a) const;
void get_nf_ipv4_addresses(std::vector<struct in_addr>& a) const;
/*
* Print related-information for NF profile
* @param void
* @return void:
*/
virtual void display() const;
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
virtual void to_json(nlohmann::json& data) const;
/*
* Covert from a json represetation to SMF profile
* @param [nlohmann::json &] data: Json data
* @return void
*/
virtual void from_json(const nlohmann::json& data);
protected:
// From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06))
std::string nf_instance_id;
std::string nf_instance_name;
std::string nf_type;
std::string nf_status;
int32_t heartBeat_timer;
std::vector<snssai_t> snssais;
std::vector<struct in_addr> ipv4_addresses;
uint16_t priority;
uint16_t capacity;
};
class smf_profile : public nf_profile {
public:
smf_profile() : nf_profile() { custom_info = {}; }
smf_profile(const std::string& id) : nf_profile(id) { custom_info = {}; }
smf_profile& operator=(const smf_profile& s) {
nf_instance_id = s.nf_instance_id;
heartBeat_timer = s.heartBeat_timer;
snssais = s.snssais;
ipv4_addresses = s.ipv4_addresses;
priority = s.priority;
capacity = s.capacity;
nf_type = s.nf_type;
nf_instance_name = s.nf_instance_name;
nf_status = s.nf_status;
custom_info = s.custom_info;
smf_info = s.smf_info;
nf_services = s.nf_services;
}
// smf_profile(smf_profile &b) = delete;
virtual ~smf_profile() {
Logger::smf_app().debug("Delete SMF Profile instance...");
}
/*
* Set NF instance services
* @param [std::vector<nf_service_t> &] n: nf_service
* @return void
*/
void set_nf_services(const std::vector<nf_service_t> &n);
void set_nf_services(const std::vector<nf_service_t>& n);
/*
* Add nf service
* @param [snssai_t &] n: nf service
* @return void
*/
void add_nf_service(const nf_service_t &n);
void add_nf_service(const nf_service_t& n);
/*
* Get NF services
* @param [std::vector<snssai_t> &] n: store instance's nf services
* @return void:
*/
void get_nf_services(std::vector<nf_service_t> &n) const;
void get_nf_services(std::vector<nf_service_t>& n) const;
/*
* Set custom info
* @param [const nlohmann::json &] c: custom info to be set
* @return void
*/
void set_custom_info(const nlohmann::json &c);
void set_custom_info(const nlohmann::json& c);
/*
* Get custom info
* @param [nlohmann::json &] c: Store custom info
* @return void
*/
void get_custom_info(nlohmann::json &c) const;
void get_custom_info(nlohmann::json& c) const;
/*
* Set smf info
* @param [smf_info_t &] s: smf info
* @return void
*/
void set_smf_info(const smf_info_t &s);
void set_smf_info(const smf_info_t& s);
/*
* Add an snssai_smf_info_item to the smf info
* @param [const snssai_smf_info_item_t &] s: snssai_smf_info_item
* @return void
*/
void add_smf_info_item(const snssai_smf_info_item_t &s);
void add_smf_info_item(const snssai_smf_info_item_t& s);
/*
* Get NF instance smf info
* @param [smf_info_t &] s: store instance's smf info
* @return void:
*/
void get_smf_info(smf_info_t &s) const;
void get_smf_info(smf_info_t& s) const;
/*
* Print related-information for NF profile
......@@ -342,14 +392,14 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
* @param [nlohmann::json &] data: Json data
* @return void
*/
void to_json(nlohmann::json &data) const;
void to_json(nlohmann::json& data) const;
/*
* Covert from a json represetation to SMF profile
* @param [nlohmann::json &] data: Json data
* @return void
*/
void from_json(const nlohmann::json &data);
void from_json(const nlohmann::json& data);
/*
* Handle heartbeart timeout event
......@@ -359,21 +409,92 @@ class smf_profile : public std::enable_shared_from_this<smf_profile> {
void handle_heartbeart_timeout(uint64_t ms);
protected:
// From NFProfile (Section 6.1.6.2.2@3GPP TS 29.510 V16.0.0 (2019-06))
std::string nf_instance_id;
std::string nf_instance_name;
std::string nf_type;
std::string nf_status;
int32_t heartBeat_timer;
std::vector<snssai_t> snssais;
std::vector<struct in_addr> ipv4_addresses;
uint16_t priority;
uint16_t capacity;
std::vector<nf_service_t> nf_services;
nlohmann::json custom_info; // store extra json data
smf_info_t smf_info;
};
class upf_profile : public nf_profile {
public:
upf_profile() : nf_profile() { // custom_info = {};
}
upf_profile(const std::string& id) : nf_profile(id) { // custom_info = {};
}
upf_profile& operator=(const upf_profile& s) {
nf_instance_id = s.nf_instance_id;
heartBeat_timer = s.heartBeat_timer;
snssais = s.snssais;
ipv4_addresses = s.ipv4_addresses;
priority = s.priority;
capacity = s.capacity;
nf_type = s.nf_type;
nf_instance_name = s.nf_instance_name;
nf_status = s.nf_status;
// custom_info = s.custom_info;
upf_info = s.upf_info;
}
// upf_profile(upf_profile &b) = delete;
virtual ~upf_profile() {
Logger::smf_app().debug("Delete UPF Profile instance...");
}
/*
* Set upf info
* @param [upf_info_t &] s: upf info
* @return void
*/
void set_upf_info(const upf_info_t& s);
/*
* Add an snssai_upf_info_item to the upf info
* @param [const snssai_upf_info_item_t &] s: snssai_upf_info_item
* @return void
*/
void add_upf_info_item(const snssai_upf_info_item_t& s);
/*
* Get NF instance upf info
* @param [upf_info_t &] s: store instance's upf info
* @return void:
*/
void get_upf_info(upf_info_t& s) const;
/*
* Print related-information for NF profile
* @param void
* @return void:
*/
void display() const;
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
void to_json(nlohmann::json& data) const;
/*
* Covert from a json represetation to SMF profile
* @param [nlohmann::json &] data: Json data
* @return void
*/
void from_json(const nlohmann::json& data);
/*
* Handle heartbeart timeout event
* @param [uint64_t] ms: current time
* @return void
*/
void handle_heartbeart_timeout(uint64_t ms);
protected:
nlohmann::json custom_info; // store extra json data
upf_info_t upf_info;
};
} // namespace smf
#endif
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