forked from acouzens/open5gs
mme_ue_set_imsi function includes GUTI generation
This commit is contained in:
parent
094a5c051d
commit
9b1e9834dd
|
@ -45,8 +45,6 @@ status_t emm_build_attach_accept(
|
|||
attach_accept->esm_message_container.data = esmbuf->payload;
|
||||
attach_accept->esm_message_container.len = esmbuf->len;
|
||||
|
||||
d_assert(mme_ue_new_guti(mme_ue) == CORE_OK,
|
||||
return CORE_ERROR, "GUTI error");
|
||||
attach_accept->presencemask |= NAS_ATTACH_ACCEPT_GUTI_PRESENT;
|
||||
guti->length = sizeof(nas_eps_mobile_identity_guti_t);
|
||||
guti->guti.odd_even = NAS_EPS_MOBILE_IDENTITY_EVEN;
|
||||
|
|
|
@ -101,29 +101,34 @@ void emm_handle_attach_request(
|
|||
{
|
||||
case NAS_EPS_MOBILE_IDENTITY_IMSI:
|
||||
{
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
|
||||
nas_imsi_to_bcd(
|
||||
&eps_mobile_identity->imsi, eps_mobile_identity->length,
|
||||
mme_ue->imsi_bcd);
|
||||
core_bcd_to_buffer(mme_ue->imsi_bcd, mme_ue->imsi,
|
||||
&mme_ue->imsi_len);
|
||||
d_assert(mme_ue->imsi_len, return,
|
||||
"Can't get IMSI(len:%d\n", mme_ue->imsi_len);
|
||||
imsi_bcd);
|
||||
mme_ue_set_imsi(mme_ue, imsi_bcd);
|
||||
|
||||
d_info("[NAS] Attach request : UE_IMSI[%s] --> EMM",
|
||||
mme_ue->imsi_bcd);
|
||||
d_info("[NAS] Attach request : UE_IMSI[%s] --> EMM", imsi_bcd);
|
||||
|
||||
mme_s6a_send_air(mme_ue);
|
||||
break;
|
||||
}
|
||||
case NAS_EPS_MOBILE_IDENTITY_GUTI:
|
||||
{
|
||||
nas_eps_mobile_identity_guti_t *guti = NULL;
|
||||
guti = &eps_mobile_identity->guti;
|
||||
nas_eps_mobile_identity_guti_t *nas_guti = NULL;
|
||||
nas_guti = &eps_mobile_identity->guti;
|
||||
guti_t guti;
|
||||
|
||||
guti.plmn_id = nas_guti->plmn_id;
|
||||
guti.mme_gid = nas_guti->mme_gid;
|
||||
guti.mme_code = nas_guti->mme_code;
|
||||
guti.m_tmsi = nas_guti->m_tmsi;
|
||||
|
||||
d_info("[NAS] Attach request : UE_GUTI[G:%d,C:%d,M_TMSI:0x%x] --> EMM",
|
||||
guti->mme_gid,
|
||||
guti->mme_code,
|
||||
guti->m_tmsi);
|
||||
guti.mme_gid,
|
||||
guti.mme_code,
|
||||
guti.m_tmsi);
|
||||
|
||||
|
||||
/* FIXME :Check if GUTI was assigend from us */
|
||||
|
||||
|
@ -134,7 +139,6 @@ void emm_handle_attach_request(
|
|||
* stored in permanent DB
|
||||
*/
|
||||
|
||||
|
||||
/* If not found,
|
||||
Initiate NAS Identity procedure to get UE IMSI */
|
||||
emm_handle_identity_request(mme_ue);
|
||||
|
@ -195,10 +199,12 @@ void emm_handle_identity_response(
|
|||
|
||||
if (mobile_identity->imsi.type == NAS_IDENTITY_TYPE_2_IMSI)
|
||||
{
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
|
||||
nas_imsi_to_bcd(
|
||||
&mobile_identity->imsi, mobile_identity->length,
|
||||
mme_ue->imsi_bcd);
|
||||
core_bcd_to_buffer(mme_ue->imsi_bcd, mme_ue->imsi, &mme_ue->imsi_len);
|
||||
imsi_bcd);
|
||||
mme_ue_set_imsi(mme_ue, imsi_bcd);
|
||||
|
||||
d_assert(mme_ue->imsi_len, return,
|
||||
"Can't get IMSI(len:%d\n", mme_ue->imsi_len);
|
||||
|
@ -643,29 +649,15 @@ mme_ue_t *emm_find_ue_by_message(enb_ue_t *enb_ue, nas_message_t *message)
|
|||
{
|
||||
case NAS_EPS_MOBILE_IDENTITY_IMSI:
|
||||
{
|
||||
c_uint8_t imsi[MAX_IMSI_LEN];
|
||||
int imsi_len = 0;
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
c_int8_t imsi_bcd[MAX_IMSI_BCD_LEN+1];
|
||||
|
||||
nas_imsi_to_bcd(
|
||||
&eps_mobile_identity->imsi, eps_mobile_identity->length,
|
||||
imsi_bcd);
|
||||
core_bcd_to_buffer(imsi_bcd, imsi, &imsi_len);
|
||||
|
||||
d_trace(3,"Search mme_ue by UE_IMSI[%s]\n", imsi_bcd);
|
||||
|
||||
/* Find mme_ue_context by IMSI */
|
||||
mme_ue = mme_ue_find_by_imsi(imsi, imsi_len);
|
||||
|
||||
/* If not found , create one */
|
||||
if (!mme_ue)
|
||||
{
|
||||
mme_ue = mme_ue_add(enb_ue);
|
||||
strncpy(mme_ue->imsi_bcd, imsi_bcd,
|
||||
sizeof(mme_ue->imsi_bcd));
|
||||
|
||||
mme_ue_set_imsi(mme_ue, imsi, imsi_len);
|
||||
}
|
||||
mme_ue = mme_ue_find_by_imsi_bcd(imsi_bcd);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -686,10 +678,6 @@ mme_ue_t *emm_find_ue_by_message(enb_ue_t *enb_ue, nas_message_t *message)
|
|||
guti.m_tmsi);
|
||||
|
||||
mme_ue = mme_ue_find_by_guti(&guti);
|
||||
if (!mme_ue)
|
||||
{
|
||||
mme_ue = mme_ue_add(enb_ue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "core_debug.h"
|
||||
#include "core_pool.h"
|
||||
#include "core_lib.h"
|
||||
|
||||
#include "gtp_path.h"
|
||||
#include "s1ap_message.h"
|
||||
|
@ -1024,16 +1025,28 @@ mme_ue_t* mme_ue_find(index_t index)
|
|||
return index_find(&mme_ue_pool, index);
|
||||
}
|
||||
|
||||
mme_ue_t* mme_ue_find_by_imsi_bcd(c_int8_t *imsi_bcd)
|
||||
{
|
||||
c_uint8_t imsi[MAX_IMSI_LEN];
|
||||
int imsi_len = 0;
|
||||
|
||||
d_assert(imsi_bcd, return NULL,"Invalid param");
|
||||
|
||||
core_bcd_to_buffer(imsi_bcd, imsi, &imsi_len);
|
||||
|
||||
return mme_ue_find_by_imsi(imsi, imsi_len);
|
||||
}
|
||||
|
||||
mme_ue_t* mme_ue_find_by_imsi(c_uint8_t *imsi, int imsi_len)
|
||||
{
|
||||
d_assert(imsi && imsi_len, return NULL,"Invalid Param");
|
||||
d_assert(imsi && imsi_len, return NULL,"Invalid param");
|
||||
|
||||
return (mme_ue_t *)hash_get(self.imsi_ue_hash, imsi, imsi_len);
|
||||
}
|
||||
|
||||
mme_ue_t* mme_ue_find_by_guti(guti_t *guti)
|
||||
{
|
||||
d_assert(guti, return NULL,"Invalid Param");
|
||||
d_assert(guti, return NULL,"Invalid param");
|
||||
|
||||
return (mme_ue_t *)hash_get(self.guti_ue_hash, guti, sizeof(guti_t));
|
||||
}
|
||||
|
@ -1055,19 +1068,8 @@ mme_ue_t *mme_ue_this(hash_index_t *hi)
|
|||
return hash_this_val(hi);
|
||||
}
|
||||
|
||||
status_t mme_ue_set_imsi(mme_ue_t *mme_ue, c_uint8_t *imsi, int imsi_len)
|
||||
{
|
||||
d_assert(mme_ue && imsi, return CORE_ERROR, "Invalid Param");
|
||||
|
||||
memcpy(mme_ue->imsi, imsi, imsi_len);
|
||||
mme_ue->imsi_len = imsi_len;
|
||||
|
||||
hash_set(self.imsi_ue_hash, mme_ue->imsi, mme_ue->imsi_len, mme_ue);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t mme_ue_new_guti(mme_ue_t *mme_ue)
|
||||
/* At this point, I'm not sure whether this function is exported or not */
|
||||
static status_t mme_ue_new_guti(mme_ue_t *mme_ue)
|
||||
{
|
||||
served_gummei_t *served_gummei = NULL;
|
||||
|
||||
|
@ -1099,6 +1101,20 @@ status_t mme_ue_new_guti(mme_ue_t *mme_ue)
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
status_t mme_ue_set_imsi(mme_ue_t *mme_ue, c_int8_t *imsi_bcd)
|
||||
{
|
||||
d_assert(mme_ue && imsi_bcd, return CORE_ERROR, "Invalid param");
|
||||
|
||||
core_cpystrn(mme_ue->imsi_bcd, imsi_bcd, MAX_IMSI_BCD_LEN+1);
|
||||
core_bcd_to_buffer(mme_ue->imsi_bcd, mme_ue->imsi, &mme_ue->imsi_len);
|
||||
|
||||
hash_set(self.imsi_ue_hash, mme_ue->imsi, mme_ue->imsi_len, mme_ue);
|
||||
|
||||
mme_ue_new_guti(mme_ue);
|
||||
|
||||
return CORE_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
unsigned int mme_ue_count()
|
||||
{
|
||||
|
|
|
@ -287,18 +287,17 @@ CORE_DECLARE(mme_ue_t*) mme_ue_add(enb_ue_t *enb_ue);
|
|||
CORE_DECLARE(status_t) mme_ue_remove(mme_ue_t *mme_ue);
|
||||
CORE_DECLARE(status_t) mme_ue_remove_all();
|
||||
|
||||
CORE_DECLARE(status_t) mme_ue_set_imsi(
|
||||
mme_ue_t *mme_ue, c_int8_t *imsi_bcd);
|
||||
CORE_DECLARE(mme_ue_t*) mme_ue_find(index_t index);
|
||||
CORE_DECLARE(mme_ue_t*) mme_ue_find_by_imsi(c_uint8_t *imsi, int imsi_len);
|
||||
CORE_DECLARE(mme_ue_t*) mme_ue_find_by_imsi_bcd(c_int8_t *imsi_bcd);
|
||||
CORE_DECLARE(mme_ue_t*) mme_ue_find_by_guti(guti_t *guti);
|
||||
|
||||
CORE_DECLARE(hash_index_t *) mme_ue_first();
|
||||
CORE_DECLARE(hash_index_t *) mme_ue_next(hash_index_t *hi);
|
||||
CORE_DECLARE(mme_ue_t *) mme_ue_this(hash_index_t *hi);
|
||||
|
||||
CORE_DECLARE(status_t) mme_ue_set_imsi(mme_ue_t *mme_ue,
|
||||
c_uint8_t *imsi, int imsi_len);
|
||||
CORE_DECLARE(status_t) mme_ue_new_guti(mme_ue_t *mme_ue);
|
||||
|
||||
CORE_DECLARE(mme_bearer_t*) mme_sess_add(mme_ue_t *mme_ue, c_uint8_t pti);
|
||||
CORE_DECLARE(status_t ) mme_sess_remove(mme_sess_t *sess);
|
||||
CORE_DECLARE(status_t ) mme_sess_remove_all(mme_ue_t *mme_ue);
|
||||
|
|
|
@ -161,10 +161,17 @@ void mme_state_operational(fsm_t *s, event_t *e)
|
|||
pkbuf_free(pkbuf); break, "Can't decode NAS_EMM");
|
||||
|
||||
mme_ue = enb_ue->mme_ue;
|
||||
if (mme_ue == NULL)
|
||||
if (!mme_ue)
|
||||
{
|
||||
/* Find MME UE by NAS message or create if needed */
|
||||
mme_ue = emm_find_ue_by_message(enb_ue, &message);
|
||||
|
||||
/* If not found , create one */
|
||||
if (!mme_ue)
|
||||
{
|
||||
mme_ue = mme_ue_add(enb_ue);
|
||||
d_assert(mme_ue, break, "Null param");
|
||||
}
|
||||
}
|
||||
|
||||
d_assert(mme_ue, pkbuf_free(pkbuf);break, "No MME UE context");
|
||||
|
|
Loading…
Reference in New Issue