2020-11-26 01:25:22 -08:00
|
|
|
/**
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2020-11-26 01:25:22 -08:00
|
|
|
* \section COPYRIGHT
|
2017-05-18 03:52:29 -07:00
|
|
|
*
|
2021-03-19 03:45:56 -07:00
|
|
|
* Copyright 2013-2021 Software Radio Systems Limited
|
2017-05-18 03:52:29 -07: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-05-18 03:52:29 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#ifndef SRSUE_GW_H
|
|
|
|
#define SRSUE_GW_H
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2019-06-06 06:43:59 -07:00
|
|
|
#include "gw_metrics.h"
|
2021-03-19 03:45:56 -07:00
|
|
|
#include "srsran/common/buffer_pool.h"
|
|
|
|
#include "srsran/common/common.h"
|
|
|
|
#include "srsran/common/interfaces_common.h"
|
|
|
|
#include "srsran/common/threads.h"
|
|
|
|
#include "srsran/interfaces/ue_gw_interfaces.h"
|
|
|
|
#include "srsran/srslog/srslog.h"
|
2019-05-28 10:24:13 -07:00
|
|
|
#include "tft_packet_filter.h"
|
2019-06-06 06:43:59 -07:00
|
|
|
#include <net/if.h>
|
2021-02-25 08:40:46 -08:00
|
|
|
#include <netinet/in.h>
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2017-09-18 05:02:31 -07:00
|
|
|
namespace srsue {
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2021-02-25 08:40:46 -08:00
|
|
|
class stack_interface_gw;
|
|
|
|
|
2019-06-19 11:12:33 -07:00
|
|
|
struct gw_args_t {
|
|
|
|
struct log_args_t {
|
|
|
|
std::string gw_level;
|
|
|
|
int gw_hex_limit;
|
|
|
|
} log;
|
2020-01-10 06:59:47 -08:00
|
|
|
std::string netns;
|
2019-05-07 01:11:57 -07:00
|
|
|
std::string tun_dev_name;
|
|
|
|
std::string tun_dev_netmask;
|
|
|
|
};
|
|
|
|
|
2021-03-19 03:45:56 -07:00
|
|
|
class gw : public gw_interface_stack, public srsran::thread
|
2017-05-18 03:52:29 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
gw();
|
2021-02-17 08:35:20 -08:00
|
|
|
int init(const gw_args_t& args_, stack_interface_gw* stack);
|
2017-05-18 03:52:29 -07:00
|
|
|
void stop();
|
|
|
|
|
2020-11-30 07:33:57 -08:00
|
|
|
void get_metrics(gw_metrics_t& m, const uint32_t nof_tti);
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
// PDCP interface
|
2021-03-19 03:45:56 -07:00
|
|
|
void write_pdu(uint32_t lcid, srsran::unique_byte_buffer_t pdu);
|
|
|
|
void write_pdu_mch(uint32_t lcid, srsran::unique_byte_buffer_t pdu);
|
2017-05-18 03:52:29 -07:00
|
|
|
|
|
|
|
// NAS interface
|
2021-01-27 07:55:49 -08:00
|
|
|
int setup_if_addr(uint32_t eps_bearer_id,
|
|
|
|
uint32_t lcid,
|
|
|
|
uint8_t pdn_type,
|
|
|
|
uint32_t ip_addr,
|
|
|
|
uint8_t* ipv6_if_addr,
|
|
|
|
char* err_str);
|
2021-01-28 08:17:43 -08:00
|
|
|
int apply_traffic_flow_template(const uint8_t& eps_bearer_id,
|
|
|
|
const uint8_t& lcid,
|
|
|
|
const LIBLTE_MME_TRAFFIC_FLOW_TEMPLATE_STRUCT* tft);
|
2020-04-08 05:43:24 -07:00
|
|
|
void set_test_loop_mode(const test_loop_mode_state_t mode, const uint32_t ip_pdu_delay_ms);
|
2017-06-28 04:21:56 -07:00
|
|
|
|
2018-05-15 08:20:51 -07:00
|
|
|
// RRC interface
|
|
|
|
void add_mch_port(uint32_t lcid, uint32_t port);
|
2021-01-27 07:55:49 -08:00
|
|
|
int update_lcid(uint32_t eps_bearer_id, uint32_t new_lcid);
|
2021-04-06 08:22:06 -07:00
|
|
|
bool is_running();
|
2017-10-19 13:26:00 -07:00
|
|
|
|
2017-05-18 03:52:29 -07:00
|
|
|
private:
|
2020-07-01 08:30:34 -07:00
|
|
|
static const int GW_THREAD_PRIO = -1;
|
2017-06-28 04:21:56 -07:00
|
|
|
|
2021-02-17 08:35:20 -08:00
|
|
|
stack_interface_gw* stack = nullptr;
|
2019-11-05 07:53:17 -08:00
|
|
|
|
|
|
|
gw_args_t args = {};
|
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
bool running = false;
|
|
|
|
bool run_enable = false;
|
2020-01-10 06:59:47 -08:00
|
|
|
int32_t netns_fd = 0;
|
2019-12-16 07:04:22 -08:00
|
|
|
int32_t tun_fd = 0;
|
|
|
|
struct ifreq ifr = {};
|
|
|
|
int32_t sock = 0;
|
|
|
|
bool if_up = false;
|
|
|
|
uint32_t default_lcid = 0;
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2021-01-28 08:17:43 -08:00
|
|
|
srslog::basic_logger& logger;
|
2021-02-06 17:08:15 -08:00
|
|
|
|
2021-01-27 07:55:49 -08:00
|
|
|
std::map<uint32_t, uint32_t> eps_lcid; // Mapping between eps bearer ID and LCID
|
2019-06-19 11:12:33 -07:00
|
|
|
|
2019-12-16 07:04:22 -08:00
|
|
|
uint32_t current_ip_addr = 0;
|
|
|
|
uint8_t current_if_id[8];
|
2017-09-07 04:19:53 -07:00
|
|
|
|
2021-01-28 08:17:43 -08:00
|
|
|
uint32_t ul_tput_bytes = 0;
|
|
|
|
uint32_t dl_tput_bytes = 0;
|
2020-12-16 06:31:15 -08:00
|
|
|
std::chrono::high_resolution_clock::time_point metrics_tp; // stores time when last metrics have been taken
|
2017-05-18 03:52:29 -07:00
|
|
|
|
2019-06-05 10:12:01 -07:00
|
|
|
void run_thread();
|
|
|
|
int init_if(char* err_str);
|
|
|
|
int setup_if_addr4(uint32_t ip_addr, char* err_str);
|
|
|
|
int setup_if_addr6(uint8_t* ipv6_if_id, char* err_str);
|
|
|
|
bool find_ipv6_addr(struct in6_addr* in6_out);
|
|
|
|
void del_ipv6_addr(struct in6_addr* in6p);
|
2018-05-15 08:20:51 -07:00
|
|
|
|
|
|
|
// MBSFN
|
2019-11-05 07:53:17 -08:00
|
|
|
int mbsfn_sock_fd = 0; // Sink UDP socket file descriptor
|
|
|
|
struct sockaddr_in mbsfn_sock_addr = {}; // Target address
|
2021-03-19 03:45:56 -07:00
|
|
|
uint32_t mbsfn_ports[SRSRAN_N_MCH_LCIDS] = {}; // Target ports for MBSFN data
|
2018-05-15 08:20:51 -07:00
|
|
|
|
2019-05-29 10:46:22 -07:00
|
|
|
// TFT
|
2021-01-28 08:17:43 -08:00
|
|
|
tft_pdu_matcher tft_matcher;
|
2017-05-18 03:52:29 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace srsue
|
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSUE_GW_H
|