Commit aad95109 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Add skeleton for Database abstraction

parent 1196491a
/*
* 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"
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 +
"/subscription-data/:ueId/authentication-data/"
"authentication-subscription",
Routes::bind(
&AuthenticationDataDocumentApi::create_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::
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 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;
};
} // 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());
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
} // 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);
};
} // namespace oai::udr::api
#endif
...@@ -83,21 +83,22 @@ void UDRApiServer::init(size_t thr) { ...@@ -83,21 +83,22 @@ void UDRApiServer::init(size_t thr) {
// opts.maxResponseSize(PISTACHE_SERVER_MAX_RESPONSE_SIZE); // opts.maxResponseSize(PISTACHE_SERVER_MAX_RESPONSE_SIZE);
m_httpEndpoint->init(opts); m_httpEndpoint->init(opts);
m_authenticationSubscriptionDocumentApiserver->init(); m_authenticationSubscriptionDocumentApiServer->init();
m_authenticationStatusDocumentApiserver->init(); m_authenticationDataDocumentApiServer->init();
m_accessAndMobilitySubscriptionDataDocumentApiserver->init(); m_authenticationStatusDocumentApiServer->init();
m_sMFSelectionSubscriptionDataDocumentApiserver->init(); m_accessAndMobilitySubscriptionDataDocumentApiServer->init();
m_sessionManagementSubscriptionDataApiserver->init(); m_sMFSelectionSubscriptionDataDocumentApiServer->init();
m_aMF3GPPAccessRegistrationDocumentApiserver->init(); m_sessionManagementSubscriptionDataApiServer->init();
m_sMFRegistrationDocumentApiserver->init(); m_aMF3GPPAccessRegistrationDocumentApiServer->init();
m_sMFRegistrationsCollectionApiserver->init(); m_sMFRegistrationDocumentApiServer->init();
m_sDMSubscriptionDocumentApiserver->init(); m_sMFRegistrationsCollectionApiServer->init();
m_sDMSubscriptionsCollectionApiserver->init(); m_sDMSubscriptionDocumentApiServer->init();
m_sDMSubscriptionsCollectionApiServer->init();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void UDRApiServer::start() { 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->setHandler(m_router->handler());
m_httpEndpoint->serve(); m_httpEndpoint->serve();
} }
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "AccessAndMobilitySubscriptionDataDocumentApiImpl.h" #include "AccessAndMobilitySubscriptionDataDocumentApiImpl.h"
#include "AuthenticationStatusDocumentApiImpl.h" #include "AuthenticationStatusDocumentApiImpl.h"
#include "AuthenticationSubscriptionDocumentApiImpl.h" #include "AuthenticationSubscriptionDocumentApiImpl.h"
#include "AuthenticationDataDocumentApiImpl.h"
#include "SDMSubscriptionDocumentApiImpl.h" #include "SDMSubscriptionDocumentApiImpl.h"
#include "SDMSubscriptionsCollectionApiImpl.h" #include "SDMSubscriptionsCollectionApiImpl.h"
#include "SMFRegistrationDocumentApiImpl.h" #include "SMFRegistrationDocumentApiImpl.h"
...@@ -69,34 +70,37 @@ class UDRApiServer { ...@@ -69,34 +70,37 @@ class UDRApiServer {
m_router = std::make_shared<Pistache::Rest::Router>(); m_router = std::make_shared<Pistache::Rest::Router>();
m_address = address.host() + ":" + (address.port()).toString(); 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>( std::make_shared<AuthenticationSubscriptionDocumentApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
m_authenticationStatusDocumentApiserver = m_authenticationStatusDocumentApiServer =
std::make_shared<AuthenticationStatusDocumentApiImpl>( std::make_shared<AuthenticationStatusDocumentApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
m_accessAndMobilitySubscriptionDataDocumentApiserver = m_accessAndMobilitySubscriptionDataDocumentApiServer =
std::make_shared<AccessAndMobilitySubscriptionDataDocumentApiImpl>( std::make_shared<AccessAndMobilitySubscriptionDataDocumentApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
m_sMFSelectionSubscriptionDataDocumentApiserver = m_sMFSelectionSubscriptionDataDocumentApiServer =
std::make_shared<SMFSelectionSubscriptionDataDocumentApiImpl>( std::make_shared<SMFSelectionSubscriptionDataDocumentApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
m_sessionManagementSubscriptionDataApiserver = m_sessionManagementSubscriptionDataApiServer =
std::make_shared<SessionManagementSubscriptionDataApiImpl>( std::make_shared<SessionManagementSubscriptionDataApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
m_aMF3GPPAccessRegistrationDocumentApiserver = m_aMF3GPPAccessRegistrationDocumentApiServer =
std::make_shared<AMF3GPPAccessRegistrationDocumentApiImpl>( std::make_shared<AMF3GPPAccessRegistrationDocumentApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
m_sMFRegistrationDocumentApiserver = m_sMFRegistrationDocumentApiServer =
std::make_shared<SMFRegistrationDocumentApiImpl>( std::make_shared<SMFRegistrationDocumentApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
m_sMFRegistrationsCollectionApiserver = m_sMFRegistrationsCollectionApiServer =
std::make_shared<SMFRegistrationsCollectionApiImpl>( std::make_shared<SMFRegistrationsCollectionApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
m_sDMSubscriptionDocumentApiserver = m_sDMSubscriptionDocumentApiServer =
std::make_shared<SDMSubscriptionDocumentApiImpl>( std::make_shared<SDMSubscriptionDocumentApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
m_sDMSubscriptionsCollectionApiserver = m_sDMSubscriptionsCollectionApiServer =
std::make_shared<SDMSubscriptionsCollectionApiImpl>( std::make_shared<SDMSubscriptionsCollectionApiImpl>(
m_router, udr_app_inst, m_address); m_router, udr_app_inst, m_address);
} }
...@@ -108,26 +112,28 @@ class UDRApiServer { ...@@ -108,26 +112,28 @@ class UDRApiServer {
std::shared_ptr<Pistache::Http::Endpoint> m_httpEndpoint; std::shared_ptr<Pistache::Http::Endpoint> m_httpEndpoint;
std::shared_ptr<Pistache::Rest::Router> m_router; std::shared_ptr<Pistache::Rest::Router> m_router;
std::shared_ptr<AuthenticationDataDocumentApiImpl>
m_authenticationDataDocumentApiServer;
std::shared_ptr<AuthenticationSubscriptionDocumentApiImpl> std::shared_ptr<AuthenticationSubscriptionDocumentApiImpl>
m_authenticationSubscriptionDocumentApiserver; m_authenticationSubscriptionDocumentApiServer;
std::shared_ptr<AuthenticationStatusDocumentApiImpl> std::shared_ptr<AuthenticationStatusDocumentApiImpl>
m_authenticationStatusDocumentApiserver; m_authenticationStatusDocumentApiServer;
std::shared_ptr<AccessAndMobilitySubscriptionDataDocumentApiImpl> std::shared_ptr<AccessAndMobilitySubscriptionDataDocumentApiImpl>
m_accessAndMobilitySubscriptionDataDocumentApiserver; m_accessAndMobilitySubscriptionDataDocumentApiServer;
std::shared_ptr<SMFSelectionSubscriptionDataDocumentApiImpl> std::shared_ptr<SMFSelectionSubscriptionDataDocumentApiImpl>
m_sMFSelectionSubscriptionDataDocumentApiserver; m_sMFSelectionSubscriptionDataDocumentApiServer;
std::shared_ptr<SessionManagementSubscriptionDataApiImpl> std::shared_ptr<SessionManagementSubscriptionDataApiImpl>
m_sessionManagementSubscriptionDataApiserver; m_sessionManagementSubscriptionDataApiServer;
std::shared_ptr<AMF3GPPAccessRegistrationDocumentApiImpl> std::shared_ptr<AMF3GPPAccessRegistrationDocumentApiImpl>
m_aMF3GPPAccessRegistrationDocumentApiserver; m_aMF3GPPAccessRegistrationDocumentApiServer;
std::shared_ptr<SMFRegistrationDocumentApiImpl> std::shared_ptr<SMFRegistrationDocumentApiImpl>
m_sMFRegistrationDocumentApiserver; m_sMFRegistrationDocumentApiServer;
std::shared_ptr<SMFRegistrationsCollectionApiImpl> std::shared_ptr<SMFRegistrationsCollectionApiImpl>
m_sMFRegistrationsCollectionApiserver; m_sMFRegistrationsCollectionApiServer;
std::shared_ptr<SDMSubscriptionDocumentApiImpl> std::shared_ptr<SDMSubscriptionDocumentApiImpl>
m_sDMSubscriptionDocumentApiserver; m_sDMSubscriptionDocumentApiServer;
std::shared_ptr<SDMSubscriptionsCollectionApiImpl> std::shared_ptr<SDMSubscriptionsCollectionApiImpl>
m_sDMSubscriptionsCollectionApiserver; m_sDMSubscriptionsCollectionApiServer;
std::string m_address; std::string m_address;
}; };
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#ifndef FILE_UDR_SEEN #ifndef FILE_UDR_SEEN
#define FILE_UDR_SEEN #define FILE_UDR_SEEN
#include <string>
#include <vector>
#define HEART_BEAT_TIMER 10 #define HEART_BEAT_TIMER 10
#define _unused(x) ((void) (x)) #define _unused(x) ((void) (x))
...@@ -69,4 +72,10 @@ typedef struct udr_info_s { ...@@ -69,4 +72,10 @@ typedef struct udr_info_s {
std::vector<std::string> data_set_id; std::vector<std::string> data_set_id;
} udr_info_t; } udr_info_t;
typedef enum db_type_s {
DB_TYPE_UNKNOWN = 0,
DB_TYPE_MYSQL = 1,
DB_TYPE_CASSANDRA = 2
} db_type_t;
#endif #endif
...@@ -33,7 +33,9 @@ add_library (UDR STATIC ...@@ -33,7 +33,9 @@ add_library (UDR STATIC
udr_nrf.cpp udr_nrf.cpp
udr_event.cpp udr_event.cpp
task_manager.cpp task_manager.cpp
udr_client.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
*/
#include "cassandra_db.hpp"
#include "udr_config.hpp"
#include "AuthenticationSubscription.h"
#include "logger.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>() {
// initialize();
}
//------------------------------------------------------------------------------
cassandra_db::~cassandra_db() {}
bool cassandra_db::initialize() {
Logger::udr_app().debug("Initialize from CassandraDB");
return true;
}
bool cassandra_db::close_connection() {
return true;
}
bool cassandra_db::insert_authentication_subscription(
const std::string& id, const nlohmann::json& json_data) {
return true;
}
bool cassandra_db::query_authentication_subscription(
const std::string& id, nlohmann::json& json_data) {
return true;
}
bool cassandra_db::update_authentication_subscription(
const std::string& id, const nlohmann::json& json_data) {
return true;
}
bool cassandra_db::delete_authentication_subscription(const std::string& id) {
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 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,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::create_sdm_subscriptions(
const std::string& ue_id, 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, oai::udr::model::Snssai, std::string dnn) {
return true;
}
//------------------------------------------------------------------------------
bool cassandra_db::insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
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
*/
#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 nlohmann::json& json_data);
bool query_authentication_subscription(
const std::string& id, nlohmann::json& json_data);
bool update_authentication_subscription(
const std::string& id, const nlohmann::json& json_data);
bool delete_authentication_subscription(const std::string& id);
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 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,
nlohmann::json& json_data);
bool create_sdm_subscriptions(
const std::string& ue_id, 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, oai::udr::model::Snssai snssai = {},
std::string dnn = {});
bool insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
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
*/
#include "database_wrapper.hpp"
#include "logger.hpp"
using namespace oai::udr::app;
/*
//------------------------------------------------------------------------------
template <class DerivedT> database_wrapper<DerivedT>::database_wrapper():
database_wrapper_abstraction() {
//db_type = DB_TYPE_UNKNOWN;
}
//------------------------------------------------------------------------------
template <class DerivedT> database_wrapper<DerivedT>::~database_wrapper() {}
*/
/*
template <class DerivedT> bool database_wrapper<DerivedT>:: initialize() {
Logger::udr_app().debug("initialize from database_wrapper");
auto derived = static_cast<DerivedT*>(this);
//return derived->initialize();
return true;
}
*/
/*
template <class DerivedT> bool database_wrapper<DerivedT>:: close_connection() {
return true;
}
*/
/*
template<class DerivedT>
bool database_wrapper<DerivedT>::insert_authentication_subscription(
const std::string& id, const nlohmann::json& json_data) {
Logger::udr_app().debug(
"insert_authentication_subscription from database_wrapper");
auto derived = static_cast<DerivedT*>(this);
return derived->insert_authentication_subscription(id, json_data);
return true;
}
template<class DerivedT>
bool database_wrapper<DerivedT>::query_authentication_subscription(
const std::string& id, nlohmann::json& json_data) {
return true;
}
template<class DerivedT>
bool database_wrapper<DerivedT>::update_authentication_subscription(
const std::string& id, const nlohmann::json& json_data) {
return true;
}
template<class DerivedT>
bool database_wrapper<DerivedT>::delete_authentication_subscription(
const std::string& id) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::query_am_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::create_amf_context_3gpp(
const std::string& ue_id, const nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::query_amf_context_3gpp(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::database_wrapper::insert_authentication_status(
const std::string& ue_id, const nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::database_wrapper::delete_authentication_status(
const std::string& ue_id) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::database_wrapper::query_authentication_status(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::database_wrapper::query_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::database_wrapper::delete_sdm_subscription(
const std::string& ue_id, const std::string& subs_id) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::update_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::create_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::query_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, oai::udr::model::Snssai, std::string dnn) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::delete_smf_context(
const std::string& ue_id, const int32_t& pdu_session_id) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::query_smf_registration(
const std::string& ue_id, const int32_t& pdu_session_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::query_smf_reg_list(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
template<class DerivedT>
bool database_wrapper<DerivedT>::query_smf_select_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data) {
return true;
}
*/
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
*/
#ifndef DATABASE_WRAPPER_ABSTRACTION_HPP
#define DATABASE_WRAPPER_ABSTRACTION_HPP
namespace oai::udr::app {
class database_wrapper_abstraction {
public:
database_wrapper_abstraction(){};
virtual ~database_wrapper_abstraction(){};
// virtual std::unique_ptr<database_wrapper_abstraction> clone() const = 0;
virtual bool initialize() = 0;
};
} // 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
*/
#include "mysql_db.hpp"
#include "udr_config.hpp"
#include "AuthenticationSubscription.h"
#include "logger.hpp"
using namespace oai::udr::app;
using namespace oai::udr::model;
using namespace oai::udr::config;
extern udr_config udr_cfg;
//------------------------------------------------------------------------------
mysql_db::mysql_db() : database_wrapper<mysql_db>() {
// initialize();
}
//------------------------------------------------------------------------------
mysql_db::~mysql_db() {}
bool mysql_db::initialize() {
Logger::udr_app().debug("Initialize from MySQL DB");
if (!mysql_init(&mysql_connector)) {
Logger::udr_app().error("Cannot initialize MySQL");
throw std::runtime_error("Cannot initialize MySQL");
}
if (!mysql_real_connect(
&mysql_connector, 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 MySQL DB: %s",
mysql_error(&mysql_connector));
throw std::runtime_error("Cannot connect to MySQL DB");
}
return true;
}
bool mysql_db::close_connection() {
mysql_close(&mysql_connector);
return true;
}
bool mysql_db::insert_authentication_subscription(
const std::string& id, const nlohmann::json& json_data) {
return true;
}
bool mysql_db::query_authentication_subscription(
const std::string& id, nlohmann::json& json_data) {
Logger::udr_server().info("Query Authentication Subscription");
MYSQL_RES* res = nullptr;
MYSQL_ROW row = {};
MYSQL_FIELD* field = nullptr;
nlohmann::json j = {};
AuthenticationSubscription authentication_subscription = {};
const std::string query =
"SELECT * FROM AuthenticationSubscription WHERE ueid='" + id + "'";
Logger::udr_server().info("MySQL Query: %s", query.c_str());
if (mysql_real_query(
&mysql_connector, query.c_str(), (unsigned long) query.size())) {
Logger::udr_server().error(
"mysql_real_query failure! SQL Query: %s", query.c_str());
return false;
}
res = mysql_store_result(&mysql_connector);
if (res == nullptr) {
Logger::udr_server().error(
"mysql_store_result failure! SQL Query: %s", query.c_str());
return false;
}
row = mysql_fetch_row(res);
if (row != nullptr) {
for (int i = 0; field = mysql_fetch_field(res); i++) {
Logger::udr_server().debug("Row [%d]: %s ", i, field->name);
if (!strcmp("authenticationMethod", field->name)) {
authentication_subscription.setAuthenticationMethod(row[i]);
} else if (!strcmp("encPermanentKey", field->name) && row[i] != nullptr) {
authentication_subscription.setEncPermanentKey(row[i]);
} else if (
!strcmp("protectionParameterId", field->name) && row[i] != nullptr) {
authentication_subscription.setProtectionParameterId(row[i]);
} else if (!strcmp("sequenceNumber", field->name) && row[i] != nullptr) {
SequenceNumber sequencenumber = {};
nlohmann::json::parse(row[i]).get_to(sequencenumber);
authentication_subscription.setSequenceNumber(sequencenumber);
} else if (
!strcmp("authenticationManagementField", field->name) &&
row[i] != nullptr) {
authentication_subscription.setAuthenticationManagementField(row[i]);
} else if (!strcmp("algorithmId", field->name) && row[i] != nullptr) {
authentication_subscription.setAlgorithmId(row[i]);
} else if (!strcmp("encOpcKey", field->name) && row[i] != nullptr) {
authentication_subscription.setEncOpcKey(row[i]);
} else if (!strcmp("encTopcKey", field->name) && row[i] != nullptr) {
authentication_subscription.setEncTopcKey(row[i]);
} else if (
!strcmp("vectorGenerationInHss", field->name) && row[i] != nullptr) {
if (strcmp(row[i], "0"))
authentication_subscription.setVectorGenerationInHss(true);
else
authentication_subscription.setVectorGenerationInHss(false);
} else if (!strcmp("n5gcAuthMethod", field->name) && row[i] != nullptr) {
authentication_subscription.setN5gcAuthMethod(row[i]);
} else if (
!strcmp("rgAuthenticationInd", field->name) && row[i] != nullptr) {
if (strcmp(row[i], "0"))
authentication_subscription.setRgAuthenticationInd(true);
else
authentication_subscription.setRgAuthenticationInd(false);
} else if (!strcmp("supi", field->name) && row[i] != nullptr) {
authentication_subscription.setSupi(row[i]);
}
}
to_json(json_data, authentication_subscription);
} else {
Logger::udr_server().error(
"AuthenticationSubscription no data! SQL Query: %s", query.c_str());
}
mysql_free_result(res);
return true;
}
bool mysql_db::update_authentication_subscription(
const std::string& id, const nlohmann::json& json_data) {
return true;
}
bool mysql_db::delete_authentication_subscription(const std::string& id) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::query_am_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::create_amf_context_3gpp(
const std::string& ue_id, const nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::query_amf_context_3gpp(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::mysql_db::insert_authentication_status(
const std::string& ue_id, const nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::mysql_db::delete_authentication_status(
const std::string& ue_id) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::mysql_db::query_authentication_status(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::mysql_db::query_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::mysql_db::delete_sdm_subscription(
const std::string& ue_id, const std::string& subs_id) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::update_sdm_subscription(
const std::string& ue_id, const std::string& subs_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::create_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::query_sdm_subscriptions(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::query_sm_data(
const std::string& ue_id, const std::string& serving_plmn_id,
nlohmann::json& json_data, oai::udr::model::Snssai, std::string dnn) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::delete_smf_context(
const std::string& ue_id, const int32_t& pdu_session_id) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::query_smf_registration(
const std::string& ue_id, const int32_t& pdu_session_id,
nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_db::query_smf_reg_list(
const std::string& ue_id, nlohmann::json& json_data) {
return true;
}
//------------------------------------------------------------------------------
bool mysql_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
*/
#ifndef MYSQL_DB_HPP
#define MYSQL_DB_HPP
#include "database_wrapper.hpp"
#include <mysql/mysql.h>
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 nlohmann::json& json_data);
bool query_authentication_subscription(
const std::string& id, nlohmann::json& json_data);
bool update_authentication_subscription(
const std::string& id, const nlohmann::json& json_data);
bool delete_authentication_subscription(const std::string& id);
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 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,
nlohmann::json& json_data);
bool create_sdm_subscriptions(
const std::string& ue_id, 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, oai::udr::model::Snssai snssai = {},
std::string dnn = {});
bool insert_smf_context_non_3gpp(
const std::string& ue_id, const int32_t& pdu_session_id,
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
This diff is collapsed.
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#ifndef FILE_UDR_APP_HPP_SEEN #ifndef FILE_UDR_APP_HPP_SEEN
#define FILE_UDR_APP_HPP_SEEN #define FILE_UDR_APP_HPP_SEEN
#include "database_wrapper.hpp"
#include <mysql/mysql.h> #include <mysql/mysql.h>
#include <pistache/http.h> #include <pistache/http.h>
...@@ -42,6 +44,7 @@ ...@@ -42,6 +44,7 @@
#include "PatchItem.h" #include "PatchItem.h"
#include "SdmSubscription.h" #include "SdmSubscription.h"
#include "SmfRegistration.h" #include "SmfRegistration.h"
#include "AuthenticationSubscription.h"
using namespace oai::udr::model; using namespace oai::udr::model;
...@@ -131,6 +134,22 @@ class udr_app { ...@@ -131,6 +134,22 @@ class udr_app {
void handle_query_authentication_status( void handle_query_authentication_status(
const std::string& ue_id, nlohmann::json& response_data, long& code); 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& http_code);
/* /*
* Handle a request to modify AuthenticationSubscription * Handle a request to modify AuthenticationSubscription
* (AuthenticationSubscriptionDocumentApiImpl) * (AuthenticationSubscriptionDocumentApiImpl)
...@@ -298,6 +317,8 @@ class udr_app { ...@@ -298,6 +317,8 @@ class udr_app {
private: private:
MYSQL mysql; MYSQL mysql;
udr_event& event_sub; udr_event& event_sub;
std::shared_ptr<database_wrapper_abstraction> db_connector;
// std::shared_ptr<database_wrapper> db_connector_test;
}; };
} // namespace app } // namespace app
} // namespace udr } // namespace udr
......
...@@ -42,6 +42,7 @@ namespace oai::udr::config { ...@@ -42,6 +42,7 @@ namespace oai::udr::config {
udr_config::udr_config() : mysql(), instance(), udr_name(), pid_dir(), nudr() { udr_config::udr_config() : mysql(), instance(), udr_name(), pid_dir(), nudr() {
nudr_http2_port = 8080; nudr_http2_port = 8080;
nudr.api_version = "v1"; nudr.api_version = "v1";
db_type = DB_TYPE_CASSANDRA;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#ifndef _UDR_CONFIG_H_ #ifndef _UDR_CONFIG_H_
#define _UDR_CONFIG_H_ #define _UDR_CONFIG_H_
#include "udr.h"
#include <arpa/inet.h> #include <arpa/inet.h>
#include <libconfig.h++> #include <libconfig.h++>
#include <netinet/in.h> #include <netinet/in.h>
...@@ -104,6 +106,7 @@ class udr_config { ...@@ -104,6 +106,7 @@ class udr_config {
bool use_http2; bool use_http2;
mysql_conf_t mysql; mysql_conf_t mysql;
db_type_t db_type;
}; };
} // namespace oai::udr::config } // namespace oai::udr::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