Commit 0aec555a authored by Cedric Roux's avatar Cedric Roux

- Some minor improvements when NAS is enabled

- Some formatting of header files

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4561 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 569d1c5f
//WARNING: Do not include this header directly. Use intertask_interface.h instead.
//MESSAGE_DEF(S1AP_SCTP_NEW_MESSAGE_IND, MESSAGE_PRIORITY_MED, S1apSctpNewMessageInd, s1apSctpNewMessageInd)
......@@ -2,7 +2,7 @@
MESSAGE_DEF(NAS_PAGING_IND, MESSAGE_PRIORITY_MED, nas_paging_ind_t, nas_paging_ind)
MESSAGE_DEF(NAS_CONNECTION_ESTABLISHMENT_IND, MESSAGE_PRIORITY_MED, nas_conn_est_ind_t, nas_conn_est_ind)
MESSAGE_DEF(NAS_CONNECTION_ESTABLISHMENT_RSP, MESSAGE_PRIORITY_MED, nas_conn_est_rsp_t, nas_conn_est_rsp)
MESSAGE_DEF(NAS_CONNECTION_ESTABLISHMENT_CNF, MESSAGE_PRIORITY_MED, nas_conn_est_cnf_t, nas_conn_est_cnf)
MESSAGE_DEF(NAS_CONNECTION_RELEASE_IND, MESSAGE_PRIORITY_MED, nas_conn_rel_ind_t, nas_conn_rel_ind)
MESSAGE_DEF(NAS_UPLINK_DATA_IND, MESSAGE_PRIORITY_MED, nas_ul_data_ind_t, nas_ul_data_ind)
MESSAGE_DEF(NAS_DOWNLINK_DATA_REQ, MESSAGE_PRIORITY_MED, nas_dl_data_req_t, nas_dl_data_req)
......@@ -11,7 +11,13 @@ MESSAGE_DEF(NAS_NON_DELIVERY_IND, MESSAGE_PRIORITY_MED, nas_non_del_
MESSAGE_DEF(NAS_RAB_ESTABLISHMENT_REQ, MESSAGE_PRIORITY_MED, nas_rab_est_req_t, nas_rab_est_req)
MESSAGE_DEF(NAS_RAB_ESTABLISHMENT_RESP, MESSAGE_PRIORITY_MED, nas_rab_est_rsp_t, nas_rab_est_rsp)
MESSAGE_DEF(NAS_RAB_RELEASE_REQ, MESSAGE_PRIORITY_MED, nas_rab_rel_req_t, nas_rab_rel_req)
MESSAGE_DEF(NAS_ATTACH_REQ, MESSAGE_PRIORITY_MED, nas_attach_req_t, nas_attach_req)
MESSAGE_DEF(NAS_ATTACH_ACCEPT, MESSAGE_PRIORITY_MED, nas_attach_accept_t, nas_attach_accept)
MESSAGE_DEF(NAS_AUTHENTICATION_REQ, MESSAGE_PRIORITY_MED, nas_auth_req_t, nas_auth_req)
MESSAGE_DEF(NAS_AUTHENTICATION_RESP, MESSAGE_PRIORITY_MED, nas_auth_resp_t, nas_auth_resp)
/* MME app -> NAS layer messages */
MESSAGE_DEF(NAS_BEARER_PARAM, MESSAGE_PRIORITY_MED, nas_bearer_param_t, nas_bearer_param)
#if defined(DISABLE_USE_NAS)
MESSAGE_DEF(NAS_ATTACH_REQ, MESSAGE_PRIORITY_MED, nas_attach_req_t, nas_attach_req)
MESSAGE_DEF(NAS_ATTACH_ACCEPT, MESSAGE_PRIORITY_MED, nas_attach_accept_t, nas_attach_accept)
#endif
\ No newline at end of file
......@@ -3,9 +3,11 @@
#ifndef NAS_MESSAGES_TYPES_H_
#define NAS_MESSAGES_TYPES_H_
#define NAS_UL_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_ul_data_ind
#define NAS_DL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_req
#define NAS_DL_DATA_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_cnf
#define NAS_UL_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.nas_ul_data_ind
#define NAS_DL_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_req
#define NAS_DL_DATA_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_dl_data_cnf
#define NAS_CONN_EST_CNF(mSGpTR) (mSGpTR)->ittiMsg.nas_conn_est_cnf
#define NAS_BEARER_PARAM(mSGpTR) (mSGpTR)->ittiMsg.nas_bearer_param
typedef struct {
......@@ -20,9 +22,38 @@ typedef struct {
s1ap_initial_ue_message_t transparent;
} nas_conn_est_ind_t;
typedef struct {
} nas_conn_est_rsp_t;
typedef struct nas_conn_est_cnf_s {
uint32_t ue_id;
nas_establish_cnf_t nas_establish_cnf;
/* Transparent message from MME_APP to S1AP */
s1ap_initial_ctxt_setup_req_t transparent;
} nas_conn_est_cnf_t;
typedef struct nas_bearer_param_s {
unsigned eNB_ue_s1ap_id:24;
uint32_t mme_ue_s1ap_id;
/* Key eNB */
uint8_t keNB[32];
ambr_t ambr;
ambr_t apn_ambr;
/* EPS bearer ID */
unsigned ebi:4;
/* QoS */
qci_t qci;
priority_level_t prio_level;
pre_emp_vulnerability_t pre_emp_vulnerability;
pre_emp_capability_t pre_emp_capability;
/* S-GW TEID for user-plane */
uint32_t teid;
/* S-GW IP address for User-Plane */
ip_address_t s_gw_address;
} nas_bearer_param_t;
typedef struct {
......@@ -72,9 +103,4 @@ typedef struct {
char imsi[16];
} nas_auth_resp_t;
typedef struct {
s1ap_initial_ctxt_setup_req_t transparent;
} nas_attach_accept_t;
#endif /* NAS_MESSAGES_TYPES_H_ */
......@@ -3,7 +3,7 @@
#define SCTP_DATA_IND(mSGpTR) (mSGpTR)->ittiMsg.sctp_data_ind
#define SCTP_DATA_REQ(mSGpTR) (mSGpTR)->ittiMsg.sctp_data_req
#define SCTP_INIT(mSGpTR) (mSGpTR)->ittiMsg.sctpInit
#define SCTP_INIT_MSG(mSGpTR) (mSGpTR)->ittiMsg.sctpInit
#define SCTP_CLOSE_ASSOCIATION(mSGpTR) (mSGpTR)->ittiMsg.sctp_close_association
typedef struct sctp_data_req_s {
......
......@@ -175,6 +175,7 @@ int mme_app_handle_authentication_info_answer(s6a_auth_info_ans_t *s6a_auth_info
return itti_send_msg_to_task(TASK_NAS, INSTANCE_DEFAULT, message_p);
}
#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.
......@@ -283,3 +284,4 @@ request_auth:
}
return 0;
}
#endif
......@@ -316,32 +316,29 @@ int mme_app_handle_create_sess_resp(SgwCreateSessionResponse *create_sess_resp_p
{
uint8_t *keNB;
MessageDef *message_p;
nas_attach_accept_t *attach_accept_p;
message_p = itti_alloc_new_message(TASK_MME_APP, NAS_ATTACH_ACCEPT);
attach_accept_p = &message_p->ittiMsg.nas_attach_accept;
message_p = itti_alloc_new_message(TASK_MME_APP, NAS_BEARER_PARAM);
derive_keNB(ue_context_p->vector_in_use->kasme, 156, &keNB);
memcpy(attach_accept_p->transparent.keNB, keNB, 32);
memcpy(NAS_BEARER_PARAM(message_p).keNB, keNB, 32);
free(keNB);
attach_accept_p->transparent.eNB_ue_s1ap_id = ue_context_p->eNB_ue_s1ap_id;
attach_accept_p->transparent.mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
NAS_BEARER_PARAM(message_p).eNB_ue_s1ap_id = ue_context_p->eNB_ue_s1ap_id;
NAS_BEARER_PARAM(message_p).mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
attach_accept_p->transparent.ebi = bearer_id;
NAS_BEARER_PARAM(message_p).ebi = bearer_id;
attach_accept_p->transparent.qci = current_bearer_p->qci;
attach_accept_p->transparent.prio_level = current_bearer_p->prio_level;
attach_accept_p->transparent.pre_emp_vulnerability = current_bearer_p->pre_emp_vulnerability;
attach_accept_p->transparent.pre_emp_capability = current_bearer_p->pre_emp_capability;
NAS_BEARER_PARAM(message_p).qci = current_bearer_p->qci;
NAS_BEARER_PARAM(message_p).prio_level = current_bearer_p->prio_level;
NAS_BEARER_PARAM(message_p).pre_emp_vulnerability = current_bearer_p->pre_emp_vulnerability;
NAS_BEARER_PARAM(message_p).pre_emp_capability = current_bearer_p->pre_emp_capability;
attach_accept_p->transparent.teid = current_bearer_p->s_gw_teid;
memcpy(&attach_accept_p->transparent.s_gw_address,
NAS_BEARER_PARAM(message_p).teid = current_bearer_p->s_gw_teid;
memcpy(&NAS_BEARER_PARAM(message_p).s_gw_address,
&current_bearer_p->s_gw_address, sizeof(ip_address_t));
memcpy(&attach_accept_p->transparent.ambr, &ue_context_p->subscribed_ambr,
memcpy(&NAS_BEARER_PARAM(message_p).ambr, &ue_context_p->subscribed_ambr,
sizeof(ambr_t));
return itti_send_msg_to_task(TASK_NAS, INSTANCE_DEFAULT, message_p);
......
......@@ -57,7 +57,9 @@ extern mme_app_desc_t mme_app_desc;
int mme_app_create_bearer(s6a_update_location_ans_t *ula_p);
#if defined(DISABLE_USE_NAS)
int mme_app_handle_attach_req(nas_attach_req_t *attach_req_p);
#endif
int mme_app_handle_create_sess_resp(SgwCreateSessionResponse *create_sess_resp_p);
......
......@@ -68,19 +68,26 @@ void *mme_app_thread(void *args)
*/
mme_app_handle_authentication_info_answer(&received_message_p->ittiMsg.s6a_auth_info_ans);
} break;
case S6A_UPDATE_LOCATION_ANS: {
/* We received the update location answer message from HSS -> Handle it */
mme_app_create_bearer(&received_message_p->ittiMsg.s6a_update_location_ans);
} break;
case SGW_CREATE_SESSION_RESPONSE: {
mme_app_handle_create_sess_resp(&received_message_p->ittiMsg.sgwCreateSessionResponse);
} break;
case NAS_AUTHENTICATION_RESP: {
mme_app_handle_nas_auth_resp(&received_message_p->ittiMsg.nas_auth_resp);
} break;
#if defined(DISABLE_USE_NAS)
case NAS_ATTACH_REQ: {
mme_app_handle_attach_req(&received_message_p->ittiMsg.nas_attach_req);
} break;
#endif
case TIMER_HAS_EXPIRED: {
/* Check if it is the statistic timer */
if (received_message_p->ittiMsg.timer_has_expired.timer_id ==
......
/*****************************************************************************
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Eurecom OpenAirInterface 3
Copyright(c) 2012 Eurecom
Source nas_message.h
Source nas_message.h
Version 0.1
Version 0.1
Date 2012/26/09
Date 2012/26/09
Product NAS stack
Product NAS stack
Subsystem Application Programming Interface
Subsystem Application Programming Interface
Author Frederic Maurel
Author Frederic Maurel
Description Defines the layer 3 messages supported by the NAS sublayer
protocol and functions used to encode and decode
Description Defines the layer 3 messages supported by the NAS sublayer
protocol and functions used to encode and decode
*****************************************************************************/
#ifndef __NAS_MESSAGE_H__
......@@ -29,7 +29,7 @@ Description Defines the layer 3 messages supported by the NAS sublayer
/********************* G L O B A L C O N S T A N T S *******************/
/****************************************************************************/
#define NAS_MESSAGE_SECURITY_HEADER_SIZE 6
#define NAS_MESSAGE_SECURITY_HEADER_SIZE 6
/****************************************************************************/
/************************ G L O B A L T Y P E S ************************/
......@@ -51,8 +51,8 @@ typedef struct {
/* Structure of plain NAS message */
typedef union {
EMM_msg emm; /* EPS Mobility Management messages */
ESM_msg esm; /* EPS Session Management messages */
EMM_msg emm; /* EPS Mobility Management messages */
ESM_msg esm; /* EPS Session Management messages */
} nas_message_plain_t;
/* Structure of security protected NAS message */
......@@ -78,12 +78,14 @@ typedef union {
/****************** E X P O R T E D F U N C T I O N S ******************/
/****************************************************************************/
int nas_message_encrypt(const char* inbuf, char* outbuf, const nas_message_security_header_t* header, int length);
int nas_message_encrypt(const char *inbuf, char *outbuf,
const nas_message_security_header_t *header, int length);
int nas_message_decrypt(const char* inbuf, char* outbuf, nas_message_security_header_t* header, int length);
int nas_message_decrypt(const char *inbuf, char *outbuf,
nas_message_security_header_t *header, int length);
int nas_message_decode(const char* buffer, nas_message_t* msg, int length);
int nas_message_decode(const char *buffer, nas_message_t *msg, int length);
int nas_message_encode(char* buffer, const nas_message_t* msg, int length);
int nas_message_encode(char *buffer, const nas_message_t *msg, int length);
#endif /* __NAS_MESSAGE_H__*/
......@@ -1080,17 +1080,22 @@ static int _emm_as_send(const emm_as_t *msg)
#if defined(EPC_BUILD) && defined(NAS_MME)
switch (as_msg.msgID) {
case AS_DL_INFO_TRANSFER_REQ: {
int ret;
nas_itti_dl_data_req(as_msg.msg.dl_info_transfer_req.UEid,
as_msg.msg.dl_info_transfer_req.nasMsg.data,
as_msg.msg.dl_info_transfer_req.nasMsg.length);
} break;
case AS_NAS_ESTABLISH_RSP: {
/* The attach procedure succeeded wihtin MME.
* This message should trigger an S1AP initial context setup
* request.
* NOTE: we support only one bearer per message...
*/
// nas_itti_establish_cnf(as_msg.msg.nas_establish_cnf.errCode,
// as_msg.msg.nas_establish_cnf.nasMsg.data,
// as_msg.msg.nas_establish_cnf.nasMsg.length);
} break;
ret = nas_itti_dl_data_req(as_msg.msg.dl_info_transfer_req.UEid,
as_msg.msg.dl_info_transfer_req.nasMsg.data,
as_msg.msg.dl_info_transfer_req.nasMsg.length);
if (ret != -1) {
LOG_FUNC_RETURN (RETURNok);
}
}
break;
default:
break;
}
......@@ -1610,10 +1615,11 @@ static int _emm_as_security_rej(const emm_as_security_t *msg,
static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
nas_establish_rsp_t *as_msg)
{
LOG_FUNC_IN;
EMM_msg *emm_msg;
int size = 0;
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMMAS-SAP - Send AS connection establish response");
nas_message_t nas_msg;
......@@ -1628,7 +1634,7 @@ static int _emm_as_establish_cnf(const emm_as_establish_t *msg,
as_msg->s_tmsi.m_tmsi = msg->UEid.guti->m_tmsi;
/* Setup the NAS security header */
EMM_msg *emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
emm_msg = _emm_as_set_header(&nas_msg, &msg->sctx);
/* Setup the initial NAS information message */
if (emm_msg != NULL) switch (msg->NASinfo) {
......
......@@ -354,12 +354,13 @@ emm_fsm_state_t emm_fsm_get_status(unsigned int ueid, void *ctx)
***************************************************************************/
int emm_fsm_process(const emm_reg_t *evt)
{
int rc;
emm_fsm_state_t status;
emm_reg_primitive_t primitive;
LOG_FUNC_IN;
int rc;
emm_reg_primitive_t primitive = evt->primitive;
primitive = evt->primitive;
#ifdef NAS_UE
status = _emm_fsm_status[0];
......
......@@ -44,3 +44,17 @@ int nas_itti_dl_data_req(const uint32_t ue_id, void * const data,
return itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p);
}
void nas_itti_establish_cnf(const nas_error_code_t error_code, void * const data,
const uint32_t length)
{
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS, NAS_CONNECTION_ESTABLISHMENT_CNF);
NAS_CONN_EST_CNF(message_p).nas_establish_cnf.nasMsg.data = data;
NAS_CONN_EST_CNF(message_p).nas_establish_cnf.nasMsg.length = length;
NAS_CONN_EST_CNF(message_p).nas_establish_cnf.errCode = error_code;
itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p);
}
......@@ -34,4 +34,7 @@
int nas_itti_dl_data_req(const uint32_t ue_id, void * const data,
const uint32_t length);
void nas_itti_establish_cnf(const nas_error_code_t error_code, void * const data,
const uint32_t length);
#endif /* NAS_ITTI_MESSAGING_H_ */
......@@ -62,6 +62,7 @@ next_message:
#endif
} break;
#if defined(DISABLE_USE_NAS)
case NAS_ATTACH_ACCEPT: {
itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, received_message_p);
goto next_message;
......@@ -81,6 +82,7 @@ next_message:
itti_send_msg_to_task(TASK_MME_APP, INSTANCE_DEFAULT, message_p);
} break;
#endif
case NAS_UPLINK_DATA_IND: {
nas_proc_ul_transfer_ind(NAS_UL_DATA_IND(received_message_p).UEid,
......
......@@ -140,12 +140,29 @@ void *s1ap_mme_thread(void *args)
/* New message received from NAS task.
* This corresponds to a S1AP downlink nas transport message.
*/
s1ap_generate_downlink_nas_transport(&NAS_DL_DATA_REQ(received_message_p));
s1ap_generate_downlink_nas_transport(NAS_DL_DATA_REQ(received_message_p).UEid,
NAS_DL_DATA_REQ(received_message_p).nasMsg.data,
NAS_DL_DATA_REQ(received_message_p).nasMsg.length);
} break;
#if defined(DISABLE_USE_NAS)
case NAS_ATTACH_ACCEPT: {
s1ap_handle_attach_accepted(&received_message_p->ittiMsg.nas_attach_accept);
} break;
#else
case NAS_CONNECTION_ESTABLISHMENT_CNF: {
if (AS_TERMINATED_NAS == NAS_CONN_EST_CNF(received_message_p).nas_establish_cnf.errCode) {
/* Attach rejected by NAS -> send result via
* DL info transfer message
*/
s1ap_generate_downlink_nas_transport(NAS_CONN_EST_CNF(received_message_p).ue_id,
NAS_CONN_EST_CNF(received_message_p).nas_establish_cnf.nasMsg.data,
NAS_CONN_EST_CNF(received_message_p).nas_establish_cnf.nasMsg.length);
} else {
s1ap_handle_conn_est_cnf(&NAS_CONN_EST_CNF(received_message_p));
}
} break;
#endif
case TIMER_HAS_EXPIRED: {
s1ap_handle_timer_expiry(&received_message_p->ittiMsg.timer_has_expired);
......
......@@ -191,7 +191,7 @@ int s1ap_mme_handle_uplink_nas_transport(uint32_t assoc_id, uint32_t stream,
//TODO: forward NAS PDU to NAS
#if defined(DISABLE_USE_NAS)
DevMessage("TODO: forward NAS PDU to NAS\n");
DevMessage("Can't go further (TODO)\n");
#else
s1ap_mme_itti_nas_uplink_ind(uplinkNASTransport_p->mme_ue_s1ap_id, uplinkNASTransport_p->nas_pdu.buf,
uplinkNASTransport_p->nas_pdu.size);
......@@ -212,15 +212,14 @@ int s1ap_mme_handle_nas_non_delivery(uint32_t assoc_id, uint32_t stream,
return 0;
}
int s1ap_generate_downlink_nas_transport(nas_dl_data_req_t *nas_dl_data_req_p)
int s1ap_generate_downlink_nas_transport(const uint32_t ue_id, void * const data,
const uint32_t size)
{
ue_description_t *ue_ref;
uint8_t *buffer_p;
uint32_t length;
DevAssert(nas_dl_data_req_p != NULL);
if ((ue_ref = s1ap_is_ue_mme_id_in_list(nas_dl_data_req_p->UEid)) == NULL) {
if ((ue_ref = s1ap_is_ue_mme_id_in_list(ue_id)) == NULL) {
/* If the UE-associated logical S1-connection is not established,
* the MME shall allocate a unique MME UE S1AP ID to be used for the UE.
*/
......@@ -245,9 +244,10 @@ int s1ap_generate_downlink_nas_transport(nas_dl_data_req_t *nas_dl_data_req_p)
/* Setting UE informations with the ones fount in ue_ref */
downlinkNasTransport->mme_ue_s1ap_id = ue_ref->mme_ue_s1ap_id;
downlinkNasTransport->eNB_UE_S1AP_ID = ue_ref->eNB_ue_s1ap_id;
OCTET_STRING_fromBuf(&downlinkNasTransport->nas_pdu,
(char*)nas_dl_data_req_p->nasMsg.data,
nas_dl_data_req_p->nasMsg.length);
/* Fill in the NAS pdu */
OCTET_STRING_fromBuf(&downlinkNasTransport->nas_pdu, (char*)data, size);
if (s1ap_mme_encode_pdu(&message, &buffer_p, &length) < 0) {
// TODO: handle something
return -1;
......@@ -261,6 +261,7 @@ int s1ap_generate_downlink_nas_transport(nas_dl_data_req_t *nas_dl_data_req_p)
return 0;
}
#if defined(DISABLE_USE_NAS)
int s1ap_handle_attach_accepted(nas_attach_accept_t *attach_accept_p)
{
/* We received create session response from S-GW on S11 interface abstraction.
......@@ -387,3 +388,131 @@ int s1ap_handle_attach_accepted(nas_attach_accept_t *attach_accept_p)
return s1ap_mme_itti_send_sctp_request(buffer_p, length, ue_ref->eNB->sctp_assoc_id,
ue_ref->sctp_stream_send);
}
#else
void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf_p)
{
/* We received create session response from S-GW on S11 interface abstraction.
* At least one bearer has been established. We can now send s1ap initial context setup request
* message to eNB.
*/
uint8_t supportedAlgorithms[] = { 0x00, 0x02 };
uint8_t offset = 0;
uint8_t *buffer_p;
uint32_t length;
ue_description_t *ue_ref = NULL;
s1ap_message message;
s1ap_initial_ctxt_setup_req_t *initial_p;
S1ap_InitialContextSetupRequestIEs_t *initialContextSetupRequest_p;
S1ap_E_RABToBeSetupItemCtxtSUReq_t e_RABToBeSetup;
DevAssert(nas_conn_est_cnf_p != NULL);
initial_p = &nas_conn_est_cnf_p->transparent;
if ((ue_ref = s1ap_is_ue_mme_id_in_list(initial_p->mme_ue_s1ap_id)) == NULL) {
S1AP_DEBUG("This mme ue s1ap id (%08x) is not attached to any UE context\n",
initial_p->mme_ue_s1ap_id);
DevParam(initial_p->mme_ue_s1ap_id, 0, 0);
}
/* Start the outcome response timer.
* When time is reached, MME consider that procedure outcome has failed.
*/
// timer_setup(mme_config.s1ap_config.outcome_drop_timer_sec, 0, TASK_S1AP, INSTANCE_DEFAULT,
// TIMER_ONE_SHOT,
// NULL,
// &ue_ref->outcome_response_timer_id);
/* Insert the timer in the MAP of mme_ue_s1ap_id <-> timer_id */
// s1ap_timer_insert(ue_ref->mme_ue_s1ap_id, ue_ref->outcome_response_timer_id);
memset(&message, 0, sizeof(s1ap_message));
memset(&e_RABToBeSetup, 0, sizeof(S1ap_E_RABToBeSetupItemCtxtSUReq_t));
message.procedureCode = S1ap_ProcedureCode_id_InitialContextSetup;
message.direction = S1AP_PDU_PR_initiatingMessage;
initialContextSetupRequest_p = &message.msg.s1ap_InitialContextSetupRequestIEs;
initialContextSetupRequest_p->mme_ue_s1ap_id = (unsigned long)ue_ref->mme_ue_s1ap_id;
initialContextSetupRequest_p->eNB_UE_S1AP_ID = (unsigned long)ue_ref->eNB_ue_s1ap_id;
/* uEaggregateMaximumBitrateDL and uEaggregateMaximumBitrateUL expressed in term of bits/sec */
initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL = initial_p->ambr.br_dl;
initialContextSetupRequest_p->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateUL = initial_p->ambr.br_ul;
e_RABToBeSetup.e_RAB_ID = initial_p->ebi;
e_RABToBeSetup.e_RABlevelQoSParameters.qCI = initial_p->qci;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.priorityLevel
= initial_p->prio_level; //No priority
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionCapability
= initial_p->pre_emp_capability;
e_RABToBeSetup.e_RABlevelQoSParameters.allocationRetentionPriority.pre_emptionVulnerability
= initial_p->pre_emp_vulnerability;
/* Set the GTP-TEID. This is the S1-U S-GW TEID */
INT32_TO_OCTET_STRING(initial_p->teid, &e_RABToBeSetup.gTP_TEID);
/* S-GW IP address(es) for user-plane */
if ((initial_p->s_gw_address.pdn_type == IPv4) ||
(initial_p->s_gw_address.pdn_type == IPv4_AND_v6))
{
e_RABToBeSetup.transportLayerAddress.buf = calloc(4, sizeof(uint8_t));
/* Only IPv4 supported */
memcpy(e_RABToBeSetup.transportLayerAddress.buf,
initial_p->s_gw_address.address.ipv4_address,
4);
offset += 4;
e_RABToBeSetup.transportLayerAddress.size = 4;
e_RABToBeSetup.transportLayerAddress.bits_unused = 0;
}
if ((initial_p->s_gw_address.pdn_type == IPv6) ||
(initial_p->s_gw_address.pdn_type == IPv4_AND_v6))
{
if (offset == 0) {
/* Both IPv4 and IPv6 provided */
/* TODO: check memory allocation */
e_RABToBeSetup.transportLayerAddress.buf = calloc(16, sizeof(uint8_t));
} else {
/* Only IPv6 supported */
/* TODO: check memory allocation */
e_RABToBeSetup.transportLayerAddress.buf
= realloc(e_RABToBeSetup.transportLayerAddress.buf, (16 + offset) * sizeof(uint8_t));
}
memcpy(&e_RABToBeSetup.transportLayerAddress.buf[offset],
initial_p->s_gw_address.address.ipv6_address,
16);
e_RABToBeSetup.transportLayerAddress.size = 16 + offset;
e_RABToBeSetup.transportLayerAddress.bits_unused = 0;
}
ASN_SEQUENCE_ADD(&initialContextSetupRequest_p->e_RABToBeSetupListCtxtSUReq,
&e_RABToBeSetup);
initialContextSetupRequest_p->ueSecurityCapabilities.encryptionAlgorithms.buf =
(uint8_t *)supportedAlgorithms;
initialContextSetupRequest_p->ueSecurityCapabilities.encryptionAlgorithms.size = 2;
initialContextSetupRequest_p->ueSecurityCapabilities.encryptionAlgorithms.bits_unused
= 0;
initialContextSetupRequest_p->ueSecurityCapabilities.integrityProtectionAlgorithms.buf
= (uint8_t *)supportedAlgorithms;
initialContextSetupRequest_p->ueSecurityCapabilities.integrityProtectionAlgorithms.size
= 2;
initialContextSetupRequest_p->ueSecurityCapabilities.integrityProtectionAlgorithms.bits_unused
= 0;
initialContextSetupRequest_p->securityKey.buf = initial_p->keNB; /* 256 bits length */
initialContextSetupRequest_p->securityKey.size = 32;
initialContextSetupRequest_p->securityKey.bits_unused = 0;
if (s1ap_mme_encode_pdu(&message, &buffer_p, &length) < 0) {
// TODO: handle something
DevMessage("Failed to encode initial context setup request message\n");
}
s1ap_mme_itti_send_sctp_request(buffer_p, length, ue_ref->eNB->sctp_assoc_id,
ue_ref->sctp_stream_send);
}
#endif
......@@ -64,8 +64,12 @@ int s1ap_mme_handle_uplink_nas_transport(uint32_t assocId, uint32_t stream,
int s1ap_mme_handle_nas_non_delivery(uint32_t assocId, uint32_t stream,
struct s1ap_message_s *message);
#if defined(DISABLE_USE_NAS)
int s1ap_handle_attach_accepted(nas_attach_accept_t *attach_accept_p);
#else
void s1ap_handle_conn_est_cnf(nas_conn_est_cnf_t *nas_conn_est_cnf_p);
#endif
int s1ap_generate_downlink_nas_transport(nas_dl_data_req_t *nas_dl_data_req);
int s1ap_generate_downlink_nas_transport(const uint32_t ue_id, void * const data,
const uint32_t size);
#endif /* S1AP_MME_NAS_PROCEDURES_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment