Get the latest NFC state from neard
[platform/core/connectivity/nfc-manager-neard.git] / common / net_nfc_util_internal.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_UTIL_INTERNAL_H__
17 #define __NET_NFC_UTIL_INTERNAL_H__
18
19 #include <stdio.h>
20 #include <libgen.h>
21 #include <netinet/in.h>
22
23 /* For multi-user support */
24 #include <tzplatform_config.h>
25
26 #include "net_nfc_typedef_internal.h"
27
28 #define NET_NFC_MANAGER_DATA_PATH                       tzplatform_mkpath(TZ_SYS_DATA, "nfc-manager-daemon")
29 #define NET_NFC_MANAGER_DATA_PATH_MESSAGE       "message"
30 #define NET_NFC_MANAGER_NDEF_FILE_NAME          "ndef-message.txt"
31
32
33 typedef enum
34 {
35         CRC_A = 0x00,
36         CRC_B,
37 } CRC_type_e;
38
39 void net_nfc_change_log_tag();
40
41 /* Memory utils */
42 /* allocation memory */
43 void __net_nfc_util_alloc_mem(void **mem, int size, char *filename, unsigned int line);
44 #define  _net_nfc_util_alloc_mem(mem,size) __net_nfc_util_alloc_mem((void **)&mem,size, basename(__FILE__), __LINE__)
45
46 /* allocation memory */
47 void __net_nfc_util_strdup(char **output, const char *origin, char *filename, unsigned int line);
48 #define  _net_nfc_util_strdup(output, origin) __net_nfc_util_strdup(&output, origin, basename(__FILE__), __LINE__)
49
50 /* free memory, after free given memory it set NULL. Before proceed free, this function also check NULL */
51 void __net_nfc_util_free_mem(void **mem, char *filename, unsigned int line);
52 #define  _net_nfc_util_free_mem(mem) __net_nfc_util_free_mem((void **)&mem, basename(__FILE__), __LINE__)
53
54 bool net_nfc_util_alloc_data(data_s *data, uint32_t length);
55 void net_nfc_util_free_data(data_s *data);
56
57 net_nfc_conn_handover_carrier_state_e net_nfc_util_get_cps(net_nfc_conn_handover_carrier_type_e carrier_type);
58
59 uint8_t *net_nfc_util_get_local_bt_address();
60 void net_nfc_util_enable_bluetooth(void);
61
62 bool net_nfc_util_strip_string(char *buffer, int buffer_length);
63
64 void net_nfc_util_compute_CRC(CRC_type_e CRC_type, uint8_t *buffer, uint32_t length);
65
66 const char *net_nfc_util_get_schema_string(int index);
67
68 #endif //__NET_NFC_UTIL_INTERNAL_H__