Commit 0f32e538 authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'api_version' into 'develop'

Api version

See merge request oai/cn5g/oai-cn5g-ausf!5
parents 7adf5f8d 4b299810
......@@ -147,7 +147,6 @@ void DefaultApi::ue_authentications_auth_ctx_id5g_aka_confirmation_put_handler(
try {
nlohmann::json::parse(request.body()).get_to(confirmationData);
Logger::ausf_server().debug("Json parsed");
this->ue_authentications_auth_ctx_id5g_aka_confirmation_put(
authCtxId, confirmationData, response);
} catch (nlohmann::detail::exception& e) {
......@@ -193,15 +192,13 @@ void DefaultApi::ue_authentications_deregister_post_handler(
void DefaultApi::ue_authentications_post_handler(
const Pistache::Rest::Request& request,
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
AuthenticationInfo authenticationInfo;
try {
nlohmann::json::parse(request.body()).get_to(authenticationInfo);
Logger::ausf_server().debug("Json parsed");
this->ue_authentications_post(authenticationInfo, response);
} catch (nlohmann::detail::exception& e) {
// send a 400 error
......
......@@ -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());
Logger::ausf_server().info(
"Send 5g-aka-confirmation response to SEAF (Code 200)");
response.send(code, json_data.dump());
"Send 5g-aka-confirmation response to SEAF (Code %d)", code);
response.send(code, json_data.dump().c_str());
}
void DefaultApiImpl::ue_authentications_deregister_post(
......@@ -115,12 +115,9 @@ void DefaultApiImpl::ue_authentications_deregister_post(
void DefaultApiImpl::ue_authentications_post(
const AuthenticationInfo& authenticationInfo,
Pistache::Http::ResponseWriter& response) {
Logger::ausf_server().debug("ue_authentications_post");
// Getting params
std::string reponse_from_udm;
std::string location;
// uint16_t http_response_code = 0;
std::string reponse_from_udm = {};
std::string location = {};
UEAuthenticationCtx ue_auth_ctx = {};
nlohmann::json UEAuthCtx_json = {};
Pistache::Http::Code code = {};
......@@ -131,10 +128,9 @@ void DefaultApiImpl::ue_authentications_post(
Logger::ausf_server().debug(
"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.send(code,
UEAuthCtx_json.dump()); // Type: json object to string
response.send(code, UEAuthCtx_json.dump().c_str());
}
} // namespace api
......
This diff is collapsed.
......@@ -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_TCP_KEEPALIVE, 1);
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.
long httpCode = {0};
......@@ -140,8 +138,9 @@ void ausf_client::curl_http_client(
nlohmann::json response_data = {};
if (httpCode != 200 && httpCode != 201 &&
httpCode != 204) { // TODO: remove hardcoded values
if (httpCode != HTTP_RESPONSE_CODE_OK &&
httpCode != HTTP_RESPONSE_CODE_CREATED &&
httpCode != HTTP_RESPONSE_CODE_NO_CONTENT) {
is_response_ok = false;
if (response.size() < 1) {
Logger::ausf_app().info("There's no content in the response");
......@@ -152,10 +151,6 @@ void ausf_client::curl_http_client(
return;
}
else { // httpCode = 200 || httpCode = 201 || httpCode = 204
response = *httpData.get();
}
if (!is_response_ok) {
try {
response_data = nlohmann::json::parse(response);
......@@ -182,5 +177,5 @@ void ausf_client::curl_http_client(
free(body_data);
body_data = NULL;
}
fflush(stdout);
return;
}
......@@ -55,7 +55,7 @@ using namespace libconfig;
namespace config {
//------------------------------------------------------------------------------
ausf_config::ausf_config() : sbi() {
ausf_config::ausf_config() : sbi(), ausf_name(), pid_dir(), instance() {
udm_addr.ipv4_addr.s_addr = INADDR_ANY;
udm_addr.port = 80;
udm_addr.api_version = "v1";
......@@ -186,7 +186,7 @@ int ausf_config::load(const std::string& config_file) {
//------------------------------------------------------------------------------
void ausf_config::display() {
Logger::config().info("======== AUSF =======");
Logger::config().info("================= AUSF =================");
Logger::config().info("Configuration AUSF:");
Logger::config().info("- Instance................: %d", instance);
Logger::config().info("- PID dir.................: %s", pid_dir.c_str());
......
......@@ -83,4 +83,31 @@ typedef struct {
typedef uint64_t supi64_t;
// 3GPP TS 29.571 (Common data)
enum http_response_codes_e {
HTTP_RESPONSE_CODE_OK = 200,
HTTP_RESPONSE_CODE_CREATED = 201,
HTTP_RESPONSE_CODE_ACCEPTED = 202,
HTTP_RESPONSE_CODE_NO_CONTENT = 204,
HTTP_RESPONSE_CODE_BAD_REQUEST = 400,
HTTP_RESPONSE_CODE_UNAUTHORIZED = 401,
HTTP_RESPONSE_CODE_FORBIDDEN = 403,
HTTP_RESPONSE_CODE_NOT_FOUND = 404,
HTTP_RESPONSE_CODE_METHOD_NOT_ALLOWED = 405,
HTTP_RESPONSE_CODE_REQUEST_TIMEOUT = 408,
HTTP_RESPONSE_CODE_406_NOT_ACCEPTED = 406,
HTTP_RESPONSE_CODE_CONFLICT = 409,
HTTP_RESPONSE_CODE_GONE = 410,
HTTP_RESPONSE_CODE_LENGTH_REQUIRED = 411,
HTTP_RESPONSE_CODE_PRECONDITION_FAILED = 412,
HTTP_RESPONSE_CODE_PAYLOAD_TOO_LARGE = 413,
HTTP_RESPONSE_CODE_URI_TOO_LONG = 414,
HTTP_RESPONSE_CODE_UNSUPPORTED_MEDIA_TYPE = 415,
HTTP_RESPONSE_CODE_TOO_MANY_REQUESTS = 429,
HTTP_RESPONSE_CODE_INTERNAL_SERVER_ERROR = 500,
HTTP_RESPONSE_CODE_NOT_IMPLEMENTED = 501,
HTTP_RESPONSE_CODE_SERVICE_UNAVAILABLE = 503,
HTTP_RESPONSE_CODE_GATEWAY_TIMEOUT = 504
};
#endif
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