CHG: making sure all outputs follow the same pattern in "hf mfu info"

This commit is contained in:
iceman1001 2015-05-20 22:04:40 +02:00
commit 329f5cf2a5

View file

@ -71,15 +71,9 @@ char* getProductTypeStr( uint8_t id){
char *retStr = buf; char *retStr = buf;
switch(id) { switch(id) {
case 3: case 3: sprintf(retStr, "%02X, Ultralight", id); break;
sprintf(retStr, "%02X, %s", id, "Ultralight"); case 4: sprintf(retStr, "%02X, NTAG", id); break;
break; default: sprintf(retStr, "%02X, unknown", id); break;
case 4:
sprintf(retStr, "%02X, %s", id, "NTAG");
break;
default:
sprintf(retStr, "%02X, %s", id, "unknown");
break;
} }
return buf; return buf;
} }
@ -100,9 +94,9 @@ char* getUlev1CardSizeStr( uint8_t fsize ){
// is LSB set? // is LSB set?
if ( fsize & 1 ) if ( fsize & 1 )
sprintf(retStr, "%02X (%u <-> %u bytes)", fsize, usize, lsize); sprintf(retStr, "%02X, (%u <-> %u bytes)", fsize, usize, lsize);
else else
sprintf(retStr, "%02X (%u bytes)", fsize, lsize); sprintf(retStr, "%02X, (%u bytes)", fsize, lsize);
return buf; return buf;
} }
@ -264,7 +258,7 @@ static int ul_print_default( uint8_t *data){
uid[6] = data[7]; uid[6] = data[7];
PrintAndLog(" UID : %s ", sprint_hex(uid, 7)); PrintAndLog(" UID : %s ", sprint_hex(uid, 7));
PrintAndLog(" UID[0] : %02X, Manufacturer: %s", uid[0], getTagInfo(uid[0]) ); PrintAndLog(" UID[0] : %02X, %s", uid[0], getTagInfo(uid[0]) );
if ( uid[0] == 0x05 ) { if ( uid[0] == 0x05 ) {
uint8_t chip = (data[8] & 0xC7); // 11000111 mask, bit 3,4,5 RFU uint8_t chip = (data[8] & 0xC7); // 11000111 mask, bit 3,4,5 RFU
switch (chip){ switch (chip){
@ -459,7 +453,7 @@ static int ulev1_print_signature( uint8_t *data, uint8_t len){
static int ulev1_print_version(uint8_t *data){ static int ulev1_print_version(uint8_t *data){
PrintAndLog("\n--- Tag Version"); PrintAndLog("\n--- Tag Version");
PrintAndLog(" Raw bytes : %s", sprint_hex(data, 8) ); PrintAndLog(" Raw bytes : %s", sprint_hex(data, 8) );
PrintAndLog(" Vendor ID : %02X, Manufacturer: %s", data[1], getTagInfo(data[1])); PrintAndLog(" Vendor ID : %02X, %s", data[1], getTagInfo(data[1]));
PrintAndLog(" Product type : %s" , getProductTypeStr(data[2])); PrintAndLog(" Product type : %s" , getProductTypeStr(data[2]));
PrintAndLog(" Product subtype : %02X, %s" , data[3], (data[3]==1) ?"17 pF":"50pF"); PrintAndLog(" Product subtype : %02X, %s" , data[3], (data[3]==1) ?"17 pF":"50pF");
PrintAndLog(" Major version : %02X" , data[4]); PrintAndLog(" Major version : %02X" , data[4]);
@ -502,14 +496,13 @@ static int ul_magic_test(){
// 1) take present UID, and try to write it back. OBSOLETE // 1) take present UID, and try to write it back. OBSOLETE
// 2) make a wrong length write to page0, and see if tag answers with ACK/NACK: // 2) make a wrong length write to page0, and see if tag answers with ACK/NACK:
iso14a_card_select_t card; iso14a_card_select_t card;
int status;
if ( !ul_select(&card) ) if ( !ul_select(&card) )
return UL_ERROR; return UL_ERROR;
status = ul_comp_write(0, NULL, 0); int status = ul_comp_write(0, NULL, 0);
ul_switch_off_field(); ul_switch_off_field();
if ( status == 0 ) if ( status == 0 )
return MAGIC; return MAGIC;
return UNKNOWN; return 0;
} }
uint32_t GetHF14AMfU_Type(void){ uint32_t GetHF14AMfU_Type(void){
@ -606,8 +599,9 @@ uint32_t GetHF14AMfU_Type(void){
} }
} }
tagtype = (ul_magic_test() == MAGIC) ? (tagtype | MAGIC) : tagtype;
if (tagtype == (UNKNOWN | MAGIC)) tagtype = UL_MAGIC; tagtype |= ul_magic_test();
if (tagtype == (UNKNOWN | MAGIC)) tagtype = (UL_MAGIC);
return tagtype; return tagtype;
} }
@ -798,6 +792,7 @@ int CmdHF14AMfUInfo(const char *Cmd){
if (tagtype & UL_TYPES_ARRAY[idx]) if (tagtype & UL_TYPES_ARRAY[idx])
startconfigblock = UL_MEMORY_ARRAY[idx]-3; startconfigblock = UL_MEMORY_ARRAY[idx]-3;
if (startconfigblock){ // if we know where the config block is...
status = ul_read(startconfigblock, ulev1_conf, sizeof(ulev1_conf)); status = ul_read(startconfigblock, ulev1_conf, sizeof(ulev1_conf));
if ( status == -1 ) { if ( status == -1 ) {
PrintAndLog("Error: tag didn't answer to READ EV1"); PrintAndLog("Error: tag didn't answer to READ EV1");
@ -807,8 +802,7 @@ int CmdHF14AMfUInfo(const char *Cmd){
// save AUTHENTICATION LIMITS for later: // save AUTHENTICATION LIMITS for later:
authlim = (ulev1_conf[4] & 0x07); authlim = (ulev1_conf[4] & 0x07);
ulev1_print_configuration(ulev1_conf); ulev1_print_configuration(ulev1_conf);
} else { }
authlim=7;
} }
// AUTHLIMIT, (number of failed authentications) // AUTHLIMIT, (number of failed authentications)