Commit 394fca1b authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup

parent 789c6c85
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*file except in compliance with the License. You may obtain a copy of the
*License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! file
brief
author Jian Yang,Fengjiao He,Hongxin Wang
date 2020
email: contact@openairinterface.org
*/
#include "logger.hpp"
#include "options.hpp"
#include "udr_config.hpp"
#include "udr_server.hpp"
using namespace config;
udr_config udr_cfg;
int main(int argc, char **argv) {
if (!Options::parse(argc, argv)) {
std::cout << "Options::parse() failed" << std::endl;
return 1;
}
Logger::init("UDR", Options::getlogStdout(), Options::getlogRotFilelog());
Logger::udr_app().startup("Options parsed!");
// add config file
udr_cfg.load(Options::getlibconfigConfig());
udr_cfg.display();
Logger::udr_app().debug("Initiating UDR server endpoints");
// Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(8080));
Pistache::Address addr(udr_cfg.nudr.addr4, Pistache::Port(udr_cfg.nudr.port));
MYSQL mysql;
mysql_init(&mysql);
if (!mysql_real_connect(&mysql, udr_cfg.mysql.mysql_server.c_str(),
udr_cfg.mysql.mysql_user.c_str(),
udr_cfg.mysql.mysql_pass.c_str(),
udr_cfg.mysql.mysql_db.c_str(), 0, 0, 0)) {
Logger::udr_app().error("An error occurred while connecting to db: %s",
mysql_error(&mysql));
return 0;
}
UDRApiServer udrApiServer(addr, &mysql);
udrApiServer.init(PISTACHE_SERVER_THREADS);
std::thread udr_api_manager(&UDRApiServer::start, udrApiServer);
Logger::udr_app().debug("Initiating Done!");
pause();
mysql_close(&mysql);
return 0;
}
cmake_minimum_required (VERSION 3.2)
project(udr)
if (CMAKE_OPENXGUDR_BUILD_TYPE STREQUAL Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -DDEBUG_IS_ON=1 -DTRACE_IS_ON=1 -DINFO_IS_ON=1")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif()
include(ExternalProject)
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_OPENXGUDR_DIR}/build/ext)
set(SRC_DIR ${CMAKE_OPENXGUDR_DIR}/src)
include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
include_directories(${SRC_DIR}/model)
include_directories(${SRC_DIR}/api)
include_directories(${SRC_DIR}/impl)
include_directories(${SRC_DIR}/common)
include_directories(${SRC_DIR}/udr_app)
# ${CMAKE_CURRENT_SOURCE_DIR}
file(GLOB SRCS
${SRC_DIR}/api/*.cpp
${SRC_DIR}/impl/*.cpp
${SRC_DIR}/model/*.cpp
${SRC_DIR}/common/*.cpp
${SRC_DIR}/udr_app/*.cpp
${EXTERNAL_INSTALL_LOCATION}/build/src/spdlog/*.cpp
)
add_executable(${PROJECT_NAME} ${SRCS} )
target_link_libraries(${PROJECT_NAME} pistache pthread mysqlclient config++)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment