Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-SMF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-SMF
Commits
53d44562
Commit
53d44562
authored
Jan 05, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add smf profile
parent
8251f33f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
547 additions
and
3 deletions
+547
-3
src/common/smf.h
src/common/smf.h
+16
-3
src/smf_app/CMakeLists.txt
src/smf_app/CMakeLists.txt
+1
-0
src/smf_app/smf_event.hpp
src/smf_app/smf_event.hpp
+1
-0
src/smf_app/smf_profile.cpp
src/smf_app/smf_profile.cpp
+209
-0
src/smf_app/smf_profile.hpp
src/smf_app/smf_profile.hpp
+320
-0
No files found.
src/common/smf.h
View file @
53d44562
...
@@ -208,15 +208,28 @@ typedef struct qos_profile_s {
...
@@ -208,15 +208,28 @@ typedef struct qos_profile_s {
#define UDM_NUMBER_RETRIES 3
#define UDM_NUMBER_RETRIES 3
constexpr
auto
CURL_MIME_BOUNDARY
=
"----Boundary"
;
constexpr
auto
CURL_MIME_BOUNDARY
=
"----Boundary"
;
//for N1N2
//
for N1N2
#define BUF_LEN 512
#define BUF_LEN 512
//for PFCP
//
for PFCP
constexpr
uint64_t
SECONDS_SINCE_FIRST_EPOCH
=
2208988800
;
constexpr
uint64_t
SECONDS_SINCE_FIRST_EPOCH
=
2208988800
;
//8.22 Fully Qualified TEID (F-TEID) - 3GPP TS 29.274 V16.0.0
//
8.22 Fully Qualified TEID (F-TEID) - 3GPP TS 29.274 V16.0.0
#define TEID_GRE_KEY_LENGTH 4
#define TEID_GRE_KEY_LENGTH 4
#define DEFAULT_QFI 6
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
;
#endif
#endif
src/smf_app/CMakeLists.txt
View file @
53d44562
...
@@ -57,6 +57,7 @@ add_library (SMF STATIC
...
@@ -57,6 +57,7 @@ add_library (SMF STATIC
smf_n10.cpp
smf_n10.cpp
smf_n11.cpp
smf_n11.cpp
smf_event.cpp
smf_event.cpp
smf_profile.cpp
smf_subscription.cpp
smf_subscription.cpp
smf_msg.cpp
smf_msg.cpp
)
)
...
...
src/smf_app/smf_event.hpp
View file @
53d44562
...
@@ -51,6 +51,7 @@ class smf_event {
...
@@ -51,6 +51,7 @@ class smf_event {
// class register/handle event
// class register/handle event
friend
class
smf_app
;
friend
class
smf_app
;
friend
class
smf_context
;
friend
class
smf_context
;
friend
class
smf_profile
;
/*
/*
* Subscribe to SM Context Status Notification signal
* Subscribe to SM Context Status Notification signal
...
...
src/smf_app/smf_profile.cpp
0 → 100644
View file @
53d44562
/*
* 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 smf_profile.cpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include "logger.hpp"
#include "smf_profile.hpp"
#include "string.hpp"
using
namespace
std
;
using
namespace
smf
;
//------------------------------------------------------------------------------
void
smf_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
{
instance_id
=
nf_instance_id
;
}
//------------------------------------------------------------------------------
std
::
string
smf_profile
::
get_nf_instance_id
()
const
{
return
nf_instance_id
;
}
//------------------------------------------------------------------------------
void
smf_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
{
instance_name
=
nf_instance_name
;
}
//------------------------------------------------------------------------------
std
::
string
smf_profile
::
get_nf_instance_name
()
const
{
return
nf_instance_name
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
set_nf_type
(
const
std
::
string
&
type
)
{
nf_type
=
type
;
}
//------------------------------------------------------------------------------
std
::
string
smf_profile
::
get_nf_type
()
const
{
return
nf_type
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
set_nf_status
(
const
std
::
string
&
status
)
{
nf_status
=
status
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
get_nf_status
(
std
::
string
&
status
)
const
{
status
=
nf_status
;
}
//------------------------------------------------------------------------------
std
::
string
smf_profile
::
get_nf_status
()
const
{
return
nf_status
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
set_nf_heartBeat_timer
(
const
int32_t
&
timer
)
{
heartBeat_timer
=
timer
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
get_nf_heartBeat_timer
(
int32_t
&
timer
)
const
{
timer
=
heartBeat_timer
;
}
//------------------------------------------------------------------------------
int32_t
smf_profile
::
get_nf_heartBeat_timer
()
const
{
return
heartBeat_timer
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
set_nf_priority
(
const
uint16_t
&
p
)
{
priority
=
p
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
get_nf_priority
(
uint16_t
&
p
)
const
{
p
=
priority
;
}
//------------------------------------------------------------------------------
uint16_t
smf_profile
::
get_nf_priority
()
const
{
return
priority
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
set_nf_capacity
(
const
uint16_t
&
c
)
{
capacity
=
c
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
get_nf_capacity
(
uint16_t
&
c
)
const
{
c
=
capacity
;
}
//------------------------------------------------------------------------------
uint16_t
smf_profile
::
get_nf_capacity
()
const
{
return
capacity
;
}
//------------------------------------------------------------------------------
void
smf_profile
::
set_nf_snssais
(
const
std
::
vector
<
snssai_t
>
&
s
)
{
snssais
=
s
;
}
//------------------------------------------------------------------------------
void
smf_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
smf_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
)
{
ipv4_addresses
.
push_back
(
a
);
}
//------------------------------------------------------------------------------
void
smf_profile
::
get_nf_ipv4_addresses
(
std
::
vector
<
struct
in_addr
>
&
a
)
const
{
a
=
ipv4_addresses
;
}
//------------------------------------------------------------------------------
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
::
display
()
{
Logger
::
smf_app
().
debug
(
"NF instance info"
);
Logger
::
smf_app
().
debug
(
"
\t
Instance ID: %s"
,
nf_instance_id
.
c_str
());
Logger
::
smf_app
().
debug
(
"
\t
Instance name: %s"
,
nf_instance_name
.
c_str
());
Logger
::
smf_app
().
debug
(
"
\t
Instance type: %s"
,
nf_type
.
c_str
());
Logger
::
smf_app
().
debug
(
"
\t
Status: %s"
,
nf_status
.
c_str
());
Logger
::
smf_app
().
debug
(
"
\t
HeartBeat timer: %d"
,
heartBeat_timer
);
Logger
::
smf_app
().
debug
(
"
\t
Priority: %d"
,
priority
);
Logger
::
smf_app
().
debug
(
"
\t
Capacity: %d"
,
capacity
);
// SNSSAIs
for
(
auto
s
:
snssais
)
{
Logger
::
smf_app
().
debug
(
"
\t
NNSSAI(SST, SD): %d, %s"
,
s
.
sST
,
s
.
sD
.
c_str
());
}
// IPv4 Addresses
for
(
auto
address
:
ipv4_addresses
)
{
Logger
::
smf_app
().
debug
(
"
\t
IPv4 Addr: %s"
,
inet_ntoa
(
address
));
}
if
(
!
custom_info
.
empty
())
{
Logger
::
smf_app
().
debug
(
"
\t
Custom info: %s"
,
custom_info
.
dump
().
c_str
());
}
}
//------------------------------------------------------------------------------
void
smf_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
[
"heartBeatTimer"
]
=
heartBeat_timer
;
// SNSSAIs
data
[
"sNssais"
]
=
nlohmann
::
json
::
array
();
for
(
auto
s
:
snssais
)
{
nlohmann
::
json
tmp
=
{};
tmp
[
"sst"
]
=
s
.
sST
;
tmp
[
"sd"
]
=
s
.
sD
;
;
data
[
"sNssais"
].
push_back
(
tmp
);
}
// ipv4_addresses
data
[
"ipv4Addresses"
]
=
nlohmann
::
json
::
array
();
for
(
auto
address
:
ipv4_addresses
)
{
nlohmann
::
json
tmp
=
inet_ntoa
(
address
);
data
[
"ipv4Addresses"
].
push_back
(
tmp
);
}
data
[
"priority"
]
=
priority
;
data
[
"capacity"
]
=
capacity
;
data
[
"custom_info"
]
=
custom_info
;
}
//------------------------------------------------------------------------------
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
);
set_nf_status
(
"SUSPENDED"
);
}
src/smf_app/smf_profile.hpp
0 → 100644
View file @
53d44562
/*
* 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 smf_profile.hpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2021
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef FILE_SMF_PROFILE_HPP_SEEN
#define FILE_SMF_PROFILE_HPP_SEEN
#include <arpa/inet.h>
#include <netinet/in.h>
#include <map>
#include <memory>
#include <nlohmann/json.hpp>
#include <shared_mutex>
#include <utility>
#include <vector>
#include "logger.hpp"
#include "smf.h"
#include "smf_event.hpp"
namespace
smf
{
using
namespace
std
;
class
smf_profile
:
public
std
::
enable_shared_from_this
<
smf_profile
>
{
public:
smf_profile
()
:
nf_type
(
"NF_TYPE_UNKNOWN"
),
heartBeat_timer
(
0
),
snssais
(),
ipv4_addresses
(),
priority
(
0
),
capacity
(
0
),
event_sub
(
smf_event
::
get_instance
())
{
nf_instance_name
=
""
;
nf_status
=
""
;
custom_info
=
{};
}
smf_profile
(
const
std
::
string
&
id
)
:
nf_instance_id
(
id
),
heartBeat_timer
(
0
),
snssais
(),
ipv4_addresses
(),
priority
(
0
),
capacity
(
0
),
nf_type
(
"NF_TYPE_UNKNOWN"
),
event_sub
(
smf_event
::
get_instance
())
{
nf_instance_name
=
""
;
nf_status
=
""
;
custom_info
=
{};
}
smf_profile
(
smf_profile
&
b
)
=
delete
;
virtual
~
smf_profile
()
{
Logger
::
smf_app
().
debug
(
"Delete SMF Profile instance..."
);
}
/*
* Set NF instance ID
* @param [const std::string &] instance_id: instance id
* @return void
*/
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
;
/*
* Get NF instance ID
* @param [std::string &] instance_id: store instance id
* @return void:
*/
std
::
string
get_nf_instance_id
()
const
;
/*
* Set NF instance name
* @param [const std::string &] instance_name: instance name
* @return void
*/
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
;
/*
* Get NF instance name
* @param
* @return [std::string] instance name
*/
std
::
string
get_nf_instance_name
()
const
;
/*
* Set NF instance status
* @param [const std::string &] status: instance status
* @return void
*/
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
;
/*
* Get NF status
* @param
* @return [std::string] instance status
*/
std
::
string
get_nf_status
()
const
;
/*
* Get NF type
* @param
* @return [std::string] nf type
*/
std
::
string
get_nf_type
()
const
;
/*
* Set NF type
* @param [const nf_type_t &] type: nf type
* @return void
*/
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
);
/*
* Get NF instance heartBeat_timer
* @param [std::string &] timer: store heartBeat_timer
* @return void:
*/
void
get_nf_heartBeat_timer
(
int32_t
&
timer
)
const
;
/*
* Get NF heartBeat_timer
* @param void
* @return heartBeat_timer
*/
int32_t
get_nf_heartBeat_timer
()
const
;
/*
* Set NF instance priority
* @param [const uint16_t] p: instance priority
* @return void
*/
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
;
/*
* Get NF instance priority
* @param void
* @return [uint16_t] instance priority
*/
uint16_t
get_nf_priority
()
const
;
/*
* Set NF instance capacity
* @param [const uint16_t] c: instance capacity
* @return void
*/
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
;
/*
* Get NF instance priority
* @param void
* @return [uint16_t ] instance capacity
*/
uint16_t
get_nf_capacity
()
const
;
/*
* Set NF instance SNSSAIs
* @param [std::vector<snssai_t> &] s: SNSSAIs
* @return void
*/
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
);
/*
* 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
;
/*
* 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
);
/*
* 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
);
/*
* 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
;
/*
* Set custom info
* @param [const nlohmann::json &] c: custom info to be set
* @return void
*/
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
;
/*
* Print related-information for NF profile
* @param void
* @return void:
*/
virtual
void
display
();
/*
* Represent NF profile as json object
* @param [nlohmann::json &] data: Json data
* @return void
*/
virtual
void
to_json
(
nlohmann
::
json
&
data
)
const
;
/*
* Handle heartbeart timeout event
* @param [uint64_t] ms: current time
* @return void
*/
void
handle_heartbeart_timeout
(
uint64_t
ms
);
protected:
// for Event Handling
smf_event
&
event_sub
;
// 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
;
nlohmann
::
json
custom_info
;
// store extra json data
smf_info_t
smf_info
;
};
}
// namespace smf
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment