libnfc  1.7.0-rc7
nfc-types.h
Go to the documentation of this file.
1 /*-
2  * Free/Libre Near Field Communication (NFC) library
3  *
4  * Libnfc historical contributors:
5  * Copyright (C) 2009 Roel Verdult
6  * Copyright (C) 2009-2013 Romuald Conty
7  * Copyright (C) 2010-2012 Romain Tartière
8  * Copyright (C) 2010-2013 Philippe Teuwen
9  * Copyright (C) 2012-2013 Ludovic Rousseau
10  * Additional contributors of this file:
11  *
12  * This program is free software: you can redistribute it and/or modify it
13  * under the terms of the GNU Lesser General Public License as published by the
14  * Free Software Foundation, either version 3 of the License, or (at your
15  * option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful, but WITHOUT
18  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20  * more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>
24  */
25 
31 #ifndef __NFC_TYPES_H__
32 #define __NFC_TYPES_H__
33 
34 #include <stddef.h>
35 #include <stdint.h>
36 #include <stdbool.h>
37 #include <stdio.h>
38 
39 #ifndef NFC_BUFSIZE_CONNSTRING
40 #define NFC_BUFSIZE_CONNSTRING 1024
41 #endif
42 
46 typedef struct nfc_context nfc_context;
47 
51 typedef struct nfc_device nfc_device;
52 
56 typedef struct nfc_driver nfc_driver;
57 
61 typedef char nfc_connstring[NFC_BUFSIZE_CONNSTRING];
62 
66 typedef enum {
141 } nfc_property;
142 
143 // Compiler directive, set struct alignment to 1 uint8_t for compatibility
144 # pragma pack(1)
145 
150 typedef enum {
151  NDM_UNDEFINED = 0,
152  NDM_PASSIVE,
153  NDM_ACTIVE,
154 } nfc_dep_mode;
155 
160 typedef struct {
162  uint8_t abtNFCID3[10];
164  uint8_t btDID;
166  uint8_t btBS;
168  uint8_t btBR;
170  uint8_t btTO;
172  uint8_t btPP;
174  uint8_t abtGB[48];
175  size_t szGB;
178 } nfc_dep_info;
179 
184 typedef struct {
185  uint8_t abtAtqa[2];
186  uint8_t btSak;
187  size_t szUidLen;
188  uint8_t abtUid[10];
189  size_t szAtsLen;
190  uint8_t abtAts[254]; // Maximal theoretical ATS is FSD-2, FSD=256 for FSDI=8 in RATS
192 
197 typedef struct {
198  size_t szLen;
199  uint8_t btResCode;
200  uint8_t abtId[8];
201  uint8_t abtPad[8];
202  uint8_t abtSysCode[2];
204 
209 typedef struct {
211  uint8_t abtPupi[4];
213  uint8_t abtApplicationData[4];
215  uint8_t abtProtocolInfo[3];
219 
224 typedef struct {
226  uint8_t abtDIV[4];
228  uint8_t btVerLog;
230  uint8_t btConfig;
232  size_t szAtrLen;
233  uint8_t abtAtr[33];
235 
240 typedef struct {
241  uint8_t abtUID[8];
243 
248 typedef struct {
249  uint8_t abtUID[4];
250  uint8_t btProdCode;
251  uint8_t btFabCode;
253 
258 typedef struct {
259  uint8_t btSensRes[2];
260  uint8_t btId[4];
262 
267 typedef union {
268  nfc_iso14443a_info nai;
269  nfc_felica_info nfi;
270  nfc_iso14443b_info nbi;
274  nfc_jewel_info nji;
275  nfc_dep_info ndi;
277 
282 typedef enum {
283  NBR_UNDEFINED = 0,
284  NBR_106,
285  NBR_212,
286  NBR_424,
287  NBR_847,
288 } nfc_baud_rate;
289 
294 typedef enum {
295  NMT_ISO14443A = 1,
296  NMT_JEWEL,
297  NMT_ISO14443B,
298  NMT_ISO14443BI, // pre-ISO14443B aka ISO/IEC 14443 B' or Type B'
299  NMT_ISO14443B2SR, // ISO14443-2B ST SRx
300  NMT_ISO14443B2CT, // ISO14443-2B ASK CTx
301  NMT_FELICA,
302  NMT_DEP,
304 
309 typedef enum {
310  N_TARGET,
311  N_INITIATOR,
312 } nfc_mode;
313 
318 typedef struct {
320  nfc_baud_rate nbr;
322 
327 typedef struct {
328  nfc_target_info nti;
329  nfc_modulation nm;
330 } nfc_target;
331 
332 // Reset struct alignment to default
333 # pragma pack()
334 
335 #endif // _LIBNFC_TYPES_H_