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.
125 lines
3.6 KiB
C
125 lines
3.6 KiB
C
6 years ago
|
/*
|
||
|
* Copyright 2013-2019 Software Radio Systems Limited
|
||
8 years ago
|
*
|
||
|
* This file is part of srsLTE.
|
||
|
*
|
||
6 years ago
|
* srsLTE is free software: you can redistribute it and/or modify
|
||
8 years ago
|
* 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.
|
||
|
*
|
||
6 years ago
|
* srsLTE is distributed in the hope that it will be useful,
|
||
8 years ago
|
* 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/.
|
||
|
*
|
||
|
*/
|
||
8 years ago
|
|
||
|
#include <string.h>
|
||
|
#include <map>
|
||
|
|
||
|
#include "srslte/common/buffer_pool.h"
|
||
|
#include "srslte/common/log.h"
|
||
7 years ago
|
#include "common_enb.h"
|
||
8 years ago
|
#include "srslte/common/threads.h"
|
||
|
#include "srslte/srslte.h"
|
||
|
#include "srslte/interfaces/enb_interfaces.h"
|
||
|
|
||
7 years ago
|
#ifndef SRSENB_GTPU_H
|
||
|
#define SRSENB_GTPU_H
|
||
8 years ago
|
|
||
6 years ago
|
|
||
8 years ago
|
namespace srsenb {
|
||
|
|
||
|
class gtpu
|
||
|
:public gtpu_interface_rrc
|
||
|
,public gtpu_interface_pdcp
|
||
|
,public thread
|
||
|
{
|
||
6 years ago
|
public:
|
||
|
|
||
6 years ago
|
gtpu();
|
||
6 years ago
|
|
||
7 years ago
|
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);
|
||
8 years ago
|
void stop();
|
||
6 years ago
|
|
||
8 years ago
|
// gtpu_interface_rrc
|
||
7 years ago
|
void add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t teid_out, uint32_t *teid_in);
|
||
8 years ago
|
void rem_bearer(uint16_t rnti, uint32_t lcid);
|
||
|
void rem_user(uint16_t rnti);
|
||
6 years ago
|
|
||
8 years ago
|
// gtpu_interface_pdcp
|
||
6 years ago
|
void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu);
|
||
8 years ago
|
|
||
|
private:
|
||
7 years ago
|
static const int THREAD_PRIO = 65;
|
||
8 years ago
|
static const int GTPU_PORT = 2152;
|
||
7 years ago
|
srslte::byte_buffer_pool *pool;
|
||
8 years ago
|
bool running;
|
||
|
bool run_enable;
|
||
6 years ago
|
|
||
|
bool enable_mbsfn;
|
||
8 years ago
|
std::string gtp_bind_addr;
|
||
|
std::string mme_addr;
|
||
|
srsenb::pdcp_interface_gtpu *pdcp;
|
||
|
srslte::log *gtpu_log;
|
||
6 years ago
|
|
||
|
// Class to create
|
||
|
class mch_thread : public thread {
|
||
|
public:
|
||
6 years ago
|
mch_thread() : initiated(false), running(false), run_enable(false), pool(NULL), lcid_counter(0), thread("MCH") {}
|
||
6 years ago
|
bool init(std::string m1u_multiaddr_, std::string m1u_if_addr_, pdcp_interface_gtpu *pdcp_, srslte::log *gtpu_log_);
|
||
6 years ago
|
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;
|
||
6 years ago
|
std::string m1u_multiaddr;
|
||
|
std::string m1u_if_addr;
|
||
6 years ago
|
|
||
|
srslte::byte_buffer_pool *pool;
|
||
|
};
|
||
|
|
||
|
// MCH thread insteance
|
||
|
mch_thread mchthread;
|
||
8 years ago
|
|
||
|
typedef struct{
|
||
|
uint32_t teids_in[SRSENB_N_RADIO_BEARERS];
|
||
|
uint32_t teids_out[SRSENB_N_RADIO_BEARERS];
|
||
7 years ago
|
uint32_t spgw_addrs[SRSENB_N_RADIO_BEARERS];
|
||
8 years ago
|
}bearer_map;
|
||
|
std::map<uint16_t, bearer_map> rnti_bearers;
|
||
|
|
||
6 years ago
|
// Socket file descriptor
|
||
|
int fd;
|
||
8 years ago
|
|
||
|
void run_thread();
|
||
6 years ago
|
void echo_response(in_addr_t addr, in_port_t port, uint16_t seq);
|
||
7 years ago
|
|
||
6 years ago
|
pthread_mutex_t mutex;
|
||
8 years ago
|
|
||
|
/****************************************************************************
|
||
|
* 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
|
||
|
|
||
7 years ago
|
#endif // SRSENB_GTPU_H
|