PHDC P2P Handling
[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 typedef enum
394 {
395         NET_NFC_PHDC_UNKNOWN = 0x00,
396         NET_NFC_PHDC_MANAGER ,
397         NET_NFC_PHDC_AGENT,
398 } net_nfc_phdc_role_e;
399
400
401 /**
402   This structure is just data, to express bytes array
403  */
404 typedef struct
405 {
406         uint8_t *buffer;
407         uint32_t length;
408 } data_s;
409
410 /**
411   ndef_record_s structure has the NDEF record data. it is only a record not a message
412   */
413 typedef struct _ndef_record_s
414 {
415         uint8_t MB :1;
416         uint8_t ME :1;
417         uint8_t CF :1;
418         uint8_t SR :1;
419         uint8_t IL :1;
420         uint8_t TNF :3;
421         data_s type_s;
422         data_s id_s;
423         data_s payload_s;
424         struct _ndef_record_s *next;
425 }ndef_record_s;
426
427 /**
428   NDEF message it has record counts and records (linked listed form)
429   */
430 typedef struct _ndef_message_s
431 {
432         uint32_t recordCount;
433         ndef_record_s *records; // linked list
434 } ndef_message_s;
435
436 typedef struct _net_nfc_target_handle_s
437 {
438         uint32_t connection_id;
439         net_nfc_connection_type_e connection_type;
440         net_nfc_target_type_e target_type;
441         /*++npp++*/
442         llcp_app_protocol_e app_type;
443         /*--npp--*/
444 }net_nfc_target_handle_s;
445
446 typedef struct _net_nfc_tag_info_s
447 {
448         char *key;
449         data_s *value;
450 } net_nfc_tag_info_s;
451
452 typedef struct _net_nfc_target_info_s
453 {
454         net_nfc_target_handle_s *handle;
455         net_nfc_target_type_e devType;
456         uint8_t is_ndef_supported;
457         uint8_t ndefCardState;
458         uint32_t maxDataSize;
459         uint32_t actualDataSize;
460         int number_of_keys;
461         net_nfc_tag_info_s *tag_info_list;
462         char **keylist;
463         data_s raw_data;
464 }net_nfc_target_info_s;
465
466 typedef struct _net_nfc_llcp_config_info_s
467 {
468         uint16_t miu; /** The remote Maximum Information Unit (NOTE: this is MIU, not MIUX !)*/
469         uint16_t wks; /** The remote Well-Known Services*/
470         uint8_t lto; /** The remote Link TimeOut (in 1/100s)*/
471         uint8_t option; /** The remote options*/
472 }net_nfc_llcp_config_info_s;
473
474 typedef struct _net_nfc_llcp_socket_option_s
475 {
476         uint16_t miu; /** The remote Maximum Information Unit */
477         uint8_t rw; /** The Receive Window size (4 bits)*/
478         net_nfc_socket_type_e type;
479 }net_nfc_llcp_socket_option_s;
480
481 typedef struct _net_nfc_connection_handover_info_s
482 {
483         net_nfc_conn_handover_carrier_type_e type;
484         data_s data;
485 }net_nfc_connection_handover_info_s;
486
487 typedef uint8_t sap_t;
488
489 typedef uint32_t net_nfc_llcp_socket_t;
490
491 typedef void *net_nfc_snep_handle_h;
492
493 typedef void *net_nfc_phdc_handle_h;
494
495
496 // LLCP Callback
497 typedef void (*net_nfc_llcp_socket_cb)(net_nfc_llcp_message_e message,
498                 net_nfc_error_e result, void *data, void *user_data, void *trans_data);
499
500 // Main Callback
501 typedef void (*net_nfc_response_cb)(net_nfc_message_e message,
502                 net_nfc_error_e result, void *data, void *user_param, void *trans_data);
503
504 typedef void (*net_nfc_internal_se_response_cb)(net_nfc_message_e message,
505                 net_nfc_error_e result, void *data, void *user_param, void *trans_data);
506
507 typedef void (* net_nfc_set_activation_completed_cb)(net_nfc_error_e error,
508                 void *user_data);
509
510 // handover
511
512 typedef enum
513 {
514         NET_NFC_CONN_HANDOVER_CARRIER_INACTIVATE = 0x00,
515         NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATE,
516         NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATING,
517         NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN_STATUS,
518 } net_nfc_conn_handover_carrier_state_e;
519
520 typedef struct _net_nfc_conn_handover_carrier_info_s *net_nfc_conn_handover_carrier_info_h;
521 typedef struct _net_nfc_conn_handover_info_s *net_nfc_conn_handover_info_h;
522
523 #define MIFARE_KEY_DEFAULT {(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF,(uint8_t)0xFF}
524 #define MIFARE_KEY_APPLICATION_DIRECTORY {(uint8_t)0xA0,(uint8_t)0xA1,(uint8_t)0xA2,(uint8_t)0xA3,(uint8_t)0xA4,(uint8_t)0xA5}
525 #define MIFARE_KEY_NET_NFC_FORUM {(uint8_t)0xD3,(uint8_t)0xF7,(uint8_t)0xD3,(uint8_t)0xF7,(uint8_t)0xD3,(uint8_t)0xF7}
526 #define MIFARE_KEY_LENGTH 6
527
528 typedef enum
529 {
530         NET_NFC_FELICA_POLL_NO_REQUEST = 0x00,
531         NET_NFC_FELICA_POLL_SYSTEM_CODE_REQUEST,
532         NET_NFC_FELICA_POLL_COMM_SPEED_REQUEST,
533         NET_NFC_FELICA_POLL_MAX = 0xFF,
534 } net_nfc_felica_poll_request_code_e;
535
536 /**
537   WIFI configuration key enums for connection handover.
538   */
539
540 typedef enum
541 {
542         NET_NFC_WIFI_ATTRIBUTE_VERSION = 0x104A,
543         NET_NFC_WIFI_ATTRIBUTE_CREDENTIAL = 0x100E,
544         NET_NFC_WIFI_ATTRIBUTE_NET_INDEX = 0x1026,
545         NET_NFC_WIFI_ATTRIBUTE_SSID = 0x1045,
546         NET_NFC_WIFI_ATTRIBUTE_AUTH_TYPE = 0x1003, /*< WPA2PSK  0x0020 */
547         NET_NFC_WIFI_ATTRIBUTE_ENC_TYPE = 0x100F, /*< AES                       0x0008 */
548         NET_NFC_WIFI_ATTRIBUTE_NET_KEY = 0x1027,
549         NET_NFC_WIFI_ATTRIBUTE_MAC_ADDR = 0x1020,
550         NET_NFC_WIFI_ATTRIBUTE_CHANNEL = 0x1001, /* Channel number - based on IEEE */
551         NET_NFC_WIFI_ATTRIBUTE_VEN_EXT = 0x1049,
552         NET_NFC_WIFI_ATTRIBUTE_VERSION2 = 0x00,
553 } net_nfc_carrier_wifi_attribute_e;
554
555 typedef enum
556 {
557         NET_NFC_BT_ATTRIBUTE_UUID16_PART = 0x02, /* More 16-bit UUIDs available */
558         NET_NFC_BT_ATTRIBUTE_UUID16 = 0x03, /* Complete list of 16-bit UUIDs */
559         NET_NFC_BT_ATTRIBUTE_UUID32_PART = 0x04, /* More 32-bit UUIDs available */
560         NET_NFC_BT_ATTRIBUTE_UUID32 = 0x05, /* Complete list of 32-bit UUIDs */
561         NET_NFC_BT_ATTRIBUTE_UUID128_PART = 0x06, /* More 128-bit UUIDs available */
562         NET_NFC_BT_ATTRIBUTE_UUID128 = 0x07, /* Complete list of 128-bit UUIDs */
563         NET_NFC_BT_ATTRIBUTE_NAME_PART = 0x08, /* Shortened local name */
564         NET_NFC_BT_ATTRIBUTE_NAME = 0x09, /* Complete local name */
565         NET_NFC_BT_ATTRIBUTE_TXPOWER = 0x0a, /* TX Power level */
566         NET_NFC_BT_ATTRIBUTE_OOB_COD = 0x0d, /* SSP OOB Class of Device */
567         NET_NFC_BT_ATTRIBUTE_OOB_HASH_C = 0x0e, /* SSP OOB Hash C */
568         NET_NFC_BT_ATTRIBUTE_OOB_HASH_R = 0x0f, /* SSP OOB Randomizer R */
569         NET_NFC_BT_ATTRIBUTE_ID = 0x10, /* Device ID */
570         NET_NFC_BT_ATTRIBUTE_MANUFACTURER = 0xFF, /* Manufacturer Specific Data */
571         NET_NFC_BT_ATTRIBUTE_ADDRESS = 0xF0, /* Bluetooth device Address */
572 } net_nfc_handover_bt_attribute_e;
573
574 typedef struct _net_nfc_carrier_config_s
575 {
576         net_nfc_conn_handover_carrier_type_e type;
577         int length;
578         GList *data;
579 } net_nfc_carrier_config_s;
580
581 /* WIFI Info */
582 typedef struct _net_nfc_carrier_property_s
583 {
584         bool is_group;
585         uint16_t attribute;
586         uint16_t length;
587         void *data;
588 } net_nfc_carrier_property_s;
589
590 typedef enum
591 {
592         NET_NFC_SE_TYPE_NONE = 0x00,/**< Invalid */
593         NET_NFC_SE_TYPE_ESE = 0x01,/**< SmartMX */
594         NET_NFC_SE_TYPE_UICC = 0x02,/**< UICC */
595         NET_NFC_SE_TYPE_SDCARD = 0x03, /* SDCard type is not currently supported */
596 } net_nfc_se_type_e;
597
598 typedef enum
599 {
600         NET_NFC_SIGN_TYPE_NO_SIGN = 0,
601         NET_NFC_SIGN_TYPE_PKCS_1,
602         NET_NFC_SIGN_TYPE_PKCS_1_V_1_5,
603         NET_NFC_SIGN_TYPE_DSA,
604         NET_NFC_SIGN_TYPE_ECDSA,
605         NET_NFC_MAX_SIGN_TYPE,
606 } net_nfc_sign_type_t;
607
608 typedef enum
609 {
610         NET_NFC_CERT_FORMAT_X_509 = 0,
611         NET_NFC_CERT_FORMAT_X9_86,
612         NET_NFC_MAX_CERT_FORMAT,
613 } net_nfc_cert_format_t;
614
615 typedef enum
616 {
617         NET_NFC_SNEP_GET = 1,
618         NET_NFC_SNEP_PUT = 2,
619 } net_nfc_snep_type_t;
620
621 typedef enum
622 {
623         NET_NFC_LLCP_REGISTERED = -1,
624         NET_NFC_LLCP_UNREGISTERED = -2,
625         NET_NFC_LLCP_START  = -3,
626         NET_NFC_LLCP_STOP  = -4,
627 }net_nfc_llcp_state_t;
628
629 typedef enum
630 {
631         NET_NFC_CARD_EMELATION_ENABLE = 0,
632         NET_NFC_CARD_EMULATION_DISABLE,
633 }net_nfc_card_emulation_mode_t;
634
635 typedef enum
636 {
637         NET_NFC_NO_LAUNCH_APP_SELECT = 0,
638         NET_NFC_LAUNCH_APP_SELECT,
639 } net_nfc_launch_popup_state_e;
640
641 /**
642   @}
643   */
644
645 #endif //__NET_NFC_TYPEDEF_H__