Commit bda176b2 authored by Niuhaiwen's avatar Niuhaiwen

dataexposure from amf

parent 79fd5d1e
......@@ -213,6 +213,8 @@ void amf_app_task(void*) {
tid = itti_inst->timer_setup(
amf_cfg.statistics_interval, 0, TASK_AMF_APP,
TASK_AMF_APP_PERIODIC_STATISTICS, 0);
stacs.display();
#if 0
long average_cap = 0;
for(int i=0;i<amf_capability.size();i++){
average_cap += amf_capability[i];
......@@ -235,6 +237,7 @@ void amf_app_task(void*) {
//double sumValue = accumulate(begin(delay_nudsf), end(delay_nudsf), 0.0);
//double meanValue = sumValue / delay_nudsf.size();
//Logger::amf_app().debug("dukl meanValue %4f", meanValue);
#endif
#if 0
if(delay_nudsf.size() == last_delay_nudsf_size && delay_nudsf.size()!=0){
Logger::amf_app().debug("total time %9f", accumulate(begin(delay_nudsf), end(delay_nudsf), 0.0));
......
......@@ -2180,11 +2180,14 @@ bool amf_n1::authentication_vectors_from_ausf(
#endif
Logger::amf_n1().debug("authentication_vectors_from_ausf");
std::string ausf_ip =
std::string(inet_ntoa(*((struct in_addr *)&amf_cfg.nausf.addr4)));
//std::string ausf_ip =
// std::string(inet_ntoa(*((struct in_addr *)&amf_cfg.nausf.addr4)));
std::string ausf_port = std::to_string(amf_cfg.nausf.port);
//printf("ausf ip: %s\n", ausf_ip.c_str());
printf("ausf config ip: %s\n", amf_cfg.nausf.addr4.c_str());
//ausf_ip = "10.244.2.6";
std::string remoteUri =
ausf_ip + ":" + ausf_port + "/nausf-auth/v1/ue-authentications";
"http://" + amf_cfg.nausf.addr4 + ":" + ausf_port + "/nausf-auth/v1/ue-authentications";
Logger::amf_n1().debug("remote ausf URI: %s",remoteUri.c_str());
std::string msgBody;
std::string Response;
......
......@@ -17,7 +17,7 @@ void AMFApiServer::init(size_t thr) {
m_nonUEN2MessagesCollectionDocumentApiImpl->init();
m_nonUEN2MessagesSubscriptionsCollectionDocumentApiImpl->init();
m_subscriptionsCollectionDocumentApiImpl->init();
m_dataExposure->init();
m_testSignallingApiImpl->init();
Logger::amf_server().debug("Initiate AMF server endpoints done!");
}
......
......@@ -16,6 +16,7 @@
#include "NonUEN2MessagesCollectionDocumentApiImpl.h"
#include "NonUEN2MessagesSubscriptionsCollectionDocumentApiImpl.h"
#include "SubscriptionsCollectionDocumentApiImpl.h"
#include "DataExposure.h"
#include "TestSignallingApiImpl.h"
......@@ -65,6 +66,9 @@ class AMFApiServer {
m_testSignallingApiImpl =
std::make_shared<TestSignallingApiImpl>(
m_router, amf_app_inst);
m_dataExposure =
std::make_shared<DataExposureApi>(
m_router);
}
void init(size_t thr = 1);
......@@ -97,4 +101,6 @@ class AMFApiServer {
std::shared_ptr<TestSignallingApiImpl>
m_testSignallingApiImpl;
std::shared_ptr<DataExposureApi>
m_dataExposure;
};
/**
* 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 "DataExposure.h"
//#include "Helpers.h"
#include "logger.hpp"
#include <nlohmann/json.hpp>
#include "TransData.hpp"
#include <stdlib.h>
#include <map>
#include <algorithm>
#include <cmath>
#include "amf_statistics.hpp"
using json = nlohmann::json;
extern statistics stacs;
//using namespace org::openapitools::server::model;
namespace oai {
namespace amf {
namespace api {
using namespace oai::amf::model;
DataExposureApi::DataExposureApi(std::shared_ptr<Pistache::Rest::Router> rtr) {
router = rtr;
}
void DataExposureApi::init() {
setupRoutes();
}
void DataExposureApi::setupRoutes() {
using namespace Pistache::Rest;
Routes::Get(*router, base + "/getNFService", Routes::bind(&DataExposureApi::getNFService, this));
}
void DataExposureApi::getNFService(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
printf("getNFService\n");
try {
json resp;
int i = 0;
for (auto const& ue : stacs.ue_infos) {
Logger::amf_app().info(
"|%7d|%22s|%18s|%15s|%16d|%11d|%9s|%7d|", i + 1,
ue.second.registerStatus.c_str(), ue.second.imsi.c_str(),
ue.second.guti.c_str(), ue.second.ranid, ue.second.amfid,
(ue.second.mcc + ue.second.mnc).c_str(), ue.second.cellId);
i++;
json ues;
ues["status"] = ue.second.registerStatus.c_str();
ues["imsi"] = ue.second.imsi.c_str();
ues["guti"] = ue.second.guti.c_str();
ues["ranid"] = ue.second.ranid;
ues["amfid"] = ue.second.amfid;
ues["location"]["plmn"] = (ue.second.mcc + ue.second.mnc).c_str();
ues["location"]["cellid"] = ue.second.cellId;
resp["ues"].push_back(ues);
}
for (i = 0; i < stacs.gnbs.size(); i++) {
Logger::amf_app().info(
"| %d | Connected | 0x%x | %s "
" | %s, %d | ",
i + 1, stacs.gnbs[i].gnb_id, stacs.gnbs[i].gnb_name.c_str(),
(stacs.gnbs[i].mcc + stacs.gnbs[i].mnc).c_str(), stacs.gnbs[i].tac);
json gnbs;
gnbs["gnb_id"] = stacs.gnbs[i].gnb_id;
gnbs["gnb_name"] = stacs.gnbs[i].gnb_name.c_str();
gnbs["tai"]["plmn"] = (stacs.gnbs[i].mcc + stacs.gnbs[i].mnc).c_str();
gnbs["tai"]["tac"] = stacs.gnbs[i].tac;
resp["gnbs"].push_back(gnbs);
}
printf("response: %s\n",resp.dump().c_str());
response.send(Pistache::Http::Code::Ok, resp.dump().c_str());
return;
} catch (nlohmann::detail::exception &e) {
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
//send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
return;
}
}
}
}
}
/**
* 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.
*/
/*
* RecordCRUDApi.h
*
*
*/
#ifndef _DATA_EXPOSURE_API_H_
#define _DATA_EXPOSURE_API_H_
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
#include <pistache/optional.h>
#include <string>
#include <vector>
#include "TransData.hpp"
#include <iostream>
#include <stdlib.h>
namespace oai {
namespace amf {
namespace api {
using namespace oai::amf::model;
class DataExposureApi {
public:
DataExposureApi(std::shared_ptr<Pistache::Rest::Router>);
virtual ~DataExposureApi() {}
void init();
const std::string base = "/data_exposure/v1";
private:
void setupRoutes();
void getNFService(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
std::shared_ptr<Pistache::Rest::Router> router;
};
}
}
}
#endif /* RecordCRUDApi_H_ */
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