mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 19:24:37 +00:00
Add reopen commands packet processing.
This commit is contained in:
@@ -64,6 +64,7 @@
|
|||||||
#define AARUREMOTE_PACKET_TYPE_RESPONSE_AM_I_ROOT 27
|
#define AARUREMOTE_PACKET_TYPE_RESPONSE_AM_I_ROOT 27
|
||||||
#define AARUREMOTE_PACKET_TYPE_MULTI_COMMAND_SDHCI 28
|
#define AARUREMOTE_PACKET_TYPE_MULTI_COMMAND_SDHCI 28
|
||||||
#define AARUREMOTE_PACKET_TYPE_RESPONSE_MULTI_SDHCI 29
|
#define AARUREMOTE_PACKET_TYPE_RESPONSE_MULTI_SDHCI 29
|
||||||
|
#define AARUREMOTE_PACKET_TYPE_COMMAND_REOPEN 30
|
||||||
#define AARUREMOTE_PROTOCOL_MAX 2
|
#define AARUREMOTE_PROTOCOL_MAX 2
|
||||||
#define AARUREMOTE_PACKET_NOP_REASON_OOO 0
|
#define AARUREMOTE_PACKET_NOP_REASON_OOO 0
|
||||||
#define AARUREMOTE_PACKET_NOP_REASON_NOT_IMPLEMENTED 1
|
#define AARUREMOTE_PACKET_NOP_REASON_NOT_IMPLEMENTED 1
|
||||||
@@ -71,6 +72,8 @@
|
|||||||
#define AARUREMOTE_PACKET_NOP_REASON_ERROR_LIST_DEVICES 3
|
#define AARUREMOTE_PACKET_NOP_REASON_ERROR_LIST_DEVICES 3
|
||||||
#define AARUREMOTE_PACKET_NOP_REASON_OPEN_OK 4
|
#define AARUREMOTE_PACKET_NOP_REASON_OPEN_OK 4
|
||||||
#define AARUREMOTE_PACKET_NOP_REASON_OPEN_ERROR 5
|
#define AARUREMOTE_PACKET_NOP_REASON_OPEN_ERROR 5
|
||||||
|
#define AARUREMOTE_PACKET_NOP_REASON_REOPEN_OK 6
|
||||||
|
#define AARUREMOTE_PACKET_NOP_REASON_CLOSE_ERROR 5
|
||||||
#define AARUREMOTE_DEVICE_TYPE_UNKNOWN -1
|
#define AARUREMOTE_DEVICE_TYPE_UNKNOWN -1
|
||||||
#define AARUREMOTE_DEVICE_TYPE_ATA 1
|
#define AARUREMOTE_DEVICE_TYPE_ATA 1
|
||||||
#define AARUREMOTE_DEVICE_TYPE_ATAPI 2
|
#define AARUREMOTE_DEVICE_TYPE_ATAPI 2
|
||||||
@@ -497,6 +500,11 @@ typedef struct
|
|||||||
AaruResSdhci responses[0];
|
AaruResSdhci responses[0];
|
||||||
} AaruPacketMultiResSdhci;
|
} AaruPacketMultiResSdhci;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
AaruPacketHeader hdr;
|
||||||
|
} AaruPacketCmdReOpen;
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -622,4 +630,5 @@ void Initialize();
|
|||||||
void PlatformLoop(AaruPacketHello* pkt_server_hello);
|
void PlatformLoop(AaruPacketHello* pkt_server_hello);
|
||||||
void* WorkingLoop(void* arguments);
|
void* WorkingLoop(void* arguments);
|
||||||
uint8_t AmIRoot();
|
uint8_t AmIRoot();
|
||||||
|
int32_t ReOpen(void *device_ctx, uint32_t* closeFailed);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
36
worker.c
36
worker.c
@@ -1194,6 +1194,42 @@ void* WorkingLoop(void* arguments)
|
|||||||
free(pkt_cmd_sdhci);
|
free(pkt_cmd_sdhci);
|
||||||
free(pkt_res_sdhci);
|
free(pkt_res_sdhci);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
case AARUREMOTE_PACKET_TYPE_COMMAND_REOPEN:
|
||||||
|
in_buf = malloc(le32toh(pkt_hdr->len));
|
||||||
|
|
||||||
|
if(!in_buf)
|
||||||
|
{
|
||||||
|
printf("Fatal error %d allocating memory for packet, closing connection...\n", errno);
|
||||||
|
free(pkt_hdr);
|
||||||
|
NetClose(cli_ctx);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetRecv(cli_ctx, in_buf, le32toh(pkt_hdr->len), 0);
|
||||||
|
|
||||||
|
ret = ReOpen(device_ctx, &sense);
|
||||||
|
memset(&pkt_nop->reason, 0, 256);
|
||||||
|
|
||||||
|
if(ret)
|
||||||
|
{
|
||||||
|
pkt_nop->error_no = htole32(ret);
|
||||||
|
|
||||||
|
// Error on close
|
||||||
|
if(sense != 0) pkt_nop->reason_code = AARUREMOTE_PACKET_NOP_REASON_CLOSE_ERROR;
|
||||||
|
else
|
||||||
|
pkt_nop->reason_code = AARUREMOTE_PACKET_NOP_REASON_OPEN_ERROR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pkt_nop->error_no = 0;
|
||||||
|
pkt_nop->reason_code = AARUREMOTE_PACKET_NOP_REASON_REOPEN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetWrite(cli_ctx, pkt_nop, sizeof(AaruPacketNop));
|
||||||
|
|
||||||
|
free(in_buf);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
pkt_nop->reason_code = AARUREMOTE_PACKET_NOP_REASON_NOT_RECOGNIZED;
|
pkt_nop->reason_code = AARUREMOTE_PACKET_NOP_REASON_NOT_RECOGNIZED;
|
||||||
|
|||||||
Reference in New Issue
Block a user