srsLTE/srsue/hdr/stack/upper/gw.h

120 lines
3.6 KiB
C
Raw Normal View History

2019-04-26 12:27:38 -07:00
/*
* Copyright 2013-2019 Software Radio Systems Limited
2017-05-18 03:52:29 -07:00
*
2019-04-26 12:27:38 -07:00
* This file is part of srsLTE.
2017-05-18 03:52:29 -07:00
*
2019-04-26 12:27:38 -07:00
* srsLTE is free software: you can redistribute it and/or modify
2017-05-18 03:52:29 -07:00
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
2019-04-26 12:27:38 -07:00
* srsLTE is distributed in the hope that it will be useful,
2017-05-18 03:52:29 -07:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
2018-03-31 10:04:04 -07:00
#ifndef SRSUE_GW_H
#define SRSUE_GW_H
2017-05-18 03:52:29 -07:00
#include "gw_metrics.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/common.h"
2018-01-17 07:45:07 -08:00
#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 "tft_packet_filter.h"
#include <mutex>
#include <net/if.h>
2017-05-18 03:52:29 -07:00
namespace srsue {
2017-05-18 03:52:29 -07:00
struct gw_args_t {
struct log_args_t {
std::string gw_level;
int gw_hex_limit;
} log;
std::string tun_dev_name;
std::string tun_dev_netmask;
};
class gw : public gw_interface_stack, public thread
2017-05-18 03:52:29 -07:00
{
public:
gw();
int init(const gw_args_t& args_, srslte::logger* logger_, stack_interface_gw* stack);
2017-05-18 03:52:29 -07:00
void stop();
void get_metrics(gw_metrics_t &m);
// PDCP interface
2019-05-13 07:34:15 -07:00
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);
2017-05-18 03:52:29 -07:00
// 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);
2017-06-28 04:21:56 -07:00
// RRC interface
void add_mch_port(uint32_t lcid, uint32_t port);
2017-05-18 03:52:29 -07:00
private:
2017-06-28 04:21:56 -07:00
static const int GW_THREAD_PRIO = 7;
stack_interface_gw* stack;
srslte::byte_buffer_pool* pool;
srslte::logger* logger;
gw_args_t args;
2017-05-18 03:52:29 -07:00
bool running;
bool run_enable;
2019-01-17 03:42:01 -08:00
int32_t tun_fd;
2017-05-18 03:52:29 -07:00
struct ifreq ifr;
2019-01-17 03:42:01 -08:00
int32_t sock;
2017-05-18 03:52:29 -07:00
bool if_up;
uint32_t default_lcid = 0;
2017-05-18 03:52:29 -07:00
srslte::log_filter log;
2017-09-07 04:19:53 -07:00
uint32_t current_ip_addr;
uint8_t current_if_id[8];
2017-09-07 04:19:53 -07:00
2017-05-18 03:52:29 -07:00
long ul_tput_bytes;
long dl_tput_bytes;
struct timeval metrics_time[3];
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);
// MBSFN
int mbsfn_sock_fd; // 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
std::mutex tft_mutex;
typedef std::map<uint16_t, tft_packet_filter_t> tft_filter_map_t;
tft_filter_map_t tft_filter_map;
uint8_t check_tft_filter_match(const srslte::unique_byte_buffer_t& pdu);
2017-05-18 03:52:29 -07:00
};
} // namespace srsue
2018-03-31 10:04:04 -07:00
#endif // SRSUE_GW_H