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