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

remove unncessary files/functions/variables

parent 9b5d9a80
......@@ -18,7 +18,6 @@ SMF_CONF[@INSTANCE@]=$INSTANCE
SMF_CONF[@PREFIX@]=$PREFIX
SMF_CONF[@PID_DIRECTORY@]='/var/run'
SMF_CONF[@SGW_INTERFACE_NAME_FOR_S11@]='eno1:s11'
SMF_CONF[@SGW_INTERFACE_NAME_FOR_S5_S8_CP@]='eno1:s5c'
SMF_CONF[@PGW_INTERFACE_NAME_FOR_S5_S8_CP@]='eno1:p5c'
SMF_CONF[@PGW_INTERFACE_NAME_FOR_SX@]='eno1:sxc'
SMF_CONF[@DEFAULT_DNS_IPV4_ADDRESS@]='8.8.8.8'
......
......@@ -18,82 +18,6 @@
# For more information about the OpenAirInterface (OAI) Software Alliance:
# contact@openairinterface.org
################################################################################
S-GW =
{
INSTANCE = @INSTANCE@; # 0 is the default
PID_DIRECTORY = "@PID_DIRECTORY@"; # /var/run is the default
#ITTI_TASKS :
#{
#ITTI_TIMER_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 85;
#};
#S11_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#S5S8_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#SX_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#SGW_APP_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#ASYNC_CMD_SCHED_PARAMS :
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 84;
#};
#};
INTERFACES :
{
S11_CP :
{
# S-GW binded interface for S11 communication (GTPV2-C), if none selected the ITTI message interface is used
INTERFACE_NAME = "@SGW_INTERFACE_NAME_FOR_S11@"; # STRING, interface name, YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read"; # STRING, CIDR or "read" to let app read interface configured IP address, YOUR NETWORK CONFIG HERE
#PORT = 2123; # INTEGER, port number, PREFER NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING
#SCHED_PARAMS : # SCHEADULING PARAMS OF THE LOOPING RECEIVER THREAD BOUND TO THIS INTERFACE/PROTOCOL
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 95;
#};
};
S5_S8_CP :
{
# S-GW binded interface for S5 or S8 communication
INTERFACE_NAME = "@SGW_INTERFACE_NAME_FOR_S5_S8_CP@"; # STRING, interface name
IPV4_ADDRESS = "read"; # STRING, CIDR or "read" to let app read interface configured IP address
#PORT = 2123; # INTEGER, port number, PREFER NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING
#SCHED_PARAMS : # SCHEADULING PARAMS OF THE LOOPING RECEIVER THREAD BOUND TO THIS INTERFACE/PROTOCOL
#{
#CPU_ID = 1;
#SCHED_POLICY = "SCHED_FIFO"; # Values in { SCHED_OTHER, SCHED_IDLE, SCHED_BATCH, SCHED_FIFO, SCHED_RR }
#SCHED_PRIORITY = 95;
#};
};
};
};
P-GW =
{
INSTANCE = @INSTANCE@; # 0 is the default
......@@ -196,7 +120,7 @@ P-GW =
{APN_NI = "apn1"; PDN_TYPE = "IPv4"; IPV4_POOL = 1; IPV6_POOL = -1},
{APN_NI = "apn2"; PDN_TYPE = "IPv4"; IPV4_POOL = 2; IPV6_POOL = -1},
{APN_NI = "apn3"; PDN_TYPE = "IPv4"; IPV4_POOL = 3; IPV6_POOL = -1},
{APN_NI = "apn2"; PDN_TYPE = "IPv4"; IPV4_POOL = 4; IPV6_POOL = -1}
{APN_NI = "apn4"; PDN_TYPE = "IPv4"; IPV4_POOL = 4; IPV6_POOL = -1}
);
# DNS address communicated to UEs
......
......@@ -100,7 +100,7 @@ extern "C" {
#define PDU_SESSION_RELEASE_COMMAND 0b11010011
#define PDU_SESSION_RELEASE_COMPLETE 0b11010100
#define _5GSM_STAUS 0b11010110
#define _5GSM_STATUS 0b11010110
......
......@@ -119,7 +119,7 @@ sm_msg_decode (
case PDU_SESSION_RELEASE_COMPLETE:
decode_result = decode_pdu_session_release_complete(&msg->specific_msg.pdu_session_release_complete, buffer, len);
break;
case _5GSM_STAUS:
case _5GSM_STATUS:
decode_result = decode__5gsm_status(&msg->specific_msg._5gsm_status, buffer, len);
break;
......@@ -235,7 +235,7 @@ fivegsm_msg_encode (
case PDU_SESSION_RELEASE_COMPLETE:
encode_result = encode_pdu_session_release_complete(&msg->specific_msg.pdu_session_release_complete, buffer, len);
break;
case _5GSM_STAUS:
case _5GSM_STATUS:
encode_result = encode__5gsm_status(&msg->specific_msg._5gsm_status, buffer, len);
break;
......
......@@ -84,29 +84,33 @@ int pgw_app::apply_config (const smf_config& cfg)
}
//------------------------------------------------------------------------------
teid_t pgw_app::generate_s5s8_cp_teid() {
std::unique_lock<std::mutex> ls(m_s5s8_cp_teid_generator);
teid_t teid = ++teid_s5s8_cp_generator;
while ((is_s5s8c_teid_exist(teid)) || (teid == UNASSIGNED_TEID)) {
teid = ++teid_s5s8_cp_generator;
uint64_t pgw_app::generate_seid() {
std::unique_lock<std::mutex> ls(m_seid_n4_generator);
uint64_t seid = ++seid_n4_generator;
while ((is_seid_n4_exist(seid)) || (seid == UNASSIGNED_SEID)) {
seid = ++seid_n4_generator;
}
s5s8cplteid.insert(teid);
set_seid_n4.insert(seid);
ls.unlock();
return teid;
return seid;
}
//------------------------------------------------------------------------------
bool pgw_app::is_s5s8c_teid_exist(const teid_t& teid_s5s8_cp) const
bool pgw_app::is_seid_n4_exist(const uint64_t& seid) const
{
return bool{s5s8cplteid.count(teid_s5s8_cp) > 0};
return bool{set_seid_n4.count(seid) > 0};
}
//------------------------------------------------------------------------------
void pgw_app::free_s5s8c_teid(const teid_t& teid_s5s8_cp)
void pgw_app::free_seid_n4(const uint64_t& seid)
{
s5s8cplteid.erase (teid_s5s8_cp); // can return value of erase
std::unique_lock<std::mutex> ls(m_seid_n4_generator);
set_seid_n4.erase (seid);
ls.unlock();
}
//------------------------------------------------------------------------------
bool pgw_app::is_imsi64_2_pgw_context(const imsi64_t& imsi64) const
{
......@@ -143,54 +147,6 @@ bool pgw_app::seid_2_pgw_context(const seid_t& seid, std::shared_ptr<pgw_context
return false;
}
//------------------------------------------------------------------------------
fteid_t pgw_app::build_s5s8_cp_fteid(const struct in_addr ipv4_address, const teid_t teid)
{
fteid_t fteid = {};
fteid.interface_type = S5_S8_PGW_GTP_C;
fteid.v4 = 1;
fteid.ipv4_address = ipv4_address;
fteid.v6 = 0;
fteid.ipv6_address = in6addr_any;
fteid.teid_gre_key = teid;
return fteid;
}
//------------------------------------------------------------------------------
fteid_t pgw_app::generate_s5s8_cp_fteid(const struct in_addr ipv4_address)
{
teid_t teid = generate_s5s8_cp_teid();
return build_s5s8_cp_fteid(ipv4_address, teid);
}
//------------------------------------------------------------------------------
void pgw_app::free_s5s8_cp_fteid(const fteid_t& fteid)
{
std::unique_lock lock(m_s5s8lteid2pgw_context);
s5s8lteid2pgw_context.erase(fteid.teid_gre_key);
free_s5s8c_teid(fteid.teid_gre_key);
}
//------------------------------------------------------------------------------
bool pgw_app::is_s5s8cpgw_fteid_2_pgw_context(const fteid_t& ls5s8_fteid) const
{
std::shared_lock lock(m_s5s8lteid2pgw_context);
return bool{s5s8lteid2pgw_context.count(ls5s8_fteid.teid_gre_key) > 0};
}
//------------------------------------------------------------------------------
std::shared_ptr<pgw_context> pgw_app::s5s8cpgw_fteid_2_pgw_context(fteid_t& ls5s8_fteid)
{
if (is_s5s8cpgw_fteid_2_pgw_context(ls5s8_fteid)) {
return s5s8lteid2pgw_context.at(ls5s8_fteid.teid_gre_key);
} else {
return std::shared_ptr<pgw_context>(nullptr);
}
}
//------------------------------------------------------------------------------
void pgw_app::set_s5s8cpgw_fteid_2_pgw_context(fteid_t& ls5s8_fteid, std::shared_ptr<pgw_context> spc)
{
std::unique_lock lock(m_s5s8lteid2pgw_context);
s5s8lteid2pgw_context[ls5s8_fteid.teid_gre_key] = spc;
}
//------------------------------------------------------------------------------
void pgw_app::delete_pgw_context(std::shared_ptr<pgw_context> spc)
{
......@@ -257,14 +213,12 @@ void pgw_app_task (void*)
}
//------------------------------------------------------------------------------
pgw_app::pgw_app (const std::string& config_file) : m_s5s8_cp_teid_generator(), m_imsi2pgw_context(), m_s5s8lteid2pgw_context(), m_seid2pgw_context()
pgw_app::pgw_app (const std::string& config_file) : m_imsi2pgw_context(), m_seid2pgw_context()
{
Logger::pgwc_app().startup("Starting...");
teid_s5s8_cp_generator = 0;
imsi2pgw_context = {};
s5s8lteid2pgw_context = {};
s5s8cplteid = {};
set_seid_n4 = {};
apply_config (smf_cfg);
......
......@@ -49,26 +49,22 @@
namespace pgwc {
//typedef std::pair<shared_ptr<pgw_context>,shared_ptr<pgw_pdn_connection>> zzz;
class smf_config; // same namespace
class pgw_app {
private:
std::thread::id thread_id;
std::thread thread;
// teid generators (linear)
teid_t teid_s5s8_cp_generator;
//seid generator
uint64_t seid_n4_generator;
std::mutex m_seid_n4_generator;
std::set<uint64_t> set_seid_n4;
std::map<imsi64_t, std::shared_ptr<pgw_context>> imsi2pgw_context;
std::map<teid_t, std::shared_ptr<pgw_context>> s5s8lteid2pgw_context;
std::map<seid_t, std::shared_ptr<pgw_context>> seid2pgw_context;
std::set<teid_t> s5s8cplteid;
std::mutex m_s5s8_cp_teid_generator;
mutable std::shared_mutex m_imsi2pgw_context;
mutable std::shared_mutex m_s5s8lteid2pgw_context;
mutable std::shared_mutex m_seid2pgw_context;
//for SMF
......@@ -78,15 +74,6 @@ private:
int apply_config(const smf_config& cfg);
teid_t generate_s5s8_cp_teid();
void free_s5s8c_teid(const teid_t& teid_s5s8_cp);
bool is_s5s8c_teid_exist(const teid_t& teid_s5s8_cp) const;
//teid_t generate_s5s8_up_teid();
//void free_s5s8u_teid(const teid_t& teid_s5s8_up);
//bool is_s5s8u_teid_exist(teid_t& teid_s5s8_up);
// s5s8crteid2pgw_eps_bearer_context collection
bool is_s5s8cpgw_fteid_2_pgw_context(const fteid_t& ls5s8_fteid) const;
bool is_imsi64_2_pgw_context(const imsi64_t& imsi64) const;
std::shared_ptr<pgw_context> imsi64_2_pgw_context(const imsi64_t& imsi64) const;
void set_imsi64_2_pgw_context(const imsi64_t& imsi64, std::shared_ptr<pgw_context> pc);
......@@ -103,12 +90,6 @@ public:
pgw_app(pgw_app const&) = delete;
void operator=(pgw_app const&) = delete;
fteid_t build_s5s8_cp_fteid(const struct in_addr ipv4_address, const teid_t teid);
fteid_t generate_s5s8_cp_fteid(const struct in_addr ipv4_address);
void free_s5s8_cp_fteid(const fteid_t& fteid);
void set_s5s8cpgw_fteid_2_pgw_context(fteid_t& rs5s8_fteid, std::shared_ptr<pgw_context> spc);
std::shared_ptr<pgw_context> s5s8cpgw_fteid_2_pgw_context(fteid_t& ls5s8_fteid);
void set_seid_2_pgw_context(const seid_t& seid, std::shared_ptr<pgw_context>& pc);
bool seid_2_pgw_context(const seid_t& seid, std::shared_ptr<pgw_context>& pc) const;
......@@ -133,6 +114,10 @@ public:
void restore_sx_sessions(const seid_t& seid) const;
uint64_t generate_seid();
bool is_seid_n4_exist(const uint64_t& s) const;
void free_seid_n4(const uint64_t& seid);
/*
* Handle PDUSession_CreateSMContextRequest from AMF
* @param [std::shared_ptr<itti_n11_create_sm_context_request>&] Request message
......
......@@ -172,15 +172,20 @@ void pgw_pdn_connection::deallocate_ressources(const std::string& apn)
if (ipv4) {
paa_dynamic::get_instance().release_paa(apn, ipv4_address);
}
pgw_app_inst->free_s5s8_cp_fteid(pgw_fteid_s5_s8_cp);
//pgw_app_inst->free_s5s8_cp_fteid(pgw_fteid_s5_s8_cp);
clear();
}
//------------------------------------------------------------------------------
void pgw_pdn_connection::generate_seid()
{
// DO it simple now:
seid = pgw_fteid_s5_s8_cp.teid_gre_key | (((uint64_t)smf_cfg.instance) << 32);
// seid = pgw_fteid_s5_s8_cp.teid_gre_key | (((uint64_t)smf_cfg.instance) << 32);
}
void pgw_pdn_connection::set_seid(const uint64_t& s){
seid = s;
}
//------------------------------------------------------------------------------
// TODO check if prd_id should be uniq in the (S)PGW-U or in the context of a pdn connection
void pgw_pdn_connection::generate_far_id(pfcp::far_id_t& far_id)
......@@ -216,8 +221,6 @@ std::string pgw_pdn_connection::toString() const
s.append("\tPAA IPv4:\t\t\t").append(conv::toString(ipv4_address)).append("\n");
if (ipv6)
s.append("\tPAA IPv6:\t\t\t").append(conv::toString(ipv6_address)).append("\n");
s.append("\tSGW FTEID S5S8 CP:\t\t").append(sgw_fteid_s5_s8_cp.toString()).append("\n");
s.append("\tPGW FTEID S5S8 CP:\t\t").append(pgw_fteid_s5_s8_cp.toString()).append("\n");
s.append("\tDefault EBI:\t\t\t").append(std::to_string(default_bearer.ebi)).append("\n");
s.append("\tSEID:\t\t\t").append(std::to_string(seid)).append("\n");
for (auto it : eps_bearers) {
......@@ -639,7 +642,7 @@ std::string dnn_context::toString() const
std::string s = {};
s.append("DNN CONTEXT:\n");
s.append("\tIn use:\t\t\t\t").append(std::to_string(in_use)).append("\n");
s.append("\tAPN:\t\t\t\t").append(dnn_in_use).append("\n");
s.append("\tDNN:\t\t\t\t").append(dnn_in_use).append("\n");
//s.append("\tAPN AMBR Bitrate Uplink:\t").append(std::to_string(apn_ambr.br_ul)).append("\n");
//s.append("\tAPN AMBR Bitrate Downlink:\t").append(std::to_string(apn_ambr.br_dl)).append("\n");
for (auto it : pdn_connections) {
......
......@@ -85,6 +85,8 @@ public:
//teid_t pgw_teid_s5_s8_up; // P-GW Tunnel Endpoint Identifier for the GTP Based S5/S8 interface for user plane.
fteid_t pgw_fteid_s5_s8_up;
fteid_t ul_fteid; //Uplink fteid of UPF
bearer_qos_t eps_bearer_qos; // EPS Bearer QoS: ARP, GBR, MBR, QCI.
// NOT NEEDED charging_id // Charging Id: Charging identifier, identifies charging records generated by S-GW and PDN GW.
......@@ -116,8 +118,6 @@ public:
ipv4_address.s_addr = INADDR_ANY;
ipv6_address = in6addr_any;
pdn_type = {};
sgw_fteid_s5_s8_cp = {};
pgw_fteid_s5_s8_cp = {};
default_bearer.ebi = EPS_BEARER_IDENTITY_UNASSIGNED;
seid = 0;
up_fseid = {};
......@@ -182,6 +182,7 @@ public:
void generate_seid();
void set_seid(const uint64_t& seid);
void generate_pdr_id(pfcp::pdr_id_t& pdr_id);
void release_pdr_id(const pfcp::pdr_id_t& pdr_id);
void generate_far_id(pfcp::far_id_t& far_id);
......@@ -194,16 +195,6 @@ public:
struct in_addr ipv4_address; // IP Address(es): IPv4 address and/or IPv6 prefix
struct in6_addr ipv6_address; // IP Address(es): IPv4 address and/or IPv6 prefix
pdn_type_t pdn_type; // IPv4, IPv6, IPv4v6 or Non-IP
// S-GW Address in Use (control plane): The IP address of the S-GW currently used for sending control plane signalling.
// S-GW TEID for S5/S8 (control plane): S-GW Tunnel Endpoint Identifier for the S5/S8 interface for the control plane. (For GTP-based S5/S8 only).
fteid_t sgw_fteid_s5_s8_cp;
// S-GW GRE Key for downlink traffic (user plane): Serving GW assigned GRE Key for the S5/S8 interface for the user plane for downlink traffic.
// (For PMIP-based S5/S8 only).
// P-GW IP address for S5/S8 (control plane): P-GW IP address for the S5/S8 for the control plane signalling.
// P-GW TEID for S5/S8 (control plane): P-GW Tunnel Endpoint Identifier for the S5/S8 control plane interface. (For GTP-based S5/S8 only).
fteid_t pgw_fteid_s5_s8_cp;
// P-GW Address in Use (user plane): The IP address of the P-GW currently used for sending user plane traffic. (For PMIP-based S5/S8 only).
// P-GW GRE Key for uplink traffic (user plane): PDN GW assigned GRE Key for the S5/S8 interface for the user plane for uplink traffic.
// (For PMIP-based S5/S8 only).
// MS Info Change Reporting support indication: The MME and/or SGSN serving the UE support(s) procedures for reporting User Location Information
// and/or User CSG Information.
......
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