Commit 92741a25 authored by gauthier's avatar gauthier

Merge SXAB tweaks into develop

parents a1fda70f 323be096
......@@ -176,9 +176,6 @@ P-GW =
# Normally no more than 96 pools allowed, but for non OVS GTP solution, only one pool allowed (TODO).
IP_ADDRESS_POOL :
{
ARP_UE = "@ARP_UE@"; # String, {"no", "linux", 'oai'}, respond to incoming ARP for UE IP addresses on SGi interface
# 'linux' use arp executable (comes with your linux distribution)
# 'oai' can only be used with OVS
IPV4_LIST = (
{RANGE = "12.1.1.2 - 12.1.1.128";}, # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE.
{RANGE = "12.1.1.129 - 12.1.1.224";}, # STRING, IPv4 RANGE IP_start - IP_end, YOUR NETWORK CONFIG HERE.
......@@ -195,11 +192,11 @@ P-GW =
APN_LIST = (
# IPV4_POOL, IPV6_POOL are index in IPV4_LIST, IPV6_LIST, PDN_TYPE choice in {IPv4, IPv6, IPv4v6}
{APN_NI = "default"; PDN_TYPE = "IPv4"; IPV4_POOL = 0; IPV6_POOL = -1; SNAT = "no"},
{APN_NI = "apn1"; PDN_TYPE = "IPv4"; IPV4_POOL = 1; IPV6_POOL = -1; SNAT = "no"},
{APN_NI = "apn2"; PDN_TYPE = "IPv4"; IPV4_POOL = 2; IPV6_POOL = -1; SNAT = "no"},
{APN_NI = "apn3"; PDN_TYPE = "IPv4"; IPV4_POOL = 3; IPV6_POOL = -1; SNAT = "no"},
{APN_NI = "apn2"; PDN_TYPE = "IPv4"; IPV4_POOL = 4; IPV6_POOL = -1; SNAT = "no"}
{APN_NI = "default"; PDN_TYPE = "IPv4"; IPV4_POOL = 0; IPV6_POOL = -1},
{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}
);
# DNS address communicated to UEs
......
......@@ -372,7 +372,7 @@ namespace pfcp {
//-------------------------------------
// 8.2.3 F-TEID
typedef struct fteid_s {
struct fteid_s {
uint8_t chid :1;
uint8_t ch :1;
uint8_t v4 :1;
......@@ -381,8 +381,25 @@ namespace pfcp {
struct in_addr ipv4_address;
struct in6_addr ipv6_address;
uint8_t choose_id;
} fteid_t;
bool operator==(const struct fteid_s& f) const
{
return (teid == f.teid) and
(ipv4_address.s_addr == f.ipv4_address.s_addr) and
(chid == f.chid) and
(ch == f.ch) and
(choose_id == f.choose_id) and
(ipv6_address.s6_addr32[0] == f.ipv6_address.s6_addr32[0]) and
(ipv6_address.s6_addr32[1] == f.ipv6_address.s6_addr32[1]) and
(ipv6_address.s6_addr32[2] == f.ipv6_address.s6_addr32[2]) and
(ipv6_address.s6_addr32[3] == f.ipv6_address.s6_addr32[3]) and
(v4 == f.v4) and
(v6 == f.v6);
}
bool is_zero() const {return ((!v4) and(!v6));}
} ;
typedef struct fteid_s fteid_t;
//-------------------------------------
// 8.2.4 Network Instance
typedef struct network_instance_s {
......@@ -734,6 +751,9 @@ namespace pfcp {
// 8.2.36 Packet Detection Rule ID (PDR ID)
typedef struct pdr_id_s {
uint16_t rule_id;
pdr_id_s() : rule_id(0) {}
pdr_id_s(const uint8_t& p) : rule_id(p) {}
pdr_id_s(const struct pdr_id_s& p) : rule_id(p.rule_id) {}
bool operator==(const struct pdr_id_s& i) const {
return (i.rule_id==rule_id);
};
......@@ -1145,10 +1165,16 @@ namespace pfcp {
//-------------------------------------
// 8.2.74 FAR ID
typedef struct far_id_s {
struct far_id_s {
uint32_t far_id;
} far_id_t;
far_id_s() : far_id(0) {}
far_id_s(const uint8_t& f) : far_id(f) {}
far_id_s(const struct far_id_s& f) : far_id(f.far_id) {}
bool operator==(const struct far_id_s& i) const {
return (i.far_id==far_id);
};
} ;
typedef struct far_id_s far_id_t;
//-------------------------------------
// 8.2.75 QER ID
typedef struct qer_id_s {
......
......@@ -361,7 +361,7 @@ public:
void add_ie(std::shared_ptr<gtpv2c_ie> ie) {
ies.push_back(ie);
std::cout << std::dec<< " add_ie = " << get_message_length() << " -> "<< get_message_length() + gtpv2c_tlv::tlv_ie_length + ie.get()->tlv.get_length() << std::endl;
//std::cout << std::dec<< " add_ie = " << get_message_length() << " -> "<< get_message_length() + gtpv2c_tlv::tlv_ie_length + ie.get()->tlv.get_length() << std::endl;
set_message_length(get_message_length() + gtpv2c_tlv::tlv_ie_length + ie.get()->tlv.get_length());
}
......
......@@ -59,11 +59,11 @@ int pgw_app::apply_config (const pgw_config& cfg)
if (cfg.apn[ia].pool_id_iv4 >= 0) {
int pool_id = cfg.apn[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_dynamic::get_instance().add_pool(cfg.apn[ia].apn, pool_id, cfg.ue_pool_range_low[pool_id], range);
paa_dynamic::get_instance().add_pool(cfg.apn[ia].apn_label, pool_id, cfg.ue_pool_range_low[pool_id], range);
}
if (cfg.apn[ia].pool_id_iv6 >= 0) {
int pool_id = cfg.apn[ia].pool_id_iv6;
paa_dynamic::get_instance().add_pool(cfg.apn[ia].apn, pool_id, cfg.paa_pool6_prefix[pool_id], cfg.paa_pool6_prefix_len[pool_id]);
paa_dynamic::get_instance().add_pool(cfg.apn[ia].apn_label, pool_id, cfg.paa_pool6_prefix[pool_id], cfg.paa_pool6_prefix_len[pool_id]);
}
}
......
......@@ -467,18 +467,6 @@ bool pgw_config::is_dotted_apn_handled(const string& apn, const pdn_type_t& pdn_
}
return false;
}
//------------------------------------------------------------------------------
int pgw_config::get_pa_pool_id(const std::string& apn, int& pool_id_ipv4, int& pool_id_ipv6)
{
for (int i = 0; i < pgw_cfg.num_apn; i++) {
if (0 == apn.compare(pgw_cfg.apn[i].apn_label)) {
pool_id_ipv4 = pgw_cfg.apn[i].pool_id_iv4;
pool_id_ipv6 = pgw_cfg.apn[i].pool_id_iv6;
return RETURNok;
}
}
return RETURNerror;
}
//------------------------------------------------------------------------------
int pgw_config::get_pfcp_node_id(pfcp::node_id_t& node_id)
......
......@@ -231,7 +231,6 @@ public:
int finalize();
void display();
bool is_dotted_apn_handled(const std::string& apn, const pdn_type_t& pdn_type);
int get_pa_pool_id(const std::string& apn, int& pool_id_ipv4, int& pool_id_ipv6);
int get_pfcp_node_id(pfcp::node_id_t& node_id);
int get_pfcp_fseid(pfcp::fseid_t& fseid);
};
......
......@@ -46,8 +46,6 @@ extern pgwc::pgw_config pgw_cfg;
void pgw_eps_bearer::release_access_bearer()
{
released = true;
pdr_id_ul = {};
far_id_ul = {};
}
//------------------------------------------------------------------------------
std::string pgw_eps_bearer::toString() const
......@@ -160,20 +158,27 @@ void pgw_pdn_connection::generate_seid()
}
//------------------------------------------------------------------------------
// 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)
{
far_id.far_id = far_id_generator.get_uid();
}
//------------------------------------------------------------------------------
// 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::release_far_id(const pfcp::far_id_t& far_id)
{
far_id_generator.free_uid(far_id.far_id);
}
//------------------------------------------------------------------------------
// 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_pdr_id(pfcp::pdr_id_t& pdr_id)
{
// make things simple, will write a more robust generator once scope of rule_id will be known
uint16_t r = ++prd_id_generator;
if (r == 0) {
r = ++prd_id_generator;
}
pdr_id.rule_id = r;
pdr_id.rule_id = pdr_id_generator.get_uid();
}
//------------------------------------------------------------------------------
// 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::release_pdr_id(const pfcp::pdr_id_t& pdr_id)
{
// TODO
pdr_id_generator.free_uid(pdr_id.rule_id);
}
//------------------------------------------------------------------------------
......@@ -483,8 +488,8 @@ void pgw_context::handle_itti_msg (std::shared_ptr<itti_s5s8_create_session_requ
// paa.pdn_type = sp->pdn_type;
// bool paa_res = csreq->gtp_ies.get(paa);
// if ((not paa_res) || (not paa.is_ip_assigned())) {
// int ret = paa_dynamic::get_instance().get_free_paa (sa->apn_in_use, paa);
// if (ret == RETURNok) {
// bool success = paa_dynamic::get_instance().get_free_paa (sa->apn_in_use, paa);
// if (success) {
// set_paa = true;
// } else {
// cause.cause_value = PREFERRED_PDN_TYPE_NOT_SUPPORTED;
......@@ -530,8 +535,8 @@ void pgw_context::handle_itti_msg (std::shared_ptr<itti_s5s8_create_session_requ
if (!pco_ids.ci_ipv4_address_allocation_via_dhcpv4) {
bool paa_res = csreq->gtp_ies.get(paa);
if ((not paa_res) || (not paa.is_ip_assigned())) {
int ret = paa_dynamic::get_instance().get_free_paa(sa->apn_in_use, paa);
if (ret == RETURNok) {
bool success = paa_dynamic::get_instance().get_free_paa(sa->apn_in_use, paa);
if (success) {
set_paa = true;
} else {
cause.cause_value = ALL_DYNAMIC_ADDRESSES_ARE_OCCUPIED;
......@@ -547,8 +552,8 @@ void pgw_context::handle_itti_msg (std::shared_ptr<itti_s5s8_create_session_requ
case PDN_TYPE_E_IPV6: {
bool paa_res = csreq->gtp_ies.get(paa);
if ((not paa_res) || (not paa.is_ip_assigned())) {
int ret = paa_dynamic::get_instance().get_free_paa (sa->apn_in_use, paa);
if (ret == RETURNok) {
bool success = paa_dynamic::get_instance().get_free_paa (sa->apn_in_use, paa);
if (success) {
set_paa = true;
} else {
cause.cause_value = ALL_DYNAMIC_ADDRESSES_ARE_OCCUPIED;
......@@ -561,8 +566,8 @@ void pgw_context::handle_itti_msg (std::shared_ptr<itti_s5s8_create_session_requ
case PDN_TYPE_E_IPV4V6: {
bool paa_res = csreq->gtp_ies.get(paa);
if ((not paa_res) || (not paa.is_ip_assigned())) {
int ret = paa_dynamic::get_instance().get_free_paa (sa->apn_in_use, paa);
if (ret == RETURNok) {
bool success = paa_dynamic::get_instance().get_free_paa (sa->apn_in_use, paa);
if (success) {
set_paa = true;
} else {
cause.cause_value = ALL_DYNAMIC_ADDRESSES_ARE_OCCUPIED;
......
......@@ -28,6 +28,7 @@
#ifndef FILE_PGW_EPS_BEARER_CONTEXT_HPP_SEEN
#define FILE_PGW_EPS_BEARER_CONTEXT_HPP_SEEN
#include <map>
#include <mutex>
#include <memory>
#include <shared_mutex>
......@@ -39,6 +40,7 @@
#include "common_root_types.h"
#include "itti_msg_s5s8.hpp"
#include "pgwc_procedure.hpp"
#include "uint_generator.hpp"
namespace pgwc {
......@@ -176,6 +178,8 @@ public:
void generate_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);
void release_far_id(const pfcp::far_id_t& far_id);
void create_procedure(itti_s5s8_create_session_response& m);
void insert_procedure(pgw_procedure* proc);
......@@ -227,8 +231,8 @@ public:
uint64_t seid;
pfcp::fseid_t up_fseid;
//
uint16_t prd_id_generator;
util::uint_generator<uint16_t> pdr_id_generator;
util::uint_generator<uint32_t> far_id_generator;
};
......
......@@ -29,6 +29,8 @@
#ifndef FILE_PGW_PAA_DYNAMIC_HPP_SEEN
#define FILE_PGW_PAA_DYNAMIC_HPP_SEEN
#include "logger.hpp"
#include <map>
#include <bitset>
......@@ -185,7 +187,7 @@ public:
paa_dynamic(paa_dynamic const&) = delete;
void operator=(paa_dynamic const&) = delete;
void add_pool(const std::string& apn, const int pool_id, const struct in_addr& first, const int range)
void add_pool(const std::string& apn_label, const int pool_id, const struct in_addr& first, const int range)
{
if (pool_id >= 0) {
uint32_t uint32pool_id = uint32_t(pool_id);
......@@ -193,15 +195,15 @@ public:
ipv4_pool pool(first, range);
ipv4_pools[uint32pool_id] = pool;
}
if (!apns.count(apn)) {
if (!apns.count(apn_label)) {
apn_dynamic_pools adp = {};
adp.add_ipv4_pool_id(uint32pool_id);
apns[apn] = adp;
apns[apn_label] = adp;
}
}
}
void add_pool(const std::string& apn, const int pool_id, const struct in6_addr& prefix, const int prefix_len)
void add_pool(const std::string& apn_label, const int pool_id, const struct in6_addr& prefix, const int prefix_len)
{
if (pool_id >= 0) {
uint32_t uint32pool_id = uint32_t(pool_id);
......@@ -209,10 +211,10 @@ public:
ipv6_pool pool(prefix, prefix_len);
ipv6_pools[uint32pool_id] = pool;
}
if (!apns.count(apn)) {
if (!apns.count(apn_label)) {
apn_dynamic_pools adp = {};
adp.add_ipv6_pool_id(uint32pool_id);
apns[apn] = adp;
apns[apn_label] = adp;
}
}
}
......@@ -227,6 +229,7 @@ public:
return true;
}
}
Logger::pgwc_app().warn("Could not get PAA PDN_TYPE_E_IPV4 for APN %s", apn_label.c_str());
return false;
} else if (paa.pdn_type.pdn_type == PDN_TYPE_E_IPV4V6) {
bool success = false;
......@@ -244,6 +247,7 @@ public:
}
ipv4_pools[*it4].free_address(paa.ipv4_address);
}
Logger::pgwc_app().warn("Could not get PAA PDN_TYPE_E_IPV4V6 for APN %s", apn_label.c_str());
return false;
} else if (paa.pdn_type.pdn_type == PDN_TYPE_E_IPV6) {
for (std::vector<uint32_t>::const_iterator it6 = apn_pool.ipv6_pool_ids.begin();it6 != apn_pool.ipv6_pool_ids.end(); ++it6) {
......@@ -251,11 +255,14 @@ public:
return true;
}
}
Logger::pgwc_app().warn("Could not get PAA PDN_TYPE_E_IPV6 for APN %s", apn_label.c_str());
return false;
}
}
Logger::pgwc_app().warn("Could not get PAA for APN %s", apn_label.c_str());
return false;
}
bool release_paa(const std::string& apn_label, const paa_t& paa)
{
if (apns.count(apn_label)) {
......@@ -280,6 +287,7 @@ public:
return true;
}
}
Logger::pgwc_app().warn("Could not release PAA for APN %s", apn_label.c_str());
return false;
}
......@@ -293,6 +301,7 @@ public:
}
}
}
Logger::pgwc_app().warn("Could not release PAA for APN %s", apn_label.c_str());
return false;
}
......
This diff is collapsed.
......@@ -47,9 +47,6 @@ class apn_context;
class pgw_context;
class pgw_pdn_connection;
void ebi2pdr_id(const ebi_t& ebi, pfcp::pdr_id_t& pdr_id, const bool is_dl_bearer);
void ebi2far_id(const ebi_t& ebi, pfcp::far_id_t& far_id, const bool is_dl_bearer);
//------------------------------------------------------------------------------
class pgw_procedure {
private:
......
......@@ -670,6 +670,9 @@ void pfcp_switch::handle_pfcp_session_modification_request(std::shared_ptr<itti_
}
pfcp::created_pdr created_pdr = {};
created_pdr.set(cr_pdr.pdr_id.second);
if (not allocated_fteid.is_zero()) {
created_pdr.set(allocated_fteid);
}
resp->pfcp_ies.set(created_pdr);
}
}
......
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