mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.2 KiB
C++
109 lines
3.2 KiB
C++
/**
|
|
*
|
|
* \section COPYRIGHT
|
|
*
|
|
* Copyright 2013-2020 Software Radio Systems Limited
|
|
*
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
#ifndef SRSUE_GW_H
|
|
#define SRSUE_GW_H
|
|
|
|
#include "gw_metrics.h"
|
|
#include "srslte/common/buffer_pool.h"
|
|
#include "srslte/common/common.h"
|
|
#include "srslte/common/interfaces_common.h"
|
|
#include "srslte/common/log.h"
|
|
#include "srslte/common/log_filter.h"
|
|
#include "srslte/common/threads.h"
|
|
#include "srslte/interfaces/ue_interfaces.h"
|
|
#include "srslte/srslog/srslog.h"
|
|
#include "tft_packet_filter.h"
|
|
#include <net/if.h>
|
|
|
|
namespace srsue {
|
|
|
|
struct gw_args_t {
|
|
struct log_args_t {
|
|
std::string gw_level;
|
|
int gw_hex_limit;
|
|
} log;
|
|
std::string netns;
|
|
std::string tun_dev_name;
|
|
std::string tun_dev_netmask;
|
|
};
|
|
|
|
class gw : public gw_interface_stack, public srslte::thread
|
|
{
|
|
public:
|
|
gw();
|
|
int init(const gw_args_t& args_, srslte::logger* logger_, stack_interface_gw* stack);
|
|
void stop();
|
|
|
|
void get_metrics(gw_metrics_t& m, const uint32_t nof_tti);
|
|
|
|
// PDCP interface
|
|
void write_pdu(uint32_t lcid, srslte::unique_byte_buffer_t pdu);
|
|
void write_pdu_mch(uint32_t lcid, srslte::unique_byte_buffer_t pdu);
|
|
|
|
// NAS interface
|
|
int setup_if_addr(uint32_t lcid, uint8_t pdn_type, uint32_t ip_addr, uint8_t* ipv6_if_addr, char* err_str);
|
|
int apply_traffic_flow_template(const uint8_t& eps_bearer_id,
|
|
const uint8_t& lcid,
|
|
const LIBLTE_MME_TRAFFIC_FLOW_TEMPLATE_STRUCT* tft);
|
|
void set_test_loop_mode(const test_loop_mode_state_t mode, const uint32_t ip_pdu_delay_ms);
|
|
|
|
// RRC interface
|
|
void add_mch_port(uint32_t lcid, uint32_t port);
|
|
|
|
private:
|
|
static const int GW_THREAD_PRIO = -1;
|
|
|
|
stack_interface_gw* stack = nullptr;
|
|
srslte::byte_buffer_pool* pool = nullptr;
|
|
srslte::logger* old_logger = nullptr;
|
|
|
|
gw_args_t args = {};
|
|
|
|
bool running = false;
|
|
bool run_enable = false;
|
|
int32_t netns_fd = 0;
|
|
int32_t tun_fd = 0;
|
|
struct ifreq ifr = {};
|
|
int32_t sock = 0;
|
|
bool if_up = false;
|
|
uint32_t default_lcid = 0;
|
|
|
|
srslog::basic_logger& logger;
|
|
|
|
uint32_t current_ip_addr = 0;
|
|
uint8_t current_if_id[8];
|
|
|
|
uint32_t ul_tput_bytes = 0;
|
|
uint32_t dl_tput_bytes = 0;
|
|
std::chrono::high_resolution_clock::time_point metrics_tp; // stores time when last metrics have been taken
|
|
|
|
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);
|
|
|
|
// MBSFN
|
|
int mbsfn_sock_fd = 0; // Sink UDP socket file descriptor
|
|
struct sockaddr_in mbsfn_sock_addr = {}; // Target address
|
|
uint32_t mbsfn_ports[SRSLTE_N_MCH_LCIDS] = {}; // Target ports for MBSFN data
|
|
|
|
// TFT
|
|
tft_pdu_matcher tft_matcher;
|
|
};
|
|
|
|
} // namespace srsue
|
|
|
|
#endif // SRSUE_GW_H
|