From 892ff2c36a4c160f1bf605797b7619275efbd4a1 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 17 Jan 2018 16:45:07 +0100 Subject: [PATCH] add configuration for GW --- lib/include/srslte/common/interfaces_common.h | 11 +++++++++++ srsue/hdr/upper/gw.h | 5 +++-- srsue/src/upper/gw.cc | 14 +++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/include/srslte/common/interfaces_common.h b/lib/include/srslte/common/interfaces_common.h index 5fe26bc13..1ddcb5150 100644 --- a/lib/include/srslte/common/interfaces_common.h +++ b/lib/include/srslte/common/interfaces_common.h @@ -45,6 +45,17 @@ public: }; +class srslte_gw_config_t +{ +public: + srslte_gw_config_t(uint32_t lcid_ = 0) + :lcid(lcid_) + {} + + uint32_t lcid; +}; + + class srslte_pdcp_config_t { public: diff --git a/srsue/hdr/upper/gw.h b/srsue/hdr/upper/gw.h index b97ceb6c5..aa5b2c70f 100644 --- a/srsue/hdr/upper/gw.h +++ b/srsue/hdr/upper/gw.h @@ -31,6 +31,7 @@ #include "srslte/common/log.h" #include "srslte/common/common.h" #include "srslte/common/msg_queue.h" +#include "srslte/common/interfaces_common.h" #include "srslte/interfaces/ue_interfaces.h" #include "srslte/common/threads.h" #include "gw_metrics.h" @@ -46,7 +47,7 @@ class gw { public: gw(); - void init(pdcp_interface_gw *pdcp_, nas_interface_gw *nas_, srslte::log *gw_log_, uint32_t lcid_); + void init(pdcp_interface_gw *pdcp_, nas_interface_gw *nas_, srslte::log *gw_log_, srslte::srslte_gw_config_t); void stop(); void get_metrics(gw_metrics_t &m); @@ -72,13 +73,13 @@ private: srslte::byte_buffer_pool *pool; srslte::log *gw_log; + srslte::srslte_gw_config_t cfg; bool running; bool run_enable; int32 tun_fd; struct ifreq ifr; int32 sock; bool if_up; - uint32_t lcid; uint32_t current_ip_addr; diff --git a/srsue/src/upper/gw.cc b/srsue/src/upper/gw.cc index 1e3e81999..d8b4a8fdc 100644 --- a/srsue/src/upper/gw.cc +++ b/srsue/src/upper/gw.cc @@ -47,13 +47,13 @@ gw::gw() default_netmask = true; } -void gw::init(pdcp_interface_gw *pdcp_, nas_interface_gw *nas_, srslte::log *gw_log_, uint32_t lcid_) +void gw::init(pdcp_interface_gw *pdcp_, nas_interface_gw *nas_, srslte::log *gw_log_, srslte::srslte_gw_config_t cfg_) { pool = srslte::byte_buffer_pool::get_instance(); pdcp = pdcp_; nas = nas_; gw_log = gw_log_; - lcid = lcid_; + cfg = cfg_; run_enable = true; gettimeofday(&metrics_time[1], NULL); @@ -273,9 +273,9 @@ void gw::run_thread() { gw_log->info_hex(pdu->msg, pdu->N_bytes, "TX PDU"); - while(run_enable && !pdcp->is_drb_enabled(lcid) && attach_attempts < ATTACH_MAX_ATTEMPTS) { + while(run_enable && !pdcp->is_drb_enabled(cfg.lcid) && attach_attempts < ATTACH_MAX_ATTEMPTS) { if (attach_cnt == 0) { - gw_log->info("LCID=%d not active, requesting NAS attach (%d/%d)\n", lcid, attach_attempts, ATTACH_MAX_ATTEMPTS); + gw_log->info("LCID=%d not active, requesting NAS attach (%d/%d)\n", cfg.lcid, attach_attempts, ATTACH_MAX_ATTEMPTS); nas->attach_request(); attach_attempts++; } @@ -287,7 +287,7 @@ void gw::run_thread() } if (attach_attempts == ATTACH_MAX_ATTEMPTS) { - gw_log->warning("LCID=%d was not active after %d attempts\n", lcid, ATTACH_MAX_ATTEMPTS); + gw_log->warning("LCID=%d was not active after %d attempts\n", cfg.lcid, ATTACH_MAX_ATTEMPTS); } attach_attempts = 0; @@ -298,10 +298,10 @@ void gw::run_thread() } // Send PDU directly to PDCP - if (pdcp->is_drb_enabled(lcid)) { + if (pdcp->is_drb_enabled(cfg.lcid)) { pdu->set_timestamp(); ul_tput_bytes += pdu->N_bytes; - pdcp->write_sdu(lcid, pdu); + pdcp->write_sdu(cfg.lcid, pdu); do { pdu = pool_allocate;