Commit 99c5366b authored by kharade's avatar kharade

handle nfmanagement service

parent e962a573
......@@ -32,6 +32,7 @@ include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
file(GLOB NRF_API_SERVER_src_files
${NRF_API_SERVER_DIR}/nrf-api-server.cpp
${NRF_API_SERVER_DIR}/nrf-http2-server.cpp
${NRF_API_SERVER_DIR}/model/*.cpp
${NRF_API_SERVER_DIR}/api/*.cpp
${NRF_API_SERVER_DIR}/impl/*.cpp
......
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 smf_http2-server.h
\brief
\author Tien-Thinh NGUYEN
\company Eurecom
\date 2020
\email: tien-thinh.nguyen@eurecom.fr
*/
#ifndef FILE_NRF_HTTP2_SERVER_SEEN
#define FILE_NRF_HTTP2_SERVER_SEEN
#include "conversions.hpp"
//#include "nrf.h"
#include "nrf_app.hpp"
#include "uint_generator.hpp"
#include <nghttp2/asio_http2_server.h>
using namespace nghttp2::asio_http2;
using namespace nghttp2::asio_http2::server;
using namespace oai::nrf::model;
using namespace oai::nrf::app;
class nrf_http2_server {
public:
nrf_http2_server(std::string addr, uint32_t port, nrf_app* nrf_app_inst)
: m_address(addr), m_port(port), server(), m_nrf_app(nrf_app_inst) {}
void start();
void init(size_t thr) {}
void register_nf_instance_handler(
const NFProfile& NFProfiledata, const response& response);
void deregister_nf_instance_handler(
const std::string& nfInstanceID, const response& response);
void get_nf_instance_handler(
const std::string& nfInstanceID, const response& response);
void get_nf_instances_handler(
const std::string& nfInstanceID, const response& response);
void update_instance_handler(
const std::string& nfInstanceID, const std::vector<PatchItem>& patchItem,
const response& response);
void create_subscription_handler(
const SubscriptionData& subscriptionData, const response& response);
void update_subscription_handler(
const std::string& subscriptionID,
const std::vector<PatchItem>& patchItem, const response& response);
void remove_subscription_handler(
const std::string& subscriptionID, const response& response);
void search_nf_instances_handler(
const SubscriptionData& subscriptionData, const response& response);
void access_token_request_handler(
const SubscriptionData& subscriptionData, const response& response);
void stop();
private:
util::uint_generator<uint32_t> m_promise_id_generator;
std::string m_address;
uint32_t m_port;
http2 server;
nrf_app* m_nrf_app;
protected:
static uint64_t generate_promise_id() {
return util::uint_uid_generator<uint64_t>::get_instance().get_uid();
}
};
#endif
......@@ -78,6 +78,7 @@ typedef uint32_t evsub_id_t;
#define NNRF_NFM_BASE "/nnrf-nfm/"
#define NNRF_NFM_NF_INSTANCE "/nf-instances/"
#define NNRF_NFM_STATUS_SUBSCRIBE_URL "/subscriptions"
#define NF_CURL_TIMEOUT_MS 1000L
......
......@@ -92,3 +92,15 @@ int conv::ascii_to_hex(uint8_t* dst, const char* h) {
dst[i++] = (high << 4) | low;
}
}
std::string conv::toString(const struct in_addr& inaddr) {
std::string s = {};
char str[INET6_ADDRSTRLEN] = {};
if (inet_ntop(AF_INET, (const void*) &inaddr, str, INET6_ADDRSTRLEN) ==
NULL) {
s.append("Error in_addr");
} else {
s.append(str);
}
return s;
}
\ No newline at end of file
......@@ -16,10 +16,12 @@
#include "logger.hpp"
#include "nrf-api-server.h"
#include "nrf-http2-server.h"
#include "nrf_app.hpp"
#include "nrf_client.hpp"
#include "options.hpp"
#include "pid_file.hpp"
#include "conversions.hpp"
#include "pistache/endpoint.h"
#include "pistache/http.h"
......@@ -39,6 +41,7 @@ using namespace std;
nrf_app* nrf_app_inst = nullptr;
nrf_config nrf_cfg;
NRFApiServer* api_server = nullptr;
nrf_http2_server* nrf_api_server_2 = nullptr;
//------------------------------------------------------------------------------
void my_app_signal_handler(int s) {
......@@ -112,7 +115,15 @@ int main(int argc, char** argv) {
api_server = new NRFApiServer(addr, nrf_app_inst);
api_server->init(2);
std::thread nrf_manager(&NRFApiServer::start, api_server);
// NRF NGHTTP API server (HTTP2)
nrf_api_server_2 = new nrf_http2_server(
conv::toString(nrf_cfg.sbi.addr4), nrf_cfg.sbi_http2_port, nrf_app_inst);
std::thread nrf_http2_manager(&nrf_http2_server::start, nrf_api_server_2);
nrf_manager.join();
nrf_http2_manager.join();
FILE* fp = NULL;
std::string filename = fmt::format("/tmp/nrf_{}.status", getpid());
......
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