amf_sbi.hpp 10.1 KB
Newer Older
1 2 3 4 5
/*
 * 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
6 7 8
 * 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
9 10 11 12 13 14 15 16 17 18 19 20 21
 *
 *      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
 */

22
/*! \file amf_sbi.hpp
23
 \brief
24
 \author Keliang DU (BUPT), Tien-Thinh NGUYEN (EURECOM)
25 26 27 28
 \date 2020
 \email: contact@openairinterface.org
 */

29 30
#ifndef _AMF_SBI_H_
#define _AMF_SBI_H_
31

dukl's avatar
dukl committed
32 33
#include <map>
#include <shared_mutex>
dukl's avatar
dukl committed
34
#include <string>
35

36 37
#include "AuthenticationInfo.h"
#include "UEAuthenticationCtx.h"
38
#include "itti_msg_n11.hpp"
39
#include "itti_msg_sbi.hpp"
40
#include "pdu_session_context.hpp"
dukl's avatar
dukl committed
41

kharade's avatar
kharade committed
42 43 44 45
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>

46 47
namespace amf_application {

48
class amf_sbi {
49
 public:
50 51
  amf_sbi();
  ~amf_sbi();
52

53 54 55 56 57 58
  /*
   * Handle ITTI message (Nsmf_PDUSessionCreateSMContext) to create a new PDU
   * Session SM context
   * @param [itti_nsmf_pdusession_create_sm_context&]: ITTI message
   * @return void
   */
Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
59
  void handle_itti_message(itti_nsmf_pdusession_create_sm_context&);
60 61 62 63 64 65 66

  /*
   * Handle ITTI message (Nsmf_PDUSessionUpdateSMContext) to update a PDU
   * Session SM context
   * @param [itti_nsmf_pdusession_update_sm_context&]: ITTI message
   * @return void
   */
Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
67
  void handle_itti_message(itti_nsmf_pdusession_update_sm_context& itti_msg);
68 69 70 71 72 73 74

  /*
   * Handle ITTI message (Nsmf_PDUSessionReleaseSMContext) to release a PDU
   * Session
   * @param [itti_nsmf_pdusession_release_sm_context&]: ITTI message
   * @return void
   */
Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
75
  void handle_itti_message(itti_nsmf_pdusession_release_sm_context& itti_msg);
76 77 78 79 80 81

  /*
   * Handle ITTI message (receiving PDU Session Resource Setup Response)
   * @param [itti_pdu_session_resource_setup_response&]: ITTI message
   * @return void
   */
Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
82
  void handle_itti_message(itti_pdu_session_resource_setup_response& itti_msg);
83 84 85 86 87 88

  /*
   * Handle ITTI message to send Event Notification to the subscribed NFs
   * @param [itti_sbi_notify_subscribed_event&]: ITTI message
   * @return void
   */
89
  void handle_itti_message(itti_sbi_notify_subscribed_event& itti_msg);
90 91 92

  /*
   * Handle ITTI message to get the Slice Selection Subscription Data from UDM
93
   * @param [itti_sbi_slice_selection_subscription_data&]: ITTI message
94 95
   * @return void
   */
96
  void handle_itti_message(
97
      itti_sbi_slice_selection_subscription_data& itti_msg);
98 99 100 101

  /*
   * Handle ITTI message to get the Network Slice Selection Information from
   * NSSF
102
   * @param [itti_sbi_network_slice_selection_information&]: ITTI message
103 104
   * @return void
   */
105
  void handle_itti_message(
106
      itti_sbi_network_slice_selection_information& itti_msg);
107

108 109
  /*
   * Handle ITTI message to reroute N1 message to the targer AMF
110
   * @param [itti_sbi_n1_message_notify&]: ITTI message
111 112
   * @return void
   */
113
  void handle_itti_message(itti_sbi_n1_message_notify& itti_msg);
114 115 116

  /*
   * Handle ITTI message to discover NF instance information from NRF
117
   * @param [itti_sbi_nf_instance_discovery&]: ITTI message
118 119
   * @return void
   */
120
  void handle_itti_message(itti_sbi_nf_instance_discovery& itti_msg);
121

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
  /*
   * Handle request to create a new PDU Session
   * @param [const std::string&] supi: SUPI
   * @param [std::shared_ptr<pdu_session_context>&] psc: Pointer to the PDU
   * Session Context
   * @param [const std::string&] smf_addr: SMF's Address
   * @param [const std::string&] smf_api_version: SMF's API version
   * @param [const std::string&] smf_port: SMF's HTTP port
   * @param [bstring] sm_msg: SM message
   * @param [const std::string&] dnn: DNN
   * @return void
   */
  void handle_pdu_session_initial_request(
      const std::string& supi, std::shared_ptr<pdu_session_context>& psc,
      const std::string& smf_addr, const std::string& smf_api_version,
      const std::string& smf_port, bstring sm_msg, const std::string& dnn);
138

139 140 141 142 143 144 145 146 147
  /*
   * Send SM Context response error to AMF
   * @param [const long] code: HTTP response code
   * @param [const std::string&] cause: Response cause
   * @param [bstring] n1sm: N1 SM message
   * @param [const std::string&] supi: SUPI
   * @param [const uint8_t] pdu_session_id: PDU Session ID
   * @return void
   */
Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
148
  void handle_post_sm_context_response_error(
149 150
      const long code, const std::string& cause, bstring n1sm,
      const std::string& supi, const uint8_t pdu_session_id);
dukl's avatar
dukl committed
151

152 153
  /*
   * Handle ITTI message to register to NRF
154
   * @param [itti_sbi_register_nf_instance_request&]: ITTI message
155 156 157
   * @return void
   */
  void register_nf_instance(
158
      std::shared_ptr<itti_sbi_register_nf_instance_request> msg);
Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
159

160 161 162 163 164 165 166 167 168 169 170 171 172
  /*
   * Send the request to update PDU session context at SMF
   * @param [const std::string&] supi: SUPI
   * @param [std::shared_ptr<pdu_session_context>&] psc: Pointer to the PDU
   * Session Context
   * @param [const std::string&] smf_addr: SMF's Address
   * @param [bstring] sm_msg: SM message
   * @param [const std::string&] dnn: DNN
   * @return void
   */
  void send_pdu_session_update_sm_context_request(
      const std::string& supi, std::shared_ptr<pdu_session_context>& psc,
      const std::string& smf_addr, bstring sm_msg, const std::string& dnn);
173

174 175 176 177 178 179 180 181 182 183
  /*
   * Select SMF from the configuration file
   * @param [const std::string&] smf_addr: SMF's Address
   * @param [const std::string&] smf_port: SMF's HTTP port
   * @param [const std::string&] smf_api_version: SMF's API version
   * @return true if successful, otherwise return false
   */
  bool smf_selection_from_configuration(
      std::string& smf_addr, std::string& smf_port,
      std::string& smf_api_version);
184

185 186 187 188 189 190 191 192 193 194 195
  /*
   * Find suitable SMF from NRF (based on snssai, plmn and dnn)
   * @param [std::string&] smf_addr: SMF's Address
   * @param [std::string&] smf_port: SMF's HTTP port
   * @param [std::string&] smf_api_version: SMF's API version
   * @param [const snssai_t&] snssai: SNSSAI
   * @param [const plmn_t&] plmn: PLMN
   * @param [const std::string&] dnn: DNN
   * @param [const std::string&] nrf_uri: NRF's NF Discovery Service URI
   * @return true if successful, otherwise return false
   */
kharade's avatar
kharade committed
196
  bool discover_smf(
197
      std::string& smf_addr, std::string& smf_port,
198 199
      std::string& smf_api_version, const snssai_t& snssai, const plmn_t& plmn,
      const std::string& dnn, const std::string& nrf_uri = {});
kharade's avatar
kharade committed
200

201 202 203 204 205 206 207 208 209
  /*
   * Send UE Authentication Request to AUSF
   * @param [const oai::amf::model::AuthenticationInfo&] auth_info:
   * Authentication Information
   * @param [oai::amf::model::UEAuthenticationCtx& ] ue_auth_ctx: UE
   * Authentication Context response
   * @param [const uint8_t] http_version: HTTP versioin
   * @return true if successful, otherwise return false
   */
210
  bool send_ue_authentication_request(
211 212 213
      const oai::amf::model::AuthenticationInfo& auth_info,
      oai::amf::model::UEAuthenticationCtx& ue_auth_ctx,
      const uint8_t& http_version);
Tien-Thinh Nguyen's avatar
Tien-Thinh Nguyen committed
214

215 216 217 218 219 220 221 222
  /*
   * Get NRF's URI from NSSF/configuration file
   * @param [const snssai_t&] snssai: SNSSAI
   * @param [const plmn_t&] plmn: PLMN
   * @param [const std::string&] dnn: DNN
   * @param [std::string&] nrf_uri: NRF's NF Discovery Service URI
   * @return true if successful, otherwise return false
   */
223 224 225
  bool get_nrf_uri(
      const snssai_t& snssai, const plmn_t& plmn, const std::string& dnn,
      std::string& nrf_uri);
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274

  /*
   * CURL client to send request to the HTTP server
   * @param [const std::string&] remote_uri: Server's Address
   * @param [const std::string&] json_data: Json data (msg body)
   * @param [const std::string&] n1sm_msg: N1 SM message
   * @param [ const std::string&] n2sm_msg: N2 SM message
   * @param [ const std::string&] supi: SUPI
   * @param [const std::string&] pdu_session_id: PDU Session ID
   * @param [const uint8_t&] http_version: HTTP versioin
   * @param [const uint32_t&] promise_id: Promise ID
   * @return void
   */
  void curl_http_client(
      const std::string& remote_uri, const std::string& json_data,
      const std::string& n1sm_msg, const std::string& n2sm_msg,
      const std::string& supi, const uint8_t& pdu_session_id,
      const uint8_t& http_version = 1, const uint32_t& promise_id = 0);

  /*
   * CURL client to send request to the HTTP server
   * @param [const std::string&] remote_uri: Server's Address
   * @param [const std::string&] method: HTTP method
   * @param [const std::string&] msg_body: Msg body
   * @param [std::string&] response_json: Respone in Json format
   * @param [uint32_t&] response_code: HTTP Response code
   * @param [const uint8_t&] http_version: HTTP versioin
   * @return void
   */
  void curl_http_client(
      const std::string& remote_uri, const std::string& method,
      const std::string& msg_body, nlohmann::json& response_json,
      uint32_t& response_code, const uint8_t& http_version = 1);

  /*
   * CURL client to send request to the HTTP server
   * @param [const std::string&] remote_uri: Server's Address
   * @param [std::string&] json_data: Msg body
   * @param [std::string&] n1sm_msg: N1 SM message
   * @param [std::string&] n2sm_msg: N2 SM message
   * @param [const uint8_t&] http_version: HTTP versioin
   * @param [uint32_t&] response_code: HTTP Response code
   * @param [const uint32_t&] promise_id: Promise ID
   * @return void
   */
  void curl_http_client(
      const std::string& remote_uri, std::string& json_data,
      std::string& n1sm_msg, std::string& n2sm_msg, const uint8_t& http_version,
      uint32_t& response_code, const uint32_t& promise_id = 0);
275
};
dukl's avatar
dukl committed
276

277
}  // namespace amf_application
dukl's avatar
dukl committed
278 279

#endif