Listen and process remote name resolving failure
[platform/upstream/bluez.git] / src / device.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *
4  *  BlueZ - Bluetooth protocol stack for Linux
5  *
6  *  Copyright (C) 2006-2010  Nokia Corporation
7  *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
8  *
9  *
10  */
11
12 #define DEVICE_INTERFACE        "org.bluez.Device1"
13
14 struct btd_device;
15
16 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
17 /* Device Physical channel connection Type */
18 #define DEV_CONN_DEFAULT 0xFF /* Represents support for BREDR and LE */
19 #define DEV_CONN_BREDR 0x00 /* Only BREDR */
20 #define DEV_CONN_LE 0x01 /* Only LE*/
21 #endif
22
23 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
24 #define L2CAP_LE_UUID_SUBSTR "FFFFFFFF-FFFF-FFFF-FFFF-"
25 DBusMessage *get_psm_l2cap_le(DBusConnection *conn, DBusMessage *msg);
26 DBusMessage *remove_l2cap_le_socket(DBusConnection *conn, DBusMessage *msg);
27 DBusMessage *listen_l2cap_le_socket(DBusConnection *conn, DBusMessage *msg,
28                                                         void *user_data);
29 #endif
30
31 struct btd_device *device_create(struct btd_adapter *adapter,
32                                 const bdaddr_t *address, uint8_t bdaddr_type);
33 struct btd_device *device_create_from_storage(struct btd_adapter *adapter,
34                                 const char *address, GKeyFile *key_file);
35 char *btd_device_get_storage_path(struct btd_device *device,
36                                 const char *filename);
37
38 void btd_device_device_set_name(struct btd_device *device, const char *name);
39 void device_store_cached_name(struct btd_device *dev, const char *name);
40 void device_get_name(struct btd_device *device, char *name, size_t len);
41 bool device_name_known(struct btd_device *device);
42 bool device_is_name_resolve_allowed(struct btd_device *device);
43 void device_name_resolve_fail(struct btd_device *device);
44 void device_set_class(struct btd_device *device, uint32_t class);
45 void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
46                                                         uint8_t bdaddr_type);
47 void device_set_bredr_support(struct btd_device *device);
48 void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type);
49 void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type);
50 void device_merge_duplicate(struct btd_device *dev, struct btd_device *dup);
51 uint32_t btd_device_get_class(struct btd_device *device);
52 uint16_t btd_device_get_vendor(struct btd_device *device);
53 uint16_t btd_device_get_vendor_src(struct btd_device *device);
54 uint16_t btd_device_get_product(struct btd_device *device);
55 uint16_t btd_device_get_version(struct btd_device *device);
56 void device_remove_bonding(struct btd_device *device, uint8_t bdaddr_type);
57 void device_remove(struct btd_device *device, gboolean remove_stored);
58 int device_address_cmp(gconstpointer a, gconstpointer b);
59 int device_bdaddr_cmp(gconstpointer a, gconstpointer b);
60
61 /* Struct used by device_addr_type_cmp() */
62 struct device_addr_type {
63         bdaddr_t bdaddr;
64         uint8_t bdaddr_type;
65 };
66
67 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
68 int device_addr_type_strict_cmp(gconstpointer a, gconstpointer b);
69 #endif
70 int device_addr_type_cmp(gconstpointer a, gconstpointer b);
71 GSList *btd_device_get_uuids(struct btd_device *device);
72 void device_probe_profiles(struct btd_device *device, GSList *profiles);
73
74 void btd_device_set_record(struct btd_device *device, const char *uuid,
75                                                         const char *record);
76 const sdp_record_t *btd_device_get_record(struct btd_device *device,
77                                                 const char *uuid);
78 struct gatt_primary *btd_device_get_primary(struct btd_device *device,
79                                                         const char *uuid);
80 GSList *btd_device_get_primaries(struct btd_device *device);
81 struct gatt_db *btd_device_get_gatt_db(struct btd_device *device);
82 struct bt_gatt_client *btd_device_get_gatt_client(struct btd_device *device);
83 struct bt_gatt_server *btd_device_get_gatt_server(struct btd_device *device);
84 void *btd_device_get_attrib(struct btd_device *device);
85 void btd_device_gatt_set_service_changed(struct btd_device *device,
86                                                 uint16_t start, uint16_t end);
87 bool device_attach_att(struct btd_device *dev, GIOChannel *io);
88 void btd_device_add_uuid(struct btd_device *device, const char *uuid);
89 void device_add_eir_uuids(struct btd_device *dev, GSList *uuids);
90 void device_set_manufacturer_data(struct btd_device *dev, GSList *list,
91                                                         bool duplicate);
92 void device_set_service_data(struct btd_device *dev, GSList *list,
93                                                         bool duplicate);
94 void device_set_data(struct btd_device *dev, GSList *list,
95                                                         bool duplicate);
96 void device_probe_profile(gpointer a, gpointer b);
97 void device_remove_profile(gpointer a, gpointer b);
98 struct btd_adapter *device_get_adapter(struct btd_device *device);
99 const bdaddr_t *device_get_address(struct btd_device *device);
100 uint8_t device_get_le_address_type(struct btd_device *device);
101 const char *device_get_path(const struct btd_device *device);
102 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
103 void device_set_remote_feature_flag(struct btd_device *device, int flags);
104 gboolean device_is_bredrle(struct btd_device *device);
105 void device_set_disconnect_reason(struct btd_device *device, uint8_t reason);
106 void device_set_gatt_connected(struct btd_device *device, gboolean connected);
107 void device_unpair(struct btd_device *device, gboolean remove_stored);
108 gboolean device_get_gatt_connected(const struct btd_device *device);
109 void device_set_rpa(struct btd_device *device, const bdaddr_t *rpa_addr);
110 const bdaddr_t *device_get_rpa(struct btd_device *device);
111 bool device_get_rpa_exist(struct btd_device *device);
112 int device_rpa_cmp(gconstpointer a, gconstpointer b);
113 int device_addr_cmp(gconstpointer a, gconstpointer b);
114 int device_rpa_ida_cmp(gconstpointer a, gconstpointer b);
115 void device_remove_stored_folder(struct btd_device *device);
116 const uint8_t *device_get_irk_value(struct btd_device *device);
117 void device_set_irk_value(struct btd_device *device, const uint8_t *val);
118 void device_set_conn_update_state(struct btd_device *device, bool state);
119 bool device_get_conn_update_state(struct btd_device *device);
120 void btd_device_set_trusted_profiles(struct btd_device *device,
121                 uint32_t pbap, uint32_t map, uint32_t sap,
122                 uint32_t hfp_hs, uint32_t a2dp);
123 void device_set_le_connectable(struct btd_device *device, uint8_t adv_type);
124 #endif
125 gboolean device_is_temporary(struct btd_device *device);
126 bool device_is_connectable(struct btd_device *device);
127 bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type);
128 bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type);
129 gboolean device_is_trusted(struct btd_device *device);
130 void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type);
131 void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type);
132 void btd_device_set_temporary(struct btd_device *device, bool temporary);
133 void btd_device_set_trusted(struct btd_device *device, gboolean trusted);
134 void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type);
135 void device_set_legacy(struct btd_device *device, bool legacy);
136 void device_set_rssi_with_delta(struct btd_device *device, int8_t rssi,
137                                                         int8_t delta_threshold);
138 void device_set_rssi(struct btd_device *device, int8_t rssi);
139 void device_set_tx_power(struct btd_device *device, int8_t tx_power);
140 void device_set_flags(struct btd_device *device, uint8_t flags);
141 bool btd_device_is_connected(struct btd_device *dev);
142 uint8_t btd_device_get_bdaddr_type(struct btd_device *dev);
143 bool device_is_retrying(struct btd_device *device);
144 void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
145                                                         uint8_t status);
146 gboolean device_is_bonding(struct btd_device *device, const char *sender);
147 void device_bonding_attempt_failed(struct btd_device *device, uint8_t status);
148 void device_bonding_failed(struct btd_device *device, uint8_t status);
149 struct btd_adapter_pin_cb_iter *device_bonding_iter(struct btd_device *device);
150 int device_bonding_attempt_retry(struct btd_device *device);
151 long device_bonding_last_duration(struct btd_device *device);
152 void device_bonding_restart_timer(struct btd_device *device);
153 int device_request_pincode(struct btd_device *device, gboolean secure);
154 int device_request_passkey(struct btd_device *device, uint8_t type);
155 int device_confirm_passkey(struct btd_device *device, uint8_t type,
156                                         int32_t passkey, uint8_t confirm_hint);
157 int device_notify_passkey(struct btd_device *device, uint8_t type,
158                                         uint32_t passkey, uint8_t entered);
159 int device_notify_pincode(struct btd_device *device, gboolean secure,
160                                                         const char *pincode);
161 void device_cancel_authentication(struct btd_device *device, gboolean aborted);
162 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
163 gboolean device_is_authenticating(struct btd_device *dev, uint8_t bdaddr_type);
164 #else
165 gboolean device_is_authenticating(struct btd_device *device);
166 #endif
167 void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type);
168 void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type);
169 void device_request_disconnect(struct btd_device *device, DBusMessage *msg);
170 bool device_is_disconnecting(struct btd_device *device);
171 void device_set_ltk_enc_size(struct btd_device *device, uint8_t enc_size);
172
173 void device_store_svc_chng_ccc(struct btd_device *device, uint8_t bdaddr_type,
174                                                                 uint16_t value);
175 void device_load_svc_chng_ccc(struct btd_device *device, uint16_t *ccc_le,
176                                                         uint16_t *ccc_bredr);
177
178 void device_set_wake_support(struct btd_device *device, bool wake_support);
179 void device_set_wake_override(struct btd_device *device, bool wake_override);
180 void device_set_wake_allowed(struct btd_device *device, bool wake_allowed,
181                              guint32 id);
182 void device_set_refresh_discovery(struct btd_device *dev, bool refresh);
183 typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal,
184                                         void *user_data);
185
186 guint device_add_disconnect_watch(struct btd_device *device,
187                                 disconnect_watch watch, void *user_data,
188                                 GDestroyNotify destroy);
189 void device_remove_disconnect_watch(struct btd_device *device, guint id);
190 int device_get_appearance(struct btd_device *device, uint16_t *value);
191 void device_set_appearance(struct btd_device *device, uint16_t value);
192
193 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
194 struct eir_data;
195 void device_set_manufacturer_info(struct btd_device *dev, struct eir_data *eir);
196 void device_set_adv_report_info(struct btd_device *device, void *data,
197                         uint8_t data_len, uint8_t adv_info, int8_t rssi);
198 void device_set_payload_timeout(struct btd_device *device,
199                         uint16_t payload_timeout);
200 void device_set_auth_addr_type(struct btd_device *device, uint8_t type);
201 void device_set_last_addr_type(struct btd_device *device, uint8_t type);
202 gboolean device_is_ipsp_connected(struct btd_device * device);
203 void device_set_ipsp_connected(struct btd_device *device, gboolean connected,
204                                                 const unsigned char *ifname);
205 int device_get_rpa_res_char_value(struct btd_device *device);
206 void device_set_rpa_res_char_value(struct btd_device *device, uint8_t value);
207 void device_le_data_length_changed(struct btd_device *device, uint16_t max_tx_octets,
208                         uint16_t max_tx_time, uint16_t max_rx_octets,
209                         uint16_t max_rx_time);
210 void device_get_tizen_addr(struct btd_device *device, uint8_t type,
211                            struct device_addr_type *addr);
212 #endif
213
214 struct btd_device *btd_device_ref(struct btd_device *device);
215 void btd_device_unref(struct btd_device *device);
216
217 int device_block(struct btd_device *device, gboolean update_only);
218 int device_unblock(struct btd_device *device, gboolean silent,
219                                                         gboolean update_only);
220 void btd_device_set_pnpid(struct btd_device *device, uint16_t source,
221                         uint16_t vendor, uint16_t product, uint16_t version);
222
223 int device_connect_le(struct btd_device *dev);
224
225 typedef void (*device_svc_cb_t) (struct btd_device *dev, int err,
226                                                         void *user_data);
227
228 unsigned int device_wait_for_svc_complete(struct btd_device *dev,
229                                                         device_svc_cb_t func,
230                                                         void *user_data);
231 bool device_remove_svc_complete_callback(struct btd_device *dev,
232                                                         unsigned int id);
233
234 struct btd_service *btd_device_get_service(struct btd_device *dev,
235                                                 const char *remote_uuid);
236
237 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
238 void device_print_addr(struct btd_device *dev);
239 gboolean device_is_profile_trusted(struct btd_device *device,
240                 const char *uuid);
241 gboolean device_is_profile_blocked(struct btd_device *device,
242                 const char *uuid);
243 void btd_device_disconnect(struct btd_device *dev);
244 void btd_device_set_legacy_pairing(struct btd_device *dev, bool legacy_pairing);
245 void btd_device_set_svc_changed_indication(struct btd_device *dev, bool value);
246 bool btd_device_get_svc_changed_indication(struct btd_device *dev);
247 #ifdef TIZEN_FEATURE_BLUEZ_BATTERY_WATCH
248 void device_change_pkt_type(gpointer data, gpointer user_data);
249 #endif  /* TIZEN_FEATURE_BLUEZ_BATTERY_WATCH */
250 #endif
251
252 int device_discover_services(struct btd_device *device);
253 int btd_device_connect_services(struct btd_device *dev, GSList *services);
254
255 uint32_t btd_device_get_current_flags(struct btd_device *dev);
256 void btd_device_flags_changed(struct btd_device *dev, uint32_t supported_flags,
257                               uint32_t current_flags);
258
259 bool btd_device_all_services_allowed(struct btd_device *dev);
260 void btd_device_update_allowed_services(struct btd_device *dev);
261 void btd_device_init(void);
262 void btd_device_cleanup(void);