Rename tag_info to nfc_target_info_t.
Rename init_modulation to nfc_modulation_t.
This commit is contained in:
parent
2feedddbfe
commit
483c69dd03
7 changed files with 117 additions and 117 deletions
|
|
@ -37,7 +37,7 @@ static byte_t abtFelica[5] = { 0x00, 0xff, 0xff, 0x00, 0x00 };
|
|||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
tag_info ti;
|
||||
nfc_target_info_t nti;
|
||||
|
||||
// Try to open the NFC device
|
||||
pnd = nfc_connect(NULL);
|
||||
|
|
@ -75,43 +75,43 @@ int main(int argc, const char* argv[])
|
|||
printf("Connected to NFC reader: %s\n\n",pnd->acName);
|
||||
|
||||
// Poll for a ISO14443A (MIFARE) tag
|
||||
if (nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
|
||||
if (nfc_initiator_select_tag(pnd,NM_ISO14443A_106,NULL,0,&nti))
|
||||
{
|
||||
printf("The following (NFC) ISO14443A tag was found:\n\n");
|
||||
printf(" ATQA (SENS_RES): "); print_hex(ti.tia.abtAtqa,2);
|
||||
printf(" UID (NFCID%c): ",(ti.tia.abtUid[0]==0x08?'3':'1')); print_hex(ti.tia.abtUid,ti.tia.szUidLen);
|
||||
printf(" SAK (SEL_RES): "); print_hex(&ti.tia.btSak,1);
|
||||
if (ti.tia.szAtsLen)
|
||||
printf(" ATQA (SENS_RES): "); print_hex(nti.nai.abtAtqa,2);
|
||||
printf(" UID (NFCID%c): ",(nti.nai.abtUid[0]==0x08?'3':'1')); print_hex(nti.nai.abtUid,nti.nai.szUidLen);
|
||||
printf(" SAK (SEL_RES): "); print_hex(&nti.nai.btSak,1);
|
||||
if (nti.nai.szAtsLen)
|
||||
{
|
||||
printf(" ATS (ATR): ");
|
||||
print_hex(ti.tia.abtAts,ti.tia.szAtsLen);
|
||||
print_hex(nti.nai.abtAts,nti.nai.szAtsLen);
|
||||
}
|
||||
}
|
||||
|
||||
// Poll for a Felica tag
|
||||
if (nfc_initiator_select_tag(pnd,IM_FELICA_212,abtFelica,5,&ti) || nfc_initiator_select_tag(pnd,IM_FELICA_424,abtFelica,5,&ti))
|
||||
if (nfc_initiator_select_tag(pnd,NM_FELICA_212,abtFelica,5,&nti) || nfc_initiator_select_tag(pnd,NM_FELICA_424,abtFelica,5,&nti))
|
||||
{
|
||||
printf("The following (NFC) Felica tag was found:\n\n");
|
||||
printf("%18s","ID (NFCID2): "); print_hex(ti.tif.abtId,8);
|
||||
printf("%18s","Parameter (PAD): "); print_hex(ti.tif.abtPad,8);
|
||||
printf("%18s","ID (NFCID2): "); print_hex(nti.nfi.abtId,8);
|
||||
printf("%18s","Parameter (PAD): "); print_hex(nti.nfi.abtPad,8);
|
||||
}
|
||||
|
||||
// Poll for a ISO14443B tag
|
||||
if (nfc_initiator_select_tag(pnd,IM_ISO14443B_106,(byte_t*)"\x00",1,&ti))
|
||||
if (nfc_initiator_select_tag(pnd,NM_ISO14443B_106,(byte_t*)"\x00",1,&nti))
|
||||
{
|
||||
printf("The following (NFC) ISO14443-B tag was found:\n\n");
|
||||
printf(" ATQB: "); print_hex(ti.tib.abtAtqb,12);
|
||||
printf(" ID: "); print_hex(ti.tib.abtId,4);
|
||||
printf(" CID: %02x\n",ti.tib.btCid);
|
||||
if (ti.tib.szInfLen>0)
|
||||
printf(" ATQB: "); print_hex(nti.nbi.abtAtqb,12);
|
||||
printf(" ID: "); print_hex(nti.nbi.abtId,4);
|
||||
printf(" CID: %02x\n",nti.nbi.btCid);
|
||||
if (nti.nbi.szInfLen>0)
|
||||
{
|
||||
printf(" INF: "); print_hex(ti.tib.abtInf,ti.tib.szInfLen);
|
||||
printf(" INF: "); print_hex(nti.nbi.abtInf,nti.nbi.szInfLen);
|
||||
}
|
||||
printf("PARAMS: %02x %02x %02x %02x\n",ti.tib.btParam1,ti.tib.btParam2,ti.tib.btParam3,ti.tib.btParam4);
|
||||
printf("PARAMS: %02x %02x %02x %02x\n",nti.nbi.btParam1,nti.nbi.btParam2,nti.nbi.btParam3,nti.nbi.btParam4);
|
||||
}
|
||||
|
||||
// Poll for a Jewel tag
|
||||
if (nfc_initiator_select_tag(pnd,IM_JEWEL_106,NULL,0,&ti))
|
||||
if (nfc_initiator_select_tag(pnd,NM_JEWEL_106,NULL,0,&nti))
|
||||
{
|
||||
// No test results yet
|
||||
printf("jewel\n");
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include "bitutils.h"
|
||||
|
||||
static nfc_device_t* pnd;
|
||||
static tag_info ti;
|
||||
static nfc_target_info_t nti;
|
||||
static mifare_param mp;
|
||||
static mifare_tag mtKeys;
|
||||
static mifare_tag mtDump;
|
||||
|
|
@ -89,7 +89,7 @@ bool authenticate(uint32_t uiBlock)
|
|||
if (bUseKeyFile)
|
||||
{
|
||||
// Set the authentication information (uid)
|
||||
memcpy(mp.mpa.abtUid,ti.tia.abtUid,4);
|
||||
memcpy(mp.mpa.abtUid,nti.nai.abtUid,4);
|
||||
|
||||
// Locate the trailer (with the keys) used for this sector
|
||||
uiTrailerBlock = get_trailer_block(uiBlock);
|
||||
|
|
@ -116,7 +116,7 @@ bool authenticate(uint32_t uiBlock)
|
|||
mc = (bUseKeyA) ? MC_AUTH_A : MC_AUTH_B;
|
||||
|
||||
// Set the authentication information (uid)
|
||||
memcpy(mp.mpa.abtUid,ti.tia.abtUid,4);
|
||||
memcpy(mp.mpa.abtUid,nti.nai.abtUid,4);
|
||||
|
||||
for (key_index = 0; key_index < num_keys; key_index++)
|
||||
{
|
||||
|
|
@ -134,7 +134,7 @@ bool authenticate(uint32_t uiBlock)
|
|||
return true;
|
||||
}
|
||||
|
||||
nfc_initiator_select_tag(pnd, IM_ISO14443A_106, mp.mpa.abtUid, 4, NULL);
|
||||
nfc_initiator_select_tag(pnd, NM_ISO14443A_106, mp.mpa.abtUid, 4, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ bool read_card()
|
|||
{
|
||||
printf("x");
|
||||
// When a failure occured we need to redo the anti-collision
|
||||
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
|
||||
if (!nfc_initiator_select_tag(pnd,NM_ISO14443A_106,NULL,0,&nti))
|
||||
{
|
||||
printf("!\nError: tag was removed\n");
|
||||
return 1;
|
||||
|
|
@ -227,7 +227,7 @@ bool write_card()
|
|||
{
|
||||
printf("x");
|
||||
// When a failure occured we need to redo the anti-collision
|
||||
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
|
||||
if (!nfc_initiator_select_tag(pnd,NM_ISO14443A_106,NULL,0,&nti))
|
||||
{
|
||||
printf("!\nError: tag was removed\n");
|
||||
return false;
|
||||
|
|
@ -427,7 +427,7 @@ int main(int argc, const char* argv[])
|
|||
printf("Connected to NFC reader: %s\n",pnd->acName);
|
||||
|
||||
// Try to find a MIFARE Classic tag
|
||||
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
|
||||
if (!nfc_initiator_select_tag(pnd,NM_ISO14443A_106,NULL,0,&nti))
|
||||
{
|
||||
printf("Error: no tag was found\n");
|
||||
nfc_disconnect(pnd);
|
||||
|
|
@ -435,7 +435,7 @@ int main(int argc, const char* argv[])
|
|||
}
|
||||
|
||||
// Test if we are dealing with a MIFARE compatible tag
|
||||
if ((ti.tia.btSak & 0x08) == 0)
|
||||
if ((nti.nai.btSak & 0x08) == 0)
|
||||
{
|
||||
printf("Error: tag is not a MIFARE Classic card\n");
|
||||
nfc_disconnect(pnd);
|
||||
|
|
@ -449,15 +449,15 @@ int main(int argc, const char* argv[])
|
|||
pbtUID = mtKeys.amb[0].mbm.abtUID;
|
||||
|
||||
// Compare if key dump UID is the same as the current tag UID
|
||||
if (memcmp(ti.tia.abtUid,pbtUID,4) != 0)
|
||||
if (memcmp(nti.nai.abtUid,pbtUID,4) != 0)
|
||||
{
|
||||
printf("Expected MIFARE Classic %cK card with UID: %08x\n",b4K?'4':'1',swap_endian32(pbtUID));
|
||||
}
|
||||
}
|
||||
|
||||
// Get the info from the current tag
|
||||
pbtUID = ti.tia.abtUid;
|
||||
b4K = (ti.tia.abtAtqa[1] == 0x02);
|
||||
pbtUID = nti.nai.abtUid;
|
||||
b4K = (nti.nai.abtAtqa[1] == 0x02);
|
||||
printf("Found MIFARE Classic %cK card with UID: %08x\n",b4K?'4':'1',swap_endian32(pbtUID));
|
||||
|
||||
uiBlocks = (b4K)?0xff:0x3f;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include "bitutils.h"
|
||||
|
||||
static nfc_device_t* pnd;
|
||||
static tag_info ti;
|
||||
static nfc_target_info_t nti;
|
||||
static mifare_param mp;
|
||||
static mifareul_tag mtDump;
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ bool write_card()
|
|||
{
|
||||
printf("x");
|
||||
// When a failure occured we need to redo the anti-collision
|
||||
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
|
||||
if (!nfc_initiator_select_tag(pnd,NM_ISO14443A_106,NULL,0,&nti))
|
||||
{
|
||||
printf("!\nError: tag was removed\n");
|
||||
return false;
|
||||
|
|
@ -171,7 +171,7 @@ int main(int argc, const char* argv[])
|
|||
printf("Connected to NFC reader: %s\n",pnd->acName);
|
||||
|
||||
// Try to find a MIFARE Ultralight tag
|
||||
if (!nfc_initiator_select_tag(pnd,IM_ISO14443A_106,NULL,0,&ti))
|
||||
if (!nfc_initiator_select_tag(pnd,NM_ISO14443A_106,NULL,0,&nti))
|
||||
{
|
||||
printf("Error: no tag was found\n");
|
||||
nfc_disconnect(pnd);
|
||||
|
|
@ -180,7 +180,7 @@ int main(int argc, const char* argv[])
|
|||
|
||||
// Test if we are dealing with a MIFARE compatible tag
|
||||
|
||||
if (ti.tia.abtAtqa[1] != 0x44){
|
||||
if (nti.nai.abtAtqa[1] != 0x44){
|
||||
printf("Error: tag is not a MIFARE Ultralight card\n");
|
||||
nfc_disconnect(pnd);
|
||||
return 1;
|
||||
|
|
@ -188,7 +188,7 @@ int main(int argc, const char* argv[])
|
|||
|
||||
|
||||
// Get the info from the current tag
|
||||
pbtUID = ti.tia.abtUid;
|
||||
pbtUID = nti.nai.abtUid;
|
||||
printf("Found MIFARE Ultralight card with uid: %08x\n", swap_endian32(pbtUID));
|
||||
|
||||
if (bReadAction)
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@
|
|||
int main(int argc, const char *argv[])
|
||||
{
|
||||
nfc_device_t *pnd;
|
||||
tag_info ti;
|
||||
nfc_target_info_t ti;
|
||||
byte_t abtRecv[MAX_FRAME_LEN];
|
||||
size_t szRecvBits;
|
||||
byte_t send[] = "Hello World!";
|
||||
|
||||
pnd = nfc_connect(NULL);
|
||||
if (!pnd || !nfc_initiator_init(pnd)
|
||||
|| !nfc_initiator_select_dep_target(pnd, IM_PASSIVE_DEP, NULL, 0,
|
||||
|| !nfc_initiator_select_dep_target(pnd, NM_PASSIVE_DEP, NULL, 0,
|
||||
NULL, 0, NULL, 0, &ti)) {
|
||||
printf
|
||||
("unable to connect, initialize, or select the target\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue