2021-03-17 00:13:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include <stratosphere.hpp>
|
2021-03-18 04:46:32 +00:00
|
|
|
#include "cs_command_impl.hpp"
|
2021-03-17 00:13:30 +00:00
|
|
|
|
|
|
|
namespace ams::cs {
|
|
|
|
|
2021-03-18 04:46:32 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct ResponseFirmwareVersion {
|
|
|
|
ResponseHeader header;
|
|
|
|
settings::system::FirmwareVersion firmware_version;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-03-17 00:13:30 +00:00
|
|
|
bool CommandProcessor::ProcessCommand(const CommandHeader &header, const u8 *body, s32 socket) {
|
|
|
|
switch (header.command) {
|
2021-03-18 04:46:32 +00:00
|
|
|
case Command_GetFirmwareVersion:
|
|
|
|
SendFirmwareVersion(socket, header);
|
|
|
|
break;
|
2021-03-17 00:13:30 +00:00
|
|
|
/* TODO: Command support. */
|
2021-07-28 07:55:53 +01:00
|
|
|
/* TODO: Command support. */
|
2021-03-17 00:13:30 +00:00
|
|
|
default:
|
|
|
|
scs::CommandProcessor::ProcessCommand(header, body, socket);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-18 04:46:32 +00:00
|
|
|
void CommandProcessor::SendFirmwareVersion(s32 socket, const CommandHeader &header) {
|
|
|
|
/* Build the response. */
|
|
|
|
ResponseFirmwareVersion response = {
|
|
|
|
.header = {
|
|
|
|
.id = header.id,
|
|
|
|
.response = Response_FirmwareVersion,
|
|
|
|
.body_size = sizeof(response) - sizeof(response.header),
|
|
|
|
},
|
|
|
|
.firmware_version = {},
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Get the firmware version. */
|
|
|
|
const Result result = DoGetFirmwareVersionCommand(std::addressof(response.firmware_version));
|
|
|
|
if (R_SUCCEEDED(result)) {
|
|
|
|
/* Send the response. */
|
|
|
|
auto lk = MakeSendGuardBlock();
|
|
|
|
Send(socket, std::addressof(response), sizeof(response));
|
|
|
|
} else {
|
|
|
|
SendErrorResult(socket, header, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-17 00:13:30 +00:00
|
|
|
}
|