46 .
data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
47 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB }
50 #define BASE_UUID16_OFFSET 2
51 #define BASE_UUID32_OFFSET 0
58 dst->
type = BT_UUID128;
74 dst->
type = BT_UUID128;
111 btuuid->
type = BT_UUID16;
120 btuuid->
type = BT_UUID32;
129 btuuid->
type = BT_UUID128;
151 snprintf(str, n,
"NULL");
155 switch (uuid->
type) {
157 snprintf(str, n,
"%.4x", uuid->
value.
u16);
160 snprintf(str, n,
"%.8x", uuid->
value.
u32);
164 unsigned short data1;
165 unsigned short data2;
166 unsigned short data3;
168 unsigned short data5;
170 const uint8_t *data = (uint8_t *) &uuid->
value.
u128;
172 memcpy(&data0, &data[0], 4);
173 memcpy(&data1, &data[4], 2);
174 memcpy(&data2, &data[6], 2);
175 memcpy(&data3, &data[8], 2);
176 memcpy(&data4, &data[10], 4);
177 memcpy(&data5, &data[14], 2);
179 snprintf(str, n,
"%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
180 ntohl(data0), ntohs(data1),
181 ntohs(data2), ntohs(data3),
182 ntohl(data4), ntohs(data5));
187 snprintf(str, n,
"Type of UUID (%x) unknown.", uuid->
type);
196 return (strlen(
string) == 36 &&
211 return sscanf(
string,
212 "0000%04hx-0000-1000-8000-00805%1[fF]9%1[bB]34%1[fF]%1[bB]",
213 &uuid, &dummy, &dummy, &dummy, &dummy) == 5;
218 return (strlen(
string) == 8 || strlen(
string) == 10);
223 return (strlen(
string) == 4 || strlen(
string) == 6);
231 u16 = strtol(
string, &endptr, 16);
232 if (endptr && (*endptr ==
'\0' || *endptr ==
'-')) {
245 u32 = strtol(
string, &endptr, 16);
246 if (endptr && *endptr ==
'\0') {
256 uint32_t data0, data4;
257 uint16_t data1, data2, data3, data5;
259 uint8_t *val = (uint8_t *) &u128;
261 if (sscanf(
string,
"%08x-%04hx-%04hx-%04hx-%08x%04hx",
262 &data0, &data1, &data2,
263 &data3, &data4, &data5) != 6)
266 data0 = htonl(data0);
267 data1 = htons(data1);
268 data2 = htons(data2);
269 data3 = htons(data3);
270 data4 = htonl(data4);
271 data5 = htons(data5);
273 memcpy(&val[0], &data0, 4);
274 memcpy(&val[4], &data1, 2);
275 memcpy(&val[6], &data2, 2);
276 memcpy(&val[8], &data3, 2);
277 memcpy(&val[10], &data4, 4);
278 memcpy(&val[14], &data5, 2);
301 return strcasecmp(a, b);
int bt_uuid_strcmp(const void *a, const void *b)
int bt_uuid32_create(bt_uuid_t *btuuid, uint32_t value)
int bt_string_to_uuid(bt_uuid_t *uuid, const char *string)
void bt_uuid_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
union bt_uuid_t::@8 value
static int is_uuid128(const char *string)
int bt_uuid_cmp(const bt_uuid_t *uuid1, const bt_uuid_t *uuid2)
static int bt_string_to_uuid16(bt_uuid_t *uuid, const char *string)
static int bt_string_to_uuid128(bt_uuid_t *uuid, const char *string)
static int is_uuid16(const char *string)
static int is_uuid32(const char *string)
static void bswap_128(const void *src, void *dst)
int bt_uuid16_create(bt_uuid_t *btuuid, uint16_t value)
static int is_base_uuid128(const char *string)
static uint128_t bluetooth_base_uuid
#define BASE_UUID16_OFFSET
static int bt_uuid128_cmp(const bt_uuid_t *u1, const bt_uuid_t *u2)
static int bt_string_to_uuid32(bt_uuid_t *uuid, const char *string)
int bt_uuid_to_le(const bt_uuid_t *src, void *dst)
static void bt_uuid16_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
static void bt_uuid32_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
static void bt_put_le16(uint16_t val, const void *ptr)
#define BASE_UUID32_OFFSET
int bt_uuid128_create(bt_uuid_t *btuuid, uint128_t value)
int bt_uuid_to_string(const bt_uuid_t *uuid, char *str, size_t n)