2020-11-26 01:25:22 -08:00
|
|
|
/**
|
2017-11-13 08:42:41 -08:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* \section COPYRIGHT
|
2017-11-13 08:42:41 -08:00
|
|
|
*
|
2021-03-19 03:45:56 -07:00
|
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
2017-11-13 08:42:41 -08:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* By using this file, you agree to the terms and conditions set
|
|
|
|
* forth in the LICENSE file which can be found at the top level of
|
|
|
|
* the distribution.
|
2017-11-13 08:42:41 -08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
2017-11-17 04:28:05 -08:00
|
|
|
* File: spgw.h
|
|
|
|
* Description: Top-level SP-GW class. Creates and links all
|
2017-11-13 08:42:41 -08:00
|
|
|
* interfaces and helpers.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#ifndef SRSEPC_SPGW_H
|
|
|
|
#define SRSEPC_SPGW_H
|
2017-11-13 08:42:41 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
#include "srsran/asn1/gtpc.h"
|
|
|
|
#include "srsran/common/buffer_pool.h"
|
|
|
|
#include "srsran/common/threads.h"
|
|
|
|
#include "srsran/srslog/srslog.h"
|
2019-03-21 10:03:46 -07:00
|
|
|
#include <cstddef>
|
2019-04-08 05:22:01 -07:00
|
|
|
#include <queue>
|
2017-11-13 08:42:41 -08:00
|
|
|
|
2019-03-19 06:53:58 -07:00
|
|
|
namespace srsepc {
|
2017-11-13 08:42:41 -08:00
|
|
|
|
2017-11-27 07:38:10 -08:00
|
|
|
class mme_gtpc;
|
|
|
|
|
2017-11-20 04:30:25 -08:00
|
|
|
const uint16_t GTPU_RX_PORT = 2152;
|
|
|
|
|
2017-11-13 08:42:41 -08:00
|
|
|
typedef struct {
|
2017-11-20 04:30:25 -08:00
|
|
|
std::string gtpu_bind_addr;
|
2017-11-20 12:34:08 -08:00
|
|
|
std::string sgi_if_addr;
|
2018-10-05 02:12:31 -07:00
|
|
|
std::string sgi_if_name;
|
2019-04-08 05:22:01 -07:00
|
|
|
uint32_t max_paging_queue;
|
2017-11-17 04:28:05 -08:00
|
|
|
} spgw_args_t;
|
2017-11-13 08:42:41 -08:00
|
|
|
|
2017-12-06 04:50:25 -08:00
|
|
|
typedef struct spgw_tunnel_ctx {
|
2021-02-07 13:30:31 -08:00
|
|
|
uint64_t imsi;
|
|
|
|
in_addr_t ue_ipv4;
|
|
|
|
uint8_t ebi;
|
2021-03-19 03:45:56 -07:00
|
|
|
srsran::gtp_fteid_t up_ctrl_fteid;
|
|
|
|
srsran::gtp_fteid_t up_user_fteid;
|
|
|
|
srsran::gtp_fteid_t dw_ctrl_fteid;
|
|
|
|
srsran::gtp_fteid_t dw_user_fteid;
|
2021-02-07 13:30:31 -08:00
|
|
|
bool paging_pending;
|
2021-03-19 03:45:56 -07:00
|
|
|
std::queue<srsran::unique_byte_buffer_t> paging_queue;
|
2017-12-06 04:50:25 -08:00
|
|
|
} spgw_tunnel_ctx_t;
|
2017-11-23 10:11:53 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
class spgw : public srsran::thread
|
2017-11-13 08:42:41 -08:00
|
|
|
{
|
2019-03-21 10:03:46 -07:00
|
|
|
class gtpc;
|
|
|
|
class gtpu;
|
|
|
|
|
2017-11-13 08:42:41 -08:00
|
|
|
public:
|
2017-11-17 04:28:05 -08:00
|
|
|
static spgw* get_instance(void);
|
2019-03-19 06:53:58 -07:00
|
|
|
static void cleanup(void);
|
2021-02-09 08:57:45 -08:00
|
|
|
int init(spgw_args_t* args, const std::map<std::string, uint64_t>& ip_to_imsi);
|
2019-10-17 08:17:25 -07:00
|
|
|
void stop();
|
|
|
|
void run_thread();
|
2017-11-23 10:11:53 -08:00
|
|
|
|
2017-11-13 08:42:41 -08:00
|
|
|
private:
|
2017-11-17 04:28:05 -08:00
|
|
|
spgw();
|
|
|
|
virtual ~spgw();
|
2019-03-19 06:53:58 -07:00
|
|
|
static spgw* m_instance;
|
2017-11-13 08:42:41 -08:00
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
spgw_tunnel_ctx_t* create_gtp_ctx(struct srsran::gtpc_create_session_request* cs_req);
|
2019-03-19 06:53:58 -07:00
|
|
|
bool delete_gtp_ctx(uint32_t ctrl_teid);
|
2017-11-27 07:38:10 -08:00
|
|
|
|
2021-02-05 13:11:49 -08:00
|
|
|
bool m_running;
|
|
|
|
mme_gtpc* m_mme_gtpc;
|
2017-11-13 08:42:41 -08:00
|
|
|
|
2019-03-21 10:03:46 -07:00
|
|
|
// GTP-C and GTP-U handlers
|
|
|
|
gtpc* m_gtpc;
|
|
|
|
gtpu* m_gtpu;
|
2017-11-23 10:11:53 -08:00
|
|
|
|
2019-03-21 10:03:46 -07:00
|
|
|
// Logs
|
2021-01-29 02:29:20 -08:00
|
|
|
srslog::basic_logger& m_logger = srslog::fetch_basic_logger("SPGW");
|
2017-11-13 08:42:41 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace srsepc
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSEPC_SPGW_H
|