srsLTE/srsue/hdr/upper/gw.h

110 lines
2.8 KiB
C
Raw Normal View History

2017-05-18 03:52:29 -07:00
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of the srsUE library.
*
* srsUE is free software: you can redistribute it and/or modify
* 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.
*
* srsUE is distributed in the hope that it will be useful,
* 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 "srslte/common/buffer_pool.h"
#include "srslte/common/log.h"
#include "srslte/common/common.h"
2018-01-17 07:45:07 -08:00
#include "srslte/common/interfaces_common.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/common/threads.h"
#include "gw_metrics.h"
2017-05-18 03:52:29 -07:00
#include <linux/if.h>
namespace srsue {
2017-05-18 03:52:29 -07:00
class gw
:public gw_interface_pdcp
,public gw_interface_nas
,public gw_interface_rrc
2017-05-18 03:52:29 -07:00
,public thread
{
public:
gw();
2018-01-17 07:45:07 -08:00
void init(pdcp_interface_gw *pdcp_, nas_interface_gw *nas_, srslte::log *gw_log_, srslte::srslte_gw_config_t);
2017-05-18 03:52:29 -07:00
void stop();
void get_metrics(gw_metrics_t &m);
void set_netmask(std::string netmask);
void set_tundevname(const std::string & devname);
2017-05-18 03:52:29 -07:00
// PDCP interface
void write_pdu(uint32_t lcid, srslte::byte_buffer_t *pdu);
void write_pdu_mch(uint32_t lcid, srslte::byte_buffer_t *pdu);
2017-05-18 03:52:29 -07:00
// NAS interface
srslte::error_t setup_if_addr(uint32_t ip_addr, char *err_str);
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
bool default_netmask;
std::string netmask;
std::string tundevname;
2017-06-28 04:21:56 -07:00
static const int GW_THREAD_PRIO = 7;
pdcp_interface_gw *pdcp;
nas_interface_gw *nas;
srslte::byte_buffer_pool *pool;
srslte::log *gw_log;
2018-01-17 07:45:07 -08:00
srslte::srslte_gw_config_t cfg;
2017-05-18 03:52:29 -07:00
bool running;
bool run_enable;
int32 tun_fd;
struct ifreq ifr;
int32 sock;
bool if_up;
2017-09-07 04:19:53 -07:00
uint32_t current_ip_addr;
2017-05-18 03:52:29 -07:00
long ul_tput_bytes;
long dl_tput_bytes;
struct timeval metrics_time[3];
void run_thread();
srslte::error_t init_if(char *err_str);
// 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
2017-05-18 03:52:29 -07:00
};
} // namespace srsue
2018-03-31 10:04:04 -07:00
#endif // SRSUE_GW_H