AT-NFC 2.1 (win) AT-NFC kernel set

nfc_outcome.h
Go to the documentation of this file.
1 #ifndef NFC_OUTCOME_H
2 #define NFC_OUTCOME_H
3
4 /* ***************************** NFC Outcome data definitions ****************************** */
8 /* ***************************************************************************************** */
9
10 /* set struct alignment */
11 #include <emv_platform_set_align.h>
12
13 /* ***************************************************************************************** */
18 /* ***************************************************************************************** */
19
20 /* ***************************************************************************************** */
21 /* outcome ui message id (Book A, paragraph 9.4, p.86) */
28 #define NFC_OUTCOME_UI_MSG_NA 0xFF
29 #define NFC_OUTCOME_UI_MSG_APPROVED 0x03
30 #define NFC_OUTCOME_UI_MSG_NOT_AUTHORISED 0x07
31 #define NFC_OUTCOME_UI_MSG_ENTER_PIN 0x09
32 #define NFC_OUTCOME_UI_MSG_PROCESSING_ERROR 0x0F
33 #define NFC_OUTCOME_UI_MSG_REMOVE_CARD 0x10
34 #define NFC_OUTCOME_UI_MSG_WELCOME 0x14
35 #define NFC_OUTCOME_UI_MSG_PRESENT_CARD 0x15
36 #define NFC_OUTCOME_UI_MSG_PROCESSING 0x16
37 #define NFC_OUTCOME_UI_MSG_CARD_READ_OK_REMOVE_CARD 0x17
38 #define NFC_OUTCOME_UI_MSG_INSERT_OR_SWIPE_CARD 0x18
39 #define NFC_OUTCOME_UI_MSG_PRESENT_ONE_CARD_ONLY 0x19
40 #define NFC_OUTCOME_UI_MSG_APPROVED_SIGN 0x1A
41 #define NFC_OUTCOME_UI_MSG_AUTHORISATION_WAIT 0x1B
42 #define NFC_OUTCOME_UI_MSG_INSERT_OR_SWIPE_OR_TRY_ANOTHER 0x1C
43 #define NFC_OUTCOME_UI_MSG_INSERT_CARD 0x1D
44 #define NFC_OUTCOME_UI_MSG_BLANK 0x1E
45 #define NFC_OUTCOME_UI_MSG_SEE_PHONE_INSTRUCTIONS 0x20
46 #define NFC_OUTCOME_UI_MSG_PRESENT_CARD_AGAIN 0x21
47 /* custom defined - absent in EMV Book A */
48 #define NFC_OUTCOME_UI_MSG_EXPIRED_ONLINE 0xA0
49 #define NFC_OUTCOME_UI_MSG_EXPIRED_DECLINE 0xA1
51 /* ***************************************************************************************** */
52
53 /* ***************************************************************************************** */
54 /* outcome ui status types (Book A, paragraph 9.3, p.76) */
61 #define NFC_OUTCOME_UI_NA 0x00
62 #define NFC_OUTCOME_UI_NOT_READY 0x01
63 #define NFC_OUTCOME_UI_IDLE 0x02
64 #define NFC_OUTCOME_UI_READY_TO_READ 0x03
65 #define NFC_OUTCOME_UI_PROCESSING 0x04
66 #define NFC_OUTCOME_UI_CARD_READ_SUCCESS 0x05
67 #define NFC_OUTCOME_UI_ERROR_PROCESSING 0x06
69 /* ***************************************************************************************** */
70
71 /* ***************************************************************************************** */
72 /* UI request struct value qualifiers */
79 #define NFC_OUTCOME_UI_VALUE_NA 0x00
80 #define NFC_OUTCOME_UI_VALUE_AMOUNT 0x01
81 #define NFC_OUTCOME_UI_VALUE_BALANCE 0x02
83 /* ***************************************************************************************** */
84
85 /* ***************************************************************************************** */
86 /* UI request struct version ID */
93 #define NFC_OUTCOME_UI_VERSION_0 0x00
94 #define NFC_OUTCOME_UI_VERSION 0x01
96 /* ***************************************************************************************** */
97
98 /* ***************************************************************************************** */
99 /* reset UI macro */
104 #define NFC_OUTCOME_UI_RESET(UI, SIZE) \
105 do \
106 { \
107 KER_MEM_SET(UI, SIZE, 0, SIZE); \
108 (UI)->usSize = SIZE; \
109 (UI)->btVersion = NFC_OUTCOME_UI_VERSION; \
110 (UI)->btMessageID = NFC_OUTCOME_UI_MSG_NA; \
111 (UI)->btStatus = NFC_OUTCOME_UI_NA; \
112 } while (0)
113
114 /* ***************************************************************************************** */
115 /* Set UI lang pref macro */
120 #define NFC_OUTCOME_UI_SET_LANG_PREF(UI, TRAN_DATA) \
121 do \
122 { \
123 if (((TRAN_DATA) != KER_NULL) && ((TRAN_DATA)->btLangPrefLen > 0)) \
124 { \
125 (UI)->btLangPrefLen = ((TRAN_DATA)->btLangPrefLen <= sizeof((UI)->ar_btLangPref)) ? (TRAN_DATA)->btLangPrefLen : sizeof((UI)->ar_btLangPref); \
126 KER_MEM_CPY((UI)->ar_btLangPref, sizeof((UI)->ar_btLangPref), (TRAN_DATA)->ar_btLangPref, (UI)->btLangPrefLen); \
127 } \
128 } while (0)
129
130 /* ***************************************************************************************** */
131 /* Init UI with lang pref macro */
136 #define NFC_OUTCOME_UI_INIT(UI, SIZE, TRAN_DATA) \
137 do \
138 { \
139 NFC_OUTCOME_UI_RESET((UI), (SIZE)); \
140 NFC_OUTCOME_UI_SET_LANG_PREF((UI), (TRAN_DATA)); \
141 } while (0)
142
143
144 /* ***************************************************************************************** */
151 typedef struct tag_NFC_OUTCOME_UI
152 {
153 KER_INT16U usSize;
154 KER_INT16U btVersion;
156 KER_BYTE btMessageID;
157 KER_BYTE btStatus;
158 KER_INT32U ulHoldTime;
160 KER_BYTE ar_btCurrCode[2];
161 KER_BYTE btValueQualifier;
162 KER_BYTE btValueLen;
163 KER_BYTE ar_btValue[6];
165 KER_BYTE ar_btLangPref[8];
166 KER_BYTE btLangPrefLen;
167 } NFC_OUTCOME_UI;
170 /* ***************************************************************************************** */
171 /* outcome types */
178 #define NFC_OUTCOME_TYPE_NA 0x00
179 #define NFC_OUTCOME_TYPE_SELECT_NEXT 0x01
180 #define NFC_OUTCOME_TYPE_TRY_AGAIN 0x02
181 #define NFC_OUTCOME_TYPE_TRY_ANOTHER_INTERFACE 0x03
182 #define NFC_OUTCOME_TYPE_APPROVED 0x11
183 #define NFC_OUTCOME_TYPE_DECLINED 0x12
184 #define NFC_OUTCOME_TYPE_ONLINE_REQUEST 0x21
185 #define NFC_OUTCOME_TYPE_ONLINE_PIN 0x22
186 #define NFC_OUTCOME_TYPE_END_APPLICATION 0xF1
187 #define NFC_OUTCOME_TYPE_CUSTOM 0xFA
189 /* ***************************************************************************************** */
190
191 /* ***************************************************************************************** */
192 /* outcome expected cvm */
199 #define NFC_OUTCOME_CVM_NA 0x00
200 #define NFC_OUTCOME_CVM_NO_CVM 0x1F
201 #define NFC_OUTCOME_CVM_ONLINE_PIN 0x02
202 #define NFC_OUTCOME_CVM_CD_CVM 0x20
203 #define NFC_OUTCOME_CVM_SIGNATURE 0x1E
204 #define NFC_OUTCOME_CVM_CUSTOM 0xFF
206 /* ***************************************************************************************** */
207
208 /* ***************************************************************************************** */
209 /* outcome options */
216 #define NFC_OUTCOME_OPT_UI 0x0001
217 #define NFC_OUTCOME_OPT_UI_RESTART 0x0002
218 #define NFC_OUTCOME_OPT_DATA_RECORD 0x0004
219 #define NFC_OUTCOME_OPT_DISCRETIONARY_DATA 0x0008
220 #define NFC_OUTCOME_OPT_RECEIPT 0x0010
221 #define NFC_OUTCOME_OPT_FIELD_OFF_REQUEST 0x0020
223 /* ***************************************************************************************** */
224
225 /* ***************************************************************************************** */
226 /* start types */
233 #define NFC_OUTCOME_START_TYPE_NA 0x00
234 #define NFC_OUTCOME_START_TYPE_A 0x01
235 #define NFC_OUTCOME_START_TYPE_B 0x02
236 #define NFC_OUTCOME_START_TYPE_C 0x03
237 #define NFC_OUTCOME_START_TYPE_D 0x04
239 /* ***************************************************************************************** */
240
241 /* ***************************************************************************************** */
242 /* online response */
249 #define NFC_OUTCOME_RESPONSE_NA 0x00
250 #define NFC_OUTCOME_RESPONSE_EMV_DATA 0x01
251 #define NFC_OUTCOME_RESPONSE_ANY 0x02
253 /* ***************************************************************************************** */
254
255 /* ***************************************************************************************** */
256 /* alt interface */
263 #define NFC_OUTCOME_ALT_NA 0x00
264 #define NFC_OUTCOME_ALT_MASK_CHIP 0x01
265 #define NFC_OUTCOME_ALT_MASK_MS 0x02
267 /* ***************************************************************************************** */
268
269 /* ***************************************************************************************** */
270 /* indicators */
277 #define NFC_OUTCOME_IND_MS_MODE 0x01
278 #define NFC_OUTCOME_IND_EMV_MODE 0x02
279 #define NFC_OUTCOME_IND_CD_CVM_REQUESTED 0x04
280 #define NFC_OUTCOME_IND_EMPTY_CL 0x08
281 #define NFC_OUTCOME_IND_APDU_RRP_TIMEOUT 0x10
282 #define NFC_OUTCOME_IND_MAND_CPLC_MISSED 0x20
284 /* ***************************************************************************************** */
285
286 /* ***************************************************************************************** */
287 /* Outcome struct version ID */
294 #define NFC_OUTCOME_VERSION_0 0x00
295 #define NFC_OUTCOME_VERSION 0x01
297 /* ***************************************************************************************** */
298
299 /* ***************************************************************************************** */
300 /* reset Outcome macro */
305 #define NFC_OUTCOME_RESET(DATA, SIZE) \
306 do \
307 { \
308 KER_MEM_SET(DATA, SIZE, 0, SIZE); \
309 (DATA)->usSize = SIZE; \
310 (DATA)->btVersion = NFC_OUTCOME_VERSION; \
311 (DATA)->btOutcomeType = NFC_OUTCOME_TYPE_NA; \
312 (DATA)->btStart = NFC_OUTCOME_START_TYPE_NA; \
313 (DATA)->btOnlineResponse = NFC_OUTCOME_RESPONSE_NA; \
314 (DATA)->btCVM = NFC_OUTCOME_CVM_NA; \
315 (DATA)->btAltInterfacePreference = NFC_OUTCOME_ALT_NA; \
316 NFC_OUTCOME_UI_RESET(&(DATA)->UI, sizeof((DATA)->UI)); \
317 NFC_OUTCOME_UI_RESET(&(DATA)->UIRestart, sizeof((DATA)->UIRestart)); \
318 } while (0)
319
320 /* ***************************************************************************************** */
321 /* init Outcome macro (with UI lang pref) */
326 #define NFC_OUTCOME_INIT(DATA, SIZE, TRAN_DATA) \
327 do \
328 { \
329 NFC_OUTCOME_RESET((DATA), (SIZE)); \
330 NFC_OUTCOME_UI_INIT(&(DATA)->UI, sizeof((DATA)->UI), (TRAN_DATA)); \
331 NFC_OUTCOME_UI_INIT(&(DATA)->UIRestart, sizeof((DATA)->UIRestart), (TRAN_DATA)); \
332 } while (0)
333
334 /* ***************************************************************************************** */
335 /* Check Outcome macro */
340 #define NFC_OUTCOME_CHECK(OUTCOME, MIN_SIZE, MIN_VER) (((OUTCOME) != KER_NULL) && ((OUTCOME)->usSize >= (MIN_SIZE)) && ((OUTCOME)->btVersion >= (MIN_VER)))
341
342 /* ***************************************************************************************** */
349 typedef struct tag_NFC_OUTCOME
350 {
351 KER_INT16U usSize;
352 KER_BYTE btVersion;
354 KER_BYTE btOutcomeType;
355 KER_BYTE btStart;
356 KER_BYTE btOnlineResponse;
357 KER_BYTE btCVM;
358 KER_INT32U ulOptions;
359 NFC_OUTCOME_UI UI;
360 NFC_OUTCOME_UI UIRestart;
361 KER_BYTE btAltInterfacePreference;
362 KER_INT16U usFieldOffTimeout;
363 KER_INT16U usRemovalTimeout;
365 KER_INT32U ulIndicators;
366 } NFC_OUTCOME;
369 /* restore struct alignment */
370 #include <emv_platform_restore_align.h>
371
372 #endif /* NFC_OUTCOME_H */
emv_platform_restore_align.h
emv_platform_set_align.h
KER_BYTE
uint8_t KER_BYTE
Definition: emv_platform.h:70
KER_INT32U
unsigned int KER_INT32U
Definition: emv_platform.h:63
KER_INT16U
unsigned short KER_INT16U
Definition: emv_platform.h:61
NFC_OUTCOME
struct tag_NFC_OUTCOME NFC_OUTCOME
Outcome User Interface struct definition, version 0.
NFC_OUTCOME_UI
struct tag_NFC_OUTCOME_UI NFC_OUTCOME_UI
Outcome User Interface struct definition, version 0.
tag_NFC_OUTCOME_UI
Outcome User Interface struct definition, version 0.
Definition: nfc_outcome.h:152
tag_NFC_OUTCOME_UI::usSize
KER_INT16U usSize
Definition: nfc_outcome.h:153
tag_NFC_OUTCOME_UI::btVersion
KER_INT16U btVersion
Definition: nfc_outcome.h:154
tag_NFC_OUTCOME_UI::btLangPrefLen
KER_BYTE btLangPrefLen
Definition: nfc_outcome.h:166
tag_NFC_OUTCOME_UI::btStatus
KER_BYTE btStatus
Definition: nfc_outcome.h:157
tag_NFC_OUTCOME_UI::ar_btLangPref
KER_BYTE ar_btLangPref[8]
Definition: nfc_outcome.h:165
tag_NFC_OUTCOME_UI::btValueQualifier
KER_BYTE btValueQualifier
Definition: nfc_outcome.h:161
tag_NFC_OUTCOME_UI::btValueLen
KER_BYTE btValueLen
Definition: nfc_outcome.h:162
tag_NFC_OUTCOME_UI::btMessageID
KER_BYTE btMessageID
Definition: nfc_outcome.h:156
tag_NFC_OUTCOME_UI::ulHoldTime
KER_INT32U ulHoldTime
Definition: nfc_outcome.h:158
tag_NFC_OUTCOME_UI::ar_btCurrCode
KER_BYTE ar_btCurrCode[2]
Definition: nfc_outcome.h:160
tag_NFC_OUTCOME_UI::ar_btValue
KER_BYTE ar_btValue[6]
Definition: nfc_outcome.h:163
tag_NFC_OUTCOME
Outcome User Interface struct definition, version 0.
Definition: nfc_outcome.h:350
tag_NFC_OUTCOME::btOnlineResponse
KER_BYTE btOnlineResponse
Definition: nfc_outcome.h:356
tag_NFC_OUTCOME::usSize
KER_INT16U usSize
Definition: nfc_outcome.h:351
tag_NFC_OUTCOME::btStart
KER_BYTE btStart
Definition: nfc_outcome.h:355
tag_NFC_OUTCOME::usFieldOffTimeout
KER_INT16U usFieldOffTimeout
Definition: nfc_outcome.h:362
tag_NFC_OUTCOME::btOutcomeType
KER_BYTE btOutcomeType
Definition: nfc_outcome.h:354
tag_NFC_OUTCOME::ulOptions
KER_INT32U ulOptions
Definition: nfc_outcome.h:358
tag_NFC_OUTCOME::ulIndicators
KER_INT32U ulIndicators
Definition: nfc_outcome.h:365
tag_NFC_OUTCOME::btVersion
KER_BYTE btVersion
Definition: nfc_outcome.h:352
tag_NFC_OUTCOME::UI
NFC_OUTCOME_UI UI
Definition: nfc_outcome.h:359
tag_NFC_OUTCOME::btCVM
KER_BYTE btCVM
Definition: nfc_outcome.h:357
tag_NFC_OUTCOME::btAltInterfacePreference
KER_BYTE btAltInterfacePreference
Definition: nfc_outcome.h:361
tag_NFC_OUTCOME::UIRestart
NFC_OUTCOME_UI UIRestart
Definition: nfc_outcome.h:360
tag_NFC_OUTCOME::usRemovalTimeout
KER_INT16U usRemovalTimeout
Definition: nfc_outcome.h:363