Starting to cleanup S1AP

master
Pedro Alvarez 7 years ago
parent 9f79b4167f
commit da7c105a29

@ -53,8 +53,6 @@ const uint16_t S1MME_PORT = 36412;
class s1ap
{
public:
s1ap();
virtual ~s1ap();
static s1ap* get_instance();
static void cleanup();
@ -93,15 +91,17 @@ public:
void print_enb_ctx_info(const enb_ctx_t &enb_ctx);
srslte::log_filter *m_s1ap_log;
private:
s1ap();
virtual ~s1ap();
static s1ap *m_instance;
s1ap_args_t m_s1ap_args;
uint32_t m_plmn;
srslte::byte_buffer_pool *m_pool;
srslte::logger *m_logger;
srslte::log_filter *m_s1ap_log;
hss *m_hss;
int m_s1mme;
@ -111,7 +111,7 @@ private:
std::map<uint16_t,std::set<uint32_t> > m_enb_id_to_ue_ids;
uint32_t m_next_mme_ue_s1ap_id;
s1ap_mngmt_proc m_s1ap_mngmt_proc;
s1ap_mngmt_proc* m_s1ap_mngmt_proc;
s1ap_nas_transport m_s1ap_nas_transport;
//FIXME the GTP-C should be moved to the MME class, the the packaging of GTP-C messages is done.

@ -29,18 +29,34 @@
#include "srslte/asn1/liblte_s1ap.h"
#include "srslte/common/common.h"
#include "mme/s1ap_common.h"
#include "srslte/common/log_filter.h"
namespace srsepc{
class s1ap;
class s1ap_mngmt_proc
{
public:
s1ap_mngmt_proc();
virtual ~s1ap_mngmt_proc();
static s1ap_mngmt_proc *m_instance;
static s1ap_mngmt_proc* get_instance(void);
static void cleanup(void);
void init(void);
//Packing/unpacking helper functions
bool unpack_s1_setup_request(LIBLTE_S1AP_MESSAGE_S1SETUPREQUEST_STRUCT *msg, enb_ctx_t* enb_ctx);
bool pack_s1_setup_failure(LIBLTE_S1AP_CAUSEMISC_ENUM cause, srslte::byte_buffer_t* msg);
bool pack_s1_setup_response(s1ap_args_t s1ap_args, srslte::byte_buffer_t* msg);
private:
s1ap_mngmt_proc();
virtual ~s1ap_mngmt_proc();
s1ap* m_parent;
srslte::log_filter *m_s1ap_log;
};
} //namespace srsepc

@ -66,7 +66,6 @@ s1ap::cleanup(void)
}
}
int
s1ap::init(s1ap_args_t s1ap_args, srslte::log_filter *s1ap_log)
{
@ -75,12 +74,22 @@ s1ap::init(s1ap_args_t s1ap_args, srslte::log_filter *s1ap_log)
m_s1ap_args = s1ap_args;
srslte::s1ap_mccmnc_to_plmn(s1ap_args.mcc, s1ap_args.mnc, &m_plmn);
//Init log
m_s1ap_log = s1ap_log;
m_s1ap_nas_transport.set_log(s1ap_log);
//Init message handlers
m_s1ap_mngmt_proc = s1ap_mngmt_proc::get_instance(); //Managment procedures (TS )
m_s1ap_mngmt_proc->init();
m_s1ap_nas_transport = s1ap_nas_transport::get_instance(); //NAS Transport procedures
m_s1ap_nas_transport->init();
//Get pointer to the HSS
m_hss = hss::get_instance();
//Get pointer to GTP-C class
m_mme_gtpc = mme_gtpc::get_instance();
//Initialize S1-MME
m_s1mme = enb_listen();
m_s1ap_log->info("S1AP Initialized\n");
@ -102,6 +111,10 @@ s1ap::stop()
delete it->second;
m_active_enbs.erase(it++);
}
//Cleanup message handlers
s1ap_mngmt_proc::cleanup();
s1ap_nas_transport::cleanup();
return;
}
@ -272,6 +285,8 @@ s1ap::handle_successful_outcome(LIBLTE_S1AP_SUCCESSFULOUTCOME_STRUCT *msg)
}
return true;
}
bool
s1ap::handle_s1_setup_request(LIBLTE_S1AP_MESSAGE_S1SETUPREQUEST_STRUCT *msg, struct sctp_sndrcvinfo *enb_sri)
{
@ -282,7 +297,7 @@ s1ap::handle_s1_setup_request(LIBLTE_S1AP_MESSAGE_S1SETUPREQUEST_STRUCT *msg, st
LIBLTE_S1AP_S1AP_PDU_STRUCT reply_pdu;
if(!m_s1ap_mngmt_proc.unpack_s1_setup_request(msg, &enb_ctx))
if(!m_s1ap_mngmt_proc->unpack_s1_setup_request(msg, &enb_ctx))
{
m_s1ap_log->error("Malformed S1 Setup Request\n");
return false;
@ -296,7 +311,7 @@ s1ap::handle_s1_setup_request(LIBLTE_S1AP_MESSAGE_S1SETUPREQUEST_STRUCT *msg, st
if(enb_ctx.plmn!=m_plmn){
m_s1ap_log->console("Sending S1 Setup Failure - Unkown PLMN\n");
m_s1ap_log->info("Sending S1 Setup Failure - Unkown PLMN\n");
m_s1ap_mngmt_proc.pack_s1_setup_failure(LIBLTE_S1AP_CAUSEMISC_UNKNOWN_PLMN,&reply_msg);
m_s1ap_mngmt_proc->pack_s1_setup_failure(LIBLTE_S1AP_CAUSEMISC_UNKNOWN_PLMN,&reply_msg);
}
else{
std::map<uint16_t,enb_ctx_t*>::iterator it = m_active_enbs.find(enb_ctx.enb_id);
@ -316,7 +331,7 @@ s1ap::handle_s1_setup_request(LIBLTE_S1AP_MESSAGE_S1SETUPREQUEST_STRUCT *msg, st
m_enb_id_to_ue_ids.insert(std::pair<uint16_t,std::set<uint32_t> >(enb_ptr->enb_id,ue_set));
}
m_s1ap_mngmt_proc.pack_s1_setup_response(m_s1ap_args, &reply_msg);
m_s1ap_mngmt_proc->pack_s1_setup_response(m_s1ap_args, &reply_msg);
m_s1ap_log->console("Sending S1 Setup Response\n");
m_s1ap_log->info("Sending S1 Setup Response\n");
}

@ -31,6 +31,10 @@
namespace srsepc{
s1ap_mngmt_proc* s1ap_mngmt_proc::m_instance = NULL;
boost::mutex s1ap_mngmt_proc_instance_mutex;
s1ap_mngmt_proc::s1ap_mngmt_proc()
{
}
@ -39,6 +43,96 @@ s1ap_mngmt_proc::~s1ap_mngmt_proc()
{
}
s1ap_mngmt_proc*
s1ap_mngmt_proc::get_instance(void)
{
boost::mutex::scoped_lock lock(s1ap_mngmt_proc_instance_mutex);
if(NULL == m_instance) {
m_instance = new s1ap_mngmt_proc();
}
return(m_instance);
}
void
s1ap_mngmt_proc::cleanup(void)
{
boost::mutex::scoped_lock lock(s1ap_mngmt_proc_instance_mutex);
if(NULL != m_instance) {
delete m_instance;
m_instance = NULL;
}
}
void
s1ap_mngmt_proc::init(void)
{
m_parent = s1ap::get_instance();
m_s1ap_log = m_parent->m_s1ap_log;
}
/*
bool
s1ap_mngmt_proc::handle_s1_setup_request(LIBLTE_S1AP_MESSAGE_S1SETUPREQUEST_STRUCT *msg, struct sctp_sndrcvinfo *enb_sri)
{
std::string mnc_str, mcc_str;
enb_ctx_t enb_ctx;
srslte::byte_buffer_t reply_msg;
LIBLTE_S1AP_S1AP_PDU_STRUCT reply_pdu;
if(!m_s1ap_mngmt_proc.unpack_s1_setup_request(msg, &enb_ctx))
{
m_s1ap_log->error("Malformed S1 Setup Request\n");
return false;
}
//Log S1 Setup Request Info
m_s1ap_log->console("Received S1 Setup Request. Association: %d\n",enb_sri->sinfo_assoc_id);
print_enb_ctx_info(enb_ctx);
//Check matching PLMNs
if(enb_ctx.plmn!=m_plmn){
m_s1ap_log->console("Sending S1 Setup Failure - Unkown PLMN\n");
m_s1ap_log->info("Sending S1 Setup Failure - Unkown PLMN\n");
m_s1ap_mngmt_proc.pack_s1_setup_failure(LIBLTE_S1AP_CAUSEMISC_UNKNOWN_PLMN,&reply_msg);
}
else{
std::map<uint16_t,enb_ctx_t*>::iterator it = m_active_enbs.find(enb_ctx.enb_id);
if(it != m_active_enbs.end())
{
//eNB already registered
//TODO replace enb_ctx
}
else
{
//new eNB
std::set<uint32_t> ue_set;
enb_ctx_t *enb_ptr = new enb_ctx_t;
memcpy(enb_ptr,&enb_ctx,sizeof(enb_ctx));
m_active_enbs.insert(std::pair<uint16_t,enb_ctx_t*>(enb_ptr->enb_id,enb_ptr));
m_sctp_to_enb_id.insert(std::pair<int32_t,uint16_t>(enb_sri->sinfo_assoc_id, enb_ptr->enb_id));
m_enb_id_to_ue_ids.insert(std::pair<uint16_t,std::set<uint32_t> >(enb_ptr->enb_id,ue_set));
}
m_s1ap_mngmt_proc.pack_s1_setup_response(m_s1ap_args, &reply_msg);
m_s1ap_log->console("Sending S1 Setup Response\n");
m_s1ap_log->info("Sending S1 Setup Response\n");
}
//Send Reply to eNB
ssize_t n_sent = sctp_send(m_s1mme,reply_msg.msg, reply_msg.N_bytes, enb_sri, 0);
if(n_sent == -1)
{
m_s1ap_log->console("Failed to send S1 Setup Setup Reply");
return false;
}
return true;
}
*/
/*
* Packing/Unpacking helper functions.
*/
bool
s1ap_mngmt_proc::unpack_s1_setup_request(LIBLTE_S1AP_MESSAGE_S1SETUPREQUEST_STRUCT *msg, enb_ctx_t* enb_ctx)
{

Loading…
Cancel
Save