Commit e5d5d7a6 authored by sagar arora's avatar sagar arora

Merge branch 'create_authentication_data' into 'develop'

Add API for insert/delete authentication data

See merge request oai/cn5g/oai-cn5g-udr!19
parents 1196491a 27aed6ee
......@@ -6,10 +6,10 @@ UDR =
SUPPORT_FEATURES:{
# STRING, {"yes", "no"},
USE_FQDN_DNS = "@USE_FQDN_DNS@"; # Set to yes if UDR will relying on a DNS to resolve UDM's FQDN
REGISTER_NRF = "@REGISTER_NRF@"; # Set to 'yes' if UDR resgisters to an NRF
REGISTER_NRF = "@REGISTER_NRF@"; # Set to yes if UDR resgisters to an NRF
USE_HTTP2 = "@USE_HTTP2@"; # Set to yes to enable HTTP2 for UDR server
DATABASE = "MySQL"; # Set to 'MySQL'/'Cassandra' to use MySQL/Cass, enable HTTP2 for UDR server
}
INTERFACES:
......
/*
* 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
*/
/**
* Unified Data Repository Service API file for subscription data
* Unified Data Repository Service (subscription data). The API version is
* defined in 3GPP TS 29.504. © 2020, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: -
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "AuthenticationDataDocumentApi.h"
#include "Helpers.h"
#include "logger.hpp"
#include "udr_config.hpp"
extern oai::udr::config::udr_config udr_cfg;
namespace oai::udr::api {
using namespace oai::udr::helpers;
using namespace oai::udr::model;
AuthenticationDataDocumentApi::AuthenticationDataDocumentApi(
const std::shared_ptr<Pistache::Rest::Router>& rtr)
: router(rtr) {}
void AuthenticationDataDocumentApi::init() {
setupRoutes();
}
void AuthenticationDataDocumentApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Put(
*router,
base + udr_cfg.nudr.api_version +
"/subscription-data/:ueId/authentication-data/"
"authentication-subscription",
Routes::bind(
&AuthenticationDataDocumentApi::create_auth_subs_data_handler, this));
Routes::Delete(
*router,
base + udr_cfg.nudr.api_version +
"/subscription-data/:ueId/authentication-data/"
"authentication-subscription",
Routes::bind(
&AuthenticationDataDocumentApi::delete_auth_subs_data_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(
&AuthenticationDataDocumentApi::
authentication_data_document_api_default_handler,
this));
}
std::pair<Pistache::Http::Code, std::string>
AuthenticationDataDocumentApi::handleParsingException(
const std::exception& ex) const noexcept {
try {
throw;
} catch (nlohmann::detail::exception& e) {
return std::make_pair(Pistache::Http::Code::Bad_Request, e.what());
} catch (std::exception& e) {
return std::make_pair(
Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
std::pair<Pistache::Http::Code, std::string>
AuthenticationDataDocumentApi::handleOperationException(
const std::exception& ex) const noexcept {
return std::make_pair(Pistache::Http::Code::Internal_Server_Error, ex.what());
}
void AuthenticationDataDocumentApi::create_auth_subs_data_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response) {
try {
// Getting the path params
auto ueId = request.param(":ueId").as<std::string>();
// Getting the body param
AuthenticationSubscription authenticationSubscription;
try {
nlohmann::json::parse(request.body()).get_to(authenticationSubscription);
authenticationSubscription.validate();
} catch (std::exception& e) {
const std::pair<Pistache::Http::Code, std::string> errorInfo =
this->handleParsingException(e);
response.send(errorInfo.first, errorInfo.second);
return;
}
try {
this->create_auth_subs_data(ueId, authenticationSubscription, response);
} catch (Pistache::Http::HttpError& e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception& e) {
const std::pair<Pistache::Http::Code, std::string> errorInfo =
this->handleOperationException(e);
response.send(errorInfo.first, errorInfo.second);
return;
}
} catch (std::exception& e) {
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void AuthenticationDataDocumentApi::delete_auth_subs_data_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response) {
try {
// Getting the path params
auto ueId = request.param(":ueId").as<std::string>();
try {
this->delete_auth_subs_data(ueId, response);
} catch (std::exception& e) {
const std::pair<Pistache::Http::Code, std::string> errorInfo =
this->handleOperationException(e);
response.send(errorInfo.first, errorInfo.second);
return;
}
} catch (std::exception& e) {
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
}
}
void AuthenticationDataDocumentApi::
authentication_data_document_api_default_handler(
const Pistache::Rest::Request&,
Pistache::Http::ResponseWriter response) {
response.send(
Pistache::Http::Code::Not_Found, "The requested method does not exist");
}
} // namespace oai::udr::api
/*
* 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
*/
/**
* Unified Data Repository Service API file for subscription data
* Unified Data Repository Service (subscription data). The API version is
* defined in 3GPP TS 29.504. © 2020, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: -
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* AuthenticationDataDocumentApi.h
*
*
*/
#ifndef AuthenticationDataDocumentApi_H_
#define AuthenticationDataDocumentApi_H_
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <optional>
#include <utility>
#include "AuthenticationSubscription.h"
#include <string>
namespace oai::udr::api {
class AuthenticationDataDocumentApi {
public:
explicit AuthenticationDataDocumentApi(
const std::shared_ptr<Pistache::Rest::Router>& rtr);
virtual ~AuthenticationDataDocumentApi() = default;
void init();
const std::string base = "/nudr-dr/";
private:
void setupRoutes();
void create_auth_subs_data_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
void delete_auth_subs_data_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
void authentication_data_document_api_default_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
const std::shared_ptr<Pistache::Rest::Router> router;
/// <summary>
/// Helper function to handle unexpected Exceptions during Parameter parsing
/// and validation. May be overridden to return custom error formats. This is
/// called inside a catch block. Important: When overriding, do not call
/// `throw ex;`, but instead use `throw;`.
/// </summary>
virtual std::pair<Pistache::Http::Code, std::string> handleParsingException(
const std::exception& ex) const noexcept;
/// <summary>
/// Helper function to handle unexpected Exceptions during processing of the
/// request in handler functions. May be overridden to return custom error
/// formats. This is called inside a catch block. Important: When overriding,
/// do not call `throw ex;`, but instead use `throw;`.
/// </summary>
virtual std::pair<Pistache::Http::Code, std::string> handleOperationException(
const std::exception& ex) const noexcept;
/// <summary>
/// To store the authentication subscription data of a UE
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="ueId">UE id</param>
/// <param name="authenticationSubscription"> (optional)</param>
virtual void create_auth_subs_data(
const std::string& ueId,
const oai::udr::model::AuthenticationSubscription&
authenticationSubscription,
Pistache::Http::ResponseWriter& response) = 0;
/// <summary>
/// To remove the Authentication subscription data of a UE
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="ueId">UE id</param>
virtual void delete_auth_subs_data(
const std::string& ueId, Pistache::Http::ResponseWriter& response) = 0;
};
} // namespace oai::udr::api
#endif /* AuthenticationDataDocumentApi_H_ */
/*
* 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
*/
/**
* Unified Data Repository Service API file for subscription data
* Unified Data Repository Service (subscription data). The API version is
* defined in 3GPP TS 29.504. © 2020, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: -
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "AuthenticationDataDocumentApiImpl.h"
#include "logger.hpp"
#include "udr_app.hpp"
namespace oai {
namespace udr {
namespace api {
using namespace oai::udr::model;
AuthenticationDataDocumentApiImpl::AuthenticationDataDocumentApiImpl(
const std::shared_ptr<Pistache::Rest::Router>& rtr, udr_app* udr_app_inst,
std::string address)
: AuthenticationDataDocumentApi(rtr),
m_udr_app(udr_app_inst),
m_address(address) {}
void AuthenticationDataDocumentApiImpl::create_auth_subs_data(
const std::string& ueId,
const AuthenticationSubscription& authenticationSubscription,
Pistache::Http::ResponseWriter& response) {
nlohmann::json responseData = {};
Pistache::Http::Code code = {};
long httpCode = 0;
m_udr_app->handle_create_authentication_data(
ueId, authenticationSubscription, responseData, httpCode);
code = static_cast<Pistache::Http::Code>(httpCode);
Logger::udr_server().debug("HTTP Response code %d.\n", code);
response.send(code, responseData.dump().c_str());
}
void AuthenticationDataDocumentApiImpl::delete_auth_subs_data(
const std::string& ueId, Pistache::Http::ResponseWriter& response) {
nlohmann::json responseData = {};
Pistache::Http::Code code = {};
long httpCode = 0;
m_udr_app->handle_delete_authentication_data(ueId, responseData, httpCode);
code = static_cast<Pistache::Http::Code>(httpCode);
Logger::udr_server().debug("HTTP Response code %d.\n", code);
response.send(code, responseData.dump().c_str());
}
} // namespace api
} // namespace udr
} // namespace oai
/*
* 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
*/
/**
* Unified Data Repository Service API file for subscription data
* Unified Data Repository Service (subscription data). The API version is
* defined in 3GPP TS 29.504. © 2020, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: -
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* AuthenticationDataDocumentApiImpl.h
*
*
*/
#ifndef AUTHENTICATION_DATA_DOCUMENT_API_IMPL_H_
#define AUTHENTICATION_DATA_DOCUMENT_API_IMPL_H_
#include "udr_app.hpp"
#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <memory>
#include <optional>
#include <AuthenticationDataDocumentApi.h>
#include "AuthenticationSubscription.h"
#include <string>
namespace oai::udr::api {
using namespace oai::udr::model;
using namespace oai::udr::app;
class AuthenticationDataDocumentApiImpl
: public oai::udr::api::AuthenticationDataDocumentApi {
private:
udr_app* m_udr_app;
std::string m_address;
public:
explicit AuthenticationDataDocumentApiImpl(
const std::shared_ptr<Pistache::Rest::Router>& rtr, udr_app* udr_app_inst,
std::string address);
~AuthenticationDataDocumentApiImpl() override = default;
void create_auth_subs_data(
const std::string& ueId,
const AuthenticationSubscription& authenticationSubscription,
Pistache::Http::ResponseWriter& response);
void delete_auth_subs_data(
const std::string& ueId, Pistache::Http::ResponseWriter& response);
};
} // namespace oai::udr::api
#endif
......@@ -83,21 +83,22 @@ void UDRApiServer::init(size_t thr) {
// opts.maxResponseSize(PISTACHE_SERVER_MAX_RESPONSE_SIZE);
m_httpEndpoint->init(opts);
m_authenticationSubscriptionDocumentApiserver->init();
m_authenticationStatusDocumentApiserver->init();
m_accessAndMobilitySubscriptionDataDocumentApiserver->init();
m_sMFSelectionSubscriptionDataDocumentApiserver->init();
m_sessionManagementSubscriptionDataApiserver->init();
m_aMF3GPPAccessRegistrationDocumentApiserver->init();
m_sMFRegistrationDocumentApiserver->init();
m_sMFRegistrationsCollectionApiserver->init();
m_sDMSubscriptionDocumentApiserver->init();
m_sDMSubscriptionsCollectionApiserver->init();
m_authenticationSubscriptionDocumentApiServer->init();
m_authenticationDataDocumentApiServer->init();
m_authenticationStatusDocumentApiServer->init();
m_accessAndMobilitySubscriptionDataDocumentApiServer->init();
m_sMFSelectionSubscriptionDataDocumentApiServer->init();
m_sessionManagementSubscriptionDataApiServer->init();
m_aMF3GPPAccessRegistrationDocumentApiServer->init();
m_sMFRegistrationDocumentApiServer->init();
m_sMFRegistrationsCollectionApiServer->init();
m_sDMSubscriptionDocumentApiServer->init();
m_sDMSubscriptionsCollectionApiServer->init();
}
//------------------------------------------------------------------------------
void UDRApiServer::start() {
Logger::udr_server().info("HTTP1 server started");
Logger::udr_server().info("HTTP1 Server started");
m_httpEndpoint->setHandler(m_router->handler());
m_httpEndpoint->serve();
}
......
......@@ -48,6 +48,7 @@
#include "AccessAndMobilitySubscriptionDataDocumentApiImpl.h"
#include "AuthenticationStatusDocumentApiImpl.h"
#include "AuthenticationSubscriptionDocumentApiImpl.h"
#include "AuthenticationDataDocumentApiImpl.h"
#include "SDMSubscriptionDocumentApiImpl.h"
#include "SDMSubscriptionsCollectionApiImpl.h"
#include "SMFRegistrationDocumentApiImpl.h"
......@@ -69,34 +70,37 @@ class UDRApiServer {
m_router = std::make_shared<Pistache::Rest::Router>();
m_address = address.host() + ":" + (address.port()).toString();
m_authenticationSubscriptionDocumentApiserver =
m_authenticationDataDocumentApiServer =
std::make_shared<AuthenticationDataDocumentApiImpl>(
m_router, udr_app_inst, m_address);
m_authenticationSubscriptionDocumentApiServer =
std::make_shared<AuthenticationSubscriptionDocumentApiImpl>(
m_router, udr_app_inst, m_address);
m_authenticationStatusDocumentApiserver =
m_authenticationStatusDocumentApiServer =
std::make_shared<AuthenticationStatusDocumentApiImpl>(
m_router, udr_app_inst, m_address);
m_accessAndMobilitySubscriptionDataDocumentApiserver =
m_accessAndMobilitySubscriptionDataDocumentApiServer =
std::make_shared<AccessAndMobilitySubscriptionDataDocumentApiImpl>(
m_router, udr_app_inst, m_address);
m_sMFSelectionSubscriptionDataDocumentApiserver =
m_sMFSelectionSubscriptionDataDocumentApiServer =
std::make_shared<SMFSelectionSubscriptionDataDocumentApiImpl>(
m_router, udr_app_inst, m_address);
m_sessionManagementSubscriptionDataApiserver =
m_sessionManagementSubscriptionDataApiServer =
std::make_shared<SessionManagementSubscriptionDataApiImpl>(
m_router, udr_app_inst, m_address);
m_aMF3GPPAccessRegistrationDocumentApiserver =
m_aMF3GPPAccessRegistrationDocumentApiServer =
std::make_shared<AMF3GPPAccessRegistrationDocumentApiImpl>(
m_router, udr_app_inst, m_address);
m_sMFRegistrationDocumentApiserver =
m_sMFRegistrationDocumentApiServer =
std::make_shared<SMFRegistrationDocumentApiImpl>(
m_router, udr_app_inst, m_address);
m_sMFRegistrationsCollectionApiserver =
m_sMFRegistrationsCollectionApiServer =
std::make_shared<SMFRegistrationsCollectionApiImpl>(
m_router, udr_app_inst, m_address);
m_sDMSubscriptionDocumentApiserver =
m_sDMSubscriptionDocumentApiServer =
std::make_shared<SDMSubscriptionDocumentApiImpl>(
m_router, udr_app_inst, m_address);
m_sDMSubscriptionsCollectionApiserver =
m_sDMSubscriptionsCollectionApiServer =
std::make_shared<SDMSubscriptionsCollectionApiImpl>(
m_router, udr_app_inst, m_address);
}
......@@ -108,26 +112,28 @@ class UDRApiServer {
std::shared_ptr<Pistache::Http::Endpoint> m_httpEndpoint;
std::shared_ptr<Pistache::Rest::Router> m_router;
std::shared_ptr<AuthenticationDataDocumentApiImpl>
m_authenticationDataDocumentApiServer;
std::shared_ptr<AuthenticationSubscriptionDocumentApiImpl>
m_authenticationSubscriptionDocumentApiserver;
m_authenticationSubscriptionDocumentApiServer;
std::shared_ptr<AuthenticationStatusDocumentApiImpl>
m_authenticationStatusDocumentApiserver;
m_authenticationStatusDocumentApiServer;
std::shared_ptr<AccessAndMobilitySubscriptionDataDocumentApiImpl>
m_accessAndMobilitySubscriptionDataDocumentApiserver;
m_accessAndMobilitySubscriptionDataDocumentApiServer;
std::shared_ptr<SMFSelectionSubscriptionDataDocumentApiImpl>
m_sMFSelectionSubscriptionDataDocumentApiserver;
m_sMFSelectionSubscriptionDataDocumentApiServer;
std::shared_ptr<SessionManagementSubscriptionDataApiImpl>
m_sessionManagementSubscriptionDataApiserver;
m_sessionManagementSubscriptionDataApiServer;
std::shared_ptr<AMF3GPPAccessRegistrationDocumentApiImpl>
m_aMF3GPPAccessRegistrationDocumentApiserver;
m_aMF3GPPAccessRegistrationDocumentApiServer;
std::shared_ptr<SMFRegistrationDocumentApiImpl>
m_sMFRegistrationDocumentApiserver;
m_sMFRegistrationDocumentApiServer;
std::shared_ptr<SMFRegistrationsCollectionApiImpl>
m_sMFRegistrationsCollectionApiserver;
m_sMFRegistrationsCollectionApiServer;
std::shared_ptr<SDMSubscriptionDocumentApiImpl>
m_sDMSubscriptionDocumentApiserver;
m_sDMSubscriptionDocumentApiServer;
std::shared_ptr<SDMSubscriptionsCollectionApiImpl>
m_sDMSubscriptionsCollectionApiserver;
m_sDMSubscriptionsCollectionApiServer;
std::string m_address;
};
......
......@@ -71,6 +71,7 @@ void Logger::_init(
m_udr_server = new _Logger("udr_server", m_sinks, ss.str().c_str());
m_udr_app = new _Logger("udr_app", m_sinks, ss.str().c_str());
m_udr_nrf = new _Logger("udr_nrf", m_sinks, ss.str().c_str());
m_udr_mysql = new _Logger("udr_mysql", m_sinks, ss.str().c_str());
}
//------------------------------------------------------------------------------
......
......@@ -87,6 +87,7 @@ class Logger {
static _Logger& config() { return *singleton().m_config; }
static _Logger& udr_server() { return *singleton().m_udr_server; }
static _Logger& udr_nrf() { return *singleton().m_udr_nrf; }
static _Logger& udr_mysql() { return *singleton().m_udr_mysql; }
private:
static Logger* m_singleton;
......@@ -109,6 +110,7 @@ class Logger {
_Logger* m_system;
_Logger* m_udr_server;
_Logger* m_udr_nrf;
_Logger* m_udr_mysql;
};
#endif
......@@ -22,6 +22,9 @@
#ifndef FILE_UDR_SEEN
#define FILE_UDR_SEEN
#include <string>
#include <vector>
#define HEART_BEAT_TIMER 10
#define _unused(x) ((void) (x))
......@@ -69,4 +72,13 @@ typedef struct udr_info_s {
std::vector<std::string> data_set_id;
} udr_info_t;
typedef enum db_type_s {
DB_TYPE_UNKNOWN = 0,
DB_TYPE_MYSQL = 1,
DB_TYPE_CASSANDRA = 2
} db_type_t;
static const std::vector<std::string> db_type_e2str = {"Unknown", "MySQL",
"Cassandra"};
#endif
......@@ -34,6 +34,8 @@ add_library (UDR STATIC
udr_event.cpp
task_manager.cpp
udr_client.cpp
mysql_db.cpp
cassandra_db.cpp
)
/*
* 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 cassandra_db.cpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2022
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#include "cassandra_db.hpp"
#include "AuthenticationSubscription.h"
#include "logger.hpp"
#include "udr_config.hpp"
using namespace oai::udr::app;
using namespace oai::udr::model;
using namespace oai::udr::config;
extern udr_config udr_cfg;
//------------------------------------------------------------------------------
cassandra_db::cassandra_db() : database_wrapper<cassandra_db>() {}
//------------------------------------------------------------------------------
cassandra_db::~cassandra_db() {}
//------------------------------------------------------------------------------
bool cassandra_db::initialize() {
Logger::udr_app().debug("Initialize CassandraDB");
Logger::udr_app().debug("CassandraDB is not supported!");
return false;
}
//------------------------------------------------------------------------------
bool cassandra_db::close_connection() {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::insert_authentication_subscription(
const std::string& id,
const oai::udr::model::AuthenticationSubscription&
authentication_subscription,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::delete_authentication_subscription(const std::string& id) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::query_authentication_subscription(
const std::string& id, nlohmann::json& json_data) {
Logger::udr_app().debug("CassandraDB is not supported!");
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::update_authentication_subscription(
const std::string& id,
const std::vector<oai::udr::model::PatchItem>& patchItem,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::query_am_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::create_amf_context_3gpp(
const std::string& ue_id, const nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::query_amf_context_3gpp(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::cassandra_db::insert_authentication_status(
const std::string& ue_id, const oai::udr::model::AuthEvent& authEvent,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::cassandra_db::delete_authentication_status(
const std::string& ue_id) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::cassandra_db::query_authentication_status(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::cassandra_db::query_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::cassandra_db::delete_sdm_subscription(
const std::string& ue_id, const std::string& subs_id) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::update_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::create_sdm_subscriptions(
const std::string& ue_id, oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::query_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, const oai::udr::model::Snssai&,
const std::string& dnn) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
const oai::udr::model::SmfRegistration& smfRegistration,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::delete_smf_context(
const std::string& ue_id, const int32_t& pdu_session_id) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::query_smf_registration(
const std::string& ue_id, const int32_t& pdu_session_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::query_smf_reg_list(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::query_smf_select_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data) {
return true;
}
/*
* 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 cassandra_db.hpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2022
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef CASSANDRA_DB_HPP
#define CASSANDRA_DB_HPP
#include "database_wrapper.hpp"
namespace oai::udr::app {
class cassandra_db : public database_wrapper<cassandra_db> {
public:
cassandra_db();
virtual ~cassandra_db();
bool initialize();
bool close_connection();
bool insert_authentication_subscription(
const std::string& id,
const oai::udr::model::AuthenticationSubscription&
authentication_subscription,
nlohmann::json& json_data);
bool delete_authentication_subscription(const std::string& id);
bool query_authentication_subscription(
const std::string& id, nlohmann::json& json_data);
bool update_authentication_subscription(
const std::string& id,
const std::vector<oai::udr::model::PatchItem>& patchItem,
nlohmann::json& json_data);
bool query_am_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data);
bool create_amf_context_3gpp(
const std::string& ue_id, const nlohmann::json& json_data);
bool query_amf_context_3gpp(
const std::string& ue_id, nlohmann::json& json_data);
bool insert_authentication_status(
const std::string& ue_id, const oai::udr::model::AuthEvent& authEvent,
nlohmann::json& json_data);
bool delete_authentication_status(const std::string& ue_id);
bool query_authentication_status(
const std::string& ue_id, nlohmann::json& json_data);
bool query_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
nlohmann::json& json_data);
bool delete_sdm_subscription(
const std::string& ue_id, const std::string& subs_id);
bool update_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data);
bool create_sdm_subscriptions(
const std::string& ue_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data);
bool query_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data);
bool query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, const oai::udr::model::Snssai& snssai = {},
const std::string& dnn = {});
bool insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
const oai::udr::model::SmfRegistration& smfRegistration,
nlohmann::json& json_data);
bool delete_smf_context(
const std::string& ue_id, const int32_t& pdu_session_id);
bool query_smf_registration(
const std::string& ue_id, const int32_t& pdu_session_id,
nlohmann::json& json_data);
bool query_smf_reg_list(const std::string& ue_id, nlohmann::json& json_data);
bool query_smf_select_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data);
private:
// cassandra_connector;
};
} // namespace oai::udr::app
#endif
/*
* 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 databse_wrapper.hpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2022
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef DATABASE_WRAPPER_HPP
#define DATABASE_WRAPPER_HPP
#include <nlohmann/json.hpp>
#include "Snssai.h"
#include "database_wrapper_abstraction.hpp"
#include "logger.hpp"
#include "udr.h"
namespace oai::udr::app {
template<class DerivedT>
class database_wrapper : public database_wrapper_abstraction {
public:
database_wrapper(){};
virtual ~database_wrapper(){};
/*std::unique_ptr<database_wrapper_abstraction> clone() const override {
return std::make_unique<DerivedT>(static_cast<DerivedT
const&>(*this));
}
*/
bool initialize() override {
Logger::udr_app().debug("Initialize from database_wrapper");
auto derived = static_cast<DerivedT*>(this);
return derived->initialize();
}
bool close_connection() override {
Logger::udr_app().debug("Initialize from database_wrapper");
auto derived = static_cast<DerivedT*>(this);
return derived->close_connection();
}
bool insert_authentication_subscription(
const std::string& id,
const oai::udr::model::AuthenticationSubscription&
authentication_subscription,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->insert_authentication_subscription(
id, authentication_subscription, json_data);
}
bool delete_authentication_subscription(const std::string& id) override {
auto derived = static_cast<DerivedT*>(this);
return derived->delete_authentication_subscription(id);
}
bool query_authentication_subscription(
const std::string& id, nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_authentication_subscription(id, json_data);
}
bool update_authentication_subscription(
const std::string& id,
const std::vector<oai::udr::model::PatchItem>& patchItem,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->update_authentication_subscription(
id, patchItem, json_data);
}
bool query_am_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_am_data(ue_id, serving_plmn_id, json_data);
}
bool create_amf_context_3gpp(
const std::string& ue_id,
oai::udr::model::Amf3GppAccessRegistration& amf3GppAccessRegistration)
override {
auto derived = static_cast<DerivedT*>(this);
return derived->create_amf_context_3gpp(ue_id, amf3GppAccessRegistration);
}
bool query_amf_context_3gpp(
const std::string& ue_id, nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_amf_context_3gpp(ue_id, json_data);
}
bool insert_authentication_status(
const std::string& ue_id, const oai::udr::model::AuthEvent& authEvent,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->insert_authentication_status(ue_id, authEvent, json_data);
}
bool delete_authentication_status(const std::string& ue_id) override {
auto derived = static_cast<DerivedT*>(this);
return derived->delete_authentication_status(ue_id);
}
bool query_authentication_status(
const std::string& ue_id, nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_authentication_status(ue_id, json_data);
}
bool query_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_sdm_subscription(ue_id, subs_id, json_data);
}
bool delete_sdm_subscription(
const std::string& ue_id, const std::string& subs_id) override {
auto derived = static_cast<DerivedT*>(this);
return derived->delete_sdm_subscription(ue_id, subs_id);
}
bool update_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->update_sdm_subscription(
ue_id, subs_id, sdmSubscription, json_data);
}
bool create_sdm_subscriptions(
const std::string& ue_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->create_sdm_subscriptions(ue_id, sdmSubscription, json_data);
}
bool query_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_sdm_subscriptions(ue_id, json_data);
}
bool query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, const oai::udr::model::Snssai& snssai = {},
const std::string& dnn = {}) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_sm_data(
ue_id, serving_plmn_id, json_data, snssai, dnn);
}
bool insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
const oai::udr::model::SmfRegistration& smfRegistration,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->insert_smf_context_non_3gpp(
ue_id, pdu_session_id, smfRegistration, json_data);
}
bool delete_smf_context(
const std::string& ue_id, const int32_t& pdu_session_id) override {
auto derived = static_cast<DerivedT*>(this);
return derived->delete_smf_context(ue_id, pdu_session_id);
}
bool query_smf_registration(
const std::string& ue_id, const int32_t& pdu_session_id,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_smf_registration(ue_id, pdu_session_id, json_data);
}
bool query_smf_reg_list(
const std::string& ue_id, nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_smf_reg_list(ue_id, json_data);
}
bool query_smf_select_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data) override {
auto derived = static_cast<DerivedT*>(this);
return derived->query_smf_select_data(ue_id, serving_plmn_id, json_data);
}
protected:
};
} // namespace oai::udr::app
#endif
This diff is collapsed.
This diff is collapsed.
/*
* 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 mysql_db.hpp
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2022
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#ifndef MYSQL_DB_HPP
#define MYSQL_DB_HPP
#include <mysql/mysql.h>
#include "Amf3GppAccessRegistration.h"
#include "database_wrapper.hpp"
namespace oai::udr::app {
class mysql_db : public database_wrapper<mysql_db> {
public:
mysql_db();
virtual ~mysql_db();
bool initialize();
bool close_connection();
bool insert_authentication_subscription(
const std::string& id,
const oai::udr::model::AuthenticationSubscription&
authentication_subscription,
nlohmann::json& json_data);
bool delete_authentication_subscription(const std::string& id);
bool query_authentication_subscription(
const std::string& id, nlohmann::json& json_data);
bool update_authentication_subscription(
const std::string& id,
const std::vector<oai::udr::model::PatchItem>& patchItem,
nlohmann::json& json_data);
bool query_am_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data);
bool create_amf_context_3gpp(
const std::string& ue_id,
oai::udr::model::Amf3GppAccessRegistration& amf3GppAccessRegistration);
bool query_amf_context_3gpp(
const std::string& ue_id, nlohmann::json& json_data);
bool insert_authentication_status(
const std::string& ue_id, const oai::udr::model::AuthEvent& authEvent,
nlohmann::json& json_data);
bool delete_authentication_status(const std::string& ue_id);
bool query_authentication_status(
const std::string& ue_id, nlohmann::json& json_data);
bool query_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
nlohmann::json& json_data);
bool delete_sdm_subscription(
const std::string& ue_id, const std::string& subs_id);
bool update_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data);
bool create_sdm_subscriptions(
const std::string& ue_id,
oai::udr::model::SdmSubscription& sdmSubscription,
nlohmann::json& json_data);
bool query_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data);
bool query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, const oai::udr::model::Snssai& snssai = {},
const std::string dnn = {});
bool insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
const oai::udr::model::SmfRegistration& smfRegistration,
nlohmann::json& json_data);
bool delete_smf_context(
const std::string& ue_id, const int32_t& pdu_session_id);
bool query_smf_registration(
const std::string& ue_id, const int32_t& pdu_session_id,
nlohmann::json& json_data);
bool query_smf_reg_list(const std::string& ue_id, nlohmann::json& json_data);
bool query_smf_select_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data);
private:
MYSQL mysql_connector;
};
} // namespace oai::udr::app
#endif
......@@ -29,9 +29,10 @@
#include "task_manager.hpp"
#include <unistd.h>
#include <iostream>
#include <thread>
#include <unistd.h>
#include "logger.hpp"
......
......@@ -24,17 +24,17 @@
\author
\company Eurecom
\date 2020
\email: Tien-Thinh.Nguyen@eurecom.fr
\email:
*/
#ifndef TASK_MANAGER_H_
#define TASK_MANAGER_H_
#include "udr_event.hpp"
#include <linux/types.h>
#include <sys/timerfd.h>
#include "udr_event.hpp"
namespace oai {
namespace udr {
namespace app {
......
This diff is collapsed.
......@@ -33,15 +33,17 @@
#include <mysql/mysql.h>
#include <pistache/http.h>
#include "udr_event.hpp"
#include <nlohmann/json.hpp>
#include <string>
#include "Amf3GppAccessRegistration.h"
#include "AuthEvent.h"
#include "AuthenticationSubscription.h"
#include "PatchItem.h"
#include "SdmSubscription.h"
#include "SmfRegistration.h"
#include "database_wrapper.hpp"
#include "udr_event.hpp"
using namespace oai::udr::model;
......@@ -131,6 +133,32 @@ class udr_app {
void handle_query_authentication_status(
const std::string& ue_id, nlohmann::json& response_data, long& code);
/*
* Handle a request to Create an Authentication Subscription
* (AuthenticationSubscriptionDocumentApiImpl)
* @param [const std::string&] ue_id: UE Identity
* @param [const AuthenticationSubscription&] authentication_subscription:
* UE's subscription information
* @param [nlohmann::json&] response_data: Response in Json format
* @param [long code] http_code: HTTP response code
* @return void
*/
void handle_create_authentication_data(
const std::string& ue_id,
const AuthenticationSubscription& authentication_subscription,
nlohmann::json& response_data, long& code);
/*
* Handle a request to remove the AuthenticationSubscription
* (AuthenticationDataDocumentApiImpl)
* @param [const std::string&] ue_id: UE Identity
* @param [nlohmann::json&] response_data: Response in Json format
* @param [long code] code: HTTP response code
* @return void
*/
void handle_delete_authentication_data(
const std::string& ue_id, nlohmann::json& response_data, long& code);
/*
* Handle a request to modify AuthenticationSubscription
* (AuthenticationSubscriptionDocumentApiImpl)
......@@ -224,13 +252,15 @@ class udr_app {
* @param [const std::string&] ue_id: UE Identity
* @param [const std::string&] serving_plmn_id: Serving PLMN ID
* @param [nlohmann::json&] response_data: Response in Json format
* @param [const oai::udr::model::Snssai&] snssai: SNSSAI
* @param [const std::string&] dnn: DNN
* @param [long code] code: HTTP response code
* @return void
*/
void handle_query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& response_data, long& code,
oai::udr::model::Snssai snssai = {}, std::string dnn = {});
const oai::udr::model::Snssai& snssai = {}, const std::string& dnn = {});
/*
* Handle a request to create SMFRegistration (SMFRegistrationDocumentApiImpl)
......@@ -298,6 +328,8 @@ class udr_app {
private:
MYSQL mysql;
udr_event& event_sub;
std::shared_ptr<database_wrapper_abstraction> db_connector;
// std::shared_ptr<database_wrapper> db_connector_test;
};
} // namespace app
} // namespace udr
......
......@@ -28,14 +28,15 @@
*/
#include "udr_client.hpp"
#include "3gpp_29.500.h"
#include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <pistache/http.h>
#include <pistache/mime.h>
#include <nlohmann/json.hpp>
#include <stdexcept>
#include "3gpp_29.500.h"
#include "logger.hpp"
#include "udr.h"
......
......@@ -29,11 +29,11 @@
#ifndef FILE_UDR_CLIENT_HPP_SEEN
#define FILE_UDR_CLIENT_HPP_SEEN
#include <curl/curl.h>
#include <map>
#include <thread>
#include <curl/curl.h>
#include "logger.hpp"
#include "udr_config.hpp"
......
......@@ -21,12 +21,11 @@
#include "udr_config.hpp"
#include <iostream>
#include <libconfig.h++>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <iostream>
#include <libconfig.h++>
#include "common_defs.h"
#include "fqdn.hpp"
......@@ -42,6 +41,7 @@ namespace oai::udr::config {
udr_config::udr_config() : mysql(), instance(), udr_name(), pid_dir(), nudr() {
nudr_http2_port = 8080;
nudr.api_version = "v1";
db_type = DB_TYPE_MYSQL;
}
//------------------------------------------------------------------------------
......@@ -141,6 +141,17 @@ int udr_config::load(const std ::string& config_file) {
} else {
use_http2 = false;
}
support_features.lookupValue(UDR_CONFIG_STRING_DATABASE_TYPE, opt);
if (boost::iequals(opt, "cassandra")) {
db_type = DB_TYPE_CASSANDRA;
} else if (boost::iequals(opt, "mysql")) {
db_type = DB_TYPE_MYSQL;
} else {
db_type = DB_TYPE_MYSQL; // Default for now
}
} catch (const SettingNotFoundException& nfex) {
Logger::udr_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
......@@ -280,20 +291,19 @@ void udr_config::display() {
Logger::config().info(
"====================== UDR =====================");
Logger::config().info("Configuration UDR:");
Logger::config().info(
"- Instance ...........................................: %d", instance);
Logger::config().info(
"- PID dir ............................................: %s",
pid_dir.c_str());
Logger::config().info("- UDR Name ..............: %s", udr_name.c_str());
Logger::config().info("- Instance ................: %d", instance);
Logger::config().info("- PID dir .................: %s", pid_dir.c_str());
Logger::config().info("- UDR Name ................: %s", udr_name.c_str());
Logger::config().info("- Nudr Networking:");
Logger::config().info(" Interface name ......: %s", nudr.if_name.c_str());
Logger::config().info(" IPv4 Addr ...........: %s", inet_ntoa(nudr.addr4));
Logger::config().info(" HTTP1 Port ..........: %d", nudr.port);
Logger::config().info(" HTTP2 port ..........: %d", nudr_http2_port);
Logger::config().info(
" API version..........: %s", nudr.api_version.c_str());
" Interface name ........: %s", nudr.if_name.c_str());
Logger::config().info(
" IPv4 Addr .............: %s", inet_ntoa(nudr.addr4));
Logger::config().info(" HTTP1 Port ............: %d", nudr.port);
Logger::config().info(" HTTP2 port ............: %d", nudr_http2_port);
Logger::config().info(
" API version ...........: %s", nudr.api_version.c_str());
Logger::config().info("- Supported Features:");
Logger::config().info(
" Register NRF ..........: %s", register_nrf ? "Yes" : "No");
......@@ -301,28 +311,37 @@ void udr_config::display() {
" Use FQDN ..............: %s", use_fqdn_dns ? "Yes" : "No");
Logger::config().info(
" Use HTTP2 .............: %s", use_http2 ? "Yes" : "No");
Logger::config().info(
" Database ..............: %s", db_type_e2str[db_type].c_str());
if (register_nrf) {
Logger::config().info("- NRF:");
Logger::config().info(
" IPv4 Addr ............: %s",
" IPv4 Addr .............: %s",
inet_ntoa(*((struct in_addr*) &nrf_addr.ipv4_addr)));
Logger::config().info(" Port .................: %lu ", nrf_addr.port);
Logger::config().info(" Port ..................: %lu ", nrf_addr.port);
Logger::config().info(
" API version ..........: %s", nrf_addr.api_version.c_str());
" API version ...........: %s", nrf_addr.api_version.c_str());
if (use_fqdn_dns)
Logger::config().info(
" FQDN .................: %s", nrf_addr.fqdn.c_str());
" FQDN ..................: %s", nrf_addr.fqdn.c_str());
}
if (db_type == DB_TYPE_MYSQL) {
Logger::config().info("- MySQL:");
Logger::config().info(
"- MYSQL Server Addr...................................: %s",
mysql.mysql_server.c_str());
" Server Addr ...........: %s", mysql.mysql_server.c_str());
Logger::config().info(
"- MYSQL user .........................................: %s",
mysql.mysql_user.c_str());
" Username ..............: %s", mysql.mysql_user.c_str());
Logger::config().info(
"- MYSQL pass .........................................: %s",
mysql.mysql_pass.c_str());
" Password ..............: %s", mysql.mysql_pass.c_str());
Logger::config().info(
"- MYSQL db ...........................................: %s",
mysql.mysql_db.c_str());
" Database ..............: %s", mysql.mysql_db.c_str());
} else if (db_type == DB_TYPE_CASSANDRA) {
Logger::config().info("- Cassandra:");
Logger::config().info(
" Cassandra DB ..........: not "
"supported!");
}
}
} // namespace oai::udr::config
......@@ -23,10 +23,13 @@
#define _UDR_CONFIG_H_
#include <arpa/inet.h>
#include <libconfig.h++>
#include <netinet/in.h>
#include <libconfig.h++>
#include <string>
#include "udr.h"
#define UDR_CONFIG_STRING_UDR_CONFIG "UDR"
#define UDR_CONFIG_STRING_INSTANCE_ID "INSTANCE_ID"
#define UDR_CONFIG_STRING_UDR_NAME "UDR_NAME"
......@@ -49,6 +52,7 @@
#define UDM_CONFIG_STRING_SUPPORT_FEATURES_USE_HTTP2 "USE_HTTP2"
#define UDR_CONFIG_STRING_FQDN_DNS "FQDN"
#define UDR_CONFIG_STRING_DATABASE_TYPE "DATABASE"
#define UDR_CONFIG_STRING_MYSQL "MYSQL"
#define UDR_CONFIG_STRING_MYSQL_SERVER "MYSQL_SERVER"
#define UDR_CONFIG_STRING_MYSQL_USER "MYSQL_USER"
......@@ -104,6 +108,7 @@ class udr_config {
bool use_http2;
mysql_conf_t mysql;
db_type_t db_type;
};
} // namespace oai::udr::config
......
......@@ -28,20 +28,21 @@
*/
#include "udr_nrf.hpp"
#include "udr_app.hpp"
#include "udr_client.hpp"
#include "udr_profile.hpp"
#include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <pistache/http.h>
#include <pistache/mime.h>
#include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <nlohmann/json.hpp>
#include <stdexcept>
#include "logger.hpp"
#include "udr.h"
#include "udr_app.hpp"
#include "udr_client.hpp"
#include "udr_profile.hpp"
using namespace oai::udr::config;
// using namespace udr;
......
......@@ -29,11 +29,11 @@
#ifndef FILE_UDR_NRF_SEEN
#define FILE_UDR_NRF_SEEN
#include <curl/curl.h>
#include <map>
#include <thread>
#include <curl/curl.h>
#include "logger.hpp"
#include "udr_config.hpp"
#include "udr_event.hpp"
......
......@@ -27,13 +27,14 @@
\email: Tien-Thinh.Nguyen@eurecom.fr
*/
#include "udr_profile.hpp"
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include "fqdn.hpp"
#include "logger.hpp"
#include "string.hpp"
#include "udr_profile.hpp"
// using namespace udr;
using namespace oai::udr::app;
......
......@@ -32,6 +32,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
#include <nlohmann/json.hpp>
#include <shared_mutex>
#include <vector>
......
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