Commit 53daef42 authored by zhenghuangkun's avatar zhenghuangkun

Fix 2ho multi cells support and Abort/Assert modify

parent 7af84127
......@@ -4803,7 +4803,8 @@ void rrc_eNB_process_handoverPreparationInformation(int mod_id, x2ap_handover_re
ho->criticalExtensions.present != LTE_HandoverPreparationInformation__criticalExtensions_PR_c1 ||
ho->criticalExtensions.choice.c1.present != LTE_HandoverPreparationInformation__criticalExtensions__c1_PR_handoverPreparationInformation_r8) {
LOG_E(RRC, "could not decode Handover Preparation\n");
abort();
//abort();
return ;
}
ho_info = &ho->criticalExtensions.choice.c1.choice.handoverPreparationInformation_r8;
......@@ -4878,15 +4879,18 @@ void rrc_eNB_process_handoverCommand(
ho->criticalExtensions.present != LTE_HandoverCommand__criticalExtensions_PR_c1 ||
ho->criticalExtensions.choice.c1.present != LTE_HandoverCommand__criticalExtensions__c1_PR_handoverCommand_r8) {
LOG_E(RRC, "could not decode Handover Command\n");
abort();
//abort();
return ;
}
unsigned char *buf = ho->criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.buf;
int size = ho->criticalExtensions.choice.c1.choice.handoverCommand_r8.handoverCommandMessage.size;
if (size > RRC_BUF_SIZE) {
printf("%s:%d: fatal\n", __FILE__, __LINE__);
abort();
//printf("%s:%d: fatal\n", __FILE__, __LINE__);
//abort();
LOG_E(RRC, "%s:%d: fatal size: %d\n", __FILE__, __LINE__,size);
return ;
}
memcpy(ue_context->ue_context.handover_info->buf, buf, size);
......@@ -5153,7 +5157,9 @@ check_handovers(
// Message buffer has been processed, free it now.
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), GTPV1U_ENB_DATA_FORWARDING_IND (msg_p).sdu_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
if(result != EXIT_SUCCESS) {
LOG_E(RRC,"Failed to free memory (%d)!\n", result);
}
break;
default:
......@@ -5162,7 +5168,9 @@ check_handovers(
}
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
if(result != EXIT_SUCCESS) {
LOG_E(RRC,"Failed to free memory (%d)!\n", result);
}
}
} while(msg_p != NULL);
ue_context_p->ue_context.handover_info->forwarding_state = FORWARDING_EMPTY;
......@@ -5224,7 +5232,9 @@ check_handovers(
// Message buffer has been processed, free it now.
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), GTPV1U_ENB_END_MARKER_IND (msg_p).sdu_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
if(result != EXIT_SUCCESS) {
LOG_E(RRC,"Failed to free memory (%d)!\n", result);
}
break;
default:
......@@ -5233,7 +5243,9 @@ check_handovers(
}
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
if(result != EXIT_SUCCESS) {
LOG_E(RRC,"Failed to free memory (%d)!\n", result);
}
}
} while(msg_p != NULL);
......@@ -6293,8 +6305,10 @@ rrc_eNB_generate_HO_RRCConnectionReconfiguration(const protocol_ctxt_t *const ct
);
if (rrc_size <= 0) {
printf("%s:%d: fatal\n", __FILE__, __LINE__);
abort();
//printf("%s:%d: fatal\n", __FILE__, __LINE__);
//abort();
LOG_E(RRC, "%s:%d: fatal size: %d\n", __FILE__, __LINE__,size);
return ;
}
char *ho_buf = (char *)buffer;
......@@ -8974,12 +8988,20 @@ void *rrc_enb_process_itti_msg(void *notUsed) {
/* is it possible? */
LOG_E(RRC, "could not find UE (rnti %x) while processing X2AP_HANDOVER_REQ_ACK\n",
X2AP_HANDOVER_REQ_ACK(msg_p).rnti);
exit(1);
//exit(1);
return ;
}
LOG_I(RRC, "[eNB %d] source eNB receives the X2 HO ACK %s\n", instance, msg_name_p);
DevAssert(ue_context_p != NULL);
if(ue_context_p == NULL) {
LOG_E(RRC,"%s %d: ue_context_p is a NULL pointer \n",__FILE__,__LINE__);
return ;
}
if (ue_context_p->ue_context.handover_info->state != HO_REQUEST) abort();
if (ue_context_p->ue_context.handover_info->state != HO_REQUEST) {
//abort();
LOG_E(RRC, "%s:%d: the handover state is not HO_REQUEST: %d\n",__FILE__, __LINE__,ue_context_p->ue_context.handover_info->state);
return ;
}
hash_rc = hashtable_get(RC.gtpv1u_data_g->ue_mapping, ue_context_p->ue_context.rnti, (void**)&gtpv1u_ue_data_p);
/* set target enb gtp teid */
......@@ -9027,9 +9049,16 @@ void *rrc_enb_process_itti_msg(void *notUsed) {
struct rrc_eNB_ue_context_s *ue_context_p = NULL;
ue_context_p = rrc_eNB_get_ue_context(RC.rrc[instance], X2AP_UE_CONTEXT_RELEASE(msg_p).rnti);
LOG_I(RRC, "[eNB %d] source eNB receives the X2 UE CONTEXT RELEASE %s\n", instance, msg_name_p);
DevAssert(ue_context_p != NULL);
if(ue_context_p == NULL) {
LOG_E(RRC,"%s %d: ue_context_p is a NULL pointer \n",__FILE__,__LINE__);
return ;
}
if (ue_context_p->ue_context.handover_info->state != HO_COMPLETE) abort();
if (ue_context_p->ue_context.handover_info->state != HO_COMPLETE) {
//abort();
LOG_E(RRC, "%s:%d: the handover state is not HO_COMPLETE: %d\n",__FILE__, __LINE__,ue_context_p->ue_context.handover_info->state);
return ;
}
ue_context_p->ue_context.handover_info->state = HO_RELEASE;
break;
......
This diff is collapsed.
......@@ -35,7 +35,10 @@
static int x2ap_eNB_decode_initiating_message(X2AP_X2AP_PDU_t *pdu)
{
DevAssert(pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
switch(pdu->choice.initiatingMessage.procedureCode) {
......@@ -62,8 +65,6 @@ static int x2ap_eNB_decode_initiating_message(X2AP_X2AP_PDU_t *pdu)
default:
X2AP_ERROR("Unknown procedure ID (%d) for initiating message\n",
(int)pdu->choice.initiatingMessage.procedureCode);
AssertFatal( 0, "Unknown procedure ID (%d) for initiating message\n",
(int)pdu->choice.initiatingMessage.procedureCode);
return -1;
}
......@@ -72,7 +73,10 @@ static int x2ap_eNB_decode_initiating_message(X2AP_X2AP_PDU_t *pdu)
static int x2ap_eNB_decode_successful_outcome(X2AP_X2AP_PDU_t *pdu)
{
DevAssert(pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
switch(pdu->choice.successfulOutcome.procedureCode) {
case X2AP_ProcedureCode_id_x2Setup:
......@@ -96,7 +100,10 @@ static int x2ap_eNB_decode_successful_outcome(X2AP_X2AP_PDU_t *pdu)
static int x2ap_eNB_decode_unsuccessful_outcome(X2AP_X2AP_PDU_t *pdu)
{
DevAssert(pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
switch(pdu->choice.unsuccessfulOutcome.procedureCode) {
case X2AP_ProcedureCode_id_x2Setup:
......@@ -117,7 +124,10 @@ int x2ap_eNB_decode_pdu(X2AP_X2AP_PDU_t *pdu, const uint8_t *const buffer, uint3
{
asn_dec_rval_t dec_ret;
DevAssert(buffer != NULL);
if(buffer == NULL) {
X2AP_ERROR("%s %d: buffer is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
dec_ret = aper_decode(NULL,
&asn_DEF_X2AP_X2AP_PDU,
......
......@@ -40,9 +40,20 @@ int x2ap_eNB_encode_pdu(X2AP_X2AP_PDU_t *pdu, uint8_t **buffer, uint32_t *len)
{
ssize_t encoded;
DevAssert(pdu != NULL);
DevAssert(buffer != NULL);
DevAssert(len != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
if(buffer == NULL) {
X2AP_ERROR("%s %d: buffer is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
if(len == NULL) {
X2AP_ERROR("%s %d: len is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
if (asn1_xer_print) {
xer_fprint(stdout, &asn_DEF_X2AP_X2AP_PDU, (void *)pdu);
......
This diff is collapsed.
......@@ -177,7 +177,10 @@ int x2ap_eNB_handle_message(instance_t instance, uint32_t assoc_id, int32_t stre
X2AP_X2AP_PDU_t pdu;
int ret = 0;
DevAssert(data != NULL);
if(data == NULL) {
X2AP_ERROR("%s %d: data is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
memset(&pdu, 0, sizeof(pdu));
......@@ -294,7 +297,11 @@ x2ap_eNB_handle_x2_setup_request(instance_t instance,
MessageDef *msg;
uint32_t eNB_id = 0;
DevAssert (pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
x2SetupRequest = &pdu->choice.initiatingMessage.value.choice.X2SetupRequest;
/*
......@@ -407,7 +414,10 @@ x2ap_eNB_handle_x2_setup_request(instance_t instance,
}
instance_p = x2ap_eNB_get_instance(instance);
DevAssert(instance_p != NULL);
if(instance_p == NULL) {
X2AP_ERROR("%s %d: instance_p is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
itti_send_msg_to_task(TASK_RRC_ENB, instance_p->instance, msg);
......@@ -430,7 +440,11 @@ int x2ap_eNB_handle_x2_setup_response(instance_t instance,
MessageDef *msg;
uint32_t eNB_id = 0;
DevAssert (pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
x2SetupResponse = &pdu->choice.successfulOutcome.value.choice.X2SetupResponse;
/*
......@@ -531,7 +545,10 @@ int x2ap_eNB_handle_x2_setup_response(instance_t instance,
x2ap_eNB_data->state = X2AP_ENB_STATE_READY;
instance_p = x2ap_eNB_get_instance(instance);
DevAssert(instance_p != NULL);
if(instance_p == NULL) {
X2AP_ERROR("%s %d: instance_p is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
instance_p->x2_target_enb_associated_nb ++;
x2ap_handle_x2_setup_message(instance_p, x2ap_eNB_data, 0);
......@@ -554,7 +571,10 @@ int x2ap_eNB_handle_x2_setup_failure(instance_t instance,
x2ap_eNB_instance_t *instance_p;
x2ap_eNB_data_t *x2ap_eNB_data;
DevAssert(pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
x2SetupFailure = &pdu->choice.unsuccessfulOutcome.value.choice.X2SetupFailure;
......@@ -594,7 +614,10 @@ int x2ap_eNB_handle_x2_setup_failure(instance_t instance,
x2ap_eNB_data->state = X2AP_ENB_STATE_WAITING;
instance_p = x2ap_eNB_get_instance(instance);
DevAssert(instance_p != NULL);
if(instance_p == NULL) {
X2AP_ERROR("%s %d: instance_p is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
x2ap_handle_x2_setup_message(instance_p, x2ap_eNB_data, 0);
......@@ -619,7 +642,11 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance,
MessageDef *msg;
int ue_id;
DevAssert (pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
x2HandoverRequest = &pdu->choice.initiatingMessage.value.choice.HandoverRequest;
if (stream == 0) {
......@@ -631,10 +658,16 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance,
X2AP_DEBUG ("Received a new X2 handover request\n");
x2ap_eNB_data = x2ap_get_eNB(NULL, assoc_id, 0);
DevAssert(x2ap_eNB_data != NULL);
if(x2ap_eNB_data == NULL) {
X2AP_ERROR("%s %d: x2ap_eNB_data is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
instance_p = x2ap_eNB_get_instance(instance);
DevAssert(instance_p != NULL);
if(instance_p == NULL) {
X2AP_ERROR("%s %d: instance_p is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
msg = itti_alloc_new_message(TASK_X2AP, X2AP_HANDOVER_REQ);
......@@ -650,7 +683,8 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance,
if (ue_id == -1) {
X2AP_ERROR("could not allocate a new X2AP UE ID\n");
/* TODO: cancel handover: send HO preparation failure to source eNB */
exit(1);
//exit(1);
return -1;
}
/* rnti is unknown yet, must not be set to -1, 0 is fine */
x2ap_set_ids(&instance_p->id_manager, ue_id, 0, ie->value.choice.UE_X2AP_ID, ue_id);
......@@ -730,10 +764,6 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance,
X2AP_RRC_Context_t *c = &ie->value.choice.UE_ContextInformation.rRC_Context;
if (c->size > 8192 /* TODO: this is the size of rrc_buffer in struct x2ap_handover_req_s */)
{ printf("%s:%d: fatal: buffer too big\n", __FILE__, __LINE__); abort(); }
memcpy(X2AP_HANDOVER_REQ(msg).rrc_buffer, c->buf, c->size);
X2AP_HANDOVER_REQ(msg).rrc_buffer_size = c->size;
itti_send_msg_to_task(TASK_RRC_ENB, instance_p->instance, msg);
......@@ -760,7 +790,10 @@ int x2ap_eNB_handle_handover_response (instance_t instance,
int id_target;
int rnti;
DevAssert (pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
x2HandoverRequestAck = &pdu->choice.successfulOutcome.value.choice.HandoverRequestAcknowledge;
if (stream == 0) {
......@@ -772,10 +805,16 @@ int x2ap_eNB_handle_handover_response (instance_t instance,
X2AP_DEBUG ("Received a new X2 handover response\n");
x2ap_eNB_data = x2ap_get_eNB(NULL, assoc_id, 0);
DevAssert(x2ap_eNB_data != NULL);
if(x2ap_eNB_data == NULL) {
X2AP_ERROR("%s %d: x2ap_eNB_data is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
instance_p = x2ap_eNB_get_instance(instance);
DevAssert(instance_p != NULL);
if(instance_p == NULL) {
X2AP_ERROR("%s %d: instance_p is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
msg = itti_alloc_new_message(TASK_X2AP, X2AP_HANDOVER_REQ_ACK);
......@@ -873,9 +912,6 @@ int x2ap_eNB_handle_handover_response (instance_t instance,
X2AP_TargeteNBtoSource_eNBTransparentContainer_t *c = &ie->value.choice.TargeteNBtoSource_eNBTransparentContainer;
if (c->size > 1024 /* TODO: this is the size of rrc_buffer in struct x2ap_handover_req_ack_s */)
{ printf("%s:%d: fatal: buffer too big\n", __FILE__, __LINE__); abort(); }
memcpy(X2AP_HANDOVER_REQ_ACK(msg).rrc_buffer, c->buf, c->size);
X2AP_HANDOVER_REQ_ACK(msg).rrc_buffer_size = c->size;
......@@ -900,7 +936,10 @@ int x2ap_eNB_handle_ue_context_release (instance_t instance,
int id_source;
int id_target;
DevAssert (pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
x2UEContextRelease = &pdu->choice.initiatingMessage.value.choice.UEContextRelease;
if (stream == 0) {
......@@ -912,10 +951,16 @@ int x2ap_eNB_handle_ue_context_release (instance_t instance,
X2AP_DEBUG ("Received a new X2 ue context release\n");
x2ap_eNB_data = x2ap_get_eNB(NULL, assoc_id, 0);
DevAssert(x2ap_eNB_data != NULL);
if(x2ap_eNB_data == NULL) {
X2AP_ERROR("%s %d: x2ap_eNB_data is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
instance_p = x2ap_eNB_get_instance(instance);
DevAssert(instance_p != NULL);
if(instance_p == NULL) {
X2AP_ERROR("%s %d: instance_p is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
msg = itti_alloc_new_message(TASK_X2AP, X2AP_UE_CONTEXT_RELEASE);
......@@ -983,7 +1028,10 @@ int x2ap_eNB_handle_handover_cancel (instance_t instance,
int id_target;
x2ap_handover_cancel_cause_t cause;
DevAssert (pdu != NULL);
if(pdu == NULL) {
X2AP_ERROR("%s %d: pdu is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
x2HandoverCancel = &pdu->choice.initiatingMessage.value.choice.HandoverCancel;
if (stream == 0) {
......@@ -994,10 +1042,16 @@ int x2ap_eNB_handle_handover_cancel (instance_t instance,
X2AP_DEBUG ("Received a new X2 handover cancel\n");
x2ap_eNB_data = x2ap_get_eNB(NULL, assoc_id, 0);
DevAssert(x2ap_eNB_data != NULL);
if(x2ap_eNB_data == NULL) {
X2AP_ERROR("%s %d: x2ap_eNB_data is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
instance_p = x2ap_eNB_get_instance(instance);
DevAssert(instance_p != NULL);
if(instance_p == NULL) {
X2AP_ERROR("%s %d: instance_p is a NULL pointer \n",__FILE__,__LINE__);
return -1;
}
X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_HandoverCancel_IEs_t, ie, x2HandoverCancel,
X2AP_ProtocolIE_ID_id_Old_eNB_UE_X2AP_ID, true);
......@@ -1059,7 +1113,8 @@ int x2ap_eNB_handle_handover_cancel (instance_t instance,
id_source,
x2ap_id_get_id_target(&instance_p->id_manager, ue_id),
id_target);
exit(1);
//exit(1);
return -1;
}
msg = itti_alloc_new_message(TASK_X2AP, X2AP_HANDOVER_CANCEL);
......
......@@ -92,7 +92,10 @@ void x2ap_eNB_prepare_internal_data(void)
void x2ap_eNB_insert_new_instance(x2ap_eNB_instance_t *new_instance_p)
{
DevAssert(new_instance_p != NULL);
if (new_instance_p == NULL) {
X2AP_ERROR("%s %d: new_instance_p is a NULL pointer \n",__FILE__,__LINE__);
return;
}
STAILQ_INSERT_TAIL(&x2ap_eNB_internal_data.x2ap_eNB_instances_head,
new_instance_p, x2ap_eNB_entries);
......@@ -255,3 +258,17 @@ x2ap_eNB_data_t * x2ap_is_eNB_assoc_id_in_list (const uint32_t sctp_assoc_id)
}
return NULL;
}
void x2ap_remove_eNB(x2ap_eNB_instance_t *instance_p,x2ap_eNB_data_t *x2ap_enb_data_p) {
printf("x2ap_remove_eNB (removing)\n");
if (instance_p == NULL) {
STAILQ_FOREACH(instance_p, &x2ap_eNB_internal_data.x2ap_eNB_instances_head,
x2ap_eNB_entries) {
RB_REMOVE(x2ap_enb_map, &instance_p->x2ap_enb_head, x2ap_enb_data_p);
}
} else {
RB_REMOVE(x2ap_enb_map, &instance_p->x2ap_enb_head, x2ap_enb_data_p);
}
free(x2ap_enb_data_p);
}
......@@ -51,4 +51,5 @@ struct x2ap_eNB_data_s *x2ap_get_eNB(x2ap_eNB_instance_t *instance_p,
int32_t assoc_id,
uint16_t cnx_id);
void x2ap_remove_eNB(x2ap_eNB_instance_t *instance_p,x2ap_eNB_data_t *x2ap_enb_data_p);
#endif /* X2AP_ENB_MANAGEMENT_PROCEDURES_H_ */
......@@ -47,7 +47,10 @@ void x2ap_check_timers(instance_t instance)
int x2_ongoing;
instance_p = x2ap_eNB_get_instance(instance);
DevAssert(instance_p != NULL);
if (instance_p == NULL) {
X2AP_ERROR("%s %d: instance_p is a NULL pointer \n",__FILE__,__LINE__);
return ;
}
t = &instance_p->timers;
m = &instance_p->id_manager;
......
......@@ -805,7 +805,7 @@ static int sctp_create_new_listener(
return -1;
}
if (listen(sd, 5) < 0) {
if (listen(sd, 6) < 0) {
SCTP_ERROR("listen: %s:%d\n", strerror(errno), errno);
free(sctp_cnx);
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