1032360c020893474747f443ae587213a5e81a61
[platform/core/connectivity/nfc-manager-neard.git] / common / include / net_nfc_typedef.h
1 /*
2  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef __NET_NFC_TYPEDEF_H__
17 #define __NET_NFC_TYPEDEF_H__
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <stdint.h>
23 #include <stdbool.h>
24 #include <glib.h>
25
26 /**
27   NFC Manager
28   NFC Manager controls the nfc device with high level APIs such as SmartPoster and Connection handover.
29   It also support the JSR257 push handling.
30   This file describe the structure and defines of the NFC manager
31   */
32
33 /**
34   @defgroup NET_NFC_MANAGER The description of NFC Manager
35   @defgroup NET_NFC_TYPEDEF Defines and structures
36   @defgroup NET_NFC_MANAGER_API NFC Manager
37   @defgroup NET_NFC_MANAGER_INFO Tag Information and data APIs
38   @defgroup NET_NFC_MANAGER_TAG Tag Read/Write APIs
39   @defgroup NET_NFC_MANAGER_NDEF NDEF Message APIs
40   @defgroup NET_NFC_MANAGER_RECORD NDEF Record APIs
41   @defgroup NET_NFC_MANAGER_LLCP NFC LLCP APIs
42   @defgroup NET_NFC_MANAGER_APDU Internal APDU APIs
43   @defgroup NET_NFC_MANAGER_EXCHANGE App Exchanger APIs
44
45
46   @addtogroup NET_NFC_MANAGER
47   @{
48   <P> "NFC Manager" is the framework that provide NFC APIs,
49   and it also provide high level services such as Smart Poster, Connection Handover,
50   and JSR257 push registry.  </P>
51
52   NFC Manager APIs are defined in <net_nfc.h>, <net_nfc_typedef.h>
53
54   <P>
55   Memory management rules <br>
56   depends on the the verb of each function it describe memory management roles
57
58   1. set: copy the parameters and used inside of nfc-manager, you should free the parameter you have used
59   2. append: it is similar to "set" but, it does not make copy, you SHOULD NOT free the parameter after use it belongs to nfc-manager and it will be freed later
60   (example "net_nfc_append_record_to_ndef_message") the appended record will be free the at the ndef message free time.
61   3. get, search : it gives original pointer to you, DO NOT free the pointer get from nfc-manager API
62   4. remove: automatically free inside of the this function do not free again.
63   5. create: it allocate handle, therefore, you should consider free after using
64   </p>
65
66   @}
67   */
68
69 /**
70   @addtogroup NET_NFC_TYPEDEF
71   @{
72   This documents provide the NFC defines
73
74 */
75
76 /**
77   net_nfc_error_e is enum type that returned from each functions
78   it mostly contains the error codes and it may contains status codes.
79   */
80 typedef enum
81 {
82         /*000*/NET_NFC_OK = 0, /**< Status is OK        */
83         /*999*/NET_NFC_UNKNOWN_ERROR = -999, /**< Unknown error */
84         /*998*/NET_NFC_ALLOC_FAIL, /**< Memory allocation is failed */
85         /*997*/NET_NFC_THREAD_CREATE_FAIL, /**< Thread creation is failed */
86         /*996*/NET_NFC_INVALID_STATE, /**< State of NFC-Manager or nfc-stack is not normal */
87         /*995*/NET_NFC_IPC_FAIL, /**< Communication with ipc is failed. (from client to server)*/
88         /*994*/NET_NFC_OUT_OF_BOUND, /**< Index is out of bound */
89         /*993*/NET_NFC_NULL_PARAMETER, /**< Unexpected NULL parameter is received */
90         /*992*/NET_NFC_BUFFER_TOO_SMALL, /**< Requested buffer is too small to store data, this error should be received */
91         /*991*/NET_NFC_ALREADY_INITIALIZED, /**< You tried to initialized again without de-init */
92         /*990*/NET_NFC_COMMUNICATE_WITH_CONTROLLER_FAILED, /**< Communication with Controller Chipset is failed this is Fatal Error */
93         /*989*/NET_NFC_RF_TIMEOUT, /**< Timeout is raised while communicate with a tag */
94         /*988*/NET_NFC_RF_ERROR, /**< Unexpected package is received from target, you may receive this error comes by the low level RF communication fault*/
95         /*987*/NET_NFC_NOT_INITIALIZED, /**< Application tries to request without initialization */
96         /*986*/NET_NFC_NOT_SUPPORTED, /**< Request information or command is not supported in current connected target */
97         /*985*/NET_NFC_ALREADY_REGISTERED, /**< Requested SAP number is already used by other socket or data is already appended or registered */
98         /*984*/NET_NFC_NOT_ALLOWED_OPERATION, /**< Requested Operation is not allowed in the situation in critical time (such as write data on target)*/
99         /*983*/NET_NFC_BUSY, /**< Previous operation is not finished. don't worry to get this message, most of request will be executed in the serial queue */
100         /*982*/NET_NFC_INVALID_HANDLE, /**< Requested Device in not valid device */
101         /*981*/NET_NFC_TAG_READ_FAILED, /**< Tag reading is failed because of unexpected chunk data is received or error ack is received */
102         /*980*/NET_NFC_TAG_WRITE_FAILED, /**< When you try to write on read only tag or error ack is received */
103         /*979*/NET_NFC_NO_NDEF_SUPPORT, /**< Tag is not supported NDEF format for tag is not formatted for NDEF */
104         /*978*/NET_NFC_NO_NDEF_MESSAGE, /**< No data is received after NDEF reading */
105         /*977*/NET_NFC_INVALID_FORMAT, /**< Received data is not readable or it has illegal values or format */
106         /*976*/NET_NFC_INSUFFICIENT_STORAGE, /**< The connected tag does not have enough information */
107         /*975*/NET_NFC_OPERATION_FAIL, /**< The remote target returned error while doing a operation*/
108         /*974*/NET_NFC_NOT_CONNECTED, /**< remote is not connected correctly. This can be happened when the RF does not have enough strength */
109         /*973*/NET_NFC_NO_DATA_FOUND, /**< Requested data is not found in the list or properties */
110         /*972*/NET_NFC_SECURITY_FAIL, /**< Authentication is failed while communication with nfc-manager server */
111         /*971*/NET_NFC_TARGET_IS_MOVED_AWAY, /**< Target is lost while doing a operation */
112         /*970*/NET_NFC_TAG_IS_ALREADY_FORMATTED, /** Target is already formatted */
113         /*969*/NET_NFC_NOT_REGISTERED, /**< removal is requested but requested data is not registered */
114         /*968*/NET_NFC_INVALID_PARAM, /**< removal is requested but requested data is not registered */
115         /*499*/NET_NFC_NDEF_TYPE_LENGTH_IS_NOT_OK = -499, /**< Illegal ndef record type length */
116         /*498*/NET_NFC_NDEF_PAYLOAD_LENGTH_IS_NOT_OK, /**< Illegal ndef record payload length */
117         /*497*/NET_NFC_NDEF_ID_LENGTH_IS_NOT_OK, /**< Illegal ndef record id length */
118         /*496*/NET_NFC_NDEF_RECORD_IS_NOT_EXPECTED_TYPE, /**< Parameter record is not expected record. for example, try to URI from text record */
119         /*495*/NET_NFC_NDEF_BUF_END_WITHOUT_ME, /**< NDEF messages is terminated without ME flag */
120         /*494*/NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC, /**< Current device does not support NFC feature or this manager does not found plugin library */
121
122         /*399*/NET_NFC_LLCP_INVALID_SOCKET = -399, /**< socket is not valid socket */
123         /*398*/NET_NFC_LLCP_SOCKET_DISCONNECTED, /**< socket is disconnected */
124         /*397*/NET_NFC_LLCP_SOCKET_FRAME_REJECTED, /**< send data is rejected from remote side */
125
126         /*299*/NET_NFC_P2P_SEND_FAIL = -299, /**< P2P data send fail */
127 } net_nfc_error_e;
128
129 /**
130   Enum value of the record type  ( TNF value )
131   */
132 typedef enum
133 {
134         NET_NFC_RECORD_EMPTY = 0x0,
135         NET_NFC_RECORD_WELL_KNOWN_TYPE,
136         NET_NFC_RECORD_MIME_TYPE, // Media type
137         NET_NFC_RECORD_URI,
138         NET_NFC_RECORD_EXTERNAL_RTD,
139         NET_NFC_RECORD_UNKNOWN,
140         NET_NFC_RECORD_UNCHAGNED,
141 } net_nfc_record_tnf_e;
142
143 /**
144   net_nfc_message_e is identify the events comes from nfc-manager.
145   most of the events response event that you requested operations.
146   and some of the events are generated by nfc-manager. (example, NET_NFC_MESSAGE_TAG_DISCOVERED, NET_NFC_MESSAGE_TAG_DETACHED,
147   NET_NFC_MESSAGE_LLCP_DISCOVERED and NET_NFC_MESSAGE_LLCP_DETACHED)
148
149   All of the events are delivered by the the callback function that registered with "net_nfc_set_response_callback"
150   */
151
152 typedef enum
153 {
154         NET_NFC_MESSAGE_TRANSCEIVE = 0, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_tranceive"
155                                                                           <br> if the operation is success, the data parameter should cast into data_s *or it return NULL*/
156         NET_NFC_MESSAGE_READ_NDEF, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_read_tag"
157                                                                  <br> if the operation is success, the data parameter should cast into ndef_message_s* or it return NULL */
158         NET_NFC_MESSAGE_WRITE_NDEF, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_write_ndef"
159                                                                   <br> data pointer always returns NULL */
160         NET_NFC_MESSAGE_MAKE_READ_ONLY_NDEF, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_make_read_only_ndef"
161                                                                                    <br> data pointer always returns NULL */
162         NET_NFC_MESSAGE_IS_TAG_CONNECTED, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_is_tag_conneced"
163                                                                                 <br> data pointer always returns NULL */
164         NET_NFC_MESSAGE_GET_CURRENT_TAG_INFO, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_get_current_tag_infof"
165                                                                                         <br> if the operation is success, the data parameter should cast into net_nfc_target_info_s* or it return NULL */
166         NET_NFC_MESSAGE_GET_CURRENT_TARGET_HANDLE,  /**< Type: Response Event, <br> This events is received after calling the "net_nfc_get_current_target_handle"
167                                                                                                   <br> if the operation is success, the data parameter should cast into net_nfc_target_handle_s* or it return NULL */
168         NET_NFC_MESSAGE_TAG_DISCOVERED, /**< Type: Notify Event, <br> When a tag or SE is detected, you got this event.
169                                                                           <br> The data contains the target info , need to cast to net_nfc_target_info_s* */
170         NET_NFC_MESSAGE_NOTIFY, /**< This Notify Event <br> when the unexpected error has occurred, this event is delivered. data pointer always returns NULL  */
171         NET_NFC_MESSAGE_TAG_DETACHED, /**< Type: Notify Event, <br> When a tag or SE is disappeared, you got this event.
172                                                                         <br> The data contains the target info , need to cast to net_nfc_target_info_s* but it does not have detail target info
173                                                                         <br> please, do not use "net_nfc_get_tag_info_keys" when you got this event*/
174         /*10*/  NET_NFC_MESSAGE_FORMAT_NDEF, /**< Type: Response Event <br> After complete "net_nfc_format_ndef", this event is delivered */
175         NET_NFC_MESSAGE_LLCP_DISCOVERED,/**< Type: Notify Event <br> When LLCP is discovered and remote device is support llcp, you receive this event
176                                                                           <br> data pointer contains the remote llcp configuration info. Cast to net_nfc_llcp_config_info_s* */
177         NET_NFC_MESSAGE_P2P_DETACHED, /**< Type: Notify Event <br> When LLCP is de-activated by removing the device, you receive this event*/
178         NET_NFC_MESSAGE_LLCP_CONFIG, /**< Type: Response Event. <br> The operation of "net_nfc_set_llcp_local_configure" is completed */
179
180         NET_NFC_MESSAGE_P2P_DISCOVERED, /**< Type: Notify Event <br> The remove device is detected and ready for transferring data to remote side */
181         NET_NFC_MESSAGE_P2P_SEND, /**< Type: Response Event, <br> This events is received after calling the "net_nfc_send_exchanger_data" */
182         NET_NFC_MESSAGE_P2P_RECEIVE, /**< Type: Notify Event, <br> When llcp server socket receive some data, this event is delivered. */
183
184         NET_NFC_MESSAGE_SE_START_TRANSACTION, /**< Type: Notify Event, indicates external reader start transaction*/
185         NET_NFC_MESSAGE_SE_END_TRANSACTION, /**< Type: Notify Event, indicates external reader end transaction*/
186         NET_NFC_MESSAGE_SE_TYPE_TRANSACTION, /**< Type: Notify Event, Indicates external reader trying to access secure element */
187         /*20*/  NET_NFC_MESSAGE_SE_CONNECTIVITY, /**< Type: Notify Event, This event notifies the terminal host that it shall send a connectivity event from UICC */
188         NET_NFC_MESSAGE_SE_FIELD_ON, /**< Type: Notify Event, indicates external reader field is on*/
189         NET_NFC_MESSAGE_SE_FIELD_OFF, /**< Type: Notify Event, indicates external reader field is off*/
190         NET_NFC_MESSAGE_SE_TYPE_CHANGED, /**< Type: Notify Event, indicates secure element type is changed*/
191         NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED, /**< Type: Notify Event, indicates card emulation mode is changed*/
192         NET_NFC_MESSAGE_CONNECTION_HANDOVER, /**< Type: Response Event. <br> The result of connection handover. If it has been completed successfully, this event will include the information of alternative carrier. */
193
194         NET_NFC_MESSAGE_SET_SE,
195         NET_NFC_MESSAGE_GET_SE,
196         NET_NFC_MESSAGE_OPEN_INTERNAL_SE,
197         NET_NFC_MESSAGE_CLOSE_INTERNAL_SE,
198         /*30*/  NET_NFC_MESSAGE_SEND_APDU_SE,
199         NET_NFC_MESSAGE_GET_ATR_SE,
200         NET_NFC_GET_SERVER_STATE,
201
202         NET_NFC_MESSAGE_SIM_TEST,
203
204         NET_NFC_MESSAGE_INIT,
205         NET_NFC_MESSAGE_DEINIT,
206
207         NET_NFC_MESSAGE_PRBS_TEST,
208
209         NET_NFC_MESSAGE_GET_FIRMWARE_VERSION,
210
211         NET_NFC_MESSAGE_SET_EEDATA,
212
213         NET_NFC_MESSAGE_SNEP_START_SERVER,
214         NET_NFC_MESSAGE_SNEP_START_CLIENT,
215         /*40*/  NET_NFC_MESSAGE_SNEP_REQUEST,
216         NET_NFC_MESSAGE_SNEP_STOP_SERVICE,
217         NET_NFC_MESSAGE_SNEP_REGISTER_SERVER,
218         NET_NFC_MESSAGE_SNEP_UNREGISTER_SERVER,
219
220         NET_NFC_MESSAGE_CONNECT,
221         NET_NFC_MESSAGE_DISCONNECT,
222         NET_NFC_MESSAGE_SET_CARD_EMULATION,
223 } net_nfc_message_e;
224
225
226 /**
227   Card states for nfc tag
228   */
229 typedef enum
230 {
231         NET_NFC_NDEF_CARD_INVALID = 0x00, /**<  The card is not NFC forum specified tag. The ndef format will be needed. */
232         NET_NFC_NDEF_CARD_INITIALISED, /**< The card is NFC forum specified tag, but It has no actual data. So, the ndef write will be needed. */
233         NET_NFC_NDEF_CARD_READ_WRITE, /**<  The card is NFC forum specified tag. The ndef read and write will be allowed. */
234         NET_NFC_NDEF_CARD_READ_ONLY /**< The card is NFC forum specified tag, but only the ndef read will be allowed. */
235 } net_nfc_ndef_card_state_e;
236
237 /**
238   Encoding type for string message
239   */
240 typedef enum
241 {
242         NET_NFC_ENCODE_UTF_8 = 0x00,
243         NET_NFC_ENCODE_UTF_16,
244 } net_nfc_encode_type_e;
245
246 /**
247   URI scheme type defined in the NFC forum  "URI Record Type Definition"
248   */
249 typedef enum
250 {
251         NET_NFC_SCHEMA_FULL_URI = 0x00, /**< protocol is specify by payload     */
252         NET_NFC_SCHEMA_HTTP_WWW, /**< http://www.                               */
253         NET_NFC_SCHEMA_HTTPS_WWW, /**< https://www.                             */
254         NET_NFC_SCHEMA_HTTP, /**< http://                                               */
255         NET_NFC_SCHEMA_HTTPS, /**< https://                                     */
256         NET_NFC_SCHEMA_TEL, /**< tel:                                           */
257         NET_NFC_SCHEMA_MAILTO, /**< mailto:                                             */
258         NET_NFC_SCHEMA_FTP_ANONYMOUS, /**< ftp://anonymouse:anonymouse@         */
259         NET_NFC_SCHEMA_FTP_FTP, /**< ftp://ftp.                                 */
260         NET_NFC_SCHEMA_FTPS, /**< ftps://                                               */
261         NET_NFC_SCHEMA_SFTP, /**< sftp://                                               */
262         NET_NFC_SCHEMA_SMB, /**< smb://                                         */
263         NET_NFC_SCHEMA_NFS, /**< nfs://                                         */
264         NET_NFC_SCHEMA_FTP, /**< ftp://                                         */
265         NET_NFC_SCHEMA_DAV, /**< dav://                                         */
266         NET_NFC_SCHEMA_NEWS, /**< news://                                       */
267         NET_NFC_SCHEMA_TELNET, /**< telnet://                                   */
268         NET_NFC_SCHEMA_IMAP, /**< imap:                                                 */
269         NET_NFC_SCHEMA_RTSP, /**< rtsp://                                               */
270         NET_NFC_SCHEMA_URN, /**< urn:                                           */
271         NET_NFC_SCHEMA_POP, /**< pop:                                           */
272         NET_NFC_SCHEMA_SIP, /**< sip:                                           */
273         NET_NFC_SCHEMA_SIPS, /**< sips:                                                 */
274         NET_NFC_SCHEMA_TFTP, /**< tftp:                                                 */
275         NET_NFC_SCHEMA_BTSPP, /**< btspp://                                     */
276         NET_NFC_SCHEMA_BTL2CAP, /**< btl2cap://                                 */
277         NET_NFC_SCHEMA_BTGOEP, /**< btgoep://                                   */
278         NET_NFC_SCHEMA_TCPOBEX, /**< tcpobex://                                 */
279         NET_NFC_SCHEMA_IRDAOBEX, /**< irdaobex://                                       */
280         NET_NFC_SCHEMA_FILE, /**< file://                                               */
281         NET_NFC_SCHEMA_URN_EPC_ID, /**< urn:epc:id:                                     */
282         NET_NFC_SCHEMA_URN_EPC_TAG, /**< urn:epc:tag:                                   */
283         NET_NFC_SCHEMA_URN_EPC_PAT, /**< urn:epc:pat:                                   */
284         NET_NFC_SCHEMA_URN_EPC_RAW, /**< urn:epc:raw:                                   */
285         NET_NFC_SCHEMA_URN_EPC, /**< urn:epc:                                   */
286         NET_NFC_SCHEMA_URN_NFC, /**< urn:epc:nfc:                                       */
287         NET_NFC_SCHEMA_MAX /**< --  indicating max--                    */
288 } net_nfc_schema_type_e;
289
290 // this is for target detect event filter
291
292 typedef enum
293 {
294         NET_NFC_ALL_DISABLE = 0x0000,
295         NET_NFC_ISO14443A_ENABLE = 0x0001,
296         NET_NFC_ISO14443B_ENABLE = 0x0002,
297         NET_NFC_ISO15693_ENABLE = 0x0004,
298         NET_NFC_FELICA_ENABLE = 0x0008,
299         NET_NFC_JEWEL_ENABLE = 0x0010,
300         NET_NFC_IP_ENABLE = 0x0020,
301         NET_NFC_ALL_ENABLE = ~0,
302
303 } net_nfc_event_filter_e;
304
305 /*
306  **************************************
307  LLCP defines
308  **************************************
309  */
310 /**
311   These events are delivered to the each socket callback. These events are separated events that comes from "net_nfc_set_response_callback" callback
312   */
313 typedef enum
314 {
315         /* start number should be larger than "net_nfc_message_e"
316            because  to make seperate with net_nfc_message_e event it may conflict in
317            the dispatcher and ipc part */
318         NET_NFC_MESSAGE_LLCP_LISTEN = 1000, /**< Type: Response Event <br> this event indicates "net_nfc_listen_llcp" requested is completed*/
319         NET_NFC_MESSAGE_LLCP_ACCEPTED, /**< Type: Notify Event. <br>  Remote socket is accepted to listening socket
320                                                                          <br> data pointer contains the remote socket info (Cast to net_nfc_llcp_socket_option_s*)*/
321         NET_NFC_MESSAGE_LLCP_CONNECT, /**< Type: Response Event. <br> "net_nfc_connect_llcp_with" request is completed and your socket is connected to remote site with url*/
322         NET_NFC_MESSAGE_LLCP_CONNECT_SAP, /**< Type: Response Event.<br>  "net_nfc_connect_llcp_with_sap" request is completed and your socket is connected to remote site with sap number*/
323         NET_NFC_MESSAGE_LLCP_SEND, /**< Type: Response Event,<br>  "net_nfc_send_llcp" operation is completed (connection mode)*/
324         NET_NFC_MESSAGE_LLCP_SEND_TO, /**< Type: Response Event,<br>  "net_nfc_send_llcp_to"operation is completed (connectionless mode)*/
325         NET_NFC_MESSAGE_LLCP_RECEIVE, /**< Type: Response Event,<br>  "net_nfc_receive_llcp" operation is completed (connection mode)
326                                                                         <br> data pointer contains received data (Cast to data_s*)*/
327         NET_NFC_MESSAGE_LLCP_RECEIVE_FROM, /**< Type: Response Event,<br>  "net_nfc_receive_llcp_from" operation is completed (connectionless mode)*/
328         NET_NFC_MESSAGE_LLCP_DISCONNECT, /**< Type: Response Event,<br>  "net_nfc_disconnect_llcp" request is completed */
329         NET_NFC_MESSAGE_LLCP_ERROR, /**< Type: Notify Event,<br>  when the socket is disconnected, you may receive this event */
330         NET_NFC_MESSAGE_LLCP_CONNECT_REQ, /**< Type: Notify Event,<br> when the peer requests connect, you may receive this event */
331         NET_NFC_MESSAGE_LLCP_ACCEPT, /**< Type: Response Event <br> this event indicates "net_nfc_accept_llcp" requested is completed*/
332         NET_NFC_MESSAGE_LLCP_REJECT, /**< Type: Response Event <br> this event indicates "net_nfc_reject_llcp" requested is completed*/
333         NET_NFC_MESSAGE_LLCP_REJECTED, /**< Type: Notify Event,<br> when the socket is rejected, you may receive this event */
334         NET_NFC_MESSAGE_LLCP_CLOSE, /**< Type: Response Event,<br>  "net_nfc_close_llcp_socket" request is completed */
335
336 } net_nfc_llcp_message_e;
337
338 typedef enum
339 {
340         NET_NFC_UNKNOWN_TARGET = 0x00U,
341
342         /* Specific PICC Devices */
343
344         NET_NFC_GENERIC_PICC,
345         NET_NFC_ISO14443_A_PICC,
346         NET_NFC_ISO14443_4A_PICC,
347         NET_NFC_ISO14443_3A_PICC,
348         NET_NFC_MIFARE_MINI_PICC,
349         NET_NFC_MIFARE_1K_PICC,
350         NET_NFC_MIFARE_4K_PICC,
351         NET_NFC_MIFARE_ULTRA_PICC,
352         NET_NFC_MIFARE_DESFIRE_PICC,
353         NET_NFC_ISO14443_B_PICC,
354         NET_NFC_ISO14443_4B_PICC,
355         NET_NFC_ISO14443_BPRIME_PICC,
356         NET_NFC_FELICA_PICC,
357         NET_NFC_JEWEL_PICC,
358         NET_NFC_ISO15693_PICC,
359
360         /* NFC-IP1 Device Types */
361         NET_NFC_NFCIP1_TARGET,
362         NET_NFC_NFCIP1_INITIATOR,
363 } net_nfc_target_type_e;
364
365 typedef enum
366 {
367         NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONORIENTED,
368         NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONLESS,
369 } net_nfc_socket_type_e;
370
371 typedef enum
372 {
373         NET_NFC_SNEP = 0x00,
374         NET_NFC_NPP,
375 } llcp_app_protocol_e;
376
377 typedef enum
378 {
379         NET_NFC_TAG_CONNECTION = 0x00,
380         NET_NFC_P2P_CONNECTION_TARGET,
381         NET_NFC_P2P_CONNECTION_INITIATOR,
382         NET_NFC_SE_CONNECTION
383 } net_nfc_connection_type_e;
384
385 typedef enum
386 {
387         NET_NFC_CONN_HANDOVER_CARRIER_BT = 0x00,
388         NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS, /* infrastructure */
389         NET_NFC_CONN_HANDOVER_CARRIER_WIFI_IBSS, /* add hoc */
390         NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN,
391 } net_nfc_conn_handover_carrier_type_e;
392
393 /**
394   This structure is just data, to express bytes array
395   */
396 typedef struct
397 {
398         uint8_t *buffer;
399         uint32_t length;
400 } data_s;
401
402 /**
403   ndef_record_s structure has the NDEF record data. it is only a record not a message
404   */
405 typedef struct _ndef_record_s
406 {
407         uint8_t MB :1;
408         uint8_t ME :1;
409         uint8_t CF :1;
410         uint8_t SR :1;
411         uint8_t IL :1;
412         uint8_t TNF :3;
413         data_s type_s;
414         data_s id_s;
415         data_s payload_s;
416         struct _ndef_record_s *next;
417 }ndef_record_s;
418
419 /**
420   NDEF message it has record counts and records (linked listed form)
421   */
422 typedef struct _ndef_message_s
423 {
424         uint32_t recordCount;
425         ndef_record_s *records; // linked list
426 } ndef_message_s;
427
428 typedef struct _net_nfc_target_handle_s
429 {
430         uint32_t connection_id;
431         net_nfc_connection_type_e connection_type;
432         net_nfc_target_type_e target_type;
433         /*++npp++*/
434         llcp_app_protocol_e app_type;
435         /*--npp--*/
436 }net_nfc_target_handle_s;
437
438 typedef struct _net_nfc_tag_info_s
439 {
440         char *key;
441         data_s *value;
442 } net_nfc_tag_info_s;
443
444 typedef struct _net_nfc_target_info_s
445 {
446         net_nfc_target_handle_s *handle;
447         net_nfc_target_type_e devType;
448         uint8_t is_ndef_supported;
449         uint8_t ndefCardState;
450         uint32_t maxDataSize;
451         uint32_t actualDataSize;
452         int number_of_keys;
453         net_nfc_tag_info_s *tag_info_list;
454         char **keylist;
455         data_s raw_data;
456 }net_nfc_target_info_s;
457
458 typedef struct _net_nfc_llcp_config_info_s
459 {
460         uint16_t miu; /** The remote Maximum Information Unit (NOTE: this is MIU, not MIUX !)*/
461         uint16_t wks; /** The remote Well-Known Services*/
462         uint8_t lto; /** The remote Link TimeOut (in 1/100s)*/
463         uint8_t option; /** The remote options*/
464 }net_nfc_llcp_config_info_s;
465
466 typedef struct _net_nfc_llcp_socket_option_s
467 {
468         uint16_t miu; /** The remote Maximum Information Unit */
469         uint8_t rw; /** The Receive Window size (4 bits)*/
470         net_nfc_socket_type_e type;
471 }net_nfc_llcp_socket_option_s;
472
473 typedef struct _net_nfc_connection_handover_info_s
474 {
475         net_nfc_conn_handover_carrier_type_e type;
476         data_s data;
477 }net_nfc_connection_handover_info_s;
478
479 typedef uint8_t sap_t;
480
481 typedef uint32_t net_nfc_llcp_socket_t;
482
483 typedef void *net_nfc_snep_handle_h;
484
485 // LLCP Callback
486 typedef void (*net_nfc_llcp_socket_cb)(net_nfc_llcp_message_e message,
487                 net_nfc_error_e result, void *data, void *user_data, void *trans_data);
488
489 // Main Callback
490 typedef void (*net_nfc_response_cb)(net_nfc_message_e message,
491                 net_nfc_error_e result, void *data, void *user_param, void *trans_data);
492
493 typedef void (*net_nfc_internal_se_response_cb)(net_nfc_message_e message,
494                 net_nfc_error_e result, void *data, void *user_param, void *trans_data);
495
496 typedef void (* net_nfc_set_activation_completed_cb)(net_nfc_error_e error,
497                 void *user_data);
498
499 // handover
500
501 typedef enum
502 {
503         NET_NFC_CONN_HANDOVER_CARRIER_INACTIVATE = 0x00,
504         NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATE,
505         NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATING,
506         NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN_STATUS,
507 } net_nfc_conn_handover_carrier_state_e;
508
509 typedef struct _net_nfc_conn_handover_carrier_info_s *net_nfc_conn_handover_carrier_info_h;
510 typedef struct _net_nfc_conn_handover_info_s *net_nfc_conn_handover_info_h;
511
512 #define MIFARE_KEY_DEFAULT {(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF}
513 #define MIFARE_KEY_APPLICATION_DIRECTORY {(uint8_t)0xA0,(uint8_t)0xA1,(uint8_t)0xA2,(uint8_t)0xA3,(uint8_t)0xA4,(uint8_t)0xA5}
514 #define MIFARE_KEY_NET_NFC_FORUM {(uint8_t)0xD3,(uint8_t)0xF7,(uint8_t)0xD3,(uint8_t)0xF7,(uint8_t)0xD3,(uint8_t)0xF7}
515 #define MIFARE_KEY_LENGTH 6
516
517 typedef enum
518 {
519         NET_NFC_FELICA_POLL_NO_REQUEST = 0x00,
520         NET_NFC_FELICA_POLL_SYSTEM_CODE_REQUEST,
521         NET_NFC_FELICA_POLL_COMM_SPEED_REQUEST,
522         NET_NFC_FELICA_POLL_MAX = 0xFF,
523 } net_nfc_felica_poll_request_code_e;
524
525 /**
526   WIFI configuration key enums for connection handover.
527   */
528
529 typedef enum
530 {
531         NET_NFC_WIFI_ATTRIBUTE_VERSION = 0x104A,
532         NET_NFC_WIFI_ATTRIBUTE_CREDENTIAL = 0x100E,
533         NET_NFC_WIFI_ATTRIBUTE_NET_INDEX = 0x1026,
534         NET_NFC_WIFI_ATTRIBUTE_SSID = 0x1045,
535         NET_NFC_WIFI_ATTRIBUTE_AUTH_TYPE = 0x1003, /*< WPA2PSK  0x0020 */
536         NET_NFC_WIFI_ATTRIBUTE_ENC_TYPE = 0x100F, /*< AES                       0x0008 */
537         NET_NFC_WIFI_ATTRIBUTE_NET_KEY = 0x1027,
538         NET_NFC_WIFI_ATTRIBUTE_MAC_ADDR = 0x1020,
539         NET_NFC_WIFI_ATTRIBUTE_CHANNEL = 0x1001, /* Channel number - based on IEEE */
540         NET_NFC_WIFI_ATTRIBUTE_VEN_EXT = 0x1049,
541         NET_NFC_WIFI_ATTRIBUTE_VERSION2 = 0x00,
542 } net_nfc_carrier_wifi_attribute_e;
543
544 typedef enum
545 {
546         NET_NFC_BT_ATTRIBUTE_UUID16_PART = 0x02, /* More 16-bit UUIDs available */
547         NET_NFC_BT_ATTRIBUTE_UUID16 = 0x03, /* Complete list of 16-bit UUIDs */
548         NET_NFC_BT_ATTRIBUTE_UUID32_PART = 0x04, /* More 32-bit UUIDs available */
549         NET_NFC_BT_ATTRIBUTE_UUID32 = 0x05, /* Complete list of 32-bit UUIDs */
550         NET_NFC_BT_ATTRIBUTE_UUID128_PART = 0x06, /* More 128-bit UUIDs available */
551         NET_NFC_BT_ATTRIBUTE_UUID128 = 0x07, /* Complete list of 128-bit UUIDs */
552         NET_NFC_BT_ATTRIBUTE_NAME_PART = 0x08, /* Shortened local name */
553         NET_NFC_BT_ATTRIBUTE_NAME = 0x09, /* Complete local name */
554         NET_NFC_BT_ATTRIBUTE_TXPOWER = 0x0a, /* TX Power level */
555         NET_NFC_BT_ATTRIBUTE_OOB_COD = 0x0d, /* SSP OOB Class of Device */
556         NET_NFC_BT_ATTRIBUTE_OOB_HASH_C = 0x0e, /* SSP OOB Hash C */
557         NET_NFC_BT_ATTRIBUTE_OOB_HASH_R = 0x0f, /* SSP OOB Randomizer R */
558         NET_NFC_BT_ATTRIBUTE_ID = 0x10, /* Device ID */
559         NET_NFC_BT_ATTRIBUTE_MANUFACTURER = 0xFF, /* Manufacturer Specific Data */
560         NET_NFC_BT_ATTRIBUTE_ADDRESS = 0xF0, /* Bluetooth device Address */
561 } net_nfc_handover_bt_attribute_e;
562
563 typedef struct _net_nfc_carrier_config_s
564 {
565         net_nfc_conn_handover_carrier_type_e type;
566         int length;
567         GList *data;
568 } net_nfc_carrier_config_s;
569
570 /* WIFI Info */
571 typedef struct _net_nfc_carrier_property_s
572 {
573         bool is_group;
574         uint16_t attribute;
575         uint16_t length;
576         void *data;
577 } net_nfc_carrier_property_s;
578
579 typedef enum
580 {
581         NET_NFC_SE_TYPE_NONE = 0x00,/**< Invalid */
582         NET_NFC_SE_TYPE_ESE = 0x01,/**< SmartMX */
583         NET_NFC_SE_TYPE_UICC = 0x02,/**< UICC */
584         NET_NFC_SE_TYPE_SDCARD = 0x03, /* SDCard type is not currently supported */
585 } net_nfc_se_type_e;
586
587 typedef enum
588 {
589         NET_NFC_SIGN_TYPE_NO_SIGN = 0,
590         NET_NFC_SIGN_TYPE_PKCS_1,
591         NET_NFC_SIGN_TYPE_PKCS_1_V_1_5,
592         NET_NFC_SIGN_TYPE_DSA,
593         NET_NFC_SIGN_TYPE_ECDSA,
594         NET_NFC_MAX_SIGN_TYPE,
595 } net_nfc_sign_type_t;
596
597 typedef enum
598 {
599         NET_NFC_CERT_FORMAT_X_509 = 0,
600         NET_NFC_CERT_FORMAT_X9_86,
601         NET_NFC_MAX_CERT_FORMAT,
602 } net_nfc_cert_format_t;
603
604 typedef enum
605 {
606         NET_NFC_SNEP_GET = 1,
607         NET_NFC_SNEP_PUT = 2,
608 } net_nfc_snep_type_t;
609
610 typedef enum
611 {
612         NET_NFC_LLCP_REGISTERED = -1,
613         NET_NFC_LLCP_UNREGISTERED = -2,
614         NET_NFC_LLCP_START  = -3,
615         NET_NFC_LLCP_STOP  = -4,
616 }net_nfc_llcp_state_t;
617
618 typedef enum
619 {
620         NET_NFC_CARD_EMELATION_ENABLE = 0,
621         NET_NFC_CARD_EMULATION_DISABLE,
622 }net_nfc_card_emulation_mode_t;
623
624 typedef enum
625 {
626         NET_NFC_NO_LAUNCH_APP_SELECT = 0,
627         NET_NFC_LAUNCH_APP_SELECT,
628 } net_nfc_launch_popup_state_e;
629
630 /**
631   @}
632   */
633
634 #endif //__NET_NFC_TYPEDEF_H__