Massive code clean up: (Fixes Issue 161)
- Remove typedef from internal structs - Remove _t suffix from types - Fix tests using connstrings
This commit is contained in:
parent
55daa29a7c
commit
c718fafee7
47 changed files with 546 additions and 533 deletions
|
|
@ -10,8 +10,8 @@
|
|||
int
|
||||
main (int argc, const char *argv[])
|
||||
{
|
||||
nfc_device_t *pnd;
|
||||
nfc_target_info_t nti;
|
||||
nfc_device *pnd;
|
||||
nfc_target_info nti;
|
||||
|
||||
// Display libnfc version
|
||||
const char *acLibnfcVersion = nfc_version ();
|
||||
|
|
@ -30,7 +30,7 @@ main (int argc, const char *argv[])
|
|||
printf ("Connected to NFC reader: %s\n", pnd->acName);
|
||||
|
||||
// Poll for a ISO14443A (MIFARE) tag
|
||||
const nfc_modulation_t nmMifare = {
|
||||
const nfc_modulation nmMifare = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_106,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ static byte_t abtSak;
|
|||
static byte_t abtAts[MAX_FRAME_LEN];
|
||||
static byte_t szAts = 0;
|
||||
static size_t szCL = 1;//Always start with Cascade Level 1 (CL1)
|
||||
static nfc_device_t *pnd;
|
||||
static nfc_device *pnd;
|
||||
|
||||
bool quiet_output = false;
|
||||
bool force_rats = false;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
#define MAX_FRAME_LEN 264
|
||||
|
||||
static nfc_device_t *pnd;
|
||||
static nfc_device *pnd;
|
||||
|
||||
void stop_dep_communication (int sig)
|
||||
{
|
||||
|
|
@ -62,7 +62,7 @@ void stop_dep_communication (int sig)
|
|||
int
|
||||
main (int argc, const char *argv[])
|
||||
{
|
||||
nfc_target_t nt;
|
||||
nfc_target nt;
|
||||
byte_t abtRx[MAX_FRAME_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
byte_t abtTx[] = "Hello World!";
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
#define MAX_FRAME_LEN 264
|
||||
|
||||
static nfc_device_t *pnd;
|
||||
static nfc_device *pnd;
|
||||
|
||||
void stop_dep_communication (int sig)
|
||||
{
|
||||
|
|
@ -86,7 +86,7 @@ main (int argc, const char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
nfc_target_t nt = {
|
||||
nfc_target nt = {
|
||||
.nm = {
|
||||
.nmt = NMT_DEP,
|
||||
.nbr = NBR_UNDEFINED
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
static byte_t abtRx[MAX_FRAME_LEN];
|
||||
static size_t szRx = sizeof(abtRx);
|
||||
static nfc_device_t *pnd;
|
||||
static nfc_device *pnd;
|
||||
static bool quiet_output = false;
|
||||
static bool init_mfc_auth = false;
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ intr_hdlr (void)
|
|||
}
|
||||
|
||||
bool
|
||||
target_io( nfc_target_t * pnt, const byte_t * pbtInput, const size_t szInput, byte_t * pbtOutput, size_t *pszOutput )
|
||||
target_io( nfc_target * pnt, const byte_t * pbtInput, const size_t szInput, byte_t * pbtOutput, size_t *pszOutput )
|
||||
{
|
||||
bool loop = true;
|
||||
*pszOutput = 0;
|
||||
|
|
@ -134,7 +134,7 @@ target_io( nfc_target_t * pnt, const byte_t * pbtInput, const size_t szInput, by
|
|||
}
|
||||
|
||||
bool
|
||||
nfc_target_emulate_tag(nfc_device_t* pnd, nfc_target_t * pnt)
|
||||
nfc_target_emulate_tag(nfc_device* pnd, nfc_target * pnt)
|
||||
{
|
||||
size_t szTx;
|
||||
byte_t abtTx[MAX_FRAME_LEN];
|
||||
|
|
@ -203,7 +203,7 @@ main (int argc, char *argv[])
|
|||
|
||||
// Example of a Mifare Classic Mini
|
||||
// Note that crypto1 is not implemented in this example
|
||||
nfc_target_t nt = {
|
||||
nfc_target nt = {
|
||||
.nm = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_UNDEFINED,
|
||||
|
|
@ -220,25 +220,37 @@ main (int argc, char *argv[])
|
|||
};
|
||||
/*
|
||||
// Example of a FeliCa
|
||||
nfc_target_t nt = {
|
||||
.nm.nmt = NMT_FELICA,
|
||||
.nm.nbr = NBR_UNDEFINED,
|
||||
.nti.nfi.abtId = { 0x01, 0xFE, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF },
|
||||
.nti.nfi.abtPad = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF },
|
||||
.nti.nfi.abtSysCode = { 0xFF, 0xFF },
|
||||
nfc_target nt = {
|
||||
.nm = {
|
||||
.nmt = NMT_FELICA,
|
||||
.nbr = NBR_UNDEFINED,
|
||||
},
|
||||
.nti = {
|
||||
.nfi = {
|
||||
.abtId = { 0x01, 0xFE, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF },
|
||||
.abtPad = { 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF },
|
||||
.abtSysCode = { 0xFF, 0xFF },
|
||||
},
|
||||
},
|
||||
};
|
||||
*/
|
||||
/*
|
||||
// Example of a ISO14443-4 (DESfire)
|
||||
nfc_target_t nt = {
|
||||
.nm.nmt = NMT_ISO14443A,
|
||||
.nm.nbr = NBR_UNDEFINED,
|
||||
.nti.nai.abtAtqa = { 0x03, 0x44 },
|
||||
.nti.nai.abtUid = { 0x08, 0xab, 0xcd, 0xef },
|
||||
.nti.nai.btSak = 0x20,
|
||||
.nti.nai.szUidLen = 4,
|
||||
.nti.nai.abtAts = { 0x75, 0x77, 0x81, 0x02, 0x80 },
|
||||
.nti.nai.szAtsLen = 5,
|
||||
nfc_target nt = {
|
||||
.nm = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_UNDEFINED,
|
||||
},
|
||||
.nti = {
|
||||
.nai = {
|
||||
abtAtqa = { 0x03, 0x44 },
|
||||
abtUid = { 0x08, 0xab, 0xcd, 0xef },
|
||||
btSak = 0x20,
|
||||
.szUidLen = 4,
|
||||
.abtAts = { 0x75, 0x77, 0x81, 0x02, 0x80 },
|
||||
.szAtsLen = 5,
|
||||
},
|
||||
},
|
||||
};
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
static byte_t abtRecv[MAX_FRAME_LEN];
|
||||
static size_t szRecvBits;
|
||||
static nfc_device_t *pnd;
|
||||
static nfc_device *pnd;
|
||||
|
||||
// ISO14443A Anti-Collision response
|
||||
byte_t abtAtqa[2] = { 0x04, 0x00 };
|
||||
|
|
@ -139,8 +139,8 @@ main (int argc, char *argv[])
|
|||
printf ("[+] To do this, please send any command after the anti-collision\n");
|
||||
printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" or \"nfc-list\" tool.\n");
|
||||
|
||||
// Note: We have to build a "fake" nfc_target_t in order to do exactly the same that was done before the new nfc_target_init() was introduced.
|
||||
nfc_target_t nt = {
|
||||
// Note: We have to build a "fake" nfc_target in order to do exactly the same that was done before the new nfc_target_init() was introduced.
|
||||
nfc_target nt = {
|
||||
.nm = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_UNDEFINED,
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
#define MAX_DEVICE_COUNT 16
|
||||
|
||||
static nfc_device_t *pnd = NULL;
|
||||
static nfc_device *pnd = NULL;
|
||||
|
||||
void stop_polling (int sig)
|
||||
{
|
||||
|
|
@ -80,7 +80,7 @@ main (int argc, const char *argv[])
|
|||
|
||||
const uint8_t uiPollNr = 20;
|
||||
const uint8_t uiPeriod = 2;
|
||||
const nfc_modulation_t nmModulations[5] = {
|
||||
const nfc_modulation nmModulations[5] = {
|
||||
{ .nmt = NMT_ISO14443A, .nbr = NBR_106 },
|
||||
{ .nmt = NMT_ISO14443B, .nbr = NBR_106 },
|
||||
{ .nmt = NMT_FELICA, .nbr = NBR_212 },
|
||||
|
|
@ -89,7 +89,7 @@ main (int argc, const char *argv[])
|
|||
};
|
||||
const size_t szModulations = 5;
|
||||
|
||||
nfc_target_t nt;
|
||||
nfc_target nt;
|
||||
bool res;
|
||||
|
||||
pnd = nfc_connect (NULL);
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ static size_t szReaderRxBits;
|
|||
static byte_t abtTagRx[MAX_FRAME_LEN];
|
||||
static byte_t abtTagRxPar[MAX_FRAME_LEN];
|
||||
static size_t szTagRxBits;
|
||||
static nfc_device_t *pndReader;
|
||||
static nfc_device_t *pndTag;
|
||||
static nfc_device *pndReader;
|
||||
static nfc_device *pndTag;
|
||||
static bool quitting = false;
|
||||
|
||||
void
|
||||
|
|
@ -130,7 +130,7 @@ main (int argc, char *argv[])
|
|||
printf ("[+] To do this, please send any command after the anti-collision\n");
|
||||
printf ("[+] For example, send a RATS command or use the \"nfc-anticol\" tool\n");
|
||||
|
||||
nfc_target_t nt = {
|
||||
nfc_target nt = {
|
||||
.nm = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_UNDEFINED,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ main (int argc, const char *argv[])
|
|||
{
|
||||
size_t szFound;
|
||||
size_t i;
|
||||
nfc_device_t *pnd;
|
||||
nfc_device *pnd;
|
||||
const char *acLibnfcVersion;
|
||||
bool result;
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ wait_one_minute ()
|
|||
int
|
||||
main (int argc, const char *argv[])
|
||||
{
|
||||
nfc_device_t *pnd;
|
||||
nfc_device *pnd;
|
||||
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
|
@ -125,7 +125,7 @@ main (int argc, const char *argv[])
|
|||
|
||||
case PSM_WIRED_CARD:
|
||||
{
|
||||
nfc_target_t nt;
|
||||
nfc_target nt;
|
||||
|
||||
// Set connected NFC device to initiator mode
|
||||
nfc_initiator_init (pnd);
|
||||
|
|
@ -136,7 +136,7 @@ main (int argc, const char *argv[])
|
|||
exit (EXIT_FAILURE);
|
||||
}
|
||||
// Read the SAM's info
|
||||
const nfc_modulation_t nmSAM = {
|
||||
const nfc_modulation nmSAM = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_106,
|
||||
};
|
||||
|
|
@ -156,7 +156,7 @@ main (int argc, const char *argv[])
|
|||
byte_t abtRx[MAX_FRAME_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
|
||||
nfc_target_t nt = {
|
||||
nfc_target nt = {
|
||||
.nm = {
|
||||
.nmt = NMT_ISO14443A,
|
||||
.nbr = NBR_UNDEFINED,
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
nfc_device_t* pnd;
|
||||
nfc_device* pnd;
|
||||
byte_t abtRx[MAX_FRAME_LEN];
|
||||
byte_t abtTx[MAX_FRAME_LEN];
|
||||
size_t szRx = sizeof(abtRx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue