intendention

This commit is contained in:
iceman1001 2018-01-30 03:29:59 +01:00
parent c6207d09e1
commit eb8e7a1679

View file

@ -745,33 +745,38 @@ uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trace, ui
return tracepos; return tracepos;
} }
void printFelica(uint16_t traceLen, uint8_t *trace) void printFelica(uint16_t traceLen, uint8_t *trace) {
{
PrintAndLog(" Gap | Src | Data | CRC | Annotation |"); PrintAndLog(" Gap | Src | Data | CRC | Annotation |");
PrintAndLog("--------|-----|---------------------------------|----------|-------------------|"); PrintAndLog("--------|-----|---------------------------------|----------|-------------------|");
uint16_t tracepos = 0; uint16_t tracepos = 0;
//I am stripping SYNC
while(tracepos<traceLen) while( tracepos < traceLen) {
{
if (tracepos + 3 >= traceLen) break; if (tracepos + 3 >= traceLen) break;
uint16_t gap = (uint16_t)trace[tracepos+1] + ((uint16_t)trace[tracepos] >> 8); uint16_t gap = (uint16_t)trace[tracepos+1] + ((uint16_t)trace[tracepos] >> 8);
uint16_t crc_ok = trace[tracepos+2]; uint16_t crc_ok = trace[tracepos+2];
tracepos += 3; tracepos += 3;
if (tracepos + 3 >= traceLen) break; if (tracepos + 3 >= traceLen) break;
uint16_t len = trace[tracepos+2]; uint16_t len = trace[tracepos+2];
//printf("!!! %02x %02x %02x %02x %02x %02x %d",trace[tracepos+0],trace[tracepos+1],trace[tracepos+2],trace[tracepos+3],trace[tracepos+4],trace[tracepos+5],len);
//I am stripping SYNC
tracepos += 3; //skip SYNC tracepos += 3; //skip SYNC
if( tracepos + len + 1 >= traceLen) break; if( tracepos + len + 1 >= traceLen) break;
uint8_t cmd = trace[tracepos]; uint8_t cmd = trace[tracepos];
uint8_t isResponse = cmd&1; uint8_t isResponse = cmd&1;
char line[32][110]; char line[32][110];
for (int j = 0; j < len+1 && j/8 < 32; j++) for (int j = 0; j < len+1 && j/8 < 32; j++) {
{
snprintf(line[j/8]+(( j % 8) * 4), 110, " %02x ", trace[tracepos+j]); snprintf(line[j/8]+(( j % 8) * 4), 110, " %02x ", trace[tracepos+j]);
} }
char expbuf[50]; char expbuf[50];
switch(cmd) switch(cmd) {
{
case FELICA_POLL_REQ: snprintf(expbuf,49,"Poll Req");break; case FELICA_POLL_REQ: snprintf(expbuf,49,"Poll Req");break;
case FELICA_POLL_ACK: snprintf(expbuf,49,"Poll Resp");break; case FELICA_POLL_ACK: snprintf(expbuf,49,"Poll Resp");break;
@ -830,8 +835,7 @@ case FELICA_UPDATE_RNDID_ACK :snprintf(expbuf,49,"Update IDr Resp");break;
} }
int num_lines = MIN((len )/16 + 1, 16); int num_lines = MIN((len )/16 + 1, 16);
for (int j = 0; j < num_lines ; j++) for (int j = 0; j < num_lines ; j++) {
{
if (j == 0) { if (j == 0) {
PrintAndLog("%7d | %s |%-32s |%02x %02x %s| %s", PrintAndLog("%7d | %s |%-32s |%02x %02x %s| %s",
gap, gap,
@ -842,17 +846,14 @@ case FELICA_UPDATE_RNDID_ACK :snprintf(expbuf,49,"Update IDr Resp");break;
(crc_ok) ? "OK" : "NG", (crc_ok) ? "OK" : "NG",
expbuf); expbuf);
} else { } else {
PrintAndLog(" | |%-32s | | ", PrintAndLog(" | |%-32s | | ", line[j]);
line[j]);
} }
} }
tracepos += len + 1; tracepos += len + 1;
} }
PrintAndLog(""); PrintAndLog("");
} }
int usage_hf_list(){ int usage_hf_list(){
PrintAndLog("List protocol data in trace buffer."); PrintAndLog("List protocol data in trace buffer.");
PrintAndLog("Usage: hf list <protocol> [f][c]"); PrintAndLog("Usage: hf list <protocol> [f][c]");