From e63f6c79aaad54533fc18adab284c4006736d4cc Mon Sep 17 00:00:00 2001 From: Cedric Roux <cedric.roux@eurecom.fr> Date: Wed, 13 Nov 2013 09:30:56 +0000 Subject: [PATCH] - Fixed instance id for SCTP layer git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4379 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- openair-cn/S1AP/s1ap_eNB.c | 20 ++++++++++-------- openair-cn/S1AP/s1ap_eNB_itti_messaging.c | 4 ++-- openair-cn/S1AP/s1ap_eNB_itti_messaging.h | 2 +- openair-cn/S1AP/s1ap_eNB_nas_procedures.c | 12 +++++++---- openair-cn/S1AP/s1ap_eNB_trace.c | 3 ++- openair-cn/SCTP/sctp_eNB_task.c | 25 +++++++++++++++-------- openair2/COMMON/sctp_messages_types.h | 7 +++---- targets/SIMU/USER/oaisim.c | 3 +-- 8 files changed, 45 insertions(+), 31 deletions(-) diff --git a/openair-cn/S1AP/s1ap_eNB.c b/openair-cn/S1AP/s1ap_eNB.c index 96057e5b3d..3c768e08e8 100644 --- a/openair-cn/S1AP/s1ap_eNB.c +++ b/openair-cn/S1AP/s1ap_eNB.c @@ -63,6 +63,8 @@ static int s1ap_eNB_generate_s1_setup_request( static void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_eNB_t *s1ap_register_eNB); +static +void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp); uint32_t s1ap_generate_eNB_id(void) { @@ -121,7 +123,7 @@ static void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p, */ RB_INSERT(s1ap_mme_map, &instance_p->s1ap_mme_head, s1ap_mme_data_p); - itti_send_msg_to_task(TASK_SCTP, INSTANCE_DEFAULT, message_p); + itti_send_msg_to_task(TASK_SCTP, instance_p->instance, message_p); } static @@ -132,7 +134,7 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_eNB_t *s1ap DevAssert(s1ap_register_eNB != NULL); - /* Look if the provided mod id already exists + /* Look if the provided instance already exists * If so notify user... */ new_instance = s1ap_eNB_get_instance(instance); @@ -172,14 +174,15 @@ void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_eNB_t *s1ap } } -void s1ap_eNB_handle_sctp_association_resp(sctp_new_association_resp_t *sctp_new_association_resp) +static +void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp) { s1ap_eNB_instance_t *instance_p; s1ap_eNB_mme_data_t *s1ap_mme_data_p; DevAssert(sctp_new_association_resp != NULL); - instance_p = s1ap_eNB_get_instance(sctp_new_association_resp->mod_id); + instance_p = s1ap_eNB_get_instance(instance); DevAssert(instance_p != NULL); s1ap_mme_data_p = s1ap_eNB_get_MME(instance_p, -1, @@ -187,9 +190,9 @@ void s1ap_eNB_handle_sctp_association_resp(sctp_new_association_resp_t *sctp_new DevAssert(s1ap_mme_data_p != NULL); if (sctp_new_association_resp->sctp_state != SCTP_STATE_ESTABLISHED) { - S1AP_WARN("Received unsuccessful result for SCTP association (%u), mod_id %u, cnx_id %u\n", + S1AP_WARN("Received unsuccessful result for SCTP association (%u), instance %d, cnx_id %u\n", sctp_new_association_resp->sctp_state, - sctp_new_association_resp->mod_id, + instance, sctp_new_association_resp->ulp_cnx_id); } @@ -240,7 +243,8 @@ void *s1ap_eNB_task(void *arg) &received_msg->msg.s1ap_register_eNB); } break; case SCTP_NEW_ASSOCIATION_RESP: { - s1ap_eNB_handle_sctp_association_resp(&received_msg->msg.sctp_new_association_resp); + s1ap_eNB_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg), + &received_msg->msg.sctp_new_association_resp); } break; case SCTP_DATA_IND: { s1ap_eNB_handle_sctp_data_ind(&received_msg->msg.sctp_data_ind); @@ -326,7 +330,7 @@ static int s1ap_eNB_generate_s1_setup_request( } /* Non UE-Associated signalling -> stream = 0 */ - s1ap_eNB_itti_send_sctp_data_req(s1ap_mme_data_p->assoc_id, buffer, len, 0); + s1ap_eNB_itti_send_sctp_data_req(instance_p->instance, s1ap_mme_data_p->assoc_id, buffer, len, 0); return ret; } diff --git a/openair-cn/S1AP/s1ap_eNB_itti_messaging.c b/openair-cn/S1AP/s1ap_eNB_itti_messaging.c index 485e80d7aa..0e1cef7027 100644 --- a/openair-cn/S1AP/s1ap_eNB_itti_messaging.c +++ b/openair-cn/S1AP/s1ap_eNB_itti_messaging.c @@ -2,7 +2,7 @@ #include "s1ap_eNB_itti_messaging.h" -void s1ap_eNB_itti_send_sctp_data_req(int32_t assoc_id, uint8_t *buffer, +void s1ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, uint32_t buffer_length, uint16_t stream) { MessageDef *message_p; @@ -17,7 +17,7 @@ void s1ap_eNB_itti_send_sctp_data_req(int32_t assoc_id, uint8_t *buffer, sctp_data_req->buffer_length = buffer_length; sctp_data_req->stream = stream; - itti_send_msg_to_task(TASK_SCTP, INSTANCE_DEFAULT, message_p); + itti_send_msg_to_task(TASK_SCTP, instance, message_p); } void s1ap_eNB_itti_send_nas_downlink_ind(instance_t instance, uint8_t *nas_pdu, diff --git a/openair-cn/S1AP/s1ap_eNB_itti_messaging.h b/openair-cn/S1AP/s1ap_eNB_itti_messaging.h index 8b0de73418..1b20423e73 100644 --- a/openair-cn/S1AP/s1ap_eNB_itti_messaging.h +++ b/openair-cn/S1AP/s1ap_eNB_itti_messaging.h @@ -1,7 +1,7 @@ #ifndef S1AP_ENB_ITTI_MESSAGING_H_ #define S1AP_ENB_ITTI_MESSAGING_H_ -void s1ap_eNB_itti_send_sctp_data_req(int32_t assoc_id, uint8_t *buffer, +void s1ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer, uint32_t buffer_length, uint16_t stream); void s1ap_eNB_itti_send_nas_downlink_ind(instance_t instance, uint8_t *nas_pdu, diff --git a/openair-cn/S1AP/s1ap_eNB_nas_procedures.c b/openair-cn/S1AP/s1ap_eNB_nas_procedures.c index b119985de7..bc128b1546 100644 --- a/openair-cn/S1AP/s1ap_eNB_nas_procedures.c +++ b/openair-cn/S1AP/s1ap_eNB_nas_procedures.c @@ -179,7 +179,8 @@ int s1ap_eNB_handle_nas_first_req( ue_desc_p->stream = ++mme_desc_p->nextstream; /* Send encoded message over sctp */ - s1ap_eNB_itti_send_sctp_data_req(mme_desc_p->assoc_id, buffer, length, ue_desc_p->stream); + s1ap_eNB_itti_send_sctp_data_req(instance_p->instance, mme_desc_p->assoc_id, + buffer, length, ue_desc_p->stream); return 0; } @@ -312,7 +313,8 @@ int s1ap_eNB_nas_uplink(instance_t instance, s1ap_uplink_nas_t *s1ap_uplink_nas_ } /* UE associated signalling -> use the allocated stream */ - s1ap_eNB_itti_send_sctp_data_req(ue_context_p->mme_ref->assoc_id, buffer, + 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); return 0; @@ -391,7 +393,8 @@ int s1ap_eNB_initial_ctxt_resp( } /* UE associated signalling -> use the allocated stream */ - s1ap_eNB_itti_send_sctp_data_req(ue_context_p->mme_ref->assoc_id, buffer, + 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); return ret; @@ -456,7 +459,8 @@ int s1ap_eNB_ue_capabilities(instance_t instance, } /* UE associated signalling -> use the allocated stream */ - s1ap_eNB_itti_send_sctp_data_req(ue_context_p->mme_ref->assoc_id, buffer, + 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); return ret; diff --git a/openair-cn/S1AP/s1ap_eNB_trace.c b/openair-cn/S1AP/s1ap_eNB_trace.c index 754f266d4f..4705a7cfa6 100644 --- a/openair-cn/S1AP/s1ap_eNB_trace.c +++ b/openair-cn/S1AP/s1ap_eNB_trace.c @@ -75,7 +75,8 @@ void s1ap_eNB_generate_trace_failure(struct s1ap_eNB_ue_context_s *ue_desc_p, return; } - s1ap_eNB_itti_send_sctp_data_req(ue_desc_p->mme_ref->assoc_id, buffer, + s1ap_eNB_itti_send_sctp_data_req(ue_desc_p->mme_ref->s1ap_eNB_instance->instance, + ue_desc_p->mme_ref->assoc_id, buffer, length, ue_desc_p->stream); } diff --git a/openair-cn/SCTP/sctp_eNB_task.c b/openair-cn/SCTP/sctp_eNB_task.c index 00792d3d3a..4019190418 100644 --- a/openair-cn/SCTP/sctp_eNB_task.c +++ b/openair-cn/SCTP/sctp_eNB_task.c @@ -71,6 +71,9 @@ struct sctp_cnx_list_elm_s { /* Task id of the task who asked for this connection */ task_id_t task_id; + /* Instance */ + instance_t instance; + /* Upper layer identifier */ uint16_t cnx_id; }; @@ -99,6 +102,7 @@ struct sctp_cnx_list_elm_s *sctp_get_cnx(int32_t assoc_id, int sd) } 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) { @@ -216,10 +220,11 @@ void sctp_handle_new_association_req( sctp_cnx = calloc(1, sizeof(*sctp_cnx)); - sctp_cnx->sd = sd; - sctp_cnx->task_id = requestor; - sctp_cnx->cnx_id = sctp_new_association_req_p->ulp_cnx_id; - sctp_cnx->ppid = sctp_new_association_req_p->ppid; + sctp_cnx->sd = sd; + sctp_cnx->task_id = requestor; + sctp_cnx->cnx_id = sctp_new_association_req_p->ulp_cnx_id; + sctp_cnx->ppid = sctp_new_association_req_p->ppid; + sctp_cnx->instance = instance; /* Get socket info */ sctp_get_sockinfo(sd, @@ -247,11 +252,11 @@ void sctp_handle_new_association_req( SCTP_DEBUG("Sending SCTP new association resp message to %s\n", itti_get_task_name(requestor)); - itti_send_msg_to_task(requestor, INSTANCE_DEFAULT, new_message_p); + itti_send_msg_to_task(requestor, sctp_cnx->instance, new_message_p); } } -void sctp_send_data(task_id_t task_id, sctp_data_req_t *sctp_data_req_p) +void sctp_send_data(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; @@ -427,12 +432,14 @@ void *sctp_eNB_task(void *arg) itti_exit_task(); break; case SCTP_NEW_ASSOCIATION_REQ: { - sctp_handle_new_association_req(received_msg->header.originTaskId, + sctp_handle_new_association_req(ITTI_MESSAGE_GET_INSTANCE(received_msg), + received_msg->header.originTaskId, &received_msg->msg.sctp_new_association_req); } break; case SCTP_DATA_REQ: { - sctp_send_data(received_msg->header.originTaskId, - &received_msg->msg.sctp_data_req); + sctp_send_data(ITTI_MESSAGE_GET_INSTANCE(received_msg), + received_msg->header.originTaskId, + &received_msg->msg.sctp_data_req); } break; default: SCTP_ERROR("Received unhandled message with id %d\n", diff --git a/openair2/COMMON/sctp_messages_types.h b/openair2/COMMON/sctp_messages_types.h index e07f530164..3fb980e460 100644 --- a/openair2/COMMON/sctp_messages_types.h +++ b/openair2/COMMON/sctp_messages_types.h @@ -8,8 +8,6 @@ enum sctp_state_e { }; typedef struct { - /* Module id: used in virtual mode */ - uint8_t mod_id; /* Upper layer connexion identifier */ uint16_t ulp_cnx_id; @@ -25,8 +23,6 @@ typedef struct { } sctp_new_association_req_t; typedef struct { - /* Module id: used in virtual mode */ - uint8_t mod_id; /* Upper layer connexion identifier */ uint16_t ulp_cnx_id; @@ -42,7 +38,10 @@ typedef struct { } sctp_new_association_resp_t; typedef struct { + /* SCTP Association ID */ int32_t assoc_id; + + /* Buffer to send over SCTP */ uint32_t buffer_length; uint8_t *buffer; diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index de18b25b5c..c84a94c55a 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -405,7 +405,6 @@ void *l2l1_task(void *args_p) { hash = s1ap_generate_eNB_id(); /* Some default/random parameters */ - s1ap_register_eNB->mod_id = eNB_id; s1ap_register_eNB->eNB_id = eNB_id + (hash & 0xFFFF8); s1ap_register_eNB->cell_type = CELL_MACRO_ENB; s1ap_register_eNB->tac = 0; @@ -420,7 +419,7 @@ void *l2l1_task(void *args_p) { memcpy(s1ap_register_eNB->mme_ip_address[0].ipv6_address, mme_address_v6, strlen(mme_address_v6)); - itti_send_msg_to_task(TASK_S1AP, INSTANCE_DEFAULT, message_p); + itti_send_msg_to_task(TASK_S1AP, eNB_id, message_p); } # endif #endif -- GitLab