47 #endif // HAVE_CONFIG_H
60 #define MAX_FRAME_LEN (264)
61 #define SAK_ISO14443_4_COMPLIANT 0x20
63 static uint8_t abtRx[MAX_FRAME_LEN];
67 static bool quiet_output =
false;
68 static bool init_mfc_auth =
false;
74 printf(
"\nQuitting...\n");
84 target_io(
nfc_target *pnt,
const uint8_t *pbtInput,
const size_t szInput, uint8_t *pbtOutput,
size_t *pszOutput)
92 print_hex(pbtInput, szInput);
95 switch (pbtInput[0]) {
99 strcpy((
char *)pbtOutput,
"You read block ");
100 pbtOutput[15] = pbtInput[1];
104 printf(
"Initiator HLTA me. Bye!\n");
115 init_mfc_auth =
true;
119 *pszOutput = pnt->nti.nai.szAtsLen + 1;
120 pbtOutput[0] = pnt->nti.nai.szAtsLen + 1;
121 if (pnt->nti.nai.szAtsLen) {
122 memcpy(pbtOutput + 1, pnt->nti.nai.abtAts, pnt->nti.nai.szAtsLen);
127 printf(
"Initiator DESELECT me. Bye!\n");
133 printf(
"Unknown frame, emulated target abort.\n");
139 if ((!quiet_output) && *pszOutput) {
141 print_hex(pbtOutput, *pszOutput);
150 uint8_t abtTx[MAX_FRAME_LEN];
159 loop = target_io(pnt, abtRx, (
size_t) szRx, abtTx, &szTx);
169 init_mfc_auth =
false;
181 main(
int argc,
char *argv[])
184 const char *acLibnfcVersion;
187 signal(SIGINT, (
void (__cdecl *)(
int)) intr_hdlr);
189 signal(SIGINT, intr_hdlr);
193 if (context == NULL) {
194 ERR(
"Unable to init libnfc (malloc)");
200 printf(
"%s uses libnfc %s\n", argv[0], acLibnfcVersion);
206 ERR(
"Unable to open NFC device");
225 .nmt = NMT_ISO14443A,
226 .nbr = NBR_UNDEFINED,
230 .abtAtqa = { 0x00, 0x04 },
231 .abtUid = { 0x08, 0xab, 0xcd, 0xef },
274 printf(
"%s will emulate this ISO14443-A tag:\n", argv[0]);
275 print_nfc_target(&nt,
true);
279 printf(
"NFC device (configured as target) is now emulating the tag, please touch it with a second NFC device (initiator)\n");
280 if (!nfc_target_emulate_tag(pnd, &nt)) {