move APDU dumps to separate log channel

This commit is contained in:
merlokk 2019-02-06 19:21:06 +02:00
parent 375db69e3a
commit bc1bb3509f
4 changed files with 52 additions and 47 deletions

View File

@ -63,6 +63,7 @@ struct logtag tagtable[] = {
{TAG_BOOT,"BOOT"}, {TAG_BOOT,"BOOT"},
{TAG_EXT,"EXT"}, {TAG_EXT,"EXT"},
{TAG_NFC,"NFC"}, {TAG_NFC,"NFC"},
{TAG_NFC_APDU, "NAPDU"},
}; };

View File

@ -43,24 +43,25 @@ typedef enum
TAG_GA = (1 << 2), TAG_GA = (1 << 2),
TAG_CP = (1 << 3), TAG_CP = (1 << 3),
TAG_ERR = (1 << 4), TAG_ERR = (1 << 4),
TAG_PARSE= (1 << 5), TAG_PARSE = (1 << 5),
TAG_CTAP = (1 << 6), TAG_CTAP = (1 << 6),
TAG_U2F = (1 << 7), TAG_U2F = (1 << 7),
TAG_DUMP = (1 << 8), TAG_DUMP = (1 << 8),
TAG_GREEN = (1 << 9), TAG_GREEN = (1 << 9),
TAG_RED= (1 << 10), TAG_RED = (1 << 10),
TAG_TIME= (1 << 11), TAG_TIME = (1 << 11),
TAG_HID = (1 << 12), TAG_HID = (1 << 12),
TAG_USB = (1 << 13), TAG_USB = (1 << 13),
TAG_WALLET = (1 << 14), TAG_WALLET = (1 << 14),
TAG_STOR = (1 << 15), TAG_STOR = (1 << 15),
TAG_DUMP2 = (1 << 16), TAG_DUMP2 = (1 << 16),
TAG_BOOT = (1 << 17), TAG_BOOT = (1 << 17),
TAG_EXT = (1 << 17), TAG_EXT = (1 << 18),
TAG_NFC = (1 << 18), TAG_NFC = (1 << 19),
TAG_NFC_APDU = (1 << 20),
TAG_NO_TAG = (1UL<<30), TAG_NO_TAG = (1UL << 30),
TAG_FILENO = (1UL<<31) TAG_FILENO = (1UL << 31)
} LOG_TAG; } LOG_TAG;
#if DEBUG_LEVEL > 0 #if DEBUG_LEVEL > 0

View File

@ -41,19 +41,20 @@ int main(int argc, char * argv[])
set_logging_mask( set_logging_mask(
/*0*/ /*0*/
// TAG_GEN| //TAG_GEN|
// TAG_MC | //TAG_MC |
// TAG_GA | //TAG_GA |
// TAG_WALLET | //TAG_WALLET |
TAG_STOR | TAG_STOR |
//TAG_NFC_APDU |
TAG_NFC | TAG_NFC |
// TAG_CP | //TAG_CP |
// TAG_CTAP| //TAG_CTAP|
// TAG_HID| //TAG_HID|
//TAG_U2F| //TAG_U2F|
// TAG_PARSE | //TAG_PARSE |
// TAG_TIME| //TAG_TIME|
// TAG_DUMP| //TAG_DUMP|
TAG_GREEN| TAG_GREEN|
TAG_RED| TAG_RED|
TAG_ERR TAG_ERR

View File

@ -91,7 +91,8 @@ bool ams_receive_with_timeout(uint32_t timeout_ms, uint8_t * data, int maxlen, i
{ {
uint8_t len = buffer_status2 & AMS_BUF_LEN_MASK; uint8_t len = buffer_status2 & AMS_BUF_LEN_MASK;
ams_read_buffer(buf, len); ams_read_buffer(buf, len);
printf1(TAG_NFC,">> "); dump_hex1(TAG_NFC, buf, len); printf1(TAG_NFC_APDU, ">> ");
dump_hex1(TAG_NFC_APDU, buf, len);
*dlen = MIN(32, MIN(maxlen, len)); *dlen = MIN(32, MIN(maxlen, len));
memcpy(data, buf, *dlen); memcpy(data, buf, *dlen);
@ -116,7 +117,8 @@ void nfc_write_frame(uint8_t * data, uint8_t len)
ams_write_buffer(data,len); ams_write_buffer(data,len);
ams_write_command(AMS_CMD_TRANSMIT_BUFFER); ams_write_command(AMS_CMD_TRANSMIT_BUFFER);
printf1(TAG_NFC,"<< "); dump_hex1(TAG_NFC, data, len); printf1(TAG_NFC_APDU, "<< ");
dump_hex1(TAG_NFC_APDU, data, len);
} }
bool nfc_write_response_ex(uint8_t req0, uint8_t * data, uint8_t len, uint16_t resp) bool nfc_write_response_ex(uint8_t req0, uint8_t * data, uint8_t len, uint16_t resp)
@ -600,7 +602,7 @@ void nfc_process_block(uint8_t * buf, int len)
{ {
if (buf[0] & 0x10) if (buf[0] & 0x10)
{ {
printf1(TAG_NFC, "NFC_CMD_IBLOCK chaining blen=%d len=%d\r\n", ibuflen, len); printf1(TAG_NFC_APDU, "NFC_CMD_IBLOCK chaining blen=%d len=%d\r\n", ibuflen, len);
if (ibuflen + len > sizeof(ibuf)) if (ibuflen + len > sizeof(ibuf))
{ {
printf1(TAG_NFC, "I block memory error! must have %d but have only %d\r\n", ibuflen + len, sizeof(ibuf)); printf1(TAG_NFC, "I block memory error! must have %d but have only %d\r\n", ibuflen + len, sizeof(ibuf));
@ -608,8 +610,8 @@ void nfc_process_block(uint8_t * buf, int len)
return; return;
} }
printf1(TAG_NFC,"i> "); printf1(TAG_NFC_APDU,"i> ");
dump_hex1(TAG_NFC, buf, len); dump_hex1(TAG_NFC_APDU, buf, len);
if (len) if (len)
{ {
@ -635,8 +637,8 @@ void nfc_process_block(uint8_t * buf, int len)
printf1(TAG_NFC, "NFC_CMD_IBLOCK chaining last block. blen=%d len=%d\r\n", ibuflen, len); printf1(TAG_NFC, "NFC_CMD_IBLOCK chaining last block. blen=%d len=%d\r\n", ibuflen, len);
printf1(TAG_NFC,"i> "); printf1(TAG_NFC_APDU,"i> ");
dump_hex1(TAG_NFC, buf, len); dump_hex1(TAG_NFC_APDU, buf, len);
nfc_process_iblock(ibuf, ibuflen); nfc_process_iblock(ibuf, ibuflen);
} else { } else {