srsLTE/srsenb/hdr/upper/gtpu.h

125 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-06-02 03:46:06 -07:00
*
* This file is part of srsLTE.
*
2019-04-26 12:27:38 -07:00
* srsLTE is free software: you can redistribute it and/or modify
2017-06-02 03:46:06 -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-06-02 03:46:06 -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/.
*
*/
2017-06-01 03:25:57 -07:00
#include <string.h>
#include <map>
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log.h"
#include "common_enb.h"
2017-06-01 03:25:57 -07:00
#include "srslte/common/threads.h"
#include "srslte/srslte.h"
#include "srslte/interfaces/enb_interfaces.h"
2018-03-31 10:04:04 -07:00
#ifndef SRSENB_GTPU_H
#define SRSENB_GTPU_H
2017-06-01 03:25:57 -07:00
2017-06-01 03:25:57 -07:00
namespace srsenb {
class gtpu
:public gtpu_interface_rrc
,public gtpu_interface_pdcp
,public thread
{
public:
gtpu();
2018-06-15 04:42:17 -07:00
bool init(std::string gtp_bind_addr_, std::string mme_addr_, std::string m1u_multiaddr_, std::string m1u_if_addr_, pdcp_interface_gtpu *pdcp_, srslte::log *gtpu_log_, bool enable_mbsfn = false);
2017-06-01 03:25:57 -07:00
void stop();
2017-06-01 03:25:57 -07:00
// gtpu_interface_rrc
void add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t teid_out, uint32_t *teid_in);
2017-06-01 03:25:57 -07:00
void rem_bearer(uint16_t rnti, uint32_t lcid);
void rem_user(uint16_t rnti);
2017-06-01 03:25:57 -07:00
// gtpu_interface_pdcp
void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer pdu);
2017-06-01 03:25:57 -07:00
private:
static const int THREAD_PRIO = 65;
2017-06-01 03:25:57 -07:00
static const int GTPU_PORT = 2152;
srslte::byte_buffer_pool *pool;
2017-06-01 03:25:57 -07:00
bool running;
bool run_enable;
bool enable_mbsfn;
2017-06-01 03:25:57 -07:00
std::string gtp_bind_addr;
std::string mme_addr;
srsenb::pdcp_interface_gtpu *pdcp;
srslte::log *gtpu_log;
// Class to create
class mch_thread : public thread {
public:
2019-01-15 07:34:41 -08:00
mch_thread() : initiated(false), running(false), run_enable(false), pool(NULL), lcid_counter(0) {}
2018-10-02 04:25:15 -07:00
bool init(std::string m1u_multiaddr_, std::string m1u_if_addr_, pdcp_interface_gtpu *pdcp_, srslte::log *gtpu_log_);
void stop();
private:
void run_thread();
bool initiated;
bool running;
bool run_enable;
static const int MCH_THREAD_PRIO = 65;
pdcp_interface_gtpu *pdcp;
srslte::log *gtpu_log;
int m1u_sd;
int lcid_counter;
2018-10-02 04:25:15 -07:00
std::string m1u_multiaddr;
std::string m1u_if_addr;
srslte::byte_buffer_pool *pool;
};
// MCH thread insteance
mch_thread mchthread;
2017-06-01 03:25:57 -07:00
typedef struct{
uint32_t teids_in[SRSENB_N_RADIO_BEARERS];
uint32_t teids_out[SRSENB_N_RADIO_BEARERS];
uint32_t spgw_addrs[SRSENB_N_RADIO_BEARERS];
2017-06-01 03:25:57 -07:00
}bearer_map;
std::map<uint16_t, bearer_map> rnti_bearers;
// Socket file descriptor
int fd;
2017-06-01 03:25:57 -07:00
void run_thread();
void echo_response(in_addr_t addr, in_port_t port, uint16_t seq);
pthread_mutex_t mutex;
2017-06-01 03:25:57 -07:00
/****************************************************************************
* TEID to RNIT/LCID helper functions
***************************************************************************/
void teidin_to_rntilcid(uint32_t teidin, uint16_t *rnti, uint16_t *lcid);
void rntilcid_to_teidin(uint16_t rnti, uint16_t lcid, uint32_t *teidin);
};
} // namespace srsenb
2018-03-31 10:04:04 -07:00
#endif // SRSENB_GTPU_H