Reintroduce the possibility to hexdump(3) PCD <=> PICC transmissions.
Not a hack this time: - Use the hexdump(3) function of the system if it exists; - Build the subpart of FreeBSD's libutil if not (contrib); - Do this only if configured --with-debug. The Mifare Classic / Ultralight code will be eventually changed to also provide this functionality.
This commit is contained in:
parent
1f1db8692b
commit
61a5ff4e4a
9 changed files with 195 additions and 1 deletions
|
|
@ -15,6 +15,16 @@ libfreefare_la_SOURCES = freefare.c \
|
|||
desfire_error.c \
|
||||
mifare_application.c \
|
||||
tlv.c
|
||||
libfreefare_la_LIBADD =
|
||||
|
||||
if WITH_DEBUG
|
||||
if HAS_LIBUTIL
|
||||
libfreefare_la_LIBADD += -lutil
|
||||
else # HAS_LIBUTIL
|
||||
libfreefare_la_LIBADD += $(top_builddir)/contrib/libutil/libutil.la
|
||||
AM_CFLAGS += -I$(top_builddir)/contrib/libutil/ -DWITH_DEBUG
|
||||
endif # !HAS_LIBUTIL
|
||||
endif # WITH_DEBUG
|
||||
|
||||
libfreefare_la_HEADERS = freefare.h
|
||||
libfreefare_ladir = $(includedir)
|
||||
|
|
|
|||
|
|
@ -200,4 +200,10 @@ struct mifare_ultralight_tag {
|
|||
#define DB_AB(ab) ((ab == C_DEFAULT) ? C_000 : ab)
|
||||
#define TB_AB(ab) ((ab == C_DEFAULT) ? C_100 : ab)
|
||||
|
||||
#ifdef WITH_DEBUG
|
||||
#define DEBUG_XFER(data, nbytes, hint) do { hexdump (data, nbytes, hint, 0); } while (0)
|
||||
#else
|
||||
#define DEBUG_XFER(data, nbytes, hint) do {} while (0)
|
||||
#endif
|
||||
|
||||
#endif /* !__FREEFARE_INTERNAL_H__ */
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@
|
|||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
#ifdef WITH_DEBUG
|
||||
# include "libutil.h"
|
||||
#endif
|
||||
|
||||
#include <freefare.h>
|
||||
#include "freefare_internal.h"
|
||||
|
||||
|
|
@ -179,8 +183,10 @@ static ssize_t read_data (MifareTag tag, uint8_t command, uint8_t file_no, off_
|
|||
do { \
|
||||
errno = 0; \
|
||||
MIFARE_DESFIRE (tag)->last_picc_error = OPERATION_OK; \
|
||||
DEBUG_XFER (msg, __##msg##_n, "===> "); \
|
||||
if (!(nfc_initiator_transceive_dep_bytes (tag->device, msg, __##msg##_n, res, &__##res##_n))) \
|
||||
return errno = EIO, -1; \
|
||||
DEBUG_XFER (res, __##res##_n, "<=== "); \
|
||||
if ((1 == __##res##_n) && (OPERATION_OK != res[0]) && (ADDITIONAL_FRAME != res[0])) \
|
||||
return MIFARE_DESFIRE (tag)->last_picc_error = res[0], -1; \
|
||||
} while (0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue