mirror of https://github.com/PentHertz/srsLTE.git
Fixed bug in the packing of the dw nas message. UE receives the authentication request message now.
This commit is contained in:
parent
961e0fc68d
commit
5b5c65435d
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
void set_log(srslte::log *s1ap_logger);
|
||||
bool unpack_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *init_ue, LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT *attach_req, LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT *pdn_con_req);
|
||||
bool pack_authentication_request(uint8_t *autn,uint8_t *rand);
|
||||
bool pack_authentication_request(srslte::byte_buffer_t *reply_msg, uint32_t enb_ue_s1ap_id, uint32_t next_mme_ue_s1ap_id, uint8_t *autn,uint8_t *rand);
|
||||
|
||||
void log_unhandled_attach_request_ies(const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT *attach_req);
|
||||
void log_unhandled_pdn_con_request_ies(const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT *pdn_con_req);
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace srsepc{
|
|||
|
||||
s1ap::s1ap():
|
||||
m_s1mme(-1),
|
||||
m_next_mme_ue_s1ap_id(0)
|
||||
m_next_mme_ue_s1ap_id(1)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -242,10 +242,10 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *ini
|
|||
LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT pdn_con_req;
|
||||
|
||||
uint64_t imsi;
|
||||
|
||||
uint8_t amf[2]; // 3GPP 33.102 v10.0.0 Annex H
|
||||
uint8_t op[16];
|
||||
uint8_t k[16];
|
||||
uint8_t k_asme[32];
|
||||
uint8_t autn[16];
|
||||
uint8_t rand[6];
|
||||
uint8_t xres[16];
|
||||
|
||||
/*Get info from initial UE message*/
|
||||
uint32_t enb_ue_s1ap_id = init_ue->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID;
|
||||
|
@ -274,11 +274,7 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *ini
|
|||
uint8_t eps_bearer_id = pdn_con_req.eps_bearer_id; //TODO: Unused
|
||||
uint8_t proc_transaction_id = pdn_con_req.proc_transaction_id; //TODO: Transaction ID unused
|
||||
|
||||
uint8_t k_asme[32];
|
||||
uint8_t autn[16];
|
||||
uint8_t rand[6];
|
||||
uint8_t xres[16];
|
||||
|
||||
//Get Authentication Vectors from HSS
|
||||
if(!m_hss->gen_auth_info_answer_milenage(imsi, k_asme, autn, rand, xres))
|
||||
{
|
||||
m_s1ap_log->console("User not found. IMSI %015lu\n",imsi);
|
||||
|
@ -286,54 +282,10 @@ s1ap::handle_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSAGE_STRUCT *ini
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Pack NAS Authentication Request in Downlink NAS Transport msg
|
||||
srslte::byte_buffer_t *nas_buffer;
|
||||
srslte::byte_buffer_t *reply_msg = m_pool->allocate();
|
||||
|
||||
//Setup initiating message
|
||||
LIBLTE_S1AP_S1AP_PDU_STRUCT tx_pdu;
|
||||
tx_pdu.ext = false;
|
||||
tx_pdu.choice_type = LIBLTE_S1AP_S1AP_PDU_CHOICE_INITIATINGMESSAGE;
|
||||
|
||||
LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *init = &tx_pdu.choice.initiatingMessage;
|
||||
init->procedureCode = LIBLTE_S1AP_PROC_ID_DOWNLINKNASTRANSPORT;
|
||||
init->choice_type = LIBLTE_S1AP_INITIATINGMESSAGE_CHOICE_DOWNLINKNASTRANSPORT;
|
||||
|
||||
//Setup Dw NAS message
|
||||
LIBLTE_S1AP_MESSAGE_DOWNLINKNASTRANSPORT_STRUCT *dw_nas = &init->choice.DownlinkNASTransport;
|
||||
dw_nas->ext=false;
|
||||
dw_nas->MME_UE_S1AP_ID.MME_UE_S1AP_ID = m_next_mme_ue_s1ap_id++;
|
||||
dw_nas->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID = enb_ue_s1ap_id;
|
||||
dw_nas->HandoverRestrictionList_present=false;
|
||||
dw_nas->SubscriberProfileIDforRFP_present=false;
|
||||
|
||||
//
|
||||
LIBLTE_MME_AUTHENTICATION_REQUEST_MSG_STRUCT auth_req;
|
||||
memcpy(auth_req.autn , autn, 16);
|
||||
memcpy(auth_req.rand, rand, 16);
|
||||
auth_req.nas_ksi.tsc_flag=LIBLTE_MME_TYPE_OF_SECURITY_CONTEXT_FLAG_NATIVE;
|
||||
auth_req.nas_ksi.nas_ksi=0;
|
||||
|
||||
|
||||
// Pack NAS_PDU
|
||||
nas_buffer = m_pool->allocate();
|
||||
LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_request_msg(&auth_req, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer);
|
||||
if(err != LIBLTE_SUCCESS)
|
||||
{
|
||||
m_s1ap_log->console("Error packing Athentication Request");
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(dw_nas->NAS_PDU.buffer, nas_buffer->msg, nas_buffer->N_bytes);
|
||||
dw_nas->NAS_PDU.n_octets = nas_buffer->N_bytes;
|
||||
|
||||
//Pack Downlink NAS Transport Message
|
||||
err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg);
|
||||
if(err != LIBLTE_SUCCESS)
|
||||
{
|
||||
m_s1ap_log->console("Error packing Athentication Request");
|
||||
return false;
|
||||
}
|
||||
m_s1ap_nas_transport.pack_authentication_request(reply_msg, enb_ue_s1ap_id, m_next_mme_ue_s1ap_id++, autn, rand);
|
||||
|
||||
//Send Reply to eNB
|
||||
ssize_t n_sent = sctp_send(m_s1mme,reply_msg->msg, reply_msg->N_bytes, enb_sri, 0);
|
||||
|
|
|
@ -99,14 +99,57 @@ s1ap_nas_transport::unpack_initial_ue_message(LIBLTE_S1AP_MESSAGE_INITIALUEMESSA
|
|||
}
|
||||
|
||||
bool
|
||||
s1ap_nas_transport::pack_authentication_request(uint8_t *autn,uint8_t *rand)
|
||||
s1ap_nas_transport::pack_authentication_request(srslte::byte_buffer_t *reply_msg, uint32_t enb_ue_s1ap_id, uint32_t next_mme_ue_s1ap_id, uint8_t *autn, uint8_t *rand)
|
||||
{
|
||||
srslte::byte_buffer_t *nas_buffer = m_pool->allocate();
|
||||
|
||||
LIBLTE_MME_AUTHENTICATION_REQUEST_MSG_STRUCT pdu;
|
||||
memcpy(pdu.autn , autn, 16);
|
||||
memcpy(pdu.rand, rand, 16);
|
||||
pdu.nas_ksi.tsc_flag=LIBLTE_MME_TYPE_OF_SECURITY_CONTEXT_FLAG_NATIVE;
|
||||
pdu.nas_ksi.nas_ksi=0;
|
||||
//Setup initiating message
|
||||
LIBLTE_S1AP_S1AP_PDU_STRUCT tx_pdu;
|
||||
bzero(&tx_pdu, sizeof(LIBLTE_S1AP_S1AP_PDU_STRUCT));
|
||||
|
||||
tx_pdu.ext = false;
|
||||
tx_pdu.choice_type = LIBLTE_S1AP_S1AP_PDU_CHOICE_INITIATINGMESSAGE;
|
||||
|
||||
LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *init = &tx_pdu.choice.initiatingMessage;
|
||||
init->procedureCode = LIBLTE_S1AP_PROC_ID_DOWNLINKNASTRANSPORT;
|
||||
init->choice_type = LIBLTE_S1AP_INITIATINGMESSAGE_CHOICE_DOWNLINKNASTRANSPORT;
|
||||
|
||||
//Setup Dw NAS structure
|
||||
LIBLTE_S1AP_MESSAGE_DOWNLINKNASTRANSPORT_STRUCT *dw_nas = &init->choice.DownlinkNASTransport;
|
||||
dw_nas->ext=false;
|
||||
dw_nas->MME_UE_S1AP_ID.MME_UE_S1AP_ID = next_mme_ue_s1ap_id;
|
||||
dw_nas->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID = enb_ue_s1ap_id;
|
||||
dw_nas->HandoverRestrictionList_present=false;
|
||||
dw_nas->SubscriberProfileIDforRFP_present=false;
|
||||
m_s1ap_log->console("Dw NAS id %d\n", enb_ue_s1ap_id);
|
||||
|
||||
//Pack NAS PDU
|
||||
LIBLTE_MME_AUTHENTICATION_REQUEST_MSG_STRUCT auth_req;
|
||||
memcpy(auth_req.autn , autn, 16);
|
||||
memcpy(auth_req.rand, rand, 16);
|
||||
auth_req.nas_ksi.tsc_flag=LIBLTE_MME_TYPE_OF_SECURITY_CONTEXT_FLAG_NATIVE;
|
||||
auth_req.nas_ksi.nas_ksi=0;
|
||||
|
||||
LIBLTE_ERROR_ENUM err = liblte_mme_pack_authentication_request_msg(&auth_req, (LIBLTE_BYTE_MSG_STRUCT *) nas_buffer);
|
||||
if(err != LIBLTE_SUCCESS)
|
||||
{
|
||||
m_s1ap_log->console("Error packing Athentication Request\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Copy NAS PDU to Downlink NAS Trasport message buffer
|
||||
memcpy(dw_nas->NAS_PDU.buffer, nas_buffer->msg, nas_buffer->N_bytes);
|
||||
dw_nas->NAS_PDU.n_octets = nas_buffer->N_bytes;
|
||||
|
||||
//Pack Downlink NAS Transport Message
|
||||
err = liblte_s1ap_pack_s1ap_pdu(&tx_pdu, (LIBLTE_BYTE_MSG_STRUCT *) reply_msg);
|
||||
if(err != LIBLTE_SUCCESS)
|
||||
{
|
||||
m_s1ap_log->console("Error packing Athentication Request\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pool->deallocate(nas_buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue