Commit 6af38a77 authored by liuyu's avatar liuyu

Merge branch 'amf_with_plugin' into stateless_amf

parents 53829e73 fd73dd63
{
"files.associations": {
"string": "cpp",
"*.h++": "cpp",
"ostream": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cfenv": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp",
"*.ipp": "cpp"
}
}
\ No newline at end of file
......@@ -11,3 +11,4 @@ set (BUILD_TOP_DIR ${OPENAIRCN_DIR}/build)
set (SRC_TOP_DIR $ENV{OPENAIRCN_DIR}/src)
include(${CMAKE_CURRENT_SOURCE_DIR}/../../src/oai-amf/CMakeLists.txt)
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
################################################################################
AMF =
{
INSTANCE_ID = 10; # 0 is the default
PID_DIRECTORY = "/var/run"; # /var/run is the default
AMF_NAME = "OAI-AMF";
RELATIVE_CAPACITY = 30;
# Display statistics about whole system (in seconds)
STATISTICS_TIMER_INTERVAL = 20; # YOUR CONFIG HERE
CORE_CONFIGURATION:
{
EMERGENCY_SUPPORT = "false";
};
GUAMI:
{
MCC = "460"; MNC = "11"; RegionID = "128"; AMFSetID = "1"; AMFPointer = "1" # YOUR GUAMI CONFIG HERE
}
SERVED_GUAMI_LIST = (
{MCC = "460"; MNC = "11"; RegionID = "128"; AMFSetID = "1"; AMFPointer = "0"} #48bits <MCC><MNC><RegionID><AMFSetID><AMFPointer>
#{MCC = "110"; MNC = "11"; RegionID = "10"; AMFSetID = "1"; AMFPointer = "1"} #48bits <MCC><MNC><RegionID><AMFSetID><AMFPointer>
);
PLMN_SUPPORT_LIST = (
{
MCC = "460"; MNC = "11"; TAC = 100; # YOUR PLMN CONFIG HERE
SLICE_SUPPORT_LIST = (
{SST = "1"; SD = "none"}, # YOUR NSSAI CONFIG HERE
{SST = "1"; SD = "12"} # YOUR NSSAI CONFIG HERE
)
}
);
INTERFACES:
{
# AMF binded interface for N1/N2 interface (NGAP)
NGAP_AMF:
{
INTERFACE_NAME = "wlp58s0"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 38412; # YOUR NETWORK CONFIG HERE
PPID = 60; # YOUR NETWORK CONFIG HERE
};
# AMF binded interface for N11
N11:
{
INTERFACE_NAME = "wlp58s0"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 8282; # YOUR NETWORK CONFIG HERE
SMF_INSTANCES_POOL = (
{SMF_INSTANCE_ID = 1; IPV4_ADDRESS = " 192.168.70.133"; PORT = "8889"; VERSION = "v2"; SELECTED = "true"}, # YOUR SMF CONFIG HERE
{SMF_INSTANCE_ID = 2; IPV4_ADDRESS = "192.168.122.2"; PORT = "80"; VERSION = "v1"; SELECTED = "false"} # YOUR SMF CONFIG HERE
);
};
};
AUTHENTICATION:
{
## MySQL mandatory options
MYSQL_server = "127.0.0.1"; # MySQL Server address
MYSQL_user = "root"; # Database server login
MYSQL_pass = "linux"; # Database server password
MYSQL_db = "OPENXG_DB"; # Your database name
## OP
OPERATOR_key = "63bfa50ee6523365ff14c1f45f88737d"; # OP key matching your database
RANDOM = "true";
};
NAS:
{
ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST = [ "NIA1" , "NIA1" , "NIA1" ];
ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST = [ "NEA0" , "NEA1" , "NEA2" ];
};
};
MODULES =
{
NGAP_MESSAGE = (
{MSG_NAME = "NGSetupRequest"; ProcedureCode = 21; TypeOfMessage = "initialMessage"}
);
};
File added
{
"files.associations": {
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cfenv": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp",
"*.ipp": "cpp"
}
}
\ No newline at end of file
......@@ -34,6 +34,8 @@
#include "itti.hpp"
#include "DLNASTransport.hpp"
#include <nlohmann/json.hpp>
#include "ngap_app.hpp"
#include "amf_config.hpp"
#include "amf_n1.hpp"
#include "amf_n11.hpp"
......@@ -282,8 +284,38 @@ void amf_app::handle_itti_message(
if (is_guti_valid) {
itti_n1_msg->guti = guti;
}
std::shared_ptr<itti_uplink_nas_data_ind> i =
std::shared_ptr<itti_uplink_nas_data_ind>(itti_n1_msg);
std::string udsf_url = "http://10.28.234.76:8081/nudsf-dr/v1/amfdata/" + std::string("ue_context/records/") + ue_context_key ;
nlohmann::json udsf_ue_context;
udsf_ue_context["meta"] ["tags"] = {
{"record_id",nlohmann::json::array({ue_context_key})},
{"from_nf_ID",nlohmann::json::array({"AMF_1234"})}
} ;
udsf_ue_context["blocks"] = nlohmann::json::array({
nlohmann::json::object({
{"ran_ue_ngap_id",to_string(uc.get()->ran_ue_ngap_id)},
{"amf_ue_ngap_id",to_string(uc.get()->amf_ue_ngap_id)},
{"isUeContextRequest",to_string(uc.get()->isUeContextRequest)},
{"rrc_estb_cause",to_string(uc.get()->rrc_estb_cause)},
{"cgi", nlohmann::json::object({
{"mcc",uc.get()->cgi.mcc},
{"mnc",uc.get()->cgi.mnc},
{"nrCellID",to_string(uc.get()->cgi.nrCellID)},
})
},
{"tai",nlohmann::json::object({
{"mcc",uc.get()->tai.mcc},
{"mnc",uc.get()->tai.mnc},
{"tac",to_string(uc.get()->tai.tac)},
})
}
})
});
std::string json_part = udsf_ue_context.dump();
amf_n2_inst->curl_http_client_udsf(udsf_url,json_part,"PUT",udsf_ue_context);
std::shared_ptr<itti_uplink_nas_data_ind> i = std::shared_ptr < itti_uplink_nas_data_ind > (itti_n1_msg);
int ret = itti_inst->send_msg(i);
if (0 != ret) {
Logger::amf_app().error(
......
This diff is collapsed.
This diff is collapsed.
......@@ -38,8 +38,10 @@
#include "ue_ngap_context.hpp"
#include "amf.hpp"
#include <nlohmann/json.hpp>
namespace amf_application {
namespace amf_application{
#define UDSF_CURL_TIMEOUT_MS 100L
class amf_n2 : public ngap::ngap_app {
public:
......@@ -71,6 +73,9 @@ class amf_n2 : public ngap::ngap_app {
void set_ran_ue_ngap_id_2_ue_ngap_context(
const uint32_t& ran_ue_ngap_id, std::shared_ptr<ue_ngap_context> unc);
bool curl_http_client_udsf(std::string remoteUri,std::string jsonData,std::string http_mothed,nlohmann::json &udsf_response) ;
private:
std::map<uint32_t, std::shared_ptr<ue_ngap_context>>
......
......@@ -35,6 +35,7 @@ include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories(${SRC_TOP_DIR}/secu_algorithms/nas_enc_int)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/model)
add_library (CONTEXTS STATIC
${CMAKE_CURRENT_SOURCE_DIR}/gNB_context.cpp
......
......@@ -27,3 +27,154 @@
*/
#include "gNB_context.hpp"
#include <nlohmann/json.hpp>
#include "logger.hpp"
#include "Record.h"
using namespace std;
using namespace oai::amf::model;
bool get_value_string(const nlohmann::json &j, const string & nm, string &value){
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == nm)
{
//if((it_block->at("Content-Type") == "varhcar")
value = it_block->at("content");
return true;
}
block_set.erase(it_block++);
}
return false;
}
// bool get_value_int(const nlohmann::json &j, const string & nm, long &value){
// Record record;
// nlohmann::json::parse(j.dump()).get_to(record);
// std::set<nlohmann::json> block_set = record.getBlocks();
// std::set<nlohmann::json>::iterator it_block;
// for(it_block=block_set.begin();it_block!=block_set.end();)
// {
// if(it_block->at("Content-ID") == nm)
// {
// string s = it_block->at("content");
// value = atoi(s.c_str());
// return true;
// }
// block_set.erase(it_block++);
// }
// return false;
// }
long gnb_context::gnb_context_globalRanNodeId_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "globalRanNodeId")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value from json is error");
// long a;
// if(!get_value_int(j,"globalRanNodeId",a))
// Logger::amf_server().error("get_value from json is error");
// return a;
}
std::string gnb_context::gnb_context_gnb_name_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "gnb_name")
{
string s = it_block->at("content");
return s;
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value from json is error");
}
int gnb_context::gnb_context_ng_state_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "ng_state")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value from json is error");
}
sctp_stream_id_t gnb_context::gnb_context_next_sctp_stream_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "next_sctp_stream")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value from json is error");
}
sctp_stream_id_t gnb_context::gnb_context_instreams_from_json(nlohmann::json j)
{
Record record;
nlohmann::json::parse(j.dump()).get_to(record);
std::set<nlohmann::json> block_set = record.getBlocks();
std::set<nlohmann::json>::iterator it_block;
for(it_block=block_set.begin();it_block!=block_set.end();)
{
if(it_block->at("Content-ID") == "instreams")
{
string s = it_block->at("content");
return atoi(s.c_str());
}
block_set.erase(it_block++);
}
Logger::amf_server().error("get_value from json is error");
}
bool gnb_context::gnb_context_from_json(nlohmann::json j)
{
//std::shared_ptr<gnb_context> gc1;
globalRanNodeId = gnb_context_globalRanNodeId_from_json(j);
gnb_name = gnb_context_gnb_name_from_json(j);
ng_state = amf_ng_gnb_state_s(gnb_context_ng_state_from_json(j));
next_sctp_stream = gnb_context_next_sctp_stream_from_json(j);
next_sctp_stream = gnb_context_instreams_from_json(j);
// printf("gnbname-%s\n",gnb_name.c_str());
// printf("globalgnbid-%d\n",globalRanNodeId);
// printf("next stream-%d\n",next_sctp_stream);
return true;
}
......@@ -32,7 +32,7 @@
#include <stdint.h>
#include <string>
#include <vector>
#include <nlohmann/json.hpp>
#include "sctp_server.hpp"
#include "NgapIEsStruct.hpp"
......@@ -43,10 +43,17 @@ extern "C" {
using namespace sctp;
using namespace ngap;
using namespace std;
enum amf_ng_gnb_state_s { NGAP_INIT, NGAP_RESETING, NGAP_READY, NGAP_SHUTDOWN };
class gnb_context {
public:
long gnb_context_globalRanNodeId_from_json(nlohmann::json j);
std::string gnb_context_gnb_name_from_json(nlohmann::json j);
int gnb_context_ng_state_from_json(nlohmann::json j);
sctp_stream_id_t gnb_context_next_sctp_stream_from_json(nlohmann::json j);
sctp_stream_id_t gnb_context_instreams_from_json(nlohmann::json j);
bool gnb_context_from_json(nlohmann::json j);
enum amf_ng_gnb_state_s ng_state;
std::string gnb_name;
......
......@@ -341,6 +341,7 @@ add_executable(amf
${SRC_TOP_DIR}/oai-amf/options.cpp
${SRC_TOP_DIR}/itti/itti.cpp
${SRC_TOP_DIR}/itti/itti_msg.cpp
${SRC_TOP_DIR}/ngap/ngap_app/ngap_app.cpp
)
IF(STATIC_LINKING)
......
......@@ -51,7 +51,6 @@ extern void ue_gnb_simulator();
using namespace config;
using namespace amf_application;
amf_config amf_cfg;
amf_modules modules;
itti_mw* itti_inst = nullptr;
......
......@@ -30,11 +30,14 @@ include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/contexts)
include_directories(${SRC_TOP_DIR}/nas/common)
include_directories(${SRC_TOP_DIR}/ngap/libngap)
include_directories(${SRC_TOP_DIR}/ngap/ngap_app)
include_directories(${SRC_TOP_DIR}/ngap/ngapIEs)
include_directories(${SRC_TOP_DIR}/ngap/ngapMsgs)
include_directories(${SRC_TOP_DIR}/secu_algorithms/5gaka)
include_directories(${SRC_TOP_DIR}/secu_algorithms/nas_enc_int)
include_directories(${SRC_TOP_DIR}/utils)
include_directories(${SRC_TOP_DIR}/utils/bstr)
include_directories(${SRC_TOP_DIR}/sctp)
include_directories(${SRC_TOP_DIR}/sbi/amf_server)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/api)
include_directories(${SRC_TOP_DIR}/sbi/amf_server/impl)
......
......@@ -13,6 +13,7 @@
#include "IndividualSubscriptionDocumentApi.h"
#include "Helpers.h"
#include "TransData.hpp"
namespace oai {
namespace amf {
......@@ -46,19 +47,56 @@ void IndividualSubscriptionDocumentApi::setupRoutes() {
a_mf_status_change_un_subscribe_handler,
this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(
&IndividualSubscriptionDocumentApi::
individual_subscription_document_api_default_handler,
this));
Routes::Put(*router, base + "/plugin_n2/:assoc_id/:stream", Routes::bind(&IndividualSubscriptionDocumentApi::gnb_message_from_plugin_handler, this));
// Default handler, called when a route is not found
router->addCustomHandler(Routes::bind(&IndividualSubscriptionDocumentApi::individual_subscription_document_api_default_handler, this));
}
void IndividualSubscriptionDocumentApi::
a_mf_status_change_subscribe_modfy_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response) {
// Getting the path params
auto subscriptionId = request.param(":subscriptionId").as<std::string>();
void IndividualSubscriptionDocumentApi::gnb_message_from_plugin_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// Getting the path params
auto assoc_id = request.param(":assoc_id").as<std::uint32_t>();
auto stream = request.param(":stream").as<std::uint32_t>();
// Getting the body param
printf("-------------------------------------------plugin http request\n-----------");
//SubscriptionData subscriptionData;
TransData transdata;
std::cout<<request.body()<<std::endl;
try {
nlohmann::json::parse(request.body()).get_to(transdata);
this->gnb_message_from_plugin(assoc_id, stream,transdata, response);
} catch (nlohmann::detail::exception &e) {
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (std::exception &e) {
//send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return;
}
}
void IndividualSubscriptionDocumentApi::a_mf_status_change_subscribe_modfy_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// Getting the path params
auto subscriptionId = request.param(":subscriptionId").as<std::string>();
// Getting the body param
SubscriptionData subscriptionData;
try {
nlohmann::json::parse(request.body()).get_to(subscriptionData);
this->a_mf_status_change_subscribe_modfy(subscriptionId, subscriptionData, response);
} catch (nlohmann::detail::exception &e) {
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (std::exception &e) {
//send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return;
}
// Getting the body param
......
......@@ -23,6 +23,7 @@
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <pistache/optional.h>
#include "TransData.hpp"
#include "ProblemDetails.h"
#include "SubscriptionData.h"
......@@ -34,53 +35,44 @@ namespace api {
using namespace oai::amf::model;
class IndividualSubscriptionDocumentApi {
public:
IndividualSubscriptionDocumentApi(std::shared_ptr<Pistache::Rest::Router>);
virtual ~IndividualSubscriptionDocumentApi() {}
void init();
class IndividualSubscriptionDocumentApi {
public:
IndividualSubscriptionDocumentApi(std::shared_ptr<Pistache::Rest::Router>);
virtual ~IndividualSubscriptionDocumentApi() {}
void init();
const std::string base = "/namf-comm/v1";
const std::string base = "/namf-comm/v1";
private:
void setupRoutes();
private:
void setupRoutes();
void a_mf_status_change_subscribe_modfy_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
void a_mf_status_change_un_subscribe_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
void individual_subscription_document_api_default_handler(
const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response);
void a_mf_status_change_subscribe_modfy_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void a_mf_status_change_un_subscribe_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void individual_subscription_document_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
void gnb_message_from_plugin_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
/// <summary>
/// Namf_Communication AMF Status Change Subscribe Modify service Operation
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="subscriptionId">AMF Status Change Subscription
/// Identifier</param> <param name="subscriptionData"></param>
virtual void a_mf_status_change_subscribe_modfy(
const std::string& subscriptionId,
const SubscriptionData& subscriptionData,
Pistache::Http::ResponseWriter& response) = 0;
/// <summary>
/// Namf_Communication AMF Status Change Subscribe Modify service Operation
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="subscriptionId">AMF Status Change Subscription Identifier</param>
/// <param name="subscriptionData"></param>
virtual void a_mf_status_change_subscribe_modfy(const std::string &subscriptionId, const SubscriptionData &subscriptionData, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Namf_Communication AMF Status Change UnSubscribe service Operation
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="subscriptionId">AMF Status Change Subscription
/// Identifier</param>
virtual void a_mf_status_change_un_subscribe(
const std::string& subscriptionId,
Pistache::Http::ResponseWriter& response) = 0;
/// <summary>
/// Namf_Communication AMF Status Change UnSubscribe service Operation
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="subscriptionId">AMF Status Change Subscription Identifier</param>
virtual void a_mf_status_change_un_subscribe(const std::string &subscriptionId, Pistache::Http::ResponseWriter &response) = 0;
virtual void gnb_message_from_plugin(const std::uint32_t &assoc_id, const std::uint16_t &stream , TransData transdata,Pistache::Http::ResponseWriter &response) =0;
};
} // namespace api
......
......@@ -12,25 +12,51 @@
*/
#include "IndividualSubscriptionDocumentApiImpl.h"
//#include "ngap_app.hpp"/
#include "bstrlib.h"
#include "amf_n2.hpp"
#include <shared_mutex>
using namespace amf_application;
using namespace ngap;
extern amf_n2 *amf_n2_inst;
extern unsigned char* format_string_as_hex(std::string str);
extern char* bstring2charString(bstring b);
extern void msg_str_2_msg_hex(std::string msg, bstring &b);
extern void convert_string_2_hex(std::string &input, std::string &output);
namespace oai {
namespace amf {
namespace api {
using namespace oai::amf::model;
IndividualSubscriptionDocumentApiImpl::IndividualSubscriptionDocumentApiImpl(
std::shared_ptr<Pistache::Rest::Router> rtr,
amf_application::amf_app* amf_app_inst)
: IndividualSubscriptionDocumentApi(rtr), m_amf_app(amf_app_inst) {}
void IndividualSubscriptionDocumentApiImpl::a_mf_status_change_subscribe_modfy(
const std::string& subscriptionId, const SubscriptionData& subscriptionData,
Pistache::Http::ResponseWriter& response) {
response.send(
Pistache::Http::Code::Ok,
"IndividualSubscriptionDocumentApiImpl::a_mf_status_change_subscribe_"
"modfy API has not been implemented yet!\n");
IndividualSubscriptionDocumentApiImpl::IndividualSubscriptionDocumentApiImpl(std::shared_ptr<Pistache::Rest::Router> rtr, amf_application::amf_app *amf_app_inst)
: IndividualSubscriptionDocumentApi(rtr), m_amf_app(amf_app_inst)
{ }
void IndividualSubscriptionDocumentApiImpl::a_mf_status_change_subscribe_modfy(const std::string &subscriptionId, const SubscriptionData &subscriptionData, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "IndividualSubscriptionDocumentApiImpl::a_mf_status_change_subscribe_modfy API has not been implemented yet!\n");
}
void IndividualSubscriptionDocumentApiImpl::gnb_message_from_plugin(const std::uint32_t &assoc_id, const std::uint16_t &stream , TransData transdata,Pistache::Http::ResponseWriter &response) {
printf("receive n2 message from plugin, sent to ngap task\n");
printf("transdata = %s\n",transdata.get_amf_data().c_str());
uint8_t buffer[SCTP_RECV_BUFFER_SIZE];
std::memcpy(buffer, format_string_as_hex(transdata.get_amf_data()),transdata.get_amf_data().length()/2+1);
bstring payload = blk2bstr(buffer, transdata.get_amf_data().length()/2+1);
printf("%s\n,length %d",bdata(payload),blength(payload));
if (!amf_n2_inst->is_assoc_id_2_gnb_context(assoc_id)) {
amf_n2_inst->handle_sctp_new_association(assoc_id,10,8);
}
amf_n2_inst->handle_receive(payload,assoc_id,stream,10,8);
response.send(Pistache::Http::Code::Ok, "plugin message\n");
}
void IndividualSubscriptionDocumentApiImpl::a_mf_status_change_un_subscribe(const std::string &subscriptionId, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "IndividualSubscriptionDocumentApiImpl::a_mf_status_change_un_subscribe API has not been implemented yet!\n");
}
}
}
void IndividualSubscriptionDocumentApiImpl::a_mf_status_change_un_subscribe(
const std::string& subscriptionId,
......
......@@ -32,7 +32,7 @@
#include "ProblemDetails.h"
#include "SubscriptionData.h"
#include <string>
#include "TransData.hpp"
#include "amf_app.hpp"
namespace oai {
......@@ -41,24 +41,16 @@ namespace api {
using namespace oai::amf::model;
class IndividualSubscriptionDocumentApiImpl
: public oai::amf::api::IndividualSubscriptionDocumentApi {
public:
IndividualSubscriptionDocumentApiImpl(
std::shared_ptr<Pistache::Rest::Router>,
amf_application::amf_app* amf_app_inst);
~IndividualSubscriptionDocumentApiImpl() {}
void a_mf_status_change_subscribe_modfy(
const std::string& subscriptionId,
const SubscriptionData& subscriptionData,
Pistache::Http::ResponseWriter& response);
void a_mf_status_change_un_subscribe(
const std::string& subscriptionId,
Pistache::Http::ResponseWriter& response);
class IndividualSubscriptionDocumentApiImpl : public oai::amf::api::IndividualSubscriptionDocumentApi {
public:
IndividualSubscriptionDocumentApiImpl(std::shared_ptr<Pistache::Rest::Router>, amf_application::amf_app *amf_app_inst);
~IndividualSubscriptionDocumentApiImpl() {}
private:
amf_application::amf_app* m_amf_app;
void a_mf_status_change_subscribe_modfy(const std::string &subscriptionId, const SubscriptionData &subscriptionData, Pistache::Http::ResponseWriter &response);
void a_mf_status_change_un_subscribe(const std::string &subscriptionId, Pistache::Http::ResponseWriter &response);
void gnb_message_from_plugin(const std::uint32_t &assoc_id, const std::uint16_t &stream ,TransData transdata, Pistache::Http::ResponseWriter &response);
private:
amf_application::amf_app *m_amf_app;
};
} // namespace api
......
/**
* Nudsf_DataRepository
* Nudsf Data Repository Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0-alpha.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "Record.h"
namespace oai {
namespace amf {
namespace model {
Record::Record()
{
m_BlocksIsSet = false;
}
Record::~Record()
{
}
void Record::validate()
{
// TODO: implement validation
}
void to_json(nlohmann::json& j, const Record& o)
{
j = nlohmann::json();
j["meta"] = o.m_Meta;
if(o.blocksIsSet() || !o.m_Blocks.empty())
j["blocks"] = o.m_Blocks;
}
void from_json(const nlohmann::json& j, Record& o)
{
j.at("meta").get_to(o.m_Meta);
if(j.find("blocks") != j.end())
{
j.at("blocks").get_to(o.m_Blocks);
o.m_BlocksIsSet = true;
}
}
RecordMeta Record::getMeta() const
{
return m_Meta;
}
void Record::setMeta(RecordMeta const& value)
{
m_Meta = value;
}
std::set<nlohmann::json> Record::getBlocks() const
{
return m_Blocks;
}
void Record::setBlocks(std::set<nlohmann::json> const& value)
{
m_Blocks = value;
m_BlocksIsSet = true;
}
bool Record::blocksIsSet() const
{
return m_BlocksIsSet;
}
void Record::unsetBlocks()
{
m_BlocksIsSet = false;
}
}
}
}
/**
* Nudsf_DataRepository
* Nudsf Data Repository Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0-alpha.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* Record.h
*
* Definition of a Record
*/
#ifndef Record_H_
#define Record_H_
#include "RecordMeta.h"
#include <vector>
//#include "AnyType.h"
#include <nlohmann/json.hpp>
namespace oai {
namespace amf {
namespace model {
// struct block{
// std::string Content_id ;
// std::string Content_type;
// std::string caontent;
// };
/// <summary>
/// Definition of a Record
/// </summary>
class Record
{
public:
Record();
virtual ~Record();
void validate();
/////////////////////////////////////////////
/// Record members
/// <summary>
///
/// </summary>
RecordMeta getMeta() const;
void setMeta(RecordMeta const& value);
/// <summary>
/// list of opaque Block&#39;s in this Record
/// </summary>
std::set<nlohmann::json> getBlocks() const;
void setBlocks(std::set<nlohmann::json> const& value);
bool blocksIsSet() const;
void unsetBlocks();
friend void to_json(nlohmann::json& j, const Record& o);
friend void from_json(const nlohmann::json& j, Record& o);
protected:
RecordMeta m_Meta;
//std::vector< std::map<std::string, std::string>> m_Blocks;
//std::vector< std::map<std::string, nlohmann::json>> m_Blocks;
std::set<nlohmann::json> m_Blocks;
bool m_BlocksIsSet;
};
}
}
}
#endif /* Record_H_ */
/**
* Nudsf_DataRepository
* Nudsf Data Repository Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0-alpha.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "RecordMeta.h"
namespace oai {
namespace amf {
namespace model {
RecordMeta::RecordMeta()
{
m_Ttl = "";
m_TtlIsSet = false;
m_CallbackReference = "";
m_CallbackReferenceIsSet = false;
m_TagsIsSet = false;
}
RecordMeta::~RecordMeta()
{
}
void RecordMeta::validate()
{
// TODO: implement validation
}
void to_json(nlohmann::json& j, const RecordMeta& o)
{
j = nlohmann::json();
if(o.ttlIsSet())
j["ttl"] = o.m_Ttl;
if(o.callbackReferenceIsSet())
j["callbackReference"] = o.m_CallbackReference;
if(o.tagsIsSet() || !o.m_Tags.empty())
j["tags"] = o.m_Tags;
}
void from_json(const nlohmann::json& j, RecordMeta& o)
{
if(j.find("ttl") != j.end())
{
j.at("ttl").get_to(o.m_Ttl);
o.m_TtlIsSet = true;
}
if(j.find("callbackReference") != j.end())
{
j.at("callbackReference").get_to(o.m_CallbackReference);
o.m_CallbackReferenceIsSet = true;
}
if(j.find("tags") != j.end())
{
j.at("tags").get_to(o.m_Tags);
o.m_TagsIsSet = true;
}
}
std::string RecordMeta::getTtl() const
{
return m_Ttl;
}
void RecordMeta::setTtl(std::string const& value)
{
m_Ttl = value;
m_TtlIsSet = true;
}
bool RecordMeta::ttlIsSet() const
{
return m_TtlIsSet;
}
void RecordMeta::unsetTtl()
{
m_TtlIsSet = false;
}
std::string RecordMeta::getCallbackReference() const
{
return m_CallbackReference;
}
void RecordMeta::setCallbackReference(std::string const& value)
{
m_CallbackReference = value;
m_CallbackReferenceIsSet = true;
}
bool RecordMeta::callbackReferenceIsSet() const
{
return m_CallbackReferenceIsSet;
}
void RecordMeta::unsetCallbackReference()
{
m_CallbackReferenceIsSet = false;
}
std::map<std::string, std::set<std::string>>& RecordMeta::getTags()
{
return m_Tags;
}
void RecordMeta::setTags(std::map<std::string, std::set<std::string>> const& value)
{
m_Tags = value;
m_TagsIsSet = true;
}
bool RecordMeta::tagsIsSet() const
{
return m_TagsIsSet;
}
void RecordMeta::unsetTags()
{
m_TagsIsSet = false;
}
}
}
}
/**
* Nudsf_DataRepository
* Nudsf Data Repository Service. © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0-alpha.2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* RecordMeta.h
*
* Meta data of a Record
*/
#ifndef RecordMeta_H_
#define RecordMeta_H_
#include <set>
#include <string>
#include <map>
#include <vector>
#include <nlohmann/json.hpp>
namespace oai {
namespace amf {
namespace model {
/// <summary>
/// Meta data of a Record
/// </summary>
class RecordMeta
{
public:
RecordMeta();
virtual ~RecordMeta();
void validate();
/////////////////////////////////////////////
/// RecordMeta members
/// <summary>
///
/// </summary>
std::string getTtl() const;
void setTtl(std::string const& value);
bool ttlIsSet() const;
void unsetTtl();
/// <summary>
///
/// </summary>
std::string getCallbackReference() const;
void setCallbackReference(std::string const& value);
bool callbackReferenceIsSet() const;
void unsetCallbackReference();
/// <summary>
/// A dictionary of {\&quot;tagName\&quot;: [ \&quot;tagValue\&quot;, ...] }. A tag name can be used to retrieve a Record. The tagValue are unique.
/// </summary>
std::map<std::string, std::set<std::string>>& getTags();
void setTags(std::map<std::string, std::set<std::string>> const& value);
bool tagsIsSet() const;
void unsetTags();
friend void to_json(nlohmann::json& j, const RecordMeta& o);
friend void from_json(const nlohmann::json& j, RecordMeta& o);
protected:
std::string m_Ttl;
bool m_TtlIsSet;
std::string m_CallbackReference;
bool m_CallbackReferenceIsSet;
std::map<std::string, std::set<std::string>> m_Tags;
bool m_TagsIsSet;
};
}
}
}
#endif /* RecordMeta_H_ */
/**
* Namf_Communication
* AMF Communication Service © 2019, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
#include "TransData.hpp"
#include <iostream>
namespace oai {
namespace amf {
namespace model {
TransData::TransData() {
m_transdata = "";
}
TransData::~TransData() {}
std::string TransData::get_amf_data()
{
return m_transdata;
}
void to_json(nlohmann::json& j, const TransData& o) {
j = nlohmann::json();
j["n2_data"] = o.m_transdata;
}
void from_json(const nlohmann::json& j, TransData& o) {
j.at("n2_data").get_to(o.m_transdata);
}
} // namespace model
} // namespace amf
} // namespace oai
/**
* Namf_Communication
* AMF Communication Service © 2019, 3GPP Organizational Partners (ARIB, ATIS,
* CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* The version of the OpenAPI document: 1.1.0.alpha-1
*
*
* NOTE: This class is auto generated by OpenAPI Generator
* (https://openapi-generator.tech). https://openapi-generator.tech Do not edit
* the class manually.
*/
/*
* TransData.h
*
*
*/
#ifndef _TRANSDATA_H_
#define _TRANSDATA_H_
#include <string>
#include <vector>
#include <stdlib.h>
#include <nlohmann/json.hpp>
#include <iostream>
namespace oai {
namespace amf {
namespace model {
class TransData {
public:
TransData();
virtual ~TransData();
friend void to_json(nlohmann::json& j, const TransData& o);
friend void from_json(const nlohmann::json& j, TransData& o);
std::string get_amf_data();
protected:
std::string m_transdata;
};
} // namespace model
} // namespace
} // namespace oai
#endif /* TransData_H_ */
......@@ -20,6 +20,7 @@
################################################################################
include_directories(${SRC_TOP_DIR}/../build/ext/spdlog/include)
include_directories(${SRC_TOP_DIR}/amf-app)
include_directories(${SRC_TOP_DIR}/common)
include_directories(${SRC_TOP_DIR}/common/unicode)
include_directories(${SRC_TOP_DIR}/nas/common)
......
......@@ -28,6 +28,10 @@
#include "sctp_server.hpp"
#include "logger.hpp"
#include <nlohmann/json.hpp>
#include "amf.hpp"
extern "C" {
#include <netinet/in.h>
#include <netinet/sctp.h>
......@@ -42,12 +46,13 @@ extern "C" {
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <arpa/inet.h>
#include <curl/curl.h>
#include "bstrlib.h"
}
#include <iostream>
using namespace std;
namespace sctp {
//------------------------------------------------------------------------------
......@@ -151,13 +156,15 @@ int sctp_server::sctp_read_from_socket(int sd, uint32_t ppid) {
struct sctp_sndrcvinfo sinfo = {0};
struct sockaddr_in6 addr = {0};
uint8_t buffer[SCTP_RECV_BUFFER_SIZE];
if (sd < 0) return -1;
// char buffer[SCTP_RECV_BUFFER_SIZE];
if (sd < 0)
return -1;
memset((void*) &addr, 0, sizeof(struct sockaddr_in6));
from_len = (socklen_t) sizeof(struct sockaddr_in6);
memset((void*) &sinfo, 0, sizeof(struct sctp_sndrcvinfo));
int n = sctp_recvmsg(
sd, (void*) buffer, SCTP_RECV_BUFFER_SIZE, (struct sockaddr*) &addr,
&from_len, &sinfo, &flags);
int n = sctp_recvmsg(sd, (void*) buffer, SCTP_RECV_BUFFER_SIZE, (struct sockaddr*) &addr, &from_len, &sinfo, &flags);
// printf("buffer = %s\n",buffer);
// std::cout<<buffer<<std::endl;
if (n < 0) {
Logger::sctp().error("sctp_recvmsg error:: %s:%d", strerror(errno), errno);
return SCTP_RC_ERROR;
......@@ -194,16 +201,14 @@ int sctp_server::sctp_read_from_socket(int sd, uint32_t ppid) {
ntohl(sinfo.sinfo_ppid), association->ppid);
return SCTP_RC_ERROR;
}
Logger::sctp().info(
"****[Assoc_id %d, Socket %d] Received a msg (length %d) from port %d, "
"on stream %d, PPID %d ****",
sinfo.sinfo_assoc_id, sd, n, ntohs(addr.sin6_port), sinfo.sinfo_stream,
ntohl(sinfo.sinfo_ppid));
Logger::sctp().info("****[Assoc_id %d, Socket %d] Received a msg (length %d) from port %d, on stream %d, PPID %d ****", sinfo.sinfo_assoc_id, sd, n, ntohs(addr.sin6_port), sinfo.sinfo_stream, ntohl(sinfo.sinfo_ppid));
bstring payload = blk2bstr(buffer, n);
// handle payload
app_->handle_receive(
payload, (sctp_assoc_id_t) sinfo.sinfo_assoc_id, sinfo.sinfo_stream,
association->instreams, association->outstreams);
//handle payload
Logger::sctp().info("%s\n,length %d",bdata(payload),blength(payload));
app_->handle_receive(payload, (sctp_assoc_id_t) sinfo.sinfo_assoc_id, sinfo.sinfo_stream, association->instreams, association->outstreams);
}
}
......@@ -414,5 +419,98 @@ int sctp_server::sctp_send_msg(
assoc_desc->messages_sent++;
return 0;
}
void octet_stream_2_hex_stream(uint8_t* buf, int len, std::string& out) {
out = "";
char* tmp = (char*) calloc(1, 2 * len * sizeof(uint8_t) + 1);
for (int i = 0; i < len; i++) {
sprintf(tmp + 2 * i, "%02x", buf[i]);
}
tmp[2 * len] = '\0';
out = tmp;
printf("n1sm buffer: %s\n", out.c_str());
}
static std::size_t callback(
const char* in, std::size_t size, std::size_t num, std::string* out) {
const std::size_t totalBytes(size * num);
out->append(in, totalBytes);
return totalBytes;
}
void sctp_server::curl_http_client_Plugin(sctp_assoc_id_t assoc_id, sctp_stream_id_t stream,bstring payload)
{
printf("使用http发送到pluginf\n");
std::string ngapmsg;
octet_stream_2_hex_stream((uint8_t*) bdata(payload), blength(payload), ngapmsg);
Logger::sctp().debug(
"[Assoc ID %d] Sending buffer %p of %d bytes on stream %d,ngapmsg length %d ",
assoc_id, bdata(payload), blength(payload), stream,ngapmsg.length());
nlohmann::json json_data = {};
json_data["n2_data"] = ngapmsg;
std::string url =
"http://" + std::string("10.112.202.24") +
":" + std::to_string(38414) + "/nplugin-dr/v1/" +
to_string (assoc_id ) + "/" + to_string (stream) ;
Logger::sctp().debug(
"Send N2 message to PLUGIN , PLUGIN URL %s", url.c_str());
} // namespace sctp
std::string body = json_data.dump();
Logger::sctp().debug(
"Send N2 message to PLUGIN , msg body: \n %s", body.c_str());
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl = curl_easy_init();
if (curl) {
CURLcode res = {};
struct curl_slist* headers = nullptr;
// std::string content_type = "content-type: multipart/related; boundary=" +
// std::string(CURL_MIME_BOUNDARY);
// headers = curl_slist_append(headers, content_type.c_str());
headers = curl_slist_append(headers, "content-type: application/json");
headers = curl_slist_append(headers, "Expect:");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, PLUGIN_CURL_TIMEOUT_MS);
// Response information.
long httpCode = {0};
std::unique_ptr<std::string> httpData(new std::string());
//std::unique_ptr<std::string> httpHeaderData(new std::string());
// Hook up data handling function.
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
// curl_easy_setopt(curl, CURLOPT_HEADERDATA, httpHeaderData.get());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, body.length());
//curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body_data);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
res = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
Logger::sctp().debug("Send NGAP message to PLUGIN, response from PLUGIN, HTTP Code: %d", httpCode);
if (static_cast<http_response_codes_e>(httpCode) ==http_response_codes_e::HTTP_RESPONSE_CODE_0) {
Logger::sctp().info( "Cannot get response when calling %s", url.c_str());
// free curl before returning
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return;
}
if (static_cast<http_response_codes_e>(httpCode) ==http_response_codes_e::HTTP_RESPONSE_CODE_200_OK) {
Logger::sctp().info("sending successful when calling %s", url.c_str());
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return;
}
curl_global_cleanup();
}
}
}
......@@ -44,6 +44,8 @@ extern "C" {
#define SCTP_RC_NORMAL_READ 0
#define SCTP_RC_DISCONNECT 1
#define PLUGIN_CURL_TIMEOUT_MS 100L
namespace sctp {
typedef uint16_t sctp_stream_id_t;
......@@ -91,11 +93,10 @@ class sctp_server {
public:
sctp_server(const char* address, const uint16_t port_num);
virtual ~sctp_server();
int create_socket(const char* address, const uint16_t port_num);
void start_receive(sctp_application* app);
int sctp_send_msg(
sctp_assoc_id_t sctp_assoc_id, sctp_stream_id_t stream, bstring* payload);
int create_socket(const char *address, const uint16_t port_num);
void start_receive(sctp_application *app);
int sctp_send_msg(sctp_assoc_id_t sctp_assoc_id, sctp_stream_id_t stream, bstring *payload);
void curl_http_client_Plugin(sctp_assoc_id_t assoc_id, sctp_stream_id_t stream,bstring payload);
private:
static void* sctp_receiver_thread(void* arg);
int getSocket();
......
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