Annotate FeliCa SEAC request and response traces

This commit is contained in:
kormax
2026-08-01 12:42:06 +03:00
parent 5b9e37ba13
commit cec963b9ba
3 changed files with 43 additions and 5 deletions
+39 -1
View File
@@ -2443,12 +2443,50 @@ void annotateLegic(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
}
}
void annotateFelica(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) {
static bool annotateFelicaSeac(char *exp, size_t size, const uint8_t *cmd, uint8_t cmdsize, bool is_response) {
if (cmdsize < 7 || cmd[4] != 0x01 || cmd[5] != 0x01 ||
(cmd[6] != 0x01 && cmd[6] < 0x0F)) {
return false;
}
const char *operation = NULL;
switch (cmd[3]) {
case FELICA_SEAC_POLLING_CMD:
operation = "POLLING";
break;
case FELICA_SEAC_AUTHENTICATION1_CMD:
operation = "AUTHENTICATION1";
break;
case FELICA_SEAC_AUTHENTICATION2_CMD:
operation = "AUTHENTICATION2";
break;
case FELICA_SEAC_WRITE_CMD:
operation = "WRITE";
break;
case FELICA_SEAC_READ_CMD:
operation = "READ";
break;
case FELICA_SEAC_EXTENDED_CMD:
operation = "EXTENDED";
break;
default:
return false;
}
snprintf(exp, size, "SEAC %s %s (SELECTOR %02X)", operation, is_response ? "RES" : "REQ", cmd[6]);
return true;
}
void annotateFelica(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response) {
if (cmdsize < 4) {
snprintf(exp, size, "?");
return;
}
if (annotateFelicaSeac(exp, size, cmd, cmdsize, is_response)) {
return;
}
uint16_t cmd_code = cmd[3];
if (cmd_code >= 0xC0 && cmdsize > 4) {
// Command codes >= 0xC0 include a second-byte subcommand/function code.
+1 -1
View File
@@ -54,7 +54,7 @@ void annotateIclass(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool
void annotateIso15693(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
void annotateTopaz(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
void annotateLegic(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
void annotateFelica(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize);
void annotateFelica(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response);
void annotateIso7816(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response);
void annotateCalypso(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response);
void annotateIso14443b(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool is_response);
+3 -3
View File
@@ -839,6 +839,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
case PROTO_HITAGS:
annotateHitagS(explanation, sizeof(explanation), frame, (data_len * 8) - ((8 - parityBytes[0]) % 8), hdr->isResponse);
break;
case FELICA:
annotateFelica(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
break;
case PROTO_HITAGU:
annotateHitagU(explanation, sizeof(explanation), frame, data_len, hdr->isResponse);
break;
@@ -872,9 +875,6 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
case ISO_15693:
annotateIso15693(explanation, sizeof(explanation), frame, data_len);
break;
case FELICA:
annotateFelica(explanation, sizeof(explanation), frame, data_len);
break;
case LTO:
annotateLTO(explanation, sizeof(explanation), frame, data_len);
break;