Create and use ctx.CommandID()

This commit is contained in:
PabloMK7 2023-10-04 22:31:14 +02:00
parent 0fa5357754
commit 3ccbe657b1
2 changed files with 10 additions and 8 deletions

View File

@ -213,6 +213,11 @@ public:
return {cmd_buf[0]}; return {cmd_buf[0]};
} }
/// Returns the command ID from the IPC command buffer.
u16 CommandID() const {
return static_cast<u16>(CommandHeader().command_id.Value());
}
/** /**
* Returns the session through which this request was made. This can be used as a map key to * Returns the session through which this request was made. This can be used as a map key to
* access per-client data on services. * access per-client data on services.

View File

@ -490,8 +490,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) {
return 1'000'000; return 1'000'000;
}, },
[async_data](Kernel::HLERequestContext& ctx) { [async_data](Kernel::HLERequestContext& ctx) {
IPC::RequestBuilder rb(ctx, static_cast<u16>(ctx.CommandHeader().command_id.Value()), 1, IPC::RequestBuilder rb(ctx, ctx.CommandID(), 1, 0);
0);
if (async_data->async_res != RESULT_SUCCESS) { if (async_data->async_res != RESULT_SUCCESS) {
rb.Push(async_data->async_res); rb.Push(async_data->async_res);
return; return;
@ -820,13 +819,13 @@ void HTTP_C::GetResponseHeader(Kernel::HLERequestContext& ctx) {
async_data->value_buffer->Write(header_value.data(), 0, header_value.size()); async_data->value_buffer->Write(header_value.data(), 0, header_value.size());
} else { } else {
LOG_DEBUG(Service_HTTP, "header={} not found", header_name_str); LOG_DEBUG(Service_HTTP, "header={} not found", header_name_str);
IPC::RequestBuilder rb(ctx, 0x001E, 1, 2); IPC::RequestBuilder rb(ctx, ctx.CommandID(), 1, 2);
rb.Push(ERROR_HEADER_NOT_FOUND); rb.Push(ERROR_HEADER_NOT_FOUND);
rb.PushMappedBuffer(*async_data->value_buffer); rb.PushMappedBuffer(*async_data->value_buffer);
return; return;
} }
IPC::RequestBuilder rb(ctx, 0x001E, 2, 2); IPC::RequestBuilder rb(ctx, ctx.CommandID(), 2, 2);
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.Push(copied_size); rb.Push(copied_size);
rb.PushMappedBuffer(*async_data->value_buffer); rb.PushMappedBuffer(*async_data->value_buffer);
@ -890,8 +889,7 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time
}, },
[async_data](Kernel::HLERequestContext& ctx) { [async_data](Kernel::HLERequestContext& ctx) {
if (async_data->async_res != RESULT_SUCCESS) { if (async_data->async_res != RESULT_SUCCESS) {
IPC::RequestBuilder rb( IPC::RequestBuilder rb(ctx, ctx.CommandID(), 1, 0);
ctx, static_cast<u16>(ctx.CommandHeader().command_id.Value()), 1, 0);
rb.Push(async_data->async_res); rb.Push(async_data->async_res);
return; return;
} }
@ -901,8 +899,7 @@ void HTTP_C::GetResponseStatusCodeImpl(Kernel::HLERequestContext& ctx, bool time
const u32 response_code = http_context.response.status; const u32 response_code = http_context.response.status;
LOG_DEBUG(Service_HTTP, "Status code: {}, response_code={}", "good", response_code); LOG_DEBUG(Service_HTTP, "Status code: {}, response_code={}", "good", response_code);
IPC::RequestBuilder rb(ctx, static_cast<u16>(ctx.CommandHeader().command_id.Value()), 2, IPC::RequestBuilder rb(ctx, ctx.CommandID(), 2, 0);
0);
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.Push(response_code); rb.Push(response_code);
}); });