xref: /linux/include/uapi/linux/nfc.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1607ca46eSDavid Howells /*
2607ca46eSDavid Howells  * Copyright (C) 2011 Instituto Nokia de Tecnologia
3607ca46eSDavid Howells  *
4607ca46eSDavid Howells  * Authors:
5607ca46eSDavid Howells  *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
6607ca46eSDavid Howells  *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
7607ca46eSDavid Howells  *
8d3710e74SLauro Ramos Venancio  * Permission to use, copy, modify, and/or distribute this software for any
9d3710e74SLauro Ramos Venancio  * purpose with or without fee is hereby granted, provided that the above
10d3710e74SLauro Ramos Venancio  * copyright notice and this permission notice appear in all copies.
11607ca46eSDavid Howells  *
12d3710e74SLauro Ramos Venancio  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13d3710e74SLauro Ramos Venancio  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14d3710e74SLauro Ramos Venancio  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15d3710e74SLauro Ramos Venancio  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16d3710e74SLauro Ramos Venancio  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17d3710e74SLauro Ramos Venancio  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18d3710e74SLauro Ramos Venancio  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19607ca46eSDavid Howells  */
20607ca46eSDavid Howells 
21607ca46eSDavid Howells #ifndef __LINUX_NFC_H
22607ca46eSDavid Howells #define __LINUX_NFC_H
23607ca46eSDavid Howells 
24607ca46eSDavid Howells #include <linux/types.h>
25607ca46eSDavid Howells #include <linux/socket.h>
26607ca46eSDavid Howells 
27607ca46eSDavid Howells #define NFC_GENL_NAME "nfc"
28607ca46eSDavid Howells #define NFC_GENL_VERSION 1
29607ca46eSDavid Howells 
30607ca46eSDavid Howells #define NFC_GENL_MCAST_EVENT_NAME "events"
31607ca46eSDavid Howells 
32607ca46eSDavid Howells /**
33607ca46eSDavid Howells  * enum nfc_commands - supported nfc commands
34607ca46eSDavid Howells  *
35607ca46eSDavid Howells  * @NFC_CMD_UNSPEC: unspecified command
36607ca46eSDavid Howells  *
37607ca46eSDavid Howells  * @NFC_CMD_GET_DEVICE: request information about a device (requires
38607ca46eSDavid Howells  *	%NFC_ATTR_DEVICE_INDEX) or dump request to get a list of all nfc devices
39607ca46eSDavid Howells  * @NFC_CMD_DEV_UP: turn on the nfc device
40607ca46eSDavid Howells  *	(requires %NFC_ATTR_DEVICE_INDEX)
41607ca46eSDavid Howells  * @NFC_CMD_DEV_DOWN: turn off the nfc device
42607ca46eSDavid Howells  *	(requires %NFC_ATTR_DEVICE_INDEX)
43607ca46eSDavid Howells  * @NFC_CMD_START_POLL: start polling for targets using the given protocols
44607ca46eSDavid Howells  *	(requires %NFC_ATTR_DEVICE_INDEX and %NFC_ATTR_PROTOCOLS)
45607ca46eSDavid Howells  * @NFC_CMD_STOP_POLL: stop polling for targets (requires
46607ca46eSDavid Howells  *	%NFC_ATTR_DEVICE_INDEX)
47607ca46eSDavid Howells  * @NFC_CMD_GET_TARGET: dump all targets found by the previous poll (requires
48607ca46eSDavid Howells  *	%NFC_ATTR_DEVICE_INDEX)
49607ca46eSDavid Howells  * @NFC_EVENT_TARGETS_FOUND: event emitted when a new target is found
50607ca46eSDavid Howells  *	(it sends %NFC_ATTR_DEVICE_INDEX)
51607ca46eSDavid Howells  * @NFC_EVENT_DEVICE_ADDED: event emitted when a new device is registred
52607ca46eSDavid Howells  *	(it sends %NFC_ATTR_DEVICE_NAME, %NFC_ATTR_DEVICE_INDEX and
53607ca46eSDavid Howells  *	%NFC_ATTR_PROTOCOLS)
54607ca46eSDavid Howells  * @NFC_EVENT_DEVICE_REMOVED: event emitted when a device is removed
55607ca46eSDavid Howells  *	(it sends %NFC_ATTR_DEVICE_INDEX)
56607ca46eSDavid Howells  * @NFC_EVENT_TM_ACTIVATED: event emitted when the adapter is activated in
57607ca46eSDavid Howells  *      target mode.
58607ca46eSDavid Howells  * @NFC_EVENT_DEVICE_DEACTIVATED: event emitted when the adapter is deactivated
59607ca46eSDavid Howells  *      from target mode.
6052feb444SThierry Escande  * @NFC_CMD_LLC_GET_PARAMS: request LTO, RW, and MIUX parameters for a device
6152feb444SThierry Escande  * @NFC_CMD_LLC_SET_PARAMS: set one or more of LTO, RW, and MIUX parameters for
6252feb444SThierry Escande  *	a device. LTO must be set before the link is up otherwise -EINPROGRESS
6352feb444SThierry Escande  *	is returned. RW and MIUX can be set at anytime and will be passed in
6452feb444SThierry Escande  *	subsequent CONNECT and CC messages.
6552feb444SThierry Escande  *	If one of the passed parameters is wrong none is set and -EINVAL is
6652feb444SThierry Escande  *	returned.
67390a1bd8SSamuel Ortiz  * @NFC_CMD_ENABLE_SE: Enable the physical link to a specific secure element.
68390a1bd8SSamuel Ortiz  *	Once enabled a secure element will handle card emulation mode, i.e.
69390a1bd8SSamuel Ortiz  *	starting a poll from a device which has a secure element enabled means
70390a1bd8SSamuel Ortiz  *	we want to do SE based card emulation.
71390a1bd8SSamuel Ortiz  * @NFC_CMD_DISABLE_SE: Disable the physical link to a specific secure element.
729ea7187cSSamuel Ortiz  * @NFC_CMD_FW_DOWNLOAD: Request to Load/flash firmware, or event to inform
739ea7187cSSamuel Ortiz  *	that some firmware was loaded
741972b5b3SSamuel Ortiz  * @NFC_EVENT_SE_ADDED: Event emitted when a new secure element is discovered.
751972b5b3SSamuel Ortiz  *	This typically will be sent whenever a new NFC controller with either
761972b5b3SSamuel Ortiz  *	an embedded SE or an UICC one connected to it through SWP.
771972b5b3SSamuel Ortiz  * @NFC_EVENT_SE_REMOVED: Event emitted when a secure element is removed from
781972b5b3SSamuel Ortiz  *	the system, as a consequence of e.g. an NFC controller being unplugged.
7991a32269SSamuel Ortiz  * @NFC_EVENT_SE_CONNECTIVITY: This event is emitted whenever a secure element
8091a32269SSamuel Ortiz  *	is requesting connectivity access. For example a UICC SE may need to
8191a32269SSamuel Ortiz  *	talk with a sleeping modem and will notify this need by sending this
8291a32269SSamuel Ortiz  *	event. It is then up to userspace to decide if it will wake the modem
8391a32269SSamuel Ortiz  *	up or not.
8491a32269SSamuel Ortiz  * @NFC_EVENT_SE_TRANSACTION: This event is sent when an application running on
8591a32269SSamuel Ortiz  *	a specific SE notifies us about the end of a transaction. The parameter
8691a32269SSamuel Ortiz  *	for this event is the application ID (AID).
87ac22ac46SSamuel Ortiz  * @NFC_CMD_GET_SE: Dump all discovered secure elements from an NFC controller.
8872b70b6eSSamuel Ortiz  * @NFC_CMD_SE_IO: Send/Receive APDUs to/from the selected secure element.
89be73c2cbSChristophe Ricard  * @NFC_CMD_ACTIVATE_TARGET: Request NFC controller to reactivate target.
909e58095fSSamuel Ortiz  * @NFC_CMD_VENDOR: Vendor specific command, to be implemented directly
919e58095fSSamuel Ortiz  *	from the driver in order to support hardware specific operations.
924d63adfeSMark Greer  * @NFC_CMD_DEACTIVATE_TARGET: Request NFC controller to deactivate target.
93607ca46eSDavid Howells  */
94607ca46eSDavid Howells enum nfc_commands {
95607ca46eSDavid Howells 	NFC_CMD_UNSPEC,
96607ca46eSDavid Howells 	NFC_CMD_GET_DEVICE,
97607ca46eSDavid Howells 	NFC_CMD_DEV_UP,
98607ca46eSDavid Howells 	NFC_CMD_DEV_DOWN,
99607ca46eSDavid Howells 	NFC_CMD_DEP_LINK_UP,
100607ca46eSDavid Howells 	NFC_CMD_DEP_LINK_DOWN,
101607ca46eSDavid Howells 	NFC_CMD_START_POLL,
102607ca46eSDavid Howells 	NFC_CMD_STOP_POLL,
103607ca46eSDavid Howells 	NFC_CMD_GET_TARGET,
104607ca46eSDavid Howells 	NFC_EVENT_TARGETS_FOUND,
105607ca46eSDavid Howells 	NFC_EVENT_DEVICE_ADDED,
106607ca46eSDavid Howells 	NFC_EVENT_DEVICE_REMOVED,
107607ca46eSDavid Howells 	NFC_EVENT_TARGET_LOST,
108607ca46eSDavid Howells 	NFC_EVENT_TM_ACTIVATED,
109607ca46eSDavid Howells 	NFC_EVENT_TM_DEACTIVATED,
11052feb444SThierry Escande 	NFC_CMD_LLC_GET_PARAMS,
11152feb444SThierry Escande 	NFC_CMD_LLC_SET_PARAMS,
112390a1bd8SSamuel Ortiz 	NFC_CMD_ENABLE_SE,
113390a1bd8SSamuel Ortiz 	NFC_CMD_DISABLE_SE,
114d9b8d8e1SThierry Escande 	NFC_CMD_LLC_SDREQ,
115d9b8d8e1SThierry Escande 	NFC_EVENT_LLC_SDRES,
1169ea7187cSSamuel Ortiz 	NFC_CMD_FW_DOWNLOAD,
1172757c372SSamuel Ortiz 	NFC_EVENT_SE_ADDED,
1182757c372SSamuel Ortiz 	NFC_EVENT_SE_REMOVED,
11991a32269SSamuel Ortiz 	NFC_EVENT_SE_CONNECTIVITY,
12091a32269SSamuel Ortiz 	NFC_EVENT_SE_TRANSACTION,
121ac22ac46SSamuel Ortiz 	NFC_CMD_GET_SE,
12272b70b6eSSamuel Ortiz 	NFC_CMD_SE_IO,
1233682f49fSChristophe Ricard 	NFC_CMD_ACTIVATE_TARGET,
1249e58095fSSamuel Ortiz 	NFC_CMD_VENDOR,
1254d63adfeSMark Greer 	NFC_CMD_DEACTIVATE_TARGET,
126607ca46eSDavid Howells /* private: internal use only */
127607ca46eSDavid Howells 	__NFC_CMD_AFTER_LAST
128607ca46eSDavid Howells };
129607ca46eSDavid Howells #define NFC_CMD_MAX (__NFC_CMD_AFTER_LAST - 1)
130607ca46eSDavid Howells 
131607ca46eSDavid Howells /**
132607ca46eSDavid Howells  * enum nfc_attrs - supported nfc attributes
133607ca46eSDavid Howells  *
134607ca46eSDavid Howells  * @NFC_ATTR_UNSPEC: unspecified attribute
135607ca46eSDavid Howells  *
136607ca46eSDavid Howells  * @NFC_ATTR_DEVICE_INDEX: index of nfc device
137607ca46eSDavid Howells  * @NFC_ATTR_DEVICE_NAME: device name, max 8 chars
138607ca46eSDavid Howells  * @NFC_ATTR_PROTOCOLS: nfc protocols - bitwise or-ed combination from
139607ca46eSDavid Howells  *	NFC_PROTO_*_MASK constants
140607ca46eSDavid Howells  * @NFC_ATTR_TARGET_INDEX: index of the nfc target
141607ca46eSDavid Howells  * @NFC_ATTR_TARGET_SENS_RES: NFC-A targets extra information such as NFCID
142607ca46eSDavid Howells  * @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the
143607ca46eSDavid Howells  *	target is not NFC-Forum compliant)
144607ca46eSDavid Howells  * @NFC_ATTR_TARGET_NFCID1: NFC-A targets identifier, max 10 bytes
145607ca46eSDavid Howells  * @NFC_ATTR_TARGET_SENSB_RES: NFC-B targets extra information, max 12 bytes
146607ca46eSDavid Howells  * @NFC_ATTR_TARGET_SENSF_RES: NFC-F targets extra information, max 18 bytes
147607ca46eSDavid Howells  * @NFC_ATTR_COMM_MODE: Passive or active mode
148607ca46eSDavid Howells  * @NFC_ATTR_RF_MODE: Initiator or target
149607ca46eSDavid Howells  * @NFC_ATTR_IM_PROTOCOLS: Initiator mode protocols to poll for
150607ca46eSDavid Howells  * @NFC_ATTR_TM_PROTOCOLS: Target mode protocols to listen for
15152feb444SThierry Escande  * @NFC_ATTR_LLC_PARAM_LTO: Link TimeOut parameter
15252feb444SThierry Escande  * @NFC_ATTR_LLC_PARAM_RW: Receive Window size parameter
15352feb444SThierry Escande  * @NFC_ATTR_LLC_PARAM_MIUX: MIU eXtension parameter
154390a1bd8SSamuel Ortiz  * @NFC_ATTR_SE: Available Secure Elements
1559674da87SEric Lapuyade  * @NFC_ATTR_FIRMWARE_NAME: Free format firmware version
1562757c372SSamuel Ortiz  * @NFC_ATTR_SE_INDEX: Secure element index
1572757c372SSamuel Ortiz  * @NFC_ATTR_SE_TYPE: Secure element type (UICC or EMBEDDED)
158352a5f5fSEric Lapuyade  * @NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS: Firmware download operation status
15972b70b6eSSamuel Ortiz  * @NFC_ATTR_APDU: Secure element APDU
160e487e4dcSMark A. Greer  * @NFC_ATTR_TARGET_ISO15693_DSFID: ISO 15693 Data Storage Format Identifier
161e487e4dcSMark A. Greer  * @NFC_ATTR_TARGET_ISO15693_UID: ISO 15693 Unique Identifier
162be73c2cbSChristophe Ricard  * @NFC_ATTR_SE_PARAMS: Parameters data from an evt_transaction
1639e58095fSSamuel Ortiz  * @NFC_ATTR_VENDOR_ID: NFC manufacturer unique ID, typically an OUI
1649e58095fSSamuel Ortiz  * @NFC_ATTR_VENDOR_SUBCMD: Vendor specific sub command
1659e58095fSSamuel Ortiz  * @NFC_ATTR_VENDOR_DATA: Vendor specific data, to be optionally passed
1669e58095fSSamuel Ortiz  *	to a vendor specific command implementation
167607ca46eSDavid Howells  */
168607ca46eSDavid Howells enum nfc_attrs {
169607ca46eSDavid Howells 	NFC_ATTR_UNSPEC,
170607ca46eSDavid Howells 	NFC_ATTR_DEVICE_INDEX,
171607ca46eSDavid Howells 	NFC_ATTR_DEVICE_NAME,
172607ca46eSDavid Howells 	NFC_ATTR_PROTOCOLS,
173607ca46eSDavid Howells 	NFC_ATTR_TARGET_INDEX,
174607ca46eSDavid Howells 	NFC_ATTR_TARGET_SENS_RES,
175607ca46eSDavid Howells 	NFC_ATTR_TARGET_SEL_RES,
176607ca46eSDavid Howells 	NFC_ATTR_TARGET_NFCID1,
177607ca46eSDavid Howells 	NFC_ATTR_TARGET_SENSB_RES,
178607ca46eSDavid Howells 	NFC_ATTR_TARGET_SENSF_RES,
179607ca46eSDavid Howells 	NFC_ATTR_COMM_MODE,
180607ca46eSDavid Howells 	NFC_ATTR_RF_MODE,
181607ca46eSDavid Howells 	NFC_ATTR_DEVICE_POWERED,
182607ca46eSDavid Howells 	NFC_ATTR_IM_PROTOCOLS,
183607ca46eSDavid Howells 	NFC_ATTR_TM_PROTOCOLS,
18452feb444SThierry Escande 	NFC_ATTR_LLC_PARAM_LTO,
18552feb444SThierry Escande 	NFC_ATTR_LLC_PARAM_RW,
18652feb444SThierry Escande 	NFC_ATTR_LLC_PARAM_MIUX,
187390a1bd8SSamuel Ortiz 	NFC_ATTR_SE,
188d9b8d8e1SThierry Escande 	NFC_ATTR_LLC_SDP,
1899674da87SEric Lapuyade 	NFC_ATTR_FIRMWARE_NAME,
1902757c372SSamuel Ortiz 	NFC_ATTR_SE_INDEX,
1912757c372SSamuel Ortiz 	NFC_ATTR_SE_TYPE,
19291a32269SSamuel Ortiz 	NFC_ATTR_SE_AID,
193352a5f5fSEric Lapuyade 	NFC_ATTR_FIRMWARE_DOWNLOAD_STATUS,
19472b70b6eSSamuel Ortiz 	NFC_ATTR_SE_APDU,
195e487e4dcSMark A. Greer 	NFC_ATTR_TARGET_ISO15693_DSFID,
196e487e4dcSMark A. Greer 	NFC_ATTR_TARGET_ISO15693_UID,
197447b27c4SChristophe Ricard 	NFC_ATTR_SE_PARAMS,
1989e58095fSSamuel Ortiz 	NFC_ATTR_VENDOR_ID,
1999e58095fSSamuel Ortiz 	NFC_ATTR_VENDOR_SUBCMD,
2009e58095fSSamuel Ortiz 	NFC_ATTR_VENDOR_DATA,
201607ca46eSDavid Howells /* private: internal use only */
202607ca46eSDavid Howells 	__NFC_ATTR_AFTER_LAST
203607ca46eSDavid Howells };
204607ca46eSDavid Howells #define NFC_ATTR_MAX (__NFC_ATTR_AFTER_LAST - 1)
205607ca46eSDavid Howells 
206d9b8d8e1SThierry Escande enum nfc_sdp_attr {
207d9b8d8e1SThierry Escande 	NFC_SDP_ATTR_UNSPEC,
208d9b8d8e1SThierry Escande 	NFC_SDP_ATTR_URI,
209d9b8d8e1SThierry Escande 	NFC_SDP_ATTR_SAP,
210d9b8d8e1SThierry Escande /* private: internal use only */
211d9b8d8e1SThierry Escande 	__NFC_SDP_ATTR_AFTER_LAST
212d9b8d8e1SThierry Escande };
213d9b8d8e1SThierry Escande #define NFC_SDP_ATTR_MAX (__NFC_SDP_ATTR_AFTER_LAST - 1)
214d9b8d8e1SThierry Escande 
215607ca46eSDavid Howells #define NFC_DEVICE_NAME_MAXSIZE		8
216607ca46eSDavid Howells #define NFC_NFCID1_MAXSIZE		10
217322bce95SSamuel Ortiz #define NFC_NFCID2_MAXSIZE		8
218322bce95SSamuel Ortiz #define NFC_NFCID3_MAXSIZE		10
219607ca46eSDavid Howells #define NFC_SENSB_RES_MAXSIZE		12
220607ca46eSDavid Howells #define NFC_SENSF_RES_MAXSIZE		18
221a99903ecSJulien Lefrique #define NFC_ATR_REQ_MAXSIZE		64
222a99903ecSJulien Lefrique #define NFC_ATR_RES_MAXSIZE		64
223e479ce47SJulien Lefrique #define NFC_ATR_REQ_GB_MAXSIZE		48
224e479ce47SJulien Lefrique #define NFC_ATR_RES_GB_MAXSIZE		47
225607ca46eSDavid Howells #define NFC_GB_MAXSIZE			48
2269674da87SEric Lapuyade #define NFC_FIRMWARE_NAME_MAXSIZE	32
227e487e4dcSMark A. Greer #define NFC_ISO15693_UID_MAXSIZE	8
228607ca46eSDavid Howells 
229607ca46eSDavid Howells /* NFC protocols */
230607ca46eSDavid Howells #define NFC_PROTO_JEWEL		1
231607ca46eSDavid Howells #define NFC_PROTO_MIFARE	2
232607ca46eSDavid Howells #define NFC_PROTO_FELICA	3
233607ca46eSDavid Howells #define NFC_PROTO_ISO14443	4
234607ca46eSDavid Howells #define NFC_PROTO_NFC_DEP	5
235607ca46eSDavid Howells #define NFC_PROTO_ISO14443_B	6
236e487e4dcSMark A. Greer #define NFC_PROTO_ISO15693	7
237607ca46eSDavid Howells 
238e487e4dcSMark A. Greer #define NFC_PROTO_MAX		8
239607ca46eSDavid Howells 
240607ca46eSDavid Howells /* NFC communication modes */
241607ca46eSDavid Howells #define NFC_COMM_ACTIVE  0
242607ca46eSDavid Howells #define NFC_COMM_PASSIVE 1
243607ca46eSDavid Howells 
244607ca46eSDavid Howells /* NFC RF modes */
245607ca46eSDavid Howells #define NFC_RF_INITIATOR 0
246607ca46eSDavid Howells #define NFC_RF_TARGET    1
247607ca46eSDavid Howells #define NFC_RF_NONE      2
248607ca46eSDavid Howells 
249607ca46eSDavid Howells /* NFC protocols masks used in bitsets */
250607ca46eSDavid Howells #define NFC_PROTO_JEWEL_MASK      (1 << NFC_PROTO_JEWEL)
251607ca46eSDavid Howells #define NFC_PROTO_MIFARE_MASK     (1 << NFC_PROTO_MIFARE)
252607ca46eSDavid Howells #define NFC_PROTO_FELICA_MASK	  (1 << NFC_PROTO_FELICA)
253607ca46eSDavid Howells #define NFC_PROTO_ISO14443_MASK	  (1 << NFC_PROTO_ISO14443)
254607ca46eSDavid Howells #define NFC_PROTO_NFC_DEP_MASK	  (1 << NFC_PROTO_NFC_DEP)
255607ca46eSDavid Howells #define NFC_PROTO_ISO14443_B_MASK (1 << NFC_PROTO_ISO14443_B)
256e487e4dcSMark A. Greer #define NFC_PROTO_ISO15693_MASK	  (1 << NFC_PROTO_ISO15693)
257607ca46eSDavid Howells 
258390a1bd8SSamuel Ortiz /* NFC Secure Elements */
259390a1bd8SSamuel Ortiz #define NFC_SE_UICC     0x1
260390a1bd8SSamuel Ortiz #define NFC_SE_EMBEDDED 0x2
261390a1bd8SSamuel Ortiz 
262fed7c25eSSamuel Ortiz #define NFC_SE_DISABLED 0x0
263fed7c25eSSamuel Ortiz #define NFC_SE_ENABLED  0x1
264fed7c25eSSamuel Ortiz 
265607ca46eSDavid Howells struct sockaddr_nfc {
2667175f02cSDmitry V. Levin 	__kernel_sa_family_t sa_family;
267607ca46eSDavid Howells 	__u32 dev_idx;
268607ca46eSDavid Howells 	__u32 target_idx;
269607ca46eSDavid Howells 	__u32 nfc_protocol;
270607ca46eSDavid Howells };
271607ca46eSDavid Howells 
272607ca46eSDavid Howells #define NFC_LLCP_MAX_SERVICE_NAME 63
273607ca46eSDavid Howells struct sockaddr_nfc_llcp {
2747175f02cSDmitry V. Levin 	__kernel_sa_family_t sa_family;
275607ca46eSDavid Howells 	__u32 dev_idx;
276607ca46eSDavid Howells 	__u32 target_idx;
277607ca46eSDavid Howells 	__u32 nfc_protocol;
278607ca46eSDavid Howells 	__u8 dsap; /* Destination SAP, if known */
279607ca46eSDavid Howells 	__u8 ssap; /* Source SAP to be bound to */
280607ca46eSDavid Howells 	char service_name[NFC_LLCP_MAX_SERVICE_NAME]; /* Service name URI */;
281*79b69a83SKrzysztof Kozlowski 	__kernel_size_t service_name_len;
282607ca46eSDavid Howells };
283607ca46eSDavid Howells 
284607ca46eSDavid Howells /* NFC socket protocols */
285607ca46eSDavid Howells #define NFC_SOCKPROTO_RAW	0
286607ca46eSDavid Howells #define NFC_SOCKPROTO_LLCP	1
287607ca46eSDavid Howells #define NFC_SOCKPROTO_MAX	2
288607ca46eSDavid Howells 
289607ca46eSDavid Howells #define NFC_HEADER_SIZE 1
290607ca46eSDavid Howells 
291607ca46eSDavid Howells /**
292607ca46eSDavid Howells  * Pseudo-header info for raw socket packets
293607ca46eSDavid Howells  * First byte is the adapter index
294607ca46eSDavid Howells  * Second byte contains flags
295607ca46eSDavid Howells  *  - 0x01 - Direction (0=RX, 1=TX)
29657be1f3fSHiren Tandel  *  - 0x02-0x04 - Payload type (000=LLCP, 001=NCI, 010=HCI, 011=Digital,
29757be1f3fSHiren Tandel  *                              100=Proprietary)
29857be1f3fSHiren Tandel  *  - 0x05-0x80 - Reserved
299607ca46eSDavid Howells  **/
30057be1f3fSHiren Tandel #define NFC_RAW_HEADER_SIZE	2
30157be1f3fSHiren Tandel #define NFC_DIRECTION_RX		0x00
30257be1f3fSHiren Tandel #define NFC_DIRECTION_TX		0x01
30357be1f3fSHiren Tandel 
30457be1f3fSHiren Tandel #define RAW_PAYLOAD_LLCP 0
30557be1f3fSHiren Tandel #define RAW_PAYLOAD_NCI	1
30657be1f3fSHiren Tandel #define RAW_PAYLOAD_HCI	2
30757be1f3fSHiren Tandel #define RAW_PAYLOAD_DIGITAL	3
30857be1f3fSHiren Tandel #define RAW_PAYLOAD_PROPRIETARY	4
309607ca46eSDavid Howells 
31026fd76caSSamuel Ortiz /* socket option names */
31126fd76caSSamuel Ortiz #define NFC_LLCP_RW		0
31226fd76caSSamuel Ortiz #define NFC_LLCP_MIUX		1
313064f370cSThierry Escande #define NFC_LLCP_REMOTE_MIU	2
314064f370cSThierry Escande #define NFC_LLCP_REMOTE_LTO	3
315064f370cSThierry Escande #define NFC_LLCP_REMOTE_RW	4
31626fd76caSSamuel Ortiz 
317607ca46eSDavid Howells #endif /*__LINUX_NFC_H */
318