Added TUN SGi interface to SP-GW.

master
Pedro Alvarez 7 years ago
parent eac3ee26c1
commit f9b2c6434a

@ -68,6 +68,7 @@ private:
bool m_running;
srslte::byte_buffer_pool *m_pool;
bool m_if_up;
int m_sgi_if;
int m_sgi_sock;
/*Logs*/

@ -29,6 +29,7 @@
#include "srslte/common/bcd_helpers.h"
#include "mme/mme.h"
#include "hss/hss.h"
#include "spgw/spgw.h"
using namespace std;
using namespace srsepc;
@ -51,6 +52,7 @@ typedef struct {
typedef struct{
mme_args_t mme_args;
hss_args_t hss_args;
spgw_args_t spgw_args;
log_args_t log_args;
}all_args_t;
@ -198,6 +200,11 @@ main (int argc,char * argv[] )
hss_log.set_level(srslte::LOG_LEVEL_DEBUG);
hss_log.set_hex_limit(32);
srslte::log_filter spgw_log;
spgw_log.init("SPGW",logger);
spgw_log.set_level(srslte::LOG_LEVEL_DEBUG);
spgw_log.set_hex_limit(32);
mme *mme = mme::get_instance();
if (mme->init(&args.mme_args, &s1ap_log)) {
cout << "Error initializing MME" << endl;
@ -210,14 +217,23 @@ main (int argc,char * argv[] )
exit(1);
}
spgw *spgw = spgw::get_instance();
if (spgw->init(&args.spgw_args,&spgw_log)) {
cout << "Error initializing SP-GW" << endl;
exit(1);
}
mme->start();
spgw->start();
while(running) {
sleep(1);
}
mme->stop();
mme->cleanup();
spgw->stop();
spgw->cleanup();
cout << "--- exiting ---" << endl;
cout << std::endl <<"--- exiting ---" << endl;
return 0;
}

@ -40,7 +40,8 @@ spgw* spgw::m_instance = NULL;
boost::mutex spgw_instance_mutex;
spgw::spgw():
m_running(false)
m_running(false),
m_if_up(false)
{
m_pool = srslte::byte_buffer_pool::get_instance();
return;
@ -92,6 +93,13 @@ spgw::stop()
m_running = false;
thread_cancel();
wait_thread_finish();
//Clean up interface
if(m_if_up)
{
close(m_sgi_if);
close(m_sgi_sock);
}
}
return;
}
@ -114,6 +122,12 @@ spgw::init_sgi_if()
char dev[IFNAMSIZ] = "srs_spgw_sgi";
struct ifreq ifr;
if(m_if_up)
{
return(srslte::ERROR_ALREADY_STARTED);
}
// Construct the TUN device
m_sgi_if = open("/dev/net/tun", O_RDWR);
m_spgw_log->info("TUN file descriptor = %d\n", m_sgi_if);
@ -149,10 +163,8 @@ spgw::init_sgi_if()
return(srslte::ERROR_CANT_START);
}
//if_up = true;
m_if_up = true;
return(srslte::ERROR_NONE);
}
} //namespace srsepc

Loading…
Cancel
Save