Starting to add S-GW

This commit is contained in:
Pedro Alvarez 2017-11-13 16:42:41 +00:00
parent 46edf6feab
commit 042cabc8a0
5 changed files with 203 additions and 23 deletions

View File

@ -1,23 +0,0 @@
#####################################################################
# srsEPC configuration file
#####################################################################
#####################################################################
# MME configuration
#
# mme_code: 8-bit MME code identifies the MME within a group.
# mme_group: 16-bit MME group identifier.
# tac: 16-bit Tracking Area Code.
# mcc: Mobile Country Code
# mnc: Mobile Network Code
# mme_bindx_addr: IP subnet to listen for eNB S1 connnections
#
#####################################################################
[mme]
mme_code = 0x19
mme_group = 0x0001
phy_cell_id = 1
tac = 0x0001
mcc = 208
mnc = 93
mme_bindx_addr = 127.0.0.0/24

76
srsepc/hdr/sgw/sgw.h Normal file
View File

@ -0,0 +1,76 @@
/**
*
* \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/.
*
*/
/******************************************************************************
* File: sgw.h
* Description: Top-level S-GW class. Creates and links all
* interfaces and helpers.
*****************************************************************************/
#ifndef SGW_H
#define SGW_H
#include <cstddef>
#include "srslte/common/log.h"
#include "srslte/common/logger_file.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/threads.h"
namespace srsepc{
typedef struct {
std::string gtpc_bind_addr;
} sgw_args_t;
class sgw:
public thread
{
public:
static sgw* get_instance(void);
static void cleanup(void);
int init(sgw_args_t* args, srslte::log_filter *sgw_log);
void stop();
void run_thread();
private:
sgw();
virtual ~sgw();
static sgw *m_instance;
bool m_running;
srslte::byte_buffer_pool *m_pool;
/*Logs*/
srslte::log_filter *m_sgw_log;
};
} // namespace srsepc
#endif // SGW_H

View File

@ -1,6 +1,7 @@
add_subdirectory(mme) add_subdirectory(mme)
add_subdirectory(hss) add_subdirectory(hss)
add_subdirectory(sgw)
# Link libstdc++ and libgcc # Link libstdc++ and libgcc
if(BUILD_STATIC) if(BUILD_STATIC)
@ -16,6 +17,7 @@ endif (RPATH)
add_executable(srsepc main.cc ) add_executable(srsepc main.cc )
target_link_libraries(srsepc srsepc_mme target_link_libraries(srsepc srsepc_mme
srsepc_hss srsepc_hss
srsepc_sgw
srslte_upper srslte_upper
srslte_common srslte_common
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}

View File

@ -0,0 +1,23 @@
#
# Copyright 2013-2017 Software Radio Systems Limited
#
# 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/.
#
file(GLOB SOURCES "*.cc")
add_library(srsepc_sgw STATIC ${SOURCES})
install(TARGETS srsepc_sgw DESTINATION ${LIBRARY_DIR})

102
srsepc/src/sgw/sgw.cc Normal file
View File

@ -0,0 +1,102 @@
/**
*
* \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/.
*
*/
#include <iostream>
#include <boost/thread/mutex.hpp>
#include "sgw/sgw.h"
namespace srsepc{
sgw* sgw::m_instance = NULL;
boost::mutex sgw_instance_mutex;
sgw::sgw():
m_running(false)
{
m_pool = srslte::byte_buffer_pool::get_instance();
return;
}
sgw::~sgw()
{
return;
}
sgw*
sgw::get_instance(void)
{
boost::mutex::scoped_lock lock(sgw_instance_mutex);
if(NULL == m_instance) {
m_instance = new sgw();
}
return(m_instance);
}
void
sgw::cleanup(void)
{
boost::mutex::scoped_lock lock(sgw_instance_mutex);
if(NULL != m_instance) {
delete m_instance;
m_instance = NULL;
}
}
int
sgw::init(sgw_args_t* args, srslte::log_filter *sgw_log)
{
m_sgw_log = sgw_log;
m_sgw_log->info("S-GW Initialized.\n");
m_sgw_log->console("S-GW Initialized.\n");
return 0;
}
void
sgw::stop()
{
if(m_running)
{
m_running = false;
thread_cancel();
wait_thread_finish();
}
return;
}
void
sgw::run_thread()
{
//Mark the thread as running
m_running=true;
while (m_running)
{
sleep(1);
}
return;
}
} //namespace srsepc