libnfc  1.7.1
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  * See AUTHORS file for a more comprehensive list of contributors.
11  * Additional contributors of this file:
12  *
13  * This program is free software: you can redistribute it and/or modify it
14  * under the terms of the GNU Lesser General Public License as published by the
15  * Free Software Foundation, either version 3 of the License, or (at your
16  * option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful, but WITHOUT
19  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21  * more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this program. If not, see <http://www.gnu.org/licenses/>
25  */
26 
32 #ifndef __NFC_TYPES_H__
33 #define __NFC_TYPES_H__
34 
35 #include <stddef.h>
36 #include <stdint.h>
37 #include <stdbool.h>
38 #include <stdio.h>
39 
40 #ifndef NFC_BUFSIZE_CONNSTRING
41 #define NFC_BUFSIZE_CONNSTRING 1024
42 #endif
43 
47 typedef struct nfc_context nfc_context;
48 
52 typedef struct nfc_device nfc_device;
53 
57 typedef struct nfc_driver nfc_driver;
58 
62 typedef char nfc_connstring[NFC_BUFSIZE_CONNSTRING];
63 
67 typedef enum {
142 } nfc_property;
143 
144 // Compiler directive, set struct alignment to 1 uint8_t for compatibility
145 # pragma pack(1)
146 
151 typedef enum {
152  NDM_UNDEFINED = 0,
153  NDM_PASSIVE,
154  NDM_ACTIVE,
155 } nfc_dep_mode;
156 
161 typedef struct {
163  uint8_t abtNFCID3[10];
165  uint8_t btDID;
167  uint8_t btBS;
169  uint8_t btBR;
171  uint8_t btTO;
173  uint8_t btPP;
175  uint8_t abtGB[48];
176  size_t szGB;
179 } nfc_dep_info;
180 
185 typedef struct {
186  uint8_t abtAtqa[2];
187  uint8_t btSak;
188  size_t szUidLen;
189  uint8_t abtUid[10];
190  size_t szAtsLen;
191  uint8_t abtAts[254]; // Maximal theoretical ATS is FSD-2, FSD=256 for FSDI=8 in RATS
193 
198 typedef struct {
199  size_t szLen;
200  uint8_t btResCode;
201  uint8_t abtId[8];
202  uint8_t abtPad[8];
203  uint8_t abtSysCode[2];
205 
210 typedef struct {
212  uint8_t abtPupi[4];
214  uint8_t abtApplicationData[4];
216  uint8_t abtProtocolInfo[3];
220 
225 typedef struct {
227  uint8_t abtDIV[4];
229  uint8_t btVerLog;
231  uint8_t btConfig;
233  size_t szAtrLen;
234  uint8_t abtAtr[33];
236 
241 typedef struct {
242  uint8_t abtUID[8];
244 
249 typedef struct {
250  uint8_t abtUID[4];
251  uint8_t btProdCode;
252  uint8_t btFabCode;
254 
259 typedef struct {
260  uint8_t btSensRes[2];
261  uint8_t btId[4];
263 
268 typedef union {
269  nfc_iso14443a_info nai;
270  nfc_felica_info nfi;
271  nfc_iso14443b_info nbi;
275  nfc_jewel_info nji;
276  nfc_dep_info ndi;
278 
283 typedef enum {
284  NBR_UNDEFINED = 0,
285  NBR_106,
286  NBR_212,
287  NBR_424,
288  NBR_847,
289 } nfc_baud_rate;
290 
295 typedef enum {
296  NMT_ISO14443A = 1,
297  NMT_JEWEL,
298  NMT_ISO14443B,
299  NMT_ISO14443BI, // pre-ISO14443B aka ISO/IEC 14443 B' or Type B'
300  NMT_ISO14443B2SR, // ISO14443-2B ST SRx
301  NMT_ISO14443B2CT, // ISO14443-2B ASK CTx
302  NMT_FELICA,
303  NMT_DEP,
305 
310 typedef enum {
311  N_TARGET,
312  N_INITIATOR,
313 } nfc_mode;
314 
319 typedef struct {
321  nfc_baud_rate nbr;
323 
328 typedef struct {
329  nfc_target_info nti;
330  nfc_modulation nm;
331 } nfc_target;
332 
333 // Reset struct alignment to default
334 # pragma pack()
335 
336 #endif // _LIBNFC_TYPES_H_