Commit 8ee1e3e4 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

First version with NRF

parent e038bc57
......@@ -34,8 +34,8 @@ AMF_CONF[@SD_0@]='123'
AMF_CONF[@SST_1@]='1'
AMF_CONF[@SD_1@]='12'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]='ens3'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]='ens3'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_NGAP@]='wlo1'
AMF_CONF[@AMF_INTERFACE_NAME_FOR_N11@]='wlo1'
AMF_CONF[@SMF_INSTANCE_ID_0@]='1'
AMF_CONF[@SMF_IPV4_ADDR_0@]='192.168.122.1'
......@@ -43,7 +43,10 @@ AMF_CONF[@SMF_HTTP_VERSION_0@]='v1'
AMF_CONF[@SMF_INSTANCE_ID_1@]='2'
AMF_CONF[@SMF_IPV4_ADDR_1@]='192.168.122.2'
AMF_CONF[@SMF_HTTP_VERSION_1@]='v1'
AMF_CONF[@NRF_IPV4_ADDRESS@]='192.168.1.23'
AMF_CONF[@NRF_PORT@]='80'
AMF_CONF[@NRF_API_VERSION@]='v1'
AMF_CONF[@MYSQL_SERVER@]='127.0.0.1'
AMF_CONF[@MYSQL_USER@]='root'
......
......@@ -78,8 +78,14 @@ AMF =
{SMF_INSTANCE_ID = @SMF_INSTANCE_ID_1@; IPV4_ADDRESS = "@SMF_IPV4_ADDR_1@"; PORT = "80"; VERSION = "@SMF_HTTP_VERSION_1@"; SELECTED = "false"} # YOUR SMF CONFIG HERE
);
};
};
NRF :
{
IPV4_ADDRESS = "@NRF_IPV4_ADDRESS@"; # YOUR NRF CONFIG HERE
PORT = @NRF_PORT@; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "@NRF_API_VERSION@"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
};
};
AUTHENTICATION:
{
......
......@@ -78,6 +78,13 @@ AMF =
{SMF_INSTANCE_ID = 2; IPV4_ADDRESS = "192.168.122.2"; PORT = "80"; VERSION = "v1"; SELECTED = "false"} # YOUR SMF CONFIG HERE
);
};
NRF :
{
IPV4_ADDRESS = "192.168.12.100"; # YOUR NRF CONFIG HERE
PORT = 80; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "v1"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
};
};
......
......@@ -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)
......@@ -55,6 +55,7 @@ file(GLOB AMF_src_files
${CMAKE_CURRENT_SOURCE_DIR}/amf_n1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_n2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_n11.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_profile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/amf_statistics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mysql_db.cpp
${SRC_TOP_DIR}/nas/msgs/*.cpp
......
This diff is collapsed.
......@@ -34,8 +34,10 @@
#include <string>
#include "amf_config.hpp"
#include "amf_module_from_config.hpp"
#include "amf_profile.hpp"
#include "itti_msg_amf_app.hpp"
#include "ue_context.hpp"
#include "itti.hpp"
using namespace config;
......@@ -46,37 +48,78 @@ namespace amf_application {
#define TASK_AMF_APP_PERIODIC_STATISTICS (0)
class amf_app {
private:
amf_profile nf_instance_profile; // AMF profile
std::string amf_instance_id; // AMF instance id
timer_id_t timer_nrf_heartbeat;
public:
explicit amf_app(const amf_config &amf_cfg);
amf_app(amf_app const &) = delete;
void operator=(amf_app const &) = delete;
void allRegistredModulesInit(const amf_modules &modules);
explicit amf_app(const amf_config& amf_cfg);
amf_app(amf_app const&) = delete;
void operator=(amf_app const&) = delete;
void allRegistredModulesInit(const amf_modules& modules);
long generate_amf_ue_ngap_id();
// itti handlers
void handle_itti_message(itti_nas_signalling_establishment_request &itti_msg);
void handle_itti_message(itti_n1n2_message_transfer_request &itti_msg);
void handle_itti_message(itti_nas_signalling_establishment_request& itti_msg);
void handle_itti_message(itti_n1n2_message_transfer_request& itti_msg);
// context management
std::map<long, std::shared_ptr<ue_context>> amf_ue_ngap_id2ue_ctx;
mutable std::shared_mutex m_amf_ue_ngap_id2ue_ctx;
std::map<std::string, std::shared_ptr<ue_context>> ue_ctx_key;
mutable std::shared_mutex m_ue_ctx_key;
bool is_amf_ue_id_2_ue_context(const long &amf_ue_ngap_id) const;
bool is_amf_ue_id_2_ue_context(const long& amf_ue_ngap_id) const;
std::shared_ptr<ue_context> amf_ue_id_2_ue_context(
const long &amf_ue_ngap_id) const;
void set_amf_ue_ngap_id_2_ue_context(const long &amf_ue_ngap_id,
std::shared_ptr<ue_context> uc);
const long& amf_ue_ngap_id) const;
void set_amf_ue_ngap_id_2_ue_context(
const long& amf_ue_ngap_id, std::shared_ptr<ue_context> uc);
bool is_ran_amf_id_2_ue_context(const std::string &ue_context_key) const;
bool is_ran_amf_id_2_ue_context(const std::string& ue_context_key) const;
std::shared_ptr<ue_context> ran_amf_id_2_ue_context(
const std::string &ue_context_key) const;
void set_ran_amf_id_2_ue_context(const std::string &ue_context_key,
std::shared_ptr<ue_context> uc);
const std::string& ue_context_key) const;
void set_ran_amf_id_2_ue_context(
const std::string& ue_context_key, std::shared_ptr<ue_context> uc);
// SMF Client response handlers
void handle_post_sm_context_response_error_400();
// others
bool generate_5g_guti(uint32_t ranid, long amfid, std::string &mcc,
std::string &mnc, uint32_t &tmsi);
bool generate_5g_guti(
uint32_t ranid, long amfid, std::string& mcc, std::string& mnc,
uint32_t& tmsi);
/*
* Trigger NF instance registration to NRF
* @param [void]
* @return void
*/
void register_to_nrf();
/*
* Generate a random UUID for SMF instance
* @param [void]
* @return void
*/
void generate_uuid();
/*
* Generate a SMF profile for this instance
* @param [void]
* @return void
*/
void generate_amf_profile();
/*
* Send request to N11 task to trigger NF instance registration to NRF
* @param [void]
* @return void
*/
void trigger_nf_registration_request();
/*
* Send request to N11 task to trigger NF instance deregistration to NRF
* @param [void]
* @return void
*/
void trigger_nf_deregistration();
};
} // namespace amf_application
......
This diff is collapsed.
......@@ -39,55 +39,62 @@
#include <string>
#include "thread_sched.hpp"
#define AMF_CONFIG_STRING_AMF_CONFIG "AMF"
#define AMF_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY"
#define AMF_CONFIG_STRING_INSTANCE_ID "INSTANCE_ID"
#define AMF_CONFIG_STRING_STATISTICS_TIMER_INTERVAL "STATISTICS_TIMER_INTERVAL"
#define AMF_CONFIG_STRING_INTERFACES "INTERFACES"
#define AMF_CONFIG_STRING_INTERFACE_NGAP_AMF "NGAP_AMF"
#define AMF_CONFIG_STRING_INTERFACE_NAME "INTERFACE_NAME"
#define AMF_CONFIG_STRING_IPV4_ADDRESS "IPV4_ADDRESS"
#define AMF_CONFIG_STRING_PORT "PORT"
#define AMF_CONFIG_STRING_PPID "PPID"
#define AMF_CONFIG_STRING_INTERFACE_N11 "N11"
#define AMF_CONFIG_STRING_SMF_INSTANCES_POOL "SMF_INSTANCES_POOL"
#define AMF_CONFIG_STRING_SMF_INSTANCE_ID "SMF_INSTANCE_ID"
#define AMF_CONFIG_STRING_SMF_INSTANCE_PORT "PORT"
#define AMF_CONFIG_STRING_SMF_INSTANCE_VERSION "VERSION"
#define AMF_CONFIG_STRING_SMF_INSTANCE_SELECTED "SELECTED"
#define AMF_CONFIG_STRING_SCHED_PARAMS "SCHED_PARAMS"
#define AMF_CONFIG_STRING_THREAD_RD_CPU_ID "CPU_ID"
#define AMF_CONFIG_STRING_THREAD_RD_SCHED_POLICY "SCHED_POLICY"
#define AMF_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY "SCHED_PRIORITY"
#define AMF_CONFIG_STRING_AMF_NAME "AMF_NAME"
#define AMF_CONFIG_STRING_GUAMI "GUAMI"
#define AMF_CONFIG_STRING_SERVED_GUAMI_LIST "SERVED_GUAMI_LIST"
#define AMF_CONFIG_STRING_TAC "TAC"
#define AMF_CONFIG_STRING_MCC "MCC"
#define AMF_CONFIG_STRING_MNC "MNC"
#define AMF_CONFIG_STRING_RegionID "RegionID"
#define AMF_CONFIG_STRING_AMFSetID "AMFSetID"
#define AMF_CONFIG_STRING_AMFPointer "AMFPointer"
#define AMF_CONFIG_STRING_RELATIVE_AMF_CAPACITY "RELATIVE_CAPACITY"
#define AMF_CONFIG_STRING_PLMN_SUPPORT_LIST "PLMN_SUPPORT_LIST"
#define AMF_CONFIG_STRING_SLICE_SUPPORT_LIST "SLICE_SUPPORT_LIST"
#define AMF_CONFIG_STRING_SST "SST"
#define AMF_CONFIG_STRING_SD "SD"
#define AMF_CONFIG_STRING_CORE_CONFIGURATION "CORE_CONFIGURATION"
#define AMF_CONFIG_STRING_EMERGENCY_SUPPORT "EMERGENCY_SUPPORT"
#define AMF_CONFIG_STRING_AUTHENTICATION "AUTHENTICATION"
#define AMF_CONFIG_STRING_AUTH_MYSQL_SERVER "MYSQL_server"
#define AMF_CONFIG_STRING_AUTH_MYSQL_USER "MYSQL_user"
#define AMF_CONFIG_STRING_AUTH_MYSQL_PASS "MYSQL_pass"
#define AMF_CONFIG_STRING_AUTH_MYSQL_DB "MYSQL_db"
#define AMF_CONFIG_STRING_AUTH_OPERATOR_KEY "OPERATOR_key"
#define AMF_CONFIG_STRING_AUTH_RANDOM "RANDOM"
#define AMF_CONFIG_STRING_NAS "NAS"
#define AMF_CONFIG_STRING_NAS_SUPPORTED_INTEGRITY_ALGORITHM_LIST "ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST"
#define AMF_CONFIG_STRING_NAS_SUPPORTED_CIPHERING_ALGORITHM_LIST "ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST"
#define AMF_CONFIG_STRING_AMF_CONFIG "AMF"
#define AMF_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY"
#define AMF_CONFIG_STRING_INSTANCE_ID "INSTANCE_ID"
#define AMF_CONFIG_STRING_STATISTICS_TIMER_INTERVAL "STATISTICS_TIMER_INTERVAL"
#define AMF_CONFIG_STRING_INTERFACES "INTERFACES"
#define AMF_CONFIG_STRING_INTERFACE_NGAP_AMF "NGAP_AMF"
#define AMF_CONFIG_STRING_INTERFACE_NAME "INTERFACE_NAME"
#define AMF_CONFIG_STRING_IPV4_ADDRESS "IPV4_ADDRESS"
#define AMF_CONFIG_STRING_PORT "PORT"
#define AMF_CONFIG_STRING_PPID "PPID"
#define AMF_CONFIG_STRING_INTERFACE_N11 "N11"
#define AMF_CONFIG_STRING_SMF_INSTANCES_POOL "SMF_INSTANCES_POOL"
#define AMF_CONFIG_STRING_SMF_INSTANCE_ID "SMF_INSTANCE_ID"
#define AMF_CONFIG_STRING_SMF_INSTANCE_PORT "PORT"
#define AMF_CONFIG_STRING_SMF_INSTANCE_VERSION "VERSION"
#define AMF_CONFIG_STRING_SMF_INSTANCE_SELECTED "SELECTED"
#define AMF_CONFIG_STRING_NRF "NRF"
#define AMF_CONFIG_STRING_NRF_IPV4_ADDRESS "IPV4_ADDRESS"
#define AMF_CONFIG_STRING_NRF_PORT "PORT"
#define AMF_CONFIG_STRING_API_VERSION "API_VERSION"
#define AMF_CONFIG_STRING_SCHED_PARAMS "SCHED_PARAMS"
#define AMF_CONFIG_STRING_THREAD_RD_CPU_ID "CPU_ID"
#define AMF_CONFIG_STRING_THREAD_RD_SCHED_POLICY "SCHED_POLICY"
#define AMF_CONFIG_STRING_THREAD_RD_SCHED_PRIORITY "SCHED_PRIORITY"
#define AMF_CONFIG_STRING_AMF_NAME "AMF_NAME"
#define AMF_CONFIG_STRING_GUAMI "GUAMI"
#define AMF_CONFIG_STRING_SERVED_GUAMI_LIST "SERVED_GUAMI_LIST"
#define AMF_CONFIG_STRING_TAC "TAC"
#define AMF_CONFIG_STRING_MCC "MCC"
#define AMF_CONFIG_STRING_MNC "MNC"
#define AMF_CONFIG_STRING_RegionID "RegionID"
#define AMF_CONFIG_STRING_AMFSetID "AMFSetID"
#define AMF_CONFIG_STRING_AMFPointer "AMFPointer"
#define AMF_CONFIG_STRING_RELATIVE_AMF_CAPACITY "RELATIVE_CAPACITY"
#define AMF_CONFIG_STRING_PLMN_SUPPORT_LIST "PLMN_SUPPORT_LIST"
#define AMF_CONFIG_STRING_SLICE_SUPPORT_LIST "SLICE_SUPPORT_LIST"
#define AMF_CONFIG_STRING_SST "SST"
#define AMF_CONFIG_STRING_SD "SD"
#define AMF_CONFIG_STRING_CORE_CONFIGURATION "CORE_CONFIGURATION"
#define AMF_CONFIG_STRING_EMERGENCY_SUPPORT "EMERGENCY_SUPPORT"
#define AMF_CONFIG_STRING_AUTHENTICATION "AUTHENTICATION"
#define AMF_CONFIG_STRING_AUTH_MYSQL_SERVER "MYSQL_server"
#define AMF_CONFIG_STRING_AUTH_MYSQL_USER "MYSQL_user"
#define AMF_CONFIG_STRING_AUTH_MYSQL_PASS "MYSQL_pass"
#define AMF_CONFIG_STRING_AUTH_MYSQL_DB "MYSQL_db"
#define AMF_CONFIG_STRING_AUTH_OPERATOR_KEY "OPERATOR_key"
#define AMF_CONFIG_STRING_AUTH_RANDOM "RANDOM"
#define AMF_CONFIG_STRING_NAS "NAS"
#define AMF_CONFIG_STRING_NAS_SUPPORTED_INTEGRITY_ALGORITHM_LIST \
"ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST"
#define AMF_CONFIG_STRING_NAS_SUPPORTED_CIPHERING_ALGORITHM_LIST \
"ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST"
using namespace libconfig;
......@@ -157,11 +164,11 @@ class amf_config {
public:
amf_config();
~amf_config();
int load(const std::string &config_file);
int load_interface(const Setting &if_cfg, interface_cfg_t &cfg);
int load(const std::string& config_file);
int load_interface(const Setting& if_cfg, interface_cfg_t& cfg);
int load_thread_sched_params(
const libconfig::Setting &thread_sched_params_cfg,
util::thread_sched_params &cfg);
const libconfig::Setting& thread_sched_params_cfg,
util::thread_sched_params& cfg);
void display();
unsigned int instance;
std::string pid_dir;
......@@ -178,6 +185,12 @@ class amf_config {
auth_conf auth_para;
nas_conf_t nas_cfg;
std::vector<smf_inst_t> smf_pool;
struct {
struct in_addr ipv4_addr;
unsigned int port;
std::string api_version;
} nrf_addr;
};
} // namespace config
......
This diff is collapsed.
......@@ -43,13 +43,13 @@ class amf_n11 {
amf_n11();
~amf_n11();
void handle_itti_message(itti_smf_services_consumer &);
void handle_itti_message(itti_smf_services_consumer&);
void handle_pdu_session_initial_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, bstring sm_msg, std::string dnn);
void handle_itti_message(itti_nsmf_pdusession_update_sm_context &itti_msg);
void handle_itti_message(itti_nsmf_pdusession_release_sm_context &itti_msg);
void handle_itti_message(itti_pdu_session_resource_setup_response &itti_msg);
void handle_itti_message(itti_nsmf_pdusession_update_sm_context& itti_msg);
void handle_itti_message(itti_nsmf_pdusession_release_sm_context& itti_msg);
void handle_itti_message(itti_pdu_session_resource_setup_response& itti_msg);
void send_pdu_session_update_sm_context_request(
std::string supi, std::shared_ptr<pdu_session_context> psc,
std::string smf_addr, bstring sm_msg, std::string dnn);
......@@ -57,23 +57,27 @@ class amf_n11 {
std::map<std::string, std::shared_ptr<pdu_session_context>>
supi2pdu; // amf ue ngap id
mutable std::shared_mutex m_supi2pdu;
bool is_supi_to_pdu_ctx(const std::string &supi) const;
bool is_supi_to_pdu_ctx(const std::string& supi) const;
std::shared_ptr<pdu_session_context> supi_to_pdu_ctx(
const std::string &supi) const;
void set_supi_to_pdu_ctx(const std::string &supi,
std::shared_ptr<pdu_session_context> psc);
const std::string& supi) const;
void set_supi_to_pdu_ctx(
const std::string& supi, std::shared_ptr<pdu_session_context> psc);
std::map<uint8_t, std::string> pduid2supi;
bool smf_selection_from_configuration(std::string &smf_addr);
bool smf_selection_from_context(std::string &smf_addr);
bool smf_selection_from_configuration(std::string& smf_addr);
bool smf_selection_from_context(std::string& smf_addr);
void handle_post_sm_context_response_error_400();
void handle_post_sm_context_response_error(long code, std::string cause,
bstring n1sm, std::string supi,
uint8_t pdu_session_id);
void handle_post_sm_context_response_error(
long code, std::string cause, bstring n1sm, std::string supi,
uint8_t pdu_session_id);
void curl_http_client(std::string remoteUri, std::string jsonData,
std::string n1SmMsg, std::string n2SmMsg,
std::string supi, uint8_t pdu_session_id);
void curl_http_client(
std::string remoteUri, std::string jsonData, std::string n1SmMsg,
std::string n2SmMsg, std::string supi, uint8_t pdu_session_id);
bool discover_smf(
std::string& smf_addr, const snssai_t snssai, const plmn_t plmn,
const std::string dnn);
};
} // namespace amf_application
......
This diff is collapsed.
This diff is collapsed.
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* 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
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file 3gpp_23.003.h
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_3GPP_23_003_SEEN
#define FILE_3GPP_23_003_SEEN
#include <stdint.h>
#include <string>
typedef struct s_nssai // section 28.4, TS23.003
{
uint8_t sST;
//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 {
if ((s.sST == this->sST) && (s.sD.compare(this->sD) == 0)) {
return true;
} else {
return false;
}
}
} snssai_t;
typedef struct plmn_s {
std::string mcc;
std::string mnc;
} plmn_t;
#define INVALID_TAC_0000 (uint16_t)0x0000
#define INVALID_TAC_FFFE (uint16_t)0xFFFE
#define INVALID_TAC (uint32_t)0x00000000
#define INVALID_TMSI UINT32_MAX /*!< \brief The network shall not allocate a TMSI with all 32 bits equal to 1
(this is because the TMSI must be stored in the SIM, and the SIM uses 4 octets with all bits
equal to 1 to indicate that no valid TMSI is available). */
typedef uint16_t tac_t;
typedef struct tai_s {
plmn_t plmn; /*!< \brief <MCC> + <MNC> */
tac_t tac; /*!< \brief Tracking Area Code */
} tai_t;
typedef struct eci_s {
uint32_t gnb_id :20;
uint32_t cell_id :8;
uint32_t empty :4;
} ci_t;
typedef struct cgi_s {
plmn_t plmn;
ci_t cell_identity; //28 bits
} cgi_t;
typedef struct nr_tai_s /*5G ADD it*/
{
plmn_t plmn;
uint32_t tac :24;
} nr_tai_t;
typedef struct nr_cell_identity_s /*5G ADD it */
{
uint32_t gnb_id;
uint8_t cell_id :4;
} nr_cell_identity_t;
typedef struct nr_cgi_s /*5G ADD it */
{
plmn_t plmn;
nr_cell_identity_t cell_identity;
} nr_cgi_t;
typedef struct fiveG_s_tmsi_s /*5G ADD it */
{
uint16_t amf_set_id :10;
uint8_t amf_pointer :6;
uint32_t fiveG_s_tmsi; //32
} fiveG_s_tmsi_t;
typedef struct fiveG_s_gua_s /*5G ADD it */
{
plmn_t plmn;
uint8_t region_id;
uint16_t amf_set_id :10;
uint8_t amf_pointer :6;
} fiveG_s_gua_t;
typedef struct amf_set_id_s /*5G ADD it*/
{
uint16_t amf_set_id :10;
} amf_set_id_t;
typedef struct allowed_nssai /*5G ADD it*/
{
uint8_t sST;
uint32_t sD :24;
} allowed_nssai;
typedef struct allowed_nssai_s /*5G ADD it*/
{
allowed_nssai *s_nssai;
uint32_t count;
} allowed_nssai_t;
typedef struct guami_5g_s {
plmn_t plmn;
std::string amf_id;
} guami_5g_t;
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* 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
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef FILE_3GPP_29_510_NRF_SEEN
#define FILE_3GPP_29_510_NRF_SEEN
#include <vector>
#include "3gpp_23.003.h"
enum class nf_status_e { REGISTERED = 0, SUSPENDED = 1, UNDISCOVERABLE = 2 };
static const std::vector<std::string> nf_status_e2str = {
"REGISTERED", "SUSPENDED", "UNDISCOVERABLE"};
typedef struct amf_info_s {
std::string amf_set_id;
std::string amf_region_id;
std::vector<guami_5g_t> guami_list;
} amf_info_t;
typedef struct dnn_smf_info_item_s {
std::string dnn;
} dnn_smf_info_item_t;
typedef struct snssai_smf_info_item_s {
snssai_t snssai;
std::vector<dnn_smf_info_item_t> dnn_smf_info_list;
} snssai_smf_info_item_t;
typedef struct smf_info_s {
std::vector<snssai_smf_info_item_t> snssai_smf_info_list;
} smf_info_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;
enum subscr_condition_type_e { // TODO: use enum class
UNKNOWN_CONDITION = 0,
NF_INSTANCE_ID_COND = 1,
NF_TYPE_COND = 2,
SERVICE_NAME_COND = 3,
AMF_COND = 4,
GUAMI_LIST_COND = 5,
NETWOTK_SLICE_COND = 6,
NF_GROUP_COND = 7
};
static const std::vector<std::string> subscription_condition_type_e2str = {
"UNKNOWN_CONDITION", "NF_INSTANCE_ID_COND",
"NF_TYPE_COND", "SERVICE_NAME_COND",
"AMF_COND", "GUAMI_LIST_COND",
"NETWOTK_SLICE_COND", "NF_GROUP_COND"};
typedef struct amf_cond_s {
std::string amf_set_id;
std::string amf_region_id;
} amf_cond_t;
typedef struct network_slice_cond_s {
std::vector<snssai_t> snssai_list;
std::vector<std::string> nsi_list;
} network_slice_cond_t;
typedef struct nf_group_cond_s {
std::string nf_type;
std::string nf_group_id;
} nf_group_cond_t;
typedef struct subscription_condition_s {
uint8_t type;
union {
std::string nf_instance_id;
std::string nf_type;
std::string service_name;
amf_cond_t amf_info;
std::vector<guami_5g_t> guami_list;
network_slice_cond_t network_slice;
nf_group_cond_t nf_group;
};
subscription_condition_s() : type(0), nf_instance_id() {}
subscription_condition_s(uint8_t t) : type(t) {}
subscription_condition_s(const subscription_condition_s& s)
: subscription_condition_s() {
type = s.type;
switch (s.type) {
case NF_INSTANCE_ID_COND: {
nf_instance_id = s.nf_instance_id;
} break;
case NF_TYPE_COND: {
nf_type = s.nf_type;
} break;
case SERVICE_NAME_COND: {
service_name = s.service_name;
} break;
case AMF_COND: {
amf_info.amf_set_id = s.amf_info.amf_set_id;
amf_info.amf_region_id = s.amf_info.amf_region_id;
} break;
case GUAMI_LIST_COND: {
// TODO:
} break;
case NETWOTK_SLICE_COND: {
// TODO:
} break;
case NF_GROUP_COND: {
// TODO:
} break;
default: {
// TODO:
}
}
// TODO:
}
bool operator==(const struct subscription_condition_s& s) const {
return (s.type == type);
}
bool operator==(const uint8_t& t) const { return (t == type); }
subscription_condition_s& operator=(const subscription_condition_s& s) {
type = s.type;
switch (s.type) {
case NF_INSTANCE_ID_COND: {
nf_instance_id = s.nf_instance_id;
} break;
case NF_TYPE_COND: {
nf_type = s.nf_type;
} break;
case SERVICE_NAME_COND: {
service_name = s.service_name;
} break;
case AMF_COND: {
amf_info.amf_set_id = s.amf_info.amf_set_id;
amf_info.amf_region_id = s.amf_info.amf_region_id;
} break;
case GUAMI_LIST_COND: {
// TODO:
} break;
case NETWOTK_SLICE_COND: {
// TODO:
} break;
case NF_GROUP_COND: {
// TODO:
} break;
default: {
// TODO:
}
}
// TODO:
}
virtual ~subscription_condition_s(){};
std::string to_string() const {
std::string s = {};
s.append("Type: ");
s.append(subscription_condition_type_e2str[type]);
s.append(", condition: ");
switch (type) {
case NF_INSTANCE_ID_COND: {
s.append(nf_instance_id);
} break;
case NF_TYPE_COND: {
s.append(nf_type);
} break;
case SERVICE_NAME_COND: {
s.append(service_name);
} break;
case AMF_COND: {
s.append(", AMF_Set_ID: ");
s.append(amf_info.amf_set_id);
s.append(", AMF_Region_ID: ");
s.append(amf_info.amf_region_id);
} break;
case GUAMI_LIST_COND: {
// TODO:
} break;
case NETWOTK_SLICE_COND: {
// TODO:
} break;
case NF_GROUP_COND: {
// TODO:
} break;
default: {
// TODO:
}
}
// TODO:
return s;
}
} subscription_condition_t;
enum notification_event_type_t {
NOTIFICATION_TYPE_UNKNOWN_EVENT = 0,
NOTIFICATION_TYPE_NF_REGISTERED = 1,
NOTIFICATION_TYPE_NF_DEREGISTERED = 2,
NOTIFICATION_TYPE_NF_PROFILE_CHANGED = 3
};
static const std::vector<std::string> notification_event_type_e2str = {
"UNKNOWN EVENT", "NF_REGISTERED", "NF_DEREGISTERED", "NF_PROFILE_CHANGED"};
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) {
api_version_in_uri = s.api_version_in_uri;
api_full_version = s.api_full_version;
}
std::string to_string() const {
std::string s = {};
s.append(", Version (");
s.append("apiVersionInUri: ");
s.append(api_version_in_uri);
s.append(", apiFullVersion: ");
s.append(api_full_version);
s.append(" )");
return s;
}
} nf_service_version_t;
typedef struct ip_endpoint_s {
std::vector<struct in_addr> ipv4_addresses;
// std::vector<struct in6_addr> ipv6_addresses;
std::string transport; // TCP
unsigned int port;
std::string to_string() const {
std::string s = {};
s.append("Ipv4 Addresses: ");
for (auto ipv4 : ipv4_addresses) {
s.append(inet_ntoa(ipv4));
}
s.append(", TransportProtocol: ");
s.append(transport);
s.append(", Port: ");
s.append(std::to_string(port));
return s;
}
} ip_endpoint_t;
typedef struct nf_service_s {
std::string service_instance_id;
std::string service_name;
std::vector<nf_service_version_t> versions;
std::string scheme;
std::string nf_service_status;
std::vector<ip_endpoint_t> ip_endpoints;
std::string to_string() const {
std::string s = {};
s.append("Service Instance ID: ");
s.append(service_instance_id);
s.append(", Service name: ");
s.append(service_name);
for (auto v : versions) {
s.append(v.to_string());
}
s.append(", Scheme: ");
s.append(scheme);
s.append(", Service status: ");
s.append(nf_service_status);
s.append(", IpEndPoints: ");
for (auto endpoint : ip_endpoints) {
s.append(endpoint.to_string());
}
return s;
}
} nf_service_t;
#endif
......@@ -28,6 +28,8 @@
#ifndef __AMF_HPP
#define __AMF_HPP
#include "3gpp_23.003.h"
/*
typedef struct {
std::string mcc;
std::string mnc;
......@@ -63,6 +65,7 @@ typedef struct s_nssai // section 28.4, TS23.003
}
} snssai_t;
*/
//SMF + AMF + 3GPP TS 29.571 (Common data)
enum class http_response_codes_e {
......@@ -96,6 +99,7 @@ enum class http_response_codes_e {
#define SMF_CURL_TIMEOUT_MS 100L
#define SMF_NUMBER_RETRIES 3
constexpr auto CURL_MIME_BOUNDARY = "----Boundary";
#define NRF_CURL_TIMEOUT_MS 100L
#define BUFFER_SIZE_1024 1024
#define BUFFER_SIZE_512 512
......
......@@ -75,6 +75,11 @@ typedef enum {
N1N2_MESSAGE_TRANSFER_REQ,
SMF_SERVICES_CONSUMER,
NSMF_PDU_SESSION_UPDATE_SM_CTX,
N11_REGISTER_NF_INSTANCE_REQUEST,
N11_REGISTER_NF_INSTANCE_RESPONSE,
N11_UPDATE_NF_INSTANCE_REQUEST,
N11_UPDATE_NF_INSTANCE_RESPONSE,
N11_DEREGISTER_NF_INSTANCE,
UE_CONTEXT_RELEASE_COMMAND,
NSMF_PDU_SESS_RELEASE_SMCTX,
HANDOVER_REQUIRED,
......
......@@ -5,17 +5,15 @@
#include "itti_msg.hpp"
#include <string>
#include "amf.hpp"
#include "amf_profile.hpp"
class itti_msg_n11 : public itti_msg {
public:
itti_msg_n11(const itti_msg_type_t msg_type, const task_id_t origin,
const task_id_t destination)
:
itti_msg(msg_type, origin, destination) {
}
itti_msg_n11(const itti_msg_n11 &i)
:
itti_msg(i) {
itti_msg_n11(
const itti_msg_type_t msg_type, const task_id_t origin,
const task_id_t destination)
: itti_msg(msg_type, origin, destination) {}
itti_msg_n11(const itti_msg_n11& i) : itti_msg(i) {
ran_ue_ngap_id = i.ran_ue_ngap_id;
amf_ue_ngap_id = i.amf_ue_ngap_id;
}
......@@ -23,20 +21,16 @@ class itti_msg_n11 : public itti_msg {
public:
long amf_ue_ngap_id;
uint32_t ran_ue_ngap_id;
};
class itti_smf_services_consumer : public itti_msg_n11 {
public:
itti_smf_services_consumer(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n11(SMF_SERVICES_CONSUMER, origin, destination) {
}
itti_smf_services_consumer(const itti_smf_services_consumer &i)
:
itti_msg_n11(i) {
}
itti_smf_services_consumer(
const task_id_t origin, const task_id_t destination)
: itti_msg_n11(SMF_SERVICES_CONSUMER, origin, destination) {}
itti_smf_services_consumer(const itti_smf_services_consumer& i)
: itti_msg_n11(i) {}
public:
uint8_t req_type;
uint8_t pdu_sess_id;
......@@ -46,32 +40,33 @@ class itti_smf_services_consumer : public itti_msg_n11 {
plmn_t plmn;
};
class itti_pdu_session_resource_setup_response : public itti_msg_n11{
public:
itti_pdu_session_resource_setup_response(const task_id_t origin, const task_id_t destination) : itti_msg_n11(PDU_SESS_RES_SET_RESP, origin, destination){}
itti_pdu_session_resource_setup_response(const itti_pdu_session_resource_setup_response &i) : itti_msg_n11(i){}
public:
class itti_pdu_session_resource_setup_response : public itti_msg_n11 {
public:
itti_pdu_session_resource_setup_response(
const task_id_t origin, const task_id_t destination)
: itti_msg_n11(PDU_SESS_RES_SET_RESP, origin, destination) {}
itti_pdu_session_resource_setup_response(
const itti_pdu_session_resource_setup_response& i)
: itti_msg_n11(i) {}
public:
uint8_t pdu_session_id;
bstring n2sm;
};
class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
public:
itti_nsmf_pdusession_update_sm_context(const task_id_t origin,
const task_id_t destination)
:
itti_msg_n11(NSMF_PDU_SESSION_UPDATE_SM_CTX, origin, destination) {
itti_nsmf_pdusession_update_sm_context(
const task_id_t origin, const task_id_t destination)
: itti_msg_n11(NSMF_PDU_SESSION_UPDATE_SM_CTX, origin, destination) {
is_n2sm_set = false;
}
itti_nsmf_pdusession_update_sm_context(
const itti_nsmf_pdusession_update_sm_context &i)
:
itti_msg_n11(i) {
const itti_nsmf_pdusession_update_sm_context& i)
: itti_msg_n11(i) {
pdu_session_id = i.pdu_session_id;
n2sm = i.n2sm;
is_n2sm_set = i.is_n2sm_set;
n2sm = i.n2sm;
is_n2sm_set = i.is_n2sm_set;
n2sm_info_type = i.n2sm_info_type;
}
......@@ -81,17 +76,85 @@ class itti_nsmf_pdusession_update_sm_context : public itti_msg_n11 {
bstring n2sm;
bool is_n2sm_set;
std::string n2sm_info_type;
};
class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11
{
public:
itti_nsmf_pdusession_release_sm_context(const task_id_t origin, const task_id_t destination) : itti_msg_n11(NSMF_PDU_SESS_RELEASE_SMCTX, origin, destination) {}
itti_nsmf_pdusession_release_sm_context(const itti_nsmf_pdusession_update_sm_context &i) : itti_msg_n11(i) {}
class itti_nsmf_pdusession_release_sm_context : public itti_msg_n11 {
public:
itti_nsmf_pdusession_release_sm_context(
const task_id_t origin, const task_id_t destination)
: itti_msg_n11(NSMF_PDU_SESS_RELEASE_SMCTX, origin, destination) {}
itti_nsmf_pdusession_release_sm_context(
const itti_nsmf_pdusession_update_sm_context& i)
: itti_msg_n11(i) {}
public:
public:
std::string supi;
};
//-----------------------------------------------------------------------------
class itti_n11_register_nf_instance_request : public itti_msg_n11 {
public:
itti_n11_register_nf_instance_request(
const task_id_t orig, const task_id_t dest)
: itti_msg_n11(N11_REGISTER_NF_INSTANCE_REQUEST, orig, dest),
http_version(1) {}
const char* get_msg_name() { return "N11_REGISTER_NF_INSTANCE_REQUEST"; };
amf_application::amf_profile profile;
uint8_t http_version;
};
//-----------------------------------------------------------------------------
class itti_n11_register_nf_instance_response : public itti_msg_n11 {
public:
itti_n11_register_nf_instance_response(
const task_id_t orig, const task_id_t dest)
: itti_msg_n11(N11_REGISTER_NF_INSTANCE_RESPONSE, orig, dest),
http_version(1) {}
const char* get_msg_name() { return "N11_REGISTER_NF_INSTANCE_RESPONSE"; };
amf_application::amf_profile profile;
uint8_t http_version;
uint8_t http_response_code;
};
//-----------------------------------------------------------------------------
class itti_n11_update_nf_instance_request : public itti_msg_n11 {
public:
itti_n11_update_nf_instance_request(
const task_id_t orig, const task_id_t dest)
: itti_msg_n11(N11_UPDATE_NF_INSTANCE_REQUEST, orig, dest),
http_version(1) {}
const char* get_msg_name() { return "N11_UPDATE_NF_INSTANCE_REQUEST"; };
// std::vector<oai::amf::model::PatchItem> patch_items;
uint8_t http_version;
std::string smf_instance_id;
};
//-----------------------------------------------------------------------------
class itti_n11_update_nf_instance_response : public itti_msg_n11 {
public:
itti_n11_update_nf_instance_response(
const task_id_t orig, const task_id_t dest)
: itti_msg_n11(N11_UPDATE_NF_INSTANCE_RESPONSE, orig, dest),
http_version(1) {}
const char* get_msg_name() { return "N11_UPDATE_NF_INSTANCE_RESPONSE"; };
uint8_t http_version;
std::string amf_instance_id;
uint8_t http_response_code;
};
//-----------------------------------------------------------------------------
class itti_n11_deregister_nf_instance : public itti_msg_n11 {
public:
itti_n11_deregister_nf_instance(const task_id_t orig, const task_id_t dest)
: itti_msg_n11(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 amf_instance_id;
};
#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