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

Merge branch 'smf_service_clean_up' into 'develop'

Smf service clean up

See merge request oai/cn5g/oai-cn5g-smf!35
parents 74893fdc 2ec30c63
...@@ -246,6 +246,7 @@ install_nghttp2_from_git() { ...@@ -246,6 +246,7 @@ install_nghttp2_from_git() {
git clone $GIT_URL git clone $GIT_URL
cd nghttp2 cd nghttp2
git checkout 43ba3125932c1d56addaeded2b7f62637af255cd
git submodule update --init git submodule update --init
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
autoreconf -i autoreconf -i
......
...@@ -27,92 +27,112 @@ ...@@ -27,92 +27,112 @@
# either expressed or implied, of the FreeBSD Project. # either expressed or implied, of the FreeBSD Project.
# #
# see https://clang.llvm.org/docs/ClangFormatStyleOptions.html for explanation ---
# of style options Language: Cpp
# BasedOnStyle: Google
BasedOnStyle: Google AccessModifierOffset: -1
Language: Cpp AlignAfterOpenBracket: Align
IndentWidth: 2 AlignConsecutiveAssignments: false
ColumnLimit: 80
IncludeBlocks: Preserve
SortIncludes: false
# alignment
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right AlignEscapedNewlines: Left
AlignOperands: true AlignOperands: true
AlignTrailingComments: true AlignTrailingComments: true
DerivePointerAlignment: false AllowAllParametersOfDeclarationOnNextLine: true
PointerAlignment: Left
# function style
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterReturnType: None
IndentWrappedFunctionNames: false
# template style
#AlwaysBreakTemplateDeclarations: Yes
# preprocessor style
IndentPPDirectives: None
# block style
AllowShortBlocksOnASingleLine: false AllowShortBlocksOnASingleLine: false
KeepEmptyLinesAtTheStartOfBlocks: false AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
# break style AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
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
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 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 MaxEmptyLinesToKeep: 1
ReflowComments: true NamespaceIndentation: None
ObjCBlockIndentWidth: 2
# spacing style ObjCSpaceAfterProperty: false
UseTab: Never ObjCSpaceBeforeProtocolList: false
SpaceAfterCStyleCast: true PenaltyBreakAssignment: 2
SpaceAfterTemplateKeyword: false PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true SpaceBeforeAssignmentOperators: true
#SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements SpaceBeforeParens: ControlStatements
#SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2 SpacesBeforeTrailingComments: 2
SpacesInAngles: false SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false SpacesInParentheses: false
SpacesInSquareBrackets: 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)
...@@ -32,10 +32,13 @@ include_directories(${SRC_TOP_DIR}/common/msg) ...@@ -32,10 +32,13 @@ include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/utils) include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/utils/bstr) include_directories(${SRC_TOP_DIR}/common/utils/bstr)
include_directories(${SRC_TOP_DIR}/common/nas) include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/common/ngap)
include_directories(${SRC_TOP_DIR}/pfcp) include_directories(${SRC_TOP_DIR}/pfcp)
include_directories(${SRC_TOP_DIR}/nas)
include_directories(${SRC_TOP_DIR}/nas/ies) include_directories(${SRC_TOP_DIR}/nas/ies)
include_directories(${SRC_TOP_DIR}/nas/sm)
include_directories(${SRC_TOP_DIR}/nas/sm/msg) include_directories(${SRC_TOP_DIR}/nas/sm/msg)
include_directories(${SRC_TOP_DIR}/nas/mm)
include_directories(${SRC_TOP_DIR}/nas/mm/msg)
include_directories(${SRC_TOP_DIR}/ngap/asn1c) include_directories(${SRC_TOP_DIR}/ngap/asn1c)
include_directories(${SRC_TOP_DIR}/ngap/ies) include_directories(${SRC_TOP_DIR}/ngap/ies)
include_directories(${SRC_TOP_DIR}/udp) include_directories(${SRC_TOP_DIR}/udp)
......
...@@ -593,3 +593,8 @@ void smf_http2_server::release_sm_context_handler( ...@@ -593,3 +593,8 @@ void smf_http2_server::release_sm_context_handler(
response.write_head(sm_context_response.get_http_code()); response.write_head(sm_context_response.get_http_code());
response.end(); response.end();
} }
//------------------------------------------------------------------------------
void smf_http2_server::stop() {
server.stop();
}
...@@ -65,6 +65,7 @@ class smf_http2_server { ...@@ -65,6 +65,7 @@ class smf_http2_server {
const std::string &smf_ref, const std::string &smf_ref,
const SmContextReleaseData &smContextReleaseData, const SmContextReleaseData &smContextReleaseData,
const response &response); const response &response);
void stop();
private: private:
util::uint_generator<uint32_t> m_promise_id_generator; util::uint_generator<uint32_t> m_promise_id_generator;
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#ifndef FILE_3GPP_23_003_SEEN #ifndef FILE_3GPP_23_003_SEEN
#define FILE_3GPP_23_003_SEEN #define FILE_3GPP_23_003_SEEN
//#include "3gpp_29.274.h"
#include <stdint.h> #include <stdint.h>
typedef struct plmn_s { typedef struct plmn_s {
......
...@@ -332,7 +332,46 @@ typedef struct pdu_session_type_s { ...@@ -332,7 +332,46 @@ typedef struct pdu_session_type_s {
} }
} pdu_session_type_t; } pdu_session_type_t;
//-------------------------------------
// 8.14 PDU Session (UE IP) Address Allocation (PAA)
struct paa_s {
pdu_session_type_t pdu_session_type;
uint8_t ipv6_prefix_length;
struct in6_addr ipv6_address;
struct in_addr ipv4_address;
//------------------------------------------------------------------------------
bool is_ip_assigned() {
switch (pdu_session_type.pdu_session_type) {
case PDU_SESSION_TYPE_E_IPV4:
if (ipv4_address.s_addr)
return true;
return false;
break;
case PDU_SESSION_TYPE_E_IPV6:
if (ipv6_address.s6_addr32[0] | ipv6_address.s6_addr32[1]
| ipv6_address.s6_addr32[2] | ipv6_address.s6_addr32[3])
return true;
return false;
break;
case PDU_SESSION_TYPE_E_IPV4V6:
// TODO
if (ipv4_address.s_addr)
return true;
if (ipv6_address.s6_addr32[0] | ipv6_address.s6_addr32[1]
| ipv6_address.s6_addr32[2] | ipv6_address.s6_addr32[3])
return true;
return false;
break;
case PDU_SESSION_TYPE_E_UNSTRUCTURED:
case PDU_SESSION_TYPE_E_ETHERNET:
case PDU_SESSION_TYPE_E_RESERVED:
default:
return false;
}
}
};
typedef struct paa_s paa_t;
#endif #endif
#endif #endif
...@@ -1357,7 +1357,7 @@ typedef struct graceful_release_period_s { ...@@ -1357,7 +1357,7 @@ typedef struct graceful_release_period_s {
//------------------------------------- //-------------------------------------
// 8.2.79 PDN Type // 8.2.79 PDN Type
enum pdn_type_value_e { enum pdu_session_type_value_e {
/* Request / Initial message */ /* Request / Initial message */
IPV4 = 1, IPV4 = 1,
IPV6 = 2, IPV6 = 2,
...@@ -1366,10 +1366,10 @@ enum pdn_type_value_e { ...@@ -1366,10 +1366,10 @@ enum pdn_type_value_e {
ETHERNET = 5 ETHERNET = 5
}; };
typedef struct pdn_type_s { typedef struct pdu_session_type_s {
uint8_t spare :5; uint8_t spare :5;
uint8_t pdn_type :3; uint8_t pdu_session_type :3;
} pdn_type_t; } pdu_session_type_t;
//------------------------------------- //-------------------------------------
// 8.2.80 Failed Rule ID // 8.2.80 Failed Rule ID
......
This diff is collapsed.
...@@ -38,142 +38,6 @@ ...@@ -38,142 +38,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace gtpv1u {
struct gtpu_exception : public std::exception {
gtpu_exception() throw () {
cause = 0;
phrase.assign("GTPV1-U Exception unknown cause");
}
gtpu_exception(int acause) throw () {
cause = acause;
phrase = fmt::format("GTPV1-U Exception cause {}", cause);
}
const char* what() const throw () {
return phrase.c_str();
}
public:
int cause;
std::string phrase;
};
struct gtpu_msg_bad_length_exception : public gtpu_exception {
public:
gtpu_msg_bad_length_exception(const uint8_t msg_type,
const uint16_t msg_size) throw () {
phrase = fmt::format("GTPV1-U msg {} Bad Length {} Exception", msg_type,
msg_size);
}
gtpu_msg_bad_length_exception(std::string &aphrase) throw () {
phrase = aphrase;
}
virtual ~gtpu_msg_bad_length_exception() throw () {
}
};
struct gtpu_msg_unimplemented_ie_exception : public gtpu_exception {
public:
gtpu_msg_unimplemented_ie_exception(const uint8_t msg_type,
const uint8_t ie_type,
const uint8_t instance = 0) throw () {
phrase = fmt::format(
"GTPV1-U msg {} Unimplemented {} IE Instance {} Exception", msg_type,
ie_type, instance);
}
gtpu_msg_unimplemented_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
}
virtual ~gtpu_msg_unimplemented_ie_exception() throw () {
}
};
struct gtpu_msg_illegal_ie_exception : public gtpu_exception {
public:
gtpu_msg_illegal_ie_exception(const uint8_t msg_type,
const uint8_t ie_type) throw () {
phrase = fmt::format("GTPV1-U msg {} Illegal {} Exception", msg_type,
ie_type);
}
gtpu_msg_illegal_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
}
virtual ~gtpu_msg_illegal_ie_exception() throw () {
}
};
struct gtpu_ie_exception : public gtpu_exception {
public:
gtpu_ie_exception(uint8_t ie_type) throw () {
phrase = fmt::format("GTPV1-U IE {} Exception", ie_type);
}
gtpu_ie_exception(std::string &aphrase) throw () {
phrase = aphrase;
}
virtual ~gtpu_ie_exception() throw () {
}
};
struct gtpu_ie_unimplemented_exception : public gtpu_ie_exception {
public:
gtpu_ie_unimplemented_exception(uint8_t ie_type) throw ()
:
gtpu_ie_exception(ie_type) {
phrase = fmt::format("GTPV1-U IE {} Unimplemented Exception", ie_type);
}
virtual ~gtpu_ie_unimplemented_exception() throw () {
}
};
struct gtpu_tlv_exception : public gtpu_ie_exception {
public:
gtpu_tlv_exception(uint8_t ie_type) throw ()
:
gtpu_ie_exception(ie_type) {
phrase = fmt::format("GTPV1-U IE TLV {} Exception", ie_type);
}
virtual ~gtpu_tlv_exception() throw () {
}
};
struct gtpu_tlv_bad_length_exception : public gtpu_tlv_exception {
public:
gtpu_tlv_bad_length_exception(uint8_t ie_type, uint16_t ie_length) throw ()
:
gtpu_tlv_exception(ie_type) {
phrase = fmt::format("GTPV1-U IE TLV {} Bad Length {} Exception", ie_type);
}
virtual ~gtpu_tlv_bad_length_exception() throw () {
}
};
struct gtpu_ie_value_exception : public gtpu_ie_exception {
public:
gtpu_ie_value_exception(uint8_t ie_type, const char *field) throw ()
:
gtpu_ie_exception(ie_type) {
phrase = fmt::format("GTPV1-U IE {} Bad Value of {} Exception", ie_type,
field);
}
virtual ~gtpu_ie_value_exception() throw () {
}
};
#define GTPU_IE_RECOVERY 14
#define GTPU_IE_TUNNEL_ENDPOINT_IDENTIFIER_DATA_I 16
#define GTPU_IE_GTP_U_PEER_ADDRESS 133
#define GTPU_IE_EXTENSION_HEADER_TYPE_LIST 141
#define GTPU_IE_PRIVATE_EXTENSION 255
#define GTPU_ECHO_REQUEST (1)
#define GTPU_ECHO_RESPONSE (2)
#define GTPU_ERROR_INDICATION (26)
#define GTPU_SUPPORTED_EXTENSION_HEADERS_NOTIFICATION (31)
#define GTPU_END_MARKER (254)
#define GTPU_G_PDU (255)
} // namespace
// 8.2 Recovery // 8.2 Recovery
// 8.3 Tunnel Endpoint Identifier Data I // 8.3 Tunnel Endpoint Identifier Data I
......
/*
* 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_NGAP_COMMON_SEEN
#define FILE_NGAP_COMMON_SEEN
#include "common_defs.h"
#include "common_types.h"
#include "bstrlib.h"
#include "Ngap_NGAP-PDU.h"
#include "Ngap_ProcedureCode.h"
#include "Ngap_TriggeringMessage.h"
#include "Ngap_Criticality.h"
#include "Ngap_CriticalityDiagnostics-IE-Item.h"
#include "assertions.h"
#define NGAP_FIND_PROTOCOLIE_BY_ID(IE_TYPE, ie, container, IE_ID, mandatory) \
do {\
IE_TYPE **ptr; \
ie = NULL; \
for (ptr = container->protocolIEs.list.array; \
ptr < &container->protocolIEs.list.array[container->protocolIEs.list.count]; \
ptr++) { \
if((*ptr)->id == IE_ID) { \
ie = *ptr; \
break; \
} \
} \
if (mandatory) DevAssert(ie != NULL); \
} while(0)
typedef int (*ngap_message_decoded_callback)(const sctp_assoc_id_t assoc_id,
const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU *message_p);
int check_NGAP_pdu_constraints(Ngap_NGAP_PDU_t *pdu);
int ngap_amf_decode_pdu(Ngap_NGAP_PDU_t *pdu, const_bstring const raw);
#endif
...@@ -201,7 +201,6 @@ typedef struct qos_profile_s { ...@@ -201,7 +201,6 @@ typedef struct qos_profile_s {
#define NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL "/sm-contexts" #define NSMF_PDU_SESSION_SM_CONTEXT_CREATE_URL "/sm-contexts"
#define NSMF_PDU_SESSION_SM_CONTEXT_UPDATE_URL "/sm-contexts/" #define NSMF_PDU_SESSION_SM_CONTEXT_UPDATE_URL "/sm-contexts/"
//for CURL //for CURL
#define AMF_CURL_TIMEOUT_MS 100L #define AMF_CURL_TIMEOUT_MS 100L
#define AMF_NUMBER_RETRIES 3 #define AMF_NUMBER_RETRIES 3
......
...@@ -36,124 +36,52 @@ ...@@ -36,124 +36,52 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void xgpp_conv::paa_to_pfcp_ue_ip_address( void xgpp_conv::paa_to_pfcp_ue_ip_address(
const paa_t &paa, pfcp::ue_ip_address_t &ue_ip_address) { const paa_t &paa, pfcp::ue_ip_address_t &ue_ip_address) {
switch (paa.pdn_type.pdn_type) { switch (paa.pdu_session_type.pdu_session_type) {
case PDN_TYPE_E_IPV4: case PDU_SESSION_TYPE_E_IPV4:
ue_ip_address.v4 = 1; ue_ip_address.v4 = 1;
ue_ip_address.ipv4_address = paa.ipv4_address; ue_ip_address.ipv4_address = paa.ipv4_address;
break; break;
case PDN_TYPE_E_IPV6: case PDU_SESSION_TYPE_E_IPV6:
ue_ip_address.v6 = 1; ue_ip_address.v6 = 1;
ue_ip_address.ipv6_address = paa.ipv6_address; ue_ip_address.ipv6_address = paa.ipv6_address;
break; break;
case PDN_TYPE_E_IPV4V6: case PDU_SESSION_TYPE_E_IPV4V6:
ue_ip_address.v4 = 1; ue_ip_address.v4 = 1;
ue_ip_address.v6 = 1; ue_ip_address.v6 = 1;
ue_ip_address.ipv4_address = paa.ipv4_address; ue_ip_address.ipv4_address = paa.ipv4_address;
ue_ip_address.ipv6_address = paa.ipv6_address; ue_ip_address.ipv6_address = paa.ipv6_address;
break; break;
case PDN_TYPE_E_NON_IP: case PDU_SESSION_TYPE_E_UNSTRUCTURED:
case PDU_SESSION_TYPE_E_ETHERNET:
case PDU_SESSION_TYPE_E_RESERVED:
default: default:
; ;
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void xgpp_conv::pdn_ip_to_pfcp_ue_ip_address( void xgpp_conv::pdn_ip_to_pfcp_ue_ip_address(
const pdn_type_t &pdn_type, const struct in_addr &ipv4_address, const pdu_session_type_t &pdu_session_type, const struct in_addr &ipv4_address,
const struct in6_addr ipv6_address, pfcp::ue_ip_address_t &ue_ip_address) { const struct in6_addr ipv6_address, pfcp::ue_ip_address_t &ue_ip_address) {
switch (pdn_type.pdn_type) { switch (pdu_session_type.pdu_session_type) {
case PDN_TYPE_E_IPV4: case PDU_SESSION_TYPE_E_IPV4:
ue_ip_address.v4 = 1; ue_ip_address.v4 = 1;
ue_ip_address.ipv4_address = ipv4_address; ue_ip_address.ipv4_address = ipv4_address;
break; break;
case PDN_TYPE_E_IPV6: case PDU_SESSION_TYPE_E_IPV6:
ue_ip_address.v6 = 1; ue_ip_address.v6 = 1;
ue_ip_address.ipv6_address = ipv6_address; ue_ip_address.ipv6_address = ipv6_address;
break; break;
case PDN_TYPE_E_IPV4V6: case PDU_SESSION_TYPE_E_IPV4V6:
ue_ip_address.v4 = 1; ue_ip_address.v4 = 1;
ue_ip_address.v6 = 1; ue_ip_address.v6 = 1;
ue_ip_address.ipv4_address = ipv4_address; ue_ip_address.ipv4_address = ipv4_address;
ue_ip_address.ipv6_address = ipv6_address; ue_ip_address.ipv6_address = ipv6_address;
break; break;
case PDN_TYPE_E_NON_IP: case PDU_SESSION_TYPE_E_UNSTRUCTURED:
case PDU_SESSION_TYPE_E_ETHERNET:
case PDU_SESSION_TYPE_E_RESERVED:
default: default:
; ;
} }
} }
//------------------------------------------------------------------------------
void xgpp_conv::pfcp_to_core_fteid(const pfcp::fteid_t &pfteid,
fteid_t &fteid) {
fteid.v4 = pfteid.v4;
fteid.v6 = pfteid.v6;
fteid.ipv4_address.s_addr = pfteid.ipv4_address.s_addr;
fteid.ipv6_address = pfteid.ipv6_address;
fteid.teid_gre_key = pfteid.teid;
}
//------------------------------------------------------------------------------
void xgpp_conv::pfcp_from_core_fteid(pfcp::fteid_t &pfteid,
const fteid_t &fteid) {
pfteid.chid = 0;
pfteid.ch = 0;
pfteid.choose_id = 0;
pfteid.v4 = fteid.v4;
pfteid.v6 = fteid.v6;
pfteid.ipv4_address.s_addr = fteid.ipv4_address.s_addr;
pfteid.ipv6_address = fteid.ipv6_address;
pfteid.teid = fteid.teid_gre_key;
}
//------------------------------------------------------------------------------
void xgpp_conv::pfcp_cause_to_core_cause(const pfcp::cause_t &pc, cause_t &c) {
switch (pc.cause_value) {
case pfcp::CAUSE_VALUE_REQUEST_ACCEPTED:
c.cause_value = REQUEST_ACCEPTED;
break;
case pfcp::CAUSE_VALUE_REQUEST_REJECTED:
c.cause_value = REQUEST_REJECTED;
break;
case pfcp::CAUSE_VALUE_SESSION_CONTEXT_NOT_FOUND:
case pfcp::CAUSE_VALUE_MANDATORY_IE_MISSING:
case pfcp::CAUSE_VALUE_CONDITIONAL_IE_MISSING:
case pfcp::CAUSE_VALUE_INVALID_LENGTH:
case pfcp::CAUSE_VALUE_MANDATORY_IE_INCORRECT:
case pfcp::CAUSE_VALUE_INVALID_FORWARDING_POLICY:
case pfcp::CAUSE_VALUE_INVALID_FTEID_ALLOCATION_OPTION:
case pfcp::CAUSE_VALUE_NO_ESTABLISHED_PFCP_ASSOCIATION:
case pfcp::CAUSE_VALUE_RULE_CREATION_MODIFICATION_FAILURE:
c.cause_value = SYSTEM_FAILURE; // ?
break;
case pfcp::CAUSE_VALUE_PFCP_ENTITY_IN_CONGESTION:
c.cause_value = APN_CONGESTION; // ? ...
break;
case pfcp::CAUSE_VALUE_NO_RESOURCES_AVAILABLE:
case pfcp::CAUSE_VALUE_SERVICE_NOT_SUPPORTED:
case pfcp::CAUSE_VALUE_SYSTEM_FAILURE:
default:
c.cause_value = SYSTEM_FAILURE; // ? ...
}
}
//------------------------------------------------------------------------------
bool xgpp_conv::endpoint_to_gtp_u_peer_address(
const endpoint &ep, gtp_u_peer_address_t &peer_address) {
switch (ep.family()) {
case AF_INET: {
const struct sockaddr_in *const sin =
reinterpret_cast<const sockaddr_in* const >(&ep.addr_storage);
peer_address.ipv4_address.s_addr = sin->sin_addr.s_addr;
peer_address.is_v4 = true;
return true;
}
break;
case AF_INET6: {
const struct sockaddr_in6 *const sin6 =
reinterpret_cast<const sockaddr_in6* const >(&ep.addr_storage);
peer_address.ipv6_address = sin6->sin6_addr;
peer_address.is_v4 = false;
return true;
}
break;
default:
return false;
}
}
...@@ -31,21 +31,17 @@ ...@@ -31,21 +31,17 @@
#include "3gpp_29.274.h" #include "3gpp_29.274.h"
#include "3gpp_29.244.h" #include "3gpp_29.244.h"
#include "3gpp_29.281.h" #include "3gpp_29.281.h"
#include "3gpp_24.501.h"
#include "endpoint.hpp" #include "endpoint.hpp"
namespace xgpp_conv { namespace xgpp_conv {
void paa_to_pfcp_ue_ip_address(const paa_t &paa, void paa_to_pfcp_ue_ip_address(const paa_t &paa,
pfcp::ue_ip_address_t &ue_ip_address); pfcp::ue_ip_address_t &ue_ip_address);
void pdn_ip_to_pfcp_ue_ip_address(const pdn_type_t &pdn_type, void pdn_ip_to_pfcp_ue_ip_address(const pdu_session_type_t &pdu_session_type,
const struct in_addr &ipv4_address, const struct in_addr &ipv4_address,
const struct in6_addr ipv6_address, const struct in6_addr ipv6_address,
pfcp::ue_ip_address_t &ue_ip_address); pfcp::ue_ip_address_t &ue_ip_address);
void pfcp_to_core_fteid(const pfcp::fteid_t &pfteid, fteid_t &fteid);
void pfcp_from_core_fteid(pfcp::fteid_t &pfteid, const fteid_t &fteid);
void pfcp_cause_to_core_cause(const pfcp::cause_t &pc, cause_t &c);
bool endpoint_to_gtp_u_peer_address(const endpoint &ep,
gtp_u_peer_address_t &gpa);
} }
#endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */ #endif /* FILE_3GPP_CONVERSIONS_HPP_SEEN */
...@@ -22,6 +22,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) ...@@ -22,6 +22,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${SRC_TOP_DIR}/common) include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/msg) include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/utils) include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/utils/bstr)
include_directories(${SRC_TOP_DIR}/itti) include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include) include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <string> #include <string>
#include <netinet/in.h> #include <netinet/in.h>
/* Used to format an uint32_t containing an ipv4 address */ /* Used to format an uint32_t containing an ipv4 address */
#define IN_ADDR_FMT "%u.%u.%u.%u" #define IN_ADDR_FMT "%u.%u.%u.%u"
#define PRI_IN_ADDR(aDDRESS) \ #define PRI_IN_ADDR(aDDRESS) \
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
*/ */
#include "string.hpp" #include "string.hpp"
#include <stdarg.h>
#include <algorithm> #include <algorithm>
#include <functional>
#include <cctype> #include <cctype>
#include <functional>
#include <locale> #include <locale>
#include <stdarg.h>
template<class T> template <class T>
class Buffer { class Buffer {
public: public:
explicit Buffer(size_t size) { explicit Buffer(size_t size) {
...@@ -34,12 +34,10 @@ class Buffer { ...@@ -34,12 +34,10 @@ class Buffer {
mbuf = new T[msize]; mbuf = new T[msize];
} }
~Buffer() { ~Buffer() {
if (mbuf) if (mbuf) delete[] mbuf;
delete[] mbuf;
}
T* get() {
return mbuf;
} }
T *get() { return mbuf; }
private: private:
Buffer(); Buffer();
size_t msize; size_t msize;
...@@ -50,7 +48,7 @@ std::string util::string_format(const char *format, ...) { ...@@ -50,7 +48,7 @@ std::string util::string_format(const char *format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
size_t size = vsnprintf( NULL, 0, format, args) + 1; // Extra space for '\0' size_t size = vsnprintf(NULL, 0, format, args) + 1; // Extra space for '\0'
va_end(args); va_end(args);
Buffer<char> buf(size); Buffer<char> buf(size);
...@@ -63,28 +61,56 @@ std::string util::string_format(const char *format, ...) { ...@@ -63,28 +61,56 @@ std::string util::string_format(const char *format, ...) {
} }
// Licence : https://creativecommons.org/licenses/by-sa/4.0/legalcode // Licence : https://creativecommons.org/licenses/by-sa/4.0/legalcode
//https://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring#217605 // https://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring#217605
// trim from start // trim from start
std::string& util::ltrim(std::string &s) { std::string &util::ltrim(std::string &s) {
s.erase( s.erase(s.begin(),
s.begin(), std::find_if(s.begin(), s.end(),
std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
std::not1(std::ptr_fun<int, int>(std::isspace))));
return s; return s;
} }
// trim from end // trim from end
std::string& util::rtrim(std::string &s) { std::string &util::rtrim(std::string &s) {
s.erase( s.erase(std::find_if(s.rbegin(), s.rend(),
std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace)))
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), .base(),
s.end()); s.end());
return s; return s;
} }
// trim from both ends // trim from both ends
std::string& util::trim(std::string &s) { std::string &util::trim(std::string &s) { return util::ltrim(util::rtrim(s)); }
return util::ltrim(util::rtrim(s));
void util::ipv4_to_bstring(struct in_addr ipv4_address, bstring str) {
unsigned char bitstream_addr[4];
bitstream_addr[0] =
(uint8_t)((ipv4_address.s_addr) & 0x000000ff);
bitstream_addr[1] =
(uint8_t)(((ipv4_address.s_addr) & 0x0000ff00) >> 8);
bitstream_addr[2] =
(uint8_t)(((ipv4_address.s_addr) & 0x00ff0000) >> 16);
bitstream_addr[3] =
(uint8_t)(((ipv4_address.s_addr) & 0xff000000) >> 24);
str = bfromcstralloc(4, "\0");
str->slen = 4;
memcpy(str->data, bitstream_addr,
sizeof(bitstream_addr));
} }
void util::string_to_bstring(const std::string &str, bstring bstr) {
bstr =
bfromcstralloc(str.length(), "\0");
bstr->slen = str.length();
memcpy((void *)bstr->data,
(void *)str.c_str(),
str.length());
/*
std::string s(
(char *)bstr->data,
bstr->slen);
Logger::nrf_app().debug("Str %s", s.c_str());
*/
}
...@@ -29,6 +29,12 @@ ...@@ -29,6 +29,12 @@
#define FILE_STRING_HPP_FILE_SEEN #define FILE_STRING_HPP_FILE_SEEN
#include <string> #include <string>
#include <arpa/inet.h>
extern "C" {
# include "bstrlib.h"
}
namespace util { namespace util {
...@@ -39,5 +45,9 @@ std::string& ltrim(std::string &s); ...@@ -39,5 +45,9 @@ std::string& ltrim(std::string &s);
std::string& rtrim(std::string &s); std::string& rtrim(std::string &s);
// trim from both ends // trim from both ends
std::string& trim(std::string &s); std::string& trim(std::string &s);
void ipv4_to_bstring(struct in_addr ipv4_address, bstring str);
void string_to_bstring(const std::string &str, bstring bstr);
} }
#endif #endif
...@@ -34,7 +34,6 @@ include_directories(${SRC_TOP_DIR}/common/msg) ...@@ -34,7 +34,6 @@ include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/utils) include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/utils/bstr) include_directories(${SRC_TOP_DIR}/common/utils/bstr)
include_directories(${SRC_TOP_DIR}/common/nas) include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/common/ngap)
file(GLOB NAS_src_files file(GLOB NAS_src_files
${NAS_DIR}/*.c ${NAS_DIR}/*.c
......
...@@ -282,7 +282,6 @@ include_directories(${SRC_TOP_DIR}/itti) ...@@ -282,7 +282,6 @@ include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/common) include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/msg) include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/nas) include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/common/ngap)
include_directories(${SRC_TOP_DIR}/common/utils) include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/utils/bstr) include_directories(${SRC_TOP_DIR}/common/utils/bstr)
include_directories(${SRC_TOP_DIR}/pfcp) include_directories(${SRC_TOP_DIR}/pfcp)
......
...@@ -45,8 +45,8 @@ itti_mw *itti_inst = nullptr; ...@@ -45,8 +45,8 @@ itti_mw *itti_inst = nullptr;
async_shell_cmd *async_shell_cmd_inst = nullptr; async_shell_cmd *async_shell_cmd_inst = nullptr;
smf_app *smf_app_inst = nullptr; smf_app *smf_app_inst = nullptr;
smf_config smf_cfg; smf_config smf_cfg;
//SMFApiServer *smf_api_server_1 = nullptr; SMFApiServer *smf_api_server_1 = nullptr;
//smf_http2_server *smf_api_server_2 = nullptr; smf_http2_server *smf_api_server_2 = nullptr;
void send_heartbeat_to_tasks(const uint32_t sequence); void send_heartbeat_to_tasks(const uint32_t sequence);
...@@ -71,9 +71,16 @@ void my_app_signal_handler(int s) ...@@ -71,9 +71,16 @@ void my_app_signal_handler(int s)
std::cout << "Freeing Allocated memory..." << std::endl; std::cout << "Freeing Allocated memory..." << std::endl;
if (async_shell_cmd_inst) delete async_shell_cmd_inst; async_shell_cmd_inst = nullptr; if (async_shell_cmd_inst) delete async_shell_cmd_inst; async_shell_cmd_inst = nullptr;
std::cout << "Async Shell CMD memory done." << std::endl; std::cout << "Async Shell CMD memory done." << std::endl;
//smf_api_server_1->shutdown(); if (smf_api_server_1) {
//if (smf_api_server_1) delete smf_api_server_1; smf_api_server_1 = nullptr; smf_api_server_1->shutdown();
//if (smf_api_server_2) delete smf_api_server_2; smf_api_server_2 = nullptr; delete smf_api_server_1;
smf_api_server_1 = nullptr;
}
if (smf_api_server_2) {
smf_api_server_2->stop();
delete smf_api_server_2;
smf_api_server_2 = nullptr;
}
std::cout << "SMF API Server memory done." << std::endl; std::cout << "SMF API Server memory done." << std::endl;
if (itti_inst) delete itti_inst; itti_inst = nullptr; if (itti_inst) delete itti_inst; itti_inst = nullptr;
std::cout << "ITTI memory done." << std::endl; std::cout << "ITTI memory done." << std::endl;
...@@ -129,14 +136,15 @@ int main(int argc, char **argv) ...@@ -129,14 +136,15 @@ int main(int argc, char **argv)
//SMF Pistache API server (HTTP1) //SMF Pistache API server (HTTP1)
Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.sbi.addr4))) , Pistache::Port(smf_cfg.sbi.port)); Pistache::Address addr(std::string(inet_ntoa (*((struct in_addr *)&smf_cfg.sbi.addr4))) , Pistache::Port(smf_cfg.sbi.port));
SMFApiServer *smf_api_server_1 = new SMFApiServer(addr, smf_app_inst); smf_api_server_1 = new SMFApiServer(addr, smf_app_inst);
smf_api_server_1->init(2); smf_api_server_1->init(2);
//smf_api_server_1->start(); //smf_api_server_1->start();
std::thread smf_http1_manager(&SMFApiServer::start, smf_api_server_1); std::thread smf_http1_manager(&SMFApiServer::start, smf_api_server_1);
//SMF NGHTTP API server (HTTP2) //SMF NGHTTP API server (HTTP2)
smf_http2_server *smf_api_server_2 = new smf_http2_server(conv::toString(smf_cfg.sbi.addr4), smf_cfg.sbi_http2_port, smf_app_inst); smf_api_server_2 = new smf_http2_server(conv::toString(smf_cfg.sbi.addr4), smf_cfg.sbi_http2_port, smf_app_inst);
//smf_api_server_2->start(); //smf_api_server_2->start();
std::thread smf_http2_manager(&smf_http2_server::start, smf_api_server_2); std::thread smf_http2_manager(&smf_http2_server::start, smf_api_server_2);
smf_http1_manager.join(); smf_http1_manager.join();
smf_http2_manager.join(); smf_http2_manager.join();
......
...@@ -55,7 +55,6 @@ bool Options::validateOptions(){ ...@@ -55,7 +55,6 @@ bool Options::validateOptions(){
(options & libconfigcfg) (options & libconfigcfg)
); );
} }
bool Options::parseInputOptions( int argc, char **argv ) bool Options::parseInputOptions( int argc, char **argv )
......
...@@ -430,8 +430,11 @@ namespace pfcp { ...@@ -430,8 +430,11 @@ namespace pfcp {
virtual bool get(pfcp::graceful_release_period_t& v) const {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_GRACEFUL_RELEASE_PERIOD, __FILE__, __LINE__);} virtual bool get(pfcp::graceful_release_period_t& v) const {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_GRACEFUL_RELEASE_PERIOD, __FILE__, __LINE__);}
virtual void set(const pfcp::graceful_release_period_t& v) {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_GRACEFUL_RELEASE_PERIOD, __FILE__, __LINE__);} virtual void set(const pfcp::graceful_release_period_t& v) {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_GRACEFUL_RELEASE_PERIOD, __FILE__, __LINE__);}
// PFCP_IE_PDN_TYPE // PFCP_IE_PDN_TYPE
virtual bool get(pfcp::pdn_type_t& v) const {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_PDN_TYPE, __FILE__, __LINE__);} //virtual bool get(pfcp::pdn_type_t& v) const {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_PDN_TYPE, __FILE__, __LINE__);}
virtual void set(const pfcp::pdn_type_t& v) {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_PDN_TYPE, __FILE__, __LINE__);} //virtual void set(const pfcp::pdn_type_t& v) {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_PDN_TYPE, __FILE__, __LINE__);}
virtual bool get(pfcp::pdu_session_type_t& v) const {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_PDN_TYPE, __FILE__, __LINE__);}
virtual void set(const pfcp::pdu_session_type_t& v) {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_PDN_TYPE, __FILE__, __LINE__);}
// PFCP_IE_FAILED_RULE_ID // PFCP_IE_FAILED_RULE_ID
virtual bool get(pfcp::failed_rule_id_t& v) const {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_FAILED_RULE_ID, __FILE__, __LINE__);} virtual bool get(pfcp::failed_rule_id_t& v) const {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_FAILED_RULE_ID, __FILE__, __LINE__);}
virtual void set(const pfcp::failed_rule_id_t& v) {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_FAILED_RULE_ID, __FILE__, __LINE__);} virtual void set(const pfcp::failed_rule_id_t& v) {throw pfcp_msg_illegal_ie_exception(0, PFCP_IE_FAILED_RULE_ID, __FILE__, __LINE__);}
...@@ -2886,7 +2889,8 @@ public: ...@@ -2886,7 +2889,8 @@ public:
std::vector<pfcp::create_qer> create_qers; std::vector<pfcp::create_qer> create_qers;
std::pair<bool, pfcp::create_bar> create_bar; std::pair<bool, pfcp::create_bar> create_bar;
std::pair<bool, pfcp::create_traffic_endpoint> create_traffic_endpoint; std::pair<bool, pfcp::create_traffic_endpoint> create_traffic_endpoint;
std::pair<bool, pfcp::pdn_type_t> pdn_type; //std::pair<bool, pfcp::pdn_type_t> pdn_type;
std::pair<bool, pfcp::pdu_session_type_t> pdu_session_type;
std::pair<bool, fq_csid_t> sgw_c_fq_csid; std::pair<bool, fq_csid_t> sgw_c_fq_csid;
std::pair<bool, fq_csid_t> mme_fq_csid; std::pair<bool, fq_csid_t> mme_fq_csid;
std::pair<bool, fq_csid_t> pgw_c_fq_csid; std::pair<bool, fq_csid_t> pgw_c_fq_csid;
...@@ -2905,7 +2909,7 @@ public: ...@@ -2905,7 +2909,7 @@ public:
create_qers(), create_qers(),
create_bar(), create_bar(),
create_traffic_endpoint(), create_traffic_endpoint(),
pdn_type(), pdu_session_type(),
sgw_c_fq_csid(), sgw_c_fq_csid(),
mme_fq_csid(), mme_fq_csid(),
pgw_c_fq_csid(), pgw_c_fq_csid(),
...@@ -2924,7 +2928,7 @@ public: ...@@ -2924,7 +2928,7 @@ public:
create_qers = i.create_qers; create_qers = i.create_qers;
create_bar = i.create_bar; create_bar = i.create_bar;
create_traffic_endpoint = i.create_traffic_endpoint; create_traffic_endpoint = i.create_traffic_endpoint;
pdn_type = i.pdn_type; pdu_session_type = i.pdu_session_type;
sgw_c_fq_csid = i.sgw_c_fq_csid; sgw_c_fq_csid = i.sgw_c_fq_csid;
mme_fq_csid = i.mme_fq_csid; mme_fq_csid = i.mme_fq_csid;
pgw_c_fq_csid = i.pgw_c_fq_csid; pgw_c_fq_csid = i.pgw_c_fq_csid;
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
include_directories(${SRC_TOP_DIR}/common) include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/msg) include_directories(${SRC_TOP_DIR}/common/msg)
include_directories(${SRC_TOP_DIR}/common/utils) include_directories(${SRC_TOP_DIR}/common/utils)
include_directories(${SRC_TOP_DIR}/common/ngap)
include_directories(${SRC_TOP_DIR}/common/nas) include_directories(${SRC_TOP_DIR}/common/nas)
include_directories(${SRC_TOP_DIR}/itti) include_directories(${SRC_TOP_DIR}/itti)
include_directories(${SRC_TOP_DIR}/pfcp) include_directories(${SRC_TOP_DIR}/pfcp)
...@@ -46,7 +45,6 @@ include_directories(${SRC_TOP_DIR}/api-server/model) ...@@ -46,7 +45,6 @@ include_directories(${SRC_TOP_DIR}/api-server/model)
include_directories(${SRC_TOP_DIR}/api-server/) include_directories(${SRC_TOP_DIR}/api-server/)
add_library (SMF STATIC add_library (SMF STATIC
${SRC_TOP_DIR}/common/ngap/ngap_common.c
smf_app.cpp smf_app.cpp
smf_config.cpp smf_config.cpp
smf_context.cpp smf_context.cpp
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -28,126 +28,22 @@ ...@@ -28,126 +28,22 @@
*/ */
#include "smf_event.hpp" #include "smf_event.hpp"
#include "smf_subscription.hpp"
#include "smf_app.hpp"
#include "itti.hpp" #include "itti.hpp"
#include "smf_app.hpp"
#include "smf_subscription.hpp"
using namespace smf; using namespace smf;
extern smf::smf_app *smf_app_inst;
extern smf::smf_app *smf_app_inst;
extern itti_mw *itti_inst; extern itti_mw *itti_inst;
smf_event::smf_event() {
//bind signal to slot type
bind();
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void smf_event::bind() { bs2::connection smf_event::subscribe_sm_context_status(
//by default, subscribe to the events const sm_context_status_sig_t::slot_type &sig) {
subscribe_sm_context_status_notification( return sm_context_status.connect(sig);
boost::bind(&smf_event::send_sm_context_status_notification, this, _1, _1,
_1));
subscribe_ee_pdu_session_release(
boost::bind(&smf_event::send_ee_pdu_session_release, this, _1, _1, _1));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
boost::signals2::connection smf_event::subscribe_sm_context_status_notification( bs2::connection smf_event::subscribe_ee_pdu_session_release(
const sm_context_status_sig_t::slot_type &context_status_st) { const ee_pdu_session_release_sig_t::slot_type &sig) {
return sm_context_status_sig.connect(context_status_st); return ee_pdu_session_release.connect(sig);
}
//------------------------------------------------------------------------------
void smf_event::trigger_sm_context_status_notification(scid_t scid,
uint8_t status,
uint8_t http_version) {
sm_context_status_sig(scid, status, http_version);
}
//------------------------------------------------------------------------------
void smf_event::send_sm_context_status_notification(scid_t scid,
uint8_t status,
uint8_t http_version) {
Logger::smf_app().debug("Send request to N11 to triger SM Context Status Notification to AMF, SMF Context ID " SCID_FMT " ", scid);
std::shared_ptr<smf_context_ref> scf = { };
if (smf_app_inst->is_scid_2_smf_context(scid)) {
scf = smf_app_inst->scid_2_smf_context(scid);
} else {
Logger::smf_app().warn(
"SM Context associated with this id " SCID_FMT " does not exit!", scid);
//TODO:
return;
}
//Send request to N11 to trigger the notification
Logger::smf_app().debug(
"Send ITTI msg to SMF N11 to trigger the status notification");
std::shared_ptr<itti_n11_notify_sm_context_status> itti_msg = std::make_shared
< itti_n11_notify_sm_context_status > (TASK_SMF_APP, TASK_SMF_N11);
itti_msg->scid = scid;
itti_msg->sm_context_status = sm_context_status_e2str[status];
itti_msg->amf_status_uri = scf.get()->amf_status_uri;
itti_msg->http_version = http_version;
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());
}
}
//------------------------------------------------------------------------------
boost::signals2::connection smf_event::subscribe_ee_pdu_session_release(
const ee_pdu_session_release_sig_t::slot_type &pdu_session_release_st) {
return pdu_session_release_sig.connect(pdu_session_release_st);
}
//------------------------------------------------------------------------------
void smf_event::trigger_ee_pdu_session_release(supi64_t supi,
pdu_session_id_t pdu_session_id,
uint8_t http_version) {
Logger::smf_app().debug("Trigger PDU Session Release event (Event Exposure) notification");
pdu_session_release_sig(supi, pdu_session_id, http_version);
}
//------------------------------------------------------------------------------
void smf_event::send_ee_pdu_session_release(supi64_t supi,
pdu_session_id_t pdu_session_id,
uint8_t http_version) {
Logger::smf_app().debug("Send request to N11 to triger PDU Session Release Notification (Event Exposure), SUPI " SUPI_64_FMT " , PDU Session ID %d, HTTP version %d", supi, pdu_session_id, http_version);
std::vector < std::shared_ptr < smf_subscription >> subscriptions = {};
smf_app_inst->get_ee_subscriptions(smf_event_t::SMF_EVENT_PDU_SES_REL, subscriptions);
if (subscriptions.size() > 0) {
//Send request to N11 to trigger the notification to the subscribed event
Logger::smf_app().debug(
"Send ITTI msg to SMF N11 to trigger the event notification");
std::shared_ptr<itti_n11_notify_subscribed_event> itti_msg = std::make_shared
< itti_n11_notify_subscribed_event > (TASK_SMF_APP, TASK_SMF_N11);
for (auto i: subscriptions) {
event_notification ev_notif = { };
ev_notif.set_supi(supi);
ev_notif.set_pdu_session_id(pdu_session_id);
ev_notif.set_smf_event(smf_event_t::SMF_EVENT_PDU_SES_REL);
ev_notif.set_supi(supi);
ev_notif.set_notif_uri(i.get()->notif_uri);
ev_notif.set_notif_id(i.get()->notif_id);
itti_msg->event_notifs.push_back(ev_notif);
}
itti_msg->http_version = http_version;
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());
}
} else {
Logger::smf_app().debug("No subscription available for this event");
}
} }
This diff is collapsed.
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. * this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under * 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 * the OAI Public License, Version 1.1 (the "License"); you may not use this
* except in compliance with the License. * file except in compliance with the License. You may obtain a copy of the
* You may obtain a copy of the License at * License at
* *
* http://www.openairinterface.org/?page_id=698 * http://www.openairinterface.org/?page_id=698
* *
...@@ -19,34 +19,42 @@ ...@@ -19,34 +19,42 @@
* contact@openairinterface.org * contact@openairinterface.org
*/ */
#include <stdint.h> /*! \file smf_event_sig.hpp
\brief
#include "ngap_common.h" \author Tien-Thinh NGUYEN
#include "dynamic_memory_check.h" \company Eurecom
\date 2019
//-------------------------------------------------------------------- \email: tien-thinh.nguyen@eurecom.fr
int check_NGAP_pdu_constraints(Ngap_NGAP_PDU_t *pdu) { */
int ret = -1;
char errbuf[512]; #ifndef FILE_SMF_EVENT_SIG_HPP_SEEN
size_t errlen = sizeof(errbuf); #define FILE_SMF_EVENT_SIG_HPP_SEEN
ret = asn_check_constraints(&asn_DEF_Ngap_NGAP_PDU, pdu, errbuf, &errlen);
if (ret != 0) { #include <boost/signals2.hpp>
printf("Constraint validation failed:%s\n", errbuf); #include "3gpp_24.007.h"
}
return ret; namespace bs2 = boost::signals2;
}
namespace smf {
//--------------------------------------------------------------------
int ngap_amf_decode_pdu(Ngap_NGAP_PDU_t *pdu, const_bstring const raw) { // Signal for PDU session status
Ngap_NGAP_PDU_t *decoded_pdu = pdu; // SCID, PDU Session Status, HTTP version
typedef bs2::signal_type<void(scid_t, uint8_t, uint8_t),
asn_dec_rval_t rc = asn_decode(NULL, ATS_ALIGNED_CANONICAL_PER, bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
&asn_DEF_Ngap_NGAP_PDU, (void**) &decoded_pdu, sm_context_status_sig_t;
bdata(raw), blength(raw));
if (rc.code != RC_OK) { // Signal for Event exposure
printf("asn_decode failed(%d)\n", rc.code); // PDU session Release, SUPI, PDU SessionID, HTTP version
return rc.code; typedef bs2::signal_type<void(supi64_t, pdu_session_id_t, uint8_t),
} bs2::keywords::mutex_type<bs2::dummy_mutex>>::type
return rc.code; ee_pdu_session_release_sig_t;
}
// ee_ue_ip_address_change_sig_t; //UI IP Address, UE ID
// TODO:
// Access Type Change
// UP Path Change
// PLMN Change
// Downlink data delivery status
} // namespace smf
#endif /* FILE_SMF_EVENT_SIG_HPP_SEEN */
This diff is collapsed.
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "3gpp_29.571.h" #include "3gpp_29.571.h"
#include "3gpp_29.508.h" #include "3gpp_29.508.h"
#include "Guami.h" #include "Guami.h"
#include "RefToBinaryData.h"
#include "NgRanTargetId.h" #include "NgRanTargetId.h"
extern "C" { extern "C" {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment