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

First version with new DNN configuration

parent 10f169de
......@@ -67,9 +67,9 @@ SMF =
DNN_LIST = (
# IPV4_POOL, IPV6_POOL are index in IPV4_LIST, IPV6_LIST, PDU_SESSION_TYPE choice in {IPv4, IPv6, IPv4v6}
{DNN_NI = "default"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 0; IPV6_POOL = -1},
{DNN_NI = "carrier.com"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 2; IPV6_POOL = -1},
{DNN_NI = "oai"; PDU_SESSION_TYPE = "IPv4"; IPV4_POOL = 1; IPV6_POOL = -1}
{DNN_NI = "default"; PDU_SESSION_TYPE = "IPv4"; IPV4_RANGE = "12.1.1.2 - 12.1.1.128"; IPV6_PREFIX = "2001:1:2::/64"},
{DNN_NI = "carrier.com"; PDU_SESSION_TYPE = "IPv4"; IPV4_RANGE = "12.1.1.2 - 12.1.1.128"; IPV6_PREFIX = "2001:1:2::/64"},
{DNN_NI = "oai"; PDU_SESSION_TYPE = "IPv4"; IPV4_RANGE = "12.1.1.129 - 12.1.1.224"; IPV6_PREFIX = "3001:1:2::/64"}
);
# DNS address communicated to UEs
......
......@@ -62,6 +62,7 @@
#include "smf_paa_dynamic.hpp"
#include "string.hpp"
#include "fqdn.hpp"
#include "smf_config.hpp"
extern "C" {
#include "dynamic_memory_check.h"
......@@ -83,29 +84,38 @@ void smf_app_task(void*);
int smf_app::apply_config(const smf_config& cfg) {
Logger::smf_app().info("Apply config...");
paa_t paa = {};
for (int ia = 0; ia < cfg.num_dnn; ia++) {
if (cfg.dnn[ia].pool_id_iv4 >= 0) {
int pool_id = cfg.dnn[ia].pool_id_iv4;
int range = be32toh(cfg.ue_pool_range_high[pool_id].s_addr) -
be32toh(cfg.ue_pool_range_low[pool_id].s_addr);
paa_t paa = {};
int pool_id = 0;
for (std::map<std::string, dnn_t>::const_iterator it = cfg.dnns.begin();
it != cfg.dnns.end(); it++) {
if ((it->second.pdu_session_type.pdu_session_type ==
PDU_SESSION_TYPE_E_IPV4) or
(it->second.pdu_session_type.pdu_session_type ==
PDU_SESSION_TYPE_E_IPV4V6)) {
int range = be32toh(it->second.ue_pool_range_high.s_addr) -
be32toh(it->second.ue_pool_range_high.s_addr);
paa_dynamic::get_instance().add_pool(
cfg.dnn[ia].dnn, pool_id, cfg.ue_pool_range_low[pool_id], range);
it->second.dnn, pool_id, it->second.ue_pool_range_low, range);
// TODO: check with dnn_label
Logger::smf_app().info("Applied config %s", cfg.dnn[ia].dnn.c_str());
paa.ipv4_address = cfg.ue_pool_range_low[pool_id];
Logger::smf_app().info("Applied config %s", it->second.dnn.c_str());
paa.ipv4_address = it->second.ue_pool_range_low;
}
if (cfg.dnn[ia].pool_id_iv6 >= 0) {
int pool_id = cfg.dnn[ia].pool_id_iv6;
if ((it->second.pdu_session_type.pdu_session_type ==
PDU_SESSION_TYPE_E_IPV6) or
(it->second.pdu_session_type.pdu_session_type ==
PDU_SESSION_TYPE_E_IPV4V6)) {
paa_dynamic::get_instance().add_pool(
cfg.dnn[ia].dnn, pool_id, cfg.paa_pool6_prefix[pool_id],
cfg.paa_pool6_prefix_len[pool_id]);
paa.ipv6_address = cfg.paa_pool6_prefix[pool_id];
it->second.dnn, pool_id, it->second.paa_pool6_prefix,
it->second.paa_pool6_prefix_len);
paa.ipv6_address = it->second.paa_pool6_prefix;
// TODO: check with dnn_label
Logger::smf_app().info(
"Applied config for IPv6 %s", cfg.dnn[ia].dnn.c_str());
"Applied config for IPv6 %s", it->second.dnn.c_str());
}
pool_id++;
}
Logger::smf_app().info("Applied config");
......
This diff is collapsed.
......@@ -81,6 +81,8 @@
#define SMF_CONFIG_STRING_PDU_SESSION_TYPE "PDU_SESSION_TYPE"
#define SMF_CONFIG_STRING_IPV4_POOL "IPV4_POOL"
#define SMF_CONFIG_STRING_IPV6_POOL "IPV6_POOL"
#define SMF_CONFIG_STRING_IPV4_RANGE "IPV4_RANGE"
#define SMF_CONFIG_STRING_IPV6_PREFIX "IPV6_PREFIX"
#define SMF_ABORT_ON_ERROR true
#define SMF_WARN_ON_ERROR false
......@@ -169,6 +171,19 @@ typedef struct itti_cfg_s {
util::thread_sched_params async_cmd_sched_params;
} itti_cfg_t;
typedef struct dnn_s {
std::string dnn;
std::string dnn_label;
bool is_ipv4;
bool is_ipv6;
int pool_id_iv4;
int pool_id_iv6;
struct in_addr ue_pool_range_low;
struct in_addr ue_pool_range_high;
struct in6_addr paa_pool6_prefix;
uint8_t paa_pool6_prefix_len;
pdu_session_type_t pdu_session_type;
} dnn_t;
class smf_config {
private:
int load_itti(const libconfig::Setting& itti_cfg, itti_cfg_t& cfg);
......@@ -195,32 +210,7 @@ class smf_config {
struct in6_addr default_dnsv6;
struct in6_addr default_dns_secv6;
#define SMF_NUM_DNN_MAX 5
int num_dnn;
struct {
std::string dnn;
std::string dnn_label;
int pool_id_iv4;
int pool_id_iv6;
pdu_session_type_t pdu_session_type;
} dnn[SMF_NUM_DNN_MAX];
int num_ue_pool;
#define SMF_NUM_UE_POOL_MAX 96
struct in_addr ue_pool_range_low[SMF_NUM_UE_POOL_MAX];
struct in_addr ue_pool_range_high[SMF_NUM_UE_POOL_MAX];
struct in_addr ue_pool_network[SMF_NUM_UE_POOL_MAX];
struct in_addr ue_pool_netmask[SMF_NUM_UE_POOL_MAX];
// computed from config, UE IP adresses that matches
// ue_pool_network[]/ue_pool_netmask[] but do not match ue_pool_range_low[] -
// ue_pool_range_high[]
// The problem here is that OpenFlow do not deal with ip ranges but with
// netmasks
std::vector<struct in_addr> ue_pool_excluded[SMF_NUM_UE_POOL_MAX];
int num_paa6_pool;
struct in6_addr paa_pool6_prefix[SMF_NUM_UE_POOL_MAX];
uint8_t paa_pool6_prefix_len[SMF_NUM_UE_POOL_MAX];
std::map<std::string, dnn_t> dnns;
bool force_push_pco;
uint ue_mtu;
......@@ -281,33 +271,12 @@ class smf_config {
uint8_t num_session_management_subscription;
smf_config()
: m_rw_lock(),
num_dnn(0),
pid_dir(),
instance(0),
n4(),
sbi(),
itti(),
upfs() {
for (int i = 0; i < SMF_NUM_DNN_MAX; i++) {
dnn[i] = {};
}
: m_rw_lock(), pid_dir(), instance(0), n4(), sbi(), itti(), upfs() {
default_dnsv4.s_addr = INADDR_ANY;
default_dns_secv4.s_addr = INADDR_ANY;
default_dnsv6 = in6addr_any;
default_dns_secv6 = in6addr_any;
num_ue_pool = 0;
num_paa6_pool = 0;
for (int i = 0; i < SMF_NUM_UE_POOL_MAX; i++) {
ue_pool_range_low[i] = {};
ue_pool_range_high[i] = {};
ue_pool_network[i] = {};
ue_pool_netmask[i] = {};
paa_pool6_prefix[i] = {};
paa_pool6_prefix_len[i] = {};
ue_pool_excluded[i] = {};
}
force_push_pco = true;
ue_mtu = 1358;
......
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