F1AP IDs: refactor common code

This commit is contained in:
Robert Schmidt
2025-01-16 15:15:47 +01:00
parent 10e07bc67f
commit 253fffe7fb
+10 -10
View File
@@ -29,6 +29,14 @@
#include "common/utils/assertions.h" #include "common/utils/assertions.h"
static f1_ue_data_t *get_hashtable_data(hash_table_t *ht, uint64_t ue_id)
{
void *data = NULL;
hashtable_rc_t ret = hashtable_get(ht, ue_id, &data);
AssertFatal(ret == HASH_TABLE_OK && data != NULL, "element for ue_id %ld not found\n", ue_id);
return data;
}
/* we have separate versions for CU and DU, as both CU&DU might coexist in the /* we have separate versions for CU and DU, as both CU&DU might coexist in the
* same process */ * same process */
static hash_table_t *cu2du_ue_mapping; static hash_table_t *cu2du_ue_mapping;
@@ -74,11 +82,7 @@ f1_ue_data_t cu_get_f1_ue_data(uint32_t ue_id)
{ {
pthread_mutex_lock(&cu2du_mutex); pthread_mutex_lock(&cu2du_mutex);
DevAssert(cu2du_ue_mapping != NULL); DevAssert(cu2du_ue_mapping != NULL);
uint64_t key = ue_id; f1_ue_data_t ued = *get_hashtable_data(cu2du_ue_mapping, ue_id);
void *data = NULL;
hashtable_rc_t ret = hashtable_get(cu2du_ue_mapping, key, &data);
AssertFatal(ret == HASH_TABLE_OK && data != NULL, "element for ue_id %d not found\n", ue_id);
f1_ue_data_t ued = *(f1_ue_data_t *)data;
pthread_mutex_unlock(&cu2du_mutex); pthread_mutex_unlock(&cu2du_mutex);
return ued; return ued;
} }
@@ -137,11 +141,7 @@ f1_ue_data_t du_get_f1_ue_data(uint32_t ue_id)
{ {
pthread_mutex_lock(&du2cu_mutex); pthread_mutex_lock(&du2cu_mutex);
DevAssert(du2cu_ue_mapping != NULL); DevAssert(du2cu_ue_mapping != NULL);
uint64_t key = ue_id; f1_ue_data_t ued = *get_hashtable_data(du2cu_ue_mapping, ue_id);
void *data = NULL;
hashtable_rc_t ret = hashtable_get(du2cu_ue_mapping, key, &data);
AssertFatal(ret == HASH_TABLE_OK && data != NULL, "element for ue_id %d not found\n", ue_id);
f1_ue_data_t ued = *(f1_ue_data_t *)data;
pthread_mutex_unlock(&du2cu_mutex); pthread_mutex_unlock(&du2cu_mutex);
return ued; return ued;
} }