diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2011-03-14 19:10:56 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2011-03-15 10:35:40 +0200 |
commit | 3ed993262f2e172971fabb13aea9cf5d28bd9ed3 (patch) | |
tree | 4b1389aaa66e70db7d0ae12d6873f41125fbdc1e /lib/uuid.h | |
parent | a709b2119b47cca71dca79d11b8705f752ed3295 (diff) | |
download | bluez-3ed993262f2e172971fabb13aea9cf5d28bd9ed3.tar.gz |
Add new UUID utility functions
New UUID functions will store the UUIDs values on host order. Added
functions to create, compare and convert UUIDs.
Diffstat (limited to 'lib/uuid.h')
-rw-r--r-- | lib/uuid.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/uuid.h b/lib/uuid.h new file mode 100644 index 000000000..01457dadd --- /dev/null +++ b/lib/uuid.h @@ -0,0 +1,62 @@ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2011 Nokia Corporation + * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __BLUETOOTH_UUID_H +#define __BLUETOOTH_UUID_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +typedef struct { + uint8_t data[16]; +} uint128_t; + +typedef struct { + enum { + BT_UUID16 = 16, + BT_UUID32 = 32, + BT_UUID128 = 128, + } type; + union { + uint16_t u16; + uint32_t u32; + uint128_t u128; + } value; +} bt_uuid_t; + +int bt_uuid16_create(bt_uuid_t *btuuid, uint16_t value); +int bt_uuid32_create(bt_uuid_t *btuuid, uint32_t value); +int bt_uuid128_create(bt_uuid_t *btuuid, uint128_t value); + +int bt_uuid_cmp(const bt_uuid_t *uuid1, const bt_uuid_t *uuid2); +void bt_uuid_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLUETOOTH_UUID_H */ |