Skip to content

Commit

Permalink
fix(agw): Replaced the key for guti hashtable, currently the key is G…
Browse files Browse the repository at this point in the history
…UTI in string format

Signed-off-by: Rashmi <rashmi.sarwad@radisys.com>
  • Loading branch information
rsarwad committed May 9, 2022
1 parent b652ce0 commit f2dbcf1
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 44 deletions.
9 changes: 9 additions & 0 deletions lte/gateway/c/core/oai/common/conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,12 @@ char* bytes_to_hex(char* byte_array, int length, char* hex_array) {
}
return hex_array;
}

void convert_guti_to_string(guti_t* guti_p, char (*guti_str)[]) {
#define GUTI_STRING_LEN 21
snprintf(*guti_str, GUTI_STRING_LEN, "%x%x%x%x%x%x%04x%02x%08x",
guti_p->gummei.plmn.mcc_digit1, guti_p->gummei.plmn.mcc_digit2,
guti_p->gummei.plmn.mcc_digit3, guti_p->gummei.plmn.mnc_digit1,
guti_p->gummei.plmn.mnc_digit2, guti_p->gummei.plmn.mnc_digit3,
guti_p->gummei.mme_gid, guti_p->gummei.mme_code, guti_p->m_tmsi);
}
3 changes: 2 additions & 1 deletion lte/gateway/c/core/oai/common/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ int ascii_to_hex(uint8_t* dst, const char* h);
((bYtE)&0x02 ? '1' : '0'), ((bYtE)&0x01 ? '1' : '0')

int get_time_zone(void);

#define GUTI_STRING_LEN 21
/* Clear GUTI without free it */
void clear_guti(guti_t* const guti);
/* Clear IMSI without free it */
Expand All @@ -757,4 +757,5 @@ bstring paa_to_bstring(const paa_t* paa);
// Return the hex representation of a char array
char* bytes_to_hex(char* byte_array, int length, char* hex_array);

void convert_guti_to_string(guti_t* guti_p, char (*guti_str)[]);
#endif /* FILE_CONVERSIONS_SEEN */
31 changes: 19 additions & 12 deletions lte/gateway/c/core/oai/tasks/mme_app/mme_app_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ ue_mm_context_t* mme_ue_context_exists_guti(
hashtable_rc_t h_rc = HASH_TABLE_OK;
uint64_t mme_ue_s1ap_id64 = 0;

char guti_str[GUTI_STRING_LEN] = {0};
convert_guti_to_string(guti_p, &guti_str);
h_rc = obj_hashtable_uint64_ts_get(mme_ue_context_p->guti_ue_context_htbl,
(const void*)guti_p, sizeof(*guti_p),
(const void*)guti_str, strlen(guti_str),
&mme_ue_s1ap_id64);

if (HASH_TABLE_OK == h_rc) {
Expand Down Expand Up @@ -519,13 +521,17 @@ void mme_ue_context_update_coll_keys(
ue_context_p->emm_context._guti.gummei.plmn.mcc_digit3) ||
(ue_context_p->mme_ue_s1ap_id != mme_ue_s1ap_id)) {
// may check guti_p with a kind of instanceof()?
char guti_str[GUTI_STRING_LEN] = {0};
convert_guti_to_string(&ue_context_p->emm_context._guti, &guti_str);
h_rc = obj_hashtable_uint64_ts_remove(
mme_ue_context_p->guti_ue_context_htbl,
&ue_context_p->emm_context._guti, sizeof(*guti_p));
mme_ue_context_p->guti_ue_context_htbl, (const void* const)guti_str,
strlen(guti_str));
if (INVALID_MME_UE_S1AP_ID != mme_ue_s1ap_id) {
char guti_str[GUTI_STRING_LEN] = {0};
convert_guti_to_string(guti_p, &guti_str);
h_rc = obj_hashtable_uint64_ts_insert(
mme_ue_context_p->guti_ue_context_htbl, (const void* const)guti_p,
sizeof(*guti_p), (uint64_t)mme_ue_s1ap_id);
mme_ue_context_p->guti_ue_context_htbl, (const void* const)guti_str,
strlen(guti_str), (uint64_t)mme_ue_s1ap_id);
} else {
h_rc = HASH_TABLE_KEY_NOT_EXISTS;
}
Expand Down Expand Up @@ -689,11 +695,11 @@ status_code_e mme_insert_ue_context(
.mcc_digit1) || // MCC 000 does not exist in ITU table
(0 != ue_context_p->emm_context._guti.gummei.plmn.mcc_digit2) ||
(0 != ue_context_p->emm_context._guti.gummei.plmn.mcc_digit3)) {
char guti_str[GUTI_STRING_LEN] = {0};
convert_guti_to_string(&ue_context_p->emm_context._guti, &guti_str);
h_rc = obj_hashtable_uint64_ts_insert(
mme_ue_context_p->guti_ue_context_htbl,
(const void* const) & ue_context_p->emm_context._guti,
sizeof(ue_context_p->emm_context._guti),
ue_context_p->mme_ue_s1ap_id);
mme_ue_context_p->guti_ue_context_htbl, (const void* const)guti_str,
strlen(guti_str), ue_context_p->mme_ue_s1ap_id);

if (HASH_TABLE_OK != h_rc) {
OAILOG_WARNING(LOG_MME_APP,
Expand Down Expand Up @@ -757,10 +763,11 @@ void mme_remove_ue_context(mme_ue_context_t* const mme_ue_context_p,
(ue_context_p->emm_context._guti.gummei.plmn.mcc_digit2) ||
(ue_context_p->emm_context._guti.gummei.plmn
.mcc_digit3)) { // MCC 000 does not exist in ITU table
char guti_str[GUTI_STRING_LEN] = {0};
convert_guti_to_string(&ue_context_p->emm_context._guti, &guti_str);
hash_rc = obj_hashtable_uint64_ts_remove(
mme_ue_context_p->guti_ue_context_htbl,
(const void* const) & ue_context_p->emm_context._guti,
sizeof(ue_context_p->emm_context._guti));
mme_ue_context_p->guti_ue_context_htbl, (const void* const)guti_str,
strlen(guti_str));
if (HASH_TABLE_OK != hash_rc)
OAILOG_ERROR(LOG_MME_APP,
"UE Context not found!\n"
Expand Down
18 changes: 9 additions & 9 deletions lte/gateway/c/core/oai/tasks/mme_app/mme_app_state_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ void MmeNasStateConverter::guti_table_to_proto(
for (unsigned int i = 0; i < size; i++) {
uint64_t mme_ue_id;

char* str = mme_app_convert_guti_to_string((guti_t*)(*key_array_p)[i]);
std::string guti_str(str);
free(str);
OAILOG_TRACE(LOG_MME_APP, "Looking for key %p with value %u\n",
(*key_array_p)[i], *((*key_list)[i]));
hashtable_rc_t ht_rc = obj_hashtable_uint64_ts_get(
guti_htbl, (const void*)(*key_array_p)[i], sizeof(guti_t), &mme_ue_id);
std::string guti_str((char*)(*key_array_p)[i], (GUTI_STRING_LEN - 1));
OAILOG_INFO(LOG_MME_APP, "Looking for key %p with value %s strlen:%ld\n",
(*key_array_p)[i], guti_str.c_str(), strlen(guti_str.c_str()));
hashtable_rc_t ht_rc =
obj_hashtable_uint64_ts_get(guti_htbl, (const void*)(*key_array_p)[i],
(GUTI_STRING_LEN - 1), &mme_ue_id);
if (ht_rc == HASH_TABLE_OK) {
(*proto_map)[guti_str] = mme_ue_id;
} else {
Expand Down Expand Up @@ -180,9 +179,10 @@ void MmeNasStateConverter::proto_to_guti_table(
std::unique_ptr<guti_t> guti = std::make_unique<guti_t>();
memset(guti.get(), 0, sizeof(guti_t));

mme_app_convert_string_to_guti(guti.get(), kv.first);
char guti_str[GUTI_STRING_LEN] = {};
strcpy(guti_str, (char*)(kv.first.c_str()));
hashtable_rc_t ht_rc = obj_hashtable_uint64_ts_insert(
guti_htbl, guti.get(), sizeof(guti_t), mme_ue_id);
guti_htbl, guti_str, strlen(guti_str), mme_ue_id);
if (ht_rc != HASH_TABLE_OK) {
OAILOG_ERROR(
LOG_MME_APP,
Expand Down
2 changes: 0 additions & 2 deletions lte/gateway/c/core/oai/tasks/nas/emm/emm_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,6 @@ struct emm_context_s* emm_context_get(emm_data_t* emm_data,
const mme_ue_s1ap_id_t ue_id);
struct emm_context_s* emm_context_get_by_imsi(emm_data_t* emm_data,
imsi64_t imsi64);
struct emm_context_s* emm_context_get_by_guti(emm_data_t* emm_data,
guti_t* guti);

status_code_e emm_context_upsert_imsi(emm_data_t* emm_data,
struct emm_context_s* elm)
Expand Down
20 changes: 0 additions & 20 deletions lte/gateway/c/core/oai/tasks/nas/emm/emm_data_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,26 +662,6 @@ struct emm_context_s* emm_context_get_by_imsi(
return emm_context_p;
}

//------------------------------------------------------------------------------
struct emm_context_s* emm_context_get_by_guti(emm_data_t* emm_data,
guti_t* guti) {
struct emm_context_s* emm_context_p = NULL;

mme_app_desc_t* mme_app_desc_p = get_mme_nas_state(false);
ue_mm_context_t* ue_mm_context =
mme_ue_context_exists_guti(&mme_app_desc_p->mme_ue_contexts, guti);
if (ue_mm_context) {
emm_context_p = &ue_mm_context->emm_context;
}
if (emm_context_p) {
OAILOG_DEBUG(LOG_NAS_EMM,
"EMM-CTX - get UE id " MME_UE_S1AP_ID_FMT
" context %p by guti " GUTI_FMT "\n",
ue_mm_context->mme_ue_s1ap_id, emm_context_p, GUTI_ARG(guti));
}
return emm_context_p;
}

//------------------------------------------------------------------------------

status_code_e emm_context_upsert_imsi(emm_data_t* emm_data,
Expand Down

0 comments on commit f2dbcf1

Please sign in to comment.