Better Reply structs

This commit is contained in:
Philippe Teuwen 2019-04-17 23:44:48 +02:00
commit 533667ea6d
57 changed files with 725 additions and 718 deletions

View file

@ -199,7 +199,7 @@ const productName uidmapping[] = {
static int getUID(uint8_t *buf) {
UsbReplyNG resp;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
c.d.asBytes[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_INVENTORY | ISO15_REQINV_SLOT1;
c.d.asBytes[1] = ISO15_CMD_INVENTORY;
@ -218,9 +218,9 @@ static int getUID(uint8_t *buf) {
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
uint8_t resplen = resp.core.old.arg[0];
if (resplen >= 12 && CheckCrc15(resp.core.old.d.asBytes, 12)) {
memcpy(buf, resp.core.old.d.asBytes + 2, 8);
uint8_t resplen = resp.oldarg[0];
if (resplen >= 12 && CheckCrc15(resp.data.asBytes, 12)) {
memcpy(buf, resp.data.asBytes + 2, 8);
return 1;
}
}
@ -418,7 +418,7 @@ static int usage_15_readmulti(void) {
* Parameters:
* **cmd command line
*/
static int prepareHF15Cmd(char **cmd, UsbCommand *c, uint8_t iso15cmd) {
static int prepareHF15Cmd(char **cmd, UsbCommandOLD *c, uint8_t iso15cmd) {
int temp;
uint8_t *req = c->d.asBytes;
uint8_t uid[8] = {0x00};
@ -577,7 +577,7 @@ static int CmdHF15Samples(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_15_samples();
UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
@ -596,7 +596,7 @@ static int CmdHF15Info(const char *Cmd) {
UsbReplyNG resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
char cmdbuf[100] = {0};
char *cmd = cmdbuf;
@ -619,14 +619,14 @@ static int CmdHF15Info(const char *Cmd) {
return 1;
}
uint32_t status = resp.core.old.arg[0];
uint32_t status = resp.oldarg[0];
if (status < 2) {
PrintAndLogEx(WARNING, "iso15693 card doesn't answer to systeminfo command");
return 1;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (recv[0] & ISO15_RES_ERROR) {
PrintAndLogEx(WARNING, "iso15693 card returned error %i: %s", recv[0], TagErrorStr(recv[0]));
@ -674,7 +674,7 @@ static int CmdHF15Record(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_15_record();
UsbCommand c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -702,7 +702,7 @@ static int CmdHF15Sim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Starting simulating UID %s", sprint_hex(uid, sizeof(uid)));
UsbCommand c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}, {{0}}};
memcpy(c.d.asBytes, uid, 8);
clearCommandBuffer();
SendCommand(&c);
@ -718,7 +718,7 @@ static int CmdHF15Afi(const char *Cmd) {
PrintAndLogEx(SUCCESS, "press pm3-button to cancel");
UsbCommand c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -784,7 +784,7 @@ static int CmdHF15Dump(const char *Cmd) {
memset(data, 0, sizeof(data));
UsbReplyNG resp;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
req[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS;
req[1] = ISO15_CMD_READ;
@ -803,13 +803,13 @@ static int CmdHF15Dump(const char *Cmd) {
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
uint8_t len = resp.core.old.arg[0];
uint8_t len = resp.oldarg[0];
if (len < 2) {
PrintAndLogEx(FAILED, "iso15693 card select failed");
continue;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (!CheckCrc15(recv, len)) {
PrintAndLogEx(FAILED, "crc fail");
@ -821,9 +821,9 @@ static int CmdHF15Dump(const char *Cmd) {
break;
}
mem[blocknum].lock = resp.core.old.d.asBytes[0];
memcpy(mem[blocknum].block, resp.core.old.d.asBytes + 1, 4);
memcpy(data + (blocknum * 4), resp.core.old.d.asBytes + 1, 4);
mem[blocknum].lock = resp.data.asBytes[0];
memcpy(mem[blocknum].block, resp.data.asBytes + 1, 4);
memcpy(data + (blocknum * 4), resp.data.asBytes + 1, 4);
retry = 0;
blocknum++;
@ -860,7 +860,7 @@ static int CmdHF15Raw(const char *Cmd) {
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_raw();
UsbReplyNG resp;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
int reply = 1, fast = 1, i = 0;
bool crc = false;
char buf[5] = "";
@ -926,9 +926,9 @@ static int CmdHF15Raw(const char *Cmd) {
if (reply) {
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
uint8_t len = resp.core.old.arg[0];
uint8_t len = resp.oldarg[0];
PrintAndLogEx(NORMAL, "received %i octets", len);
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.core.old.d.asBytes, len));
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.data.asBytes, len));
} else {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
}
@ -947,7 +947,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
UsbReplyNG resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0;
uint8_t pagenum, pagecount;
@ -986,13 +986,13 @@ static int CmdHF15Readmulti(const char *Cmd) {
return 1;
}
uint32_t status = resp.core.old.arg[0];
uint32_t status = resp.oldarg[0];
if (status < 2) {
PrintAndLogEx(FAILED, "iso15693 card select failed");
return 1;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (!CheckCrc15(recv, status)) {
PrintAndLogEx(FAILED, "CRC failed");
@ -1031,11 +1031,11 @@ static int CmdHF15Read(const char *Cmd) {
UsbReplyNG resp;
uint8_t *recv;
// UsbCommand arg: len, speed, recv?
// UsbCommandOLD arg: len, speed, recv?
// arg0 (datalen, cmd len? .arg0 == crc?)
// arg1 (speed == 0 == 1 of 256, == 1 == 1 of 4 )
// arg2 (recv == 1 == expect a response)
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}};
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}};
uint8_t *req = c.d.asBytes;
int reqlen = 0, blocknum;
char cmdbuf[100] = {0};
@ -1066,13 +1066,13 @@ static int CmdHF15Read(const char *Cmd) {
return 1;
}
uint32_t status = resp.core.old.arg[0];
uint32_t status = resp.oldarg[0];
if (status < 2) {
PrintAndLogEx(NORMAL, "iso15693 card select failed");
return 1;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (!CheckCrc15(recv, status)) {
PrintAndLogEx(NORMAL, "CRC failed");
@ -1104,7 +1104,7 @@ static int CmdHF15Write(const char *Cmd) {
UsbReplyNG resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0, pagenum, temp;
char cmdbuf[100] = {0};
@ -1150,13 +1150,13 @@ static int CmdHF15Write(const char *Cmd) {
return 1;
}
uint32_t status = resp.core.old.arg[0];
uint32_t status = resp.oldarg[0];
if (status < 2) {
PrintAndLogEx(FAILED, "iso15693 card select failed");
return 1;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (!CheckCrc15(recv, status)) {
PrintAndLogEx(FAILED, "CRC failed");