Capabilities versionning, would also detect platform struct pack issues

This commit is contained in:
Philippe Teuwen 2019-05-10 19:00:18 +02:00
commit 3412e9d8c5
3 changed files with 8 additions and 1 deletions

View file

@ -428,6 +428,7 @@ void SendStatus(void) {
void SendCapabilities(void) {
capabilities_t capabilities;
capabilities.version = CAPABILITIES_VERSION;
capabilities.via_fpc = reply_via_fpc;
if (reply_via_fpc)
capabilities.baudrate = USART_BAUD_RATE;

View file

@ -613,6 +613,11 @@ int TestProxmark(void) {
SendCommandNG(CMD_CAPABILITIES, NULL, 0);
if (WaitForResponseTimeoutW(CMD_CAPABILITIES, &resp, 1000, false)) {
if ((resp.length != sizeof(pm3_capabilities)) || (resp.data.asBytes[0] != CAPABILITIES_VERSION)) {
PrintAndLogEx(ERR, _RED_("Capabilities structure version sent by Proxmark3 is not the same as the one used by the client!"));
PrintAndLogEx(ERR, _RED_("Please flash the Proxmark with the same version as the client."));
return PM3_EDEVNOTSUPP;
}
memcpy(&pm3_capabilities, resp.data.asBytes, MIN(sizeof(capabilities_t), resp.length));
conn.send_via_fpc_usart = pm3_capabilities.via_fpc;
conn.uart_speed = pm3_capabilities.baudrate;

View file

@ -138,6 +138,7 @@ typedef struct {
} t55xx_config;
typedef struct {
uint8_t version;
uint32_t baudrate;
bool via_fpc : 1;
// rdv4
@ -164,7 +165,7 @@ typedef struct {
bool hw_available_flash : 1;
bool hw_available_smartcard : 1;
} PACKED capabilities_t;
#define CAPABILITIES_VERSION 1
extern capabilities_t pm3_capabilities;
// For the bootloader