Commit 46407ca4 authored by Haruki NAOI's avatar Haruki NAOI Committed by masayuki.harada

Add S1down auto recovery.

(cherry picked from commit 2339972ceaeb75fe18c0b2ae9ea69216dd919668)
parent 7631a1dc
...@@ -540,6 +540,7 @@ add_library(S1AP_ENB ...@@ -540,6 +540,7 @@ add_library(S1AP_ENB
${S1AP_DIR}/s1ap_eNB_overload.c ${S1AP_DIR}/s1ap_eNB_overload.c
${S1AP_DIR}/s1ap_eNB_trace.c ${S1AP_DIR}/s1ap_eNB_trace.c
${S1AP_DIR}/s1ap_eNB_ue_context.c ${S1AP_DIR}/s1ap_eNB_ue_context.c
${S1AP_DIR}/s1ap_eNB_timer.c
) )
add_dependencies(S1AP_ENB rrc_flag s1ap_flag) add_dependencies(S1AP_ENB rrc_flag s1ap_flag)
......
...@@ -393,6 +393,11 @@ typedef struct s1ap_register_enb_req_s { ...@@ -393,6 +393,11 @@ typedef struct s1ap_register_enb_req_s {
/* Number of SCTP streams used for a mme association */ /* Number of SCTP streams used for a mme association */
uint16_t sctp_in_streams; uint16_t sctp_in_streams;
uint16_t sctp_out_streams; uint16_t sctp_out_streams;
uint16_t s1_setuprsp_wait_timer;
uint16_t s1_setupreq_wait_timer;
uint16_t s1_setupreq_count;
uint16_t sctp_req_timer;
uint16_t sctp_req_count;
} s1ap_register_enb_req_t; } s1ap_register_enb_req_t;
//-------------------------------------------------------------------------------------------// //-------------------------------------------------------------------------------------------//
......
...@@ -47,7 +47,8 @@ TASK_DEF(TASK_RAL_ENB, TASK_PRIORITY_MED, 200) ...@@ -47,7 +47,8 @@ TASK_DEF(TASK_RAL_ENB, TASK_PRIORITY_MED, 200)
TASK_DEF(TASK_UDP, TASK_PRIORITY_MED, 1000) TASK_DEF(TASK_UDP, TASK_PRIORITY_MED, 1000)
// GTP_V1U task // GTP_V1U task
TASK_DEF(TASK_GTPV1_U, TASK_PRIORITY_MED, 1000) TASK_DEF(TASK_GTPV1_U, TASK_PRIORITY_MED, 1000)
TASK_DEF(TASK_S1AP, TASK_PRIORITY_MED, 200) //TASK_DEF(TASK_S1AP, TASK_PRIORITY_MED, 200)
TASK_DEF(TASK_S1AP, TASK_PRIORITY_MED, 2000)
TASK_DEF(TASK_CU_F1, TASK_PRIORITY_MED, 200) TASK_DEF(TASK_CU_F1, TASK_PRIORITY_MED, 200)
TASK_DEF(TASK_DU_F1, TASK_PRIORITY_MED, 200) TASK_DEF(TASK_DU_F1, TASK_PRIORITY_MED, 200)
/// M3ap task, acts as both source and target /// M3ap task, acts as both source and target
......
...@@ -2426,6 +2426,65 @@ int RCconfig_S1( ...@@ -2426,6 +2426,65 @@ int RCconfig_S1(
"to\n" "to\n"
" tracking_area_code = 1; // no string!!\n" " tracking_area_code = 1; // no string!!\n"
" plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n"); " plmn_list = ( { mcc = 208; mnc = 93; mnc_length = 2; } )\n");
if(*ENBParamList.paramarray[k][ENB_S1SETUP_RSP_TIMER_IDX].uptr <= 0xffff)
{
S1AP_REGISTER_ENB_REQ(msg_p).s1_setuprsp_wait_timer = *ENBParamList.paramarray[k][ENB_S1SETUP_RSP_TIMER_IDX].uptr;
}
else
{
LOG_E(S1AP,
"s1setup_rsp_timer value in conf file is invalid (%d). Default value is set.\n",
*ENBParamList.paramarray[k][ENB_S1SETUP_RSP_TIMER_IDX].uptr);
S1AP_REGISTER_ENB_REQ(msg_p).s1_setuprsp_wait_timer = 5;
}
if(*ENBParamList.paramarray[k][ENB_S1SETUP_REQ_TIMER_IDX].uptr <= 0xffff)
{
S1AP_REGISTER_ENB_REQ(msg_p).s1_setupreq_wait_timer = *ENBParamList.paramarray[k][ENB_S1SETUP_REQ_TIMER_IDX].uptr;
}
else
{
LOG_E(S1AP,
"s1setup_req_timer value in conf file is invalid (%d). Default value is set.\n",
*ENBParamList.paramarray[k][ENB_S1SETUP_REQ_TIMER_IDX].uptr);
S1AP_REGISTER_ENB_REQ(msg_p).s1_setupreq_wait_timer = 5;
}
if(*ENBParamList.paramarray[k][ENB_S1SETUP_REQ_COUNT_IDX].uptr <= 0xffff)
{
S1AP_REGISTER_ENB_REQ(msg_p).s1_setupreq_count = *ENBParamList.paramarray[k][ENB_S1SETUP_REQ_COUNT_IDX].uptr;
}
else
{
LOG_E(S1AP,
"s1setup_req_count value in conf file is invalid (%d). Default value is set.\n",
*ENBParamList.paramarray[k][ENB_S1SETUP_REQ_COUNT_IDX].uptr);
S1AP_REGISTER_ENB_REQ(msg_p).s1_setupreq_count = 0xffff;
}
if(*ENBParamList.paramarray[k][ENB_SCTP_REQ_TIMER_IDX].uptr <= 0xffff)
{
S1AP_REGISTER_ENB_REQ(msg_p).sctp_req_timer = *ENBParamList.paramarray[k][ENB_SCTP_REQ_TIMER_IDX].uptr;
}
else
{
LOG_E(S1AP,
"sctp_req_timer value in conf file is invalid (%d). Default value is set.\n",
*ENBParamList.paramarray[k][ENB_SCTP_REQ_TIMER_IDX].uptr);
S1AP_REGISTER_ENB_REQ(msg_p).sctp_req_timer = 180;
}
if(*ENBParamList.paramarray[k][ENB_SCTP_REQ_COUNT_IDX].uptr <= 0xffff)
{
S1AP_REGISTER_ENB_REQ(msg_p).sctp_req_count = *ENBParamList.paramarray[k][ENB_SCTP_REQ_COUNT_IDX].uptr;
}
else
{
LOG_E(S1AP,
"sctp_req_count value in conf file is invalid (%d). Default value is set.\n",
*ENBParamList.paramarray[k][ENB_SCTP_REQ_COUNT_IDX].uptr);
S1AP_REGISTER_ENB_REQ(msg_p).sctp_req_count = 0xffff;
}
config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix); config_getlist(&PLMNParamList, PLMNParams, sizeof(PLMNParams)/sizeof(paramdef_t), aprefix);
if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) { if (PLMNParamList.numelt < 1 || PLMNParamList.numelt > 6) {
......
...@@ -214,6 +214,11 @@ typedef enum { ...@@ -214,6 +214,11 @@ typedef enum {
#define ENB_CONFIG_STRING_X2 "enable_x2" #define ENB_CONFIG_STRING_X2 "enable_x2"
#define ENB_CONFIG_STRING_ENB_M2 "enable_enb_m2" #define ENB_CONFIG_STRING_ENB_M2 "enable_enb_m2"
#define ENB_CONFIG_STRING_MCE_M2 "enable_mce_m2" #define ENB_CONFIG_STRING_MCE_M2 "enable_mce_m2"
#define ENB_CONFIG_STRING_S1SETUP_RSP_TIMER "s1setup_rsp_timer"
#define ENB_CONFIG_STRING_S1SETUP_REQ_TIMER "s1setup_req_timer"
#define ENB_CONFIG_STRING_S1SETUP_REQ_COUNT "s1setup_req_count"
#define ENB_CONFIG_STRING_SCTP_REQ_TIMER "sctp_req_timer"
#define ENB_CONFIG_STRING_SCTP_REQ_COUNT "sctp_req_count"
/*-----------------------------------------------------------------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------------------*/
/* cell configuration parameters */ /* cell configuration parameters */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
...@@ -239,6 +244,11 @@ typedef enum { ...@@ -239,6 +244,11 @@ typedef enum {
{ENB_CONFIG_STRING_X2, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_X2, NULL, 0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0}, \
{ENB_CONFIG_STRING_ENB_M2, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_ENB_M2, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0}, \
{ENB_CONFIG_STRING_MCE_M2, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0}, \ {ENB_CONFIG_STRING_MCE_M2, NULL, 0, strptr:NULL, defstrval:"no", TYPE_STRING, 0}, \
{ENB_CONFIG_STRING_S1SETUP_RSP_TIMER, NULL, 0, uptr:NULL, defuintval:5, TYPE_UINT, 0}, \
{ENB_CONFIG_STRING_S1SETUP_REQ_TIMER, NULL, 0, uptr:NULL, defuintval:5, TYPE_UINT, 0}, \
{ENB_CONFIG_STRING_S1SETUP_REQ_COUNT, NULL, 0, uptr:NULL, defuintval:65535, TYPE_UINT, 0}, \
{ENB_CONFIG_STRING_SCTP_REQ_TIMER, NULL, 0, uptr:NULL, defuintval:180, TYPE_UINT, 0}, \
{ENB_CONFIG_STRING_SCTP_REQ_COUNT, NULL, 0, uptr:NULL, defuintval:65535, TYPE_UINT, 0}, \
} }
#define ENB_ENB_ID_IDX 0 #define ENB_ENB_ID_IDX 0
...@@ -261,6 +271,11 @@ typedef enum { ...@@ -261,6 +271,11 @@ typedef enum {
#define ENB_ENABLE_X2 17 #define ENB_ENABLE_X2 17
#define ENB_ENABLE_ENB_M2 18 #define ENB_ENABLE_ENB_M2 18
#define ENB_ENABLE_MCE_M2 19 #define ENB_ENABLE_MCE_M2 19
#define ENB_S1SETUP_RSP_TIMER_IDX 20
#define ENB_S1SETUP_REQ_TIMER_IDX 21
#define ENB_S1SETUP_REQ_COUNT_IDX 22
#define ENB_SCTP_REQ_TIMER_IDX 23
#define ENB_SCTP_REQ_COUNT_IDX 24
#define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD} #define TRACKING_AREA_CODE_OKRANGE {0x0001,0xFFFD}
#define ENBPARAMS_CHECK { \ #define ENBPARAMS_CHECK { \
......
...@@ -84,7 +84,7 @@ extern int asn1_xer_print; ...@@ -84,7 +84,7 @@ extern int asn1_xer_print;
break; \ break; \
} \ } \
} \ } \
if (mandatory) DevAssert(ie != NULL); \ /* if (mandatory) DevAssert(ie != NULL); \*/ \
} while(0) } while(0)
/** \brief Function callback prototype. /** \brief Function callback prototype.
......
...@@ -536,6 +536,14 @@ int x2ap_eNB_handle_x2_setup_response(instance_t instance, ...@@ -536,6 +536,14 @@ int x2ap_eNB_handle_x2_setup_response(instance_t instance,
return -1; return -1;
} }
if((x2ap_eNB_data->state == X2AP_ENB_STATE_CONNECTED) ||
(x2ap_eNB_data->state == X2AP_ENB_STATE_READY))
{
X2AP_ERROR("Received Unexpexted X2 Setup Response Message\n");
return -1;
}
X2AP_DEBUG("Received a new X2 setup response\n"); X2AP_DEBUG("Received a new X2 setup response\n");
X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_X2SetupResponse_IEs_t, ie, x2SetupResponse, X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_X2SetupResponse_IEs_t, ie, x2SetupResponse,
...@@ -662,6 +670,14 @@ int x2ap_eNB_handle_x2_setup_failure(instance_t instance, ...@@ -662,6 +670,14 @@ int x2ap_eNB_handle_x2_setup_failure(instance_t instance,
return -1; return -1;
} }
if((x2ap_eNB_data->state == X2AP_ENB_STATE_CONNECTED) ||
(x2ap_eNB_data->state == X2AP_ENB_STATE_READY))
{
X2AP_ERROR("Received Unexpexted X2 Setup Failure Message\n");
return -1;
}
X2AP_DEBUG("Received a new X2 setup failure\n"); X2AP_DEBUG("Received a new X2 setup failure\n");
X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_X2SetupFailure_IEs_t, ie, x2SetupFailure, X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_X2SetupFailure_IEs_t, ie, x2SetupFailure,
...@@ -730,6 +746,7 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance, ...@@ -730,6 +746,7 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance,
X2AP_ProtocolIE_ID_id_Old_eNB_UE_X2AP_ID, true); X2AP_ProtocolIE_ID_id_Old_eNB_UE_X2AP_ID, true);
if (ie == NULL ) { if (ie == NULL ) {
X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
return -1; return -1;
} }
...@@ -750,7 +767,11 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance, ...@@ -750,7 +767,11 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance,
//measResultListEUTRA.list.array[ncell_index]->physCellId; //measResultListEUTRA.list.array[ncell_index]->physCellId;
X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_HandoverRequest_IEs_t, ie, x2HandoverRequest, X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_HandoverRequest_IEs_t, ie, x2HandoverRequest,
X2AP_ProtocolIE_ID_id_GUMMEI_ID, true); X2AP_ProtocolIE_ID_id_GUMMEI_ID, true);
if (ie == NULL ) {
X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
return -1;
}
TBCD_TO_MCC_MNC(&ie->value.choice.ECGI.pLMN_Identity, X2AP_HANDOVER_REQ(msg).ue_gummei.mcc, TBCD_TO_MCC_MNC(&ie->value.choice.ECGI.pLMN_Identity, X2AP_HANDOVER_REQ(msg).ue_gummei.mcc,
X2AP_HANDOVER_REQ(msg).ue_gummei.mnc, X2AP_HANDOVER_REQ(msg).ue_gummei.mnc_len); X2AP_HANDOVER_REQ(msg).ue_gummei.mnc, X2AP_HANDOVER_REQ(msg).ue_gummei.mnc_len);
OCTET_STRING_TO_INT8(&ie->value.choice.GUMMEI.mME_Code, X2AP_HANDOVER_REQ(msg).ue_gummei.mme_code); OCTET_STRING_TO_INT8(&ie->value.choice.GUMMEI.mME_Code, X2AP_HANDOVER_REQ(msg).ue_gummei.mme_code);
...@@ -761,6 +782,7 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance, ...@@ -761,6 +782,7 @@ int x2ap_eNB_handle_handover_preparation (instance_t instance,
if (ie == NULL ) { if (ie == NULL ) {
X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
return -1; return -1;
} }
...@@ -872,6 +894,7 @@ int x2ap_eNB_handle_handover_response (instance_t instance, ...@@ -872,6 +894,7 @@ int x2ap_eNB_handle_handover_response (instance_t instance,
if (ie == NULL ) { if (ie == NULL ) {
X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
return -1; return -1;
} }
...@@ -882,6 +905,7 @@ int x2ap_eNB_handle_handover_response (instance_t instance, ...@@ -882,6 +905,7 @@ int x2ap_eNB_handle_handover_response (instance_t instance,
if (ie == NULL ) { if (ie == NULL ) {
X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
return -1; return -1;
} }
...@@ -912,6 +936,7 @@ int x2ap_eNB_handle_handover_response (instance_t instance, ...@@ -912,6 +936,7 @@ int x2ap_eNB_handle_handover_response (instance_t instance,
if (ie == NULL ) { if (ie == NULL ) {
X2AP_ERROR("%s %d: ie is a NULL pointer \n", __FILE__, __LINE__); X2AP_ERROR("%s %d: ie is a NULL pointer \n", __FILE__, __LINE__);
itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
return -1; return -1;
}else{ }else{
if (ie->value.choice.E_RABs_Admitted_List.list.count > 0) { if (ie->value.choice.E_RABs_Admitted_List.list.count > 0) {
...@@ -959,6 +984,12 @@ int x2ap_eNB_handle_handover_response (instance_t instance, ...@@ -959,6 +984,12 @@ int x2ap_eNB_handle_handover_response (instance_t instance,
X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_HandoverRequestAcknowledge_IEs_t, ie, x2HandoverRequestAck, X2AP_FIND_PROTOCOLIE_BY_ID(X2AP_HandoverRequestAcknowledge_IEs_t, ie, x2HandoverRequestAck,
X2AP_ProtocolIE_ID_id_TargeteNBtoSource_eNBTransparentContainer, true); X2AP_ProtocolIE_ID_id_TargeteNBtoSource_eNBTransparentContainer, true);
if (ie == NULL ) {
X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
return -1;
}
X2AP_TargeteNBtoSource_eNBTransparentContainer_t *c = &ie->value.choice.TargeteNBtoSource_eNBTransparentContainer; 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 */) if (c->size > 1024 /* TODO: this is the size of rrc_buffer in struct x2ap_handover_req_ack_s */)
...@@ -1012,6 +1043,7 @@ int x2ap_eNB_handle_ue_context_release (instance_t instance, ...@@ -1012,6 +1043,7 @@ int x2ap_eNB_handle_ue_context_release (instance_t instance,
if (ie == NULL ) { if (ie == NULL ) {
X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
return -1; return -1;
} }
...@@ -1022,6 +1054,7 @@ int x2ap_eNB_handle_ue_context_release (instance_t instance, ...@@ -1022,6 +1054,7 @@ int x2ap_eNB_handle_ue_context_release (instance_t instance,
if (ie == NULL ) { if (ie == NULL ) {
X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__); X2AP_ERROR("%s %d: ie is a NULL pointer \n",__FILE__,__LINE__);
itti_free(ITTI_MSG_ORIGIN_ID(msg), msg);
return -1; return -1;
} }
......
...@@ -106,7 +106,12 @@ extern int asn1_xer_print; ...@@ -106,7 +106,12 @@ extern int asn1_xer_print;
if (ie == NULL ) { \ if (ie == NULL ) { \
S1AP_ERROR("S1AP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL\n",__FILE__,__LINE__);\ S1AP_ERROR("S1AP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL\n",__FILE__,__LINE__);\
} \ } \
if (mandatory) DevAssert(ie != NULL); \ if (mandatory) { \
if (ie == NULL) { \
S1AP_ERROR("S1AP_FIND_PROTOCOLIE_BY_ID: %s %d: ie is NULL\n",__FILE__,__LINE__);\
return -1; \
} \
} \
} while(0) } while(0)
/** \brief Function callback prototype. /** \brief Function callback prototype.
**/ **/
......
This diff is collapsed.
...@@ -166,6 +166,10 @@ typedef struct s1ap_eNB_mme_data_s { ...@@ -166,6 +166,10 @@ typedef struct s1ap_eNB_mme_data_s {
struct s1ap_eNB_instance_s *s1ap_eNB_instance; struct s1ap_eNB_instance_s *s1ap_eNB_instance;
uint32_t nb_calls; uint32_t nb_calls;
net_ip_address_t mme_ip_address;
long timer_id;
uint16_t s1_setupreq_cnt;
uint16_t sctp_req_cnt;
} s1ap_eNB_mme_data_t; } s1ap_eNB_mme_data_t;
typedef struct s1ap_eNB_instance_s { typedef struct s1ap_eNB_instance_s {
...@@ -218,6 +222,14 @@ typedef struct s1ap_eNB_instance_s { ...@@ -218,6 +222,14 @@ typedef struct s1ap_eNB_instance_s {
/* Default Paging DRX of the eNB as defined in TS 36.304 */ /* Default Paging DRX of the eNB as defined in TS 36.304 */
paging_drx_t default_drx; paging_drx_t default_drx;
net_ip_address_t enb_ip_address;
uint16_t s1_setuprsp_wait_timer;
uint16_t s1_setupreq_wait_timer;
uint16_t s1_setupreq_count;
uint16_t sctp_req_timer;
uint16_t sctp_req_count;
uint16_t sctp_in_streams;
uint16_t sctp_out_streams;
} s1ap_eNB_instance_t; } s1ap_eNB_instance_t;
typedef struct { typedef struct {
......
This diff is collapsed.
...@@ -95,12 +95,15 @@ struct s1ap_eNB_mme_data_s *s1ap_eNB_get_MME( ...@@ -95,12 +95,15 @@ struct s1ap_eNB_mme_data_s *s1ap_eNB_get_MME(
{ {
struct s1ap_eNB_mme_data_s temp; struct s1ap_eNB_mme_data_s temp;
struct s1ap_eNB_mme_data_s *found; struct s1ap_eNB_mme_data_s *found;
struct s1ap_eNB_mme_data_s *mme_p;
memset(&temp, 0, sizeof(struct s1ap_eNB_mme_data_s)); memset(&temp, 0, sizeof(struct s1ap_eNB_mme_data_s));
temp.assoc_id = assoc_id; temp.assoc_id = assoc_id;
temp.cnx_id = cnx_id; temp.cnx_id = cnx_id;
if( cnx_id != 0 )
{
if (instance_p == NULL) { if (instance_p == NULL) {
STAILQ_FOREACH(instance_p, &s1ap_eNB_internal_data.s1ap_eNB_instances_head, STAILQ_FOREACH(instance_p, &s1ap_eNB_internal_data.s1ap_eNB_instances_head,
s1ap_eNB_entries) { s1ap_eNB_entries) {
...@@ -113,6 +116,34 @@ struct s1ap_eNB_mme_data_s *s1ap_eNB_get_MME( ...@@ -113,6 +116,34 @@ struct s1ap_eNB_mme_data_s *s1ap_eNB_get_MME(
} else { } else {
return RB_FIND(s1ap_mme_map, &instance_p->s1ap_mme_head, &temp); return RB_FIND(s1ap_mme_map, &instance_p->s1ap_mme_head, &temp);
} }
}
else
{
if (instance_p == NULL)
{
STAILQ_FOREACH(instance_p, &s1ap_eNB_internal_data.s1ap_eNB_instances_head,
s1ap_eNB_entries)
{
RB_FOREACH(mme_p, s1ap_mme_map, &instance_p->s1ap_mme_head)
{
if( mme_p->assoc_id == assoc_id )
{
return mme_p;
}
}
}
}
else
{
RB_FOREACH(mme_p, s1ap_mme_map, &instance_p->s1ap_mme_head)
{
if( mme_p->assoc_id == assoc_id )
{
return mme_p;
}
}
}
}
return NULL; return NULL;
} }
......
...@@ -359,10 +359,18 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id, ...@@ -359,10 +359,18 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id,
container = &pdu->choice.initiatingMessage.value.choice.DownlinkNASTransport; container = &pdu->choice.initiatingMessage.value.choice.DownlinkNASTransport;
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID, true);
if(ie == NULL)
{
return -1;
}
mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID; mme_ue_s1ap_id = ie->value.choice.MME_UE_S1AP_ID;
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true); S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID, true);
if(ie == NULL)
{
return -1;
}
enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID; enb_ue_s1ap_id = ie->value.choice.ENB_UE_S1AP_ID;
if ((ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance, if ((ue_desc_p = s1ap_eNB_get_ue_context(s1ap_eNB_instance,
...@@ -417,6 +425,10 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id, ...@@ -417,6 +425,10 @@ int s1ap_eNB_handle_nas_downlink(uint32_t assoc_id,
S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container, S1AP_FIND_PROTOCOLIE_BY_ID(S1AP_DownlinkNASTransport_IEs_t, ie, container,
S1AP_ProtocolIE_ID_id_NAS_PDU, true); S1AP_ProtocolIE_ID_id_NAS_PDU, true);
if(ie == NULL)
{
return -1;
}
/* Forward the NAS PDU to RRC */ /* Forward the NAS PDU to RRC */
s1ap_eNB_itti_send_nas_downlink_ind(s1ap_eNB_instance->instance, s1ap_eNB_itti_send_nas_downlink_ind(s1ap_eNB_instance->instance,
ue_desc_p->ue_initial_id, ue_desc_p->ue_initial_id,
......
...@@ -62,6 +62,10 @@ int s1ap_eNB_handle_overload_start(uint32_t assoc_id, ...@@ -62,6 +62,10 @@ int s1ap_eNB_handle_overload_start(uint32_t assoc_id,
S1AP_OverloadResponse_PR_overloadAction, S1AP_OverloadResponse_PR_overloadAction,
S1AP_OverloadResponse_PR_overloadAction, 0, 0); S1AP_OverloadResponse_PR_overloadAction, 0, 0);
} }
else
{
return -1;
}
/* Non UE-associated signalling -> stream 0 */ /* Non UE-associated signalling -> stream 0 */
if (stream != 0) { if (stream != 0) {
S1AP_ERROR("[SCTP %d] Received s1 overload start on stream != 0 (%d)\n", S1AP_ERROR("[SCTP %d] Received s1 overload start on stream != 0 (%d)\n",
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include "assertions.h"
#include "intertask_interface.h"
#include "s1ap_eNB_timer.h"
#include "common/utils/LOG/log.h"
#include "queue.h"
#include "s1ap_common.h"
struct s1ap_timer_elm_s {
task_id_t task_id; ///< Task ID which has requested the timer
int32_t instance; ///< Instance of the task which has requested the timer
uint32_t timer_kind; ///< Instance of the task which has requested the timer
timer_t timer; ///< Unique timer id
timer_type_t type; ///< Timer type
void *timer_arg; ///< Optional argument that will be passed when timer expires
STAILQ_ENTRY(s1ap_timer_elm_s) entries; ///< Pointer to next element
};
typedef struct timer_desc_s {
STAILQ_HEAD(timer_list_head, s1ap_timer_elm_s) timer_queue;
pthread_mutex_t timer_list_mutex;
struct timespec timeout;
} timer_desc_t;
static timer_desc_t timer_desc;
#define TIMER_SEARCH(vAR, tIMERfIELD, tIMERvALUE, tIMERqUEUE) \
do { \
STAILQ_FOREACH(vAR, tIMERqUEUE, entries) { \
if (((vAR)->tIMERfIELD == tIMERvALUE)) \
break; \
} \
} while(0)
int s1ap_timer_timeout(sigval_t info)
{
struct s1ap_timer_elm_s *timer_p;
MessageDef *message_p;
s1ap_timer_has_expired_t *timer_expired_p;
task_id_t task_id;
int32_t instance;
uint32_t timer_kind;
timer_kind = info.sival_int;
if( pthread_mutex_lock(&timer_desc.timer_list_mutex) != 0 )
{
S1AP_ERROR("Failed to mutex lock timeout=%x\n", timer_kind);
return -1;
}
TIMER_SEARCH(timer_p, timer_kind, timer_kind, &timer_desc.timer_queue);
if( pthread_mutex_unlock(&timer_desc.timer_list_mutex) != 0 )
{
S1AP_ERROR("Failed to mutex unlock timeout=%x\n", timer_kind);
}
if (timer_p == NULL)
{
S1AP_ERROR("Didn't find timer 0x%lx in list\n", timer_kind);
return -1;
}
S1AP_DEBUG("Timer kind 0x%x has expired\n", timer_kind);
task_id = timer_p->task_id;
instance = timer_p->instance;
message_p = itti_alloc_new_message(TASK_UNKNOWN, TIMER_HAS_EXPIRED);
timer_expired_p = &message_p->ittiMsg.timer_has_expired;
timer_expired_p->timer_id = (long)timer_p->timer;
timer_expired_p->timer_kind = timer_p->timer_kind;
timer_expired_p->arg = timer_p->timer_arg;
/* Timer is a one shot timer, remove it */
if( timer_p->type == S1AP_TIMER_ONE_SHOT )
{
if( s1ap_timer_remove((long)timer_p->timer) != 0 )
{
S1AP_DEBUG("Failed to delete timer 0x%lx\n", (long)timer_p->timer);
}
}
/* Notify task of timer expiry */
if( itti_send_msg_to_task(task_id, instance, message_p) < 0 )
{
S1AP_ERROR("Failed to send msg TIMER_HAS_EXPIRED to task %u\n", task_id);
free(message_p);
return -1;
}
return 0;
}
int s1ap_timer_setup(
uint32_t interval_sec,
uint32_t interval_us,
task_id_t task_id,
int32_t instance,
uint32_t timer_kind,
timer_type_t type,
void *timer_arg,
long *timer_id)
{
struct sigevent evp;
struct itimerspec its;
struct s1ap_timer_elm_s *timer_p;
timer_t timer;
if( timer_id == NULL )
{
S1AP_ERROR("Invalid timer_id\n");
return -1;
}
if( type >= S1AP_TIMER_TYPE_MAX )
{
S1AP_ERROR("Invalid timer type (%d/%d)!\n", type, TIMER_TYPE_MAX);
return -1;
}
if( *timer_id != S1AP_TIMERID_INIT )
{
if( s1ap_timer_remove(*timer_id) != 0 )
{
S1AP_ERROR("Failed to delete timer when the timer start 0x%lx\n", *timer_id);
}
}
/* Allocate new timer list element */
timer_p = malloc(sizeof(struct s1ap_timer_elm_s));
if( timer_p == NULL )
{
S1AP_ERROR("Failed to create new timer element\n");
return -1;
}
memset(&timer, 0, sizeof(timer_t));
memset(&evp, 0, sizeof(evp));
timer_p->task_id = task_id;
timer_p->instance = instance;
timer_p->timer_kind = timer_kind;
timer_p->type = type;
timer_p->timer_arg = timer_arg;
evp.sigev_notify = (int)SIGEV_THREAD;
evp.sigev_notify_function = (void *)s1ap_timer_timeout;
evp.sigev_signo = SIGRTMIN;
evp.sigev_notify_attributes = NULL;
evp.sigev_value.sival_int = timer_kind;
/* At the timer creation, the timer structure will be filled in with timer_id,
* which is unique for this process. This id is allocated by kernel and the
* value might be used to distinguish timers.
*/
if( timer_create(CLOCK_REALTIME, &evp, &timer) < 0 )
{
S1AP_ERROR("Failed to create timer: (%s:%d)\n", strerror(errno), errno);
free(timer_p);
return -1;
}
/* Fill in the first expiration value. */
its.it_value.tv_sec = interval_sec;
its.it_value.tv_nsec = interval_us * 1000;
if( type == S1AP_TIMER_PERIODIC )
{
/* Asked for periodic timer. We set the interval time */
its.it_interval.tv_sec = interval_sec;
its.it_interval.tv_nsec = interval_us * 1000;
}
else
{
/* Asked for one-shot timer. Do not set the interval field */
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = 0;
}
if( timer_settime(timer, 0, &its, NULL) )
{
S1AP_ERROR("Failed to Settimer: (%s:%d)\n", strerror(errno), errno);
free(timer_p);
return -1;
}
/* Simply set the timer_id argument. so it can be used by caller */
*timer_id = (long)timer;
timer_p->timer = timer;
/* Lock the queue and insert the timer at the tail */
if( pthread_mutex_lock(&timer_desc.timer_list_mutex) != 0 )
{
S1AP_ERROR("Failed to mutex lock\n");
if( timer_delete(timer_p->timer) < 0 )
{
S1AP_ERROR("Failed to delete timer 0x%lx\n", (long)timer_p->timer);
}
free(timer_p);
timer_p = NULL;
return -1;
}
STAILQ_INSERT_TAIL(&timer_desc.timer_queue, timer_p, entries);
if( pthread_mutex_unlock(&timer_desc.timer_list_mutex) != 0 )
{
S1AP_ERROR("Failed to mutex unlock\n");
}
return 0;
}
int s1ap_timer_remove(long timer_id)
{
int rc = 0;
struct s1ap_timer_elm_s *timer_p;
if( pthread_mutex_lock(&timer_desc.timer_list_mutex) != 0 )
{
S1AP_ERROR("Failed to mutex lock\n");
if( timer_delete(timer_id) < 0 )
{
S1AP_ERROR("Failed to delete timer 0x%lx\n", (long)timer_id);
}
return -1;
}
TIMER_SEARCH(timer_p, timer, ((timer_t)timer_id), &timer_desc.timer_queue);
/* We didn't find the timer in list */
if (timer_p == NULL)
{
S1AP_ERROR("Didn't find timer 0x%lx in list\n", timer_id);
if( pthread_mutex_unlock(&timer_desc.timer_list_mutex) != 0 )
{
S1AP_ERROR("Failed to mutex unlock\n");
}
return -1;
}
timer_delete(timer_p->timer);
STAILQ_REMOVE(&timer_desc.timer_queue, timer_p, s1ap_timer_elm_s, entries);
if( pthread_mutex_unlock(&timer_desc.timer_list_mutex) != 0 )
{
S1AP_ERROR("Failed to mutex unlock\n");
}
free(timer_p);
timer_p = NULL;
return rc;
}
int s1ap_timer_init(void)
{
memset(&timer_desc, 0, sizeof(timer_desc_t));
STAILQ_INIT(&timer_desc.timer_queue);
pthread_mutex_init(&timer_desc.timer_list_mutex, NULL);
return 0;
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#ifndef TIMER_H_
#define TIMER_H_
#include <signal.h>
#define SIGTIMER SIGRTMIN
typedef enum s1ap_timer_type_s {
S1AP_TIMER_PERIODIC,
S1AP_TIMER_ONE_SHOT,
S1AP_TIMER_TYPE_MAX,
} s1ap_timer_type_t;
typedef struct {
void *arg;
long timer_id;
int32_t timer_kind;
} s1ap_timer_has_expired_t;
int s1ap_timer_timeout(sigval_t info);
/** \brief Request a new timer
* \param interval_sec timer interval in seconds
* \param interval_us timer interval in micro seconds
* \param task_id task id of the task requesting the timer
* \param instance instance of the task requesting the timer
* \param type timer type
* \param timer_id unique timer identifier
* @returns -1 on failure, 0 otherwise
**/
int s1ap_timer_setup(
uint32_t interval_sec,
uint32_t interval_us,
task_id_t task_id,
int32_t instance,
uint32_t timer_kind,
timer_type_t type,
void *timer_arg,
long *timer_id);
/** \brief Remove the timer from list
* \param timer_id unique timer id
* @returns -1 on failure, 0 otherwise
**/
int s1ap_timer_remove(long timer_id);
/** \brief Initialize timer task and its API
* \param mme_config MME common configuration
* @returns -1 on failure, 0 otherwise
**/
int s1ap_timer_init(void);
#define S1AP_MMEIND 0x80000000
#define S1AP_UEIND 0x00000000
#define S1_SETRSP_WAIT 0x00010000
#define S1_SETREQ_WAIT 0x00020000
#define SCTP_REQ_WAIT 0x00030000
#define S1AP_LINEIND 0x0000ffff
#define S1AP_TIMERIND 0x00ff0000
#define S1AP_TIMERID_INIT 0xffffffffffffffff
#endif
...@@ -121,6 +121,10 @@ int s1ap_eNB_handle_trace_start(uint32_t assoc_id, ...@@ -121,6 +121,10 @@ int s1ap_eNB_handle_trace_start(uint32_t assoc_id,
if (ie != NULL) { if (ie != NULL) {
ue_desc_p = s1ap_eNB_get_ue_context(mme_ref_p->s1ap_eNB_instance, ue_desc_p = s1ap_eNB_get_ue_context(mme_ref_p->s1ap_eNB_instance,
ie->value.choice.ENB_UE_S1AP_ID); ie->value.choice.ENB_UE_S1AP_ID);
}
else
{
return -1;
} }
if (ue_desc_p == NULL) { if (ue_desc_p == NULL) {
/* Could not find context associated with this eNB_ue_s1ap_id -> generate /* Could not find context associated with this eNB_ue_s1ap_id -> generate
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#define SCTP_OUT_STREAMS (16) #define SCTP_OUT_STREAMS (16)
#define SCTP_IN_STREAMS (16) #define SCTP_IN_STREAMS (16)
#define SCTP_MAX_ATTEMPTS (2) #define SCTP_MAX_ATTEMPTS (8)
#define SCTP_TIMEOUT (5) #define SCTP_TIMEOUT (60000)
#define SCTP_RECV_BUFFER_SIZE (8192) #define SCTP_RECV_BUFFER_SIZE (8192)
#endif /* SCTP_DEFAULT_VALUES_H_ */ #endif /* SCTP_DEFAULT_VALUES_H_ */
...@@ -943,10 +943,12 @@ sctp_eNB_read_from_socket( ...@@ -943,10 +943,12 @@ sctp_eNB_read_from_socket(
&sinfo, &flags); &sinfo, &flags);
if (n < 0) { if (n < 0) {
if (errno == ENOTCONN) { if( (errno == ENOTCONN) || (errno == ECONNRESET) || (errno == ETIMEDOUT) || (errno == ECONNREFUSED) )
{
itti_unsubscribe_event_fd(TASK_SCTP, sctp_cnx->sd); itti_unsubscribe_event_fd(TASK_SCTP, sctp_cnx->sd);
SCTP_DEBUG("Received not connected for sd %d\n", sctp_cnx->sd); SCTP_DEBUG("Received not connected for sd %d\n", sctp_cnx->sd);
SCTP_ERROR("sctp_recvmsg (fd %d, len %d ): %s:%d\n", sctp_cnx->sd, n, strerror(errno), errno);
sctp_itti_send_association_resp( sctp_itti_send_association_resp(
sctp_cnx->task_id, sctp_cnx->instance, -1, sctp_cnx->task_id, sctp_cnx->instance, -1,
......
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