From bc447a32fe47c49da94d35f1e1df43b0aad89dd8 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 20 Oct 2017 17:05:52 +0100 Subject: [PATCH] Addind the mechanisms to cleanup eNB when SCTP connection is terminated. --- srsepc/src/mme/mme.cc | 19 ++++++++++++++++--- srsepc/src/mme/s1ap.cc | 4 +++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/srsepc/src/mme/mme.cc b/srsepc/src/mme/mme.cc index 65fa1a922..ebab43e1e 100644 --- a/srsepc/src/mme/mme.cc +++ b/srsepc/src/mme/mme.cc @@ -136,9 +136,22 @@ mme::run_thread() m_s1ap_log.debug("Socket timeout reached"); } else{ - pdu->N_bytes = rd_sz; - m_s1ap_log.info("Received S1AP msg. Size: %d\n", pdu->N_bytes); - m_s1ap.handle_s1ap_rx_pdu(pdu,&sri); + if(msg_flags & MSG_NOTIFICATION) + { + //Received notification + m_s1ap_log.console("SCTP Notification %d\n", ((union sctp_notification*)pdu->msg)->sn_header.sn_type); + if (((union sctp_notification*)pdu->msg)->sn_header.sn_type == SCTP_SHUTDOWN_EVENT) + { + m_s1ap_log.console("SCTP Association Gracefully Shutdown\n"); + } + } + else + { + //Received data + pdu->N_bytes = rd_sz; + m_s1ap_log.info("Received S1AP msg. Size: %d\n", pdu->N_bytes); + m_s1ap.handle_s1ap_rx_pdu(pdu,&sri); + } } } return; diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 4abbd5dc4..6fa3382b2 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -62,7 +62,7 @@ s1ap::stop() std::map::iterator it = m_active_enbs.begin(); while(it!=m_active_enbs.end()) { - //print_enb_ctx_info(*it->second); + print_enb_ctx_info(*it->second); delete it->second; m_active_enbs.erase(it++); } @@ -91,8 +91,10 @@ s1ap::enb_listen() } //Sets the data_io_event to be able to use sendrecv_info + //Subscribes to the SCTP_SHUTDOWN event, to handle graceful shutdown bzero (&evnts, sizeof (evnts)) ; evnts.sctp_data_io_event = 1; + evnts.sctp_shutdown_event=1; if(setsockopt(sock_fd, IPPROTO_SCTP, SCTP_EVENTS, &evnts, sizeof (evnts))){ m_s1ap_log->console("Subscribing to sctp_data_io_events failed\n"); return -1;