48 #endif // HAVE_CONFIG_H
61 #define MAX_FRAME_LEN (264)
62 #define SAK_ISO14443_4_COMPLIANT 0x20
64 static uint8_t abtRx[MAX_FRAME_LEN];
68 static bool quiet_output =
false;
69 static bool init_mfc_auth =
false;
75 printf(
"\nQuitting...\n");
85 target_io(
nfc_target *pnt,
const uint8_t *pbtInput,
const size_t szInput, uint8_t *pbtOutput,
size_t *pszOutput)
93 print_hex(pbtInput, szInput);
96 switch (pbtInput[0]) {
100 strcpy((
char *)pbtOutput,
"You read block ");
101 pbtOutput[15] = pbtInput[1];
105 printf(
"Initiator HLTA me. Bye!\n");
116 init_mfc_auth =
true;
120 *pszOutput = pnt->nti.nai.szAtsLen + 1;
121 pbtOutput[0] = pnt->nti.nai.szAtsLen + 1;
122 if (pnt->nti.nai.szAtsLen) {
123 memcpy(pbtOutput + 1, pnt->nti.nai.abtAts, pnt->nti.nai.szAtsLen);
128 printf(
"Initiator DESELECT me. Bye!\n");
134 printf(
"Unknown frame, emulated target abort.\n");
140 if ((!quiet_output) && *pszOutput) {
142 print_hex(pbtOutput, *pszOutput);
151 uint8_t abtTx[MAX_FRAME_LEN];
160 loop = target_io(pnt, abtRx, (
size_t) szRx, abtTx, &szTx);
175 init_mfc_auth =
false;
187 main(
int argc,
char *argv[])
190 const char *acLibnfcVersion;
193 signal(SIGINT, (
void (__cdecl *)(
int)) intr_hdlr);
195 signal(SIGINT, intr_hdlr);
199 if (context == NULL) {
200 ERR(
"Unable to init libnfc (malloc)");
206 printf(
"%s uses libnfc %s\n", argv[0], acLibnfcVersion);
212 ERR(
"Unable to open NFC device");
231 .nmt = NMT_ISO14443A,
232 .nbr = NBR_UNDEFINED,
236 .abtAtqa = { 0x00, 0x04 },
237 .abtUid = { 0x08, 0xab, 0xcd, 0xef },
280 printf(
"%s will emulate this ISO14443-A tag:\n", argv[0]);
281 print_nfc_target(&nt,
true);
290 printf(
"NFC device (configured as target) is now emulating the tag, please touch it with a second NFC device (initiator)\n");
291 if (!nfc_target_emulate_tag(pnd, &nt)) {