updated rrc to new srsasn1 version

master
Francisco Paisana 5 years ago
parent 1212d403c6
commit d270518d69

@ -26,14 +26,24 @@
#include <array>
#include <cmath>
#include <cstring>
#include <limits>
#include <map>
#include <sstream>
#include <stdarg.h> /* va_list, va_start, va_arg, va_end */
#include <stdint.h>
#include <string>
#include <vector>
namespace asn1 {
#define ASN_16K 16383
#define ASN_16K 16384
#define ASN_64K 65536
template <class Integer>
constexpr Integer ceil_frac(Integer n, Integer d)
{
return (n + (d - 1)) / d;
}
/************************
logging
@ -59,7 +69,7 @@ void log_error_code(SRSASN_CODE code, const char* filename, int line);
#define HANDLE_CODE(ret) \
{ \
SRSASN_CODE macrocode = (ret); \
SRSASN_CODE macrocode = ((ret)); \
if (macrocode != SRSASN_SUCCESS) { \
log_error_code(macrocode, __FILE__, __LINE__); \
return macrocode; \
@ -129,7 +139,7 @@ public:
using const_iterator = const T*;
dyn_array() = default;
dyn_array(uint32_t new_size) : size_(new_size), cap_(new_size) { data_ = new T[size_]; }
explicit dyn_array(uint32_t new_size) : size_(new_size), cap_(new_size) { data_ = new T[size_]; }
dyn_array(const dyn_array<T>& other)
{
size_ = other.size_;
@ -243,6 +253,98 @@ private:
uint32_t current_size;
};
/**
* This array does small buffer optimization. The array has a small stack (Nthres elements) to store elements. Once
* the number of elements exceeds this stack, the array allocs on the heap.
* @tparam T
* @tparam Nthres number of elements T that can be stored in the stack
*/
template <class T, uint32_t Nthres = ceil_frac(16lu, sizeof(T))>
class ext_array
{
public:
static const uint32_t small_buffer_size = Nthres;
ext_array() : size_(0), head(&small_buffer.data[0]) {}
explicit ext_array(uint32_t new_size) : ext_array() { resize(new_size); }
ext_array(const ext_array<T, Nthres>& other) : ext_array(other.size_)
{
std::copy(other.head, other.head + other.size_, head);
}
ext_array(ext_array<T, Nthres>&& other) noexcept
{
size_ = other.size();
if (other.is_in_small_buffer()) {
head = &small_buffer.data[0];
std::copy(other.data(), other.data() + other.size(), head);
} else {
head = other.head;
small_buffer.cap_ = other.small_buffer.cap_;
other.head = &other.small_buffer.data[0];
other.size_ = 0;
}
}
~ext_array()
{
if (not is_in_small_buffer()) {
delete[] head;
}
}
ext_array<T, Nthres>& operator=(const ext_array<T, Nthres>& other)
{
if (this != &other) {
resize(other.size());
std::copy(other.data(), other.data() + other.size(), head);
}
return *this;
}
uint32_t size() const { return size_; }
uint32_t capacity() const { return is_in_small_buffer() ? Nthres : small_buffer.cap_; }
T& operator[](uint32_t index) { return head[index]; }
const T& operator[](uint32_t index) const { return head[index]; }
T* data() { return &head[0]; }
const T* data() const { return &head[0]; }
T& back() { return head[size() - 1]; }
const T& back() const { return head[size() - 1]; }
bool operator==(const ext_array<T, Nthres>& other) const
{
return other.size() == size() and std::equal(other.data(), other.data() + other.size(), data());
}
void push_back(const T& elem)
{
resize(size() + 1);
head[size() - 1] = elem;
}
void resize(uint32_t new_size)
{
if (new_size == size_) {
return;
}
if (capacity() >= new_size) {
size_ = new_size;
return;
}
T* old_data = head;
uint32_t newcap = new_size + 5;
head = new T[newcap];
std::copy(&small_buffer.data[0], &small_buffer.data[size_], head);
size_ = new_size;
if (old_data != &small_buffer.data[0]) {
delete[] old_data;
}
small_buffer.cap_ = newcap;
}
bool is_in_small_buffer() const { return head == &small_buffer.data[0]; }
private:
union {
T data[Nthres];
uint32_t cap_;
} small_buffer;
uint32_t size_;
T* head;
};
/*********************
ext packing
*********************/
@ -250,6 +352,15 @@ private:
SRSASN_CODE pack_unsupported_ext_flag(bit_ref& bref, bool ext);
SRSASN_CODE unpack_unsupported_ext_flag(bool& ext, bit_ref& bref);
/************************
asn1 null packing
************************/
struct asn1_null_t {
SRSASN_CODE pack(bit_ref& bref) const { return SRSASN_SUCCESS; }
SRSASN_CODE unpack(bit_ref& bref) const { return SRSASN_SUCCESS; }
};
/************************
enum packing
************************/
@ -337,66 +448,26 @@ public:
};
/************************
integer packing
PER encoding
************************/
// Constrained Whole Number
template <class IntType>
SRSASN_CODE pack_unalign_integer(bit_ref& bref, IntType n, IntType lb, IntType ub);
/* X.691 - Section 10.5 - Constrained Whole Number */
template <class IntType>
SRSASN_CODE unpack_unalign_integer(IntType& n, bit_ref& bref, IntType lb, IntType ub);
SRSASN_CODE pack_constrained_whole_number(bit_ref& bref, IntType n, IntType lb, IntType ub, bool aligned);
template <class IntType>
struct UnalignedIntegerPacker {
UnalignedIntegerPacker(IntType lb_, IntType ub_) : lb(lb_), ub(ub_) {}
const IntType lb;
const IntType ub;
SRSASN_CODE pack(bit_ref& bref, IntType n) const;
SRSASN_CODE unpack(IntType& n, bit_ref& bref) const;
};
template <class IntType, IntType lb, IntType ub>
struct unaligned_integer {
IntType value;
unaligned_integer() = default;
unaligned_integer(IntType value_) : value(value_) {}
operator IntType() { return value; }
SRSASN_CODE pack(bit_ref& bref) const { return pack_unalign_integer(bref, value, lb, ub); }
SRSASN_CODE unpack(bit_ref& bref) { return unpack_unalign_integer(value, bref, lb, ub); }
};
template <class IntType>
SRSASN_CODE pack_align_integer(bit_ref& bref, IntType n, IntType lb, IntType ub);
template <typename IntType>
SRSASN_CODE unpack_align_integer(IntType& intval, bit_ref& bref, IntType lb, IntType ub);
template <class IntType>
struct AlignedIntegerPacker {
AlignedIntegerPacker(IntType lb_, IntType ub_);
IntType lb;
IntType ub;
SRSASN_CODE pack(bit_ref& bref, IntType n);
SRSASN_CODE unpack(IntType& n, bit_ref& bref);
};
SRSASN_CODE unpack_constrained_whole_number(IntType& n, bit_ref& bref, IntType lb, IntType ub, bool aligned);
// Normally Small non-negative whole number
/* X.691 - Section 10.6 - Normally small non-negative whole Number */
template <typename UintType>
SRSASN_CODE pack_norm_small_integer(bit_ref& bref, UintType n);
SRSASN_CODE pack_norm_small_non_neg_whole_number(bit_ref& bref, UintType n);
template <typename UintType>
SRSASN_CODE unpack_norm_small_integer(UintType& n, bit_ref& bref);
SRSASN_CODE unpack_norm_small_non_neg_whole_number(UintType& n, bit_ref& bref);
// Unconstrained Whole Number
// FIXME: Implement
inline SRSASN_CODE pack_unconstrained_integer(bit_ref& bref, int64_t n)
{
// TODO
srsasn_log_print(LOG_LEVEL_ERROR, "Not implemented\n");
return SRSASN_SUCCESS;
}
inline SRSASN_CODE unpack_unconstrained_integer(int64_t& n, bit_ref& bref)
{
// TODO
srsasn_log_print(LOG_LEVEL_ERROR, "Not implemented\n");
return SRSASN_SUCCESS;
}
/* X.691 - Section 10.8 - Unconstrained Whole Number */
template <typename IntType>
SRSASN_CODE pack_unconstrained_whole_number(bit_ref& bref, IntType n, bool aligned);
template <typename IntType>
SRSASN_CODE unpack_unconstrained_whole_number(IntType& n, bit_ref& bref, bool aligned);
/************************
length determinant
@ -404,13 +475,66 @@ inline SRSASN_CODE unpack_unconstrained_integer(int64_t& n, bit_ref& bref)
// Pack as whole constrained number
template <typename IntType>
SRSASN_CODE pack_length(bit_ref& bref, IntType n, IntType lb, IntType ub);
SRSASN_CODE pack_length(bit_ref& bref, IntType n, IntType lb, IntType ub, bool aligned = false);
template <typename IntType>
SRSASN_CODE unpack_length(IntType& n, bit_ref& bref, IntType lb, IntType ub);
SRSASN_CODE unpack_length(IntType& n, bit_ref& bref, IntType lb, IntType ub, bool aligned = false);
// Pack as a small non-negative whole number
SRSASN_CODE pack_length(bit_ref& ref, uint32_t val);
SRSASN_CODE unpack_length(uint32_t& val, bit_ref& ref);
SRSASN_CODE pack_length(bit_ref& ref, uint32_t val, bool aligned = false);
SRSASN_CODE unpack_length(uint32_t& val, bit_ref& ref, bool aligned = false);
/************************
Integer
************************/
template <typename IntType>
SRSASN_CODE pack_integer(bit_ref& bref,
IntType n,
IntType lb = std::numeric_limits<IntType>::min(),
IntType ub = std::numeric_limits<IntType>::max(),
bool has_ext = false,
bool aligned = false);
template <typename IntType>
SRSASN_CODE unpack_integer(IntType& n,
bit_ref& bref,
IntType lb = std::numeric_limits<IntType>::min(),
IntType ub = std::numeric_limits<IntType>::max(),
bool has_ext = false,
bool aligned = false);
// unconstrained case
template <typename IntType>
SRSASN_CODE pack_unconstrained_integer(bit_ref& bref, IntType n, bool has_ext = false, bool aligned = false);
template <typename IntType>
SRSASN_CODE unpack_unconstrained_integer(IntType& n, bit_ref& bref, bool has_ext = false, bool aligned = false);
template <class IntType>
struct integer_packer {
integer_packer(IntType lb_, IntType ub_, bool has_ext_ = false, bool aligned_ = false);
SRSASN_CODE pack(bit_ref& bref, IntType n);
SRSASN_CODE unpack(IntType& n, bit_ref& bref);
IntType lb;
IntType ub;
bool has_ext;
bool aligned;
};
template <class IntType,
IntType LB = std::numeric_limits<IntType>::min(),
IntType UB = std::numeric_limits<IntType>::max(),
bool Ext = false,
bool Al = false>
class integer
{
public:
static const IntType ub = UB, lb = LB;
static const bool has_ext = Ext, is_aligned = Al;
IntType value;
integer() = default;
integer(IntType value_) : value(value_) {}
operator IntType() { return value; }
SRSASN_CODE pack(bit_ref& bref) const { return pack_integer(bref, value, lb, ub, has_ext, is_aligned); }
SRSASN_CODE unpack(bit_ref& bref) { return unpack_integer(value, bref, lb, ub, has_ext, is_aligned); }
};
/************************
General Packer/Unpacker
@ -459,7 +583,7 @@ void string_to_octstring(uint8_t* ptr, const std::string& str);
fixed_octstring
************************/
template <uint32_t N>
template <uint32_t N, bool aligned = false>
class fixed_octstring
{
public:
@ -471,7 +595,7 @@ public:
static uint32_t size() { return N; }
std::string to_string() const { return octstring_to_string(&octets_[0], N); }
fixed_octstring<N>& from_string(const std::string& hexstr)
fixed_octstring<N, aligned>& from_string(const std::string& hexstr)
{
if (hexstr.size() != 2 * N) {
srsasn_log_print(LOG_LEVEL_ERROR, "The provided hex string size is not valid (%d!=2*%d).\n", hexstr.size(), N);
@ -481,7 +605,7 @@ public:
return *this;
}
uint64_t to_number() const { return octstring_to_number(&octets_[0], size()); }
fixed_octstring<N>& from_number(uint64_t val)
fixed_octstring<N, aligned>& from_number(uint64_t val)
{
number_to_octstring(&octets_[0], val, size());
return *this;
@ -494,24 +618,31 @@ private:
std::array<uint8_t, N> octets_;
};
template <uint32_t N>
SRSASN_CODE fixed_octstring<N>::pack(bit_ref& bref) const
/**
* X.691 Section 16 - Encoding the octetstring type
* @tparam N - number of items
* @tparam ext - aligned variant
* @param bref
* @return
*/
template <uint32_t N, bool aligned>
SRSASN_CODE fixed_octstring<N, aligned>::pack(bit_ref& bref) const
{
// if(N > 2) { // X.691 Sec.16
// bref.align_bytes_zero();
// }
if (aligned and N > 2) {
bref.align_bytes_zero();
}
for (uint32_t i = 0; i < size(); ++i) {
bref.pack(octets_[i], 8);
HANDLE_CODE(bref.pack(octets_[i], 8));
}
return SRSASN_SUCCESS;
}
template <uint32_t N>
SRSASN_CODE fixed_octstring<N>::unpack(bit_ref& bref)
template <uint32_t N, bool aligned>
SRSASN_CODE fixed_octstring<N, aligned>::unpack(bit_ref& bref)
{
// if(N > 2) { // X.691 Sec.16
// bref.align_bytes_zero();
// }
if (aligned and N > 2) {
bref.align_bytes_zero();
}
for (uint32_t i = 0; i < size(); ++i) {
HANDLE_CODE(bref.unpack(octets_[i], 8));
}
@ -522,15 +653,18 @@ SRSASN_CODE fixed_octstring<N>::unpack(bit_ref& bref)
dyn_octstring
************************/
class dyn_octstring
template <bool Al = false>
class unbounded_octstring
{
public:
dyn_octstring() = default;
dyn_octstring(uint32_t new_size) : octets_(new_size) {}
static const bool aligned = Al;
unbounded_octstring() = default;
explicit unbounded_octstring(uint32_t new_size) : octets_(new_size) {}
const uint8_t& operator[](uint32_t idx) const { return octets_[idx]; }
uint8_t& operator[](uint32_t idx) { return octets_[idx]; }
bool operator==(const dyn_octstring& other) const { return octets_ == other.octets_; }
bool operator==(const unbounded_octstring<Al>& other) const { return octets_ == other.octets_; }
void resize(uint32_t new_size) { octets_.resize(new_size); }
uint32_t size() const { return octets_.size(); }
uint8_t* data() { return &octets_[0]; }
@ -539,9 +673,9 @@ public:
SRSASN_CODE pack(bit_ref& ie_ref) const;
SRSASN_CODE unpack(bit_ref& ie_ref);
std::string to_string() const;
dyn_octstring& from_string(const std::string& hexstr);
unbounded_octstring<Al>& from_string(const std::string& hexstr);
uint64_t to_number() const { return octstring_to_number(&octets_[0], size()); }
dyn_octstring& from_number(uint64_t val)
unbounded_octstring<Al>& from_number(uint64_t val)
{
number_to_octstring(&octets_[0], val, size());
return *this;
@ -551,6 +685,8 @@ private:
dyn_array<uint8_t> octets_;
};
using dyn_octstring = unbounded_octstring<false>;
/*********************
common bitstring
*********************/
@ -563,16 +699,16 @@ inline bool bitstring_get(const uint8_t* ptr, uint32_t idx)
{
uint32_t byte_idx = idx / 8;
uint32_t offset = idx % 8;
return (ptr[byte_idx] & (1 << offset)) > 0;
return (ptr[byte_idx] & (1u << offset)) > 0;
}
inline void bitstring_set(uint8_t* ptr, uint32_t idx, bool value)
{
uint32_t byte_idx = idx / 8;
uint32_t offset = idx % 8;
if (value) {
ptr[byte_idx] |= (1 << offset);
ptr[byte_idx] |= (1u << offset);
} else {
ptr[byte_idx] &= ((uint16_t)(1 << 8) - 1) - (1 << offset);
ptr[byte_idx] &= ((uint16_t)(1u << 8) - 1) - (1 << offset);
}
}
@ -586,10 +722,13 @@ SRSASN_CODE pack_fixed_bitstring(bit_ref& bref, const uint8_t* buf, uint32_t nbi
SRSASN_CODE unpack_fixed_bitstring(uint8_t* buf, bit_ref& bref, uint32_t nbits);
SRSASN_CODE unpack_fixed_bitstring(uint8_t* buf, bool& ext, bit_ref& bref, uint32_t nbits);
template <uint32_t N>
template <uint32_t N, bool Ext = false, bool Al = false>
class fixed_bitstring
{
public:
using type_t = fixed_bitstring<N, Ext, Al>;
static const bool has_ext = Ext, is_aligned = Al;
fixed_bitstring() { memset(&octets_[0], 0, nof_octets()); }
fixed_bitstring(const std::string& s)
{
@ -603,16 +742,13 @@ public:
}
bool get(uint32_t idx) const { return bitstring_get(&octets_[0], idx); }
void set(uint32_t idx, bool value) { bitstring_set(&octets_[0], idx, value); }
bool operator==(const fixed_bitstring<N>& other) const { return octets_ == other.octets_; }
bool operator==(const char* other_str) const
{
return strlen(other_str) == N and (*this) == fixed_bitstring<N>(other_str);
}
bool operator==(const type_t& other) const { return octets_ == other.octets_; }
bool operator==(const char* other_str) const { return strlen(other_str) == N and (*this) == type_t(other_str); }
uint32_t nof_octets() const { return (uint32_t)ceilf(N / 8.0f); }
uint32_t length() const { return N; }
std::string to_string() const { return bitstring_to_string(&octets_[0], length()); }
uint64_t to_number() const { return bitstring_to_number(&octets_[0], length()); }
fixed_bitstring<N>& from_number(uint64_t val)
type_t& from_number(uint64_t val)
{
number_to_bitstring(&octets_[0], val, length());
return *this;
@ -621,53 +757,193 @@ public:
const uint8_t* data() const { return &octets_[0]; }
SRSASN_CODE pack(bit_ref& bref) const { return pack_fixed_bitstring(bref, data(), N); }
SRSASN_CODE pack(bit_ref& bref, bool ext) const { return pack_fixed_bitstring(bref, data(), N, ext); }
SRSASN_CODE unpack(bit_ref& bref) { return unpack_fixed_bitstring(data(), bref, N); }
SRSASN_CODE unpack(bit_ref& bref, bool& ext) { return unpack_fixed_bitstring(data(), ext, bref, N); }
private:
std::array<uint8_t, (uint32_t)((N + 7) / 8)> octets_; // ceil(N/8.0)
};
/*********************
dyn_bitstring
bounded_bitstring
*********************/
class dyn_bitstring
namespace bitstring_utils {
SRSASN_CODE
pack(bit_ref& bref, const uint8_t* data, uint32_t size, uint32_t lb, uint32_t ub, bool has_ext, bool is_aligned);
SRSASN_CODE unpack_length_prefix(uint32_t& len, bit_ref& bref, uint32_t lb, uint32_t ub, bool has_ext, bool is_aligned);
SRSASN_CODE unpack_bitfield(uint8_t* buf, bit_ref& bref, uint32_t n, uint32_t lb, uint32_t ub, bool is_aligned);
SRSASN_CODE
unpack_fixed_bitstring(uint8_t* buf, bit_ref& bref, uint32_t nof_bits, bool has_ext = false, bool is_aligned = false);
} // namespace bitstring_utils
template <typename BitStringType>
class base_bitstring
{
protected:
using derived_t = BitStringType;
public:
dyn_bitstring() : n_bits(0) {}
dyn_bitstring(uint32_t n_bits_);
dyn_bitstring(const char* s);
bool get(uint32_t idx) const { return bitstring_get(derived()->data(), idx); }
void set(uint32_t idx, bool value) { bitstring_set(derived()->data(), idx, value); }
uint32_t nof_octets() const { return ceil_frac(derived()->length(), 8u); }
std::string to_string() const { return bitstring_to_string(derived()->data(), derived()->length()); }
derived_t& from_string(const std::string& s)
{
if (s.size() < derived_t::lb or s.size() > derived_t::ub) {
srsasn_log_print(LOG_LEVEL_ERROR,
"The provided string size=%d is not withing the bounds [%d, %d]\n",
s.size(),
derived_t::lb,
derived_t::ub);
} else {
derived()->resize(s.size());
for (uint32_t i = 0; i < s.size(); ++i) {
set(s.size() - i - 1, s[i] == '1');
}
}
return *derived();
}
uint64_t to_number() const { return bitstring_to_number(derived()->data(), derived()->length()); }
derived_t& from_number(uint64_t val)
{
uint32_t nof_bits = (uint32_t)ceilf(log2(val));
if (nof_bits > derived()->length()) {
derived()->resize(nof_bits);
}
number_to_bitstring(derived()->data(), val, derived()->length());
return *derived();
}
bool operator==(const dyn_bitstring& other) const { return octets_ == other.octets_; }
bool operator==(const char* other_str) const;
bool get(uint32_t idx) const { return bitstring_get(&octets_[0], idx); }
void set(uint32_t idx, bool value) { bitstring_set(&octets_[0], idx, value); }
bool operator==(const base_bitstring<BitStringType>& other) const
{
return derived()->length() == other.derived()->length() and
std::equal(derived()->data(), derived()->data() + derived()->nof_octets(), other.derived()->data());
}
bool operator==(const char* other_str) const
{
return strlen(other_str) == derived()->length() and (*this) == derived_t{}.from_string(other_str);
}
void resize(uint32_t new_size);
uint32_t length() const { return n_bits; }
uint32_t nof_octets() const { return (uint32_t)ceilf(length() / 8.0f); }
std::string to_string() const { return bitstring_to_string(&octets_[0], length()); }
uint64_t to_number() const { return bitstring_to_number(&octets_[0], length()); }
dyn_bitstring& from_number(uint64_t val)
SRSASN_CODE pack(bit_ref& bref) const
{
number_to_bitstring(&octets_[0], val, length());
return *this;
return bitstring_utils::pack(bref,
derived()->data(),
derived()->length(),
derived_t::lb,
derived_t::ub,
derived_t::has_ext,
derived_t::is_aligned);
}
SRSASN_CODE unpack(bit_ref& bref)
{
// X.691, subclause 15.11
uint32_t nbits;
HANDLE_CODE(bitstring_utils::unpack_length_prefix(
nbits, bref, derived_t::lb, derived_t::ub, derived_t::has_ext, derived_t::is_aligned));
derived()->resize(nbits);
return bitstring_utils::unpack_bitfield(
derived()->data(), bref, nbits, derived_t::lb, derived_t::ub, derived_t::is_aligned);
}
private:
derived_t* derived() { return static_cast<derived_t*>(this); }
const derived_t* derived() const { return static_cast<const derived_t*>(this); }
};
template <uint32_t LB, uint32_t UB, bool ext = false, bool aligned = false>
class bounded_bitstring : public base_bitstring<bounded_bitstring<LB, UB, ext, aligned> >
{
using base_t = base_bitstring<bounded_bitstring<LB, UB> >;
public:
static const uint32_t lb = LB, ub = UB;
static const bool has_ext = ext, is_aligned = aligned;
explicit bounded_bitstring(uint32_t siz_ = 0) { resize(siz_); }
const uint8_t* data() const { return &octets_[0]; }
uint8_t* data() { return &octets_[0]; }
uint32_t length() const { return nof_bits; }
void resize(uint32_t new_size)
{
nof_bits = new_size;
octets_.resize(this->nof_octets());
memset(data(), 0, this->nof_octets());
}
private:
bounded_array<uint8_t, ceil_frac(ub, 8u)> octets_;
uint32_t nof_bits = 0;
};
/*********************
dyn_bitstring
*********************/
template <bool Ext = false, bool Al = false>
class unbounded_bitstring : public base_bitstring<unbounded_bitstring<Ext, Al> >
{
using base_t = base_bitstring<unbounded_bitstring<Ext, Al> >;
public:
static const uint32_t lb = 0, ub = std::numeric_limits<uint32_t>::max();
static const bool has_ext = Ext, is_aligned = Al;
explicit unbounded_bitstring(uint32_t siz_ = 0) { resize(siz_); }
SRSASN_CODE pack(bit_ref& bref, uint32_t lb = 0, uint32_t ub = 0) const;
SRSASN_CODE pack(bit_ref& bref, bool ext, uint32_t lb = 0, uint32_t ub = 0) const;
SRSASN_CODE unpack(bit_ref& bref, uint32_t lb = 0, uint32_t ub = 0);
SRSASN_CODE unpack(bit_ref& bref, bool& ext, uint32_t lb = 0, uint32_t ub = 0);
const uint8_t* data() const { return &octets_[0]; }
uint8_t* data() { return &octets_[0]; }
uint32_t length() const { return n_bits; }
void resize(uint32_t new_size)
{
n_bits = new_size;
octets_.resize(this->nof_octets());
memset(data(), 0, this->nof_octets()); // resize always resets content
}
private:
dyn_array<uint8_t> octets_;
uint32_t n_bits;
};
using dyn_bitstring = unbounded_bitstring<false, false>;
// class dyn_bitstring
//{
// public:
// dyn_bitstring() = default;
// dyn_bitstring(uint32_t n_bits_);
// dyn_bitstring(const char* s);
//
// bool operator==(const dyn_bitstring& other) const { return octets_ == other.octets_; }
// bool operator==(const char* other_str) const;
// bool get(uint32_t idx) const { return bitstring_get(&octets_[0], idx); }
// void set(uint32_t idx, bool value) { bitstring_set(&octets_[0], idx, value); }
//
// void resize(uint32_t new_size);
// uint32_t length() const { return n_bits; }
// uint32_t nof_octets() const { return (uint32_t)ceilf(length() / 8.0f); }
// std::string to_string() const { return bitstring_to_string(&octets_[0], length()); }
// uint64_t to_number() const { return bitstring_to_number(&octets_[0], length()); }
// dyn_bitstring& from_number(uint64_t val)
// {
// number_to_bitstring(&octets_[0], val, length());
// return *this;
// }
// const uint8_t* data() const { return &octets_[0]; }
// uint8_t* data() { return &octets_[0]; }
//
// SRSASN_CODE pack(bit_ref& bref, uint32_t lb = 0, uint32_t ub = 0) const;
// SRSASN_CODE pack(bit_ref& bref, bool ext, uint32_t lb = 0, uint32_t ub = 0) const;
// SRSASN_CODE unpack(bit_ref& bref, uint32_t lb = 0, uint32_t ub = 0);
// SRSASN_CODE unpack(bit_ref& bref, bool& ext, uint32_t lb = 0, uint32_t ub = 0);
//
// private:
// dyn_array<uint8_t> octets_;
// uint32_t n_bits = 0;
//};
/*********************
fixed sequence of
*********************/
@ -729,9 +1005,14 @@ struct FixedSeqOfPacker {
*********************/
template <class ArrayType, class ItemPacker>
SRSASN_CODE pack_dyn_seq_of(bit_ref& bref, const ArrayType& seqof, uint32_t lb, uint32_t ub, ItemPacker packer)
{
HANDLE_CODE(pack_length(bref, seqof.size(), lb, ub));
SRSASN_CODE pack_dyn_seq_of(bit_ref& bref,
const ArrayType& seqof,
uint32_t lb,
uint32_t ub,
ItemPacker packer,
bool aligned = false)
{
HANDLE_CODE(pack_length(bref, seqof.size(), lb, ub, aligned));
for (uint32_t i = 0; i < seqof.size(); ++i) {
HANDLE_CODE(packer.pack(bref, seqof[i]));
}
@ -739,9 +1020,9 @@ SRSASN_CODE pack_dyn_seq_of(bit_ref& bref, const ArrayType& seqof, uint32_t lb,
}
template <class ArrayType>
SRSASN_CODE pack_dyn_seq_of(bit_ref& bref, const ArrayType& seqof, uint32_t lb, uint32_t ub)
SRSASN_CODE pack_dyn_seq_of(bit_ref& bref, const ArrayType& seqof, uint32_t lb, uint32_t ub, bool aligned = false)
{
HANDLE_CODE(pack_length(bref, seqof.size(), lb, ub));
HANDLE_CODE(pack_length(bref, seqof.size(), lb, ub, aligned));
for (uint32_t i = 0; i < seqof.size(); ++i) {
HANDLE_CODE(seqof[i].pack(bref));
}
@ -749,10 +1030,15 @@ SRSASN_CODE pack_dyn_seq_of(bit_ref& bref, const ArrayType& seqof, uint32_t lb,
}
template <class ArrayType, class ItemUnpacker>
SRSASN_CODE unpack_dyn_seq_of(ArrayType& seqof, bit_ref& bref, uint32_t lb, uint32_t ub, ItemUnpacker unpacker)
SRSASN_CODE unpack_dyn_seq_of(ArrayType& seqof,
bit_ref& bref,
uint32_t lb,
uint32_t ub,
ItemUnpacker unpacker,
bool aligned = false)
{
uint32_t nof_items;
HANDLE_CODE(unpack_length(nof_items, bref, lb, ub));
HANDLE_CODE(unpack_length(nof_items, bref, lb, ub, aligned));
seqof.resize(nof_items);
for (uint32_t i = 0; i < nof_items; ++i) {
HANDLE_CODE(unpacker.unpack(seqof[i], bref));
@ -761,10 +1047,10 @@ SRSASN_CODE unpack_dyn_seq_of(ArrayType& seqof, bit_ref& bref, uint32_t lb, uint
}
template <class ArrayType>
SRSASN_CODE unpack_dyn_seq_of(ArrayType& seqof, bit_ref& bref, uint32_t lb, uint32_t ub)
SRSASN_CODE unpack_dyn_seq_of(ArrayType& seqof, bit_ref& bref, uint32_t lb, uint32_t ub, bool aligned = false)
{
uint32_t nof_items;
HANDLE_CODE(unpack_length(nof_items, bref, lb, ub));
HANDLE_CODE(unpack_length(nof_items, bref, lb, ub, aligned));
seqof.resize(nof_items);
for (uint32_t i = 0; i < nof_items; ++i) {
HANDLE_CODE(seqof[i].unpack(bref));
@ -790,87 +1076,50 @@ struct SeqOfPacker {
uint32_t ub;
};
template <class ItemType, uint32_t lb, uint32_t ub>
template <class ItemType, uint32_t lb, uint32_t ub, bool aligned = false>
struct dyn_seq_of : public dyn_array<ItemType> {
SeqOfPacker<Packer> packer;
dyn_seq_of() : packer(lb, ub, Packer()) {}
dyn_seq_of(const dyn_array<ItemType>& other) : dyn_array<ItemType>(other), packer(lb, ub, Packer()) {}
SRSASN_CODE pack(bit_ref& bref) const { return packer.pack(bref, *this); }
SRSASN_CODE unpack(bit_ref& bref) { return packer.unpack(*this, bref); }
dyn_seq_of() = default;
dyn_seq_of(const dyn_array<ItemType>& other) : dyn_array<ItemType>(other) {}
SRSASN_CODE pack(bit_ref& bref) const { return pack_dyn_seq_of(bref, *this, lb, ub, aligned); }
SRSASN_CODE unpack(bit_ref& bref) { return unpack_dyn_seq_of(*this, bref, lb, ub, aligned); }
};
/*********************
choice utils
printable string
*********************/
union alignment_t {
char c;
float f;
uint32_t i;
uint64_t i2;
double d;
long double d2;
uint32_t* ptr;
};
#define MAX2(a, b) ((a) > (b)) ? (a) : (b)
#define MAX4(a, b, c, d) MAX2((MAX2(a, b)), MAX2(c, d))
#define MAX8(a, b, c, d, e, f, g, h) MAX2((MAX4(a, b, c, d)), (MAX4(e, f, g, h)))
#define MAX12(a, b, c, d, e, f, g, h, i, j, k, l) MAX2((MAX8(a, b, c, d, e, f, g, h)), (MAX4(i, j, k, l)))
#define MAX16(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
MAX2((MAX8(a, b, c, d, e, f, g, h)), (MAX8(i, j, k, l, m, n, o, p)))
#define MAX32( \
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1) \
MAX2((MAX16(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)), \
(MAX16(a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1)))
template <size_t SIZE>
class choice_buffer_t
/* X.691 - Section 27 - Character Restricted String */
namespace asn_string_utils {
SRSASN_CODE
pack(bit_ref& bref, const std::string& s, size_t lb, size_t ub, size_t alb, size_t aub, bool ext, bool aligned);
SRSASN_CODE unpack(std::string& s, bit_ref& bref, size_t lb, size_t ub, size_t alb, size_t aub, bool ext, bool aligned);
} // namespace asn_string_utils
template <uint32_t LB,
uint32_t UB,
uint32_t ALB = 0,
uint32_t AUB = std::numeric_limits<uint32_t>::max(),
bool ext = false,
bool aligned = false>
class asn_string
{
public:
struct __attribute__((__may_alias__)) bytes {
uint8_t buf_[MAX2(SIZE, 8)];
uint8_t* data() { return &buf_[0]; }
const uint8_t* data() const { return &buf_[0]; }
};
template <typename T>
T& get()
{
return *((T*)buffer.buf_.data());
}
template <typename T>
const T& get() const
{
return *((T*)buffer.buf_.data());
}
template <typename T>
void destroy()
{
((T*)buffer.buf_.data())->~T();
}
template <typename T>
void init()
{
new (buffer.buf_.data()) T();
}
template <typename T>
void init(const T& other)
{
new (buffer.buf_.data()) T(other);
}
template <typename T>
void set(const T& other)
{
get<T>() = other;
}
SRSASN_CODE pack(bit_ref& bref) const { return asn_string_utils::pack(bref, str, LB, UB, ALB, AUB, ext, aligned); }
SRSASN_CODE unpack(bit_ref& bref) { return asn_string_utils::unpack(str, bref, LB, UB, ALB, AUB, ext, aligned); }
char& operator[](std::size_t idx) { return str[idx]; }
const char& operator[](std::size_t idx) const { return str[idx]; }
void resize(std::size_t newsize) { str.resize(newsize); }
std::size_t size() const { return str.size(); }
std::string to_string() const { return str; }
void from_string(std::string s) { str = std::move(s); }
private:
union {
alignment_t a_;
bytes buf_;
} buffer;
std::string str;
};
template <uint32_t ALB = 0, uint32_t AUB = std::numeric_limits<uint32_t>::max(), bool ext = false, bool aligned = false>
using printable_string = asn_string<32, 122, ALB, AUB, ext, aligned>;
/*********************
copy_ptr
*********************/
@ -935,6 +1184,80 @@ copy_ptr<T> make_copy_ptr(const T& t)
return copy_ptr<T>(new T(t));
}
/*********************
choice utils
*********************/
union alignment_t {
char c;
float f;
uint32_t i;
uint64_t i2;
double d;
long double d2;
uint32_t* ptr;
};
template <std::size_t arg1, std::size_t... others>
struct static_max;
template <std::size_t arg>
struct static_max<arg> {
static const std::size_t value = arg;
};
template <std::size_t arg1, std::size_t arg2, std::size_t... others>
struct static_max<arg1, arg2, others...> {
static const std::size_t value =
arg1 >= arg2 ? static_max<arg1, others...>::value : static_max<arg2, others...>::value;
};
template <std::size_t Size, std::size_t Align>
struct choice_buffer_base_t {
static const std::size_t data_size = Size;
static const std::size_t data_align = Align;
using buffer_t = typename std::aligned_storage<data_size, data_align>::type;
buffer_t buffer;
template <typename T>
T& get()
{
return *(reinterpret_cast<T*>(&buffer));
}
template <typename T>
const T& get() const
{
return *(reinterpret_cast<const T*>(&buffer));
}
template <typename T>
void destroy()
{
get<T>().~T();
}
template <typename T>
void init()
{
new (&buffer) T();
}
template <typename T>
void init(const T& other)
{
new (&buffer) T(other);
}
template <typename T>
void set(const T& other)
{
get<T>() = other;
}
};
template <typename... Ts>
struct choice_buffer_t : public choice_buffer_base_t<static_max<sizeof(alignment_t), sizeof(Ts)...>::value,
static_max<alignof(alignment_t), alignof(Ts)...>::value> {
};
using pod_choice_buffer_t = choice_buffer_t<>;
/*********************
ext group
*********************/
@ -946,7 +1269,7 @@ public:
SRSASN_CODE pack(bit_ref& bref) const;
private:
bounded_array<bool, 20> groups;
ext_array<bool> groups;
};
class ext_groups_unpacker_guard
@ -960,7 +1283,7 @@ public:
SRSASN_CODE unpack(bit_ref& bref);
private:
bounded_array<bool, 20> groups;
ext_array<bool> groups;
const uint32_t nof_supported_groups;
uint32_t nof_unpacked_groups = 0;
bit_ref* bref_tracker = nullptr;
@ -973,7 +1296,7 @@ private:
class varlength_field_pack_guard
{
public:
varlength_field_pack_guard(bit_ref& bref);
explicit varlength_field_pack_guard(bit_ref& bref, bool align_ = false);
~varlength_field_pack_guard();
private:
@ -981,18 +1304,19 @@ private:
// bit_ref bref0;
bit_ref* bref_tracker;
uint8_t buffer[1024];
bool align;
};
class varlength_field_unpack_guard
{
public:
varlength_field_unpack_guard(bit_ref& bref);
explicit varlength_field_unpack_guard(bit_ref& bref, bool align = false);
~varlength_field_unpack_guard();
private:
bit_ref bref0;
bit_ref* bref_tracker;
uint32_t len;
bit_ref* bref_tracker = nullptr;
uint32_t len = 0;
};
/*******************

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -2745,7 +2745,18 @@ int8_t sib_type3_s::cell_resel_info_common_s_::speed_state_resel_pars_s_::q_hyst
options, 4, value, "sib_type3_s::cell_resel_info_common_s_::speed_state_resel_pars_s_::q_hyst_sf_s_::sf_high_e_");
}
std::string sib_info_item_c::types_opts::to_string() const
std::string pos_sys_info_r15_ies_s::pos_sib_type_and_info_r15_item_c_::types_opts::to_string() const
{
static constexpr const char* options[] = {
"posSib1-1-r15", "posSib1-2-r15", "posSib1-3-r15", "posSib1-4-r15", "posSib1-5-r15", "posSib1-6-r15",
"posSib1-7-r15", "posSib2-1-r15", "posSib2-2-r15", "posSib2-3-r15", "posSib2-4-r15", "posSib2-5-r15",
"posSib2-6-r15", "posSib2-7-r15", "posSib2-8-r15", "posSib2-9-r15", "posSib2-10-r15", "posSib2-11-r15",
"posSib2-12-r15", "posSib2-13-r15", "posSib2-14-r15", "posSib2-15-r15", "posSib2-16-r15", "posSib2-17-r15",
"posSib2-18-r15", "posSib2-19-r15", "posSib3-1-r15"};
return convert_enum_idx(options, 27, value, "pos_sys_info_r15_ies_s::pos_sib_type_and_info_r15_item_c_::types");
}
std::string sys_info_r8_ies_s::sib_type_and_info_item_c_::types_opts::to_string() const
{
static constexpr const char* options[] = {"sib2", "sib3", "sib4", "sib5", "sib6",
"sib7", "sib8", "sib9", "sib10", "sib11",
@ -2943,7 +2954,7 @@ std::string p_c_and_cbsr_r13_s::cbsr_sel_r13_c_::types_opts::to_string() const
uint8_t p_c_and_cbsr_r13_s::cbsr_sel_r13_c_::types_opts::to_number() const
{
switch (value) {
case beamformed_k1a_r13:
case bf_k1a_r13:
return 1;
default:
invalid_enum_number(value, "p_c_and_cbsr_r13_s::cbsr_sel_r13_c_::types");
@ -5625,15 +5636,15 @@ int8_t mac_main_cfg_s::phr_cfg_c_::setup_s_::dl_pathloss_change_opts::to_number(
return convert_enum_idx(options, 4, value, "mac_main_cfg_s::phr_cfg_c_::setup_s_::dl_pathloss_change_e_");
}
std::string mac_main_cfg_s::mac_main_cfg_v1020_s_::s_cell_deactivation_timer_r10_opts::to_string() const
std::string mac_main_cfg_s::mac_main_cfg_v1020_s_::scell_deactivation_timer_r10_opts::to_string() const
{
static constexpr const char* options[] = {"rf2", "rf4", "rf8", "rf16", "rf32", "rf64", "rf128", "spare"};
return convert_enum_idx(options, 8, value, "mac_main_cfg_s::mac_main_cfg_v1020_s_::s_cell_deactivation_timer_r10_e_");
return convert_enum_idx(options, 8, value, "mac_main_cfg_s::mac_main_cfg_v1020_s_::scell_deactivation_timer_r10_e_");
}
uint8_t mac_main_cfg_s::mac_main_cfg_v1020_s_::s_cell_deactivation_timer_r10_opts::to_number() const
uint8_t mac_main_cfg_s::mac_main_cfg_v1020_s_::scell_deactivation_timer_r10_opts::to_number() const
{
static constexpr uint8_t options[] = {2, 4, 8, 16, 32, 64, 128};
return convert_enum_idx(options, 7, value, "mac_main_cfg_s::mac_main_cfg_v1020_s_::s_cell_deactivation_timer_r10_e_");
return convert_enum_idx(options, 7, value, "mac_main_cfg_s::mac_main_cfg_v1020_s_::scell_deactivation_timer_r10_e_");
}
std::string mac_main_cfg_s::dual_connect_phr_c_::setup_s_::phr_mode_other_cg_r12_opts::to_string() const
@ -5655,15 +5666,15 @@ uint16_t mac_main_cfg_s::lc_ch_sr_cfg_r12_c_::setup_s_::lc_ch_sr_prohibit_timer_
options, 7, value, "mac_main_cfg_s::lc_ch_sr_cfg_r12_c_::setup_s_::lc_ch_sr_prohibit_timer_r12_e_");
}
std::string mac_main_cfg_s::e_drx_cfg_cycle_start_offset_r13_c_::setup_c_::types_opts::to_string() const
std::string mac_main_cfg_s::edrx_cfg_cycle_start_offset_r13_c_::setup_c_::types_opts::to_string() const
{
static constexpr const char* options[] = {"sf5120", "sf10240"};
return convert_enum_idx(options, 2, value, "mac_main_cfg_s::e_drx_cfg_cycle_start_offset_r13_c_::setup_c_::types");
return convert_enum_idx(options, 2, value, "mac_main_cfg_s::edrx_cfg_cycle_start_offset_r13_c_::setup_c_::types");
}
uint16_t mac_main_cfg_s::e_drx_cfg_cycle_start_offset_r13_c_::setup_c_::types_opts::to_number() const
uint16_t mac_main_cfg_s::edrx_cfg_cycle_start_offset_r13_c_::setup_c_::types_opts::to_number() const
{
static constexpr uint16_t options[] = {5120, 10240};
return convert_enum_idx(options, 2, value, "mac_main_cfg_s::e_drx_cfg_cycle_start_offset_r13_c_::setup_c_::types");
return convert_enum_idx(options, 2, value, "mac_main_cfg_s::edrx_cfg_cycle_start_offset_r13_c_::setup_c_::types");
}
std::string mac_main_cfg_s::short_tti_and_spt_r15_c_::setup_s_::periodic_bsr_timer_r15_opts::to_string() const
@ -5701,17 +5712,17 @@ std::string mac_main_cfg_s::short_tti_and_spt_r15_c_::setup_s_::proc_timeline_r1
options, 4, value, "mac_main_cfg_s::short_tti_and_spt_r15_c_::setup_s_::proc_timeline_r15_e_");
}
std::string mac_main_cfg_s::dormant_state_timers_r15_c_::setup_s_::s_cell_hibernation_timer_r15_opts::to_string() const
std::string mac_main_cfg_s::dormant_state_timers_r15_c_::setup_s_::scell_hibernation_timer_r15_opts::to_string() const
{
static constexpr const char* options[] = {"rf2", "rf4", "rf8", "rf16", "rf32", "rf64", "rf128", "spare"};
return convert_enum_idx(
options, 8, value, "mac_main_cfg_s::dormant_state_timers_r15_c_::setup_s_::s_cell_hibernation_timer_r15_e_");
options, 8, value, "mac_main_cfg_s::dormant_state_timers_r15_c_::setup_s_::scell_hibernation_timer_r15_e_");
}
uint8_t mac_main_cfg_s::dormant_state_timers_r15_c_::setup_s_::s_cell_hibernation_timer_r15_opts::to_number() const
uint8_t mac_main_cfg_s::dormant_state_timers_r15_c_::setup_s_::scell_hibernation_timer_r15_opts::to_number() const
{
static constexpr uint8_t options[] = {2, 4, 8, 16, 32, 64, 128};
return convert_enum_idx(
options, 7, value, "mac_main_cfg_s::dormant_state_timers_r15_c_::setup_s_::s_cell_hibernation_timer_r15_e_");
options, 7, value, "mac_main_cfg_s::dormant_state_timers_r15_c_::setup_s_::scell_hibernation_timer_r15_e_");
}
std::string
@ -6973,16 +6984,16 @@ uint8_t rlf_timers_and_consts_scg_r12_c::setup_s_::n314_r12_opts::to_number() co
return convert_enum_idx(options, 8, value, "rlf_timers_and_consts_scg_r12_c::setup_s_::n314_r12_e_");
}
std::string scell_to_add_mod_r10_s::s_cell_state_r15_opts::to_string() const
std::string scell_to_add_mod_r10_s::scell_state_r15_opts::to_string() const
{
static constexpr const char* options[] = {"activated", "dormant"};
return convert_enum_idx(options, 2, value, "scell_to_add_mod_r10_s::s_cell_state_r15_e_");
return convert_enum_idx(options, 2, value, "scell_to_add_mod_r10_s::scell_state_r15_e_");
}
std::string scell_to_add_mod_ext_v1430_s::s_cell_state_r15_opts::to_string() const
std::string scell_to_add_mod_ext_v1430_s::scell_state_r15_opts::to_string() const
{
static constexpr const char* options[] = {"activated", "dormant"};
return convert_enum_idx(options, 2, value, "scell_to_add_mod_ext_v1430_s::s_cell_state_r15_e_");
return convert_enum_idx(options, 2, value, "scell_to_add_mod_ext_v1430_s::scell_state_r15_e_");
}
std::string sl_disc_tx_ref_carrier_ded_r13_c::types_opts::to_string() const
@ -7034,15 +7045,15 @@ uint8_t sf_assign_r15_opts::to_number() const
return convert_enum_idx(options, 7, value, "sf_assign_r15_e");
}
std::string wlan_mob_cfg_r13_s::association_timer_r13_opts::to_string() const
std::string wlan_mob_cfg_r13_s::assoc_timer_r13_opts::to_string() const
{
static constexpr const char* options[] = {"s10", "s30", "s60", "s120", "s240"};
return convert_enum_idx(options, 5, value, "wlan_mob_cfg_r13_s::association_timer_r13_e_");
return convert_enum_idx(options, 5, value, "wlan_mob_cfg_r13_s::assoc_timer_r13_e_");
}
uint8_t wlan_mob_cfg_r13_s::association_timer_r13_opts::to_number() const
uint8_t wlan_mob_cfg_r13_s::assoc_timer_r13_opts::to_number() const
{
static constexpr uint8_t options[] = {10, 30, 60, 120, 240};
return convert_enum_idx(options, 5, value, "wlan_mob_cfg_r13_s::association_timer_r13_e_");
return convert_enum_idx(options, 5, value, "wlan_mob_cfg_r13_s::assoc_timer_r13_e_");
}
// CA-BandwidthClass-r10 ::= ENUMERATED
@ -7510,7 +7521,7 @@ std::string pwr_pref_ind_cfg_r11_c::setup_s_::pwr_pref_ind_timer_r11_opts::to_nu
return convert_enum_idx(options, 16, value, "pwr_pref_ind_cfg_r11_c::setup_s_::pwr_pref_ind_timer_r11_e_");
}
std::string report_cfg_eutra_s::trigger_type_c_::event_s_::event_id_c_::types_opts::to_string() const
std::string eutra_event_s::event_id_c_::types_opts::to_string() const
{
static constexpr const char* options[] = {"eventA1",
"eventA2",
@ -7524,7 +7535,7 @@ std::string report_cfg_eutra_s::trigger_type_c_::event_s_::event_id_c_::types_op
"eventV2-r14",
"eventH1-r15",
"eventH2-r15"};
return convert_enum_idx(options, 12, value, "report_cfg_eutra_s::trigger_type_c_::event_s_::event_id_c_::types");
return convert_enum_idx(options, 12, value, "eutra_event_s::event_id_c_::types");
}
std::string report_cfg_eutra_s::trigger_type_c_::periodical_s_::purpose_opts::to_string() const
@ -9890,15 +9901,15 @@ uint8_t mimo_ca_params_per_bo_bc_per_tm_v1470_s::csi_report_advanced_max_ports_r
options, 6, value, "mimo_ca_params_per_bo_bc_per_tm_v1470_s::csi_report_advanced_max_ports_r14_e_");
}
std::string stti_spt_band_params_r15_s::s_tti_supported_csi_proc_r15_opts::to_string() const
std::string stti_spt_band_params_r15_s::stti_supported_csi_proc_r15_opts::to_string() const
{
static constexpr const char* options[] = {"n1", "n3", "n4"};
return convert_enum_idx(options, 3, value, "stti_spt_band_params_r15_s::s_tti_supported_csi_proc_r15_e_");
return convert_enum_idx(options, 3, value, "stti_spt_band_params_r15_s::stti_supported_csi_proc_r15_e_");
}
uint8_t stti_spt_band_params_r15_s::s_tti_supported_csi_proc_r15_opts::to_number() const
uint8_t stti_spt_band_params_r15_s::stti_supported_csi_proc_r15_opts::to_number() const
{
static constexpr uint8_t options[] = {1, 3, 4};
return convert_enum_idx(options, 3, value, "stti_spt_band_params_r15_s::s_tti_supported_csi_proc_r15_e_");
return convert_enum_idx(options, 3, value, "stti_spt_band_params_r15_s::stti_supported_csi_proc_r15_e_");
}
// V2X-BandwidthClass-r14 ::= ENUMERATED
@ -10024,30 +10035,30 @@ uint8_t processing_timeline_set_r15_opts::to_number() const
return convert_enum_idx(options, 2, value, "processing_timeline_set_r15_e");
}
std::string mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_aperiodic_info_r14_s_::n_max_res_r14_opts::to_string() const
std::string mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_aperiodic_info_r14_s_::nmax_res_r14_opts::to_string() const
{
static constexpr const char* options[] = {"ffs1", "ffs2", "ffs3", "ffs4"};
return convert_enum_idx(
options, 4, value, "mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_aperiodic_info_r14_s_::n_max_res_r14_e_");
options, 4, value, "mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_aperiodic_info_r14_s_::nmax_res_r14_e_");
}
uint8_t mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_aperiodic_info_r14_s_::n_max_res_r14_opts::to_number() const
uint8_t mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_aperiodic_info_r14_s_::nmax_res_r14_opts::to_number() const
{
static constexpr uint8_t options[] = {1, 2, 3, 4};
return convert_enum_idx(
options, 4, value, "mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_aperiodic_info_r14_s_::n_max_res_r14_e_");
options, 4, value, "mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_aperiodic_info_r14_s_::nmax_res_r14_e_");
}
std::string mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_periodic_info_r14_s_::n_max_res_r14_opts::to_string() const
std::string mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_periodic_info_r14_s_::nmax_res_r14_opts::to_string() const
{
static constexpr const char* options[] = {"ffs1", "ffs2", "ffs3", "ffs4"};
return convert_enum_idx(
options, 4, value, "mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_periodic_info_r14_s_::n_max_res_r14_e_");
options, 4, value, "mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_periodic_info_r14_s_::nmax_res_r14_e_");
}
uint8_t mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_periodic_info_r14_s_::n_max_res_r14_opts::to_number() const
uint8_t mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_periodic_info_r14_s_::nmax_res_r14_opts::to_number() const
{
static constexpr uint8_t options[] = {1, 2, 3, 4};
return convert_enum_idx(
options, 4, value, "mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_periodic_info_r14_s_::n_max_res_r14_e_");
options, 4, value, "mimo_ue_params_per_tm_v1430_s::nzp_csi_rs_periodic_info_r14_s_::nmax_res_r14_e_");
}
std::string mimo_ue_params_per_tm_v1470_s::csi_report_advanced_max_ports_r14_opts::to_string() const
@ -10161,31 +10172,23 @@ uint8_t phy_layer_params_v1430_s::ce_retuning_symbols_r14_opts::to_number() cons
return convert_enum_idx(options, 2, value, "phy_layer_params_v1430_s::ce_retuning_symbols_r14_e_");
}
std::string
phy_layer_params_v1530_s::stti_spt_capabilities_r15_s_::max_layers_slot_or_subslot_pusch_r15_opts::to_string() const
std::string phy_layer_params_v1530_s::stti_spt_cap_r15_s_::max_layers_slot_or_subslot_pusch_r15_opts::to_string() const
{
static constexpr const char* options[] = {"oneLayer", "twoLayers", "fourLayers"};
return convert_enum_idx(
options,
3,
value,
"phy_layer_params_v1530_s::stti_spt_capabilities_r15_s_::max_layers_slot_or_subslot_pusch_r15_e_");
options, 3, value, "phy_layer_params_v1530_s::stti_spt_cap_r15_s_::max_layers_slot_or_subslot_pusch_r15_e_");
}
uint8_t
phy_layer_params_v1530_s::stti_spt_capabilities_r15_s_::max_layers_slot_or_subslot_pusch_r15_opts::to_number() const
uint8_t phy_layer_params_v1530_s::stti_spt_cap_r15_s_::max_layers_slot_or_subslot_pusch_r15_opts::to_number() const
{
static constexpr uint8_t options[] = {1, 2, 4};
return convert_enum_idx(
options,
3,
value,
"phy_layer_params_v1530_s::stti_spt_capabilities_r15_s_::max_layers_slot_or_subslot_pusch_r15_e_");
options, 3, value, "phy_layer_params_v1530_s::stti_spt_cap_r15_s_::max_layers_slot_or_subslot_pusch_r15_e_");
}
std::string phy_layer_params_v1530_s::stti_spt_capabilities_r15_s_::sps_stti_r15_opts::to_string() const
std::string phy_layer_params_v1530_s::stti_spt_cap_r15_s_::sps_stti_r15_opts::to_string() const
{
static constexpr const char* options[] = {"slot", "subslot", "slotAndSubslot"};
return convert_enum_idx(options, 3, value, "phy_layer_params_v1530_s::stti_spt_capabilities_r15_s_::sps_stti_r15_e_");
return convert_enum_idx(options, 3, value, "phy_layer_params_v1530_s::stti_spt_cap_r15_s_::sps_stti_r15_e_");
}
std::string supported_band_eutra_v1320_s::ue_pwr_class_n_r13_opts::to_string() const

@ -334,7 +334,7 @@ void set_phy_cfg_t_dedicated_cfg(phy_cfg_t* cfg, const asn1::rrc::phys_cfg_ded_s
asn1_type.ul_pwr_ctrl_ded.delta_mcs_enabled == asn1::rrc::ul_pwr_ctrl_ded_s::delta_mcs_enabled_e_::en0;
cfg->ul_cfg.power_ctrl.acc_enabled = asn1_type.ul_pwr_ctrl_ded.accumulation_enabled;
cfg->ul_cfg.power_ctrl.p0_ue_pucch = asn1_type.ul_pwr_ctrl_ded.p0_ue_pucch;
cfg->ul_cfg.power_ctrl.p_srs_offset = asn1_type.ul_pwr_ctrl_ded.p_srs_offset;
cfg->ul_cfg.power_ctrl.p_srs_offset = asn1_type.ul_pwr_ctrl_ded.psrs_offset;
}
if (asn1_type.ul_pwr_ctrl_ded.filt_coef_present) {
@ -501,8 +501,8 @@ void set_phy_cfg_t_common_pucch(phy_cfg_t* cfg, const asn1::rrc::pucch_cfg_commo
{
/* PUCCH configuration */
cfg->ul_cfg.pucch.delta_pucch_shift = asn1_type.delta_pucch_shift.to_number();
cfg->ul_cfg.pucch.N_cs = asn1_type.n_cs_an;
cfg->ul_cfg.pucch.n_rb_2 = asn1_type.n_rb_cqi;
cfg->ul_cfg.pucch.N_cs = asn1_type.ncs_an;
cfg->ul_cfg.pucch.n_rb_2 = asn1_type.nrb_cqi;
cfg->ul_cfg.pucch.N_pucch_1 = asn1_type.n1_pucch_an;
}

@ -66,7 +66,7 @@ void print_console(srsasn_logger_level_t log_level, void* ctx, const char* str)
}
struct TestLogger {
TestLogger(const std::string& layer_) : layer(layer_), last_level(LOG_LEVEL_INFO) {}
TestLogger(const std::string& layer_) : layer(layer_) {}
void log(srsasn_logger_level_t log_level, const char* str)
{
last_level = log_level;
@ -395,7 +395,7 @@ int ue_rrc_conn_recfg_r15_v10_test()
dl_dcch_msg_s dl_dcch_msg;
dl_dcch_msg.unpack(bref);
TESTASSERT(ceil(bref.distance(bref0) / 8.0) == rrc_msg_len);
TESTASSERT(bref.distance_bytes() == (int)rrc_msg_len);
TESTASSERT(dl_dcch_msg.msg.type() == dl_dcch_msg_type_c::types::c1);
TESTASSERT(dl_dcch_msg.msg.c1().type() == dl_dcch_msg_type_c::c1_c_::types::rrc_conn_recfg);
@ -450,7 +450,7 @@ int ue_rrc_conn_recfg_r15_v10_test()
TESTASSERT(explicit_value.type() == rlc_cfg_c::types::am);
rlc_cfg_c::am_s_& am = explicit_value.am();
TESTASSERT(am.ul_am_rlc.t_poll_retx == t_poll_retx_e::ms35);
TESTASSERT(am.ul_am_rlc.poll_pdu == poll_pdu_e::p_infinity);
TESTASSERT(am.ul_am_rlc.poll_pdu == poll_pdu_e::pinfinity);
TESTASSERT(am.ul_am_rlc.poll_byte == poll_byte_e::kbinfinity);
TESTASSERT(am.ul_am_rlc.max_retx_thres == ul_am_rlc_s::max_retx_thres_e_::t32);
TESTASSERT(am.dl_am_rlc.t_reordering == t_reordering_e::ms35);
@ -511,8 +511,8 @@ int ue_rrc_conn_recfg_r15_v10_test()
TESTASSERT(rrc_recfg_r8->non_crit_ext.non_crit_ext_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.other_cfg_r9_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.full_cfg_r9_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.s_cell_to_release_list_r10_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.s_cell_to_add_mod_list_r10_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.scell_to_release_list_r10_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.scell_to_add_mod_list_r10_present);
TESTASSERT(rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.sib_type1_ded_r11_present);
TESTASSERT(rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext_present);
@ -527,9 +527,9 @@ int ue_rrc_conn_recfg_r15_v10_test()
not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.sl_comm_cfg_r12_present);
TESTASSERT(rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext
.s_cell_to_release_list_ext_r13_present);
.scell_to_release_list_ext_r13_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext
.s_cell_to_add_mod_list_ext_r13_present);
.scell_to_add_mod_list_ext_r13_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext
.lwa_cfg_r13_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext
@ -541,7 +541,7 @@ int ue_rrc_conn_recfg_r15_v10_test()
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext
.non_crit_ext.sl_v2x_cfg_ded_r14_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext
.non_crit_ext.s_cell_to_add_mod_list_ext_v1430_present);
.non_crit_ext.scell_to_add_mod_list_ext_v1430_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext
.non_crit_ext.per_cc_gap_ind_request_r14_present);
TESTASSERT(not rrc_recfg_r8->non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext.non_crit_ext
@ -594,6 +594,54 @@ int unrecognized_ext_group_test()
return 0;
}
int v2x_test()
{
// Suspected sl_v2x_preconfig message
static uint8_t rrc_msg[] = {
0x20, 0x98, 0x03, 0x5E, 0x5B, 0x5F, 0xB0, 0x00, 0x00, 0x00, 0x40, 0xA0, 0x00, 0x00, 0x00, 0xBF, 0xFF, 0xFE,
0x54, 0x02, 0x54, 0x06, 0x97, 0xFF, 0xFF, 0xCA, 0x80, 0x4A, 0x92, 0x88, 0x01, 0x00, 0x06, 0x01, 0x30, 0x00,
0x81, 0x84, 0xE0, 0x8C, 0x00, 0x10, 0xC2, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x82, 0x30, 0x0E, 0x02,
0x22, 0xAC, 0x04, 0x41, 0x02, 0x16, 0x2C, 0x58, 0xB1, 0x62, 0xC1, 0x02, 0x16, 0x2C, 0x58, 0xB1, 0x62, 0xC1,
0x02, 0x16, 0x2C, 0x58, 0xB1, 0x62, 0xC1, 0x02, 0x16, 0x2C, 0x58, 0xB1, 0x62, 0xC1, 0x02, 0x16, 0x2C, 0x58,
0xB1, 0x62, 0xC1, 0x02, 0x16, 0x2C, 0x58, 0xB1, 0x62, 0xC1, 0x02, 0x16, 0x2C, 0x58, 0xB1, 0x62, 0xC1, 0x02,
0x16, 0x2C, 0x58, 0xB1, 0x62, 0xC0, 0xA2, 0x80, 0x04, 0x30, 0x72, 0x19, 0xE8, 0x34, 0x32, 0x19, 0xE8, 0x34,
0x32, 0x08, 0x9C, 0x42, 0x0E, 0x00, 0x8E, 0x00, 0x19, 0x10, 0x70, 0x04, 0x70, 0x01, 0x2C, 0x83, 0x80, 0x23,
0x80, 0x01, 0xE4, 0x1C, 0x01, 0x1C, 0x00, 0x07, 0xA0, 0xE0, 0x08, 0xE0, 0x00, 0x79, 0x31, 0xC0, 0x47, 0x00,
0x02, 0x88, 0x38, 0x02, 0x38, 0x00, 0x0F, 0x4C, 0x70, 0x11, 0xC0, 0x00, 0x52, 0x0E, 0x00, 0x8E, 0x00};
// 2098035E5B5FB000000040A0000000BFFFFE5402540697FFFFCA804A92880100060130008184E08C0010C22000000000000282300E0222AC044102162C58B162C102162C58B162C102162C58B162C102162C58B162C102162C58B162C102162C58B162C102162C58B162C102162C58B162C0A28004307219E8343219E83432089C420E008E001910700470012C8380238001E41C011C0007A0E008E0007931C047000288380238000F4C7011C000520E008E00
bit_ref bref(rrc_msg, sizeof(rrc_msg));
sl_v2x_precfg_r14_s sl_preconf{};
TESTASSERT(sl_preconf.unpack(bref) == SRSASN_SUCCESS);
// asn1::json_writer json_writer;
// sl_preconf.to_json(json_writer);
// printf("Content: %s\n", json_writer.to_string().c_str());
return SRSASN_SUCCESS;
}
int test_rrc_conn_reconf_r15_2()
{
uint8_t rrc_msg[] = {0x20, 0x16, 0x15, 0xC8, 0x40, 0x00, 0x03, 0xC2, 0x84, 0x18, 0x10, 0xA8, 0x04, 0xD7, 0x95, 0x14,
0xA2, 0x01, 0x02, 0x18, 0x9A, 0x01, 0x80, 0x14, 0x81, 0x0A, 0xCB, 0x84, 0x08, 0x00, 0xAD, 0x6D,
0xC4, 0x06, 0x08, 0xAF, 0x6D, 0xC7, 0xA0, 0xC0, 0x82, 0x00, 0x00, 0x0C, 0x38, 0x60, 0x20, 0x30,
0xC3, 0x00, 0x00, 0x10, 0x04, 0x40, 0x10, 0xC2, 0x3C, 0x2A, 0x06, 0x20, 0x30, 0x11, 0x10, 0x28,
0x13, 0xDA, 0x4E, 0x96, 0xDA, 0x80, 0x83, 0xA1, 0x00, 0xA4, 0x83, 0x00, 0x32, 0x7B, 0x08, 0x95,
0xAE, 0x00, 0x16, 0xA9, 0x00, 0xE0, 0x80, 0x84, 0x8C, 0x82, 0xBB, 0xB1, 0xB4, 0xBA, 0x18, 0x83,
0x36, 0xB7, 0x31, 0x98, 0x18, 0x98, 0x83, 0x36, 0xB1, 0xB1, 0x9A, 0x1B, 0x1B, 0x02, 0x33, 0xB8,
0x39, 0x39, 0x82, 0x80, 0x85, 0x7F, 0x80, 0x80, 0xAF, 0x03, 0x7F, 0x7F, 0x7D, 0x7D, 0x7F, 0x7F,
0x28, 0x05, 0xFB, 0x32, 0x7B, 0x08, 0xC0, 0x00, 0x01, 0xF8, 0x3E, 0x3C, 0xB1, 0xB2, 0x00, 0xC0,
0x30, 0x38, 0x1F, 0xFA, 0x9C, 0x08, 0x3E, 0xA2, 0x5F, 0x1C, 0xE1, 0xD0, 0x84};
// 201615C8400003C2841810A804D79514A20102189A018014810ACB840800AD6DC40608AF6DC7A0C08200000C38602030C3000010044010C23C2A06203011102813DA4E96DA8083A100A48300327B0895AE0016A900E080848C82BBB1B4BA188336B7319818988336B1B19A1B1B0233B839398280857F8080AF037F7F7D7D7F7F2805FB327B08C00001F83E3CB1B200C030381FFA9C083EA25F1CE1D084
bit_ref bref(rrc_msg, sizeof(rrc_msg));
dl_dcch_msg_s recfg_msg;
TESTASSERT(recfg_msg.unpack(bref) == SRSASN_SUCCESS);
return SRSASN_SUCCESS;
}
int main()
{
srsasn_log_register_handler(&asn_logger, print_console);
@ -609,6 +657,8 @@ int main()
TESTASSERT(ue_rrc_conn_recfg_r15_v10_test() == 0);
TESTASSERT(failed_dl_ccch_unpack() == 0);
TESTASSERT(unrecognized_ext_group_test() == 0);
TESTASSERT(v2x_test() == 0);
TESTASSERT(test_rrc_conn_reconf_r15_2() == 0);
printf("Success\n");
return 0;

@ -322,7 +322,7 @@ int mbsfn_area_info_list_parser::parse(Setting& root)
return -1;
}
parser::field<uint8_t> areaid("mbsfn_area_id", &mbsfn_item->mbsfn_area_id_r9);
parser::field<uint16_t> areaid("mbsfn_area_id", &mbsfn_item->mbsfn_area_id_r9);
if (areaid.parse(root["mbsfn_area_info_list"])) {
fprintf(stderr, "Error parsing mbsfn_area_id\n");
return -1;
@ -1072,8 +1072,8 @@ int parse_sib2(std::string filename, sib_type2_s* data)
rr_config.add_subsection(&pucch_cnfg);
pucch_cnfg.add_field(
make_asn1_enum_number_parser("delta_pucch_shift", &rr_cfg_common->pucch_cfg_common.delta_pucch_shift));
pucch_cnfg.add_field(new parser::field<uint8>("n_rb_cqi", &rr_cfg_common->pucch_cfg_common.n_rb_cqi));
pucch_cnfg.add_field(new parser::field<uint8>("n_cs_an", &rr_cfg_common->pucch_cfg_common.n_cs_an));
pucch_cnfg.add_field(new parser::field<uint8>("n_rb_cqi", &rr_cfg_common->pucch_cfg_common.nrb_cqi));
pucch_cnfg.add_field(new parser::field<uint8>("n_cs_an", &rr_cfg_common->pucch_cfg_common.ncs_an));
pucch_cnfg.add_field(new parser::field<uint16>("n1_pucch_an", &rr_cfg_common->pucch_cfg_common.n1_pucch_an));
// UL PWR Ctrl configuration

@ -85,8 +85,8 @@ void phy::parse_config(const phy_cfg_t& cfg)
// PUCCH
workers_common.ul_cfg_com.pucch.delta_pucch_shift = cfg.pucch_cnfg.delta_pucch_shift.to_number();
workers_common.ul_cfg_com.pucch.N_cs = cfg.pucch_cnfg.n_cs_an;
workers_common.ul_cfg_com.pucch.n_rb_2 = cfg.pucch_cnfg.n_rb_cqi;
workers_common.ul_cfg_com.pucch.N_cs = cfg.pucch_cnfg.ncs_an;
workers_common.ul_cfg_com.pucch.n_rb_2 = cfg.pucch_cnfg.nrb_cqi;
workers_common.ul_cfg_com.pucch.N_pucch_1 = cfg.pucch_cnfg.n1_pucch_an;
workers_common.ul_cfg_com.pucch.threshold_format1 = 0.8;

@ -1574,7 +1574,7 @@ void rrc::ue::send_connection_setup(bool is_setup)
phy_cfg->ul_pwr_ctrl_ded.p0_ue_pusch = 0;
phy_cfg->ul_pwr_ctrl_ded.delta_mcs_enabled = ul_pwr_ctrl_ded_s::delta_mcs_enabled_e_::en0;
phy_cfg->ul_pwr_ctrl_ded.accumulation_enabled = true;
phy_cfg->ul_pwr_ctrl_ded.p0_ue_pucch = 0, phy_cfg->ul_pwr_ctrl_ded.p_srs_offset = 3;
phy_cfg->ul_pwr_ctrl_ded.p0_ue_pucch = 0, phy_cfg->ul_pwr_ctrl_ded.psrs_offset = 3;
// PDSCH
phy_cfg->pdsch_cfg_ded_present = true;
@ -1629,8 +1629,8 @@ void rrc::ue::send_connection_setup(bool is_setup)
sched_cfg.pucch_cfg.sr_configured = true;
sched_cfg.pucch_cfg.n_pucch = cqi_pucch;
sched_cfg.pucch_cfg.delta_pucch_shift = parent->sib2.rr_cfg_common.pucch_cfg_common.delta_pucch_shift.to_number();
sched_cfg.pucch_cfg.N_cs = parent->sib2.rr_cfg_common.pucch_cfg_common.n_cs_an;
sched_cfg.pucch_cfg.n_rb_2 = parent->sib2.rr_cfg_common.pucch_cfg_common.n_rb_cqi;
sched_cfg.pucch_cfg.N_cs = parent->sib2.rr_cfg_common.pucch_cfg_common.ncs_an;
sched_cfg.pucch_cfg.n_rb_2 = parent->sib2.rr_cfg_common.pucch_cfg_common.nrb_cqi;
sched_cfg.pucch_cfg.N_pucch_1 = parent->sib2.rr_cfg_common.pucch_cfg_common.n1_pucch_an;
// Configure MAC
@ -2247,8 +2247,8 @@ int rrc::ue::sr_allocate(uint32_t period, uint8_t* I_sr, uint16_t* N_pucch_sr)
// Compute N_pucch_sr
*N_pucch_sr = i_min * max_users + parent->sr_sched.nof_users[i_min][j_min];
if (parent->sib2.rr_cfg_common.pucch_cfg_common.n_cs_an) {
*N_pucch_sr += parent->sib2.rr_cfg_common.pucch_cfg_common.n_cs_an;
if (parent->sib2.rr_cfg_common.pucch_cfg_common.ncs_an) {
*N_pucch_sr += parent->sib2.rr_cfg_common.pucch_cfg_common.ncs_an;
}
// Allocate user
@ -2344,8 +2344,8 @@ int rrc::ue::cqi_allocate(uint32_t period, uint16_t* pmi_idx, uint16_t* n_pucch)
// Compute n_pucch_2
*n_pucch = i_min * max_users + parent->cqi_sched.nof_users[i_min][j_min];
if (parent->sib2.rr_cfg_common.pucch_cfg_common.n_cs_an) {
*n_pucch += parent->sib2.rr_cfg_common.pucch_cfg_common.n_cs_an;
if (parent->sib2.rr_cfg_common.pucch_cfg_common.ncs_an) {
*n_pucch += parent->sib2.rr_cfg_common.pucch_cfg_common.ncs_an;
}
// Allocate user

@ -2366,7 +2366,7 @@ void rrc::apply_phy_scell_config(const asn1::rrc::scell_to_add_mod_r10_s& scell_
srslte::phy_cfg_t scell_phy_cfg = current_phy_cfg;
set_phy_cfg_t_scell_config(&scell_phy_cfg, scell_config);
phy->set_config(scell_phy_cfg, scell_config.s_cell_idx_r10, earfcn, &scell);
phy->set_config(scell_phy_cfg, scell_config.scell_idx_r10, earfcn, &scell);
}
void rrc::log_mac_config_dedicated()
@ -2461,9 +2461,9 @@ void rrc::apply_scell_config(asn1::rrc::rrc_conn_recfg_r8_ies_s* reconfig_r8)
rrc_conn_recfg_v1020_ies_s* reconfig_r1020 = &reconfig_r920->non_crit_ext;
// Handle Add/Modify SCell list
if (reconfig_r1020->s_cell_to_add_mod_list_r10_present) {
for (uint32_t i = 0; i < reconfig_r1020->s_cell_to_add_mod_list_r10.size(); i++) {
auto scell_config = &reconfig_r1020->s_cell_to_add_mod_list_r10[i];
if (reconfig_r1020->scell_to_add_mod_list_r10_present) {
for (uint32_t i = 0; i < reconfig_r1020->scell_to_add_mod_list_r10.size(); i++) {
auto scell_config = &reconfig_r1020->scell_to_add_mod_list_r10[i];
// Limit enable64_qam, if the ue does not
// since the phy does not have information about the RRC category and release, the RRC shall limit the
@ -2486,7 +2486,7 @@ void rrc::apply_scell_config(asn1::rrc::rrc_conn_recfg_r8_ies_s* reconfig_r8)
}
// Call mac reconfiguration
mac->reconfiguration(scell_config->s_cell_idx_r10, true);
mac->reconfiguration(scell_config->scell_idx_r10, true);
// Call phy reconfiguration
apply_phy_scell_config(*scell_config);
@ -2494,10 +2494,10 @@ void rrc::apply_scell_config(asn1::rrc::rrc_conn_recfg_r8_ies_s* reconfig_r8)
}
// Handle Remove SCell list
if (reconfig_r1020->s_cell_to_release_list_r10_present) {
for (uint32_t i = 0; i < reconfig_r1020->s_cell_to_release_list_r10.size(); i++) {
if (reconfig_r1020->scell_to_release_list_r10_present) {
for (uint32_t i = 0; i < reconfig_r1020->scell_to_release_list_r10.size(); i++) {
// Call mac reconfiguration
mac->reconfiguration(reconfig_r1020->s_cell_to_release_list_r10[i], false);
mac->reconfiguration(reconfig_r1020->scell_to_release_list_r10[i], false);
// Call phy reconfiguration
// TODO: Implement phy layer cell removal

Loading…
Cancel
Save