nrf-http2-server.h 3.28 KB
Newer Older
Rohan's avatar
Rohan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * 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"
Rohan's avatar
Rohan committed
34

Rohan's avatar
Rohan committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//#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(
Rohan's avatar
Rohan committed
58
59
      const std::string& nfType, const uint32_t& limit,
      const response& response);
Rohan's avatar
Rohan committed
60
61
62
63
64
65
66
67
68
69
70
  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(
Rohan's avatar
Rohan committed
71
72
73
      const std::string& target_nf_type, const std::string& requester_nf_type,
      const std::string& requester_nf_instance_id, const std::string& limit_nfs,
      const response& response);
Rohan's avatar
Rohan committed
74

Rohan's avatar
Rohan committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
  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