Commit 536206c5 authored by yangjian's avatar yangjian

clean up udm code

parent ecb0f0a5
...@@ -107,6 +107,8 @@ function main() ...@@ -107,6 +107,8 @@ function main()
if [[ $install_deps -ne 0 ]]; then if [[ $install_deps -ne 0 ]]; then
apt-get install cmake curl git libboost-all-dev libconfig++-dev libcurl4-gnutls-dev libgmp-dev libspdlog-dev nettle-dev -y apt-get install cmake curl git libboost-all-dev libconfig++-dev libcurl4-gnutls-dev libgmp-dev libspdlog-dev nettle-dev -y
read -p "Do you want to install Nlohmann Json ? <y/N> " prompt
if [[ $prompt =~ [yY](es)* ]]; then
if [ ! -d "$OPENXGUDM_DIR/build/ext/json/git_src/build" ]; then if [ ! -d "$OPENXGUDM_DIR/build/ext/json/git_src/build" ]; then
mkdir $OPENXGUDM_DIR/build/ext/json/git_src/build mkdir $OPENXGUDM_DIR/build/ext/json/git_src/build
fi fi
...@@ -114,6 +116,7 @@ function main() ...@@ -114,6 +116,7 @@ function main()
cmake .. cmake ..
make make
make install make install
fi
echo "install successful!" echo "install successful!"
return 0 return 0
fi fi
......
...@@ -30,7 +30,8 @@ void ConfirmAuthApiImpl::confirm_auth( ...@@ -30,7 +30,8 @@ void ConfirmAuthApiImpl::confirm_auth(
const std::string &supi, const AuthEvent &authEvent, const std::string &supi, const AuthEvent &authEvent,
Pistache::Http::ResponseWriter &response) { Pistache::Http::ResponseWriter &response) {
Logger::udm_ueau().info("\n\nEntering confirm_auth()"); std::cout<<std::endl;
Logger::udm_ueau().info("Entering confirm_auth()");
std::string udr_ip = std::string udr_ip =
std::string(inet_ntoa(*((struct in_addr *)&udm_cfg.nudr.addr4))); std::string(inet_ntoa(*((struct in_addr *)&udm_cfg.nudr.addr4)));
...@@ -48,7 +49,7 @@ void ConfirmAuthApiImpl::confirm_auth( ...@@ -48,7 +49,7 @@ void ConfirmAuthApiImpl::confirm_auth(
// UDR GET interface ----- get user info-------------------- // UDR GET interface ----- get user info--------------------
remoteUri = udr_ip + ":" + udr_port + "/nudr-dr/v2/subscription-data/" + remoteUri = udr_ip + ":" + udr_port + "/nudr-dr/v2/subscription-data/" +
supi + "/authentication-data/authentication-subscription"; supi + "/authentication-data/authentication-subscription";
Logger::udm_ueau().debug("GET Request:" + remoteUri); Logger::udm_ueau().debug("Send GET Request URI: " + remoteUri);
Method = "GET"; Method = "GET";
Curl::curl_http_client(remoteUri, Method, "", Response); Curl::curl_http_client(remoteUri, Method, "", Response);
...@@ -87,21 +88,21 @@ void ConfirmAuthApiImpl::confirm_auth( ...@@ -87,21 +88,21 @@ void ConfirmAuthApiImpl::confirm_auth(
remoteUri = udr_ip + ":" + udr_port + "/nudr-dr/v2/subscription-data/" + remoteUri = udr_ip + ":" + udr_port + "/nudr-dr/v2/subscription-data/" +
supi + "/authentication-data/authentication-status"; supi + "/authentication-data/authentication-status";
Logger::udm_ueau().debug("PUT Request:" + remoteUri); Logger::udm_ueau().info("Send PUT Request URI: " + remoteUri);
Method = "PUT"; Method = "PUT";
nlohmann::json j_authEvent; nlohmann::json j_authEvent;
to_json(j_authEvent, authEvent); to_json(j_authEvent, authEvent);
msgBody = j_authEvent.dump(); msgBody = j_authEvent.dump();
Logger::udm_ueau().debug("PATCH Request body = " + msgBody); Logger::udm_ueau().debug("PUT Request body = " + msgBody);
Curl::curl_http_client(remoteUri, Method, msgBody, Response); Curl::curl_http_client(remoteUri, Method, msgBody, Response);
std::string hash_value = sha256(supi + authEvent.getServingNetworkName()); std::string hash_value = sha256(supi + authEvent.getServingNetworkName());
// Logger::udm_ueau().debug("\n\nauthEventId=" + // Logger::udm_ueau().debug("\n\nauthEventId=" +
// hash_value.substr(0,hash_value.length()/2)); // hash_value.substr(0,hash_value.length()/2));
Logger::udm_ueau().debug("authEventId=" + hash_value); // Logger::udm_ueau().debug("authEventId=" + hash_value);
authEventId = hash_value; // Represents the authEvent Id per UE per serving authEventId = hash_value; // Represents the authEvent Id per UE per serving
// network assigned by the UDM during // network assigned by the UDM during
......
...@@ -35,7 +35,8 @@ void GenerateAuthDataApiImpl::generate_auth_data( ...@@ -35,7 +35,8 @@ void GenerateAuthDataApiImpl::generate_auth_data(
const AuthenticationInfoRequest &authenticationInfoRequest, const AuthenticationInfoRequest &authenticationInfoRequest,
Pistache::Http::ResponseWriter &response) { Pistache::Http::ResponseWriter &response) {
Logger::udm_ueau().info("\n\nEntering generate_auth_data()"); std::cout<<std::endl;
Logger::udm_ueau().info("Entering generate_auth_data()");
// test data // test data
// uint8_t rand[] = {0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d, 0x21, // uint8_t rand[] = {0x23, 0x55, 0x3c, 0xbe, 0x96, 0x37, 0xa8, 0x9d, 0x21,
...@@ -95,7 +96,7 @@ void GenerateAuthDataApiImpl::generate_auth_data( ...@@ -95,7 +96,7 @@ void GenerateAuthDataApiImpl::generate_auth_data(
// UDR GET interface ----- get authentication related info-------------------- // UDR GET interface ----- get authentication related info--------------------
remoteUri = udr_ip + ":" + udr_port + "/nudr-dr/v2/subscription-data/" + remoteUri = udr_ip + ":" + udr_port + "/nudr-dr/v2/subscription-data/" +
supi + "/authentication-data/authentication-subscription"; supi + "/authentication-data/authentication-subscription";
Logger::udm_ueau().debug("GET Request:" + remoteUri); Logger::udm_ueau().info("Send GET Request - URI: " + remoteUri);
Method = "GET"; Method = "GET";
Curl::curl_http_client(remoteUri, Method, "", Response); Curl::curl_http_client(remoteUri, Method, "", Response);
...@@ -194,8 +195,8 @@ void GenerateAuthDataApiImpl::generate_auth_data( ...@@ -194,8 +195,8 @@ void GenerateAuthDataApiImpl::generate_auth_data(
std::string r_rand_s = m_ResynchronizationInfo.getRand(); std::string r_rand_s = m_ResynchronizationInfo.getRand();
std::string r_auts_s = m_ResynchronizationInfo.getAuts(); std::string r_auts_s = m_ResynchronizationInfo.getAuts();
Logger::udm_ueau().debug("[resync] r_rand = " + r_rand_s); // Logger::udm_ueau().debug("[resync] r_rand = " + r_rand_s);
Logger::udm_ueau().debug("[resync] r_auts = " + r_auts_s); // Logger::udm_ueau().debug("[resync] r_auts = " + r_auts_s);
conv::hex_str_to_uint8(r_rand_s.c_str(), r_rand); conv::hex_str_to_uint8(r_rand_s.c_str(), r_rand);
conv::hex_str_to_uint8(r_auts_s.c_str(), r_auts); conv::hex_str_to_uint8(r_auts_s.c_str(), r_auts);
...@@ -203,7 +204,7 @@ void GenerateAuthDataApiImpl::generate_auth_data( ...@@ -203,7 +204,7 @@ void GenerateAuthDataApiImpl::generate_auth_data(
r_sqn = Authentication_5gaka::sqn_ms_derive(opc, key, r_auts, r_rand, amf); r_sqn = Authentication_5gaka::sqn_ms_derive(opc, key, r_auts, r_rand, amf);
if (r_sqn) { // Not NULL (validate auts) if (r_sqn) { // Not NULL (validate auts)
Logger::udm_ueau().debug("Valid AUTS, generate new AV with SQNms"); // Logger::udm_ueau().debug("Valid AUTS, generate new AV with SQNms");
// UDR PATCH interface ------- replace SQNhe with // UDR PATCH interface ------- replace SQNhe with
// SQNms------------------------------ // SQNms------------------------------
...@@ -254,7 +255,7 @@ void GenerateAuthDataApiImpl::generate_auth_data( ...@@ -254,7 +255,7 @@ void GenerateAuthDataApiImpl::generate_auth_data(
sqn_s = conv::uint8_to_hex_string(sqn, 6); sqn_s = conv::uint8_to_hex_string(sqn, 6);
print_buffer("udm_ueau", "SQNms", sqn, 6); // print_buffer("udm_ueau", "SQNms", sqn, 6);
if (r_sqn) { // free if (r_sqn) { // free
free(r_sqn); free(r_sqn);
...@@ -310,13 +311,13 @@ void GenerateAuthDataApiImpl::generate_auth_data( ...@@ -310,13 +311,13 @@ void GenerateAuthDataApiImpl::generate_auth_data(
sqn_s = conv::uint8_to_hex_string(sqn, 6); sqn_s = conv::uint8_to_hex_string(sqn, 6);
Logger::udm_ueau().debug("new_sqn = " + sqn_s); // Logger::udm_ueau().debug("new_sqn = " + sqn_s);
// UDR PATCH interface ------- increase // UDR PATCH interface ------- increase
// sqn------------------------------------ // sqn------------------------------------
remoteUri = udr_ip + ":" + udr_port + "/nudr-dr/v2/subscription-data/" + remoteUri = udr_ip + ":" + udr_port + "/nudr-dr/v2/subscription-data/" +
supi + "/authentication-data/authentication-subscription"; supi + "/authentication-data/authentication-subscription";
Logger::udm_ueau().debug("PATCH Request:" + remoteUri); Logger::udm_ueau().debug("Send PATCH Request URI: " + remoteUri);
Method = "PATCH"; Method = "PATCH";
nlohmann::json j_SequenceNumber; nlohmann::json j_SequenceNumber;
...@@ -337,10 +338,10 @@ void GenerateAuthDataApiImpl::generate_auth_data( ...@@ -337,10 +338,10 @@ void GenerateAuthDataApiImpl::generate_auth_data(
to_json(j_PatchItem, m_PatchItem); to_json(j_PatchItem, m_PatchItem);
msgBody = "[" + j_PatchItem.dump() + "]"; msgBody = "[" + j_PatchItem.dump() + "]";
// Logger::udm_ueau().debug("PATCH Request body = " + msgBody); Logger::udm_ueau().debug("PATCH Request body = " + msgBody);
Curl::curl_http_client(remoteUri, Method, msgBody, Response); Curl::curl_http_client(remoteUri, Method, msgBody, Response);
Logger::udm_ueau().info("Update sqn in Database"); // Logger::udm_ueau().info("Update sqn in Database");
} }
} // namespace api } // namespace api
......
...@@ -41,7 +41,7 @@ std::size_t callback(const char *in, std::size_t size, std::size_t num, ...@@ -41,7 +41,7 @@ std::size_t callback(const char *in, std::size_t size, std::size_t num,
long Curl::curl_http_client(std::string remoteUri, std::string Method, long Curl::curl_http_client(std::string remoteUri, std::string Method,
std::string msgBody, std::string &Response) { std::string msgBody, std::string &Response) {
Logger::udm_ueau().info("Send HTTP message with body %s", msgBody.c_str()); // Logger::udm_ueau().info("Send HTTP message with body %s", msgBody.c_str());
uint32_t str_len = msgBody.length(); uint32_t str_len = msgBody.length();
char *body_data = (char *)malloc(str_len + 1); char *body_data = (char *)malloc(str_len + 1);
...@@ -75,8 +75,8 @@ long Curl::curl_http_client(std::string remoteUri, std::string Method, ...@@ -75,8 +75,8 @@ long Curl::curl_http_client(std::string remoteUri, std::string Method,
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT_MS); curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1); curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1);
curl_easy_setopt(curl, CURLOPT_INTERFACE, udm_cfg.nudr.if_name.c_str()); curl_easy_setopt(curl, CURLOPT_INTERFACE, udm_cfg.nudr.if_name.c_str());
Logger::udm_ueau().info("[CURL] request sent by interface " + // Logger::udm_ueau().info("[CURL] request sent by interface " +
udm_cfg.nudr.if_name); // udm_cfg.nudr.if_name);
// Response information. // Response information.
std::unique_ptr<std::string> httpData(new std::string()); std::unique_ptr<std::string> httpData(new std::string());
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#include "logger.hpp" #include "logger.hpp"
#include "udm_config.hpp" #include "udm_config.hpp"
#define CURL_TIMEOUT_MS 300L #define CURL_TIMEOUT_MS 1000L
class Curl { class Curl {
public: public:
......
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