Commit b3f1548f authored by gauthier's avatar gauthier

PFCP Added pdr_id and far_id generators (removed hardcoded ebi2pdr_id/far_id() methods)

parent ae2d43c0
......@@ -734,6 +734,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 +1148,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 {
......
......@@ -160,20 +160,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);
}
//------------------------------------------------------------------------------
......
......@@ -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;
};
......
......@@ -44,30 +44,6 @@ extern itti_mw *itti_inst;
extern pgwc::pgw_app *pgw_app_inst;
extern pgwc::pgw_config pgw_cfg;
//------------------------------------------------------------------------------
#define EBI2PDR_ID_DL_BEARER true
#define EBI2PDR_ID_UL_BEARER false
// TODO better than this (uid generator)?
void pgwc::ebi2pdr_id(const ebi_t& ebi, pfcp::pdr_id_t& pdr_id, const bool is_dl_bearer)
{
if (is_dl_bearer) {
pdr_id.rule_id = (2 * ebi.ebi) | 0x2000;
} else {
pdr_id.rule_id = (2 * ebi.ebi) | 0x1000;
}
}
//------------------------------------------------------------------------------
#define EBI2FAR_ID_DL_BEARER true
#define EBI2FAR_ID_UL_BEARER false
// TODO better than this (uid generator)?
void pgwc::ebi2far_id(const ebi_t& ebi, pfcp::far_id_t& far_id, const bool is_dl_bearer)
{
if (is_dl_bearer) {
far_id.far_id = (2 * ebi.ebi) | 0x00022000;
} else {
far_id.far_id = (2 * ebi.ebi) + 1 | 0x00011000;
}
}
//------------------------------------------------------------------------------
int sx_session_restore_procedure::run()
{
......@@ -165,8 +141,7 @@ int session_establishment_procedure::run(std::shared_ptr<itti_s5s8_create_sessio
//pfcp::traffic_endpoint_id_t linked_traffic_endpoint_id_t = {};
//pfcp::proxying_t proxying = {};
// DOIT simple ?
ebi2far_id(it.eps_bearer_id, far_id, EBI2FAR_ID_UL_BEARER);
ppc->generate_far_id(far_id);
apply_action.forw = 1;
destination_interface.interface_value = pfcp::INTERFACE_VALUE_CORE; // ACCESS is for downlink, CORE for uplink
......@@ -207,7 +182,7 @@ int session_establishment_procedure::run(std::shared_ptr<itti_s5s8_create_sessio
// DOIT simple
// shall uniquely identify the PDR among all the PDRs configured for that PFCP session.
ebi2pdr_id(it.eps_bearer_id, pdr_id, EBI2PDR_ID_UL_BEARER);
ppc->generate_pdr_id(pdr_id);
precedence.precedence = it.bearer_level_qos.pl;
pdi.set(source_interface);
......@@ -263,48 +238,22 @@ void session_establishment_procedure::handle_itti_msg (itti_sxab_session_establi
for (auto it : resp.pfcp_ies.created_pdrs) {
pfcp::pdr_id_t pdr_id = {};
pfcp::far_id_t far_id = {};
if (it.get(pdr_id)) {
pgw_eps_bearer b = {};
if (not ppc->get_eps_bearer(pdr_id, b)) {
bearer_context_found = false;
for (auto it : s5_trigger->gtp_ies.bearer_contexts_to_be_created) {
pfcp::pdr_id_t conv_pdr_id;
ebi2pdr_id(it.eps_bearer_id, conv_pdr_id, EBI2PDR_ID_UL_BEARER);
if (conv_pdr_id.rule_id == pdr_id.rule_id) {
pfcp::far_id_t far_id = {};
ebi2far_id(it.eps_bearer_id, far_id, EBI2FAR_ID_UL_BEARER);
pfcp::create_far create_far = {};
if (sx_triggered->pfcp_ies.get(far_id, create_far)) {
b.far_id_ul.first = true;
b.far_id_ul.second = far_id;
}
b.ebi = it.eps_bearer_id;
b.tft = it.tft;
b.eps_bearer_qos = it.bearer_level_qos;
b.pdr_id_ul = pdr_id;
bearer_context_found = true;
break;
if (ppc->get_eps_bearer(pdr_id, b)) {
pfcp::fteid_t local_up_fteid = {};
if (bearer_context_found) {
if (it.get(local_up_fteid)) {
xgpp_conv::pfcp_to_core_fteid(local_up_fteid, b.pgw_fteid_s5_s8_up);
b.pgw_fteid_s5_s8_up.interface_type = S5_S8_PGW_GTP_U;
// comment if SPGW-C allocate up fteid
pgw_eps_bearer b2 = b;
ppc->add_eps_bearer(b2);
}
// uncomment if SPGW-C allocate up fteid
// ppc->add_eps_bearer(b);
}
} else {
bearer_context_found = true;
}
pfcp::fteid_t local_up_fteid = {};
if (bearer_context_found) {
if (it.get(local_up_fteid)) {
xgpp_conv::pfcp_to_core_fteid(local_up_fteid, b.pgw_fteid_s5_s8_up);
b.pgw_fteid_s5_s8_up.interface_type = S5_S8_PGW_GTP_U;
// comment if SPGW-C allocate up fteid
pgw_eps_bearer b2 = b;
ppc->add_eps_bearer(b2);
}
// uncomment if SPGW-C allocate up fteid
// ppc->add_eps_bearer(b);
}
} else {
Logger::pgwc_app().error( "Could not get pdr_id for created_pdr in %s", resp.pfcp_ies.get_msg_name());
......@@ -379,7 +328,7 @@ int modify_bearer_procedure::run(std::shared_ptr<itti_s5s8_modify_bearer_request
::fteid_t v = {};
pgw_eps_bearer& peb = ppc->get_eps_bearer(it.eps_bearer_id);
if (peb.ebi.ebi != it.eps_bearer_id.ebi) { // target is to test EPS_BEARER_IDENTITY_UNASSIGNED
if (peb.ebi != it.eps_bearer_id) { // target is to test EPS_BEARER_IDENTITY_UNASSIGNED
// TODO something (bearer not there)
Logger::pgwc_app().error( "modify_bearer_procedure: missing pgw_eps_bearer ebi %d", it.eps_bearer_id.ebi);
::cause_t cause = {};
......@@ -456,8 +405,7 @@ int modify_bearer_procedure::run(std::shared_ptr<itti_s5s8_modify_bearer_request
//pfcp::traffic_endpoint_id_t linked_traffic_endpoint_id_t = {};
//pfcp::proxying_t proxying = {};
// DOIT simple ?
ebi2far_id(it.eps_bearer_id, far_id, EBI2FAR_ID_DL_BEARER);
ppc->generate_far_id(far_id);
apply_action.forw = 1;
destination_interface.interface_value = pfcp::INTERFACE_VALUE_ACCESS; // ACCESS is for downlink, CORE for uplink
......@@ -520,7 +468,7 @@ int modify_bearer_procedure::run(std::shared_ptr<itti_s5s8_modify_bearer_request
// DOIT simple
// shall uniquely identify the PDR among all the PDRs configured for that PFCP session.
ebi2pdr_id(it.eps_bearer_id, pdr_id, EBI2PDR_ID_DL_BEARER);
ppc->generate_pdr_id(pdr_id);
precedence.precedence = peb.eps_bearer_qos.pl;
pdi.set(source_interface);
......@@ -567,8 +515,7 @@ int modify_bearer_procedure::run(std::shared_ptr<itti_s5s8_modify_bearer_request
//pfcp::traffic_endpoint_id_t linked_traffic_endpoint_id_t = {};
//pfcp::proxying_t proxying = {};
// DOIT simple ?
ebi2far_id(it.eps_bearer_id, far_id, EBI2FAR_ID_UL_BEARER);
ppc->generate_far_id(far_id);
apply_action.forw = 1;
destination_interface.interface_value = pfcp::INTERFACE_VALUE_CORE; // ACCESS is for downlink, CORE for uplink
......@@ -619,7 +566,7 @@ int modify_bearer_procedure::run(std::shared_ptr<itti_s5s8_modify_bearer_request
// DOIT simple
// shall uniquely identify the PDR among all the PDRs configured for that PFCP session.
ebi2pdr_id(it.eps_bearer_id, pdr_id, EBI2PDR_ID_UL_BEARER);
ppc->generate_pdr_id(pdr_id);
precedence.precedence = peb.eps_bearer_qos.pl;
pdi.set(source_interface);
......
......@@ -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:
......
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