Upgrade bluez5_37 :Merge the code from private
[platform/upstream/bluez.git] / src / shared / ad.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2015  Google Inc.
6  *
7  *
8  *  This library is free software; you can redistribute it and/or
9  *  modify it under the terms of the GNU Lesser General Public
10  *  License as published by the Free Software Foundation; either
11  *  version 2.1 of the License, or (at your option) any later version.
12  *
13  *  This library is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  *  Lesser General Public License for more details.
17  *
18  *  You should have received a copy of the GNU Lesser General Public
19  *  License along with this library; if not, write to the Free Software
20  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23
24 #include <inttypes.h>
25 #include <stdbool.h>
26
27 #include "lib/bluetooth.h"
28 #include "lib/uuid.h"
29
30 typedef void (*bt_ad_func_t)(void *data, void *user_data);
31
32 struct bt_ad;
33
34 struct bt_ad_manufacturer_data {
35         uint16_t manufacturer_id;
36         uint8_t *data;
37         size_t len;
38 };
39
40 struct bt_ad_service_data {
41         bt_uuid_t uuid;
42         uint8_t *data;
43         size_t len;
44 };
45
46 struct bt_ad *bt_ad_new(void);
47
48 struct bt_ad *bt_ad_ref(struct bt_ad *ad);
49
50 void bt_ad_unref(struct bt_ad *ad);
51
52 uint8_t *bt_ad_generate(struct bt_ad *ad, size_t *length);
53
54 bool bt_ad_add_service_uuid(struct bt_ad *ad, const bt_uuid_t *uuid);
55
56 bool bt_ad_remove_service_uuid(struct bt_ad *ad, bt_uuid_t *uuid);
57
58 void bt_ad_clear_service_uuid(struct bt_ad *ad);
59
60 bool bt_ad_add_manufacturer_data(struct bt_ad *ad, uint16_t manufacturer_data,
61                                                 void *data, size_t len);
62
63 bool bt_ad_has_manufacturer_data(struct bt_ad *ad,
64                                 const struct bt_ad_manufacturer_data *data);
65
66 void bt_ad_foreach_manufacturer_data(struct bt_ad *ad, bt_ad_func_t func,
67                                                         void *user_data);
68
69 bool bt_ad_remove_manufacturer_data(struct bt_ad *ad, uint16_t manufacturer_id);
70
71 void bt_ad_clear_manufacturer_data(struct bt_ad *ad);
72
73 bool bt_ad_add_solicit_uuid(struct bt_ad *ad, const bt_uuid_t *uuid);
74
75 bool bt_ad_remove_solicit_uuid(struct bt_ad *ad, bt_uuid_t *uuid);
76
77 void bt_ad_clear_solicit_uuid(struct bt_ad *ad);
78
79 bool bt_ad_add_service_data(struct bt_ad *ad, const bt_uuid_t *uuid, void *data,
80                                                                 size_t len);
81
82 bool bt_ad_has_service_data(struct bt_ad *ad,
83                                         const struct bt_ad_service_data *data);
84
85 void bt_ad_foreach_service_data(struct bt_ad *ad, bt_ad_func_t func,
86                                                         void *user_data);
87
88 bool bt_ad_remove_service_data(struct bt_ad *ad, bt_uuid_t *uuid);
89
90 void bt_ad_clear_service_data(struct bt_ad *ad);