41 #endif // HAVE_CONFIG_H
55 #define MAX_FRAME_LEN (264)
56 #define SAK_ISO14443_4_COMPLIANT 0x20
58 static byte_t abtRx[MAX_FRAME_LEN];
61 static bool quiet_output =
false;
62 static bool init_mfc_auth =
false;
67 printf (
"\nQuitting...\n");
75 target_io(
nfc_target_t * pnt,
const byte_t * pbtInput,
const size_t szInput, byte_t * pbtOutput,
size_t *pszOutput )
83 print_hex (pbtInput, szInput);
90 strcpy((
char*)pbtOutput,
"You read block ");
91 pbtOutput[15] = pbtInput[1];
95 printf(
"Target halted me. Bye!\n");
106 init_mfc_auth =
true;
110 *pszOutput = pnt->nti.nai.szAtsLen + 1;
111 pbtOutput[0] = pnt->nti.nai.szAtsLen + 1;
112 if(pnt->nti.nai.szAtsLen) {
113 memcpy(pbtOutput+1, pnt->nti.nai.abtAts, pnt->nti.nai.szAtsLen);
118 printf(
"Target released me. Bye!\n");
124 printf(
"Unknown frame, emulated target abort.\n");
130 if ((!quiet_output) && *pszOutput) {
132 print_hex (pbtOutput, *pszOutput);
141 byte_t abtTx[MAX_FRAME_LEN];
150 loop = target_io( pnt, abtRx, szRx, abtTx, &szTx );
158 if ( init_mfc_auth ) {
160 init_mfc_auth =
false;
172 main (
int argc,
char *argv[])
174 const char *acLibnfcVersion;
177 signal (SIGINT, (
void (__cdecl *) (
int)) intr_hdlr);
179 signal (SIGINT, (
void (*)()) intr_hdlr);
187 printf (
"%s use libnfc %s\n", argv[0], acLibnfcVersion);
190 ERR(
"Unable to connect to NFC device");
194 printf (
"Connected to NFC device: %s\n", pnd->
acName);
207 .nm.nmt = NMT_ISO14443A,
208 .nm.nbr = NBR_UNDEFINED,
209 .nti.nai.abtAtqa = { 0x00, 0x04 },
210 .nti.nai.abtUid = { 0x08, 0xab, 0xcd, 0xef },
211 .nti.nai.btSak = 0x09,
212 .nti.nai.szUidLen = 4,
213 .nti.nai.szAtsLen = 0,
239 printf (
"%s will emulate this ISO14443-A tag:\n", argv[0]);
240 print_nfc_iso14443a_info (nt.nti.nai,
true);
244 printf (
"NFC device (configured as target) is now emulating the tag, please touch it with a second NFC device (initiator)\n");
245 if (!nfc_target_emulate_tag (pnd, &nt)) {