tizen 2.3.1 release
[framework/connectivity/bluez.git] / src / eir.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2011  Nokia Corporation
6  *  Copyright (C) 2011  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 EIR_FLAGS                   0x01  /* flags */
26 #define EIR_UUID16_SOME             0x02  /* 16-bit UUID, more available */
27 #define EIR_UUID16_ALL              0x03  /* 16-bit UUID, all listed */
28 #define EIR_UUID32_SOME             0x04  /* 32-bit UUID, more available */
29 #define EIR_UUID32_ALL              0x05  /* 32-bit UUID, all listed */
30 #define EIR_UUID128_SOME            0x06  /* 128-bit UUID, more available */
31 #define EIR_UUID128_ALL             0x07  /* 128-bit UUID, all listed */
32 #define EIR_NAME_SHORT              0x08  /* shortened local name */
33 #define EIR_NAME_COMPLETE           0x09  /* complete local name */
34 #define EIR_TX_POWER                0x0A  /* transmit power level */
35 #define EIR_CLASS_OF_DEV            0x0D  /* Class of Device */
36 #define EIR_SSP_HASH                0x0E  /* SSP Hash */
37 #define EIR_SSP_RANDOMIZER          0x0F  /* SSP Randomizer */
38 #define EIR_DEVICE_ID               0x10  /* device ID */
39 #define EIR_GAP_APPEARANCE          0x19  /* GAP appearance */
40 #define EIR_MANUFACTURER_DATA       0xFF  /* Manufacturer Specific Data */
41
42 /* Flags Descriptions */
43 #define EIR_LIM_DISC                0x01 /* LE Limited Discoverable Mode */
44 #define EIR_GEN_DISC                0x02 /* LE General Discoverable Mode */
45 #define EIR_BREDR_UNSUP             0x04 /* BR/EDR Not Supported */
46 #define EIR_CONTROLLER              0x08 /* Simultaneous LE and BR/EDR to Same
47                                             Device Capable (Controller) */
48 #define EIR_SIM_HOST                0x10 /* Simultaneous LE and BR/EDR to Same
49                                             Device Capable (Host) */
50
51 #define EIR_MSD_MAX_LEN             236  /* 240 (EIR) - 2 (len & type) - 2 */
52
53 struct eir_msd {
54         uint16_t company;
55         uint8_t data[EIR_MSD_MAX_LEN];
56         uint8_t data_len;
57 };
58
59 struct eir_data {
60         GSList *services;
61         unsigned int flags;
62         char *name;
63         uint32_t class;
64         uint16_t appearance;
65         bool name_complete;
66         int8_t tx_power;
67         uint8_t *hash;
68         uint8_t *randomizer;
69         bdaddr_t addr;
70         uint16_t did_vendor;
71         uint16_t did_product;
72         uint16_t did_version;
73         uint16_t did_source;
74         GSList *msd_list;
75 #ifdef __TIZEN_PATCH__
76         char *manufacturer_data;
77         uint8_t manufacturer_data_len;
78 #endif
79 };
80
81 void eir_data_free(struct eir_data *eir);
82 void eir_parse(struct eir_data *eir, const uint8_t *eir_data, uint8_t eir_len);
83 int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len);
84 int eir_create_oob(const bdaddr_t *addr, const char *name, uint32_t cod,
85                         const uint8_t *hash, const uint8_t *randomizer,
86                         uint16_t did_vendor, uint16_t did_product,
87                         uint16_t did_version, uint16_t did_source,
88                         sdp_list_t *uuids, uint8_t *data);