F1AP IDs: refactor common code
This commit is contained in:
+10
-10
@@ -29,6 +29,14 @@
|
||||
#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
|
||||
* same process */
|
||||
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);
|
||||
DevAssert(cu2du_ue_mapping != NULL);
|
||||
uint64_t key = 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;
|
||||
f1_ue_data_t ued = *get_hashtable_data(cu2du_ue_mapping, ue_id);
|
||||
pthread_mutex_unlock(&cu2du_mutex);
|
||||
return ued;
|
||||
}
|
||||
@@ -137,11 +141,7 @@ f1_ue_data_t du_get_f1_ue_data(uint32_t ue_id)
|
||||
{
|
||||
pthread_mutex_lock(&du2cu_mutex);
|
||||
DevAssert(du2cu_ue_mapping != NULL);
|
||||
uint64_t key = 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;
|
||||
f1_ue_data_t ued = *get_hashtable_data(du2cu_ue_mapping, ue_id);
|
||||
pthread_mutex_unlock(&du2cu_mutex);
|
||||
return ued;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user