Commit f79840f3 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Minor update for logging

parent 7adf5f8d
...@@ -147,7 +147,6 @@ void DefaultApi::ue_authentications_auth_ctx_id5g_aka_confirmation_put_handler( ...@@ -147,7 +147,6 @@ void DefaultApi::ue_authentications_auth_ctx_id5g_aka_confirmation_put_handler(
try { try {
nlohmann::json::parse(request.body()).get_to(confirmationData); nlohmann::json::parse(request.body()).get_to(confirmationData);
Logger::ausf_server().debug("Json parsed");
this->ue_authentications_auth_ctx_id5g_aka_confirmation_put( this->ue_authentications_auth_ctx_id5g_aka_confirmation_put(
authCtxId, confirmationData, response); authCtxId, confirmationData, response);
} catch (nlohmann::detail::exception& e) { } catch (nlohmann::detail::exception& e) {
...@@ -193,15 +192,13 @@ void DefaultApi::ue_authentications_deregister_post_handler( ...@@ -193,15 +192,13 @@ void DefaultApi::ue_authentications_deregister_post_handler(
void DefaultApi::ue_authentications_post_handler( void DefaultApi::ue_authentications_post_handler(
const Pistache::Rest::Request& request, const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response) { Pistache::Http::ResponseWriter response) {
Logger::ausf_server().info("Received ue-authentications post Request"); Logger::ausf_server().info("Received ue_authentications_post Request");
// Getting the body param // Getting the body param
AuthenticationInfo authenticationInfo; AuthenticationInfo authenticationInfo;
try { try {
nlohmann::json::parse(request.body()).get_to(authenticationInfo); nlohmann::json::parse(request.body()).get_to(authenticationInfo);
Logger::ausf_server().debug("Json parsed");
this->ue_authentications_post(authenticationInfo, response); this->ue_authentications_post(authenticationInfo, response);
} catch (nlohmann::detail::exception& e) { } catch (nlohmann::detail::exception& e) {
// send a 400 error // send a 400 error
......
...@@ -99,8 +99,8 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put( ...@@ -99,8 +99,8 @@ void DefaultApiImpl::ue_authentications_auth_ctx_id5g_aka_confirmation_put(
"5g-aka-confirmation response:\n %s", json_data.dump().c_str()); "5g-aka-confirmation response:\n %s", json_data.dump().c_str());
Logger::ausf_server().info( Logger::ausf_server().info(
"Send 5g-aka-confirmation response to SEAF (Code 200)"); "Send 5g-aka-confirmation response to SEAF (Code %d)", code);
response.send(code, json_data.dump()); response.send(code, json_data.dump().c_str());
} }
void DefaultApiImpl::ue_authentications_deregister_post( void DefaultApiImpl::ue_authentications_deregister_post(
...@@ -115,12 +115,9 @@ void DefaultApiImpl::ue_authentications_deregister_post( ...@@ -115,12 +115,9 @@ void DefaultApiImpl::ue_authentications_deregister_post(
void DefaultApiImpl::ue_authentications_post( void DefaultApiImpl::ue_authentications_post(
const AuthenticationInfo& authenticationInfo, const AuthenticationInfo& authenticationInfo,
Pistache::Http::ResponseWriter& response) { Pistache::Http::ResponseWriter& response) {
Logger::ausf_server().debug("ue_authentications_post");
// Getting params // Getting params
std::string reponse_from_udm; std::string reponse_from_udm = {};
std::string location; std::string location = {};
// uint16_t http_response_code = 0;
UEAuthenticationCtx ue_auth_ctx = {}; UEAuthenticationCtx ue_auth_ctx = {};
nlohmann::json UEAuthCtx_json = {}; nlohmann::json UEAuthCtx_json = {};
Pistache::Http::Code code = {}; Pistache::Http::Code code = {};
...@@ -131,10 +128,9 @@ void DefaultApiImpl::ue_authentications_post( ...@@ -131,10 +128,9 @@ void DefaultApiImpl::ue_authentications_post(
Logger::ausf_server().debug( Logger::ausf_server().debug(
"Auth response:\n %s", UEAuthCtx_json.dump().c_str()); "Auth response:\n %s", UEAuthCtx_json.dump().c_str());
Logger::ausf_server().info("Send Auth response to SEAF (Code 201)"); Logger::ausf_server().info("Send Auth response to SEAF (Code %d)", code);
response.headers().add<Pistache::Http::Header::Location>(location); response.headers().add<Pistache::Http::Header::Location>(location);
response.send(code, response.send(code, UEAuthCtx_json.dump().c_str());
UEAuthCtx_json.dump()); // Type: json object to string
} }
} // namespace api } // namespace api
......
...@@ -136,7 +136,7 @@ void ausf_app::handle_ue_authentications( ...@@ -136,7 +136,7 @@ void ausf_app::handle_ue_authentications(
inet_ntoa(*((struct in_addr*) &ausf_cfg.udm_addr.ipv4_addr))) + inet_ntoa(*((struct in_addr*) &ausf_cfg.udm_addr.ipv4_addr))) +
":" + std::to_string(ausf_cfg.udm_addr.port) + "/nudm-ueau/v1/" + ":" + std::to_string(ausf_cfg.udm_addr.port) + "/nudm-ueau/v1/" +
supi + "/security-information/generate-auth-data"; supi + "/security-information/generate-auth-data";
Logger::ausf_server().debug("UDM's URI %s", udmUri.c_str()); Logger::ausf_app().debug("UDM's URI %s", udmUri.c_str());
method = "POST"; method = "POST";
// Create AuthInfo to send to UDM // Create AuthInfo to send to UDM
...@@ -155,17 +155,17 @@ void ausf_app::handle_ue_authentications( ...@@ -155,17 +155,17 @@ void ausf_app::handle_ue_authentications(
AuthInfo["resynchronizationInfo"]["rand"] = resynInfo.getRand(); AuthInfo["resynchronizationInfo"]["rand"] = resynInfo.getRand();
AuthInfo["resynchronizationInfo"]["auts"] = resynInfo.getAuts(); AuthInfo["resynchronizationInfo"]["auts"] = resynInfo.getAuts();
Logger::ausf_server().info( Logger::ausf_app().info(
"Received authInfo from AMF with ResynchronizationInfo IE"); "Received authInfo from AMF with ResynchronizationInfo IE");
} else { } else {
Logger::ausf_server().info( Logger::ausf_app().info(
"Received authInfo from AMF without ResynchronizationInfo IE"); "Received authInfo from AMF without ResynchronizationInfo IE");
} }
// Send request to UDM // Send request to UDM
ausf_client_inst->curl_http_client(udmUri, method, AuthInfo.dump(), response); ausf_client_inst->curl_http_client(udmUri, method, AuthInfo.dump(), response);
Logger::ausf_server().error("Response from UDM: %s", response.c_str()); Logger::ausf_app().info("Response from UDM: %s", response.c_str());
ProblemDetails problemDetails; ProblemDetails problemDetails;
nlohmann::json problemDetails_json = {}; nlohmann::json problemDetails_json = {};
...@@ -177,24 +177,23 @@ void ausf_app::handle_ue_authentications( ...@@ -177,24 +177,23 @@ void ausf_app::handle_ue_authentications(
response_data = nlohmann::json::parse(response.c_str()); response_data = nlohmann::json::parse(response.c_str());
// Get security context // Get security context
authType_udm = response_data.at("authType"); // AuthType authType_udm = response_data.at("authType"); // AuthType
Logger::ausf_server().debug("authType %s", authType_udm.c_str()); Logger::ausf_app().debug("authType %s", authType_udm.c_str());
autn_udm = response_data["authenticationVector"].at("autn"); // autn autn_udm = response_data["authenticationVector"].at("autn"); // autn
Logger::ausf_server().debug("autn_udm %s", autn_udm.c_str()); Logger::ausf_app().debug("autn_udm %s", autn_udm.c_str());
avType_udm = response_data["authenticationVector"].at("avType"); // avType avType_udm = response_data["authenticationVector"].at("avType"); // avType
Logger::ausf_server().debug("avType_udm %s", avType_udm.c_str()); Logger::ausf_app().debug("avType_udm %s", avType_udm.c_str());
kausf_udm = response_data["authenticationVector"].at("kausf"); // kausf kausf_udm = response_data["authenticationVector"].at("kausf"); // kausf
Logger::ausf_server().debug("kausf_udm %s", kausf_udm.c_str()); Logger::ausf_app().debug("kausf_udm %s", kausf_udm.c_str());
rand_udm = response_data["authenticationVector"].at("rand"); // rand rand_udm = response_data["authenticationVector"].at("rand"); // rand
Logger::ausf_server().debug("rand_udm %s", rand_udm.c_str()); Logger::ausf_app().debug("rand_udm %s", rand_udm.c_str());
xresStar_udm = xresStar_udm =
response_data["authenticationVector"].at("xresStar"); // xres* response_data["authenticationVector"].at("xresStar"); // xres*
Logger::ausf_server().debug("xres*_udm %s", xresStar_udm.c_str()); Logger::ausf_app().debug("xres*_udm %s", xresStar_udm.c_str());
} catch (nlohmann::json::exception& e) { } catch (nlohmann::json::exception& e) {
// TODO: Catch parse_error exception // TODO: Catch parse_error exception
// TODO: Catch out_of_range exception // TODO: Catch out_of_range exception
Logger::ausf_server().info( Logger::ausf_app().info("Could not Parse Json content from UDM response");
"Could not Parse Json content from UDM response");
// TODO: error handling // TODO: error handling
problemDetails.setCause("CONTEXT_NOT_FOUND"); problemDetails.setCause("CONTEXT_NOT_FOUND");
...@@ -203,9 +202,9 @@ void ausf_app::handle_ue_authentications( ...@@ -203,9 +202,9 @@ void ausf_app::handle_ue_authentications(
"Resource corresponding to User " + supi + " not found in UDM"); "Resource corresponding to User " + supi + " not found in UDM");
to_json(problemDetails_json, problemDetails); to_json(problemDetails_json, problemDetails);
Logger::ausf_server().error( Logger::ausf_app().error(
"Resource corresponding to User " + supi + " not found in UDM"); "Resource corresponding to User " + supi + " not found in UDM");
Logger::ausf_server().info("Send 404 Not_Found response to AUSF"); Logger::ausf_app().info("Send 404 Not_Found response to AUSF");
code = Pistache::Http::Code::Not_Found; code = Pistache::Http::Code::Not_Found;
json_data = problemDetails_json; json_data = problemDetails_json;
return; return;
...@@ -228,7 +227,7 @@ void ausf_app::handle_ue_authentications( ...@@ -228,7 +227,7 @@ void ausf_app::handle_ue_authentications(
// 5G HE AV HXRES* XRES*,KSEAF KAUSF // 5G HE AV HXRES* XRES*,KSEAF KAUSF
// KSEAF,SEAF 5G SE AV(RAND, AUTN, HXRES*) // KSEAF,SEAF 5G SE AV(RAND, AUTN, HXRES*)
// A.5, 3gpp ts33.501 // A.5, 3gpp ts33.501
Logger::ausf_server().debug("Generating 5G AV"); Logger::ausf_app().debug("Generating 5G AV");
// Generating hxres* // Generating hxres*
uint8_t rand_ausf[16] = {0}; uint8_t rand_ausf[16] = {0};
...@@ -246,13 +245,13 @@ void ausf_app::handle_ue_authentications( ...@@ -246,13 +245,13 @@ void ausf_app::handle_ue_authentications(
// Generate_Hxres* // Generate_Hxres*
Authentication_5gaka::generate_Hxres(rand_ausf, xresStar_ausf, hxresStar); Authentication_5gaka::generate_Hxres(rand_ausf, xresStar_ausf, hxresStar);
Logger::ausf_server().debug( Logger::ausf_app().debug(
"HXresStar calculated:\n %s", "HXresStar calculated:\n %s",
(conv::uint8_to_hex_string(hxresStar, 16)).c_str()); (conv::uint8_to_hex_string(hxresStar, 16)).c_str());
uint8_t kseaf[32] = {0}; uint8_t kseaf[32] = {0};
Authentication_5gaka::derive_kseaf(snn, kausf, kseaf); Authentication_5gaka::derive_kseaf(snn, kausf, kseaf);
Logger::ausf_server().debug( Logger::ausf_app().debug(
"Kseaf calculated:\n %s", (conv::uint8_to_hex_string(kseaf, 32)).c_str()); "Kseaf calculated:\n %s", (conv::uint8_to_hex_string(kseaf, 32)).c_str());
// Store the security context // Store the security context
...@@ -327,7 +326,7 @@ void ausf_app::handle_ue_authentications( ...@@ -327,7 +326,7 @@ void ausf_app::handle_ue_authentications(
to_json(json_data, UEAuthCtx); to_json(json_data, UEAuthCtx);
code = Pistache::Http::Code::Created; code = Pistache::Http::Code::Created;
Logger::ausf_server().debug("Auth Response:\n %s", json_data.dump().c_str()); Logger::ausf_app().debug("Auth Response:\n %s", json_data.dump().c_str());
return; return;
} }
...@@ -338,7 +337,7 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -338,7 +337,7 @@ void ausf_app::handle_ue_authentications_confirmation(
// SEAF-> AUSF // SEAF-> AUSF
ProblemDetails problemDetails; ProblemDetails problemDetails;
nlohmann::json problemDetails_json = {}; nlohmann::json problemDetails_json = {};
Logger::ausf_server().debug("Handling 5g-aka-confirmation"); Logger::ausf_app().debug("Handling 5g-aka-confirmation");
// Get the security context // Get the security context
std::shared_ptr<security_context> sc = {}; std::shared_ptr<security_context> sc = {};
...@@ -356,16 +355,16 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -356,16 +355,16 @@ void ausf_app::handle_ue_authentications_confirmation(
problemDetails.setDetail("Serving Network Not Authorized"); problemDetails.setDetail("Serving Network Not Authorized");
to_json(problemDetails_json, problemDetails); to_json(problemDetails_json, problemDetails);
Logger::ausf_server().error("Serving Network Not Authorized"); Logger::ausf_app().error("Serving Network Not Authorized");
Logger::ausf_server().info("Send 403 Forbidden response to AUSF"); Logger::ausf_app().info("Send 403 Forbidden response to AUSF");
code = Pistache::Http::Code::Forbidden; code = Pistache::Http::Code::Forbidden;
json_data = problemDetails_json; json_data = problemDetails_json;
return; return;
} }
Logger::ausf_server().info( Logger::ausf_app().info(
"Received authCtxId %s", authCtxId.c_str()); // authCtxId "Received authCtxId %s", authCtxId.c_str()); // authCtxId
Logger::ausf_server().info( Logger::ausf_app().info(
"Received res* %s", confirmationData.getResStar().c_str()); "Received res* %s", confirmationData.getResStar().c_str());
uint8_t resStar[16] = {0}; uint8_t resStar[16] = {0};
...@@ -376,7 +375,7 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -376,7 +375,7 @@ void ausf_app::handle_ue_authentications_confirmation(
conv::hex_str_to_uint8( conv::hex_str_to_uint8(
authCtxId.c_str(), authCtxId_seaf); // authCtxId in SEAF authCtxId.c_str(), authCtxId_seaf); // authCtxId in SEAF
Logger::ausf_server().debug( Logger::ausf_app().debug(
"authCtxId in AUSF: %s", "authCtxId in AUSF: %s",
(conv::uint8_to_hex_string(sc->ausf_av_s.autn, 16)).c_str()); (conv::uint8_to_hex_string(sc->ausf_av_s.autn, 16)).c_str());
...@@ -384,14 +383,14 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -384,14 +383,14 @@ void ausf_app::handle_ue_authentications_confirmation(
Authentication_5gaka::equal_uint8(sc->ausf_av_s.autn, authCtxId_seaf, 16); Authentication_5gaka::equal_uint8(sc->ausf_av_s.autn, authCtxId_seaf, 16);
if (!is_auth_vectors_present) // AV expired if (!is_auth_vectors_present) // AV expired
{ {
Logger::ausf_server().error( Logger::ausf_app().error(
"Authentication failure by home network with authCtxId %s: AV expired", "Authentication failure by home network with authCtxId %s: AV expired",
authCtxId.c_str()); authCtxId.c_str());
confirmResponse.setAuthResult(is_auth_vectors_present); confirmResponse.setAuthResult(is_auth_vectors_present);
sc->kausf_tmp = "invalid"; sc->kausf_tmp = "invalid";
} else // AV valid } else // AV valid
{ {
Logger::ausf_server().info("AV is up to date, handling received res*..."); Logger::ausf_app().info("AV is up to date, handling received res*...");
// Get stored xres* and compare with res* // Get stored xres* and compare with res*
uint8_t xresStar[16] = {0}; uint8_t xresStar[16] = {0};
// xres* stored for 5g-aka-confirmation // xres* stored for 5g-aka-confirmation
...@@ -399,9 +398,9 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -399,9 +398,9 @@ void ausf_app::handle_ue_authentications_confirmation(
std::begin(sc->xres_star), std::end(sc->xres_star), std::begin(sc->xres_star), std::end(sc->xres_star),
std::begin(xresStar)); std::begin(xresStar));
Logger::ausf_server().debug( Logger::ausf_app().debug(
"xres* in AUSF: %s", (conv::uint8_to_hex_string(xresStar, 16)).c_str()); "xres* in AUSF: %s", (conv::uint8_to_hex_string(xresStar, 16)).c_str());
Logger::ausf_server().debug( Logger::ausf_app().debug(
"xres in AMF: %s", (conv::uint8_to_hex_string(resStar, 16)).c_str()); "xres in AMF: %s", (conv::uint8_to_hex_string(resStar, 16)).c_str());
bool authResult = Authentication_5gaka::equal_uint8(xresStar, resStar, 16); bool authResult = Authentication_5gaka::equal_uint8(xresStar, resStar, 16);
...@@ -409,13 +408,13 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -409,13 +408,13 @@ void ausf_app::handle_ue_authentications_confirmation(
if (!authResult) // Authentication failed if (!authResult) // Authentication failed
{ {
Logger::ausf_server().error( Logger::ausf_app().error(
"Authentication failure by home network with authCtxId %s: res* != " "Authentication failure by home network with authCtxId %s: res* != "
"xres*", "xres*",
authCtxId.c_str()); authCtxId.c_str());
} else // Authentication success } else // Authentication success
{ {
Logger::ausf_server().info("Authentication successful by home network!"); Logger::ausf_app().info("Authentication successful by home network!");
// Send Kseaf to SEAF // Send Kseaf to SEAF
string kseaf_s; string kseaf_s;
kseaf_s = conv::uint8_to_hex_string(sc->ausf_av_s.kseaf, 32); kseaf_s = conv::uint8_to_hex_string(sc->ausf_av_s.kseaf, 32);
...@@ -432,7 +431,7 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -432,7 +431,7 @@ void ausf_app::handle_ue_authentications_confirmation(
":" + std::to_string(ausf_cfg.udm_addr.port) + "/nudm-ueau/v1/" + ":" + std::to_string(ausf_cfg.udm_addr.port) + "/nudm-ueau/v1/" +
sc->supi_ausf + "/auth-events"; sc->supi_ausf + "/auth-events";
Logger::ausf_server().debug("UDM's URI: %s", udmUri.c_str()); Logger::ausf_app().debug("UDM's URI: %s", udmUri.c_str());
method = "POST"; method = "POST";
// Form request body // Form request body
...@@ -454,7 +453,7 @@ void ausf_app::handle_ue_authentications_confirmation( ...@@ -454,7 +453,7 @@ void ausf_app::handle_ue_authentications_confirmation(
confirmResultInfo["servingNetworkName"] = sc->serving_nn; confirmResultInfo["servingNetworkName"] = sc->serving_nn;
confirmResultInfo["authRemovalInd"] = false; confirmResultInfo["authRemovalInd"] = false;
Logger::ausf_server().debug( Logger::ausf_app().debug(
"confirmResultInfo: %s", confirmResultInfo.dump().c_str()); "confirmResultInfo: %s", confirmResultInfo.dump().c_str());
ausf_client_inst->curl_http_client( ausf_client_inst->curl_http_client(
udmUri, method, confirmResultInfo.dump(), response); udmUri, method, confirmResultInfo.dump(), response);
......
...@@ -103,8 +103,6 @@ void ausf_client::curl_http_client( ...@@ -103,8 +103,6 @@ void ausf_client::curl_http_client(
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, ausf_cfg.sbi.if_name.c_str()); curl_easy_setopt(curl, CURLOPT_INTERFACE, ausf_cfg.sbi.if_name.c_str());
Logger::ausf_app().info(
"Request sent by interface " + ausf_cfg.sbi.if_name);
// Response information. // Response information.
long httpCode = {0}; long httpCode = {0};
...@@ -152,10 +150,6 @@ void ausf_client::curl_http_client( ...@@ -152,10 +150,6 @@ void ausf_client::curl_http_client(
return; return;
} }
else { // httpCode = 200 || httpCode = 201 || httpCode = 204
response = *httpData.get();
}
if (!is_response_ok) { if (!is_response_ok) {
try { try {
response_data = nlohmann::json::parse(response); response_data = nlohmann::json::parse(response);
...@@ -182,5 +176,6 @@ void ausf_client::curl_http_client( ...@@ -182,5 +176,6 @@ void ausf_client::curl_http_client(
free(body_data); free(body_data);
body_data = NULL; body_data = NULL;
} }
fflush(stdout); // fflush(stdout);
return;
} }
...@@ -186,7 +186,7 @@ int ausf_config::load(const std::string& config_file) { ...@@ -186,7 +186,7 @@ int ausf_config::load(const std::string& config_file) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ausf_config::display() { void ausf_config::display() {
Logger::config().info("======== AUSF ======="); Logger::config().info("================= AUSF =================");
Logger::config().info("Configuration AUSF:"); Logger::config().info("Configuration AUSF:");
Logger::config().info("- Instance................: %d", instance); Logger::config().info("- Instance................: %d", instance);
Logger::config().info("- PID dir.................: %s", pid_dir.c_str()); Logger::config().info("- PID dir.................: %s", pid_dir.c_str());
......
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