1 /* $NetBSD: sdp.h,v 1.2 2006/08/17 20:13:31 plunky Exp $ */ 2 /* $DragonFly: src/lib/libsdp/sdp.h,v 1.1 2008/01/03 11:47:53 hasso Exp $ */ 3 4 /*- 5 * Copyright (c) 2006 Itronix Inc. 6 * All rights reserved. 7 * 8 * Written by Iain Hibbert for Itronix Inc. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. The name of Itronix Inc. may not be used to endorse 19 * or promote products derived from this software without specific 20 * prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY 26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 * ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 * POSSIBILITY OF SUCH DAMAGE. 33 */ 34 /* 35 * sdp.h 36 * 37 * Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com> 38 * All rights reserved. 39 * 40 * Redistribution and use in source and binary forms, with or without 41 * modification, are permitted provided that the following conditions 42 * are met: 43 * 1. Redistributions of source code must retain the above copyright 44 * notice, this list of conditions and the following disclaimer. 45 * 2. Redistributions in binary form must reproduce the above copyright 46 * notice, this list of conditions and the following disclaimer in the 47 * documentation and/or other materials provided with the distribution. 48 * 49 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 50 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 51 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 52 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 59 * SUCH DAMAGE. 60 * 61 * $Id: sdp.h,v 1.2 2006/08/17 20:13:31 plunky Exp $ 62 * $FreeBSD: src/lib/libsdp/sdp.h,v 1.5 2005/05/27 19:11:33 emax Exp $ 63 */ 64 65 #ifndef _SDP_H_ 66 #define _SDP_H_ 67 68 #include <string.h> 69 70 __BEGIN_DECLS 71 72 /* 73 * Data representation (page 349) 74 */ 75 76 /* Nil, the null type */ 77 #define SDP_DATA_NIL 0x00 78 79 /* Unsigned integer */ 80 #define SDP_DATA_UINT8 0x08 81 #define SDP_DATA_UINT16 0x09 82 #define SDP_DATA_UINT32 0x0A 83 #define SDP_DATA_UINT64 0x0B 84 #define SDP_DATA_UINT128 0x0C 85 86 /* Signed two's-complement integer */ 87 #define SDP_DATA_INT8 0x10 88 #define SDP_DATA_INT16 0x11 89 #define SDP_DATA_INT32 0x12 90 #define SDP_DATA_INT64 0x13 91 #define SDP_DATA_INT128 0x14 92 93 /* UUID, a universally unique identifier */ 94 #define SDP_DATA_UUID16 0x19 95 #define SDP_DATA_UUID32 0x1A 96 #define SDP_DATA_UUID128 0x1C 97 98 /* Text string */ 99 #define SDP_DATA_STR8 0x25 100 #define SDP_DATA_STR16 0x26 101 #define SDP_DATA_STR32 0x27 102 103 /* Boolean */ 104 #define SDP_DATA_BOOL 0x28 105 106 /* 107 * Data element sequence. 108 * A data element whose data field is a sequence of data elements 109 */ 110 #define SDP_DATA_SEQ8 0x35 111 #define SDP_DATA_SEQ16 0x36 112 #define SDP_DATA_SEQ32 0x37 113 114 /* 115 * Data element alternative. 116 * A data element whose data field is a sequence of data elements from 117 * which one data element is to be selected. 118 */ 119 #define SDP_DATA_ALT8 0x3D 120 #define SDP_DATA_ALT16 0x3E 121 #define SDP_DATA_ALT32 0x3F 122 123 /* URL, a uniform resource locator */ 124 #define SDP_DATA_URL8 0x45 125 #define SDP_DATA_URL16 0x46 126 #define SDP_DATA_URL32 0x47 127 128 /* 129 * Protocols UUID (short) http://www.bluetoothsig.org/assigned-numbers/sdp.htm 130 * BASE UUID 00000000-0000-1000-8000-00805F9B34FB 131 */ 132 133 #define SDP_UUID_PROTOCOL_SDP 0x0001 134 #define SDP_UUID_PROTOCOL_UDP 0x0002 135 #define SDP_UUID_PROTOCOL_RFCOMM 0x0003 136 #define SDP_UUID_PROTOCOL_TCP 0x0004 137 #define SDP_UUID_PROTOCOL_TCS_BIN 0x0005 138 #define SDP_UUID_PROTOCOL_TCS_AT 0x0006 139 #define SDP_UUID_PROTOCOL_OBEX 0x0008 140 #define SDP_UUID_PROTOCOL_IP 0x0009 141 #define SDP_UUID_PROTOCOL_FTP 0x000A 142 #define SDP_UUID_PROTOCOL_HTTP 0x000C 143 #define SDP_UUID_PROTOCOL_WSP 0x000E 144 #define SDP_UUID_PROTOCOL_BNEP 0x000F 145 #define SDP_UUID_PROTOCOL_UPNP 0x0010 146 #define SDP_UUID_PROTOCOL_HIDP 0x0011 147 #define SDP_UUID_PROTOCOL_HARDCOPY_CONTROL_CHANNEL 0x0012 148 #define SDP_UUID_PROTOCOL_HARDCOPY_DATA_CHANNEL 0x0014 149 #define SDP_UUID_PROTOCOL_HARDCOPY_NOTIFICATION 0x0016 150 #define SDP_UUID_PROTOCOL_AVCTP 0x0017 151 #define SDP_UUID_PROTOCOL_AVDTP 0x0019 152 #define SDP_UUID_PROTOCOL_CMPT 0x001B 153 #define SDP_UUID_PROTOCOL_UDI_C_PLANE 0x001D 154 #define SDP_UUID_PROTOCOL_L2CAP 0x0100 155 156 /* 157 * Service class IDs http://www.bluetoothsig.org/assigned-numbers/sdp.htm 158 */ 159 160 #define SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER 0x1000 161 #define SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR 0x1001 162 #define SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP 0x1002 163 #define SDP_SERVICE_CLASS_SERIAL_PORT 0x1101 164 #define SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP 0x1102 165 #define SDP_SERVICE_CLASS_DIALUP_NETWORKING 0x1103 166 #define SDP_SERVICE_CLASS_IR_MC_SYNC 0x1104 167 #define SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH 0x1105 168 #define SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER 0x1106 169 #define SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND 0x1107 170 #define SDP_SERVICE_CLASS_HEADSET 0x1108 171 #define SDP_SERVICE_CLASS_CORDLESS_TELEPHONY 0x1109 172 #define SDP_SERVICE_CLASS_AUDIO_SOURCE 0x110A 173 #define SDP_SERVICE_CLASS_AUDIO_SINK 0x110B 174 #define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL_TARGET 0x110C 175 #define SDP_SERVICE_CLASS_ADVANCED_AUDIO_DISTRIBUTION 0x110D 176 #define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL 0x110E 177 #define SDP_SERVICE_CLASS_VIDEO_CONFERENCING 0x110F 178 #define SDP_SERVICE_CLASS_INTERCOM 0x1110 179 #define SDP_SERVICE_CLASS_FAX 0x1111 180 #define SDP_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY 0x1112 181 #define SDP_SERVICE_CLASS_WAP 0x1113 182 #define SDP_SERVICE_CLASS_WAP_CLIENT 0x1114 183 #define SDP_SERVICE_CLASS_PANU 0x1115 184 #define SDP_SERVICE_CLASS_NAP 0x1116 185 #define SDP_SERVICE_CLASS_GN 0x1117 186 #define SDP_SERVICE_CLASS_DIRECT_PRINTING 0x1118 187 #define SDP_SERVICE_CLASS_REFERENCE_PRINTING 0x1119 188 #define SDP_SERVICE_CLASS_IMAGING 0x111A 189 #define SDP_SERVICE_CLASS_IMAGING_RESPONDER 0x111B 190 #define SDP_SERVICE_CLASS_IMAGING_AUTOMATIC_ARCHIVE 0x111C 191 #define SDP_SERVICE_CLASS_IMAGING_REFERENCED_OBJECTS 0x111D 192 #define SDP_SERVICE_CLASS_HANDSFREE 0x111E 193 #define SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY 0x111F 194 #define SDP_SERVICE_CLASS_DIRECT_PRINTING_REFERENCE_OBJECTS 0x1120 195 #define SDP_SERVICE_CLASS_REFLECTED_UI 0x1121 196 #define SDP_SERVICE_CLASS_BASIC_PRINTING 0x1122 197 #define SDP_SERVICE_CLASS_PRINTING_STATUS 0x1123 198 #define SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE 0x1124 199 #define SDP_SERVICE_CLASS_HARDCOPY_CABLE_REPLACEMENT 0x1125 200 #define SDP_SERVICE_CLASS_HCR_PRINT 0x1126 201 #define SDP_SERVICE_CLASS_HCR_SCAN 0x1127 202 #define SDP_SERVICE_CLASS_COMMON_ISDN_ACCESS 0x1128 203 #define SDP_SERVICE_CLASS_VIDEO_CONFERENCING_GW 0x1129 204 #define SDP_SERVICE_CLASS_UDI_MT 0x112A 205 #define SDP_SERVICE_CLASS_UDI_TA 0x112B 206 #define SDP_SERVICE_CLASS_AUDIO_VIDEO 0x112C 207 #define SDP_SERVICE_CLASS_SIM_ACCESS 0x112D 208 #define SDP_SERVICE_CLASS_PNP_INFORMATION 0x1200 209 #define SDP_SERVICE_CLASS_GENERIC_NETWORKING 0x1201 210 #define SDP_SERVICE_CLASS_GENERIC_FILE_TRANSFER 0x1202 211 #define SDP_SERVICE_CLASS_GENERIC_AUDIO 0x1203 212 #define SDP_SERVICE_CLASS_GENERIC_TELEPHONY 0x1204 213 #define SDP_SERVICE_CLASS_UPNP 0x1205 214 #define SDP_SERVICE_CLASS_UPNP_IP 0x1206 215 #define SDP_SERVICE_CLASS_ESDP_UPNP_IP_PAN 0x1300 216 #define SDP_SERVICE_CLASS_ESDP_UPNP_IP_LAP 0x1301 217 #define SDP_SERVICE_CLASS_ESDP_UPNP_L2CAP 0x1302 218 219 /* 220 * Universal attribute definitions (page 366) and 221 * http://www.bluetoothsig.org/assigned-numbers/sdp.htm 222 */ 223 224 #define SDP_ATTR_RANGE(lo, hi) \ 225 (uint32_t)(((uint16_t)(lo) << 16) | ((uint16_t)(hi))) 226 227 #define SDP_ATTR_SERVICE_RECORD_HANDLE 0x0000 228 #define SDP_ATTR_SERVICE_CLASS_ID_LIST 0x0001 229 #define SDP_ATTR_SERVICE_RECORD_STATE 0x0002 230 #define SDP_ATTR_SERVICE_ID 0x0003 231 #define SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST 0x0004 232 #define SDP_ATTR_BROWSE_GROUP_LIST 0x0005 233 #define SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST 0x0006 234 #define SDP_ATTR_SERVICE_INFO_TIME_TO_LIVE 0x0007 235 #define SDP_ATTR_SERVICE_AVAILABILITY 0x0008 236 #define SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST 0x0009 237 #define SDP_ATTR_DOCUMENTATION_URL 0x000A 238 #define SDP_ATTR_CLIENT_EXECUTABLE_URL 0x000B 239 #define SDP_ATTR_ICON_URL 0x000C 240 #define SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS 0x000D 241 #define SDP_ATTR_GROUP_ID 0x0200 242 #define SDP_ATTR_IP_SUBNET 0x0200 243 #define SDP_ATTR_VERSION_NUMBER_LIST 0x0200 244 #define SDP_ATTR_SERVICE_DATABASE_STATE 0x0201 245 #define SDP_ATTR_SERVICE_VERSION 0x0300 246 #define SDP_ATTR_EXTERNAL_NETWORK 0x0301 247 #define SDP_ATTR_NETWORK 0x0301 248 #define SDP_ATTR_SUPPORTED_DATA_STORES_LIST 0x0301 249 #define SDP_ATTR_FAX_CLASS1_SUPPORT 0x0302 250 #define SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL 0x0302 251 #define SDP_ATTR_FAX_CLASS20_SUPPORT 0x0303 252 #define SDP_ATTR_SUPPORTED_FORMATS_LIST 0x0303 253 #define SDP_ATTR_FAX_CLASS2_SUPPORT 0x0304 254 #define SDP_ATTR_AUDIO_FEEDBACK_SUPPORT 0x0305 255 #define SDP_ATTR_NETWORK_ADDRESS 0x0306 256 #define SDP_ATTR_WAP_GATEWAY 0x0307 257 #define SDP_ATTR_HOME_PAGE_URL 0x0308 258 #define SDP_ATTR_WAP_STACK_TYPE 0x0309 259 #define SDP_ATTR_SECURITY_DESCRIPTION 0x030A 260 #define SDP_ATTR_NET_ACCESS_TYPE 0x030B 261 #define SDP_ATTR_MAX_NET_ACCESS_RATE 0x030C 262 #define SDP_ATTR_IPV4_SUBNET 0x030D 263 #define SDP_ATTR_IPV6_SUBNET 0x030E 264 #define SDP_ATTR_SUPPORTED_CAPABALITIES 0x0310 265 #define SDP_ATTR_SUPPORTED_FEATURES 0x0311 266 #define SDP_ATTR_SUPPORTED_FUNCTIONS 0x0312 267 #define SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY 0x0313 268 269 /* 270 * The offset must be added to the attribute ID base (contained in the 271 * LANGUAGE_BASE_ATTRIBUTE_ID_LIST attribute) in order to compute the 272 * attribute ID for these attributes. 273 */ 274 275 #define SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID 0x0100 276 #define SDP_ATTR_SERVICE_NAME_OFFSET 0x0000 277 #define SDP_ATTR_SERVICE_DESCRIPTION_OFFSET 0x0001 278 #define SDP_ATTR_PROVIDER_NAME_OFFSET 0x0002 279 280 /* 281 * Protocol data unit (PDU) format (page 352) 282 */ 283 284 #define SDP_PDU_ERROR_RESPONSE 0x01 285 #define SDP_PDU_SERVICE_SEARCH_REQUEST 0x02 286 #define SDP_PDU_SERVICE_SEARCH_RESPONSE 0x03 287 #define SDP_PDU_SERVICE_ATTRIBUTE_REQUEST 0x04 288 #define SDP_PDU_SERVICE_ATTRIBUTE_RESPONSE 0x05 289 #define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_REQUEST 0x06 290 #define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_RESPONSE 0x07 291 292 struct sdp_pdu { 293 uint8_t pid; /* PDU ID - SDP_PDU_xxx */ 294 uint16_t tid; /* transaction ID */ 295 uint16_t len; /* parameters length (in bytes) */ 296 } __attribute__ ((packed)); 297 typedef struct sdp_pdu sdp_pdu_t; 298 typedef struct sdp_pdu * sdp_pdu_p; 299 300 /* 301 * Error codes for SDP_PDU_ERROR_RESPONSE 302 */ 303 304 #define SDP_ERROR_CODE_INVALID_SDP_VERSION 0x0001 305 #define SDP_ERROR_CODE_INVALID_SERVICE_RECORD_HANDLE 0x0002 306 #define SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX 0x0003 307 #define SDP_ERROR_CODE_INVALID_PDU_SIZE 0x0004 308 #define SDP_ERROR_CODE_INVALID_CONTINUATION_STATE 0x0005 309 #define SDP_ERROR_CODE_INSUFFICIENT_RESOURCES 0x0006 310 311 /* 312 * SDP int128/uint128 parameter 313 */ 314 315 struct int128 { 316 int8_t b[16]; 317 }; 318 typedef struct int128 int128_t; 319 typedef struct int128 uint128_t; 320 321 /* 322 * SDP attribute 323 */ 324 325 struct sdp_attr { 326 uint16_t flags; 327 #define SDP_ATTR_OK (0 << 0) 328 #define SDP_ATTR_INVALID (1 << 0) 329 #define SDP_ATTR_TRUNCATED (1 << 1) 330 uint16_t attr; /* SDP_ATTR_xxx */ 331 uint32_t vlen; /* length of the value[] in bytes */ 332 uint8_t *value; /* base pointer */ 333 }; 334 typedef struct sdp_attr sdp_attr_t; 335 typedef struct sdp_attr * sdp_attr_p; 336 337 /****************************************************************************** 338 * User interface 339 *****************************************************************************/ 340 341 /* Inline versions of get/put byte/short/long. Pointer is advanced */ 342 #define SDP_GET8(b, cp) do { \ 343 (b) = *(const uint8_t *)(cp); \ 344 (cp) += sizeof(uint8_t); \ 345 } while (/* CONSTCOND */0) 346 347 #define SDP_GET16(s, cp) do { \ 348 (s) = be16dec(cp); \ 349 (cp) += sizeof(uint16_t); \ 350 } while (/* CONSTCOND */0) 351 352 #define SDP_GET32(l, cp) do { \ 353 (l) = be32dec(cp); \ 354 (cp) += sizeof(uint32_t); \ 355 } while (/* CONSTCOND */0) 356 357 #define SDP_GET64(l, cp) do { \ 358 (l) = be64dec(cp); \ 359 (cp) += sizeof(uint64_t); \ 360 } while (/* CONSTCOND */0) 361 362 #if BYTE_ORDER == LITTLE_ENDIAN 363 #define SDP_GET128(l, cp) do { \ 364 register const uint8_t *t_cp = (const uint8_t *)(cp); \ 365 (l)->b[15] = *t_cp++; \ 366 (l)->b[14] = *t_cp++; \ 367 (l)->b[13] = *t_cp++; \ 368 (l)->b[12] = *t_cp++; \ 369 (l)->b[11] = *t_cp++; \ 370 (l)->b[10] = *t_cp++; \ 371 (l)->b[9] = *t_cp++; \ 372 (l)->b[8] = *t_cp++; \ 373 (l)->b[7] = *t_cp++; \ 374 (l)->b[6] = *t_cp++; \ 375 (l)->b[5] = *t_cp++; \ 376 (l)->b[4] = *t_cp++; \ 377 (l)->b[3] = *t_cp++; \ 378 (l)->b[2] = *t_cp++; \ 379 (l)->b[1] = *t_cp++; \ 380 (l)->b[0] = *t_cp++; \ 381 (cp) += 16; \ 382 } while (/* CONSTCOND */0) 383 384 #define SDP_GET_UUID128(l, cp) do { \ 385 memcpy(&((l)->b), (cp), 16); \ 386 (cp) += 16; \ 387 } while (/* CONSTCOND */0) 388 #elif BYTE_ORDER == BIG_ENDIAN 389 #define SDP_GET128(l, cp) do { \ 390 memcpy(&((l)->b), (cp), 16); \ 391 (cp) += 16; \ 392 } while (/* CONSTCOND */0) 393 394 #define SDP_GET_UUID128(l, cp) SDP_GET128(l, cp) 395 #else 396 #error "Unsupported BYTE_ORDER" 397 #endif /* BYTE_ORDER */ 398 399 #define SDP_PUT8(b, cp) do { \ 400 *(uint8_t *)(cp) = (b); \ 401 (cp) += sizeof(uint8_t); \ 402 } while (/* CONSTCOND */0) 403 404 #define SDP_PUT16(s, cp) do { \ 405 be16enc((cp), (s)); \ 406 (cp) += sizeof(uint16_t); \ 407 } while (/* CONSTCOND */0) 408 409 #define SDP_PUT32(s, cp) do { \ 410 be32enc((cp), (s)); \ 411 (cp) += sizeof(uint32_t); \ 412 } while (/* CONSTCOND */0) 413 414 #define SDP_PUT64(s, cp) do { \ 415 be64enc((cp), (s)); \ 416 (cp) += sizeof(uint64_t); \ 417 } while (/* CONSTCOND */0) 418 419 #if BYTE_ORDER == LITTLE_ENDIAN 420 #define SDP_PUT128(l, cp) do { \ 421 register const uint8_t *t_cp = (const uint8_t *)(cp); \ 422 *t_cp++ = (l)->b[15]; \ 423 *t_cp++ = (l)->b[14]; \ 424 *t_cp++ = (l)->b[13]; \ 425 *t_cp++ = (l)->b[12]; \ 426 *t_cp++ = (l)->b[11]; \ 427 *t_cp++ = (l)->b[10]; \ 428 *t_cp++ = (l)->b[9]; \ 429 *t_cp++ = (l)->b[8]; \ 430 *t_cp++ = (l)->b[7]; \ 431 *t_cp++ = (l)->b[6]; \ 432 *t_cp++ = (l)->b[5]; \ 433 *t_cp++ = (l)->b[4]; \ 434 *t_cp++ = (l)->b[3]; \ 435 *t_cp++ = (l)->b[2]; \ 436 *t_cp++ = (l)->b[1]; \ 437 *t_cp = (l)->b[0]; \ 438 (cp) += 16; \ 439 } while (/* CONSTCOND */0) 440 441 #define SDP_PUT_UUID128(l, cp) do { \ 442 memcpy((cp), &((l)->b), 16); \ 443 (cp) += 16; \ 444 } while (/* CONSTCOND */0) 445 #elif BYTE_ORDER == BIG_ENDIAN 446 #define SDP_PUT128(l, cp) do { \ 447 memcpy((cp), &((l)->b), 16); \ 448 (cp) += 16; \ 449 } while (/* CONSTCOND */0) 450 451 #define SDP_PUT_UUID128(l, cp) SDP_PUT128(l, cp) 452 #else 453 #error "Unsupported BYTE_ORDER" 454 #endif /* BYTE_ORDER */ 455 456 void * sdp_open (bdaddr_t const *l, bdaddr_t const *r); 457 void * sdp_open_local (char const *control); 458 int32_t sdp_close (void *xs); 459 int32_t sdp_error (void *xs); 460 461 int32_t sdp_search (void *xs, 462 uint32_t plen, uint16_t const *pp, 463 uint32_t alen, uint32_t const *ap, 464 uint32_t vlen, sdp_attr_t *vp); 465 466 char const * sdp_attr2desc (uint16_t attr); 467 char const * sdp_uuid2desc (uint16_t uuid); 468 void sdp_print (uint32_t level, uint8_t *start, 469 uint8_t const *end); 470 471 /****************************************************************************** 472 * sdpd interface and Bluetooth profiles data 473 *****************************************************************************/ 474 475 #define SDP_LOCAL_PATH "/var/run/sdp" 476 #define SDP_LOCAL_MTU 4096 477 478 /* 479 * These are NOT defined in spec and only accepted on control sockets. 480 * The response to these request always will be SDP_PDU_ERROR_RESPONSE. 481 * The first 2 bytes (after PDU header) is an error code (in network 482 * byte order). The rest of the data (pdu->len - 2) is a response data 483 * and depend on the request. 484 * 485 * SDP_PDU_SERVICE_REGISTER_REQUEST 486 * pdu_header_t hdr; 487 * uint16_t uuid; service class UUID (network byte order) 488 * bdaddr_t bdaddr; local BD_ADDR (or ANY) 489 * profile data[pdu->len - sizeof(uuid) - sizeof(bdaddr)] 490 * 491 * in successful reponse additional data will contain 4 bytes record handle 492 * 493 * 494 * SDP_PDU_SERVICE_UNREGISTER_REQUEST 495 * pdu_header_t hdr; 496 * uint32_t record_handle; (network byte order) 497 * 498 * no additional data in response. 499 * 500 * 501 * SDP_PDU_SERVICE_CHANGE_REQUEST 502 * pdu_header_t hdr; 503 * uint32_t record_handle; (network byte order) 504 * profile data[pdu->len - sizeof(record_handle)] 505 * 506 * no additional data in response. 507 */ 508 509 #define SDP_PDU_SERVICE_REGISTER_REQUEST 0x81 510 #define SDP_PDU_SERVICE_UNREGISTER_REQUEST 0x82 511 #define SDP_PDU_SERVICE_CHANGE_REQUEST 0x83 512 513 struct sdp_dun_profile 514 { 515 uint8_t server_channel; 516 uint8_t audio_feedback_support; 517 uint8_t reserved[2]; 518 }; 519 typedef struct sdp_dun_profile sdp_dun_profile_t; 520 typedef struct sdp_dun_profile * sdp_dun_profile_p; 521 522 struct sdp_ftrn_profile 523 { 524 uint8_t server_channel; 525 uint8_t reserved[3]; 526 }; 527 typedef struct sdp_ftrn_profile sdp_ftrn_profile_t; 528 typedef struct sdp_ftrn_profile * sdp_ftrn_profile_p; 529 530 struct sdp_hset_profile 531 { 532 uint8_t server_channel; 533 uint8_t reserved[3]; 534 }; 535 typedef struct sdp_hset_profile sdp_hset_profile_t; 536 typedef struct sdp_hset_profile * sdp_hset_profile_p; 537 538 struct sdp_hf_profile 539 { 540 uint8_t server_channel; 541 uint16_t supported_features; 542 }; 543 typedef struct sdp_hf_profile sdp_hf_profile_t; 544 typedef struct sdp_hf_profile * sdp_hf_profile_p; 545 546 /* Keep this in sync with sdp_opush_profile */ 547 struct sdp_irmc_profile 548 { 549 uint8_t server_channel; 550 uint8_t supported_formats_size; 551 uint8_t supported_formats[30]; 552 }; 553 typedef struct sdp_irmc_profile sdp_irmc_profile_t; 554 typedef struct sdp_irmc_profile * sdp_irmc_profile_p; 555 556 struct sdp_irmc_command_profile 557 { 558 uint8_t server_channel; 559 uint8_t reserved[3]; 560 }; 561 typedef struct sdp_irmc_command_profile sdp_irmc_command_profile_t; 562 typedef struct sdp_irmc_command_profile * sdp_irmc_command_profile_p; 563 564 struct sdp_lan_profile 565 { 566 uint8_t server_channel; 567 uint8_t load_factor; 568 uint8_t reserved; 569 uint8_t ip_subnet_radius; 570 uint32_t ip_subnet; 571 }; 572 typedef struct sdp_lan_profile sdp_lan_profile_t; 573 typedef struct sdp_lan_profile * sdp_lan_profile_p; 574 575 /* Keep this in sync with sdp_irmc_profile */ 576 struct sdp_opush_profile 577 { 578 uint8_t server_channel; 579 uint8_t supported_formats_size; 580 uint8_t supported_formats[30]; 581 }; 582 typedef struct sdp_opush_profile sdp_opush_profile_t; 583 typedef struct sdp_opush_profile * sdp_opush_profile_p; 584 585 struct sdp_sp_profile 586 { 587 uint8_t server_channel; 588 uint8_t reserved[3]; 589 }; 590 typedef struct sdp_sp_profile sdp_sp_profile_t; 591 typedef struct sdp_sp_profile * sdp_sp_profile_p; 592 593 int32_t sdp_register_service (void *xss, uint16_t uuid, 594 bdaddr_t *bdaddr, uint8_t *data, 595 uint32_t datalen, uint32_t *handle); 596 int32_t sdp_unregister_service (void *xss, uint32_t handle); 597 int32_t sdp_change_service (void *xss, uint32_t handle, 598 uint8_t *data, uint32_t datalen); 599 600 __END_DECLS 601 602 #endif /* ndef _SDP_H_ */ 603