Starting to generate modify bearer request. Fixed bug in unpacking activate default bearer accept.

master
Pedro Alvarez 7 years ago
parent 8becf4ab23
commit 9f994dba04

@ -294,5 +294,45 @@ struct gtpc_create_session_response
//acpo //CO
};
/****************************************************************************
*
* GTP-C v2 Modify Bearer Request
* Ref: 3GPP TS 29.274 v10.14.0 Table 7.2.7-1, 7.2.7-2 and 7.2.7-3
*
***************************************************************************/
struct gtpc_modify_bearer_request
{
//ME Identity (MEI)//C
//User Location Information (ULI)//C
//Serving Network //CO
//RAT Type //C/CO
//Indication Flags
//Sender F-TEID for Control Plane
//APN-AMBR
//Delay Downlink Packet Notification Request
struct gtpc_bearer_context_modified_ie
{
uint8_t ebi;
gtpc_cause_ie cause;
bool s1_u_enb_f_teid_present;
struct gtpc_f_teid_ie s1_u_enb_f_teid;
bool s5_s8_u_sgw_f_teid_present;
struct gtpc_f_teid_ie s5_s8_u_sgw_f_teid;
bool s12_rnc_f_teid_present;
struct gtpc_f_teid_ie s12_rnc_f_teid;
bool s4_u_sgsn_f_teid_present;
struct gtpc_f_teid_ie s4_u_sgsn_f_teid;
} eps_bearer_context_to_modify;
//Bearer Contexts to be removed
//Recovery
//UE Time Zone
//MME-FQ-CSID
//SGW-FQ-CSID
//User CSG Information (UCI)
//MME/S4-SGSN LDN
//SGW LDN
};
}; //namespace
#endif //GTPC_V2_MSG_H

@ -31,7 +31,7 @@
#include "srslte/common/buffer_pool.h"
#include <boost/thread/mutex.hpp>
#include "srslte/asn1/gtpc.h"
#include "mme/s1ap_common.h"
namespace srsepc
{
@ -50,6 +50,7 @@ public:
uint32_t get_new_ctrl_teid();
void send_create_session_request(uint64_t imsi, uint32_t mme_s1ap_id);
void handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu);
void send_modify_bearer_request(erab_ctx_t *bearer_ctx);
private:

@ -81,7 +81,7 @@ public:
bool handle_nas_authentication_response(srslte::byte_buffer_t *nas_buffer, srslte::byte_buffer_t *reply_buffer, ue_ctx_t *ue_ctx);
bool handle_nas_security_mode_complete(srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_msg, ue_ctx_t *ue_ctx);
bool send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte::gtpc_create_session_response *cs_resp);
bool send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte::gtpc_create_session_response *cs_resp, struct srslte::gtpc_f_teid_ie sgw_ctrl_fteid);
bool handle_successful_outcome(LIBLTE_S1AP_SUCCESSFULOUTCOME_STRUCT *msg);
bool handle_initial_context_setup_response(LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPRESPONSE_STRUCT *in_ctxt_resp);

@ -23,6 +23,8 @@
#include "srslte/common/security.h"
#include "srslte/asn1/gtpc_ies.h"
#include "srslte/asn1/liblte_s1ap.h"
#include <netinet/sctp.h>
namespace srsepc{
@ -77,7 +79,7 @@ typedef struct{
enum erab_state state;
uint8_t erab_id;
srslte::gtpc_f_teid_ie enb_fteid;
//gtpc_f_teid_ie sgw_fteid; //?
srslte::gtpc_f_teid_ie sgw_ctrl_fteid;
} erab_ctx_t;
typedef struct{

@ -144,7 +144,7 @@ mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
return;
}
//Get MME_UE_S1AP_ID from the Ctrl TEID
//Get MME_UE_S1AP_ID from the control TEID
std::map<uint32_t,uint32_t>::iterator id_it = m_teid_to_mme_s1ap_id.find(cs_resp_pdu->header.teid);
if(id_it == m_teid_to_mme_s1ap_id.end())
{
@ -153,7 +153,37 @@ mme_gtpc::handle_create_session_response(srslte::gtpc_pdu *cs_resp_pdu)
return;
}
uint32_t mme_s1ap_id = id_it->second;
m_s1ap->send_initial_context_setup_request(mme_s1ap_id, cs_resp);
//Get S-GW Control F-TEID
srslte::gtpc_f_teid_ie sgw_ctrl_fteid;
sgw_ctrl_fteid.teid = cs_resp_pdu->header.teid;
sgw_ctrl_fteid.ipv4 = 0; //FIXME This is not used for now. In the future it will be obtained from the socket addr_info
m_s1ap->send_initial_context_setup_request(mme_s1ap_id, cs_resp, sgw_ctrl_fteid);
}
void
mme_gtpc::send_modify_bearer_request(erab_ctx_t *erab_ctx)
{
m_mme_gtpc_log->info("Sending GTP-C Modify bearer request\n");
srslte::gtpc_pdu pdu;
srslte::gtpc_f_teid_ie *enb_fteid = &erab_ctx->enb_fteid;
srslte::gtpc_f_teid_ie *sgw_ctrl_fteid = &erab_ctx->sgw_ctrl_fteid;
srslte::gtpc_header *header = &pdu.header;
header->teid_present = true;
header->teid = sgw_ctrl_fteid->teid;
header->type = srslte::GTPC_MSG_TYPE_MODIFY_BEARER_REQUEST;
srslte::gtpc_modify_bearer_request mb_req;
mb_req.eps_bearer_context_to_modify.ebi = erab_ctx->erab_id;
mb_req.eps_bearer_context_to_modify.s1_u_enb_f_teid.ipv4 = enb_fteid->ipv4;
mb_req.eps_bearer_context_to_modify.s1_u_enb_f_teid.teid = enb_fteid->teid;
m_mme_gtpc_log->info("GTP-C Modify bearer request -- S-GW Control TEID %d\n", sgw_ctrl_fteid->teid );
m_mme_gtpc_log->info("GTP-C Modify bearer request -- S1-U TEID 0x%x\n", enb_fteid->teid );
}
} //namespace srsepc

@ -570,56 +570,9 @@ s1ap::handle_nas_security_mode_complete(srslte::byte_buffer_t *nas_msg, srslte::
}
bool
s1ap::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_msg, ue_ctx_t *ue_ctx)
{
/*
typedef struct{
LIBLTE_BYTE_MSG_STRUCT esm_msg;
}LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT;
*/
/*
typedef struct{
LIBLTE_MME_PROTOCOL_CONFIG_OPTIONS_STRUCT protocol_cnfg_opts;
uint8 eps_bearer_id;
uint8 proc_transaction_id;
bool protocol_cnfg_opts_present;
}LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT;
*/
LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_comp;
uint8_t pd, msg_type;
srslte::byte_buffer_t *esm_msg = m_pool->allocate();
LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT act_bearer;
//Get NAS authentication response
LIBLTE_ERROR_ENUM err = liblte_mme_unpack_attach_complete_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &attach_comp);
if(err != LIBLTE_SUCCESS){
m_s1ap_log->error("Error unpacking NAS authentication response. Error: %s\n", liblte_error_text[err]);
return false;
}
memcpy(esm_msg->msg, attach_comp.esm_msg.buffer, attach_comp.esm_msg.N_bytes);
esm_msg->N_bytes = attach_comp.esm_msg.N_bytes;
/*liblte_mme_parse_msg_header((LIBLTE_BYTE_MSG_STRUCT *) esm_msg, &pd, &msg_type);
if(msg_type!= LIBLTE_MME_MSG_TYPE_ACTIVATE_DEFAULT_EPS_BEARER_ACCEPT){
m_s1ap_log->error("Error unpacking activate default eps bearer context accept\n");
return false;
}*/
err = liblte_mme_pack_activate_default_eps_bearer_context_accept_msg(&act_bearer, (LIBLTE_BYTE_MSG_STRUCT *) esm_msg);
if(err != LIBLTE_SUCCESS){
m_s1ap_log->error("Error unpacking Activate EPS Bearer Context Accept Msg. Error: %s\n", liblte_error_text[err]);
return false;
}
m_s1ap_log->console("Unpacked Attached Complete Message\n");
m_s1ap_log->console("Unpacked Activavate Default EPS Bearer message\n");
return true;
}
bool
s1ap::send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte::gtpc_create_session_response *cs_resp)
s1ap::send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte::gtpc_create_session_response *cs_resp, struct srslte::gtpc_f_teid_ie sgw_ctrl_fteid)
{
ue_ctx_t *ue_ctx;
@ -716,11 +669,13 @@ s1ap::send_initial_context_setup_request(uint32_t mme_ue_s1ap_id, struct srslte:
return false;
}
//Change E-RAB state to Context Setup Requested
//Change E-RAB state to Context Setup Requested and save S-GW control F-TEID
ue_ctx->erabs_ctx[erab_ctxt->e_RAB_ID.E_RAB_ID].state = ERAB_CTX_REQUESTED;
ue_ctx->erabs_ctx[erab_ctxt->e_RAB_ID.E_RAB_ID].sgw_ctrl_fteid.teid = sgw_ctrl_fteid.teid;
ue_ctx->erabs_ctx[erab_ctxt->e_RAB_ID.E_RAB_ID].sgw_ctrl_fteid.ipv4 = sgw_ctrl_fteid.ipv4;
m_s1ap_log->info("Sent Intial Context Setup Request\n");
m_s1ap_log->console("Sent Intial Context Setup Request\n");
m_s1ap_log->info("Sent Intial Context Setup Request. E-RAB id %d \n",erab_ctxt->e_RAB_ID.E_RAB_ID);
m_s1ap_log->console("Sent Intial Context Setup Request, E-RAB id %d\n",erab_ctxt->e_RAB_ID.E_RAB_ID);
m_pool->deallocate(reply_buffer);
m_pool->deallocate(nas_buffer);
@ -773,6 +728,58 @@ s1ap::handle_initial_context_setup_response(LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSE
return true;
}
bool
s1ap::handle_nas_attach_complete(srslte::byte_buffer_t *nas_msg, srslte::byte_buffer_t *reply_msg, ue_ctx_t *ue_ctx)
{
/*
typedef struct{
LIBLTE_BYTE_MSG_STRUCT esm_msg;
}LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT;
*/
/*
typedef struct{
LIBLTE_MME_PROTOCOL_CONFIG_OPTIONS_STRUCT protocol_cnfg_opts;
uint8 eps_bearer_id;
uint8 proc_transaction_id;
bool protocol_cnfg_opts_present;
}LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT;
*/
LIBLTE_MME_ATTACH_COMPLETE_MSG_STRUCT attach_comp;
uint8_t pd, msg_type;
srslte::byte_buffer_t *esm_msg = m_pool->allocate();
LIBLTE_MME_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_MSG_STRUCT act_bearer;
m_s1ap_log->info_hex(nas_msg->msg, nas_msg->N_bytes, "NAS Attach complte");
//Get NAS authentication response
LIBLTE_ERROR_ENUM err = liblte_mme_unpack_attach_complete_msg((LIBLTE_BYTE_MSG_STRUCT *) nas_msg, &attach_comp);
if(err != LIBLTE_SUCCESS){
m_s1ap_log->error("Error unpacking NAS authentication response. Error: %s\n", liblte_error_text[err]);
return false;
}
// memcpy(esm_msg->msg, attach_comp.esm_msg.buffer, attach_comp.esm_msg.N_bytes);
//esm_msg->N_bytes = attach_comp.esm_msg.N_bytes;
err = liblte_mme_unpack_activate_default_eps_bearer_context_accept_msg( (LIBLTE_BYTE_MSG_STRUCT *) &attach_comp.esm_msg, &act_bearer);
if(err != LIBLTE_SUCCESS){
m_s1ap_log->error("Error unpacking Activate EPS Bearer Context Accept Msg. Error: %s\n", liblte_error_text[err]);
return false;
}
m_s1ap_log->console("Unpacked Attached Complete Message\n");
m_s1ap_log->console("Unpacked Activavate Default EPS Bearer message. EPS Bearer id %d\n",act_bearer.eps_bearer_id);
//ue_ctx->erabs_ctx[act_bearer->eps_bearer_id].enb_fteid;
if(act_bearer.eps_bearer_id < 5 || act_bearer.eps_bearer_id > 16)
{
m_s1ap_log->error("EPS Bearer ID out of range\n");
return false;
}
m_mme_gtpc->send_modify_bearer_request(&ue_ctx->erabs_ctx[act_bearer.eps_bearer_id]);
return true;
}
bool
s1ap::handle_ue_context_release_request(LIBLTE_S1AP_MESSAGE_UECONTEXTRELEASEREQUEST_STRUCT *ue_rel, struct sctp_sndrcvinfo *enb_sri)

@ -490,6 +490,7 @@ s1ap_nas_transport::pack_attach_accept(ue_ctx_t *ue_ctx, LIBLTE_S1AP_E_RABTOBESE
memcpy(act_def_eps_bearer_context_req.pdn_addr.addr, &paa->ipv4, 4);
//Set eps bearer id
act_def_eps_bearer_context_req.eps_bearer_id = erab_ctxt->e_RAB_ID.E_RAB_ID;
printf("%d\n",act_def_eps_bearer_context_req.eps_bearer_id);
act_def_eps_bearer_context_req.transaction_id_present = false;
//set eps_qos
act_def_eps_bearer_context_req.eps_qos.qci = erab_ctxt->e_RABlevelQoSParameters.qCI.QCI;

Loading…
Cancel
Save