|
|
@ -24,12 +24,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "srslte/asn1/rrc_asn1_utils.h"
|
|
|
|
#include "srslte/asn1/rrc_asn1_utils.h"
|
|
|
|
#include <algorithm>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
|
|
|
|
namespace srslte {
|
|
|
|
namespace srslte {
|
|
|
|
|
|
|
|
|
|
|
|
//! Functor to compare RRC config elements (e.g. SRB/measObj/Rep) based on ID
|
|
|
|
//! Functor to compare RRC config elements (e.g. SRB/measObj/Rep) based on ID
|
|
|
|
template <typename T>
|
|
|
|
template <typename T>
|
|
|
|
struct rrb_obj_id_cmp {
|
|
|
|
struct rrc_obj_id_cmp {
|
|
|
|
bool operator()(const T& lhs, const T& rhs) const
|
|
|
|
bool operator()(const T& lhs, const T& rhs) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return asn1::rrc::get_rrc_obj_id(lhs) < asn1::rrc::get_rrc_obj_id(rhs);
|
|
|
|
return asn1::rrc::get_rrc_obj_id(lhs) < asn1::rrc::get_rrc_obj_id(rhs);
|
|
|
@ -46,7 +47,7 @@ struct rrb_obj_id_cmp {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
template <typename Container>
|
|
|
|
template <typename Container>
|
|
|
|
using rrc_obj_id_list_cmp = rrb_obj_id_cmp<typename Container::value_type>;
|
|
|
|
using rrc_obj_id_list_cmp = rrc_obj_id_cmp<typename Container::value_type>;
|
|
|
|
|
|
|
|
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
typename Container::iterator find_rrc_obj_id(Container& c, IdType id)
|
|
|
|
typename Container::iterator find_rrc_obj_id(Container& c, IdType id)
|
|
|
@ -57,35 +58,74 @@ typename Container::iterator find_rrc_obj_id(Container& c, IdType id)
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
typename Container::const_iterator find_rrc_obj_id(const Container& c, IdType id)
|
|
|
|
typename Container::const_iterator find_rrc_obj_id(const Container& c, IdType id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return std::find_if(c.begin(), c.end(), [id](const typename Container::value_type& e) {
|
|
|
|
return std::find_if(
|
|
|
|
return asn1::rrc::get_rrc_obj_id(*e) == id;
|
|
|
|
c.begin(), c.end(), [id](const typename Container::value_type& e) { return asn1::rrc::get_rrc_obj_id(e) == id; });
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! Search of rrc cfg element based on ID. Assumes sorted list.
|
|
|
|
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
|
|
|
|
typename Container::iterator sorted_find_rrc_obj_id(Container& c, IdType id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto it = std::lower_bound(c.begin(), c.end(), id, rrc_obj_id_list_cmp<Container>{});
|
|
|
|
|
|
|
|
return (it == c.end() or asn1::rrc::get_rrc_obj_id(*it) != id) ? c.end() : it;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
|
|
|
|
typename Container::const_iterator sorted_find_rrc_obj_id(const Container& c, IdType id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto it = std::lower_bound(c.begin(), c.end(), id, rrc_obj_id_list_cmp<Container>{});
|
|
|
|
|
|
|
|
return (it == c.end() or asn1::rrc::get_rrc_obj_id(*it) != id) ? c.end() : it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//! Add Id to List in a sorted manner
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
typename Container::iterator add_rrc_obj_id(Container& c, IdType id)
|
|
|
|
typename Container::iterator add_rrc_obj_id(Container& c, IdType id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto it = find_rrc_obj_id(c, id);
|
|
|
|
auto it = sorted_find_rrc_obj_id(c, id);
|
|
|
|
if (it == c.end()) {
|
|
|
|
if (it == c.end()) {
|
|
|
|
c.push_back({});
|
|
|
|
c.push_back({});
|
|
|
|
it = c.end() - 1;
|
|
|
|
it = c.end() - 1;
|
|
|
|
asn1::rrc::set_rrc_obj_id(*it, id);
|
|
|
|
asn1::rrc::set_rrc_obj_id(*it, id);
|
|
|
|
|
|
|
|
std::sort(c.begin(), c.end(), rrc_obj_id_list_cmp<Container>{});
|
|
|
|
|
|
|
|
it = sorted_find_rrc_obj_id(c, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return it;
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//! Search of rrc cfg element based on ID. Assumes sorted list.
|
|
|
|
template <typename Container>
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
typename Container::iterator add_rrc_obj(Container& c, const typename Container::value_type& v)
|
|
|
|
typename Container::iterator binary_find(Container& c, IdType id)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto it = std::lower_bound(c.begin(), c.end(), id, rrb_obj_id_cmp<decltype(*c.begin())>{});
|
|
|
|
auto it = sorted_find_rrc_obj_id(c, asn1::rrc::get_rrc_obj_id(v));
|
|
|
|
return (it == c.end() or asn1::rrc::get_rrc_obj_id(*it) != id) ? c.end() : it;
|
|
|
|
if (it == c.end()) {
|
|
|
|
|
|
|
|
c.push_back(v);
|
|
|
|
|
|
|
|
std::sort(c.begin(), c.end(), rrc_obj_id_list_cmp<Container>{});
|
|
|
|
|
|
|
|
it = sorted_find_rrc_obj_id(c, asn1::rrc::get_rrc_obj_id(v));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
*it = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename Container, typename IdType>
|
|
|
|
return it;
|
|
|
|
typename Container::const_iterator binary_find(const Container& c, IdType id)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Find rrc obj id gap in list of rrc objs (e.g. {1, 2, 4} -> 3)
|
|
|
|
|
|
|
|
* Expects list to be sorted
|
|
|
|
|
|
|
|
* @return id value
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
template <typename Container>
|
|
|
|
|
|
|
|
auto find_rrc_obj_id_gap(const Container& c) -> decltype(asn1::rrc::get_rrc_obj_id(c[0]))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto it = std::lower_bound(c.begin(), c.end(), id, rrb_obj_id_cmp<decltype(*c.begin())>{});
|
|
|
|
auto id_cmp_op = rrc_obj_id_list_cmp<Container>{};
|
|
|
|
return (it == c.end() or asn1::rrc::get_rrc_obj_id(*it) != id) ? c.end() : it;
|
|
|
|
assert(std::is_sorted(c.begin(), c.end(), id_cmp_op));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto prev_it = c.begin();
|
|
|
|
|
|
|
|
if (prev_it != c.end() and asn1::rrc::get_rrc_obj_id(*prev_it) == 1) {
|
|
|
|
|
|
|
|
auto it = prev_it;
|
|
|
|
|
|
|
|
for (++it; it != c.end(); prev_it = it, ++it) {
|
|
|
|
|
|
|
|
if (asn1::rrc::get_rrc_obj_id(*it) > asn1::rrc::get_rrc_obj_id(*prev_it) + 1) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return (prev_it == c.end()) ? 1 : asn1::rrc::get_rrc_obj_id(*prev_it) + 1; // starts at 1.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -95,7 +135,7 @@ typename Container::const_iterator binary_find(const Container& c, IdType id)
|
|
|
|
* @param target_list resulting list. (Can be same as src_list)
|
|
|
|
* @param target_list resulting list. (Can be same as src_list)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
template <typename AddModList>
|
|
|
|
template <typename AddModList>
|
|
|
|
void apply_addmodlist_diff(AddModList& src_list, AddModList& add_diff_list, AddModList& target_list)
|
|
|
|
void apply_addmodlist_diff(const AddModList& src_list, const AddModList& add_diff_list, AddModList& target_list)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Shortcut for empty case
|
|
|
|
// Shortcut for empty case
|
|
|
|
if (add_diff_list.size() == 0) {
|
|
|
|
if (add_diff_list.size() == 0) {
|
|
|
@ -104,10 +144,9 @@ void apply_addmodlist_diff(AddModList& src_list, AddModList& add_diff_list, AddM
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Sort Lists by ID
|
|
|
|
|
|
|
|
auto id_cmp_op = rrc_obj_id_list_cmp<AddModList>{};
|
|
|
|
auto id_cmp_op = rrc_obj_id_list_cmp<AddModList>{};
|
|
|
|
std::sort(src_list.begin(), src_list.end(), id_cmp_op);
|
|
|
|
assert(std::is_sorted(src_list.begin(), src_list.end(), id_cmp_op));
|
|
|
|
std::sort(add_diff_list.begin(), add_diff_list.end(), id_cmp_op);
|
|
|
|
assert(std::is_sorted(add_diff_list.begin(), add_diff_list.end(), id_cmp_op));
|
|
|
|
|
|
|
|
|
|
|
|
AddModList l;
|
|
|
|
AddModList l;
|
|
|
|
std::set_union(
|
|
|
|
std::set_union(
|
|
|
@ -123,16 +162,21 @@ void apply_addmodlist_diff(AddModList& src_list, AddModList& add_diff_list, AddM
|
|
|
|
* @param target_list resulting list. (Can be same as src_list)
|
|
|
|
* @param target_list resulting list. (Can be same as src_list)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
template <typename AddModList, typename RemoveList>
|
|
|
|
template <typename AddModList, typename RemoveList>
|
|
|
|
void apply_addmodremlist_diff(AddModList& src_list,
|
|
|
|
void apply_addmodremlist_diff(const AddModList& src_list,
|
|
|
|
AddModList& add_diff_list,
|
|
|
|
const AddModList& add_diff_list,
|
|
|
|
RemoveList& rm_diff_list,
|
|
|
|
RemoveList& rm_diff_list,
|
|
|
|
AddModList& target_list)
|
|
|
|
AddModList& target_list)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Sort Lists by ID
|
|
|
|
if (add_diff_list.size() == 0 and rm_diff_list.size() == 0) {
|
|
|
|
|
|
|
|
if (&target_list != &src_list) {
|
|
|
|
|
|
|
|
target_list = src_list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
auto id_cmp_op = rrc_obj_id_list_cmp<AddModList>{};
|
|
|
|
auto id_cmp_op = rrc_obj_id_list_cmp<AddModList>{};
|
|
|
|
std::sort(src_list.begin(), src_list.end(), id_cmp_op);
|
|
|
|
assert(std::is_sorted(src_list.begin(), src_list.end(), id_cmp_op));
|
|
|
|
std::sort(add_diff_list.begin(), add_diff_list.end(), id_cmp_op);
|
|
|
|
assert(std::is_sorted(add_diff_list.begin(), add_diff_list.end(), id_cmp_op));
|
|
|
|
std::sort(rm_diff_list.begin(), rm_diff_list.end());
|
|
|
|
assert(std::is_sorted(rm_diff_list.begin(), rm_diff_list.end()));
|
|
|
|
|
|
|
|
|
|
|
|
AddModList tmp_lst;
|
|
|
|
AddModList tmp_lst;
|
|
|
|
// apply remove list
|
|
|
|
// apply remove list
|
|
|
@ -155,15 +199,15 @@ void apply_addmodremlist_diff(AddModList& src_list,
|
|
|
|
|
|
|
|
|
|
|
|
//! Update RRC field toAddModList
|
|
|
|
//! Update RRC field toAddModList
|
|
|
|
template <typename List, typename RemFunctor, typename AddFunctor, typename ModFunctor>
|
|
|
|
template <typename List, typename RemFunctor, typename AddFunctor, typename ModFunctor>
|
|
|
|
void apply_cfg_list_updates(List& src_list,
|
|
|
|
void compute_cfg_diff(const List& src_list,
|
|
|
|
List& target_list,
|
|
|
|
const List& target_list,
|
|
|
|
RemFunctor rem_func,
|
|
|
|
RemFunctor rem_func,
|
|
|
|
AddFunctor add_func,
|
|
|
|
AddFunctor add_func,
|
|
|
|
ModFunctor mod_func)
|
|
|
|
ModFunctor mod_func)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Sort by ID
|
|
|
|
auto id_cmp_op = rrc_obj_id_list_cmp<List>{};
|
|
|
|
std::sort(src_list.begin(), src_list.end(), rrb_obj_id_cmp<decltype(*src_list.begin())>{});
|
|
|
|
assert(std::is_sorted(src_list.begin(), src_list.end(), id_cmp_op));
|
|
|
|
std::sort(target_list.begin(), target_list.end(), rrb_obj_id_cmp<decltype(*target_list.begin())>{});
|
|
|
|
assert(std::is_sorted(target_list.begin(), target_list.end(), id_cmp_op));
|
|
|
|
|
|
|
|
|
|
|
|
auto src_it = src_list.begin();
|
|
|
|
auto src_it = src_list.begin();
|
|
|
|
auto target_it = target_list.begin();
|
|
|
|
auto target_it = target_list.begin();
|
|
|
@ -171,10 +215,9 @@ void apply_cfg_list_updates(List& src_list,
|
|
|
|
bool src_left = src_it != src_list.end();
|
|
|
|
bool src_left = src_it != src_list.end();
|
|
|
|
bool target_left = target_it != target_list.end();
|
|
|
|
bool target_left = target_it != target_list.end();
|
|
|
|
while (src_left or target_left) {
|
|
|
|
while (src_left or target_left) {
|
|
|
|
if (not target_left or (src_left and asn1::rrc::get_rrc_obj_id(*src_it) < asn1::rrc::get_rrc_obj_id(*target_it))) {
|
|
|
|
if (not target_left or (src_left and id_cmp_op(*src_it, *target_it))) {
|
|
|
|
rem_func(src_it++);
|
|
|
|
rem_func(src_it++);
|
|
|
|
} else if (not src_left or
|
|
|
|
} else if (not src_left or (target_left and id_cmp_op(*target_it, *src_it))) {
|
|
|
|
(target_left and asn1::rrc::get_rrc_obj_id(*src_it) > asn1::rrc::get_rrc_obj_id(*target_it))) {
|
|
|
|
|
|
|
|
// a new object has been added to target
|
|
|
|
// a new object has been added to target
|
|
|
|
add_func(target_it++);
|
|
|
|
add_func(target_it++);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -185,6 +228,23 @@ void apply_cfg_list_updates(List& src_list,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename toAddModList, typename RemoveList>
|
|
|
|
|
|
|
|
void compute_cfg_diff(const toAddModList& src_list,
|
|
|
|
|
|
|
|
const toAddModList& target_list,
|
|
|
|
|
|
|
|
toAddModList& add_diff_list,
|
|
|
|
|
|
|
|
RemoveList& rem_diff_list)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using it_t = typename toAddModList::const_iterator;
|
|
|
|
|
|
|
|
auto rem_func = [&rem_diff_list](it_t rem_it) { rem_diff_list.push_back(asn1::rrc::get_rrc_obj_id(*rem_it)); };
|
|
|
|
|
|
|
|
auto add_func = [&add_diff_list](it_t add_it) { add_diff_list.push_back(*add_it); };
|
|
|
|
|
|
|
|
auto mod_func = [&add_diff_list](it_t src_it, it_t target_it) {
|
|
|
|
|
|
|
|
if (not(*src_it == *target_it)) {
|
|
|
|
|
|
|
|
add_diff_list.push_back(*target_it);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
compute_cfg_diff(src_list, target_list, rem_func, add_func, mod_func);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace srslte
|
|
|
|
} // namespace srslte
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SRSLTE_RRC_CFG_UTILS_H
|
|
|
|
#endif // SRSLTE_RRC_CFG_UTILS_H
|
|
|
|