Skip to content

Commit 1ee4a25

Browse files
andrepuschmanncodebot
authored andcommitted
cu_cp: make RNTI optional when creating UE context
1 parent e4b3ddd commit 1ee4a25

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

include/srsran/cu_cp/ue_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class du_processor_ue_manager : public common_ue_manager
101101
/// \param[in] pci PCI of the cell that the UE is connected to.
102102
/// \param[in] rnti RNTI of the UE to be added.
103103
/// \return Pointer to the newly added DU UE if successful, nullptr otherwise.
104-
virtual du_ue* add_ue(du_index_t du_index, pci_t pci, rnti_t rnti) = 0;
104+
virtual du_ue* add_ue(du_index_t du_index, pci_t pci, optional<rnti_t> rnti) = 0;
105105

106106
/// \brief Remove the DU UE context with the given UE index.
107107
/// \param[in] ue_index Index of the UE to be removed.

lib/cu_cp/ue_manager_impl.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,27 @@ du_ue* ue_manager::find_du_ue(ue_index_t ue_index)
3636
return nullptr;
3737
}
3838

39-
du_ue* ue_manager::add_ue(du_index_t du_index, pci_t pci, rnti_t rnti)
39+
du_ue* ue_manager::add_ue(du_index_t du_index, pci_t pci, optional<rnti_t> rnti)
4040
{
4141
// check if PCI is valid
4242
if (pci == INVALID_PCI) {
4343
logger.error("Invalid pci={}.", pci);
4444
return nullptr;
4545
}
4646

47-
// check if RNTI is valid
48-
if (rnti == INVALID_RNTI) {
49-
logger.error("Invalid rnti={}.", rnti);
50-
return nullptr;
51-
}
47+
// if the RNTI is provided it needs to be valid and it must not be already present.
48+
if (rnti.has_value()) {
49+
// check if RNTI is valid
50+
if (rnti.value() == INVALID_RNTI) {
51+
logger.error("Invalid rnti={}.", rnti);
52+
return nullptr;
53+
}
5254

53-
// check if the UE is already present
54-
if (get_ue_index(pci, rnti) != ue_index_t::invalid) {
55-
logger.error("UE with pci={} and rnti={} already exists.", pci, rnti);
56-
return nullptr;
55+
// check if the UE is already present
56+
if (get_ue_index(pci, rnti.value()) != ue_index_t::invalid) {
57+
logger.error("UE with pci={} and rnti={} already exists.", pci, rnti.value());
58+
return nullptr;
59+
}
5760
}
5861

5962
ue_index_t new_ue_index = get_next_ue_index(du_index);
@@ -66,8 +69,10 @@ du_ue* ue_manager::add_ue(du_index_t du_index, pci_t pci, rnti_t rnti)
6669
ues.emplace(
6770
std::piecewise_construct, std::forward_as_tuple(new_ue_index), std::forward_as_tuple(new_ue_index, pci, rnti));
6871

69-
// Add RNTI to lookup
70-
pci_rnti_to_ue_index.emplace(std::make_tuple(pci, rnti), new_ue_index);
72+
// Add RNTI to lookup if it was provided.
73+
if (rnti.has_value()) {
74+
pci_rnti_to_ue_index.emplace(std::make_tuple(pci, rnti.value()), new_ue_index);
75+
}
7176

7277
auto& ue = ues.at(new_ue_index);
7378
ue.du_ue_created = true;

lib/cu_cp/ue_manager_impl.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct ngap_ue_context_t {
2626
class cu_cp_ue : public du_ue, public ngap_ue
2727
{
2828
public:
29-
cu_cp_ue(const ue_index_t ue_index_, const pci_t pci_, const rnti_t c_rnti_) :
29+
cu_cp_ue(const ue_index_t ue_index_, const pci_t pci_, const optional<rnti_t> c_rnti_) :
3030
ue_index(ue_index_), pci(pci_), c_rnti(c_rnti_)
3131
{
3232
du_index = get_du_index_from_ue_index(ue_index);
@@ -52,7 +52,13 @@ class cu_cp_ue : public du_ue, public ngap_ue
5252
pci_t get_pci() override { return pci; };
5353

5454
/// \brief Get the C-RNTI of the UE.
55-
rnti_t get_c_rnti() override { return c_rnti; }
55+
rnti_t get_c_rnti() override
56+
{
57+
if (c_rnti.has_value()) {
58+
return c_rnti.value();
59+
}
60+
return rnti_t::INVALID_RNTI;
61+
}
5662

5763
/// \brief Get the DU index of the UE.
5864
du_index_t get_du_index() override { return du_index; }
@@ -149,10 +155,10 @@ class cu_cp_ue : public du_ue, public ngap_ue
149155
ue_index_t ue_index = ue_index_t::invalid;
150156

151157
// du ue context
152-
du_index_t du_index = du_index_t::invalid;
153-
du_cell_index_t pcell_index = du_cell_index_t::invalid;
154-
pci_t pci = INVALID_PCI;
155-
rnti_t c_rnti = INVALID_RNTI;
158+
du_index_t du_index = du_index_t::invalid;
159+
du_cell_index_t pcell_index = du_cell_index_t::invalid;
160+
pci_t pci = INVALID_PCI;
161+
optional<rnti_t> c_rnti;
156162

157163
std::map<srb_id_t, cu_srb_context> srbs;
158164
rrc_ue_task_scheduler* task_sched = nullptr;
@@ -191,7 +197,7 @@ class ue_manager : public du_processor_ue_manager, public ngap_ue_manager
191197
/// \param[in] pci PCI of the cell that the UE is connected to.
192198
/// \param[in] rnti RNTI of the UE to be added.
193199
/// \return Pointer to the newly added DU UE if successful, nullptr otherwise.
194-
du_ue* add_ue(du_index_t du_index, pci_t pci, rnti_t rnti) override;
200+
du_ue* add_ue(du_index_t du_index, pci_t pci, optional<rnti_t> rnti) override;
195201

196202
/// \brief Remove the DU UE context with the given UE index.
197203
/// \param[in] ue_index Index of the UE to be removed.

0 commit comments

Comments
 (0)