Rework error reporting infrastructure.
This commit is contained in:
parent
b932c923d5
commit
d9b2deebe2
4 changed files with 14 additions and 7 deletions
1
NEWS
1
NEWS
|
@ -3,6 +3,7 @@ Changes between 0.2.0 and 0.2.1 [xx XXX xxxx]
|
|||
*) The mifare_desfire_error_lookup() and mifare_desfire_get_last_error()
|
||||
functions were removed and replaced by the freefare_strerror(),
|
||||
freefare_strerror_r() and freefare_perror() functions.
|
||||
*) The library reports errors other that the ones returned by the PICC.
|
||||
*) The MDAD_KEYx macro where renamed MDAR_KEYx for consistency.
|
||||
*) The MDCM_MACING macro was renamed MDCM_MACED.
|
||||
*) The MDCM_FULLDES macro was renamed MDCM_ENCIPHERED.
|
||||
|
|
|
@ -214,10 +214,17 @@ const char *
|
|||
freefare_strerror (MifareTag tag)
|
||||
{
|
||||
const char *p = "Unkown error";
|
||||
if (tag->device->iLastError > 0)
|
||||
if (tag->device->iLastError > 0) {
|
||||
p = nfc_strerror (tag->device);
|
||||
else if (tag->tag_info->type == DESFIRE)
|
||||
p = mifare_desfire_error_lookup (MIFARE_DESFIRE (tag)->last_picc_error);
|
||||
} else {
|
||||
if (tag->tag_info->type == DESFIRE) {
|
||||
if (MIFARE_DESFIRE (tag)->last_pcd_error) {
|
||||
p = mifare_desfire_error_lookup (MIFARE_DESFIRE (tag)->last_pcd_error);
|
||||
} else if (MIFARE_DESFIRE (tag)->last_picc_error) {
|
||||
p = mifare_desfire_error_lookup (MIFARE_DESFIRE (tag)->last_picc_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ struct mifare_desfire_tag {
|
|||
struct mifare_tag __tag;
|
||||
|
||||
uint8_t last_picc_error;
|
||||
char *last_pcd_error;
|
||||
uint8_t last_pcd_error;
|
||||
MifareDESFireKey session_key;
|
||||
uint8_t authenticated_key_no;
|
||||
uint8_t ivect[MAX_CRYPTO_BLOCK_SIZE];
|
||||
|
|
|
@ -243,7 +243,7 @@ mifare_desfire_tag_new (void)
|
|||
MifareTag tag;
|
||||
if ((tag= malloc (sizeof (struct mifare_desfire_tag)))) {
|
||||
MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK;
|
||||
MIFARE_DESFIRE (tag)->last_pcd_error = NULL;
|
||||
MIFARE_DESFIRE (tag)->last_pcd_error = OPERATION_OK;
|
||||
MIFARE_DESFIRE (tag)->session_key = NULL;
|
||||
MIFARE_DESFIRE (tag)->crypto_buffer = NULL;
|
||||
MIFARE_DESFIRE (tag)->crypto_buffer_size = 0;
|
||||
|
@ -258,7 +258,6 @@ void
|
|||
mifare_desfire_tag_free (MifareTag tag)
|
||||
{
|
||||
free (MIFARE_DESFIRE (tag)->session_key);
|
||||
free (MIFARE_DESFIRE (tag)->last_pcd_error);
|
||||
free (MIFARE_DESFIRE (tag)->crypto_buffer);
|
||||
free (tag);
|
||||
}
|
||||
|
@ -291,7 +290,7 @@ mifare_desfire_connect (MifareTag tag)
|
|||
free (MIFARE_DESFIRE (tag)->session_key);
|
||||
MIFARE_DESFIRE (tag)->session_key = NULL;
|
||||
MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK;
|
||||
MIFARE_DESFIRE (tag)->last_pcd_error = NULL;
|
||||
MIFARE_DESFIRE (tag)->last_pcd_error = OPERATION_OK;
|
||||
MIFARE_DESFIRE (tag)->authenticated_key_no = NOT_YET_AUTHENTICATED;
|
||||
MIFARE_DESFIRE (tag)->block_number = 0;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue