gcc warns:
mifare_classic.c:353:45: warning: dereferencing type-punned pointer
will break strict-aliasing rules [-Wstrict-aliasing]
There is another problem with this code: "data", being a 16-byte
array, may not be suitably aligned for the other types in the union.
This patch resolves this.
libnfc changed its nfc_initiator_transceive_bytes(): it now takes a const size_t used as maximal allowed rx bytes.
libnfc now checks if rx buffer is large enough to get the full response, so libfreefare should take care about whole size of its buffers.
After trying to tweak gindent so that it does not mess-up my ASCII art, give
and read the help of Vim to setup 'cinoptions' according to my needs
(cino=t0(0). This changeset reindent some bits that where not indented as they
should. A future commit will reindent the switch/case according to my (bad)
taste now that I have setup cindent correctly on my system (cino=t0(0:0).
nfc_initiator_transceive_dep_bytes() was removed, and
nfc_initiator_transceive_bytes() is now configured to behave like the one or
the other of the original functions. For details, see:
http://code.google.com/p/libnfc/source/detail?r=592
Many command return 1 byte, and my documentation does not tell what it's
supposed to be. However, this byte is always 0 when running the regression test
suite. It's likely to be an error code with value 0 being a no-error code.
Assume this and check that the returned byte is always 0.
- mifare_classic_format_sector() now wants a sector instead of a block (the name was really disturbing);
- New public API functions for Block <=> Sector conversions.
- New mifare_classic_first_sector_block(), mifare_classic_last_sector_block() functions to ease detection of sectors boundaries;
- New unit tests for mifare_classic_first_sector_block() and mifare_classic_last_sector_block();
- Start to update the API for consistently using blocks and not mixing blocks and sectors with mifare_classic_*() functions;
- Update the mifare-classic-format(1) example to handle MIFARE Classic 1k and 4k.
Many thanks to Johann Dantant from SpringCard for giving me MIFARE Classic 4k cards.
- New mifare_*_tag_new() functions for allocating and initialising memory for a given MIFARE tag;
- Rename mifare_*_free_tag() to mifare_*_tag_free() for consistent names with mifare_*_tag_new() functions.
- Factorize Mifare*Tag as MifareTag;
- Factorize mifare_*_get_tags() / mifare_*_free_tags() as freefare_get_tags() and freefare_free_tags();
- Add a new freefare_get_tag_type() function to get a tag type;
- Update regression test suite;
- Update example.
While this is a major change that basically change all the API, programs using libfreefare should be easily modified by replacing any Mifare*Tag variable by a generic MifareTag one, adding a few lines of code to check the target's type using freefare_get_tag_type(), and changing any call to mifare_*_get_tags() / mifare_*_free_tags() by the generic freefare_get_tags() and freefare_free_tags() functions.