diff --git a/srsepc/hdr/mme/s1ap.h b/srsepc/hdr/mme/s1ap.h index f8c6cee28..4cb8385e0 100644 --- a/srsepc/hdr/mme/s1ap.h +++ b/srsepc/hdr/mme/s1ap.h @@ -67,6 +67,7 @@ public: void delete_enb_ctx(int32_t assoc_id); + bool s1ap_tx_pdu(srslte::byte_buffer_t *pdu, struct sctp_sndrcvinfo *enb_sri); bool handle_s1ap_rx_pdu(srslte::byte_buffer_t *pdu, struct sctp_sndrcvinfo *enb_sri); bool handle_initiating_message(LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *msg, struct sctp_sndrcvinfo *enb_sri); bool handle_successful_outcome(LIBLTE_S1AP_SUCCESSFULOUTCOME_STRUCT *msg); diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index 1dcf756e7..7bd252233 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -186,7 +186,7 @@ s1ap::enb_listen() //S1-MME bind bzero(&s1mme_addr, sizeof(s1mme_addr)); - s1mme_addr.sin_family = AF_INET; + s1mme_addr.sin_family = AF_INET; inet_pton(AF_INET, m_s1ap_args.mme_bind_addr.c_str(), &(s1mme_addr.sin_addr) ); s1mme_addr.sin_port = htons(S1MME_PORT); err = bind(sock_fd, (struct sockaddr*) &s1mme_addr, sizeof (s1mme_addr)); @@ -209,6 +209,22 @@ s1ap::enb_listen() return sock_fd; } +bool +s1ap::s1ap_tx_pdu(srslte::byte_buffer_t *pdu, struct sctp_sndrcvinfo *enb_sri) +{ + ssize_t n_sent = sctp_send(m_s1mme, pdu->msg, pdu->N_bytes, enb_sri, 0); + if(n_sent == -1) + { + m_s1ap_log->console("Failed to send S1AP PDU.\n"); + m_s1ap_log->error("Failed to send S1AP PDU. \n"); + return false; + } + if(m_pcap_enable) + { + m_pcap.write_s1ap(pdu->msg,pdu->N_bytes); + } + return true; +} bool s1ap::handle_s1ap_rx_pdu(srslte::byte_buffer_t *pdu, struct sctp_sndrcvinfo *enb_sri) @@ -251,6 +267,7 @@ s1ap::handle_initiating_message(LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *msg, stru { bool reply_flag = false; srslte::byte_buffer_t * reply_buffer = m_pool->allocate(); + bool ret = false; switch(msg->choice_type) { case LIBLTE_S1AP_INITIATINGMESSAGE_CHOICE_S1SETUPREQUEST: @@ -276,20 +293,13 @@ s1ap::handle_initiating_message(LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *msg, stru //Send Reply to eNB if(reply_flag == true) { - ssize_t n_sent = sctp_send(m_s1mme,reply_buffer->msg, reply_buffer->N_bytes, enb_sri, 0); - if(n_sent == -1) - { - m_s1ap_log->console("Failed to send S1AP Initiating Reply.\n"); - m_s1ap_log->error("Failed to send S1AP Initiating Reply. \n"); - m_pool->deallocate(reply_buffer); - return false; - } + ret = s1ap_tx_pdu(reply_buffer, enb_sri); } m_pool->deallocate(reply_buffer); - return true; + return ret; } -bool +bool s1ap::handle_successful_outcome(LIBLTE_S1AP_SUCCESSFULOUTCOME_STRUCT *msg) { switch(msg->choice_type) { diff --git a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc index b9d599d3e..18cb6c1ac 100644 --- a/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc +++ b/srsepc/src/mme/s1ap_ctx_mngmt_proc.cc @@ -96,7 +96,7 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(ue_emm_ctx_t *emm_ctx, init->choice_type = LIBLTE_S1AP_INITIATINGMESSAGE_CHOICE_INITIALCONTEXTSETUPREQUEST; LIBLTE_S1AP_MESSAGE_INITIALCONTEXTSETUPREQUEST_STRUCT *in_ctxt_req = &init->choice.InitialContextSetupRequest; - + LIBLTE_S1AP_E_RABTOBESETUPITEMCTXTSUREQ_STRUCT *erab_ctx_req = &in_ctxt_req->E_RABToBeSetupListCtxtSUReq.buffer[0]; //FIXME support more than one erab srslte::byte_buffer_t *reply_buffer = m_pool->allocate(); @@ -178,12 +178,10 @@ s1ap_ctx_mngmt_proc::send_initial_context_setup_request(ue_emm_ctx_t *emm_ctx, return false; } - //Send Reply to eNB - ssize_t n_sent = sctp_send(s1mme,reply_buffer->msg, reply_buffer->N_bytes, &ecm_ctx->enb_sri, 0); - if(n_sent == -1) + if(!m_s1ap->s1ap_tx_pdu(reply_buffer,&ecm_ctx->enb_sri)) { - m_s1ap_log->error("Failed to send Initial Context Setup Request\n"); - return false; + m_s1ap_log->error("Error sending Initial Context Setup Request.\n"); + return false; } //Change E-RAB state to Context Setup Requested and save S-GW control F-TEID @@ -345,14 +343,12 @@ s1ap_ctx_mngmt_proc::send_ue_context_release_command(ue_ecm_ctx_t *ecm_ctx, srsl return false; } //Send Reply to eNB - int n_sent = sctp_send(s1mme,reply_buffer->msg, reply_buffer->N_bytes, &ecm_ctx->enb_sri, 0); - if(n_sent == -1) + if(!m_s1ap->s1ap_tx_pdu(reply_buffer,&ecm_ctx->enb_sri)) { - m_s1ap_log->error("Failed to send Initial Context Setup Request\n"); + m_s1ap_log->error("Error sending UE Context Release command.\n"); return false; } - return true; }