update it

This commit is contained in:
Sukchan Lee 2017-04-11 11:54:00 +09:00
parent 3244b08f2a
commit 480ec5af15
8 changed files with 71 additions and 38 deletions

View File

@ -89,8 +89,6 @@ void emm_handle_attach_request(
&attach_request->ms_network_capability,
sizeof(attach_request->ms_network_capability));
d_info("[NAS] Attach request : UE[%s] --> EMM", ue->imsi_bcd);
mme_s6a_send_air(ue);
break;
}
@ -104,6 +102,31 @@ void emm_handle_attach_request(
}
}
void emm_handle_authentication_request(mme_ue_t *ue)
{
nas_message_t message;
pkbuf_t *sendbuf = NULL;
nas_authentication_request_t *authentication_request =
&message.emm.authentication_request;
d_assert(ue, return, "Null param");
memset(&message, 0, sizeof(message));
message.emm.h.protocol_discriminator = NAS_PROTOCOL_DISCRIMINATOR_EMM;
message.emm.h.message_type = NAS_AUTHENTICATION_REQUEST;
memcpy(authentication_request->authentication_parameter_rand.rand,
ue->rand, RAND_LEN);
memcpy(authentication_request->authentication_parameter_autn.autn,
ue->autn, AUTN_LEN);
authentication_request->authentication_parameter_autn.length =
AUTN_LEN;
d_assert(nas_plain_encode(&sendbuf, &message) == CORE_OK && sendbuf,,);
mme_event_nas_to_s1ap(ue, sendbuf);
}
void emm_handle_authentication_response(
mme_ue_t *ue, nas_authentication_response_t *authentication_response)
{
@ -172,8 +195,6 @@ void emm_handle_authentication_response(
d_assert(nas_security_encode(&sendbuf, ue, &message) == CORE_OK &&
sendbuf,,);
mme_event_nas_to_s1ap(ue, sendbuf);
d_info("[NAS] Security mode command : UE[%s] <-- EMM", ue->imsi_bcd);
}
void emm_handle_security_mode_complete(mme_ue_t *ue)

View File

@ -11,6 +11,7 @@ extern "C" {
CORE_DECLARE(void) emm_handle_attach_request(
mme_ue_t *ue, nas_attach_request_t *attach_request);
CORE_DECLARE(void) emm_handle_authentication_request(mme_ue_t *ue);
CORE_DECLARE(void) emm_handle_authentication_response(
mme_ue_t *ue, nas_authentication_response_t *authentication_response);
CORE_DECLARE(void) emm_handle_security_mode_complete(mme_ue_t *ue);

View File

@ -41,6 +41,22 @@ void emm_state_operational(fsm_t *s, event_t *e)
{
break;
}
case EVT_LO_MME_EMM_AUTH_REQ:
{
index_t index = event_get_param1(e);
mme_ue_t *ue = NULL;
d_assert(index, return, "Null param");
ue = mme_ue_find(index);
d_assert(ue, return, "Null param");
emm_handle_authentication_request(ue);
d_info("[NAS] Authentication request : UE[%s] <-- EMM",
ue->imsi_bcd);
break;
}
case EVT_MSG_MME_EMM:
{
index_t index = event_get_param1(e);
@ -60,23 +76,19 @@ void emm_state_operational(fsm_t *s, event_t *e)
{
emm_handle_attach_request(
ue, &message->emm.attach_request);
break;
}
case NAS_AUTHENTICATION_REQUEST:
{
pkbuf_t *recvbuf = (pkbuf_t *)event_get_param2(e);
d_assert(recvbuf, break, "Null param");
mme_event_nas_to_s1ap(ue, pkbuf_copy(recvbuf));
d_info("[NAS] Authentication request : UE[%s] <-- EMM",
d_info("[NAS] Attach request : UE[%s] --> EMM",
ue->imsi_bcd);
break;
}
case NAS_AUTHENTICATION_RESPONSE:
{
emm_handle_authentication_response(
ue, &message->emm.authentication_response);
d_info("[NAS] Security mode command : UE[%s] <-- EMM",
ue->imsi_bcd);
break;
}
case NAS_SECURITY_MODE_COMPLETE:

View File

@ -121,6 +121,8 @@ typedef struct _mme_ue_t {
c_uint8_t xres[MAX_RES_LEN];
c_uint8_t xres_len;
c_uint8_t kasme[SHA256_DIGEST_SIZE];
c_uint8_t rand[RAND_LEN];
c_uint8_t autn[AUTN_LEN];
c_uint8_t knas_int[SHA256_DIGEST_SIZE/2];
c_uint8_t knas_enc[SHA256_DIGEST_SIZE/2];
c_uint32_t dl_count;

View File

@ -9,6 +9,7 @@
static char EVT_NAME_LO_MME_S1AP_ACCEPT[] = "LO_MME_S1AP_ACCEPT";
static char EVT_NAME_LO_MME_S1AP_CONNREFUSED[] = "LO_MME_S1AP_CONNREFUSED";
static char EVT_NAME_LO_MME_EMM_AUTH_REQ[] = "LO_MME_EMM_AUTH_REQ";
static char EVT_NAME_TM_MME_S11_T3[] = "TM_MME_S11_T3";
@ -33,6 +34,8 @@ char* mme_event_get_name(event_t *e)
return EVT_NAME_LO_MME_S1AP_ACCEPT;
case EVT_LO_MME_S1AP_CONNREFUSED:
return EVT_NAME_LO_MME_S1AP_CONNREFUSED;
case EVT_LO_MME_EMM_AUTH_REQ:
return EVT_NAME_LO_MME_EMM_AUTH_REQ;
case EVT_TM_MME_S11_T3:
return EVT_NAME_TM_MME_S11_T3;

View File

@ -19,6 +19,7 @@ typedef enum {
EVT_LO_MME_S1AP_ACCEPT,
EVT_LO_MME_S1AP_CONNREFUSED,
EVT_LO_MME_EMM_AUTH_REQ,
EVT_TM_MME_S11_T3,

View File

@ -35,11 +35,7 @@ static void mme_s6a_aia_cb(void *data, struct msg **msg)
int new;
mme_ue_t *ue = NULL;
nas_message_t message;
pkbuf_t *sendbuf = NULL;
event_t e;
nas_authentication_request_t *authentication_request =
&message.emm.authentication_request;
CHECK_SYS_DO(clock_gettime(CLOCK_REALTIME, &ts), return);
@ -67,10 +63,6 @@ static void mme_s6a_aia_cb(void *data, struct msg **msg)
goto out;
}
memset(&message, 0, sizeof(message));
message.emm.h.protocol_discriminator = NAS_PROTOCOL_DISCRIMINATOR_EMM;
message.emm.h.message_type = NAS_AUTHENTICATION_REQUEST;
d_assert(fd_msg_search_avp(*msg, s6a_authentication_info, &avp) == 0 &&
avp, error++; goto out,);
d_assert(fd_msg_avp_hdr(avp, &hdr) == 0 && hdr, error++; goto out,);
@ -94,29 +86,17 @@ static void mme_s6a_aia_cb(void *data, struct msg **msg)
d_assert(fd_avp_search_avp(avp_e_utran_vector, s6a_rand, &avp_rand) == 0 &&
avp_rand, error++; goto out,);
d_assert(fd_msg_avp_hdr(avp_rand, &hdr) == 0 && hdr, error++; goto out,);
memcpy(authentication_request->authentication_parameter_rand.rand,
hdr->avp_value->os.data, hdr->avp_value->os.len);
memcpy(ue->rand, hdr->avp_value->os.data, hdr->avp_value->os.len);
d_assert(fd_avp_search_avp(avp_e_utran_vector, s6a_autn, &avp_autn) == 0 &&
avp_autn, error++; goto out,);
d_assert(fd_msg_avp_hdr(avp_autn, &hdr) == 0 && hdr, error++; goto out,);
authentication_request->authentication_parameter_autn.length =
hdr->avp_value->os.len;
memcpy(authentication_request->authentication_parameter_autn.autn,
hdr->avp_value->os.data, hdr->avp_value->os.len);
memcpy(ue->autn, hdr->avp_value->os.data, hdr->avp_value->os.len);
d_assert(nas_plain_encode(&sendbuf, &message) == CORE_OK && sendbuf,
error++; goto out,);
event_set(&e, EVT_MSG_MME_EMM);
event_set(&e, EVT_LO_MME_EMM_AUTH_REQ);
event_set_param1(&e, (c_uintptr_t)ue->index);
event_set_param2(&e, (c_uintptr_t)sendbuf);
if (mme_event_send(&e) != CORE_OK)
{
d_error("mme_event_send failed");
pkbuf_free(sendbuf);
error++;
}
mme_event_send(&e);
out:
/* Free the message */
d_assert(pthread_mutex_lock(&s6a_config->stats_lock) == 0,,);

View File

@ -144,6 +144,19 @@ void mme_state_operational(fsm_t *s, event_t *e)
pkbuf_free(pkbuf);
break;
}
case EVT_LO_MME_EMM_AUTH_REQ:
{
index_t index = event_get_param1(e);
mme_ue_t *ue = NULL;
d_assert(index, break, "Null param");
ue = mme_ue_find(index);
d_assert(ue, break, "No UE context");
d_assert(FSM_STATE(&ue->sm), break, "No EMM State Machine");
fsm_dispatch(&ue->sm, (fsm_event_t*)e);
break;
}
case EVT_MSG_MME_EMM:
{
nas_message_t message;