Added new HSS class to compute the authentication vectors.

This commit is contained in:
Pedro Alvarez 2017-10-26 14:20:29 +01:00
parent e7d6ea530f
commit ef73254707
7 changed files with 161 additions and 38 deletions

76
srsepc/hdr/hss/hss.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: hss.h
* Description: Top-level HSS class. Creates and links all
* interfaces and helpers.
*****************************************************************************/
#ifndef HSS_H
#define HSS_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"
namespace srsepc{
typedef struct{
std::string ue_file;
}hss_args_t;
class hss
{
public:
static hss* get_instance(void);
static void cleanup(void);
int init(hss_args_t *hss_args, srslte::logger* logger);
private:
hss();
virtual ~hss();
static hss *m_instance;
srslte::byte_buffer_pool *m_pool;
/*Logs*/
srslte::logger_stdout m_logger_stdout;
srslte::logger_file m_logger_file;
srslte::logger *m_logger;
srslte::log_filter m_hss_log;
};
} // namespace srsepc
#endif // MME_H

View File

@ -44,18 +44,20 @@
namespace srsepc{
/*
typedef struct {
std::string s1ap_level;
std::string all_level;
int s1ap_hex_limit;
std::string filename;
}log_args_t;
*/
typedef struct{
s1ap_args_t s1ap_args;
log_args_t log_args;
} all_args_t;
//diameter_args_t diameter_args;
//gtpc_args_t gtpc_args;
} mme_args_t;
class mme:
@ -64,7 +66,7 @@ class mme:
public:
static mme* get_instance(void);
static void cleanup(void);
int init(all_args_t* args);
int init(mme_args_t* args, srslte::logger *logger);
void stop();
int get_s1_mme();
void run_thread();
@ -80,8 +82,8 @@ private:
srslte::byte_buffer_pool *m_pool;
/*Logs*/
srslte::logger_stdout m_logger_stdout;
srslte::logger_file m_logger_file;
//srslte::logger_stdout m_logger_stdout;
//srslte::logger_file m_logger_file;
srslte::logger *m_logger;
srslte::log_filter m_s1ap_log;

View File

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

View File

@ -0,0 +1,24 @@
#
# 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_hss STATIC ${SOURCES})
install(TARGETS srsepc_hss DESTINATION ${LIBRARY_DIR})

View File

@ -24,21 +24,15 @@
*
*/
#include <iostream> //TODO Remove
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/sctp.h>
#include <boost/thread/mutex.hpp>
#include "mme/mme.h"
#include "hss/hss.h"
namespace srsepc{
hss* hss::m_instance = NULL;
boost::mutex hss_instance_mutex;
hss::hss():
m_running(false)
hss::hss()
{
m_pool = srslte::byte_buffer_pool::get_instance();
return;
@ -70,24 +64,14 @@ hss::cleanup(void)
}
int
hss::init(all_args_t* args)
hss::init(hss_args_t *hss_args, srslte::logger *logger)
{
/*Init loggers*/
if (!args->log_args.filename.compare("stdout")) {
m_logger = &m_logger_stdout;
} else {
m_logger_file.init(args->log_args.filename);
m_logger_file.log("\n--- Software Radio Systems HSS log ---\n\n");
m_logger = &m_logger_file;
}
m_logger=logger;
m_hss_log.init("HSS", m_logger);
m_hss_log.set_level(srslte::LOG_LEVEL_DEBUG);
m_hss_log.set_hex_limit(32);
if(m_hss.init(args->s1ap_args, &m_s1ap_log)){
m_hss_log.error("Error initializing MME S1APP\n");
exit(-1);
}
m_hss_log.info("Initialized HSS\n");
m_hss_log.console("Initialized HSS\n");
return 0;

View File

@ -27,6 +27,7 @@
#include <boost/program_options.hpp>
#include "srslte/common/bcd_helpers.h"
#include "mme/mme.h"
#include "hss/hss.h"
using namespace std;
using namespace srsepc;
@ -39,6 +40,19 @@ sig_int_handler(int signo){
running = false;
}
typedef struct {
std::string all_level;
int hex_limit;
std::string filename;
}log_args_t;
typedef struct{
mme_args_t mme_args;
hss_args_t hss_args;
log_args_t log_args;
}all_args_t;
/**********************************************************************
* Program arguments processing
***********************************************************************/
@ -103,29 +117,29 @@ parse_args(all_args_t *args, int argc, char* argv[]) {
{
std::stringstream sstr;
sstr << std::hex << vm["mme.mme_group"].as<std::string>();
sstr >> args->s1ap_args.mme_group;
sstr >> args->mme_args.s1ap_args.mme_group;
}
{
std::stringstream sstr;
sstr << std::hex << vm["mme.mme_code"].as<std::string>();
uint16_t tmp; // Need intermediate uint16_t as uint8_t is treated as char
sstr >> tmp;
args->s1ap_args.mme_code = tmp;
args->mme_args.s1ap_args.mme_code = tmp;
}
{
std::stringstream sstr;
sstr << std::hex << vm["mme.tac"].as<std::string>();
sstr >> args->s1ap_args.tac;
sstr >> args->mme_args.s1ap_args.tac;
}
// Convert MCC/MNC strings
if(!srslte::string_to_mcc(mcc, &args->s1ap_args.mcc)) {
if(!srslte::string_to_mcc(mcc, &args->mme_args.s1ap_args.mcc)) {
cout << "Error parsing enb.mcc:" << mcc << " - must be a 3-digit string." << endl;
}
if(!srslte::string_to_mnc(mnc, &args->s1ap_args.mnc)) {
if(!srslte::string_to_mnc(mnc, &args->mme_args.s1ap_args.mnc)) {
cout << "Error parsing enb.mnc:" << mnc << " - must be a 2 or 3-digit string." << endl;
}
args->s1ap_args.mme_bind_addr = mme_bind_addr;
args->mme_args.s1ap_args.mme_bind_addr = mme_bind_addr;
return;
}
@ -138,14 +152,34 @@ main (int argc,char * argv[] )
all_args_t args;
parse_args(&args, argc, argv);
args.log_args.filename = std::string("/tmp/epc.log");
srslte::logger_stdout logger_stdout;
srslte::logger_file logger_file;
srslte::logger *logger;
/*Init logger*/
args.log_args.filename = std::string("/tmp/epc.log"); //FIXME
if (!args.log_args.filename.compare("stdout")) {
logger = &logger_stdout;
} else {
logger_file.init(args.log_args.filename);
logger_file.log("\n--- Software Radio Systems EPC log ---\n\n");
logger = &logger_file;
}
mme *mme = mme::get_instance();
if (mme->init(&args)) {
if (mme->init(&args.mme_args, logger)) {
cout << "Error initializing MME" << endl;
exit(1);
}
hss *hss = hss::get_instance();
if (hss->init(&args.hss_args,logger)) {
cout << "Error initializing HSS" << endl;
exit(1);
}
mme->start();
while(running) {

View File

@ -70,9 +70,10 @@ mme::cleanup(void)
}
int
mme::init(all_args_t* args)
mme::init(mme_args_t* args, srslte::logger *logger)
{
/*Init loggers*/
/*
if (!args->log_args.filename.compare("stdout")) {
m_logger = &m_logger_stdout;
} else {
@ -80,7 +81,7 @@ mme::init(all_args_t* args)
m_logger_file.log("\n--- Software Radio Systems MME log ---\n\n");
m_logger = &m_logger_file;
}
*/
m_s1ap_log.init("S1AP", m_logger);
m_s1ap_log.set_level(srslte::LOG_LEVEL_DEBUG);
m_s1ap_log.set_hex_limit(32);