Address review comments

This commit is contained in:
FearlessTobi 2023-07-31 05:03:29 +02:00
parent 87f5aae7dd
commit 3ba8da15c8
7 changed files with 126 additions and 331 deletions

View File

@ -245,6 +245,8 @@ add_library(citra_core STATIC
hle/service/cam/cam_s.h hle/service/cam/cam_s.h
hle/service/cam/cam_u.cpp hle/service/cam/cam_u.cpp
hle/service/cam/cam_u.h hle/service/cam/cam_u.h
hle/service/cam/y2r_u.cpp
hle/service/cam/y2r_u.h
hle/service/cecd/cecd.cpp hle/service/cecd/cecd.cpp
hle/service/cecd/cecd.h hle/service/cecd/cecd.h
hle/service/cecd/cecd_ndm.cpp hle/service/cecd/cecd_ndm.cpp
@ -423,8 +425,6 @@ add_library(citra_core STATIC
hle/service/soc/soc_u.h hle/service/soc/soc_u.h
hle/service/ssl/ssl_c.cpp hle/service/ssl/ssl_c.cpp
hle/service/ssl/ssl_c.h hle/service/ssl/ssl_c.h
hle/service/y2r/y2r_u.cpp
hle/service/y2r/y2r_u.h
hw/aes/arithmetic128.cpp hw/aes/arithmetic128.cpp
hw/aes/arithmetic128.h hw/aes/arithmetic128.h
hw/aes/ccm.cpp hw/aes/ccm.cpp

View File

@ -11,7 +11,7 @@
#include "core/hle/ipc_helpers.h" #include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/service/y2r/y2r_u.h" #include "core/hle/service/cam/y2r_u.h"
#include "core/hw/y2r.h" #include "core/hw/y2r.h"
SERVICE_CONSTRUCT_IMPL(Service::Y2R::Y2R_U) SERVICE_CONSTRUCT_IMPL(Service::Y2R::Y2R_U)

View File

@ -55,12 +55,12 @@ const ResultCode ERROR_WRONG_CERT_HANDLE = // 0xD8A0A0C9
const ResultCode ERROR_CERT_ALREADY_SET = // 0xD8A0A03D const ResultCode ERROR_CERT_ALREADY_SET = // 0xD8A0A03D
ResultCode(61, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent); ResultCode(61, ErrorModule::HTTP, ErrorSummary::InvalidState, ErrorLevel::Permanent);
static std::pair<std::string, std::string> splitUrl(const std::string& url) { static std::pair<std::string, std::string> SplitUrl(const std::string& url) {
const std::string prefix = "://"; const std::string prefix = "://";
const auto scheme = url.find(prefix); const auto scheme_end = url.find(prefix);
const auto scheme_end = scheme == std::string::npos ? 0 : scheme + prefix.length(); const auto prefix_end = scheme_end == std::string::npos ? 0 : scheme_end + prefix.length();
const auto path_index = url.find("/", scheme_end); const auto path_index = url.find("/", prefix_end);
std::string host; std::string host;
std::string path; std::string path;
if (path_index == std::string::npos) { if (path_index == std::string::npos) {
@ -78,7 +78,7 @@ void Context::MakeRequest() {
ASSERT(state == RequestState::NotStarted); ASSERT(state == RequestState::NotStarted);
#ifdef ENABLE_WEB_SERVICE #ifdef ENABLE_WEB_SERVICE
const auto& [host, path] = splitUrl(url.c_str()); const auto& [host, path] = SplitUrl(url.c_str());
std::unique_ptr<httplib::Client> client = std::make_unique<httplib::Client>(host); std::unique_ptr<httplib::Client> client = std::make_unique<httplib::Client>(host);
SSL_CTX* ctx = client->ssl_context(); SSL_CTX* ctx = client->ssl_context();
if (ctx) { if (ctx) {
@ -205,33 +205,7 @@ void HTTP_C::BeginRequest(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_HTTP, "(STUBBED) called, context_id={}", context_handle); LOG_WARNING(Service_HTTP, "(STUBBED) called, context_id={}", context_handle);
auto* session_data = GetSessionData(ctx.Session()); if (!PerformStateChecks(ctx, rp, context_handle)) {
ASSERT(session_data);
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to make a request on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return;
}
// This command can only be called with a bound context
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Tried to make a request without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
return;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(
Service_HTTP,
"Tried to make a request on a mismatched session input context={} session context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return; return;
} }
@ -258,33 +232,7 @@ void HTTP_C::BeginRequestAsync(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_HTTP, "(STUBBED) called, context_id={}", context_handle); LOG_WARNING(Service_HTTP, "(STUBBED) called, context_id={}", context_handle);
auto* session_data = GetSessionData(ctx.Session()); if (!PerformStateChecks(ctx, rp, context_handle)) {
ASSERT(session_data);
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to make a request on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return;
}
// This command can only be called with a bound context
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Tried to make a request without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
return;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(
Service_HTTP,
"Tried to make a request on a mismatched session input context={} session context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return; return;
} }
@ -306,93 +254,37 @@ void HTTP_C::BeginRequestAsync(Kernel::HLERequestContext& ctx) {
} }
void HTTP_C::ReceiveData(Kernel::HLERequestContext& ctx) { void HTTP_C::ReceiveData(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); ReceiveDataImpl(ctx, false);
const Context::Handle context_handle = rp.Pop<u32>();
[[maybe_unused]] const u32 buffer_size = rp.Pop<u32>();
LOG_WARNING(Service_HTTP, "(STUBBED) called");
auto* session_data = GetSessionData(ctx.Session());
ASSERT(session_data);
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to make a request on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return;
}
// This command can only be called with a bound context
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Tried to make a request without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
return;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(
Service_HTTP,
"Tried to make a request on a mismatched session input context={} session context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return;
}
auto itr = contexts.find(context_handle);
ASSERT(itr != contexts.end());
itr->second.request_future.wait();
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
} }
void HTTP_C::ReceiveDataTimeout(Kernel::HLERequestContext& ctx) { void HTTP_C::ReceiveDataTimeout(Kernel::HLERequestContext& ctx) {
ReceiveDataImpl(ctx, true);
}
void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
const Context::Handle context_handle = rp.Pop<u32>(); const Context::Handle context_handle = rp.Pop<u32>();
[[maybe_unused]] const u32 buffer_size = rp.Pop<u32>(); [[maybe_unused]] const u32 buffer_size = rp.Pop<u32>();
const u64 timeout = rp.Pop<u64>(); u64 timeout_nanos = 0;
if (timeout) {
LOG_WARNING(Service_HTTP, "(STUBBED) called, timeout={}", timeout); timeout_nanos = rp.Pop<u64>();
LOG_WARNING(Service_HTTP, "(STUBBED) called, timeout={}", timeout_nanos);
auto* session_data = GetSessionData(ctx.Session()); } else {
ASSERT(session_data); LOG_WARNING(Service_HTTP, "(STUBBED) called");
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to make a request on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return;
} }
// This command can only be called with a bound context if (!PerformStateChecks(ctx, rp, context_handle)) {
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Tried to make a request without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
return;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(
Service_HTTP,
"Tried to make a request on a mismatched session input context={} session context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return; return;
} }
auto itr = contexts.find(context_handle); auto itr = contexts.find(context_handle);
ASSERT(itr != contexts.end()); ASSERT(itr != contexts.end());
itr->second.request_future.wait_for(std::chrono::nanoseconds(timeout)); if (timeout) {
itr->second.request_future.wait_for(std::chrono::nanoseconds(timeout_nanos));
} else {
itr->second.request_future.wait();
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
@ -410,14 +302,8 @@ void HTTP_C::CreateContext(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_HTTP, "called, url_size={}, url={}, method={}", url_size, url, method); LOG_DEBUG(Service_HTTP, "called, url_size={}, url={}, method={}", url_size, url, method);
auto* session_data = GetSessionData(ctx.Session()); auto* session_data = EnsureSessionInitialized(ctx, rp);
ASSERT(session_data); if (!session_data) {
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to create a context on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ERROR_STATE_ERROR);
rb.PushMappedBuffer(buffer);
return; return;
} }
@ -478,13 +364,8 @@ void HTTP_C::CloseContext(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_HTTP, "(STUBBED) called, handle={}", context_handle); LOG_WARNING(Service_HTTP, "(STUBBED) called, handle={}", context_handle);
auto* session_data = GetSessionData(ctx.Session()); auto* session_data = EnsureSessionInitialized(ctx, rp);
ASSERT(session_data); if (!session_data) {
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to close a context on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return; return;
} }
@ -529,36 +410,7 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_HTTP, "called, name={}, value={}, context_handle={}", name, value, LOG_DEBUG(Service_HTTP, "called, name={}, value={}, context_handle={}", name, value,
context_handle); context_handle);
auto* session_data = GetSessionData(ctx.Session()); if (!PerformStateChecks(ctx, rp, context_handle)) {
ASSERT(session_data);
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to add a request header on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ERROR_STATE_ERROR);
rb.PushMappedBuffer(value_buffer);
return;
}
// This command can only be called with a bound context
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Command called without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
rb.PushMappedBuffer(value_buffer);
return;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(Service_HTTP,
"Tried to add a request header on a mismatched session input context={} session "
"context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ERROR_STATE_ERROR);
rb.PushMappedBuffer(value_buffer);
return; return;
} }
@ -605,36 +457,7 @@ void HTTP_C::AddPostDataAscii(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_HTTP, "called, name={}, value={}, context_handle={}", name, value, LOG_DEBUG(Service_HTTP, "called, name={}, value={}, context_handle={}", name, value,
context_handle); context_handle);
auto* session_data = GetSessionData(ctx.Session()); if (!PerformStateChecks(ctx, rp, context_handle)) {
ASSERT(session_data);
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to add post data on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ERROR_STATE_ERROR);
rb.PushMappedBuffer(value_buffer);
return;
}
// This command can only be called with a bound context
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Command called without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
rb.PushMappedBuffer(value_buffer);
return;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(Service_HTTP,
"Tried to add post data on a mismatched session input context={} session "
"context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(ERROR_STATE_ERROR);
rb.PushMappedBuffer(value_buffer);
return; return;
} }
@ -663,93 +486,37 @@ void HTTP_C::AddPostDataAscii(Kernel::HLERequestContext& ctx) {
} }
void HTTP_C::GetResponseStatusCode(Kernel::HLERequestContext& ctx) { void HTTP_C::GetResponseStatusCode(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx); GetResponseStatusCodeImpl(ctx, false);
const Context::Handle context_handle = rp.Pop<u32>();
LOG_INFO(Service_HTTP, "called");
auto* session_data = GetSessionData(ctx.Session());
ASSERT(session_data);
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to make a request on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return;
}
// This command can only be called with a bound context
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Tried to make a request without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
return;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(
Service_HTTP,
"Tried to make a request on a mismatched session input context={} session context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return;
}
auto itr = contexts.find(context_handle);
ASSERT(itr != contexts.end());
itr->second.request_future.wait();
const u32 response_code = itr->second.response.status;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
rb.Push(RESULT_SUCCESS);
rb.Push(response_code);
} }
void HTTP_C::GetResponseStatusCodeTimeout(Kernel::HLERequestContext& ctx) { void HTTP_C::GetResponseStatusCodeTimeout(Kernel::HLERequestContext& ctx) {
GetResponseStatusCodeImpl(ctx, true);
}
void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool timeout) {
IPC::RequestParser rp(ctx); IPC::RequestParser rp(ctx);
const Context::Handle context_handle = rp.Pop<u32>(); const Context::Handle context_handle = rp.Pop<u32>();
const u64 timeout = rp.Pop<u64>(); u64 timeout_nanos = 0;
if (timeout) {
LOG_INFO(Service_HTTP, "called, timeout={}", timeout); timeout_nanos = rp.Pop<u64>();
LOG_INFO(Service_HTTP, "called, timeout={}", timeout_nanos);
auto* session_data = GetSessionData(ctx.Session()); } else {
ASSERT(session_data); LOG_INFO(Service_HTTP, "called");
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to make a request on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return;
} }
// This command can only be called with a bound context if (!PerformStateChecks(ctx, rp, context_handle)) {
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Tried to make a request without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
return;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(
Service_HTTP,
"Tried to make a request on a mismatched session input context={} session context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return; return;
} }
auto itr = contexts.find(context_handle); auto itr = contexts.find(context_handle);
ASSERT(itr != contexts.end()); ASSERT(itr != contexts.end());
itr->second.request_future.wait_for(std::chrono::nanoseconds(timeout)); if (timeout) {
itr->second.request_future.wait_for(std::chrono::nanoseconds(timeout));
} else {
itr->second.request_future.wait();
}
const u32 response_code = itr->second.response.status; const u32 response_code = itr->second.response.status;
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
@ -765,32 +532,7 @@ void HTTP_C::SetClientCertContext(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_HTTP, "called with context_handle={} client_cert_handle={}", context_handle, LOG_DEBUG(Service_HTTP, "called with context_handle={} client_cert_handle={}", context_handle,
client_cert_handle); client_cert_handle);
auto* session_data = GetSessionData(ctx.Session()); if (!PerformStateChecks(ctx, rp, context_handle)) {
ASSERT(session_data);
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to set client cert on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return;
}
// This command can only be called with a bound context
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Tried to set client cert without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
return;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(Service_HTTP,
"Tried to add set client cert on a mismatched session input context={} session "
"context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return; return;
} }
@ -891,13 +633,8 @@ void HTTP_C::OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx) {
LOG_DEBUG(Service_HTTP, "called, cert_id={} cert_handle={}", cert_id, client_certs_counter); LOG_DEBUG(Service_HTTP, "called, cert_id={} cert_handle={}", cert_id, client_certs_counter);
auto* session_data = GetSessionData(ctx.Session()); auto* session_data = EnsureSessionInitialized(ctx, rp);
ASSERT(session_data); if (!session_data) {
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Command called without Initialize");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return; return;
} }
@ -1006,13 +743,8 @@ void HTTP_C::GetDownloadSizeState(Kernel::HLERequestContext& ctx) {
LOG_INFO(Service_HTTP, "called"); LOG_INFO(Service_HTTP, "called");
auto* session_data = GetSessionData(ctx.Session()); const auto* session_data = EnsureSessionInitialized(ctx, rp);
ASSERT(session_data); if (!session_data) {
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to make a request on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return; return;
} }
@ -1039,6 +771,51 @@ void HTTP_C::GetDownloadSizeState(Kernel::HLERequestContext& ctx) {
rb.Push(content_length); rb.Push(content_length);
} }
SessionData* HTTP_C::EnsureSessionInitialized(Kernel::HLERequestContext& ctx,
IPC::RequestParser rp) {
auto* session_data = GetSessionData(ctx.Session());
ASSERT(session_data);
if (!session_data->initialized) {
LOG_ERROR(Service_HTTP, "Tried to make a request on an uninitialized session");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return nullptr;
}
return session_data;
}
bool HTTP_C::PerformStateChecks(Kernel::HLERequestContext& ctx, IPC::RequestParser rp,
Context::Handle context_handle) {
const auto* session_data = EnsureSessionInitialized(ctx, rp);
if (!session_data) {
return false;
}
// This command can only be called with a bound context
if (!session_data->current_http_context) {
LOG_ERROR(Service_HTTP, "Tried to make a request without a bound context");
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultCode(ErrorDescription::NotImplemented, ErrorModule::HTTP,
ErrorSummary::Internal, ErrorLevel::Permanent));
return false;
}
if (session_data->current_http_context != context_handle) {
LOG_ERROR(
Service_HTTP,
"Tried to make a request on a mismatched session input context={} session context={}",
context_handle, *session_data->current_http_context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ERROR_STATE_ERROR);
return false;
}
return true;
}
void HTTP_C::DecryptClCertA() { void HTTP_C::DecryptClCertA() {
static constexpr u32 iv_length = 16; static constexpr u32 iv_length = 16;

View File

@ -353,6 +353,12 @@ private:
*/ */
void ReceiveDataTimeout(Kernel::HLERequestContext& ctx); void ReceiveDataTimeout(Kernel::HLERequestContext& ctx);
/**
* ReceiveDataImpl:
* Implements ReceiveData and ReceiveDataTimeout service functions
*/
void ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout);
/** /**
* HTTP_C::AddRequestHeader service function * HTTP_C::AddRequestHeader service function
* Inputs: * Inputs:
@ -404,6 +410,12 @@ private:
*/ */
void GetResponseStatusCodeTimeout(Kernel::HLERequestContext& ctx); void GetResponseStatusCodeTimeout(Kernel::HLERequestContext& ctx);
/**
* GetResponseStatusCodeImpl:
* Implements GetResponseStatusCode and GetResponseStatusCodeTimeout service functions
*/
void GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool timeout);
/** /**
* HTTP_C::SetClientCertContext service function * HTTP_C::SetClientCertContext service function
* Inputs: * Inputs:
@ -465,6 +477,12 @@ private:
*/ */
void Finalize(Kernel::HLERequestContext& ctx); void Finalize(Kernel::HLERequestContext& ctx);
[[nodiscard]] SessionData* EnsureSessionInitialized(Kernel::HLERequestContext& ctx,
IPC::RequestParser rp);
[[nodiscard]] bool PerformStateChecks(Kernel::HLERequestContext& ctx, IPC::RequestParser rp,
Context::Handle context_handle);
void DecryptClCertA(); void DecryptClCertA();
std::shared_ptr<Kernel::SharedMemory> shared_memory = nullptr; std::shared_ptr<Kernel::SharedMemory> shared_memory = nullptr;

View File

@ -19,22 +19,23 @@
#include "core/hle/service/apt/apt.h" #include "core/hle/service/apt/apt.h"
#include "core/hle/service/boss/boss.h" #include "core/hle/service/boss/boss.h"
#include "core/hle/service/cam/cam.h" #include "core/hle/service/cam/cam.h"
#include "core/hle/service/cam/y2r_u.h"
#include "core/hle/service/cecd/cecd.h" #include "core/hle/service/cecd/cecd.h"
#include "core/hle/service/cfg/cfg.h" #include "core/hle/service/cfg/cfg.h"
#include "core/hle/service/csnd/csnd_snd.h" #include "core/hle/service/csnd/csnd_snd.h"
#include "core/hle/service/dlp/dlp.h" #include "core/hle/service/dlp/dlp.h"
#include "core/hle/service/dsp/dsp_dsp.h" #include "core/hle/service/dsp/dsp_dsp.h"
#include "core/hle/service/err_f.h" #include "core/hle/service/err/err_f.h"
#include "core/hle/service/frd/frd.h" #include "core/hle/service/frd/frd.h"
#include "core/hle/service/fs/archive.h" #include "core/hle/service/fs/archive.h"
#include "core/hle/service/fs/fs_user.h" #include "core/hle/service/fs/fs_user.h"
#include "core/hle/service/gsp/gsp.h" #include "core/hle/service/gsp/gsp.h"
#include "core/hle/service/gsp/gsp_lcd.h" #include "core/hle/service/gsp/gsp_lcd.h"
#include "core/hle/service/hid/hid.h" #include "core/hle/service/hid/hid.h"
#include "core/hle/service/http_c.h" #include "core/hle/service/http/http_c.h"
#include "core/hle/service/ir/ir.h" #include "core/hle/service/ir/ir.h"
#include "core/hle/service/ldr_ro/ldr_ro.h" #include "core/hle/service/ldr_ro/ldr_ro.h"
#include "core/hle/service/mic_u.h" #include "core/hle/service/mic/mic_u.h"
#include "core/hle/service/mvd/mvd.h" #include "core/hle/service/mvd/mvd.h"
#include "core/hle/service/ndm/ndm_u.h" #include "core/hle/service/ndm/ndm_u.h"
#include "core/hle/service/news/news.h" #include "core/hle/service/news/news.h"
@ -50,9 +51,8 @@
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
#include "core/hle/service/sm/sm.h" #include "core/hle/service/sm/sm.h"
#include "core/hle/service/sm/srv.h" #include "core/hle/service/sm/srv.h"
#include "core/hle/service/soc_u.h" #include "core/hle/service/soc/soc_u.h"
#include "core/hle/service/ssl_c.h" #include "core/hle/service/ssl/ssl_c.h"
#include "core/hle/service/y2r_u.h"
namespace Service { namespace Service {

View File

@ -12,7 +12,7 @@
#include "common/microprofileui.h" #include "common/microprofileui.h"
#include "common/vector_math.h" #include "common/vector_math.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/service/y2r/y2r_u.h" #include "core/hle/service/cam/y2r_u.h"
#include "core/hw/y2r.h" #include "core/hw/y2r.h"
#include "core/memory.h" #include "core/memory.h"