32#ifndef __NFC_INTERNAL_H__
33#define __NFC_INTERNAL_H__
49#define HAL( FUNCTION, ... ) __extension__ ({int res; \
50 pnd->last_error = 0; \
51 if (pnd->driver->FUNCTION) { \
52 res = pnd->driver->FUNCTION( __VA_ARGS__ ); \
54 pnd->last_error = NFC_EDEVNOTSUPP; \
60#define MIN(a,b) (((a) < (b)) ? (a) : (b))
63#define MAX(a,b) (((a) > (b)) ? (a) : (b))
86#define BUFFER_INIT(buffer_name, size) \
87 uint8_t buffer_name[size]; \
88 size_t __##buffer_name##_n = 0
94#define BUFFER_ALIAS(buffer_name, origin) \
95 uint8_t *buffer_name = (void *)origin; \
96 size_t __##buffer_name##_n = 0;
98#define BUFFER_SIZE(buffer_name) (__##buffer_name##_n)
100#define BUFFER_CLEAR(buffer_name) (__##buffer_name##_n = 0)
104#define BUFFER_APPEND(buffer_name, data) \
106 buffer_name[__##buffer_name##_n++] = data; \
112#define BUFFER_APPEND_BYTES(buffer_name, data, size) \
115 while (__n < size) { \
116 buffer_name[__##buffer_name##_n++] = ((uint8_t *)data)[__n++]; \
128 const scan_type_enum scan_type;
132 const char *(*strerror)(
const struct nfc_device *pnd);
134 int (*initiator_init)(
struct nfc_device *pnd);
135 int (*initiator_init_secure_element)(
struct nfc_device *pnd);
136 int (*initiator_select_passive_target)(
struct nfc_device *pnd,
const nfc_modulation nm,
const uint8_t *pbtInitData,
const size_t szInitData, nfc_target *pnt);
137 int (*initiator_poll_target)(
struct nfc_device *pnd,
const nfc_modulation *pnmModulations,
const size_t szModulations,
const uint8_t uiPollNr,
const uint8_t btPeriod, nfc_target *pnt);
138 int (*initiator_select_dep_target)(
struct nfc_device *pnd,
const nfc_dep_mode ndm,
const nfc_baud_rate nbr,
const nfc_dep_info *pndiInitiator, nfc_target *pnt,
const int timeout);
139 int (*initiator_deselect_target)(
struct nfc_device *pnd);
140 int (*initiator_transceive_bytes)(
struct nfc_device *pnd,
const uint8_t *pbtTx,
const size_t szTx, uint8_t *pbtRx,
const size_t szRx,
int timeout);
141 int (*initiator_transceive_bits)(
struct nfc_device *pnd,
const uint8_t *pbtTx,
const size_t szTxBits,
const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar);
142 int (*initiator_transceive_bytes_timed)(
struct nfc_device *pnd,
const uint8_t *pbtTx,
const size_t szTx, uint8_t *pbtRx,
const size_t szRx, uint32_t *cycles);
143 int (*initiator_transceive_bits_timed)(
struct nfc_device *pnd,
const uint8_t *pbtTx,
const size_t szTxBits,
const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar, uint32_t *cycles);
144 int (*initiator_target_is_present)(
struct nfc_device *pnd,
const nfc_target *pnt);
146 int (*target_init)(
struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx,
const size_t szRx,
int timeout);
147 int (*target_send_bytes)(
struct nfc_device *pnd,
const uint8_t *pbtTx,
const size_t szTx,
int timeout);
148 int (*target_receive_bytes)(
struct nfc_device *pnd, uint8_t *pbtRx,
const size_t szRxLen,
int timeout);
149 int (*target_send_bits)(
struct nfc_device *pnd,
const uint8_t *pbtTx,
const size_t szTxBits,
const uint8_t *pbtTxPar);
150 int (*target_receive_bits)(
struct nfc_device *pnd, uint8_t *pbtRx,
const size_t szRxLen, uint8_t *pbtRxPar);
156 int (*device_get_information_about)(
struct nfc_device *pnd,
char **buf);
163# define DEVICE_NAME_LENGTH 256
164# define DEVICE_PORT_LENGTH 64
166#define MAX_USER_DEFINED_DEVICES 4
168struct nfc_user_defined_device {
169 char name[DEVICE_NAME_LENGTH];
181 bool allow_intrusive_scan;
183 struct nfc_user_defined_device user_defined_devices[MAX_USER_DEFINED_DEVICES];
184 unsigned int user_defined_device_count;
196 const struct nfc_driver *driver;
224void string_as_boolean(
const char *s,
bool *value);
226void iso14443_cascade_uid(
const uint8_t abtUID[],
const size_t szUID, uint8_t *pbtCascadedUID,
size_t *pszCascadedUID);
228void prepare_initiator_data(
const nfc_modulation nm, uint8_t **ppbtInitiatorData,
size_t *pszInitiatorData);
230int connstring_decode(
const nfc_connstring connstring,
const char *driver_name,
const char *bus_name,
char **pparam1,
char **pparam2);
nfc_mode
NFC mode type enumeration.
char nfc_connstring[NFC_BUFSIZE_CONNSTRING]
nfc_dep_mode
NFC D.E.P. (Data Exchange Protocol) active/passive mode.
nfc_modulation_type
NFC modulation type enumeration.
struct nfc_context nfc_context
struct nfc_device nfc_device
nfc_baud_rate
NFC baud rate enumeration.
NFC library context Struct which contains internal options, references, pointers, etc....
char name[DEVICE_NAME_LENGTH]
nfc_connstring connstring
NFC modulation structure.