diff --git a/Makefile.am b/Makefile.am index 82d9d53..ec3de78 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ AM_LDFLAGS = @LIBNFC_LIBS@ lib_LTLIBRARIES = libfreefare.la libfreefare_la_SOURCES = mifare_classic.c mad.c mifare_application.c -libfreefare_la_HEADERS = mifare_common.h mifare_classic.h mad.h mifare_application.h +libfreefare_la_HEADERS = freefare.h libfreefare_ladir = $(includedir) pkgconfigdir = $(libdir)/pkgconfig diff --git a/mad.c b/mad.c index fa9ae14..0233026 100644 --- a/mad.c +++ b/mad.c @@ -31,7 +31,7 @@ #include #include -#include +#include struct mad_sector_0x00 { uint8_t crc; diff --git a/mad.h b/mad.h deleted file mode 100644 index 085df14..0000000 --- a/mad.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (C) 2009, Romain Tartiere, Romuald Conty. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see - * - * $Id$ - */ -#ifndef __MIFARE_APPLICATION_DIRECTORY_H__ -#define __MIFARE_APPLICATION_DIRECTORY_H__ - -#include -#include - -struct mad_aid { - uint8_t function_cluster_code; - uint8_t application_code; -}; -typedef struct mad_aid MadAid; - -struct mad; -typedef struct mad *Mad; - -Mad mad_new (uint8_t version); -Mad mad_read (MifareClassicTag tag); -int mad_write (MifareClassicTag tag, Mad mad, MifareClassicKey key_b_sector_00, MifareClassicKey key_b_sector_10); -int mad_get_version (Mad mad); -void mad_set_version (Mad mad, uint8_t version); -MifareSectorNumber mad_get_card_publisher_sector(Mad mad); -int mad_set_card_publisher_sector(Mad mad, MifareSectorNumber cps); -int mad_get_aid(Mad mad, MifareSectorNumber sector, MadAid *aid); -int mad_set_aid(Mad mad, MifareSectorNumber sector, MadAid aid); -void mad_free (Mad mad); - -#endif /* !__MIFARE_APPLICATION_DIRECTORY_H__ */ diff --git a/mifare_application.c b/mifare_application.c index 4934c21..101f9d0 100644 --- a/mifare_application.c +++ b/mifare_application.c @@ -27,7 +27,7 @@ #include -#include +#include #define FIRST_SECTOR 1 diff --git a/mifare_application.h b/mifare_application.h deleted file mode 100644 index d7f34d6..0000000 --- a/mifare_application.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __MAD_DATA_H__ -#define __MAD_DATA_H__ - -#include - -MifareSectorNumber *mifare_application_alloc (Mad mad, MadAid aid, size_t size); -void mifare_application_free (Mad mad, MadAid aid); - -MifareSectorNumber *mifare_application_find (Mad mad, MadAid aid); - - -#endif /* !__MAD_DATA_H__ */ diff --git a/mifare_classic.c b/mifare_classic.c index 8eb5855..eea90ce 100644 --- a/mifare_classic.c +++ b/mifare_classic.c @@ -45,7 +45,7 @@ #include -#include +#include struct mifare_classic_tag { nfc_device_t *device; diff --git a/mifare_classic.h b/mifare_classic.h deleted file mode 100644 index 6c24b91..0000000 --- a/mifare_classic.h +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * Copyright (C) 2009, Romain Tartiere, Romuald Conty. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see - * - * $Id$ - */ - -#ifndef __MIFARE_CLASSIC_H__ -#define __MIFARE_CLASSIC_H__ - -#include -#include - -#include - -struct mifare_classic_tag; -typedef struct mifare_classic_tag *MifareClassicTag; - -typedef unsigned char MifareClassicBlock[16]; - -typedef unsigned char MifareClassicBlockNumber; - -typedef enum { MFC_KEY_A, MFC_KEY_B } MifareClassicKeyType; -typedef unsigned char MifareClassicKey[6]; - -MifareClassicTag *mifare_classic_get_tags (nfc_device_t *device); -void mifare_classic_free_tags (MifareClassicTag *tags); -int mifare_classic_connect (MifareClassicTag tag); -int mifare_classic_disconnect (MifareClassicTag tag); - -int mifare_classic_authenticate (MifareClassicTag tag, const MifareClassicBlockNumber block, const MifareClassicKey key, const MifareClassicKeyType key_type); -int mifare_classic_read (MifareClassicTag tag, const MifareClassicBlockNumber block, MifareClassicBlock *data); -int mifare_classic_init_value (MifareClassicTag tag, const MifareClassicBlockNumber block, const int32_t value, const MifareClassicBlockNumber adr); -int mifare_classic_read_value (MifareClassicTag tag, const MifareClassicBlockNumber block, int32_t *value, MifareClassicBlockNumber *adr); -int mifare_classic_write (MifareClassicTag tag, const MifareClassicBlockNumber block, const MifareClassicBlock data); - -int mifare_classic_increment (MifareClassicTag tag, const MifareClassicBlockNumber block, const uint32_t amount); -int mifare_classic_decrement (MifareClassicTag tag, const MifareClassicBlockNumber block, const uint32_t amount); -int mifare_classic_restore (MifareClassicTag tag, const MifareClassicBlockNumber block); -int mifare_classic_transfer (MifareClassicTag tag, const MifareClassicBlockNumber block); - -int mifare_classic_get_trailer_block_permission (MifareClassicTag tag, const MifareClassicBlockNumber block, const uint16_t permission, const MifareClassicKeyType key_type); -int mifare_classic_get_data_block_permission (MifareClassicTag tag, const MifareClassicBlockNumber block, const unsigned char permission, const MifareClassicKeyType key_type); - -int mifare_classic_format_sector (MifareClassicTag tag, const MifareSectorNumber sector); -void mifare_classic_trailer_block (MifareClassicBlock *block, const MifareClassicKey key_a, const uint8_t ab_0, const uint8_t ab_1, const uint8_t ab_2, const uint8_t ab_tb, const uint8_t gpb, const MifareClassicKey key_b); - -/* MIFARE Classic Access Bits */ -#define MCAB_R 0x8 -#define MCAB_W 0x4 -#define MCAB_D 0x2 -#define MCAB_I 0x1 - -#define MCAB_READ_KEYA 0x400 -#define MCAB_WRITE_KEYA 0x100 -#define MCAB_READ_ACCESS_BITS 0x040 -#define MCAB_WRITE_ACCESS_BITS 0x010 -#define MCAB_READ_KEYB 0x004 -#define MCAB_WRITE_KEYB 0x001 - -#endif /* !__MIFARE_CLASSIC_H__ */ diff --git a/mifare_common.h b/mifare_common.h deleted file mode 100644 index 4db7a00..0000000 --- a/mifare_common.h +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * Copyright (C) 2009, Romain Tartiere, Romuald Conty. - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see - * - * $Id$ - */ -#ifndef __MIFARE_COMMON_H__ -#define __MIFARE_COMMON_H__ - -#include - -typedef uint8_t MifareSectorNumber; - -#endif /* !__MIFARE_COMMON_H__ */ diff --git a/test/test.h b/test/test.h index c00f0aa..249095a 100644 --- a/test/test.h +++ b/test/test.h @@ -204,9 +204,7 @@ int read_open_memory2(struct archive *, void *, size_t, size_t); */ #include -#include -#include -#include +#include int mifare_classic_test_setup (MifareClassicTag *tag); int mifare_classic_test_teardown (MifareClassicTag tag); diff --git a/test/test_authenticate.c b/test/test_authenticate.c index f9e5807..f5ca974 100644 --- a/test/test_authenticate.c +++ b/test/test_authenticate.c @@ -7,8 +7,6 @@ #include -#include "mifare_classic.h" - DEFINE_TEST(test_authenticate) { int res; diff --git a/test/test_create_trailer_block.c b/test/test_create_trailer_block.c index 60d2681..accdc81 100644 --- a/test/test_create_trailer_block.c +++ b/test/test_create_trailer_block.c @@ -1,7 +1,5 @@ #include "test.h" -#include "mifare_classic.h" - DEFINE_TEST(test_create_trailer_block) { do { diff --git a/test/test_format.c b/test/test_format.c index e3f2885..b28c3cf 100644 --- a/test/test_format.c +++ b/test/test_format.c @@ -7,8 +7,6 @@ #include -#include "mifare_classic.h" - DEFINE_TEST(test_format) { int res; diff --git a/test/test_read_sector_0.c b/test/test_read_sector_0.c index 1cb4018..ffdc164 100644 --- a/test/test_read_sector_0.c +++ b/test/test_read_sector_0.c @@ -7,8 +7,6 @@ #include -#include "mifare_classic.h" - DEFINE_TEST(test_read_sector_0) { MifareClassicTag tag;