Commit 6761011e authored by chen2022's avatar chen2022

zhuce-php-fasongqingqiu

parent bda176b2
......@@ -50,7 +50,8 @@ install_fmt() {
cd /tmp
echo "Downloading fmt"
$SUDO rm -rf /tmp/fmt*
git clone https://github.com/fmtlib/fmt.git
#git clone https://github.com/fmtlib/fmt.git
git clone http://git.opensource5g.org/libraries/fmt.git
ret=$?;[[ $ret -ne 0 ]] && return $ret
cd fmt
cmake -DFMT_TEST=FALSE .
......@@ -84,7 +85,8 @@ install_spdlog_from_git() {
if [[ $prompt =~ [yY](es)* ]]
then
GIT_URL=https://github.com/gabime/spdlog.git
# GIT_URL=https://github.com/gabime/spdlog.git
GIT_URL=http://git.opensource5g.org/libraries/spdlog.git
echo "Install spdlog from $GIT_URL"
pushd $OPENAIRCN_DIR/build/ext
echo "Downloading spdlog"
......@@ -123,7 +125,8 @@ install_pistache_from_git() {
if [[ $prompt =~ [yY](es)* ]]
then
GIT_URL=https://github.com/oktal/pistache.git
#GIT_URL=https://github.com/oktal/pistache.git
GIT_URL=http://git.opensource5g.org/libraries/pistache.git
echo "Install Pistache from $GIT_URL"
pushd $OPENAIRCN_DIR/build/ext
echo "Downloading Pistache"
......@@ -168,7 +171,8 @@ install_nlohmann_from_git() {
if [[ $prompt =~ [yY](es)* ]]
then
GIT_URL=https://github.com/nlohmann/json.git
#GIT_URL=https://github.com/nlohmann/json.git
GIT_URL=http://git.opensource5g.org/libraries/json.git
echo "Install Nlohmann Json from $GIT_URL"
pushd $OPENAIRCN_DIR/build/ext
echo "Downloading Nlohmann"
......
......@@ -79,7 +79,11 @@ install_fb_folly_from_source(){
libdwarf-dev
ret=$?;[[ $ret -ne 0 ]] && return $ret
wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz && \
# wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz && \
cd /tmp
git clone http://git.opensource5g.org/libraries/openxg-cnlibs.git
cd /tmp/openxg-cnlibs/
tar zxf release-1.8.0.tar.gz && \
rm -f release-1.8.0.tar.gz && \
cd googletest-release-1.8.0 && \
......@@ -92,7 +96,9 @@ install_fb_folly_from_source(){
$SUDO rm -rf /tmp/folly
git clone https://github.com/facebook/folly.git
#git clone https://github.com/facebook/folly.git
git clone http://git.opensource5g.org/libraries/folly.git
ret=$?;[[ $ret -ne 0 ]] && popd && return $ret
cd folly
mkdir _build && cd _build
......
......@@ -60,7 +60,7 @@ AMF =
# AMF binded interface for N1/N2 interface (NGAP)
NGAP_AMF:
{
INTERFACE_NAME = "ens3"; # YOUR NETWORK CONFIG HERE
INTERFACE_NAME = "ens33"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 38412; # YOUR NETWORK CONFIG HERE
PPID = 60; # YOUR NETWORK CONFIG HERE
......@@ -69,12 +69,12 @@ AMF =
# AMF binded interface for N11
N11:
{
INTERFACE_NAME = "ens9"; # YOUR NETWORK CONFIG HERE
INTERFACE_NAME = "ens33"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 8282; # YOUR NETWORK CONFIG HERE
SMF_INSTANCES_POOL = (
{SMF_INSTANCE_ID = 1; IPV4_ADDRESS = "192.168.122.151"; PORT = "8889"; VERSION = "v2"; SELECTED = "true"}, # YOUR SMF CONFIG HERE
{SMF_INSTANCE_ID = 1; IPV4_ADDRESS = "192.168.43.236"; 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
);
};
......
......@@ -25,7 +25,7 @@ AMF =
PID_DIRECTORY = "/var/run"; # /var/run is the default
AMF_NAME = "OAI-AMF";
LOCAL_IP = "192.168.43.236:1001";
RELATIVE_CAPACITY = 30;
# Display statistics about whole system (in seconds)
STATISTICS_TIMER_INTERVAL = 20; # YOUR CONFIG HERE
......@@ -60,7 +60,7 @@ AMF =
# AMF binded interface for N1/N2 interface (NGAP)
NGAP_AMF:
{
INTERFACE_NAME = "eno1"; # YOUR NETWORK CONFIG HERE
INTERFACE_NAME = "ens33"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 38414; # YOUR NETWORK CONFIG HERE
PPID = 60; # YOUR NETWORK CONFIG HERE
......@@ -69,16 +69,39 @@ AMF =
# AMF binded interface for Nausf interface
NAUSF:
{
INTERFACE_NAME = "eno1"; # YOUR NETWORK CONFIG HERE
INTERFACE_NAME = "ens33"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 8383; # YOUR NETWORK CONFIG HERE
};
NUDSF:
{
IPV4_ADDRESS = "10.244.1.16";
PORT = 7123; # YOUR NETWORK CONFIG HERE
};
RISE:
{
IPV4_ADDRESS = "10.244.1.20";
PORT = 38414; # YOUR NETWORK CONFIG HERE
};
NRF :
{
IPV4_ADDRESS = "10.103.239.54"; # YOUR NRF CONFIG HERE
PORT = 80; # YOUR NRF CONFIG HERE (default: 80)
API_VERSION = "v1"; # YOUR NRF API VERSION FOR SBI CONFIG HERE
};
SUPPORT_FEATURES:
{
# STRING, {"yes", "no"},
NF_REGISTRATION = "yes"; # Set to yes if AMF resgisters to an NRF
SMF_SELECTION = "no"; # Set to yes to enable SMF discovery and selection
EXTERNAL_AUSF = "yes"; # Set to yes if AMF works with an external AUSF
EXTERNAL_UDM = "no"; # Set to yes if AMF works with an external UDM
};
# AMF binded interface for N11
N11:
{
INTERFACE_NAME = "eno1"; # YOUR NETWORK CONFIG HERE
INTERFACE_NAME = "ens33"; # YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read";
PORT = 8282; # YOUR NETWORK CONFIG HERE
......
......@@ -126,6 +126,8 @@ int amf_config::load(const std::string& config_file) {
}
try {
amf_cfg.lookupValue(AMF_CONFIG_STRING_AMF_NAME, AMF_Name);
amf_cfg.lookupValue("LOCAL_IP", local_ip);
} catch (const SettingNotFoundException& nfex) {
Logger::amf_app().error(
"%s : %s, using defaults", nfex.what(), nfex.getPath());
......
......@@ -207,6 +207,7 @@ class amf_config {
itti_cfg_t itti;
unsigned int statistics_interval;
std::string AMF_Name;
std::string local_ip;
guami_t guami;
std::vector<guami_t> guami_list;
unsigned int relativeAMFCapacity;
......
......@@ -62,6 +62,7 @@
#include "nas_algorithms.hpp"
#include "sha256.hpp"
#include <nlohmann/json.hpp>
#include <curl/curl.h>
#include "AuthenticationInfo.h"
#include "ConfirmationData.h"
......@@ -430,7 +431,61 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind &nas_data_ind) {
nas_data_ind.amf_ue_ngap_id, decoded_plain_msg, plmn);
}
}
//get请求和post请求数据响应函数
size_t req_reply(void *ptr, size_t size, size_t nmemb, void *stream)
{
//在注释的里面可以打印请求流,cookie的信息
//cout << "----->reply" << endl;
string *str = (string*)stream;
//cout << *str << endl;
(*str).append((char*)ptr, size*nmemb);
return size * nmemb;
}
//http POST请求
CURLcode curl_post_req(const string &url, const string &postParams, string &response)
{
// curl初始化
CURL *curl = curl_easy_init();
// curl返回值
CURLcode res;
if (curl)
{
// set params
//设置curl的请求头
struct curl_slist* header_list = NULL;
// header_list = curl_slist_append(header_list, "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
header_list = curl_slist_append(header_list, "Content-Type:application/json; charset=UTF-8");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list);
//不接收响应头数据0代表不接收 1代表接收
curl_easy_setopt(curl, CURLOPT_HEADER, 0);
//设置请求为post请求
curl_easy_setopt(curl, CURLOPT_POST, 1);
//设置请求的URL地址
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
//设置post请求的参数
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postParams.c_str());
//设置ssl验证
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
//CURLOPT_VERBOSE的值为1时,会显示详细的调试信息
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
//设置数据接收和写入函数
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, req_reply);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&response);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
//设置超时时间
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 6);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 6);
// 开启post请求
res = curl_easy_perform(curl);
}
//释放curl
curl_easy_cleanup(curl);
return res;
}
// handlers for lower layer
//------------------------------------------------------------------------------
void amf_n1::nas_signalling_establishment_request_handle(
......@@ -695,6 +750,25 @@ void amf_n1::nas_signalling_establishment_request_handle(
"Received registration request message, handling...");
registration_request_handle(true, nc, ran_ue_ngap_id, amf_ue_ngap_id, snn,
plain_msg);
//向php发送数据
std::shared_ptr<nas_context> nc_new = amf_ue_id_2_nas_context(amf_ue_ngap_id);
nlohmann::json response_data_json = {};
response_data_json["ueid"] = nc_new.get()->imsi;
response_data_json["status"] = "REGISTERED";
Logger::amf_n1().debug("UE注册数据推送:%s",response_data_json.dump().c_str());
string urlresponse;
string url = "http://"+amf_cfg.local_ip+"/admin/api/update_ue";
auto res = curl_post_req(url, response_data_json.dump().c_str(), urlresponse);
Logger::amf_n1().debug("UE注册数据返回:%s",urlresponse.c_str());
// if (res == CURLE_OK)
// {
// cout << urlresponse << endl;
// }
//向php发送数据
} break;
case SERVICE_REQUEST: {
Logger::amf_n1().debug("Received service request message, handling...");
......
......@@ -39,12 +39,17 @@
#include "amf_app.hpp"
#include "amf_module_from_config.hpp"
#include "amf_statistics.hpp"
#include <nlohmann/json.hpp>
#include <curl/curl.h>
#include <fstream>
#include <string>
#include <cstring>
#include "normalizer.hh"
using namespace std;
extern void hexStr2Byte(const char* src, unsigned char* dest, int len);
extern void print_buffer(
const std::string app, const std::string commit, uint8_t* buf, int len);
......@@ -63,6 +68,7 @@ std::vector<long> delay_processing;
ofstream timeline;
//------------------------------------------------------------------------------
int main(int argc, char** argv) {
srand(time(NULL));
......@@ -97,6 +103,8 @@ int main(int argc, char** argv) {
amfApiServer.init(2);
std::thread amf_api_manager(&AMFApiServer::start, amfApiServer);
Logger::amf_app().debug("Initiating Done!");
pause();
return 0;
......
......@@ -69,6 +69,9 @@ class AMFApiServer {
m_dataExposure =
std::make_shared<DataExposureApi>(
m_router);
}
void init(size_t thr = 1);
......@@ -103,4 +106,7 @@ class AMFApiServer {
m_testSignallingApiImpl;
std::shared_ptr<DataExposureApi>
m_dataExposure;
};
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
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