Commit 366b06c8 authored by Cedric Roux's avatar Cedric Roux

- Fixed handling of non success result for S1AP/SCTP new association

- Handled not connected state in SCTP when recvmsg returns -1

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4416 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 9414363c
......@@ -89,8 +89,8 @@ void *mme_app_thread(void *args)
}
} break;
case TERMINATE_MESSAGE: {
/* Termination message received -> release any data allocated */
/* Termination message received TODO -> release any data allocated */
itti_exit_task();
} break;
default: {
MME_APP_DEBUG("Unkwnon message ID %d:%s\n",
......
......@@ -194,6 +194,7 @@ void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_associa
sctp_new_association_resp->sctp_state,
instance,
sctp_new_association_resp->ulp_cnx_id);
return;
}
/* Update parameters */
......
......@@ -16,7 +16,7 @@
#define SCTP_OUT_STREAMS (64)
#define SCTP_IN_STREAMS (64)
#define SCTP_MAX_ATTEMPTS (5)
#define SCTP_MAX_ATTEMPTS (2)
#define SCTP_RECV_BUFFER_SIZE (1024)
#endif /* S1AP_ENB_DEFAULT_VALUES_H_ */
......@@ -240,8 +240,12 @@ void sctp_handle_new_association_req(
sctp_itti_send_association_resp(
requestor, instance, -1, sctp_new_association_req_p->ulp_cnx_id,
SCTP_STATE_UNREACHABLE, 0, 0);
/* Add the socket to list of fd monitored by ITTI */
itti_unsubscribe_event_fd(TASK_SCTP, sd);
close(sd);
return;
} else {
SCTP_DEBUG("connectx in progress...\n");
}
}
} else {
......@@ -406,8 +410,23 @@ inline void sctp_eNB_read_from_socket(struct sctp_cnx_list_elm_s *sctp_cnx)
(struct sockaddr *)&addr, &from_len,
&sinfo, &flags);
if (n < 0) {
SCTP_DEBUG("An error occured during read\n");
SCTP_ERROR("sctp_recvmsg: %s:%d\n", strerror(errno), errno);
if (errno == ENOTCONN) {
itti_unsubscribe_event_fd(TASK_SCTP, sctp_cnx->sd);
sctp_itti_send_association_resp(
sctp_cnx->task_id, sctp_cnx->instance, -1,
sctp_cnx->cnx_id, SCTP_STATE_UNREACHABLE, 0, 0);
close(sctp_cnx->sd);
sctp_nb_cnx--;
free(sctp_cnx);
} else {
SCTP_DEBUG("An error occured during read\n");
SCTP_ERROR("sctp_recvmsg: %s:%d\n", strerror(errno), errno);
}
return;
} else if (n == 0) {
SCTP_DEBUG("return of sctp_recvmsg is 0...\n");
return;
}
if (flags & MSG_NOTIFICATION) {
......@@ -419,9 +438,19 @@ inline void sctp_eNB_read_from_socket(struct sctp_cnx_list_elm_s *sctp_cnx)
/* Client deconnection */
if (SCTP_SHUTDOWN_EVENT == snp->sn_header.sn_type) {
DevMessage("Other peer has requested a com down -> not handled\n");
// return sctp_handle_com_down(snp->sn_shutdown_event.sse_assoc_id);
itti_unsubscribe_event_fd(TASK_SCTP, sctp_cnx->sd);
close(sctp_cnx->sd);
sctp_itti_send_association_resp(
sctp_cnx->task_id, sctp_cnx->instance, sctp_cnx->assoc_id,
sctp_cnx->cnx_id, SCTP_STATE_SHUTDOWN,
0, 0);
STAILQ_REMOVE(&sctp_cnx_list, sctp_cnx, sctp_cnx_list_elm_s, entries);
sctp_nb_cnx--;
free(sctp_cnx);
}
/* Association has changed. */
else if (SCTP_ASSOC_CHANGE == snp->sn_header.sn_type) {
......@@ -515,7 +544,8 @@ void *sctp_eNB_task(void *arg)
/* Check if there is a packet to handle */
if (received_msg != NULL) {
switch (ITTI_MSG_ID(received_msg)) {
switch (ITTI_MSG_ID(received_msg))
{
case TERMINATE_MESSAGE:
itti_exit_task();
break;
......@@ -530,8 +560,8 @@ void *sctp_eNB_task(void *arg)
&received_msg->msg.sctp_data_req);
} break;
default:
SCTP_ERROR("Received unhandled message with id %d\n",
ITTI_MSG_ID(received_msg));
SCTP_ERROR("Received unhandled message %d:%s\n",
ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
break;
}
}
......
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