From e8487211e44bb5c030d3361ae03035951336c9d2 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Tue, 19 Nov 2019 14:59:59 +0000 Subject: [PATCH] changed the naming of mch to m1u in the gtpu class --- lib/include/srslte/common/network_utils.h | 2 +- .../srslte/interfaces/enb_interfaces.h | 4 +- srsenb/hdr/stack/enb_stack_lte.h | 4 +- srsenb/hdr/stack/upper/gtpu.h | 49 +++++++++---------- srsenb/src/stack/enb_stack_lte.cc | 16 +++--- srsenb/src/stack/mac/mac.cc | 6 +-- srsenb/src/stack/upper/gtpu.cc | 29 ++++++----- 7 files changed, 52 insertions(+), 58 deletions(-) diff --git a/lib/include/srslte/common/network_utils.h b/lib/include/srslte/common/network_utils.h index bab19b45f..dfd12ff0d 100644 --- a/lib/include/srslte/common/network_utils.h +++ b/lib/include/srslte/common/network_utils.h @@ -160,7 +160,7 @@ public: rx_multisocket_handler(rx_multisocket_handler&&) = delete; rx_multisocket_handler(const rx_multisocket_handler&) = delete; rx_multisocket_handler& operator=(const rx_multisocket_handler&) = delete; - rx_multisocket_handler& operator=(const rx_multisocket_handler&&) = delete; + rx_multisocket_handler& operator=(rx_multisocket_handler&&) = delete; ~rx_multisocket_handler(); void stop(); diff --git a/lib/include/srslte/interfaces/enb_interfaces.h b/lib/include/srslte/interfaces/enb_interfaces.h index cf60c85e0..87d11f212 100644 --- a/lib/include/srslte/interfaces/enb_interfaces.h +++ b/lib/include/srslte/interfaces/enb_interfaces.h @@ -347,8 +347,8 @@ public: class stack_interface_gtpu_lte { public: - virtual void add_gtpu_socket(int fd) = 0; - virtual void add_gtpu_mch_socket(int fd) = 0; + virtual void add_gtpu_s1u_socket_handler(int fd) = 0; + virtual void add_gtpu_m1u_socket_handler(int fd) = 0; }; } // namespace srsenb diff --git a/srsenb/hdr/stack/enb_stack_lte.h b/srsenb/hdr/stack/enb_stack_lte.h index 5fa058fd6..dba1b12cc 100644 --- a/srsenb/hdr/stack/enb_stack_lte.h +++ b/srsenb/hdr/stack/enb_stack_lte.h @@ -96,8 +96,8 @@ public: /* STACK-S1AP interface*/ void add_mme_socket(int fd) override; void remove_mme_socket(int fd) override; - void add_gtpu_socket(int fd) override; - void add_gtpu_mch_socket(int fd) override; + void add_gtpu_s1u_socket_handler(int fd) override; + void add_gtpu_m1u_socket_handler(int fd) override; private: static const int STACK_MAIN_THREAD_PRIO = -1; // Use default high-priority below UHD diff --git a/srsenb/hdr/stack/upper/gtpu.h b/srsenb/hdr/stack/upper/gtpu.h index fb2fa7cba..7b22197f7 100644 --- a/srsenb/hdr/stack/upper/gtpu.h +++ b/srsenb/hdr/stack/upper/gtpu.h @@ -19,23 +19,22 @@ * */ -#include #include +#include +#include "common_enb.h" #include "srslte/common/buffer_pool.h" #include "srslte/common/log.h" -#include "common_enb.h" #include "srslte/common/threads.h" -#include "srslte/srslte.h" #include "srslte/interfaces/enb_interfaces.h" +#include "srslte/srslte.h" #ifndef SRSENB_GTPU_H #define SRSENB_GTPU_H - namespace srsenb { -class gtpu : public gtpu_interface_rrc, public gtpu_interface_pdcp +class gtpu final : public gtpu_interface_rrc, public gtpu_interface_pdcp { public: gtpu(); @@ -51,20 +50,19 @@ public: void stop(); // gtpu_interface_rrc - void add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t teid_out, uint32_t *teid_in); - void rem_bearer(uint16_t rnti, uint32_t lcid); - void rem_user(uint16_t rnti); + void add_bearer(uint16_t rnti, uint32_t lcid, uint32_t addr, uint32_t teid_out, uint32_t* teid_in) override; + void rem_bearer(uint16_t rnti, uint32_t lcid) override; + void rem_user(uint16_t rnti) override; // gtpu_interface_pdcp - void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu); + void write_pdu(uint16_t rnti, uint32_t lcid, srslte::unique_byte_buffer_t pdu) override; // stack interface - void handle_gtpu_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); - void handle_gtpu_mch_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); + void handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); + void handle_gtpu_m1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); private: - static const int THREAD_PRIO = 65; - static const int GTPU_PORT = 2152; + static const int GTPU_PORT = 2152; srslte::byte_buffer_pool* pool = nullptr; stack_interface_gtpu_lte* stack = nullptr; @@ -76,15 +74,15 @@ private: srslte::log* gtpu_log = nullptr; // Class to create - class mch_handler + class m1u_handler { public: - explicit mch_handler(gtpu* gtpu_) : parent(gtpu_) {} - ~mch_handler(); - mch_handler(const mch_handler&) = delete; - mch_handler(mch_handler&&) = delete; - mch_handler& operator=(const mch_handler&) = delete; - mch_handler& operator=(mch_handler&&) = delete; + explicit m1u_handler(gtpu* gtpu_) : parent(gtpu_) {} + ~m1u_handler(); + m1u_handler(const m1u_handler&) = delete; + m1u_handler(m1u_handler&&) = delete; + m1u_handler& operator=(const m1u_handler&) = delete; + m1u_handler& operator=(m1u_handler&&) = delete; bool init(std::string m1u_multiaddr_, std::string m1u_if_addr_); void handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr); @@ -99,15 +97,13 @@ private: int m1u_sd = -1; int lcid_counter = 0; }; - - // MCH thread insteance - mch_handler mch; + m1u_handler m1u; 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]; - }bearer_map; + } bearer_map; std::map rnti_bearers; // Socket file descriptor @@ -120,11 +116,10 @@ private: /**************************************************************************** * 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); + 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 #endif // SRSENB_GTPU_H diff --git a/srsenb/src/stack/enb_stack_lte.cc b/srsenb/src/stack/enb_stack_lte.cc index 959c48e29..1c252d545 100644 --- a/srsenb/src/stack/enb_stack_lte.cc +++ b/srsenb/src/stack/enb_stack_lte.cc @@ -243,22 +243,22 @@ void enb_stack_lte::remove_mme_socket(int fd) rx_sockets->remove_socket(fd); } -void enb_stack_lte::add_gtpu_socket(int fd) +void enb_stack_lte::add_gtpu_s1u_socket_handler(int fd) { - auto gtpu_rx_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) { - auto task_handler = [this, from](task_t* t) { gtpu.handle_gtpu_rx_packet(std::move(t->pdu), from); }; + auto gtpu_s1u_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) { + auto task_handler = [this, &from](task_t* t) { gtpu.handle_gtpu_s1u_rx_packet(std::move(t->pdu), from); }; pending_tasks.push(gtpu_queue_id, task_t{task_handler, std::move(pdu)}); }; - rx_sockets->add_socket_pdu_handler(fd, gtpu_rx_handler); + rx_sockets->add_socket_pdu_handler(fd, gtpu_s1u_handler); } -void enb_stack_lte::add_gtpu_mch_socket(int fd) +void enb_stack_lte::add_gtpu_m1u_socket_handler(int fd) { - auto gtpu_mch_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) { - auto task_handler = [this, from](task_t* t) { gtpu.handle_gtpu_mch_rx_packet(std::move(t->pdu), from); }; + auto gtpu_m1u_handler = [this](srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) { + auto task_handler = [this, &from](task_t* t) { gtpu.handle_gtpu_m1u_rx_packet(std::move(t->pdu), from); }; pending_tasks.push(gtpu_queue_id, task_t{task_handler, std::move(pdu)}); }; - rx_sockets->add_socket_pdu_handler(fd, gtpu_mch_handler); + rx_sockets->add_socket_pdu_handler(fd, gtpu_m1u_handler); } } // namespace srsenb diff --git a/srsenb/src/stack/mac/mac.cc b/srsenb/src/stack/mac/mac.cc index 024410b6a..9716a88ab 100644 --- a/srsenb/src/stack/mac/mac.cc +++ b/srsenb/src/stack/mac/mac.cc @@ -694,12 +694,12 @@ int mac::get_mch_sched(uint32_t tti, bool is_mcch, dl_sched_t* dl_sched_res) mch.mtch_sched[0].lcid, mch.mtch_sched[mch.num_mtch_sched - 1].stop, tti); phy_h->set_mch_period_stop(mch.mtch_sched[mch.num_mtch_sched - 1].stop); - for(uint32_t i = 0; i < mch.num_mtch_sched; i++) { + for (uint32_t i = 0; i < mch.num_mtch_sched; i++) { mch.pdu[i].lcid = srslte::sch_subh::MCH_SCHED_INFO; - // mch.mtch_sched[i].lcid = 1+i; + // m1u.mtch_sched[i].lcid = 1+i; } - mch.pdu[mch.num_mtch_sched].lcid = 0; + mch.pdu[mch.num_mtch_sched].lcid = 0; mch.pdu[mch.num_mtch_sched].nbytes = current_mcch_length; dl_sched_res->pdsch[0].dci.rnti = SRSLTE_MRNTI; diff --git a/srsenb/src/stack/upper/gtpu.cc b/srsenb/src/stack/upper/gtpu.cc index e602890a5..bb99f53ea 100644 --- a/srsenb/src/stack/upper/gtpu.cc +++ b/srsenb/src/stack/upper/gtpu.cc @@ -30,7 +30,7 @@ using namespace srslte; namespace srsenb { -gtpu::gtpu() : mch(this) +gtpu::gtpu() : m1u(this) { pthread_mutex_init(&mutex, nullptr); } @@ -79,12 +79,12 @@ bool gtpu::init(std::string gtp_bind_addr_, return false; } - stack->add_gtpu_socket(fd); + stack->add_gtpu_s1u_socket_handler(fd); // Start MCH socket if enabled enable_mbsfn = enable_mbsfn_; if (enable_mbsfn) { - if (not mch.init(m1u_multiaddr_, m1u_if_addr_)) { + if (not m1u.init(m1u_multiaddr_, m1u_if_addr_)) { return false; } } @@ -192,7 +192,7 @@ void gtpu::rem_user(uint16_t rnti) pthread_mutex_unlock(&mutex); } -void gtpu::handle_gtpu_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& from) +void gtpu::handle_gtpu_s1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) { gtpu_log->debug("Received %d bytes from S1-U interface\n", pdu->N_bytes); @@ -204,7 +204,7 @@ void gtpu::handle_gtpu_rx_packet(srslte::unique_byte_buffer_t pdu, const sockadd switch (header.message_type) { case GTPU_MSG_ECHO_REQUEST: // Echo request - send response - echo_response(from.sin_addr.s_addr, from.sin_port, header.seq_number); + echo_response(addr.sin_addr.s_addr, addr.sin_port, header.seq_number); break; case GTPU_MSG_DATA_PDU: { uint16_t rnti = 0; @@ -235,9 +235,9 @@ void gtpu::handle_gtpu_rx_packet(srslte::unique_byte_buffer_t pdu, const sockadd } } -void gtpu::handle_gtpu_mch_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) +void gtpu::handle_gtpu_m1u_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) { - mch.handle_rx_packet(std::move(pdu), addr); + m1u.handle_rx_packet(std::move(pdu), addr); } void gtpu::echo_response(in_addr_t addr, in_port_t port, uint16_t seq) @@ -281,10 +281,10 @@ void gtpu::rntilcid_to_teidin(uint16_t rnti, uint16_t lcid, uint32_t *teidin) } /**************************************************************************** - * Class to run the MCH thread + * Class to handle MCH packet handling ***************************************************************************/ -gtpu::mch_handler::~mch_handler() +gtpu::m1u_handler::~m1u_handler() { if (initiated) { close(m1u_sd); @@ -292,7 +292,7 @@ gtpu::mch_handler::~mch_handler() } } -bool gtpu::mch_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr_) +bool gtpu::m1u_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr_) { m1u_multiaddr = std::move(m1u_multiaddr_); m1u_if_addr = std::move(m1u_if_addr_); @@ -300,9 +300,8 @@ bool gtpu::mch_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr gtpu_log = parent->gtpu_log; // Set up sink socket - struct sockaddr_in bindaddr { - }; - m1u_sd = socket(AF_INET, SOCK_DGRAM, 0); + struct sockaddr_in bindaddr = {}; + m1u_sd = socket(AF_INET, SOCK_DGRAM, 0); if (m1u_sd < 0) { gtpu_log->error("Failed to create M1-U sink socket\n"); return false; @@ -333,12 +332,12 @@ bool gtpu::mch_handler::init(std::string m1u_multiaddr_, std::string m1u_if_addr lcid_counter = 1; // Register socket in stack rx sockets thread - parent->stack->add_gtpu_mch_socket(m1u_sd); + parent->stack->add_gtpu_m1u_socket_handler(m1u_sd); return true; } -void gtpu::mch_handler::handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) +void gtpu::m1u_handler::handle_rx_packet(srslte::unique_byte_buffer_t pdu, const sockaddr_in& addr) { gtpu_log->debug("Received %d bytes from M1-U interface\n", pdu->N_bytes);