put MifareSectorNumber type in a new mifare_common.h header.
API changed: mifare_classic_format_sector() now takes a MifareSectorNumber in argument.
This commit is contained in:
parent
4bf33cc707
commit
a5dd66f77d
6 changed files with 37 additions and 8 deletions
|
@ -1,13 +1,13 @@
|
|||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
AM_CFLAGS = -I. -std=c99 @LIBNFC_CFLAGS@
|
||||
AM_CFLAGS = -I. @LIBNFC_CFLAGS@
|
||||
AM_LDFLAGS = @LIBNFC_LIBS@
|
||||
|
||||
lib_LTLIBRARIES = libfreefare.la
|
||||
|
||||
libfreefare_la_SOURCES = mifare_classic.c mad.c mifare_application.c
|
||||
libfreefare_la_HEADERS = mifare_classic.h mad.h mifare_application.h
|
||||
libfreefare_la_HEADERS = mifare_common.h mifare_classic.h mad.h mifare_application.h
|
||||
libfreefare_ladir = $(includedir)
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
|
|
@ -30,9 +30,11 @@ AC_CHECK_FUNCS([memset])
|
|||
|
||||
AC_CHECK_HEADERS([endian.h sys/endian.h])
|
||||
if test $ac_cv_header_endian_h = "no" -a $ac_cv_header_sys_endian_h = "no"; then
|
||||
AC_MSG_ERROR([Can't locate header endian.h.]);
|
||||
AC_MSG_ERROR(["Can't locate header endian.h."]);
|
||||
fi
|
||||
|
||||
CFLAGS="$CFLAGS -std=c99"
|
||||
|
||||
# Checks for pkg-config modules.
|
||||
PKG_CHECK_MODULES([LIBNFC], [libnfc], [], [AC_MSG_ERROR([libnfc is mandatory.])])
|
||||
|
||||
|
|
3
mad.h
3
mad.h
|
@ -19,10 +19,9 @@
|
|||
#ifndef __MIFARE_APPLICATION_DIRECTORY_H__
|
||||
#define __MIFARE_APPLICATION_DIRECTORY_H__
|
||||
|
||||
#include <mifare_common.h>
|
||||
#include <mifare_classic.h>
|
||||
|
||||
typedef uint8_t MifareSectorNumber;
|
||||
|
||||
struct mad_aid {
|
||||
uint8_t function_cluster_code;
|
||||
uint8_t application_code;
|
||||
|
|
|
@ -655,9 +655,9 @@ mifare_classic_get_data_block_permission (MifareClassicTag tag, const MifareClas
|
|||
* Reset a MIFARE target sector to factory default.
|
||||
*/
|
||||
int
|
||||
mifare_classic_format_sector (MifareClassicTag tag, const MifareClassicBlockNumber block)
|
||||
mifare_classic_format_sector (MifareClassicTag tag, const MifareSectorNumber sector)
|
||||
{
|
||||
MifareClassicBlockNumber first_sector_block = (block / 4) * 4;
|
||||
MifareClassicBlockNumber first_sector_block = sector * 4;
|
||||
/*
|
||||
* Check that the current key allow us to rewrite data and trailer blocks.
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include <nfc/nfc.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <mifare_common.h>
|
||||
|
||||
struct mifare_classic_tag;
|
||||
typedef struct mifare_classic_tag *MifareClassicTag;
|
||||
|
||||
|
@ -52,7 +54,7 @@ int mifare_classic_transfer (MifareClassicTag tag, const MifareClassicBlockNumb
|
|||
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 MifareClassicBlockNumber block);
|
||||
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 */
|
||||
|
|
26
mifare_common.h
Normal file
26
mifare_common.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*-
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
#ifndef __MIFARE_COMMON_H__
|
||||
#define __MIFARE_COMMON_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint8_t MifareSectorNumber;
|
||||
|
||||
#endif /* !__MIFARE_COMMON_H__ */
|
Loading…
Reference in a new issue