From ff3e7c321dd8c46e117cdb5e534c21b37aaa9090 Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Fri, 4 Jun 2021 10:29:02 +0200 Subject: [PATCH] Added bref function for calc distance til end --- lib/include/srsran/asn1/asn1_utils.h | 1 + lib/src/asn1/asn1_utils.cc | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/include/srsran/asn1/asn1_utils.h b/lib/include/srsran/asn1/asn1_utils.h index 8c583141d..0361359e9 100644 --- a/lib/include/srsran/asn1/asn1_utils.h +++ b/lib/include/srsran/asn1/asn1_utils.h @@ -142,6 +142,7 @@ public: int distance() const; int distance_bytes(uint8_t* ref_ptr) const; int distance_bytes() const; + int distance_bytes_end() const; template SRSASN_CODE unpack(T& val, uint32_t n_bits) diff --git a/lib/src/asn1/asn1_utils.cc b/lib/src/asn1/asn1_utils.cc index 2e4b81259..6433d8d7a 100644 --- a/lib/src/asn1/asn1_utils.cc +++ b/lib/src/asn1/asn1_utils.cc @@ -129,6 +129,11 @@ int bit_ref_impl::distance_bytes() const { return ((int)(ptr - start_ptr)) + ((offset) ? 1 : 0); } +template +int bit_ref_impl::distance_bytes_end() const +{ + return ((int)(max_ptr - ptr)) - ((offset) ? 1 : 0); +} SRSASN_CODE bit_ref::pack(uint64_t val, uint32_t n_bits) {