2017-10-09 10:36:40 -07:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \section COPYRIGHT
|
|
|
|
*
|
|
|
|
* Copyright 2013-2017 Software Radio Systems Limited
|
|
|
|
*
|
|
|
|
* \section LICENSE
|
|
|
|
*
|
|
|
|
* This file is part of srsLTE.
|
|
|
|
*
|
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
2018-03-31 10:04:04 -07:00
|
|
|
#ifndef SRSEPC_S1AP_H
|
|
|
|
#define SRSEPC_S1AP_H
|
2017-10-19 06:47:41 -07:00
|
|
|
|
2017-11-27 07:38:10 -08:00
|
|
|
#include "srslte/asn1/gtpc.h"
|
2017-10-12 13:53:48 -07:00
|
|
|
#include "srslte/asn1/liblte_s1ap.h"
|
2017-10-25 11:17:36 -07:00
|
|
|
#include "srslte/asn1/liblte_mme.h"
|
2017-10-13 11:19:45 -07:00
|
|
|
#include "srslte/common/common.h"
|
2017-10-11 08:18:47 -07:00
|
|
|
#include "srslte/common/log.h"
|
2017-10-09 10:36:40 -07:00
|
|
|
|
2017-10-19 06:47:41 -07:00
|
|
|
#include <strings.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/sctp.h>
|
|
|
|
#include <unistd.h>
|
2017-10-20 06:16:19 -07:00
|
|
|
#include <map>
|
2017-11-10 07:21:56 -08:00
|
|
|
#include <set>
|
2018-04-01 09:08:24 -07:00
|
|
|
#include "s1ap_common.h"
|
|
|
|
#include "s1ap_mngmt_proc.h"
|
|
|
|
#include "s1ap_nas_transport.h"
|
|
|
|
#include "s1ap_ctx_mngmt_proc.h"
|
|
|
|
#include "mme_gtpc.h"
|
|
|
|
#include "srsepc/hdr/hss/hss.h"
|
2017-10-19 06:47:41 -07:00
|
|
|
|
2017-10-09 11:35:00 -07:00
|
|
|
namespace srsepc{
|
|
|
|
|
2017-10-10 09:32:34 -07:00
|
|
|
const uint16_t S1MME_PORT = 36412;
|
|
|
|
|
2017-10-09 10:36:40 -07:00
|
|
|
class s1ap
|
|
|
|
{
|
|
|
|
public:
|
2017-11-27 07:38:10 -08:00
|
|
|
|
|
|
|
static s1ap* get_instance();
|
|
|
|
static void cleanup();
|
|
|
|
|
2017-11-22 03:52:37 -08:00
|
|
|
int enb_listen();
|
2018-01-28 07:56:39 -08:00
|
|
|
int init(s1ap_args_t s1ap_args, srslte::log_filter *s1ap_log, hss_interface_s1ap * hss_);
|
2017-10-11 04:22:02 -07:00
|
|
|
void stop();
|
2017-10-10 09:32:34 -07:00
|
|
|
|
|
|
|
int get_s1_mme();
|
2017-11-22 03:52:37 -08:00
|
|
|
|
2017-11-09 09:43:40 -08:00
|
|
|
void delete_enb_ctx(int32_t assoc_id);
|
2017-11-10 07:21:56 -08:00
|
|
|
|
2017-10-17 04:32:34 -07:00
|
|
|
bool handle_s1ap_rx_pdu(srslte::byte_buffer_t *pdu, struct sctp_sndrcvinfo *enb_sri);
|
2017-10-19 06:47:41 -07:00
|
|
|
bool handle_initiating_message(LIBLTE_S1AP_INITIATINGMESSAGE_STRUCT *msg, struct sctp_sndrcvinfo *enb_sri);
|
2017-12-21 16:14:42 -08:00
|
|
|
bool handle_successful_outcome(LIBLTE_S1AP_SUCCESSFULOUTCOME_STRUCT *msg);
|
2017-10-12 13:53:48 -07:00
|
|
|
|
2018-03-07 10:48:08 -08:00
|
|
|
void activate_eps_bearer(uint64_t imsi, uint8_t ebi);
|
2017-12-06 12:18:11 -08:00
|
|
|
|
2017-12-20 02:45:55 -08:00
|
|
|
void print_enb_ctx_info(const std::string &prefix, const enb_ctx_t &enb_ctx);
|
2017-10-19 06:47:41 -07:00
|
|
|
|
2017-12-20 02:45:55 -08:00
|
|
|
uint32_t get_plmn();
|
2017-12-20 07:28:10 -08:00
|
|
|
uint32_t get_next_mme_ue_s1ap_id();
|
2017-12-20 02:45:55 -08:00
|
|
|
enb_ctx_t* find_enb_ctx(uint16_t enb_id);
|
2017-12-20 07:28:10 -08:00
|
|
|
void add_new_enb_ctx(const enb_ctx_t &enb_ctx, const struct sctp_sndrcvinfo* enb_sri);
|
2018-04-16 06:54:55 -07:00
|
|
|
void get_enb_ctx(uint16_t sctp_stream);
|
2018-02-05 07:33:16 -08:00
|
|
|
|
2018-03-14 11:07:07 -07:00
|
|
|
bool add_ue_ctx_to_imsi_map(ue_ctx_t *ue_ctx);
|
|
|
|
bool add_ue_ctx_to_mme_ue_s1ap_id_map(ue_ctx_t *ue_ctx);
|
2018-04-18 03:28:01 -07:00
|
|
|
bool add_ue_to_enb_set(int32_t enb_assoc, uint32_t mme_ue_s1ap_id);
|
2018-03-14 06:36:20 -07:00
|
|
|
|
2018-03-14 04:14:44 -07:00
|
|
|
ue_ctx_t* find_ue_ctx_from_imsi(uint64_t imsi);
|
|
|
|
ue_ctx_t* find_ue_ctx_from_mme_ue_s1ap_id(uint32_t mme_ue_s1ap_id);
|
2018-02-05 07:33:16 -08:00
|
|
|
|
2018-03-14 06:36:20 -07:00
|
|
|
bool release_ue_ecm_ctx(uint32_t mme_ue_s1ap_id);
|
2018-04-18 03:28:01 -07:00
|
|
|
void release_ues_ecm_ctx_in_enb(int32_t enb_assoc);
|
2018-03-14 06:36:20 -07:00
|
|
|
bool delete_ue_ctx(uint64_t imsi);
|
|
|
|
|
2018-02-08 05:57:30 -08:00
|
|
|
uint32_t allocate_m_tmsi(uint64_t imsi);
|
2018-01-10 03:35:08 -08:00
|
|
|
|
2017-12-20 02:45:55 -08:00
|
|
|
s1ap_args_t m_s1ap_args;
|
2017-12-19 08:54:44 -08:00
|
|
|
srslte::log_filter *m_s1ap_log;
|
|
|
|
|
2017-12-27 08:21:30 -08:00
|
|
|
s1ap_mngmt_proc* m_s1ap_mngmt_proc;
|
2018-02-27 05:33:43 -08:00
|
|
|
s1ap_nas_transport* m_s1ap_nas_transport;
|
|
|
|
s1ap_ctx_mngmt_proc* m_s1ap_ctx_mngmt_proc;
|
2017-12-27 08:21:30 -08:00
|
|
|
|
2018-02-12 08:19:31 -08:00
|
|
|
std::map<uint32_t, uint64_t> m_tmsi_to_imsi;
|
2018-01-10 03:35:08 -08:00
|
|
|
|
2017-10-10 09:32:34 -07:00
|
|
|
private:
|
2017-12-19 08:54:44 -08:00
|
|
|
s1ap();
|
|
|
|
virtual ~s1ap();
|
2017-10-20 03:45:45 -07:00
|
|
|
|
2017-11-27 07:38:10 -08:00
|
|
|
static s1ap *m_instance;
|
|
|
|
|
2017-11-06 11:10:57 -08:00
|
|
|
uint32_t m_plmn;
|
|
|
|
srslte::byte_buffer_pool *m_pool;
|
2017-10-11 08:18:47 -07:00
|
|
|
|
2018-01-28 07:56:39 -08:00
|
|
|
hss_interface_s1ap *m_hss;
|
2017-10-10 09:32:34 -07:00
|
|
|
int m_s1mme;
|
2017-12-01 09:41:45 -08:00
|
|
|
std::map<uint16_t, enb_ctx_t*> m_active_enbs;
|
|
|
|
std::map<int32_t, uint16_t> m_sctp_to_enb_id;
|
2018-04-18 03:28:01 -07:00
|
|
|
std::map<int32_t,std::set<uint32_t> > m_enb_assoc_to_ue_ids;
|
2018-02-05 07:33:16 -08:00
|
|
|
|
2018-03-14 04:14:44 -07:00
|
|
|
std::map<uint64_t, ue_ctx_t*> m_imsi_to_ue_ctx;
|
|
|
|
std::map<uint32_t, ue_ctx_t*> m_mme_ue_s1ap_id_to_ue_ctx;
|
|
|
|
|
2017-12-01 09:41:45 -08:00
|
|
|
uint32_t m_next_mme_ue_s1ap_id;
|
2018-01-10 03:35:08 -08:00
|
|
|
uint32_t m_next_m_tmsi;
|
2017-11-22 03:52:37 -08:00
|
|
|
|
2018-02-05 04:26:23 -08:00
|
|
|
//FIXME the GTP-C should be moved to the MME class, when the packaging of GTP-C messages is done.
|
2017-11-24 10:20:14 -08:00
|
|
|
mme_gtpc *m_mme_gtpc;
|
2017-10-09 11:35:00 -07:00
|
|
|
};
|
|
|
|
|
2017-12-20 02:45:55 -08:00
|
|
|
inline uint32_t
|
|
|
|
s1ap::get_plmn()
|
|
|
|
{
|
|
|
|
return m_plmn;
|
|
|
|
}
|
2017-10-13 11:19:45 -07:00
|
|
|
|
|
|
|
|
2017-10-09 11:35:00 -07:00
|
|
|
} //namespace srsepc
|
2017-10-19 06:47:41 -07:00
|
|
|
|
2018-03-31 10:04:04 -07:00
|
|
|
#endif // SRSEPC_S1AP_H
|