Commit 2e3e9ee2 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup for Event Exposure

parent 51cd6e5c
......@@ -3176,8 +3176,6 @@ void amf_n1::handle_ue_location_change(
std::make_shared<itti_sbi_notify_subscribed_event>(
TASK_AMF_N1, TASK_AMF_N11);
// TODO:
// itti_msg->notif_id = "";
itti_msg->http_version = 1;
for (auto i : subscriptions) {
......@@ -3233,8 +3231,6 @@ void amf_n1::handle_ue_reachability_status_change(
std::make_shared<itti_sbi_notify_subscribed_event>(
TASK_AMF_N1, TASK_AMF_N11);
// TODO:
// itti_msg->notif_id = "";
itti_msg->http_version = 1;
for (auto i : subscriptions) {
......@@ -3295,8 +3291,6 @@ void amf_n1::handle_ue_registration_state_change(
std::make_shared<itti_sbi_notify_subscribed_event>(
TASK_AMF_N1, TASK_AMF_N11);
// TODO:
// itti_msg->notif_id = "";
itti_msg->http_version = 1;
for (auto i : subscriptions) {
......@@ -3364,8 +3358,6 @@ void amf_n1::handle_ue_connectivity_state_change(
std::make_shared<itti_sbi_notify_subscribed_event>(
TASK_AMF_N1, TASK_AMF_N11);
// TODO:
// itti_msg->notif_id = "";
itti_msg->http_version = 1;
for (auto i : subscriptions) {
......
......@@ -530,8 +530,7 @@ void amf_n11::handle_itti_message(
//------------------------------------------------------------------------------
void amf_n11::handle_itti_message(itti_sbi_notify_subscribed_event& itti_msg) {
Logger::amf_n11().debug(
"Send notification for the subscribed event to the subscription");
Logger::amf_n11().debug("Send notification for the subscribed events");
for (auto i : itti_msg.event_notifs) {
// Fill the json part
......@@ -636,10 +635,10 @@ void amf_n11::handle_post_sm_context_response_error(
//------------------------------------------------------------------------------
void amf_n11::curl_http_client(
std::string remoteUri, std::string jsonData, std::string n1SmMsg,
std::string remote_uri, std::string jsonData, std::string n1SmMsg,
std::string n2SmMsg, std::string supi, uint8_t pdu_session_id,
uint8_t http_version, uint32_t promise_id) {
Logger::amf_n11().debug("Call SMF service: %s", remoteUri.c_str());
Logger::amf_n11().debug("Call SMF service: %s", remote_uri.c_str());
uint8_t number_parts = 0;
mime_parser parser = {};
......@@ -696,7 +695,7 @@ void amf_n11::curl_http_client(
}
headers = curl_slist_append(headers, content_type.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_URL, remoteUri.c_str());
curl_easy_setopt(curl, CURLOPT_URL, remote_uri.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, CURL_TIMEOUT_MS);
curl_easy_setopt(curl, CURLOPT_INTERFACE, amf_cfg.n11.if_name.c_str());
......@@ -741,7 +740,7 @@ void amf_n11::curl_http_client(
http_response_codes_e::HTTP_RESPONSE_CODE_0) {
// TODO: should be removed
Logger::amf_n11().error(
"Cannot get response when calling %s", remoteUri.c_str());
"Cannot get response when calling %s", remote_uri.c_str());
// free curl before returning
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
......@@ -758,7 +757,7 @@ void amf_n11::curl_http_client(
json_data_response = response;
}
Logger::amf_n11().info("Json part %s", json_data_response.c_str());
Logger::amf_n11().info("JSON part %s", json_data_response.c_str());
if ((static_cast<http_response_codes_e>(httpCode) !=
http_response_codes_e::HTTP_RESPONSE_CODE_200_OK) &&
......@@ -784,7 +783,7 @@ void amf_n11::curl_http_client(
response_data = nlohmann::json::parse(json_data_response);
} catch (nlohmann::json::exception& e) {
Logger::amf_n11().warn(
"Could not get Json content from the response");
"Could not get JSON content from the response");
// Set the default Cause
response_data["error"]["cause"] = "504 Gateway Timeout";
}
......@@ -827,7 +826,7 @@ void amf_n11::curl_http_client(
try {
response_data = nlohmann::json::parse(json_data_response);
} catch (nlohmann::json::exception& e) {
Logger::amf_n11().warn("Could not get Json content from the response");
Logger::amf_n11().warn("Could not get JSON content from the response");
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
......@@ -1333,7 +1332,7 @@ bool amf_n11::send_ue_authentication_request(
"UE Authentication, response from AUSF\n, %s ", tmp.c_str());
} catch (nlohmann::json::exception& e) {
Logger::amf_n11().warn(
"UE Authentication, could not parse Json from the AUSF "
"UE Authentication, could not parse JSON from the AUSF "
"response");
// TODO: error handling
return false;
......@@ -1355,15 +1354,15 @@ bool amf_n11::send_ue_authentication_request(
//-----------------------------------------------------------------------------------------------------
// From AMF_N1, need to be reworked
void amf_n11::curl_http_client(
std::string remoteUri, std::string method, std::string msgBody,
std::string remote_uri, std::string method, std::string msg_body,
std::string& response, uint8_t http_version) {
Logger::amf_n11().info("Send HTTP message to %s", remoteUri.c_str());
Logger::amf_n11().info("HTTP message Body: %s", msgBody.c_str());
Logger::amf_n11().info("Send HTTP message to %s", remote_uri.c_str());
Logger::amf_n11().info("HTTP message Body: %s", msg_body.c_str());
uint32_t str_len = msgBody.length();
uint32_t str_len = msg_body.length();
char* body_data = (char*) malloc(str_len + 1);
memset(body_data, 0, str_len + 1);
memcpy((void*) body_data, (void*) msgBody.c_str(), str_len);
memcpy((void*) body_data, (void*) msg_body.c_str(), str_len);
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl_easy_init();
......@@ -1377,7 +1376,7 @@ void amf_n11::curl_http_client(
headers = curl_slist_append(headers, content_type.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
}
curl_easy_setopt(curl, CURLOPT_URL, remoteUri.c_str());
curl_easy_setopt(curl, CURLOPT_URL, remote_uri.c_str());
if (method.compare("POST") == 0)
curl_easy_setopt(curl, CURLOPT_HTTPPOST, 1);
else if (method.compare("PATCH") == 0)
......@@ -1411,7 +1410,7 @@ void amf_n11::curl_http_client(
curl_easy_setopt(curl, CURLOPT_HEADERDATA, httpHeaderData.get());
if ((method.compare("POST") == 0) or (method.compare("PATCH") == 0) or
(method.compare("PUT") == 0)) {
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, msgBody.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, msg_body.length());
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body_data);
}
......@@ -1423,11 +1422,11 @@ void amf_n11::curl_http_client(
std::string json_data_response = {};
std::string resMsg = {};
bool is_response_ok = true;
Logger::amf_n11().info("Get response with httpcode (%d)", httpCode);
Logger::amf_n11().info("Get response with HTTP code (%d)", httpCode);
if (httpCode == 0) {
Logger::amf_n11().info(
"Cannot get response when calling %s", remoteUri.c_str());
"Cannot get response when calling %s", remote_uri.c_str());
// free curl before returning
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
......@@ -1451,7 +1450,7 @@ void amf_n11::curl_http_client(
try {
response_data = nlohmann::json::parse(json_data_response);
} catch (nlohmann::json::exception& e) {
Logger::amf_n11().info("Could not get Json content from the response");
Logger::amf_n11().info("Could not get JSON content from the response");
// Set the default Cause
response_data["error"]["cause"] = "504 Gateway Timeout";
}
......
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