summaryrefslogtreecommitdiffstats
path: root/lib/libsdp
diff options
context:
space:
mode:
authoremax <emax@FreeBSD.org>2005-05-27 19:11:33 +0000
committeremax <emax@FreeBSD.org>2005-05-27 19:11:33 +0000
commit720e9b2d9fb28b57fcae795d38e68d9396f1fb0c (patch)
tree4dbe1e40ae84309636c8070672a81ba7f90e84ca /lib/libsdp
parent9409f5e4f1cae0b940f05349a61181c1a50eda6f (diff)
downloadFreeBSD-src-720e9b2d9fb28b57fcae795d38e68d9396f1fb0c.zip
FreeBSD-src-720e9b2d9fb28b57fcae795d38e68d9396f1fb0c.tar.gz
Do not tread 128-bit UUID as int128. Provide separate macros to get/put
128-bit UUID libsdp(3). Fix 128-bit UUID printing in sdpcontrol(8). MFC after: 3 days
Diffstat (limited to 'lib/libsdp')
-rw-r--r--lib/libsdp/sdp.314
-rw-r--r--lib/libsdp/sdp.h55
-rw-r--r--lib/libsdp/util.c21
3 files changed, 81 insertions, 9 deletions
diff --git a/lib/libsdp/sdp.3 b/lib/libsdp/sdp.3
index c48b595..e80d0ac 100644
--- a/lib/libsdp/sdp.3
+++ b/lib/libsdp/sdp.3
@@ -34,11 +34,13 @@
.Nm SDP_GET32 ,
.Nm SDP_GET64 ,
.Nm SDP_GET128 ,
+.Nm SDP_GET_UUID128 ,
.Nm SDP_PUT8 ,
.Nm SDP_PUT16 ,
.Nm SDP_PUT32 ,
.Nm SDP_PUT64 ,
.Nm SDP_PUT128 ,
+.Nm SDP_PUT_UUID128 ,
.Nm sdp_open ,
.Nm sdp_open_local ,
.Nm sdp_close ,
@@ -57,11 +59,13 @@
.Fn SDP_GET32 "l" "cp"
.Fn SDP_GET64 "l" "cp"
.Fn SDP_GET128 "l" "cp"
+.Fn SDP_GET_UUID128 "l" "cp"
.Fn SDP_PUT8 "b" "cp"
.Fn SDP_PUT16 "s" "cp"
.Fn SDP_PUT32 "l" "cp"
.Fn SDP_PUT64 "l" "cp"
.Fn SDP_PUT128 "l" "cp"
+.Fn SDP_PUT_UUID128 "l" "cp"
.Ft "void *"
.Fn sdp_open "bdaddr_t const *l" "bdaddr_t const *r"
.Ft "void *"
@@ -117,6 +121,14 @@ into the buffer pointed by
pointer.
The pointer is automatically advanced.
.Pp
+.Fn SDP_GET_UUID128
+and
+.Fn SDP_PUT_UUID128
+macros are used to get and put 128-bit UUID into the buffer pointed by
+.Fa cp
+pointer.
+The pointer is automatically advanced.
+.Pp
The
.Fn sdp_open
and
@@ -359,7 +371,7 @@ sdp_attr_t proto = { SDP_ATTR_INVALID,0,sizeof(buffer),buffer };
if ((ss = sdp_open(NG_HCI_BDADDR_ANY, remote)) == NULL)
/* exit ENOMEM */
if (sdp_error(ss) != 0)
- /* exit spd_error(ss) */
+ /* exit sdp_error(ss) */
if (sdp_search(ss, 1, &serv, 1, &attr, 1, &proto) != 0)
/* exit sdp_error(ss) */
diff --git a/lib/libsdp/sdp.h b/lib/libsdp/sdp.h
index 42743f9..2b06b2c 100644
--- a/lib/libsdp/sdp.h
+++ b/lib/libsdp/sdp.h
@@ -360,9 +360,31 @@ typedef struct sdp_attr * sdp_attr_p;
(l)->b[3] = *t_cp++; \
(l)->b[2] = *t_cp++; \
(l)->b[1] = *t_cp++; \
+ (l)->b[0] = *t_cp++; \
+ (cp) += 16; \
+}
+
+#define SDP_GET_UUID128(l, cp) { \
+ register uint8_t *t_cp = (uint8_t *)(cp); \
+ (l)->b[0] = *t_cp++; \
+ (l)->b[1] = *t_cp++; \
+ (l)->b[2] = *t_cp++; \
+ (l)->b[3] = *t_cp++; \
+ (l)->b[4] = *t_cp++; \
+ (l)->b[5] = *t_cp++; \
+ (l)->b[6] = *t_cp++; \
+ (l)->b[7] = *t_cp++; \
+ (l)->b[8] = *t_cp++; \
+ (l)->b[9] = *t_cp++; \
+ (l)->b[10] = *t_cp++; \
+ (l)->b[11] = *t_cp++; \
+ (l)->b[12] = *t_cp++; \
+ (l)->b[13] = *t_cp++; \
+ (l)->b[14] = *t_cp++; \
+ (l)->b[15] = *t_cp++; \
(cp) += 16; \
}
-#else /* BYTE_ORDER != LITTLE_ENDIAN */
+#elif BYTE_ORDER == BIG_ENDIAN
#define SDP_GET128(l, cp) { \
register uint8_t *t_cp = (uint8_t *)(cp); \
(l)->b[0] = *t_cp++; \
@@ -383,6 +405,10 @@ typedef struct sdp_attr * sdp_attr_p;
(l)->b[15] = *t_cp++; \
(cp) += 16; \
}
+
+#define SDP_GET_UUID128(l, cp) SDP_GET128(l, cp)
+#else
+#error "Unsupported BYTE_ORDER"
#endif /* BYTE_ORDER */
#define SDP_PUT8(b, cp) { \
@@ -445,7 +471,28 @@ typedef struct sdp_attr * sdp_attr_p;
*t_cp = (l)->b[0]; \
(cp) += 16; \
}
-#else /* BYTE_ORDER != LITTLE_ENDIAN */
+
+#define SDP_PUT_UUID128(l, cp) { \
+ register uint8_t *t_cp = (uint8_t *)(cp); \
+ *t_cp++ = (l)->b[0]; \
+ *t_cp++ = (l)->b[1]; \
+ *t_cp++ = (l)->b[2]; \
+ *t_cp++ = (l)->b[3]; \
+ *t_cp++ = (l)->b[4]; \
+ *t_cp++ = (l)->b[5]; \
+ *t_cp++ = (l)->b[6]; \
+ *t_cp++ = (l)->b[7]; \
+ *t_cp++ = (l)->b[8]; \
+ *t_cp++ = (l)->b[9]; \
+ *t_cp++ = (l)->b[10]; \
+ *t_cp++ = (l)->b[11]; \
+ *t_cp++ = (l)->b[12]; \
+ *t_cp++ = (l)->b[13]; \
+ *t_cp++ = (l)->b[14]; \
+ *t_cp = (l)->b[15]; \
+ (cp) += 16; \
+}
+#elif BYTE_ORDER == BIG_ENDIAN
#define SDP_PUT128(l, cp) { \
register uint8_t *t_cp = (uint8_t *)(cp); \
*t_cp++ = (l)->b[0]; \
@@ -466,6 +513,10 @@ typedef struct sdp_attr * sdp_attr_p;
*t_cp = (l)->b[15]; \
(cp) += 16; \
}
+
+#define SDP_PUT_UUID128(l, cp) SDP_PUT128(l, cp)
+#else
+#error "Unsupported BYTE_ORDER"
#endif /* BYTE_ORDER */
void * sdp_open (bdaddr_t const *l, bdaddr_t const *r);
diff --git a/lib/libsdp/util.c b/lib/libsdp/util.c
index ae41fb2..7c7330d 100644
--- a/lib/libsdp/util.c
+++ b/lib/libsdp/util.c
@@ -29,6 +29,7 @@
* $FreeBSD$
*/
+#include <netinet/in.h>
#include <bluetooth.h>
#include <stdio.h>
#include <sdp.h>
@@ -317,17 +318,25 @@ sdp_print(uint32_t level, uint8_t const *start, uint8_t const *end)
case SDP_DATA_UINT128:
case SDP_DATA_INT128:
- case SDP_DATA_UUID128:
SDP_GET128(&value.int128, start);
- printf("int128/uuid128 %#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x\n",
+ printf("u/int128 %#8.8x%8.8x%8.8x%8.8x\n",
*(uint32_t *)&value.int128.b[0],
- *(uint16_t *)&value.int128.b[4],
- *(uint16_t *)&value.int128.b[6],
- *(uint16_t *)&value.int128.b[8],
- *(uint16_t *)&value.int128.b[10],
+ *(uint32_t *)&value.int128.b[4],
+ *(uint32_t *)&value.int128.b[8],
*(uint32_t *)&value.int128.b[12]);
break;
+ case SDP_DATA_UUID128:
+ SDP_GET_UUID128(&value.int128, start);
+ printf("uuid128 %#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x\n",
+ ntohl(*(uint32_t *)&value.int128.b[0]),
+ ntohs(*(uint16_t *)&value.int128.b[4]),
+ ntohs(*(uint16_t *)&value.int128.b[6]),
+ ntohs(*(uint16_t *)&value.int128.b[8]),
+ ntohs(*(uint16_t *)&value.int128.b[10]),
+ ntohl(*(uint32_t *)&value.int128.b[12]));
+ break;
+
case SDP_DATA_INT8:
SDP_GET8(value.int8, start);
printf("int8 %d\n", value.int8);
OpenPOWER on IntegriCloud