Commit fb09ba8e authored by gauthier's avatar gauthier

OK for start of MME_GW and HSS on same host

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7110 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent ecff2e01
......@@ -349,6 +349,10 @@ _gtpuah_tg4_add(struct sk_buff *old_skb_pP, const struct xt_action_param *par_pP
}
}
};
/*pr_info("GTPUAH: PACKET -> NF_HOOK NF_INET_POST_ROUTING/%s encapsulated src: %u.%u.%u.%u dst: %u.%u.%u.%u\n",
gtpuah_tg_reg[0].table,
NIPADDR(old_iph_p->saddr),
NIPADDR(old_iph_p->daddr));*/
rt = ip_route_output_key(&init_net, &fl.u.ip4);
......
......@@ -68,6 +68,7 @@ extern boolean_t pdcp_data_req(
unsigned char *const sdu_buffer_pP,
const pdcp_transmission_mode_t modeP);
extern unsigned char NB_eNB_INST;
static int
gtpv1u_eNB_send_init_udp(
......@@ -132,19 +133,23 @@ gtpv1u_initial_req(
int
gtpv1u_new_data_req(
uint8_t enb_idP,
uint8_t ue_idP,
uint8_t enb_module_idP,
rnti_t ue_rntiP,
uint8_t rab_idP,
uint8_t *buffer_pP,
uint32_t buf_lenP,
uint32_t buf_offsetP);
uint32_t buf_offsetP
);
static int
gtpv1u_create_s1u_tunnel(
gtpv1u_enb_create_tunnel_req_t *create_tunnel_req_pP);
const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP);
static int
gtpv1u_delete_s1u_tunnel(gtpv1u_enb_delete_tunnel_req_t *req_pP);
gtpv1u_delete_s1u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_delete_tunnel_req_t * const req_pP);
static int
gtpv1u_eNB_init(void);
......@@ -322,17 +327,14 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req(
#endif
#warning "LG eps bearer mapping to DRB id to do (offset -4)"
ctxt.enb_module_id = gtpv1u_teid_data_p->enb_id;
ctxt.ue_module_id = gtpv1u_teid_data_p->ue_id;
ctxt.frame = 0;
ctxt.enb_flag = ENB_FLAG_YES;
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, gtpv1u_teid_data_p->enb_id, ENB_FLAG_YES, gtpv1u_teid_data_p->ue_id, 0, 0);
result = pdcp_data_req(
&ctxt,
SRB_FLAG_NO,
(gtpv1u_teid_data_p->eps_bearer_id) ? gtpv1u_teid_data_p->eps_bearer_id - 4: 5-4,
0, // mui
FALSE, // confirm
SDU_CONFIRM_NO, // confirm
buffer_len,
buffer,
PDCP_TRANSMISSION_MODE_DATA);
......@@ -551,8 +553,8 @@ gtpv1u_initial_req(
//-----------------------------------------------------------------------------
int
gtpv1u_new_data_req(
uint8_t enb_idP,
uint8_t ue_idP,
uint8_t enb_module_idP,
rnti_t ue_rntiP,
uint8_t rab_idP,
uint8_t *buffer_pP,
uint32_t buf_lenP,
......@@ -569,18 +571,18 @@ gtpv1u_new_data_req(
gtpv1u_data_t *gtpv1u_data_p = NULL;
memset(&ue, 0, sizeof(struct gtpv1u_ue_data_s));
ue.ue_id = ue_idP;
ue.ue_id = ue_rntiP;
AssertFatal(enb_idP >=0, "Bad parameter enb module id %u\n", enb_idP);
AssertFatal(enb_module_idP >=0, "Bad parameter enb module id %u\n", enb_module_idP);
AssertFatal((rab_idP - GTPV1U_BEARER_OFFSET)< GTPV1U_MAX_BEARERS_ID, "Bad parameter rab id %u\n", rab_idP);
AssertFatal((rab_idP - GTPV1U_BEARER_OFFSET) >= 0 , "Bad parameter rab id %u\n", rab_idP);
gtpv1u_data_p = &gtpv1u_data_g;
/* Check that UE context is present in ue map. */
hash_rc = hashtable_get(gtpv1u_data_p->ue_mapping, (uint64_t)ue_idP, (void**)&ue_inst_p);
hash_rc = hashtable_get(gtpv1u_data_p->ue_mapping, (uint64_t)ue_rntiP, (void**)&ue_inst_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS ) {
LOG_E(GTPU, "[UE %d] Trying to send data on non-existing UE context\n", ue_idP);
LOG_E(GTPU, "[UE %d] Trying to send data on non-existing UE context\n", ue_rntiP);
return -1;
}
......@@ -643,7 +645,8 @@ gtpv1u_new_data_req(
//-----------------------------------------------------------------------------
static int
gtpv1u_create_s1u_tunnel(
gtpv1u_enb_create_tunnel_req_t *create_tunnel_req_pP)
const instance_t instanceP,
const gtpv1u_enb_create_tunnel_req_t * const create_tunnel_req_pP)
{
/* Create a new nw-gtpv1-u stack req using API */
NwGtpv1uUlpApiT stack_req;
......@@ -662,15 +665,15 @@ gtpv1u_create_s1u_tunnel(
int addrs_length_in_bytes= 0;
message_p = itti_alloc_new_message(TASK_GTPV1_U, GTPV1U_ENB_CREATE_TUNNEL_RESP);
GTPV1U_ENB_CREATE_TUNNEL_RESP(message_p).ue_index = create_tunnel_req_pP->ue_index;
GTPV1U_ENB_CREATE_TUNNEL_RESP(message_p).rnti = create_tunnel_req_pP->rnti;
GTPV1U_ENB_CREATE_TUNNEL_RESP(message_p).status = 0;
GTPV1U_ENB_CREATE_TUNNEL_RESP(message_p).num_tunnels = 0;
for (i = 0; i < create_tunnel_req_pP->num_tunnels; i++) {
ip_offset = 0;
eps_bearer_id = create_tunnel_req_pP->eps_bearer_id[i];
LOG_D(GTPU, "Rx GTPV1U_ENB_CREATE_TUNNEL_REQ ue_index %u eps bearer id %u\n",
create_tunnel_req_pP->ue_index, eps_bearer_id);
LOG_D(GTPU, "Rx GTPV1U_ENB_CREATE_TUNNEL_REQ ue rnti %x eps bearer id %u\n",
create_tunnel_req_pP->rnti, eps_bearer_id);
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
stack_req.apiType = NW_GTPV1U_ULP_API_CREATE_TUNNEL_ENDPOINT;
......@@ -689,17 +692,17 @@ gtpv1u_create_s1u_tunnel(
//-----------------------
// PDCP->GTPV1U mapping
//-----------------------
hash_rc = hashtable_get(gtpv1u_data_g.ue_mapping, create_tunnel_req_pP->ue_index, (void **)&gtpv1u_ue_data_p);
hash_rc = hashtable_get(gtpv1u_data_g.ue_mapping, create_tunnel_req_pP->rnti, (void **)&gtpv1u_ue_data_p);
if ((hash_rc == HASH_TABLE_KEY_NOT_EXISTS) || (hash_rc == HASH_TABLE_OK)) {
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
gtpv1u_ue_data_p = calloc (1, sizeof(gtpv1u_ue_data_t));
hash_rc = hashtable_insert(gtpv1u_data_g.ue_mapping, create_tunnel_req_pP->ue_index, gtpv1u_ue_data_p);
hash_rc = hashtable_insert(gtpv1u_data_g.ue_mapping, create_tunnel_req_pP->rnti, gtpv1u_ue_data_p);
AssertFatal(hash_rc == HASH_TABLE_OK, "Error inserting ue_mapping in GTPV1U hashtable");
}
gtpv1u_ue_data_p->ue_id = create_tunnel_req_pP->ue_index;
gtpv1u_ue_data_p->ue_id = create_tunnel_req_pP->rnti;
gtpv1u_ue_data_p->instance_id = 0; // TO DO
memcpy(&GTPV1U_ENB_CREATE_TUNNEL_RESP(message_p).enb_addr.buffer,
&gtpv1u_data_g.enb_ip_address_for_S1u_S12_S4_up,
......@@ -748,7 +751,7 @@ gtpv1u_create_s1u_tunnel(
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
gtpv1u_teid_data_p = calloc (1, sizeof(gtpv1u_teid_data_t));
gtpv1u_teid_data_p->enb_id = 0; // TO DO
gtpv1u_teid_data_p->ue_id = create_tunnel_req_pP->ue_index;
gtpv1u_teid_data_p->ue_id = create_tunnel_req_pP->rnti;
gtpv1u_teid_data_p->eps_bearer_id = eps_bearer_id;
hash_rc = hashtable_insert(gtpv1u_data_g.teid_mapping, s1u_teid, gtpv1u_teid_data_p);
AssertFatal(hash_rc == HASH_TABLE_OK, "Error inserting teid mapping in GTPV1U hashtable");
......@@ -758,16 +761,18 @@ gtpv1u_create_s1u_tunnel(
}
}
LOG_D(GTPU, "Tx GTPV1U_ENB_CREATE_TUNNEL_RESP ue_index %u status %d\n",
create_tunnel_req_pP->ue_index,
LOG_D(GTPU, "Tx GTPV1U_ENB_CREATE_TUNNEL_RESP ue rnti %x status %d\n",
create_tunnel_req_pP->rnti,
GTPV1U_ENB_CREATE_TUNNEL_RESP(message_p).status);
return itti_send_msg_to_task(TASK_RRC_ENB, INSTANCE_DEFAULT, message_p);
return itti_send_msg_to_task(TASK_RRC_ENB, instanceP, message_p);
}
//-----------------------------------------------------------------------------
static int gtpv1u_delete_s1u_tunnel(gtpv1u_enb_delete_tunnel_req_t *req_pP)
static int gtpv1u_delete_s1u_tunnel(
const instance_t instanceP,
const gtpv1u_enb_delete_tunnel_req_t * const req_pP)
{
NwGtpv1uUlpApiT stack_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
......@@ -779,18 +784,18 @@ static int gtpv1u_delete_s1u_tunnel(gtpv1u_enb_delete_tunnel_req_t *req_pP)
message_p = itti_alloc_new_message(TASK_GTPV1_U, GTPV1U_ENB_DELETE_TUNNEL_RESP);
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).ue_index = req_pP->ue_index;
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti = req_pP->rnti;
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).status = 0;
hash_rc = hashtable_get(gtpv1u_data_g.ue_mapping, req_pP->ue_index, (void**)&gtpv1u_ue_data_p);
hash_rc = hashtable_get(gtpv1u_data_g.ue_mapping, req_pP->rnti, (void**)&gtpv1u_ue_data_p);
if (hash_rc == HASH_TABLE_OK) {
for (erab_index = 0; erab_index < req_pP->num_erab; erab_index++) {
teid_eNB = gtpv1u_ue_data_p->bearers[req_pP->eps_bearer_id[erab_index] - GTPV1U_BEARER_OFFSET].teid_eNB;
LOG_D(GTPU, "Rx GTPV1U_ENB_DELETE_TUNNEL user index %u eNB S1U teid %u eps bearer id %u\n",
req_pP->ue_index, teid_eNB, req_pP->eps_bearer_id[erab_index]);
LOG_D(GTPU, "Rx GTPV1U_ENB_DELETE_TUNNEL user rnti %x eNB S1U teid %u eps bearer id %u\n",
req_pP->rnti, teid_eNB, req_pP->eps_bearer_id[erab_index]);
{
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
......@@ -821,8 +826,8 @@ static int gtpv1u_delete_s1u_tunnel(gtpv1u_enb_delete_tunnel_req_t *req_pP)
gtpv1u_ue_data_p->num_bearers -= 1;
if (gtpv1u_ue_data_p->num_bearers == 0) {
hash_rc = hashtable_remove(gtpv1u_data_g.ue_mapping, req_pP->ue_index);
LOG_D(GTPU, "Removed user index %u,no more bearers configured\n", req_pP->ue_index);
hash_rc = hashtable_remove(gtpv1u_data_g.ue_mapping, req_pP->rnti);
LOG_D(GTPU, "Removed user rnti %x,no more bearers configured\n", req_pP->rnti);
}
//-----------------------
......@@ -831,17 +836,17 @@ static int gtpv1u_delete_s1u_tunnel(gtpv1u_enb_delete_tunnel_req_t *req_pP)
hash_rc = hashtable_remove(gtpv1u_data_g.teid_mapping, teid_eNB);
if (hash_rc != HASH_TABLE_OK) {
LOG_D(GTPU, "Removed user index %u , enb S1U teid %u not found\n", req_pP->ue_index, teid_eNB);
LOG_D(GTPU, "Removed user rnti %x , enb S1U teid %u not found\n", req_pP->rnti, teid_eNB);
}
}
}// else silently do nothing
LOG_D(GTPU, "Tx GTPV1U_ENB_DELETE_TUNNEL_RESP user index %u eNB S1U teid %u status %u\n",
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).ue_index,
LOG_D(GTPU, "Tx GTPV1U_ENB_DELETE_TUNNEL_RESP user rnti %x eNB S1U teid %u status %u\n",
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).rnti,
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).enb_S1u_teid,
GTPV1U_ENB_DELETE_TUNNEL_RESP(message_p).status);
return itti_send_msg_to_task(TASK_RRC_ENB, INSTANCE_DEFAULT, message_p);
return itti_send_msg_to_task(TASK_RRC_ENB, instanceP, message_p);
}
//-----------------------------------------------------------------------------
......@@ -947,7 +952,10 @@ static int gtpv1u_eNB_init(void)
//-----------------------------------------------------------------------------
void *gtpv1u_eNB_task(void *args)
{
int rc = 0;
int rc = 0;
instance_t instance;
const char *msg_name_p;
rc = gtpv1u_eNB_init();
AssertFatal(rc == 0, "gtpv1u_eNB_init Failed");
itti_mark_task_ready(TASK_GTPV1_U);
......@@ -962,14 +970,17 @@ void *gtpv1u_eNB_task(void *args)
vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_GTPV1U_ENB_TASK, VCD_FUNCTION_IN);
DevAssert(received_message_p != NULL);
instance = ITTI_MSG_INSTANCE(received_message_p);
msg_name_p = ITTI_MSG_NAME(received_message_p);
switch (ITTI_MSG_ID(received_message_p)) {
case GTPV1U_ENB_CREATE_TUNNEL_REQ: {
gtpv1u_create_s1u_tunnel(&received_message_p->ittiMsg.Gtpv1uCreateTunnelReq);
gtpv1u_create_s1u_tunnel(instance, &received_message_p->ittiMsg.Gtpv1uCreateTunnelReq);
}
break;
case GTPV1U_ENB_DELETE_TUNNEL_REQ: {
gtpv1u_delete_s1u_tunnel(&received_message_p->ittiMsg.Gtpv1uDeleteTunnelReq);
gtpv1u_delete_s1u_tunnel(instance, &received_message_p->ittiMsg.Gtpv1uDeleteTunnelReq);
}
break;
......@@ -989,7 +1000,7 @@ void *gtpv1u_eNB_task(void *args)
// DATA TO BE SENT TO UDP
case GTPV1U_ENB_TUNNEL_DATA_REQ: {
gtpv1u_enb_tunnel_data_req_t *data_req_p = NULL;
NwGtpv1uUlpApiT stack_req;
NwGtpv1uUlpApiT stack_req;
NwGtpv1uRcT rc = NW_GTPV1U_FAILURE;
hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS;
gtpv1u_ue_data_t *gtpv1u_ue_data_p = NULL;
......@@ -1005,10 +1016,10 @@ void *gtpv1u_eNB_task(void *args)
#endif
memset(&stack_req, 0, sizeof(NwGtpv1uUlpApiT));
hash_rc = hashtable_get(gtpv1u_data_g.ue_mapping, (uint64_t)data_req_p->ue_index, (void**)&gtpv1u_ue_data_p);
hash_rc = hashtable_get(gtpv1u_data_g.ue_mapping, (uint64_t)data_req_p->rnti, (void**)&gtpv1u_ue_data_p);
if (hash_rc == HASH_TABLE_KEY_NOT_EXISTS) {
LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: while getting ue_index %u in hashtable ue_mapping\n", data_req_p->ue_index);
LOG_E(GTPU, "nwGtpv1uProcessUlpReq failed: while getting ue rnti %x in hashtable ue_mapping\n", data_req_p->rnti);
} else {
if ((data_req_p->rab_id >= GTPV1U_BEARER_OFFSET) && (data_req_p->rab_id <= max_val_DRB_Identity)) {
enb_s1u_teid = gtpv1u_ue_data_p->bearers[data_req_p->rab_id - GTPV1U_BEARER_OFFSET].teid_eNB;
......
......@@ -58,7 +58,7 @@ typedef enum {
typedef struct gtpv1u_teid_data_s {
/* UE identifier for oaisim stack */
module_id_t enb_id;
module_id_t ue_id;
rnti_t ue_id;
ebi_t eps_bearer_id;
} gtpv1u_teid_data_t;
......@@ -76,7 +76,7 @@ typedef struct gtpv1u_bearer_s {
typedef struct gtpv1u_ue_data_s {
/* UE identifier for oaisim stack */
module_id_t ue_id;
rnti_t ue_id;
/* Unique identifier used between PDCP and GTP-U to distinguish UEs */
uint32_t instance_id;
......@@ -121,12 +121,13 @@ typedef struct gtpv1u_data_s {
int
gtpv1u_new_data_req(
uint8_t enb_id,
uint8_t ue_id,
uint8_t rab_id,
uint8_t *buffer,
uint32_t buf_len,
uint32_t buf_offset);
uint8_t enb_module_idP,
rnti_t ue_rntiP,
uint8_t rab_idP,
uint8_t *buffer_pP,
uint32_t buf_lenP,
uint32_t buf_offsetP
);
int
gtpv1u_initial_req(
......
......@@ -54,7 +54,9 @@
//static NwGtpv1uStackHandleT gtpv1u_stack = 0;
static gtpv1u_data_t gtpv1u_sgw_data;
#if !defined(ENABLE_USE_GTPU_IN_KERNEL)
static int gtpv1u_send_init_udp(uint16_t port_number);
#endif
static int gtpv1u_create_s1u_tunnel(Gtpv1uCreateTunnelReq *create_tunnel_reqP);
static int gtpv1u_delete_s1u_tunnel(Teid_t context_teidP, Teid_t S1U_teidP);
static int gtpv1u_update_s1u_tunnel(Gtpv1uUpdateTunnelReq *reqP);
......@@ -147,6 +149,7 @@ void gtpu_print_hex_octets(unsigned char* dataP, unsigned long sizeP)
}
#if !defined(ENABLE_USE_GTPU_IN_KERNEL)
static int gtpv1u_send_init_udp(uint16_t port_number)
{
// Create and alloc new message
......@@ -168,6 +171,7 @@ static int gtpv1u_send_init_udp(uint16_t port_number)
return itti_send_msg_to_task(TASK_UDP, INSTANCE_DEFAULT, message_p);
}
#endif
NwGtpv1uRcT gtpv1u_log_request(NwGtpv1uLogMgrHandleT hLogMgr,
NwU32T logLevel,
......@@ -179,6 +183,7 @@ NwGtpv1uRcT gtpv1u_log_request(NwGtpv1uLogMgrHandleT hLogMgr,
return NW_GTPV1U_OK;
}
#if !defined(ENABLE_USE_GTPU_IN_KERNEL)
NwGtpv1uRcT gtpv1u_send_udp_msg(
NwGtpv1uUdpHandleT udpHandle,
NwU8T *buffer,
......@@ -203,7 +208,7 @@ NwGtpv1uRcT gtpv1u_send_udp_msg(
return itti_send_msg_to_task(TASK_UDP, INSTANCE_DEFAULT, message_p);
}
#endif
/* Callback called when a gtpv1u message arrived on UDP interface */
NwGtpv1uRcT gtpv1u_process_stack_req(
NwGtpv1uUlpHandleT hUlp,
......
......@@ -128,6 +128,7 @@ nwGtpv1uGpduMsgNew( NW_IN NwGtpv1uStackHandleT hGtpuStackHandle,
{
NwGtpv1uStackT *pStack = (NwGtpv1uStackT *) hGtpuStackHandle;
NwGtpv1uMsgT *pMsg;
//NwU32T header_len = 0;
NwU32T msgExtraLen = 0;
if(gpGtpv1uMsgPool) {
......
......@@ -45,19 +45,20 @@
#include "assertions.h"
static
int mme_app_request_authentication_info(const mme_app_imsi_t imsi,
int mme_app_request_authentication_info(const char *imsi,
const uint8_t nb_of_vectors,
const plmn_t *plmn,
const uint8_t *auts);
static
int mme_app_request_authentication_info(const mme_app_imsi_t imsi,
int mme_app_request_authentication_info(const char *imsi,
const uint8_t nb_of_vectors,
const plmn_t *plmn,
const uint8_t *auts)
{
s6a_auth_info_req_t *auth_info_req = NULL;
MessageDef *message_p = NULL;
int imsi_length = strlen(imsi);
DevAssert(plmn != NULL);
......@@ -66,7 +67,9 @@ int mme_app_request_authentication_info(const mme_app_imsi_t imsi,
auth_info_req = &message_p->ittiMsg.s6a_auth_info_req;
memset(auth_info_req, 0, sizeof(*auth_info_req));
auth_info_req->imsi_length = MME_APP_IMSI_TO_STRING(imsi, auth_info_req->imsi);
strncpy(auth_info_req->imsi, imsi, imsi_length);
auth_info_req->imsi_length = imsi_length;
//MME_APP_IMSI_TO_STRING(imsi, auth_info_req->imsi);
memcpy(&auth_info_req->visited_plmn, plmn, sizeof(plmn_t));
MME_APP_DEBUG("%s visited_plmn MCC %X%X%X MNC %X%X%X\n",
......@@ -214,122 +217,7 @@ mme_app_handle_authentication_info_answer(
return 0;
}
#if defined(DISABLE_USE_NAS)
int mme_app_handle_attach_req(nas_attach_req_t *attach_req_p)
{
/* An attach request has been received from NAS layer.
* If the UE authentication vectors for the UE are known within MME then the
* authentication procedure should be triggered only if the request is an
* initial attach, otherwise an update location should be sent to the HSS
* and default bearer should be established for the provided APN.
* In case of initial attach procedure, the default APN retrieved from the
* HSS will be used to establish the default bearer within EPC.
* The default APN is the one that matches the context-identifier
*/
struct ue_context_s *ue_context;
uint64_t imsi = 0;
DevAssert(attach_req_p != NULL);
MME_APP_STRING_TO_IMSI((char *)attach_req_p->imsi, &imsi);
MME_APP_DEBUG("Handling imsi %"IMSI_FORMAT"\n", imsi);
ue_context = mme_ue_context_exists_imsi(&mme_app_desc.mme_ue_contexts, imsi);
if (ue_context == NULL) {
/* The MME doesn't know this IMSI.
* Insert the UE to the list of known equipements and
* Retrieve the authentication vector from HSS.
*/
MME_APP_DEBUG("UE context doesn't exist -> create one\n");
if ((ue_context = mme_create_new_ue_context()) == NULL) {
/* Error during ue context malloc */
/* TODO */
DevMessage("mme_create_new_ue_context");
return -1;
}
ue_context->imsi = imsi;
ue_context->eNB_ue_s1ap_id = attach_req_p->transparent.eNB_ue_s1ap_id;
ue_context->mme_ue_s1ap_id = attach_req_p->transparent.mme_ue_s1ap_id;
ue_context->ue_id = attach_req_p->transparent.mme_ue_s1ap_id;
// STAILQ_INIT(&ue_context->vector_list);
DevAssert(mme_insert_ue_context(&mme_app_desc.mme_ue_contexts, ue_context) == 0);
goto request_auth;
} else {
/* MME knows this IMSI, check if UE is authenticated and authentication
* vectors are known.
*/
MME_APP_DEBUG("UE context already exists, use it\n");
/* Update mme ue s1ap id */
ue_context->mme_ue_s1ap_id = attach_req_p->transparent.mme_ue_s1ap_id;
if ((ue_context->imsi_auth == IMSI_AUTHENTICATED) &&
(attach_req_p->initial != INITIAL_REQUEST)) {
/* We have to send an update location request to the HSS */
MME_APP_DEBUG("UE is authenticated\n");
} else {
MME_APP_DEBUG("UE is not authenticated\n");
/* UE is not authenticated or an initial request */
// if (STAILQ_EMPTY(&ue_context->vector_list))
if (ue_context->nb_of_vectors == 0)
request_auth: {
/* We have no vector for this UE, send an authentication request
* to the HSS.
*/
AssertFatal(0, "Hardcoded MCC/MNC");
plmn_t plmn = {
.MCCdigit2 = 0,
.MCCdigit1 = 8,
.MCCdigit3 = 2,
.MNCdigit1 = 0,
.MNCdigit2 = 4,
.MNCdigit3 = 3,
};
memcpy(&ue_context->e_utran_cgi, &attach_req_p->transparent.e_utran_cgi,
sizeof(cgi_t));
/* Acquire the current time */
time(&ue_context->cell_age);
/* Some random values for GUTI */
ue_context->guti.m_tmsi = 0x24568956;
ue_context->guti.gummei.MMEcode = 0x01;
ue_context->guti.gummei.MMEgid = 0x5691;
memcpy(&ue_context->guti.gummei.plmn, &plmn, sizeof(plmn_t));
MME_APP_DEBUG("and we have no auth. vector for it, request"
" authentication information\n");
// mme_app_dump_ue_contexts();
mme_app_request_authentication_info(imsi, 1, &plmn, NULL);
} else {
nas_auth_req_t *nas_auth_req_p;
MessageDef *message_p;
/* We have a vector... USE it */
MME_APP_DEBUG("but we have an auth. vector for it, request"
" authentication from NAS\n");
message_p = itti_alloc_new_message(TASK_MME_APP, NAS_AUTHENTICATION_PARAM_FAIL);
nas_auth_req_p = &message_p->ittiMsg.nas_auth_req;
MME_APP_IMSI_TO_STRING(imsi, nas_auth_req_p->imsi);
nas_auth_req_p->failure = NAS_FAILURE_OK;
return itti_send_msg_to_task(TASK_NAS_MME, INSTANCE_DEFAULT, message_p);
}
}
}
return 0;
}
#else
void
mme_app_handle_nas_auth_param_req(
const nas_auth_param_req_t * const nas_auth_param_req_pP)
......@@ -354,13 +242,14 @@ mme_app_handle_nas_auth_param_req(
visited_plmn_from_req.MCCdigit2 = nas_auth_param_req_pP->imsi[1];
visited_plmn_from_req.MCCdigit3 = nas_auth_param_req_pP->imsi[2];
mnc_length = find_mnc_length(nas_auth_param_req_pP->imsi[0],
nas_auth_param_req_pP->imsi[1],
nas_auth_param_req_pP->imsi[2],
nas_auth_param_req_pP->imsi[3],
nas_auth_param_req_pP->imsi[4],
nas_auth_param_req_pP->imsi[5]
);
mnc_length = find_mnc_length(
nas_auth_param_req_pP->imsi[0],
nas_auth_param_req_pP->imsi[1],
nas_auth_param_req_pP->imsi[2],
nas_auth_param_req_pP->imsi[3],
nas_auth_param_req_pP->imsi[4],
nas_auth_param_req_pP->imsi[5]
);
if (mnc_length == 2) {
visited_plmn_from_req.MNCdigit1 = nas_auth_param_req_pP->imsi[3];
......@@ -439,11 +328,10 @@ mme_app_handle_nas_auth_param_req(
memcpy(&ue_context->guti.gummei.plmn, visited_plmn, sizeof(plmn_t));
MME_APP_DEBUG("and we have no auth. vector for it, request"
" authentication information\n");
mme_app_request_authentication_info(imsi, 1, visited_plmn, NULL);
mme_app_request_authentication_info(nas_auth_param_req_pP->imsi, 1, visited_plmn, NULL);
} else {
memcpy(&ue_context->guti.gummei.plmn, visited_plmn, sizeof(plmn_t));
mme_app_request_authentication_info(imsi, 1, visited_plmn, nas_auth_param_req_pP->auts);
mme_app_request_authentication_info(nas_auth_param_req_pP->imsi, 1, visited_plmn, nas_auth_param_req_pP->auts);
}
}
#endif
......@@ -50,8 +50,8 @@
#include "mme_app_ue_context.h"
#include "mme_app_defs.h"
static inline int ue_context_compare_identifiers(struct ue_context_s *p1,
struct ue_context_s *p2);
int ue_context_compare_identifiers(struct ue_context_s *p1,
struct ue_context_s *p2);
RB_PROTOTYPE(ue_context_map, ue_context_s, rb_entry,
ue_contex