From 1a7142d73f460d12654b414d4284cf4b1ce52662 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 5 Nov 2019 16:53:17 +0100 Subject: [PATCH] fix GW init procedure and set pool instance in ctor --- srsue/hdr/stack/upper/gw.h | 37 ++++++++++++++++++------------------- srsue/src/stack/upper/gw.cc | 10 +--------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/srsue/hdr/stack/upper/gw.h b/srsue/hdr/stack/upper/gw.h index d885a28e2..5da437573 100644 --- a/srsue/hdr/stack/upper/gw.h +++ b/srsue/hdr/stack/upper/gw.h @@ -70,27 +70,27 @@ public: private: static const int GW_THREAD_PRIO = 7; - stack_interface_gw* stack; - srslte::byte_buffer_pool* pool; - srslte::logger* logger; - - gw_args_t args; - - bool running; - bool run_enable; - int32_t tun_fd; - struct ifreq ifr; - int32_t sock; - bool if_up; + stack_interface_gw* stack = nullptr; + srslte::byte_buffer_pool* pool = nullptr; + srslte::logger* logger = nullptr; + + gw_args_t args = {}; + + bool running = false; + bool run_enable = false; + int32_t tun_fd = 0; + struct ifreq ifr = {}; + int32_t sock = 0; + bool if_up = false; uint32_t default_lcid = 0; srslte::log_filter log; - uint32_t current_ip_addr; + uint32_t current_ip_addr = 0; uint8_t current_if_id[8]; - long ul_tput_bytes; - long dl_tput_bytes; + long ul_tput_bytes = 0; + long dl_tput_bytes = 0; struct timeval metrics_time[3]; void run_thread(); @@ -101,9 +101,9 @@ private: 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 + int mbsfn_sock_fd = 0; // 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; @@ -115,5 +115,4 @@ private: } // namespace srsue - #endif // SRSUE_GW_H diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index 71d0d53a0..f638951b4 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -34,14 +34,10 @@ namespace srsue { -gw::gw() : if_up(false), default_lcid(0), thread("GW") -{ - current_ip_addr = 0; -} +gw::gw() : thread("GW"), pool(srslte::byte_buffer_pool::get_instance()) {} int gw::init(const gw_args_t& args_, srslte::logger* logger_, stack_interface_gw* stack_) { - pool = srslte::byte_buffer_pool::get_instance(); stack = stack_; logger = logger_; args = args_; @@ -52,8 +48,6 @@ int gw::init(const gw_args_t& args_, srslte::logger* logger_, stack_interface_gw log.set_hex_limit(args.log.gw_hex_limit); gettimeofday(&metrics_time[1], NULL); - dl_tput_bytes = 0; - ul_tput_bytes = 0; // MBSFN mbsfn_sock_fd = socket(AF_INET, SOCK_DGRAM, 0); @@ -69,8 +63,6 @@ int gw::init(const gw_args_t& args_, srslte::logger* logger_, stack_interface_gw mbsfn_sock_addr.sin_family = AF_INET; mbsfn_sock_addr.sin_addr.s_addr =inet_addr("127.0.0.1"); - bzero(mbsfn_ports, SRSLTE_N_MCH_LCIDS*sizeof(uint32_t)); - return SRSLTE_SUCCESS; }