Commit 445ca246 authored by gauthier's avatar gauthier

S1AP UE context release

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@6314 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent e61c50fa
......@@ -51,15 +51,19 @@ endif
include $(ASN1MESSAGESDIR)/Makefile.inc
libs1ap_OBJECTS = \
s1ap_eNB.o s1ap_common.o \
s1ap_eNB_itti_messaging.o \
s1ap_eNB_decoder.o \
s1ap_eNB_encoder.o \
s1ap_eNB_handlers.o \
s1ap_eNB_nnsf.o s1ap_eNB_ue_context.o \
s1ap_eNB_trace.o s1ap_eNB_overload.o \
s1ap_eNB_nas_procedures.o \
s1ap_eNB_management_procedures.o \
s1ap_common.o \
s1ap_eNB.o \
s1ap_eNB_context_management_procedures.o \
s1ap_eNB_decoder.o \
s1ap_eNB_encoder.o \
s1ap_eNB_handlers.o \
s1ap_eNB_itti_messaging.o \
s1ap_eNB_management_procedures.o \
s1ap_eNB_nas_procedures.o \
s1ap_eNB_nnsf.o \
s1ap_eNB_overload.o \
s1ap_eNB_trace.o \
s1ap_eNB_ue_context.o \
$(addprefix MESSAGES/, $(S1AP_ASN_MODULE_SOURCES))
ifeq ($(USE_MME), R10)
......
......@@ -51,6 +51,7 @@
#include "s1ap_eNB_nas_procedures.h"
#include "s1ap_eNB_management_procedures.h"
#include "s1ap_eNB_context_management_procedures.h"
#include "s1ap_eNB_itti_messaging.h"
......@@ -300,6 +301,10 @@ void *s1ap_eNB_task(void *arg)
s1ap_ue_context_release_complete(ITTI_MESSAGE_GET_INSTANCE(received_msg),
&S1AP_UE_CONTEXT_RELEASE_COMPLETE(received_msg));
} break;
case S1AP_UE_CONTEXT_RELEASE_REQ: {
s1ap_ue_context_release_req(ITTI_MESSAGE_GET_INSTANCE(received_msg),
&S1AP_UE_CONTEXT_RELEASE_REQ(received_msg));
} break;
default:
S1AP_ERROR("Received unhandled message: %d:%s\n",
ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
......
......@@ -95,6 +95,11 @@ int s1ap_eNB_encode_ue_context_release_complete(
uint8_t **buffer,
uint32_t *length);
static inline
int s1ap_eNB_encode_ue_context_release_request(
S1ap_UEContextReleaseRequestIEs_t *s1ap_UEContextReleaseRequestIEs,
uint8_t **buffer,
uint32_t *length);
int s1ap_eNB_encode_pdu(s1ap_message *message, uint8_t **buffer, uint32_t *len)
{
......@@ -170,6 +175,15 @@ int s1ap_eNB_encode_initiating(s1ap_message *s1ap_message_p,
message_id = S1AP_NAS_NON_DELIVERY_IND_LOG;
break;
case S1ap_ProcedureCode_id_UEContextReleaseRequest:
ret = s1ap_eNB_encode_ue_context_release_request(
&s1ap_message_p->msg.s1ap_UEContextReleaseRequestIEs, buffer, len);
s1ap_xer_print_s1ap_uecontextreleaserequest(s1ap_xer__print2sp,
message_string, s1ap_message_p);
message_id = S1AP_UE_CONTEXT_RELEASE_REQ_LOG;
break;
default:
S1AP_DEBUG("Unknown procedure ID (%d) for initiating message\n",
(int)s1ap_message_p->procedureCode);
......@@ -466,19 +480,19 @@ int s1ap_eNB_encode_initial_context_setup_response(
static inline
int s1ap_eNB_encode_ue_context_release_complete(
S1ap_UEContextReleaseCompleteIEs_t *s1ap_UEContextReleaseCompleteIEs,
S1ap_UEContextReleaseCompleteIEs_t *s1ap_UEContextReleaseCompleteIEs,
uint8_t **buffer,
uint32_t *length)
{
S1ap_UEContextReleaseComplete_t ue_context_release_complete;
S1ap_UEContextReleaseComplete_t *ue_context_release_complete_p =
S1ap_UEContextReleaseComplete_t ue_context_release_complete;
S1ap_UEContextReleaseComplete_t *ue_context_release_complete_p =
&ue_context_release_complete;
memset((void *)ue_context_release_complete_p, 0,
sizeof(ue_context_release_complete));
if (s1ap_encode_s1ap_uecontextreleasecompleteies(
ue_context_release_complete_p, s1ap_UEContextReleaseCompleteIEs) < 0)
ue_context_release_complete_p, s1ap_UEContextReleaseCompleteIEs) < 0)
{
return -1;
}
......@@ -491,3 +505,30 @@ int s1ap_eNB_encode_ue_context_release_complete(
ue_context_release_complete_p);
}
static inline
int s1ap_eNB_encode_ue_context_release_request(
S1ap_UEContextReleaseRequestIEs_t *s1ap_UEContextReleaseRequestIEs,
uint8_t **buffer,
uint32_t *length)
{
S1ap_UEContextReleaseRequest_t ue_context_release_request;
S1ap_UEContextReleaseRequest_t *ue_context_release_request_p =
&ue_context_release_request;
memset((void *)ue_context_release_request_p, 0,
sizeof(ue_context_release_request));
if (s1ap_encode_s1ap_uecontextreleaserequesties(
ue_context_release_request_p, s1ap_UEContextReleaseRequestIEs) < 0)
{
return -1;
}
return s1ap_generate_initiating_message(buffer,
length,
S1ap_ProcedureCode_id_UEContextReleaseRequest,
S1ap_Criticality_reject,
&asn_DEF_S1ap_UEContextReleaseRequest,
ue_context_release_request_p);
}
......@@ -573,74 +573,3 @@ int s1ap_eNB_ue_capabilities(instance_t instance,
return ret;
}
int s1ap_ue_context_release_complete(instance_t instance,
s1ap_ue_release_complete_t *ue_release_complete_p)
{
s1ap_eNB_instance_t *s1ap_eNB_instance_p = NULL;
struct s1ap_eNB_ue_context_s *ue_context_p = NULL;
S1ap_UEContextReleaseCompleteIEs_t *ue_ctxt_release_complete_ies_p = NULL;
s1ap_message message;
uint8_t *buffer;
uint32_t length;
int ret = -1;
/* Retrieve the S1AP eNB instance associated with Mod_id */
s1ap_eNB_instance_p = s1ap_eNB_get_instance(instance);
DevAssert(ue_release_complete_p != NULL);
DevAssert(s1ap_eNB_instance_p != NULL);
if ((ue_context_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance_p,
ue_release_complete_p->eNB_ue_s1ap_id)) == NULL)
{
/* The context for this eNB ue s1ap id doesn't exist in the map of eNB UEs */
S1AP_WARN("Failed to find ue context associated with eNB ue s1ap id: %u\n",
ue_release_complete_p->eNB_ue_s1ap_id);
return -1;
}
/* Prepare the S1AP message to encode */
memset(&message, 0, sizeof(s1ap_message));
message.direction = S1AP_PDU_PR_successfulOutcome;
message.procedureCode = S1ap_ProcedureCode_id_UEContextRelease;
//message.criticality = S1ap_Criticality_reject;
message.direction = S1AP_PDU_PR_successfulOutcome;
ue_ctxt_release_complete_ies_p = &message.msg.s1ap_UEContextReleaseCompleteIEs;
ue_ctxt_release_complete_ies_p->eNB_UE_S1AP_ID = ue_release_complete_p->eNB_ue_s1ap_id;
ue_ctxt_release_complete_ies_p->mme_ue_s1ap_id = ue_context_p->mme_ue_s1ap_id;
//ue_ctxt_release_complete_ies_p->criticalityDiagnostics
//ue_ctxt_release_complete_ies_p->presenceMask
if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
/* Encode procedure has failed... */
S1AP_ERROR("Failed to encode UE context release complete\n");
return -1;
}
/* UE associated signalling -> use the allocated stream */
s1ap_eNB_itti_send_sctp_data_req(s1ap_eNB_instance_p->instance,
ue_context_p->mme_ref->assoc_id, buffer,
length, ue_context_p->stream);
s1ap_eNB_itti_send_sctp_close_association(s1ap_eNB_instance_p->instance,
ue_context_p->mme_ref->assoc_id);
// release UE context
struct s1ap_eNB_ue_context_s *ue_context2_p = NULL;
if ((ue_context2_p = RB_REMOVE(s1ap_ue_map, &s1ap_eNB_instance_p->s1ap_ue_head, ue_context_p))
== NULL)
{
s1ap_eNB_free_ue_context(ue_context2_p);
}
return ret;
}
......@@ -49,8 +49,5 @@ int s1ap_eNB_initial_ctxt_resp(
int s1ap_eNB_ue_capabilities(instance_t instance,
s1ap_ue_cap_info_ind_t *ue_cap_info_ind_p);
int s1ap_ue_context_release_complete(instance_t instance,
s1ap_ue_release_complete_t *ue_release_complete_p);
#endif /* S1AP_ENB_NAS_PROCEDURES_H_ */
......@@ -97,8 +97,7 @@ static STAILQ_HEAD(sctp_cnx_list_head, sctp_cnx_list_elm_s) sctp_cnx_list;
static uint16_t sctp_nb_cnx = 0;
struct sctp_cnx_list_elm_s *sctp_get_cnx(int32_t assoc_id, int sd)
{
struct sctp_cnx_list_elm_s *sctp_get_cnx(int32_t assoc_id, int sd) {
struct sctp_cnx_list_elm_s *elm;
STAILQ_FOREACH(elm, &sctp_cnx_list, entries)
......@@ -117,10 +116,11 @@ struct sctp_cnx_list_elm_s *sctp_get_cnx(int32_t assoc_id, int sd)
return NULL;
}
void sctp_handle_new_association_req(
const instance_t instance,
const task_id_t requestor,
const sctp_new_association_req_t * const sctp_new_association_req_p)
void
sctp_handle_new_association_req(
const instance_t instance,
const task_id_t requestor,
const sctp_new_association_req_t * const sctp_new_association_req_p)
{
int sd;
int32_t assoc_id;
......@@ -358,9 +358,9 @@ void sctp_handle_new_association_req(
}
void sctp_send_data(
instance_t instance,
task_id_t task_id,
sctp_data_req_t *sctp_data_req_p)
instance_t instance,
task_id_t task_id,
sctp_data_req_t *sctp_data_req_p)
{
struct sctp_cnx_list_elm_s *sctp_cnx = NULL;
......@@ -400,9 +400,9 @@ void sctp_send_data(
}
static int sctp_close_association(
const instance_t instance,
const task_id_t requestor,
sctp_close_association_t *close_association_p)
const instance_t instance,
const task_id_t requestor,
sctp_close_association_t *close_association_p)
{
struct sctp_cnx_list_elm_s *sctp_cnx = NULL;
......@@ -507,11 +507,10 @@ static int sctp_create_new_listener(
/* Some pre-bind socket configuration */
if (sctp_set_init_opt(sd,
sctp_cnx->in_streams,
sctp_cnx->out_streams,
0,
0) < 0)
{
sctp_cnx->in_streams,
sctp_cnx->out_streams,
0,
0) < 0) {
goto err;
}
......@@ -540,11 +539,12 @@ err:
return -1;
}
static
inline void sctp_eNB_accept_associations(struct sctp_cnx_list_elm_s *sctp_cnx)
static inline
void
sctp_eNB_accept_associations(
struct sctp_cnx_list_elm_s *sctp_cnx)
{
int client_sd;
int client_sd;
struct sockaddr saddr;
socklen_t saddr_size;
......@@ -606,8 +606,10 @@ inline void sctp_eNB_accept_associations(struct sctp_cnx_list_elm_s *sctp_cnx)
}
}
static
inline void sctp_eNB_read_from_socket(struct sctp_cnx_list_elm_s *sctp_cnx)
static inline
void
sctp_eNB_read_from_socket(
struct sctp_cnx_list_elm_s *sctp_cnx)
{
int flags = 0, n;
socklen_t from_len;
......@@ -724,7 +726,9 @@ inline void sctp_eNB_read_from_socket(struct sctp_cnx_list_elm_s *sctp_cnx)
}
}
void sctp_eNB_flush_sockets(struct epoll_event *events, int nb_events)
void
sctp_eNB_flush_sockets(
struct epoll_event *events, int nb_events)
{
int i;
struct sctp_cnx_list_elm_s *sctp_cnx = NULL;
......
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