Changing pack accept

master
Pedro Alvarez 6 years ago
parent 3663d59920
commit c1eff4ce73

@ -188,11 +188,11 @@ public:
bool integrity_check( emm_ctx_t *emm_ctx, srslte::byte_buffer_t *pdu); bool integrity_check( emm_ctx_t *emm_ctx, srslte::byte_buffer_t *pdu);
bool short_integrity_check( emm_ctx_t *emm_ctx, srslte::byte_buffer_t *pdu); bool short_integrity_check( emm_ctx_t *emm_ctx, srslte::byte_buffer_t *pdu);
private: /* UE Context*/
emm_ctx_t m_emm_ctx; emm_ctx_t m_emm_ctx;
ecm_ctx_t m_ecm_ctx; ecm_ctx_t m_ecm_ctx;
esm_ctx_t m_esm_ctx[MAX_ERABS_PER_UE]; esm_ctx_t m_esm_ctx[MAX_ERABS_PER_UE];
sec_ctx_t sec_ctx; sec_ctx_t m_sec_ctx;
}; };
}//namespace }//namespace

@ -47,7 +47,7 @@ public:
void init(void); void init(void);
bool send_initial_context_setup_request(nas *nas_ctx); bool send_initial_context_setup_request(nas *nas_ctx, uint16_t erab_to_setup);
bool handle_initial_context_setup_response(LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPRESPONSE_STRUCT *in_ctxt_resp); bool handle_initial_context_setup_response(LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPRESPONSE_STRUCT *in_ctxt_resp);
bool handle_ue_context_release_request(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASEREQUEST_STRUCT *ue_rel, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag); bool handle_ue_context_release_request(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASEREQUEST_STRUCT *ue_rel, struct sctp_sndrcvinfo *enb_sri, srslte::byte_buffer_t *reply_buffer, bool *reply_flag);
bool send_ue_context_release_command(ecm_ctx_t *ecm_ctx, srslte::byte_buffer_t *reply_buffer); bool send_ue_context_release_command(ecm_ctx_t *ecm_ctx, srslte::byte_buffer_t *reply_buffer);

@ -100,7 +100,7 @@ nas::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id,
struct sctp_sndrcvinfo *enb_sri) struct sctp_sndrcvinfo *enb_sri)
{ {
uint8_t k_asme[32]; uint8_t k_asme[32];
uint8_t autn[16]; uint8_t autn[16];
uint8_t rand[16]; uint8_t rand[16];
uint8_t xres[8]; uint8_t xres[8];
@ -114,7 +114,7 @@ nas::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id,
imsi += attach_req.eps_mobile_id.imsi[i]*std::pow(10,14-i); imsi += attach_req.eps_mobile_id.imsi[i]*std::pow(10,14-i);
} }
//Check if UE is //Check if UE is already atached
ue_ctx_t *old_ctx = m_s1ap->find_ue_ctx_from_imsi(imsi); ue_ctx_t *old_ctx = m_s1ap->find_ue_ctx_from_imsi(imsi);
if(old_ctx!=NULL) if(old_ctx!=NULL)
{ {
@ -227,13 +227,13 @@ nas::handle_nas_imsi_attach_request(uint32_t enb_ue_s1ap_id,
} }
bool bool
s1ap_nas_transport::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id, nas::handle_nas_guti_attach_request( uint32_t enb_ue_s1ap_id,
const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req, const LIBLTE_MME_ATTACH_REQUEST_MSG_STRUCT &attach_req,
const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req, const LIBLTE_MME_PDN_CONNECTIVITY_REQUEST_MSG_STRUCT &pdn_con_req,
srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *nas_msg,
srslte::byte_buffer_t *reply_buffer, srslte::byte_buffer_t *reply_buffer,
bool* reply_flag, bool* reply_flag,
struct sctp_sndrcvinfo *enb_sri) struct sctp_sndrcvinfo *enb_sri)
{ {
//Parse the message security header //Parse the message security header
uint8 pd = 0; uint8 pd = 0;
@ -1301,14 +1301,14 @@ nas::pack_security_mode_command(srslte::byte_buffer_t *reply_msg, ue_emm_ctx_t *
dw_nas->HandoverRestrictionList_present=false; dw_nas->HandoverRestrictionList_present=false;
dw_nas->SubscriberProfileIDforRFP_present=false; dw_nas->SubscriberProfileIDforRFP_present=false;
//Pack NAS PDU //Pack NAS PDU
LIBLTE_MME_SECURITY_MODE_COMMAND_MSG_STRUCT sm_cmd; LIBLTE_MME_SECURITY_MODE_COMMAND_MSG_STRUCT sm_cmd;
sm_cmd.selected_nas_sec_algs.type_of_eea = LIBLTE_MME_TYPE_OF_CIPHERING_ALGORITHM_EEA0; sm_cmd.selected_nas_sec_algs.type_of_eea = LIBLTE_MME_TYPE_OF_CIPHERING_ALGORITHM_EEA0;
sm_cmd.selected_nas_sec_algs.type_of_eia = LIBLTE_MME_TYPE_OF_INTEGRITY_ALGORITHM_128_EIA1; sm_cmd.selected_nas_sec_algs.type_of_eia = LIBLTE_MME_TYPE_OF_INTEGRITY_ALGORITHM_128_EIA1;
sm_cmd.nas_ksi.tsc_flag=LIBLTE_MME_TYPE_OF_SECURITY_CONTEXT_FLAG_NATIVE; sm_cmd.nas_ksi.tsc_flag=LIBLTE_MME_TYPE_OF_SECURITY_CONTEXT_FLAG_NATIVE;
sm_cmd.nas_ksi.nas_ksi=ue_emm_ctx->security_ctxt.eksi; sm_cmd.nas_ksi.nas_ksi=ue_emm_ctx->security_ctxt.eksi;
//Replay UE security cap //Replay UE security cap
memcpy(sm_cmd.ue_security_cap.eea,ue_emm_ctx->security_ctxt.ue_network_cap.eea,8*sizeof(bool)); memcpy(sm_cmd.ue_security_cap.eea,ue_emm_ctx->security_ctxt.ue_network_cap.eea,8*sizeof(bool));
@ -1358,7 +1358,7 @@ nas::pack_security_mode_command(srslte::byte_buffer_t *reply_msg, ue_emm_ctx_t *
&nas_buffer->msg[5], &nas_buffer->msg[5],
nas_buffer->N_bytes - 5, nas_buffer->N_bytes - 5,
mac mac
); );
memcpy(&nas_buffer->msg[1],mac,4); memcpy(&nas_buffer->msg[1],mac,4);
//Copy NAS PDU to Downlink NAS Trasport message buffer //Copy NAS PDU to Downlink NAS Trasport message buffer
@ -1378,7 +1378,7 @@ nas::pack_security_mode_command(srslte::byte_buffer_t *reply_msg, ue_emm_ctx_t *
} }
bool bool
s1ap_nas_transport::pack_esm_information_request(srslte::byte_buffer_t *reply_msg, ue_emm_ctx_t *ue_emm_ctx, ue_ecm_ctx_t *ue_ecm_ctx) nas::pack_esm_information_request(srslte::byte_buffer_t *reply_msg, ue_emm_ctx_t *ue_emm_ctx, ue_ecm_ctx_t *ue_ecm_ctx)
{ {
srslte::byte_buffer_t *nas_buffer = m_pool->allocate(); srslte::byte_buffer_t *nas_buffer = m_pool->allocate();
@ -1409,8 +1409,7 @@ s1ap_nas_transport::pack_esm_information_request(srslte::byte_buffer_t *reply_ms
ue_emm_ctx->security_ctxt.dl_nas_count++; ue_emm_ctx->security_ctxt.dl_nas_count++;
LIBLTE_ERROR_ENUM err = srslte_mme_pack_esm_information_request_msg(&esm_info_req, sec_hdr_type,ue_emm_ctx->security_ctxt.dl_nas_count,(LIBLTE_BYTE_MSG_STRUCT *) nas_buffer); LIBLTE_ERROR_ENUM err = srslte_mme_pack_esm_information_request_msg(&esm_info_req, sec_hdr_type,ue_emm_ctx->security_ctxt.dl_nas_count,(LIBLTE_BYTE_MSG_STRUCT *) nas_buffer);
if(err != LIBLTE_SUCCESS) if (err != LIBLTE_SUCCESS) {
{
m_s1ap_log->error("Error packing ESM information request\n"); m_s1ap_log->error("Error packing ESM information request\n");
m_s1ap_log->console("Error packing ESM information request\n"); m_s1ap_log->console("Error packing ESM information request\n");
return false; return false;
@ -1427,7 +1426,7 @@ s1ap_nas_transport::pack_esm_information_request(srslte::byte_buffer_t *reply_ms
); );
memcpy(&nas_buffer->msg[1],mac,4); memcpy(&nas_buffer->msg[1],mac,4);
//Copy NAS PDU to Downlink NAS Trasport message buffer //Copy NAS PDU to Downlink NAS Trasport message buffer
memcpy(dw_nas->NAS_PDU.buffer, nas_buffer->msg, nas_buffer->N_bytes); memcpy(dw_nas->NAS_PDU.buffer, nas_buffer->msg, nas_buffer->N_bytes);
dw_nas->NAS_PDU.n_octets = nas_buffer->N_bytes; dw_nas->NAS_PDU.n_octets = nas_buffer->N_bytes;
@ -1446,12 +1445,11 @@ s1ap_nas_transport::pack_esm_information_request(srslte::byte_buffer_t *reply_ms
} }
bool bool
s1ap_nas_transport::pack_attach_accept(ue_emm_ctx_t *ue_emm_ctx, ue_ecm_ctx_t *ue_ecm_ctx, LIBLTE_S1AP_E_RABTOBESETUPITEMCTXTSUREQ_STRUCT *erab_ctxt, struct srslte::gtpc_pdn_address_allocation_ie *paa, srslte::byte_buffer_t *nas_buffer) { nas::pack_attach_accept(LIBLTE_S1AP_E_RABTOBESETUPITEMCTXTSUREQ_STRUCT *erab_ctxt, struct srslte::gtpc_pdn_address_allocation_ie *paa, srslte::byte_buffer_t *nas_buffer)
{
m_nas_log->info("Packing Attach Accept\n");
LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT attach_accept; LIBLTE_MME_ATTACH_ACCEPT_MSG_STRUCT attach_accept;
LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req; LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT act_def_eps_bearer_context_req;
//bzero(&act_def_eps_bearer_context_req,sizeof(LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_MSG_STRUCT));
m_s1ap_log->info("Packing Attach Accept\n");
//Get decimal MCC and MNC //Get decimal MCC and MNC
uint32_t mcc = 0; uint32_t mcc = 0;

@ -79,7 +79,7 @@ s1ap_ctx_mngmt_proc::init(void)
} }
bool bool
s1ap_ctx_mngmt_proc::send_initial_context_setup_request(nas *nas_ctx) s1ap_ctx_mngmt_proc::send_initial_context_setup_request(nas *nas_ctx, uint16_t erab_to_setup)
{ {
//Prepare reply PDU //Prepare reply PDU
LIBLTE_S1AP_S1AP_PDU_STRUCT pdu; LIBLTE_S1AP_S1AP_PDU_STRUCT pdu;
@ -93,6 +93,12 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(nas *nas_ctx)
LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPREQUEST_STRUCT *in_ctxt_req = &init->choice.InitialContextSetupRequest; LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPREQUEST_STRUCT *in_ctxt_req = &init->choice.InitialContextSetupRequest;
m_s1ap_log->info("Preparing to send Initial Context Setup request\n"); m_s1ap_log->info("Preparing to send Initial Context Setup request\n");
//Get UE Context/E-RAB Context to setup
emm_ctx_t *emm_ctx = &nas_ctx->m_emm_ctx;
ecm_ctx_t *ecm_ctx = &nas_ctx->m_ecm_ctx;
esm_ctx_t *esm_ctx = &nas_ctx->m_esm_ctx[erab_to_setup];
sec_ctx_t *sec_ctx = &nas_ctx->m_sec_ctx;
//Add MME and eNB S1AP Ids //Add MME and eNB S1AP Ids
in_ctxt_req->MME_UE_S1AP_ID.MME_UE_S1AP_ID = ecm_ctx->mme_ue_s1ap_id; in_ctxt_req->MME_UE_S1AP_ID.MME_UE_S1AP_ID = ecm_ctx->mme_ue_s1ap_id;
in_ctxt_req->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID = ecm_ctx->enb_ue_s1ap_id; in_ctxt_req->eNB_UE_S1AP_ID.ENB_UE_S1AP_ID = ecm_ctx->enb_ue_s1ap_id;
@ -148,7 +154,7 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(nas *nas_ctx)
//Attach procedure initiated from an attach request //Attach procedure initiated from an attach request
m_s1ap_log->console("Adding attach accept to Initial Context Setup Request\n"); m_s1ap_log->console("Adding attach accept to Initial Context Setup Request\n");
m_s1ap_log->info("Adding attach accept to Initial Context Setup Request\n"); m_s1ap_log->info("Adding attach accept to Initial Context Setup Request\n");
nas_ctx->pack_attach_accept(emm_ctx, ecm_ctx, erab_ctx_req, &erab_ctx->pdn_addr_alloc, nas_buffer); nas_ctx->pack_attach_accept(emm_ctx, ecm_ctx, erab_ctx_req, &esm_ctx->pdn_addr_alloc, nas_buffer);
} }
srslte::byte_buffer_t *reply_buffer = m_pool->allocate(); srslte::byte_buffer_t *reply_buffer = m_pool->allocate();
@ -163,7 +169,7 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(nas *nas_ctx)
} }
//Change E-RAB state to Context Setup Requested and save S-GW control F-TEID //Change E-RAB state to Context Setup Requested and save S-GW control F-TEID
ecm_ctx->erabs_ctx[erab_ctx_req->e_RAB_ID.E_RAB_ID].state = ERAB_CTX_REQUESTED; esm_ctx->state = ERAB_CTX_REQUESTED;
struct in_addr addr; struct in_addr addr;
addr.s_addr = htonl(sgw_s1u_ip); addr.s_addr = htonl(sgw_s1u_ip);

Loading…
Cancel
Save