+// EMV Book 3
+static void emv_tag_dump_cid(const struct tlv *tlv, const struct emv_tag *tag, FILE *f, int level) {
+ if (!tlv || tlv->len < 1) {
+ PRINT_INDENT(level);
+ fprintf(f, "\tINVALID!\n");
+ return;
+ }
+
+ PRINT_INDENT(level);
+ if ((tlv->value[0] & EMVAC_AC_MASK) == EMVAC_AAC) fprintf(f, "\tAC1: AAC (Transaction declined)\n");
+ if ((tlv->value[0] & EMVAC_AC_MASK) == EMVAC_TC) fprintf(f, "\tAC1: TC (Transaction approved)\n");
+ if ((tlv->value[0] & EMVAC_AC_MASK) == EMVAC_ARQC) fprintf(f, "\tAC1: ARQC (Online authorisation requested)\n");
+ if ((tlv->value[0] & EMVAC_AC_MASK) == EMVAC_AC_MASK) fprintf(f, "\tAC1: RFU\n");
+
+ if (tlv->value[0] & EMVCID_ADVICE) {
+ PRINT_INDENT(level);
+ fprintf(f, "\tAdvice required!\n");
+ }
+
+ if (tlv->value[0] & EMVCID_REASON_MASK) {
+ PRINT_INDENT(level);
+ fprintf(f, "\tReason/advice/referral code: ");
+ switch((tlv->value[0] & EMVCID_REASON_MASK)) {
+ case 0:
+ fprintf(f, "No information given\n");
+ break;
+ case 1:
+ fprintf(f, "Service not allowed\n");
+ break;
+ case 2:
+ fprintf(f, "PIN Try Limit exceeded\n");
+ break;
+ case 3:
+ fprintf(f, "Issuer authentication failed\n");
+ break;
+ default:
+ fprintf(f, "\tRFU: %2x\n", (tlv->value[0] & EMVCID_REASON_MASK));
+ break;
+ }
+ }
+
+ return;
+}
+