From db2c43553eaf6701136a7149ecb119288c5df201 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Fri, 22 Nov 2019 22:17:43 +0100 Subject: [PATCH] add basic rlc_am_base class containing data/control PDU check --- lib/include/srslte/upper/rlc_am_base.h | 3 +++ lib/include/srslte/upper/rlc_am_lte.h | 11 ++++---- lib/src/upper/CMakeLists.txt | 1 + lib/src/upper/rlc_am_base.cc | 37 ++++++++++++++++++++++++++ lib/src/upper/rlc_am_lte.cc | 10 ------- 5 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 lib/src/upper/rlc_am_base.cc diff --git a/lib/include/srslte/upper/rlc_am_base.h b/lib/include/srslte/upper/rlc_am_base.h index d29264ed1..8e95c9eba 100644 --- a/lib/include/srslte/upper/rlc_am_base.h +++ b/lib/include/srslte/upper/rlc_am_base.h @@ -37,6 +37,9 @@ namespace srslte { ///< Add rlc_am_base here +bool rlc_am_is_control_pdu(uint8_t* payload); +bool rlc_am_is_control_pdu(byte_buffer_t* pdu); + } // namespace srslte #endif // SRSLTE_RLC_AM_BASE_H diff --git a/lib/include/srslte/upper/rlc_am_lte.h b/lib/include/srslte/upper/rlc_am_lte.h index 15de3b097..72abd3b54 100644 --- a/lib/include/srslte/upper/rlc_am_lte.h +++ b/lib/include/srslte/upper/rlc_am_lte.h @@ -23,15 +23,16 @@ #define SRSLTE_RLC_AM_LTE_H #include "srslte/common/buffer_pool.h" -#include "srslte/common/log.h" #include "srslte/common/common.h" -#include "srslte/interfaces/ue_interfaces.h" -#include "srslte/upper/rlc_tx_queue.h" +#include "srslte/common/log.h" #include "srslte/common/timeout.h" +#include "srslte/interfaces/ue_interfaces.h" +#include "srslte/upper/rlc_am_base.h" #include "srslte/upper/rlc_common.h" -#include +#include "srslte/upper/rlc_tx_queue.h" #include #include +#include namespace srslte { @@ -303,8 +304,6 @@ uint32_t rlc_am_packed_length(rlc_amd_pdu_header_t* header); uint32_t rlc_am_packed_length(rlc_status_pdu_t* status); uint32_t rlc_am_packed_length(rlc_amd_retx_t retx); bool rlc_am_is_valid_status_pdu(const rlc_status_pdu_t& status); -bool rlc_am_is_control_pdu(byte_buffer_t* pdu); -bool rlc_am_is_control_pdu(uint8_t* payload); bool rlc_am_is_pdu_segment(uint8_t* payload); std::string rlc_am_status_pdu_to_string(rlc_status_pdu_t* status); std::string rlc_amd_pdu_header_to_string(const rlc_amd_pdu_header_t& header); diff --git a/lib/src/upper/CMakeLists.txt b/lib/src/upper/CMakeLists.txt index 9bac16c28..56f4471f6 100644 --- a/lib/src/upper/CMakeLists.txt +++ b/lib/src/upper/CMakeLists.txt @@ -28,6 +28,7 @@ set(SOURCES gtpu.cc rlc_um_base.cc rlc_um_lte.cc rlc_um_nr.cc + rlc_am_base.cc rlc_am_lte.cc rlc_am_nr.cc) add_library(srslte_upper STATIC ${SOURCES}) diff --git a/lib/src/upper/rlc_am_base.cc b/lib/src/upper/rlc_am_base.cc new file mode 100644 index 000000000..2fb050a27 --- /dev/null +++ b/lib/src/upper/rlc_am_base.cc @@ -0,0 +1,37 @@ +/* + * Copyright 2013-2019 Software Radio Systems Limited + * + * This file is part of srsLTE. + * + * srsLTE is free software: you can redistribute it and/or modify + * 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. + * + * srsLTE is distributed in the hope that it will be useful, + * 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/. + * + */ + +#include "srslte/upper/rlc_am_base.h" +#include + +namespace srslte { + +bool rlc_am_is_control_pdu(uint8_t* payload) +{ + return ((*(payload) >> 7) & 0x01) == RLC_DC_FIELD_CONTROL_PDU; +} + +bool rlc_am_is_control_pdu(byte_buffer_t* pdu) +{ + return rlc_am_is_control_pdu(pdu->msg); +} + +} // namespace srslte diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index 7f199b0ff..de3e340e8 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -2035,16 +2035,6 @@ uint32_t rlc_am_packed_length(rlc_status_pdu_t *status) return (len_bits+7)/8; // Convert to bytes - integer rounding up } -bool rlc_am_is_control_pdu(byte_buffer_t *pdu) -{ - return rlc_am_is_control_pdu(pdu->msg); -} - -bool rlc_am_is_control_pdu(uint8_t *payload) -{ - return ((*(payload) >> 7) & 0x01) == RLC_DC_FIELD_CONTROL_PDU; -} - bool rlc_am_is_pdu_segment(uint8_t *payload) { return ((*(payload) >> 6) & 0x01) == 1;