Add Diameter Error if IMSI is not found

This commit is contained in:
Sukchan Lee 2017-08-09 14:48:44 +09:00
parent d8fad33169
commit e6e2183801
6 changed files with 90 additions and 36 deletions

View File

@ -9,6 +9,15 @@
extern "C" {
#endif /* __cplusplus */
#define S6A_DIAMETER_AUTHENTICATION_DATA_UNAVAILABLE 4181
#define S6A_DIAMETER_ERROR_USER_UNKNOWN 5001
#define S6A_DIAMETER_ERROR_ROAMING_NOT_ALLOWED 5004
#define S6A_DIAMETER_ERROR_UNKNOWN_EPS_SUBSCRIPTION 5420
#define S6A_DIAMETER_ERROR_RAT_NOT_ALLOWED 5421
#define S6A_DIAMETER_ERROR_EQUIPMENT_UNKNOWN 5422
#define S6A_DIAMETER_ERROR_UNKOWN_SERVING_NODE 5423
#define S6A_AVP_CODE_CONTEXT_IDENTIFIER (1423)
#define S6A_AVP_CODE_ALL_APN_CONFIG_INC_IND (1428)
#define S6A_AVP_CODE_APN_CONFIGURATION (1430)

View File

@ -54,6 +54,7 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
hss_db_auth_info_t auth_info;
c_uint8_t zero[RAND_LEN];
status_t rv;
c_uint32_t result_code = 0;
d_assert(msg, return EINVAL,);
@ -71,7 +72,8 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
rv = hss_db_auth_info(imsi_bcd, &auth_info);
if (rv != CORE_OK)
{
d_error("Cannot get Auth-Info for IMSI:'%s'", imsi_bcd);
d_warn("Cannot get Auth-Info for IMSI:'%s'", imsi_bcd);
result_code = S6A_DIAMETER_ERROR_USER_UNKNOWN;
goto out;
}
@ -85,6 +87,7 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
if (rv != CORE_OK)
{
d_error("Cannot update rand and sqn for IMSI:'%s'", imsi_bcd);
result_code = S6A_DIAMETER_AUTHENTICATION_DATA_UNAVAILABLE;
goto out;
}
@ -92,19 +95,17 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
if (rv != CORE_OK)
{
d_error("Cannot increment sqn for IMSI:'%s'", imsi_bcd);
result_code = S6A_DIAMETER_AUTHENTICATION_DATA_UNAVAILABLE;
goto out;
}
CHECK_FCT( fd_msg_search_avp(qry, s6a_visited_plmn_id, &avp) );
CHECK_FCT( fd_msg_avp_hdr(avp, &hdr) );
if (hdr && hdr->avp_value && hdr->avp_value->os.data)
{
#if 0 // TODO : check visited_plmn_id
memcpy(visited_plmn_id,
hdr->avp_value->os.data, hdr->avp_value->os.len);
memcpy(visited_plmn_id,
hdr->avp_value->os.data, hdr->avp_value->os.len);
#endif
}
milenage_opc(auth_info.k, auth_info.op, opc);
milenage_generate(opc, auth_info.amf, auth_info.k,
@ -112,15 +113,6 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
autn, ik, ck, ak, xres, &xres_len);
hss_kdf_kasme(ck, ik, hdr->avp_value->os.data, sqn, ak, kasme);
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
CHECK_FCT( fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1) );
/* Set the Auth-Session-State AVP */
CHECK_FCT( fd_msg_avp_new(fd_auth_session_state, 0, &avp) );
val.i32 = 1;
CHECK_FCT( fd_msg_avp_setvalue(avp, &val) );
CHECK_FCT( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) );
/* Set the Authentication-Info */
CHECK_FCT( fd_msg_avp_new(s6a_authentication_info, 0, &avp) );
CHECK_FCT( fd_msg_avp_new(s6a_e_utran_vector, 0, &avp_e_utran_vector) );
@ -155,7 +147,16 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
CHECK_FCT( fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avp_e_utran_vector) );
CHECK_FCT( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) );
/* Set the Origin-Host, Origin-Realm, andResult-Code AVPs */
CHECK_FCT( fd_msg_rescode_set(ans, "DIAMETER_SUCCESS", NULL, NULL, 1) );
/* Set the Auth-Session-State AVP */
CHECK_FCT( fd_msg_avp_new(fd_auth_session_state, 0, &avp) );
val.i32 = 1;
CHECK_FCT( fd_msg_avp_setvalue(avp, &val) );
CHECK_FCT( fd_msg_avp_add(ans, MSG_BRW_LAST_CHILD, avp) );
/* Send the answer */
CHECK_FCT( fd_msg_send(msg, NULL, NULL) );
@ -167,8 +168,7 @@ static int hss_air_cb( struct msg **msg, struct avp *avp,
return 0;
out:
CHECK_FCT( fd_msg_rescode_set(
ans, "DIAMETER_AUTHENTICATION_REJECTED", NULL, NULL, 1) );
CHECK_FCT( fd_message_experimental_rescode_set(ans, result_code) );
CHECK_FCT( fd_msg_send(msg, NULL, NULL) );
return 0;

View File

@ -15,6 +15,7 @@
#include "emm_build.h"
#include "s1ap_build.h"
#include "s1ap_path.h"
#include "fd_lib.h"
#include "mme_s11_build.h"
#include "mme_s11_path.h"
@ -814,3 +815,16 @@ void emm_handle_downlink_data_notification(gtp_xact_t *xact,
sess->sgw_s11_teid, s11buf) == CORE_OK,
return , "xact commit error");
}
void emm_handle_s6a_aia(mme_ue_t *mme_ue, c_uint32_t result_code)
{
if (result_code == ER_DIAMETER_SUCCESS)
{
emm_handle_authentication_request(mme_ue);
}
else
{
/* TODO */
/* Send Attach Reject */
}
}

View File

@ -11,29 +11,37 @@ extern "C" {
CORE_DECLARE(void) emm_handle_attach_request(
mme_ue_t *mme_ue, nas_attach_request_t *attach_request);
CORE_DECLARE(void) emm_handle_authentication_request(mme_ue_t *mme_ue);
CORE_DECLARE(void) emm_handle_authentication_response(
mme_ue_t *mme_ue, nas_authentication_response_t *authentication_response);
CORE_DECLARE(void) emm_handle_create_session_response(mme_bearer_t *bearer);
CORE_DECLARE(void) emm_handle_attach_accept(mme_ue_t *mme_ue);
CORE_DECLARE(void) emm_handle_attach_complete(
mme_ue_t *mme_ue, nas_attach_complete_t *attach_complete);
CORE_DECLARE(void) emm_handle_emm_status(
mme_ue_t *mme_ue, nas_emm_status_t *emm_status);
CORE_DECLARE(void) emm_handle_identity_request(mme_ue_t *mme_ue);
CORE_DECLARE(void) emm_handle_identity_response(
mme_ue_t *mme_ue, nas_identity_response_t *identity_response);
CORE_DECLARE(void) emm_handle_authentication_request(mme_ue_t *mme_ue);
CORE_DECLARE(void) emm_handle_authentication_response(
mme_ue_t *mme_ue, nas_authentication_response_t *authentication_response);
CORE_DECLARE(void) emm_handle_detach_request(
mme_ue_t *mme_ue, nas_detach_request_from_ue_t *detach_request);
CORE_DECLARE(void) emm_handle_detach_accept(
mme_ue_t *mme_ue, nas_detach_request_from_ue_t *detach_request);
CORE_DECLARE(void) emm_handle_delete_session_request(mme_ue_t *mme_ue);
CORE_DECLARE(void) emm_handle_delete_session_response(mme_bearer_t *bearer);
CORE_DECLARE(void) emm_handle_emm_status(
mme_ue_t *mme_ue, nas_emm_status_t *emm_status);
CORE_DECLARE(void) emm_handle_service_request(
mme_ue_t *mme_ue, nas_service_request_t *service_request);
CORE_DECLARE(void) emm_handle_create_session_response(mme_bearer_t *bearer);
CORE_DECLARE(void) emm_handle_delete_session_request(mme_ue_t *mme_ue);
CORE_DECLARE(void) emm_handle_delete_session_response(mme_bearer_t *bearer);
CORE_DECLARE(void) emm_handle_downlink_data_notification(gtp_xact_t *xact,
mme_bearer_t *bearer);
CORE_DECLARE(void) emm_handle_s6a_aia(mme_ue_t *mme_ue, c_uint32_t result_code);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -93,7 +93,8 @@ void emm_state_operational(fsm_t *s, event_t *e)
{
case S6A_CMD_AUTHENTICATION_INFORMATION:
{
emm_handle_authentication_request(mme_ue);
c_uint32_t result_code = event_get_param3(e);
emm_handle_s6a_aia(mme_ue, result_code);
break;
}
case S6A_CMD_UPDATE_LOCATION:

View File

@ -26,11 +26,12 @@ static void mme_s6a_aia_cb(void *data, struct msg **msg)
struct sess_state *mi = NULL;
struct timespec ts;
struct session *sess;
struct avp *avp;
struct avp *avp, *avpch;
struct avp *avp_e_utran_vector, *avp_xres, *avp_kasme, *avp_rand, *avp_autn;
struct avp_hdr *hdr;
unsigned long dur;
int error = 0;
c_uint32_t result_code = 0;
int new;
event_t e;
@ -57,17 +58,29 @@ static void mme_s6a_aia_cb(void *data, struct msg **msg)
if (avp)
{
CHECK_FCT_DO( fd_msg_avp_hdr(avp, &hdr), return);
d_trace(3, "Status: %d\n", hdr->avp_value->i32);
if (hdr->avp_value->i32 != ER_DIAMETER_SUCCESS)
{
d_error("ERROR DIAMETER Result Code(%d)", hdr->avp_value->i32);
error++;
}
result_code = hdr->avp_value->i32;
d_trace(3, "Result Code: %d\n", hdr->avp_value->i32);
}
else
{
d_error("no Result-Code");
error++;
CHECK_FCT_DO( fd_msg_search_avp(*msg,
fd_experimental_result, &avp), return );
if (avp)
{
CHECK_FCT_DO( fd_avp_search_avp(avp,
fd_experimental_result_code, &avpch), return );
if (avpch)
{
CHECK_FCT_DO( fd_msg_avp_hdr(avpch, &hdr), return);
result_code = hdr->avp_value->i32;
d_trace(3, "Experimental Result Code: %d\n", result_code);
}
}
else
{
d_error("no Result-Code");
error++;
}
}
/* Value of Origin-Host */
@ -98,6 +111,13 @@ static void mme_s6a_aia_cb(void *data, struct msg **msg)
error++;
}
if (result_code != ER_DIAMETER_SUCCESS)
{
d_warn("ERROR DIAMETER Result Code(%d)", result_code);
error++;
goto out;
}
CHECK_FCT_DO(
fd_msg_search_avp(*msg, s6a_authentication_info, &avp), return );
if (avp)
@ -158,9 +178,11 @@ static void mme_s6a_aia_cb(void *data, struct msg **msg)
else
error++;
out:
event_set(&e, MME_EVT_EMM_UE_FROM_S6A);
event_set_param1(&e, (c_uintptr_t)mme_ue->index);
event_set_param2(&e, (c_uintptr_t)S6A_CMD_AUTHENTICATION_INFORMATION);
event_set_param3(&e, (c_uintptr_t)result_code);
mme_event_send(&e);
/* Free the message */