Scroll to navigation

MIFARE_APPLICATION(3) Library Functions Manual MIFARE_APPLICATION(3)

NAME

mifare_application_alloc, mifare_application_find, mifare_application_free, mifare_application_read, mifare_application_writeMifare Applications Manipulation Functions

LIBRARY

Mifare card manipulation library (libfreefare, -lfreefare)

SYNOPSIS

#include <freefare.h>

MifareClassicSectorNumber *
mifare_application_alloc(Mad mad, MadAid aid, size_t size);

void
mifare_application_free(Mad mad, MadAid aid);

MifareClassicSectorNumber *
mifare_application_find(Mad mad, MadAid aid);

ssize_t
mifare_application_read(MifareTag tag, Mad mad, MadAid aid, void *buf, size_t nbytes, MifareClassicKey key, MifareClassicKeyType key_type);

ssize_t
mifare_application_write(MifareTag tag, Mad mad, MadAid aid, const void *buf, size_t nbytes, MifareClassicKey key, MifareClassicKeyType key_type);

DESCRIPTION

The () functions facilitate management of applications in a Mifare Application Directory.

The () function allocates enought sectors to store size bytes for the Application Identifier aid and returns the list of allocated sectors.

The list of the sectors previously allocated for aid in a mad can be requested using ().

An application can be removed from a mad using ().

The () reads at most nbytes of the application identified by aid in the mad on the tag and copy them into buf. The function returns the amount of data it copied, or -1 on error.

The () functions writes at most nbytes of buf in the application identified by aid on the mad of the tag and returns the quantity of data written, or -1 on error.

IMPLEMENTATION NOTES

The mifare_application_alloc() function will try to avoid wasting space and might not allocate sectors sequentially if a large amount of space is requested and the target has sectors of different size.

The nbytes argument of mifare_application_read() and mifare_application_write() does not need to be aligned on blocks not sectors.

RETURN VALUES

Unless stated otherwise, all functions return a value greater than or equal to 0 on success or -1 on failure.

SEE ALSO

mad(3), mifare_classic(3)

AUTHORS

Romain Tartiere ⟨romain@blogreen.org⟩
Romuald Conty ⟨romuald@libnfc.org⟩

March 30, 2010 Debian