Commit 6dd054cf authored by gauthier's avatar gauthier

sgwc

parent 339f4777
This diff is collapsed.
/*
* 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 sgwc_app.hpp
\author Lionel GAUTHIER
\date 2018
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_SGWC_APP_HPP_SEEN
#define FILE_SGWC_APP_HPP_SEEN
#include "common_root_types.h"
#include "itti_msg_s11.hpp"
#include "itti_msg_s5s8.hpp"
#include "sgwc_eps_bearer_context.hpp"
#include <boost/atomic.hpp>
#include <map>
#include <string>
#include <thread>
#include <memory>
#include <map>
#include <set>
namespace oai::cn::nf::sgwc {
class sgwc_app {
private:
std::thread::id thread_id;
std::thread thread;
// teid generators (linear)
boost::atomic<teid_t> teid_s11_cp;
boost::atomic<teid_t> teid_s5s8_cp;
/* There shall be only one pair of TEID-C per UE over the S11 and the S4 interfaces. The same tunnel shall be
shared for the control messages related to the same UE operation. A TEID-C on the S11/S4 interface shall be
released after all its associated EPS bearers are deleted.*/
std::map<imsi64_t, std::shared_ptr<sgw_eps_bearer_context>> imsi2sgw_eps_bearer_context;
std::map<teid_t, std::shared_ptr<sgw_eps_bearer_context>> s11lteid2sgw_eps_bearer_context;
std::map<teid_t, std::pair<std::shared_ptr<sgw_eps_bearer_context>, std::shared_ptr<sgw_pdn_connection>>> s5s8lteid2sgw_contexts;
teid_t generate_s11_cp_teid();
bool is_s11c_teid_exist(const teid_t& teid_s11_cp) const;
bool is_s5s8sgw_teid_2_sgw_contexts(const teid_t& sgw_teid) const;
// s11lteid2sgw_eps_bearer_context collection
bool is_s11sgw_teid_2_sgw_eps_bearer_context(const teid_t& sgw_teid) const;
bool is_imsi64_2_sgw_eps_bearer_context(const imsi64_t& imsi64) const;
void set_imsi64_2_sgw_eps_bearer_context(const imsi64_t& imsi64, std::shared_ptr<sgw_eps_bearer_context> sebc);
teid_t generate_s5s8_cp_teid();
bool is_s5s8c_teid_exist(const teid_t& teid_s5s8_cp)const;
bool is_s5s8u_teid_exist(const teid_t& teid_s5s8_up) const;
public:
// key is S11 S-GW local teid, value is S11 tunnel id pair
// map<teid_t, int> s11teid2mme_hashtable;
// key is paa, value is S11 s-gw local teid
//obj_hash_table_uint64_t *ip2s11teid;
// key is S1-U S-GW local teid
////hash_table_t *s1uteid2enb_hashtable;
// the key of this hashtable is the S11 s-gw local teid.
//hash_table_ts_t *s11_bearer_context_information_hashtable;
/* The TEID-C shall be unique per PDN-Connection on GTP based S2a, S2b, S5 and S8 interfaces. The same
tunnel shall be shared for the control messages related to all bearers associated to
the PDN-Connection. A TEID-C on the S2a/S2b/S5/S8 interface shall be released after all its associated EPS bearers are deleted. */
//gtpv1u_data_t gtpv1u_data;
sgwc_app(const std::string& config_file);
~sgwc_app();
sgwc_app(sgwc_app const&) = delete;
void operator=(sgwc_app const&) = delete;
core::fteid_t generate_s5s8_cp_fteid(const struct in_addr ipv4_address);
core::fteid_t generate_s11_cp_fteid(const struct in_addr ipv4_address);
std::pair<std::shared_ptr<sgw_eps_bearer_context>, std::shared_ptr<sgw_pdn_connection>> s5s8sgw_teid_2_sgw_contexts(const teid_t& sgw_teid) const;
std::shared_ptr<sgw_eps_bearer_context> s11sgw_teid_2_sgw_eps_bearer_context(const teid_t& sgw_teid) const;
void set_s11sgw_teid_2_sgw_eps_bearer_context(const teid_t& sgw_teid, std::shared_ptr<sgw_eps_bearer_context> sebc);
void delete_sgw_eps_bearer_context(std::shared_ptr<sgw_eps_bearer_context> sebc);
std::shared_ptr<sgw_eps_bearer_context> imsi64_2_sgw_eps_bearer_context(const imsi64_t& imsi64) const;
void set_s5s8sgw_teid_2_sgw_contexts(const teid_t& sgw_teid, std::shared_ptr<sgw_eps_bearer_context> sebc, std::shared_ptr<sgw_pdn_connection> spc);
void handle_itti_msg (core::itti::itti_s11_create_session_request& m);
void handle_itti_msg (core::itti::itti_s11_delete_session_request& m);
void handle_itti_msg (core::itti::itti_s11_modify_bearer_request& m);
void handle_itti_msg (core::itti::itti_s11_release_access_bearers_request& m);
void handle_itti_msg (core::itti::itti_s5s8_create_session_response& m);
void handle_itti_msg (core::itti::itti_s5s8_delete_session_response& m);
void handle_itti_msg (core::itti::itti_s5s8_modify_bearer_response& m);
void handle_itti_msg (core::itti::itti_s5s8_release_access_bearers_response& m);
};
}
#endif /* FILE_SGWC_APP_HPP_SEEN */
/*
* 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 sSGW_CONFIG.cpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#include "async_shell_cmd.hpp"
#include "common_defs.h"
#include "if.hpp"
#include "logger.hpp"
#include "sgwc_config.hpp"
#include "string.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <cstdlib>
#include <iomanip>
#include <iostream>
using namespace std;
using namespace libconfig;
using namespace oai::cn::nf::sgwc;
// C includes
#include <arpa/inet.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
//------------------------------------------------------------------------------
int sgwc_config::execute ()
{
return RETURNok;
}
//------------------------------------------------------------------------------
int sgwc_config::load_interface(const Setting& if_cfg, interface_cfg_t& cfg)
{
if_cfg.lookupValue(SGWC_CONFIG_STRING_INTERFACE_NAME, cfg.if_name);
util::trim(cfg.if_name);
if (not boost::iequals(cfg.if_name, "none")) {
std::string address = {};
if_cfg.lookupValue(SGWC_CONFIG_STRING_IPV4_ADDRESS, address);
util::trim(address);
if (boost::iequals(address, "read")) {
if (get_inet_addr_infos_from_iface(cfg.if_name, cfg.addr4, cfg.network4, cfg.mtu)) {
Logger::sgwc_app().error("Could not read %s network interface configuration", cfg.if_name);
return RETURNerror;
}
} else {
std::vector<std::string> words;
boost::split(words, address, boost::is_any_of("/"), boost::token_compress_on);
if (words.size() != 2) {
Logger::sgwc_app().error("Bad value " SGWC_CONFIG_STRING_IPV4_ADDRESS " = %s in config file", address.c_str());
return RETURNerror;
}
unsigned char buf_in_addr[sizeof(struct in6_addr)]; // you never know...
if (inet_pton (AF_INET, util::trim(words.at(0)).c_str(), buf_in_addr) == 1) {
memcpy (&cfg.addr4, buf_in_addr, sizeof (struct in_addr));
} else {
Logger::sgwc_app().error("In conversion: Bad value " SGWC_CONFIG_STRING_IPV4_ADDRESS " = %s in config file", util::trim(words.at(0)).c_str());
return RETURNerror;
}
cfg.network4.s_addr = htons(ntohs(cfg.addr4.s_addr) & 0xFFFFFFFF << (32 - std::stoi (util::trim(words.at(1)))));
}
if_cfg.lookupValue(SGWC_CONFIG_STRING_PORT, cfg.port);
}
return RETURNok;
}
//------------------------------------------------------------------------------
int sgwc_config::load(const string& config_file)
{
Config cfg;
// Read the file. If there is an error, report it and exit.
try
{
cfg.readFile(config_file.c_str());
}
catch(const FileIOException &fioex)
{
Logger::sgwc_app().error("I/O error while reading file %s - %s", config_file.c_str(), fioex.what());
throw fioex;
}
catch(const ParseException &pex)
{
Logger::sgwc_app().error("Parse error at %s:%d - %s", pex.getFile(), pex.getLine(), pex.getError());
throw pex;
}
const Setting& root = cfg.getRoot();
try
{
const Setting& sgw_cfg = root[SGWC_CONFIG_STRING_SGW_CONFIG];
sgw_cfg.lookupValue(SGWC_CONFIG_STRING_INSTANCE, instance);
sgw_cfg.lookupValue(SGWC_CONFIG_STRING_PID_DIRECTORY, pid_dir);
util::trim(pid_dir);
const Setting& nw_if_cfg = sgw_cfg[SGWC_CONFIG_STRING_INTERFACES];
const Setting& s11_cp_cfg = nw_if_cfg[SGWC_CONFIG_STRING_INTERFACE_S11_CP];
load_interface(s11_cp_cfg, s11_cp);
const Setting& s5s8_cp_cfg = nw_if_cfg[SGWC_CONFIG_STRING_INTERFACE_S5_S8_CP];
load_interface(s5s8_cp_cfg, s5s8_cp);
}
catch(const SettingNotFoundException &nfex)
{
Logger::sgwc_app().error("%s : %s", nfex.what(), nfex.getPath());
return RETURNerror;
}
return RETURNok;
}
//------------------------------------------------------------------------------
void sgwc_config::display ()
{
Logger::sgwc_app().info("==== EURECOM %s v%s ====", PACKAGE_NAME, PACKAGE_VERSION);
Logger::sgwc_app().info( "Configuration:");
//Logger::sgwc_app().info( "- Instance ..............: %s", instance);
//Logger::sgwc_app().info( "- PID dir ...............: %s", pid_dir.c_str());
Logger::sgwc_app().info( "- S5_S8-C:");
Logger::sgwc_app().info( " iface ............: %s", s5s8_cp.if_name.c_str());
Logger::sgwc_app().info( " ipv4.addr ........: %s", inet_ntoa (s5s8_cp.addr4));
Logger::sgwc_app().info( " ipv4.mask ........: %s", inet_ntoa (s5s8_cp.network4));
Logger::sgwc_app().info( " port .............: %d", s5s8_cp.port);
Logger::sgwc_app().info( "- S11-C:");
Logger::sgwc_app().info( " iface ............: %s", s11_cp.if_name.c_str());
Logger::sgwc_app().info( " ipv4.addr ........: %s", inet_ntoa (s11_cp.addr4));
Logger::sgwc_app().info( " ipv4.mask ........: %s", inet_ntoa (s11_cp.network4));
Logger::sgwc_app().info( " port .............: %u", s11_cp.port);
}
/*
* 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 sgwc_config.hpp
* \brief
* \author Lionel Gauthier
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_SGWC_CONFIG_HPP_SEEN
#define FILE_SGWC_CONFIG_HPP_SEEN
#include <libconfig.h++>
#include <mutex>
#include <netinet/in.h>
#include <stdint.h>
#include <stdbool.h>
namespace oai::cn::nf::sgwc {
#define SGWC_CONFIG_STRING_SGW_CONFIG "S-GW"
#define SGWC_CONFIG_STRING_PID_DIRECTORY "PID_DIRECTORY"
#define SGWC_CONFIG_STRING_INSTANCE "INSTANCE"
#define SGWC_CONFIG_STRING_INTERFACES "INTERFACES"
#define SGWC_CONFIG_STRING_INTERFACE_NAME "INTERFACE_NAME"
#define SGWC_CONFIG_STRING_IPV4_ADDRESS "IPV4_ADDRESS"
#define SGWC_CONFIG_STRING_PORT "PORT"
#define SGWC_CONFIG_STRING_INTERFACE_S11_CP "S11_CP"
#define SGWC_CONFIG_STRING_INTERFACE_S11_UP "S11_UP"
#define SGWC_CONFIG_STRING_INTERFACE_S5_S8_CP "S5_S8_CP"
#define SPGW_ABORT_ON_ERROR true
#define SPGW_WARN_ON_ERROR false
typedef struct interface_cfg_s {
std::string if_name;
struct in_addr addr4;
struct in_addr network4;
struct in6_addr addr6;
unsigned int mtu;
unsigned int port;
} interface_cfg_t;
class sgwc_config {
private:
int load_interface(const libconfig::Setting& if_cfg, interface_cfg_t& cfg);
public:
/* Reader/writer lock for this configuration */
std::mutex m_rw_lock;
std::string pid_dir;
unsigned int instance;
interface_cfg_t s11_cp;
interface_cfg_t s11_up;
interface_cfg_t s5s8_cp;
//interface_cfg_t sxa;
bool local_to_eNB;
sgwc_config() : m_rw_lock(), pid_dir(), instance(0), s11_cp(), s11_up(), s5s8_cp(), local_to_eNB(false) {};
void lock() {m_rw_lock.lock();};
void unlock() {m_rw_lock.unlock();};
int load(const std::string& config_file);
int execute();
void display();
};
} // namespace sgw
#endif /* FILE_SGWC_CONFIG_HPP_SEEN */
This diff is collapsed.
This diff is collapsed.
/*
* 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 sgw_pdn_connection.cpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#include "sgwc_app.hpp"
#include "sgwc_eps_bearer_context.hpp"
#include "sgwc_config.hpp"
#include <algorithm>
using namespace oai::cn::core;
using namespace oai::cn::core::itti;
using namespace oai::cn::nf::sgwc;
using namespace std;
extern sgwc_app *sgwc_app_inst;
////------------------------------------------------------------------------------
//fteid_t sgw_pdn_connection::generate_s5s8_up_fteid(const struct in_addr ipv4_address, const bearer_qos_t& bearer_qos) {
// fteid_t fteid = {};
// fteid.interface_type = S5_S8_SGW_GTP_U;
// fteid.v4 = 1;
// fteid.ipv4_address = ipv4_address;
// fteid.v6 = 0;
// fteid.ipv6_address = in6addr_any;
// for (auto it : sgw_eps_bearers) {
// if (it.second->sgw_fteid_s5_s8_up.v4) {
// if (it.second->eps_bearer_qos.is_arp_equals(bearer_qos)) {
// fteid.teid_gre_key = it.second->sgw_fteid_s5_s8_up.teid_gre_key;
// return fteid;
// }
// }
// }
// fteid.teid_gre_key = sgwc_app_inst->generate_s5s8_up_teid();
// return fteid;
//}
//------------------------------------------------------------------------------
void sgw_pdn_connection::add_eps_bearer(std::shared_ptr<sgw_eps_bearer> sb)
{
if (sb.get()) {
if ((sb->ebi.ebi >= EPS_BEARER_IDENTITY_FIRST) and (sb->ebi.ebi <= EPS_BEARER_IDENTITY_LAST)) {
sgw_eps_bearers.insert(std::pair<uint8_t,std::shared_ptr<sgw_eps_bearer>>(sb->ebi.ebi, sb));
Logger::sgwc_app().trace( "sgw_pdn_connection::add_eps_bearer(%d) success", sb->ebi.ebi);
} else {
Logger::sgwc_app().error( "sgw_pdn_connection::add_eps_bearer(%d) failed, invalid EBI", sb->ebi.ebi);
}
}
}
//------------------------------------------------------------------------------
bool sgw_pdn_connection::get_eps_bearer(const core::ebi_t& ebi, std::shared_ptr<sgw_eps_bearer>& b)
{
if (sgw_eps_bearers.count(ebi.ebi)) {
b = sgw_eps_bearers.at(ebi.ebi);
return true;
}
b = {};
return false;
}
//------------------------------------------------------------------------------
bool sgw_pdn_connection::update_eps_bearer(const oai::cn::proto::gtpv2c::bearer_context_modified_within_modify_bearer_response& b)
{
core::ebi_t ebi = {};
if (b.get(ebi)) {
std::shared_ptr<sgw_eps_bearer> sb = {};
if (get_eps_bearer(ebi, sb)) {
return sb->update(b);
}
}
return false;
}
//------------------------------------------------------------------------------
void sgw_pdn_connection::remove_eps_bearer(const core::ebi_t& ebi)
{
std::shared_ptr<sgw_eps_bearer> sb = {};
if (get_eps_bearer(ebi, sb)) {
if (sb.get()) {
sb->deallocate_ressources();
sgw_eps_bearers.erase(ebi.ebi);
}
}
}
//------------------------------------------------------------------------------
void sgw_pdn_connection::remove_eps_bearer(std::shared_ptr<sgw_eps_bearer> sb)
{
if (sb.get()) {
core::ebi_t ebi = {.ebi = sb->ebi.ebi};
sb->deallocate_ressources();
sgw_eps_bearers.erase(ebi.ebi);
}
}
//------------------------------------------------------------------------------
void sgw_pdn_connection::delete_bearers()
{
sgw_eps_bearers.clear();
}
//------------------------------------------------------------------------------
void sgw_pdn_connection::deallocate_ressources()
{
Logger::sgwc_app().error( "TODO sgw_pdn_connection::deallocate_ressources()");
for (auto it : sgw_eps_bearers) {
it.second->deallocate_ressources();
}
}
//------------------------------------------------------------------------------
std::string sgw_pdn_connection::toString() const
{
std::string s = {};
s.reserve(300);
s.append("PDN CONNECTION:\n");
s.append("\tAPN IN USE:\t\t").append(apn_in_use).append("\n");
s.append("\tPDN TYPE:\t\t").append(oai::cn::core::toString(pdn_type)).append("\n");
s.append("\tPGW FTEID S5S8 CP:\t").append(oai::cn::core::toString(pgw_fteid_s5_s8_cp)).append("\n");
//s.append("\tPGW ADDRESS IN USE UP:\t").append(oai::cn::core::toString(pgw_address_in_use_up)).append("\n");
s.append("\tSGW FTEID S5S8 CP:\t").append(oai::cn::core::toString(sgw_fteid_s5_s8_cp)).append("\n");
s.append("\tDEFAULT BEARER:\t\t").append(std::to_string(default_bearer.ebi)).append("\n");
for (auto it : sgw_eps_bearers) {
s.append(it.second->toString());
}
return s;
}
This diff is collapsed.
/*
* 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
*/
#ifndef FILE_SGWC_PROCEDURE_HPP_SEEN
#define FILE_SGWC_PROCEDURE_HPP_SEEN
/*! \file sgwc_procedure.hpp
\brief
\author Lionel Gauthier
\company Eurecom
\email: lionel.gauthier@eurecom.fr
*/
#include "itti_msg_s11.hpp"
#include "msg_gtpv2c.hpp"
#include "uint_generator.hpp"
#include <memory>
#include <list>
namespace oai::cn::nf::sgwc {
class sgw_eps_bearer_context;
class sgw_pdn_connection;
class sebc_procedure {
private:
static uint64_t generate_trxn_id() {
return oai::cn::util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
uint64_t gtpc_tx_id;
public:
bool marked_for_removal;
sebc_procedure(){gtpc_tx_id = generate_trxn_id();marked_for_removal = false;}
sebc_procedure(uint64_t tx_id){gtpc_tx_id = tx_id;marked_for_removal = false;}
virtual ~sebc_procedure(){}
virtual core::itti::itti_msg_type_t get_procedure_type(){return core::itti::ITTI_MSG_TYPE_NONE;}
virtual bool has_trxn_id(const uint64_t trxn_id) {return (trxn_id == gtpc_tx_id);}
virtual uint64_t get_trxn_id() {return gtpc_tx_id;}
virtual int run(std::shared_ptr<sgw_eps_bearer_context> ebc) {return RETURNerror;}
virtual void handle_itti_msg (core::itti::itti_s5s8_create_session_response& csresp, std::shared_ptr<sgw_eps_bearer_context> ebc, std::shared_ptr<sgw_pdn_connection> spc) {}
virtual void handle_itti_msg (core::itti::itti_s5s8_delete_session_response& dsresp, std::shared_ptr<sgw_eps_bearer_context> ebc, std::shared_ptr<sgw_pdn_connection> spc) {}
virtual void handle_itti_msg (core::itti::itti_s5s8_modify_bearer_response& dsresp, std::shared_ptr<sgw_eps_bearer_context> ebc, std::shared_ptr<sgw_pdn_connection> spc) {}
virtual void handle_itti_msg (core::itti::itti_s5s8_release_access_bearers_response& dsresp, std::shared_ptr<sgw_eps_bearer_context> ebc, std::shared_ptr<sgw_pdn_connection> spc) {}
};
//------------------------------------------------------------------------------
class sgw_eps_bearer_context;
class sgw_pdn_connection;
class create_session_request_procedure : public sebc_procedure {
public:
create_session_request_procedure(core::itti::itti_s11_create_session_request& msg) : sebc_procedure(msg.gtpc_tx_id), msg(msg), ebc(nullptr) {}
int run(std::shared_ptr<sgw_eps_bearer_context> ebc);
void handle_itti_msg (core::itti::itti_s5s8_create_session_response& csresp, std::shared_ptr<sgw_eps_bearer_context> ebc, std::shared_ptr<sgw_pdn_connection> spc);
core::itti::itti_s11_create_session_request msg;
std::shared_ptr<sgw_eps_bearer_context> ebc;
};
//------------------------------------------------------------------------------
class pdn_bearers_to_be_xied {
public:
pdn_bearers_to_be_xied() : pdn(), bearer_contexts_to_be_modified(), bearer_contexts_to_be_removed(), msg(), gtpc_tx_id() {}
pdn_bearers_to_be_xied(const pdn_bearers_to_be_xied& p) : pdn(p.pdn), bearer_contexts_to_be_modified(p.bearer_contexts_to_be_modified),
bearer_contexts_to_be_removed(p.bearer_contexts_to_be_removed), msg(p.msg), gtpc_tx_id(p.gtpc_tx_id) {}
std::shared_ptr<sgw_pdn_connection> pdn;
std::vector<oai::cn::proto::gtpv2c::bearer_context_to_be_modified_within_modify_bearer_request> bearer_contexts_to_be_modified;
// Still there because of not complete S/P GW split
std::vector<oai::cn::proto::gtpv2c::bearer_context_to_be_removed_within_modify_bearer_request> bearer_contexts_to_be_removed;
std::shared_ptr<core::itti::itti_s5s8_modify_bearer_request> msg;
uint64_t gtpc_tx_id;
};
class modify_bearer_request_procedure : public sebc_procedure {
public:
modify_bearer_request_procedure(core::itti::itti_s11_modify_bearer_request& msg) : sebc_procedure(msg.gtpc_tx_id), msg(msg),
pdn_bearers(), null_pdn_bearers(), ebc(), bearer_contexts_modified(), bearer_contexts_marked_for_removal() {}
bool has_trxn_id(const uint64_t trxn_id);
int run(std::shared_ptr<sgw_eps_bearer_context> ebc);
void handle_itti_msg (core::itti::itti_s5s8_modify_bearer_response& s5resp, std::shared_ptr<sgw_eps_bearer_context> ebc, std::shared_ptr<sgw_pdn_connection> pdn);
core::itti::itti_s11_modify_bearer_request msg;
std::vector<std::shared_ptr<pdn_bearers_to_be_xied>> pdn_bearers;
pdn_bearers_to_be_xied null_pdn_bearers;
std::vector<oai::cn::proto::gtpv2c::bearer_context_modified_within_modify_bearer_response> bearer_contexts_modified;
std::vector<oai::cn::proto::gtpv2c::bearer_context_marked_for_removal_within_modify_bearer_response> bearer_contexts_marked_for_removal;
std::shared_ptr<sgw_eps_bearer_context> ebc;
};
//------------------------------------------------------------------------------
class bearers_to_be_released {
public:
bearers_to_be_released(): pdn(), gtpc_tx_id() {}
bearers_to_be_released(const bearers_to_be_released& p): pdn(p.pdn), gtpc_tx_id(p.gtpc_tx_id) {}
std::shared_ptr<sgw_pdn_connection> pdn;
// Still there because of not complete S/P GW split
//std::shared_ptr<core::itti::itti_s5s8_release_access_bearers_request> msg;
uint64_t gtpc_tx_id;
};
class release_access_bearers_request_procedure : public sebc_procedure {
public:
release_access_bearers_request_procedure(core::itti::itti_s11_release_access_bearers_request& msg) : sebc_procedure(msg.gtpc_tx_id), msg(msg),
bearers(), ebc(), cause() {}
bool has_trxn_id(const uint64_t trxn_id);
int run(std::shared_ptr<sgw_eps_bearer_context> ebc);
void handle_itti_msg (core::itti::itti_s5s8_release_access_bearers_response& s5resp, std::shared_ptr<sgw_eps_bearer_context> ebc, std::shared_ptr<sgw_pdn_connection> pdn);
core::itti::itti_s11_release_access_bearers_request msg;
std::vector<std::shared_ptr<bearers_to_be_released>> bearers;
std::shared_ptr<sgw_eps_bearer_context> ebc;
core::cause_t cause;
};
//------------------------------------------------------------------------------
class delete_session_request_procedure : public sebc_procedure {
public:
delete_session_request_procedure(core::itti::itti_s11_delete_session_request& msg, std::shared_ptr<sgw_pdn_connection>& pdn) : sebc_procedure(msg.gtpc_tx_id), msg(msg), pdn_connection(pdn), ebc(nullptr) {}
int run(std::shared_ptr<sgw_eps_bearer_context> ebc);
void handle_itti_msg (core::itti::itti_s5s8_delete_session_response& dsresp, std::shared_ptr<sgw_eps_bearer_context> ebc, std::shared_ptr<sgw_pdn_connection>& spc);
core::itti::itti_s11_delete_session_request msg;
std::shared_ptr<sgw_eps_bearer_context> ebc;
std::shared_ptr<sgw_pdn_connection> pdn_connection;
};
}
#include "sgwc_eps_bearer_context.hpp"
#endif
This diff is collapsed.
/*
* 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 sgwc_s11.hpp
\author Lionel GAUTHIER
\date 2018
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_SGWC_S11_HPP_SEEN
#define FILE_SGWC_S11_HPP_SEEN
#include "gtpv2c.hpp"
#include "itti_msg_s11.hpp"
#include <thread>
namespace oai::cn::nf::sgwc {
class sgw_s11 : public proto::gtpv2c::gtpv2c_stack {
private:
std::thread::id thread_id;
std::thread thread;
void handle_receive_gtpv2c_msg(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_echo_request(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint );
void handle_receive_echo_response(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint );
void handle_receive_create_session_request(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint );
void handle_receive_delete_session_request(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_modify_bearer_request(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_release_access_bearers_request(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
public:
sgw_s11();
sgw_s11(sgw_s11 const&) = delete;
void operator=(sgw_s11 const&) = delete;
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint);
void send_msg(core::itti::itti_s11_create_session_response& m);
void send_msg(core::itti::itti_s11_delete_session_response& m);
void send_msg(core::itti::itti_s11_modify_bearer_response& m);
void send_msg(core::itti::itti_s11_release_access_bearers_response& m);
void send_echo_response(const boost::asio::ip::udp::endpoint& r_endpoint, const uint64_t trxn_id);
void time_out_itti_event(const uint32_t timer_id);
};
}
#endif /* FILE_SGWC_S11_HPP_SEEN */
This diff is collapsed.
/*
* 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 sgwc_s5s8.hpp
\author Lionel GAUTHIER
\date 2018
\email: lionel.gauthier@eurecom.fr
*/
#ifndef FILE_SGWC_S5S8_HPP_SEEN
#define FILE_SGWC_S5S8_HPP_SEEN
#include "gtpv2c.hpp"
#include "itti_msg_s5s8.hpp"
#include <thread>
namespace oai::cn::nf::sgwc {
class sgw_s5s8 : public proto::gtpv2c::gtpv2c_stack {
private:
std::thread::id thread_id;
std::thread thread;
void handle_receive_gtpv2c_msg(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_create_session_response(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint );
void handle_receive_delete_session_response(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_modify_bearer_response(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
void handle_receive_release_access_bearers_response(proto::gtpv2c::gtpv2c_msg& msg, const boost::asio::ip::udp::endpoint& remote_endpoint);
public:
sgw_s5s8();
sgw_s5s8(sgw_s5s8 const&) = delete;
void operator=(sgw_s5s8 const&) = delete;
void handle_receive(char* recv_buffer, const std::size_t bytes_transferred, boost::asio::ip::udp::endpoint& remote_endpoint);
void send_msg(core::itti::itti_s5s8_create_session_request& m);
void send_msg(core::itti::itti_s5s8_delete_session_request& m);
void send_msg(core::itti::itti_s5s8_modify_bearer_request& m);
void send_msg(core::itti::itti_s5s8_release_access_bearers_request& m);
void time_out_itti_event(const uint32_t timer_id);
};
}
#endif /* FILE_SGWC_S5S8_HPP_SEEN */
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