update to use libnfc's trunk
This commit is contained in:
parent
21008cda5d
commit
4f0227ddcb
20 changed files with 330 additions and 295 deletions
|
|
@ -139,7 +139,7 @@ main(int argc, char *argv[])
|
|||
{
|
||||
int ch;
|
||||
int error = EXIT_SUCCESS;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
|
||||
while ((ch = getopt (argc, argv, "fhy")) != -1) {
|
||||
|
|
@ -161,25 +161,28 @@ main(int argc, char *argv[])
|
|||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
nfc_connstring devices[8];
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count = nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; d < device_count; d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing Mifare Classic tag.");
|
||||
}
|
||||
|
||||
|
|
@ -242,8 +245,9 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
int error = 0;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
Mad mad;
|
||||
|
||||
|
|
@ -102,24 +102,26 @@ main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
nfc_connstring devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count= nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; d < device_count; d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
if (!device) {
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing MIFARE classic tag.");
|
||||
}
|
||||
|
||||
|
|
@ -206,8 +208,9 @@ error:
|
|||
}
|
||||
fclose (ndef_stream);
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
|
||||
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ search_sector_key (MifareTag tag, MifareClassicSectorNumber sector, MifareClassi
|
|||
}
|
||||
|
||||
int
|
||||
fix_mad_trailer_block (nfc_device_t *device, MifareTag tag, MifareClassicSectorNumber sector, MifareClassicKey key, MifareClassicKeyType key_type)
|
||||
fix_mad_trailer_block (nfc_device *device, MifareTag tag, MifareClassicSectorNumber sector, MifareClassicKey key, MifareClassicKeyType key_type)
|
||||
{
|
||||
MifareClassicBlock block;
|
||||
mifare_classic_trailer_block (&block, mad_public_key_a, 0x0, 0x1, 0x1, 0x6, 0x00, default_keyb);
|
||||
|
|
@ -128,7 +128,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
int error = 0;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
Mad mad;
|
||||
MifareClassicKey transport_key = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
|
|
@ -191,24 +191,26 @@ main(int argc, char *argv[])
|
|||
err (EXIT_FAILURE, "malloc");
|
||||
}
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
nfc_connstring devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count = nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; d < device_count; d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
if (!device) {
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing MIFARE classic tag.");
|
||||
}
|
||||
|
||||
|
|
@ -399,10 +401,10 @@ error:
|
|||
}
|
||||
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
|
||||
free (card_write_keys);
|
||||
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,30 +33,32 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
int error = EXIT_SUCCESS;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
|
||||
if (argc > 1)
|
||||
errx (EXIT_FAILURE, "usage: %s", argv[0]);
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
nfc_connstring devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count = nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; d < device_count; d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
if (!device) {
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing tags.");
|
||||
}
|
||||
|
||||
|
|
@ -128,9 +130,9 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
} /* main() */
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ main(int argc, char *argv[])
|
|||
{
|
||||
int ch;
|
||||
int error = EXIT_SUCCESS;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
|
||||
while ((ch = getopt (argc, argv, "hy")) != -1) {
|
||||
|
|
@ -73,24 +73,26 @@ main(int argc, char *argv[])
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
nfc_connstring devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count = nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
if (!device) {
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing Mifare DESFire tags.");
|
||||
}
|
||||
|
||||
|
|
@ -146,9 +148,9 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
} /* main() */
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ main(int argc, char *argv[])
|
|||
{
|
||||
int ch;
|
||||
int error = EXIT_SUCCESS;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
|
||||
while ((ch = getopt (argc, argv, "hy")) != -1) {
|
||||
|
|
@ -73,24 +73,26 @@ main(int argc, char *argv[])
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
nfc_connstring devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count = nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
if (!device) {
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing Mifare DESFire tags.");
|
||||
}
|
||||
|
||||
|
|
@ -230,8 +232,8 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ main(int argc, char *argv[])
|
|||
{
|
||||
int ch;
|
||||
int error = EXIT_SUCCESS;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
|
||||
while ((ch = getopt (argc, argv, "hy")) != -1) {
|
||||
|
|
@ -70,24 +70,26 @@ main(int argc, char *argv[])
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
nfc_connstring devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count = nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
if (!device) {
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing Mifare DESFire tags.");
|
||||
}
|
||||
|
||||
|
|
@ -182,9 +184,9 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
} /* main() */
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ main(int argc, char *argv[])
|
|||
{
|
||||
int ch;
|
||||
int error = EXIT_SUCCESS;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
|
||||
while ((ch = getopt (argc, argv, "hy")) != -1) {
|
||||
|
|
@ -70,24 +70,26 @@ main(int argc, char *argv[])
|
|||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
nfc_connstring devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count = nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; (!error) && (d < device_count); d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
if (!device) {
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing Mifare DESFire tags.");
|
||||
}
|
||||
|
||||
|
|
@ -141,9 +143,9 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
} /* main() */
|
||||
|
||||
|
|
|
|||
|
|
@ -31,30 +31,32 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
int error = EXIT_SUCCESS;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
|
||||
if (argc > 1)
|
||||
errx (EXIT_FAILURE, "usage: %s", argv[0]);
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
nfc_connstring devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count = nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; d < device_count; d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
if (!device) {
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing tags.");
|
||||
}
|
||||
|
||||
|
|
@ -138,9 +140,9 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
} /* main() */
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
int error = EXIT_SUCCESS;
|
||||
nfc_device_t *device = NULL;
|
||||
nfc_device *device = NULL;
|
||||
MifareTag *tags = NULL;
|
||||
|
||||
printf ("NOTE: This application turns Mifare DESFire targets into NFC Forum Type 4 Tags.\n");
|
||||
|
|
@ -56,24 +56,27 @@ main(int argc, char *argv[])
|
|||
if (argc > 1)
|
||||
errx (EXIT_FAILURE, "usage: %s", argv[0]);
|
||||
|
||||
nfc_device_desc_t devices[8];
|
||||
nfc_connstring devices[8];
|
||||
size_t device_count;
|
||||
|
||||
nfc_init(NULL);
|
||||
|
||||
nfc_list_devices (devices, 8, &device_count);
|
||||
if (!device_count)
|
||||
device_count = nfc_list_devices (NULL, devices, 8);
|
||||
if (device_count <= 0)
|
||||
errx (EXIT_FAILURE, "No NFC device found.");
|
||||
|
||||
for (size_t d = 0; d < device_count; d++) {
|
||||
device = nfc_connect (&(devices[d]));
|
||||
if (!device) {
|
||||
warnx ("nfc_connect() failed.");
|
||||
device = nfc_open (NULL, devices[d]);
|
||||
|
||||
if (!device) {
|
||||
warnx ("nfc_open() failed.");
|
||||
error = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
tags = freefare_get_tags (device);
|
||||
if (!tags) {
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
errx (EXIT_FAILURE, "Error listing tags.");
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +162,7 @@ main(int argc, char *argv[])
|
|||
// Mapping Version equal to 10h,MLe equal to 003Bh, MLc equal to 0034h, and NDEF File Control TLV
|
||||
// equal to T =04h, L=06h, V=E1 04 (NDEF ISO FID=E104h) 0E E0 (NDEF File size =3808 Bytes) 00 (free read access)
|
||||
// 00 free write access
|
||||
byte_t capability_container_file_content[15] = {
|
||||
uint8_t capability_container_file_content[15] = {
|
||||
0x00, 0x0F, // CCLEN: Size of this capability container.CCLEN values are between 000Fh and FFFEh
|
||||
0x10, // Mapping version
|
||||
0x00, 0x3B, // MLe: Maximum data size that can be read using a single ReadBinary command. MLe = 000Fh-FFFFh
|
||||
|
|
@ -193,7 +196,8 @@ main(int argc, char *argv[])
|
|||
free (tag_uid);
|
||||
}
|
||||
freefare_free_tags (tags);
|
||||
nfc_disconnect (device);
|
||||
nfc_close (device);
|
||||
}
|
||||
nfc_exit(NULL);
|
||||
exit (error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue