bt_sdp.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * Copyright (C) 2015 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include "bluetooth.h"
  18. #define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15
  19. __BEGIN_DECLS
  20. /**
  21. * These events are handled by the state machine
  22. */
  23. typedef enum {
  24. SDP_TYPE_RAW, // Used to carry raw SDP search data for unknown UUIDs
  25. SDP_TYPE_MAP_MAS, // Message Access Profile - Server
  26. SDP_TYPE_MAP_MNS, // Message Access Profile - Client (Notification Server)
  27. SDP_TYPE_PBAP_PSE, // Phone Book Profile - Server
  28. SDP_TYPE_PBAP_PCE, // Phone Book Profile - Client
  29. SDP_TYPE_OPP_SERVER, // Object Push Profile
  30. SDP_TYPE_SAP_SERVER // SIM Access Profile
  31. } bluetooth_sdp_types;
  32. typedef struct _bluetooth_sdp_hdr {
  33. bluetooth_sdp_types type;
  34. bluetooth::Uuid uuid;
  35. uint32_t service_name_length;
  36. char* service_name;
  37. int32_t rfcomm_channel_number;
  38. int32_t l2cap_psm;
  39. int32_t profile_version;
  40. } bluetooth_sdp_hdr;
  41. /**
  42. * Some signals need additional pointers, hence we introduce a
  43. * generic way to handle these pointers.
  44. */
  45. typedef struct _bluetooth_sdp_hdr_overlay {
  46. bluetooth_sdp_types type;
  47. bluetooth::Uuid uuid;
  48. uint32_t service_name_length;
  49. char* service_name;
  50. int32_t rfcomm_channel_number;
  51. int32_t l2cap_psm;
  52. int32_t profile_version;
  53. // User pointers, only used for some signals - see bluetooth_sdp_ops_record
  54. int user1_ptr_len;
  55. uint8_t* user1_ptr;
  56. int user2_ptr_len;
  57. uint8_t* user2_ptr;
  58. } bluetooth_sdp_hdr_overlay;
  59. typedef struct _bluetooth_sdp_mas_record {
  60. bluetooth_sdp_hdr_overlay hdr;
  61. uint32_t mas_instance_id;
  62. uint32_t supported_features;
  63. uint32_t supported_message_types;
  64. } bluetooth_sdp_mas_record;
  65. typedef struct _bluetooth_sdp_mns_record {
  66. bluetooth_sdp_hdr_overlay hdr;
  67. uint32_t supported_features;
  68. } bluetooth_sdp_mns_record;
  69. typedef struct _bluetooth_sdp_pse_record {
  70. bluetooth_sdp_hdr_overlay hdr;
  71. uint32_t supported_features;
  72. uint32_t supported_repositories;
  73. } bluetooth_sdp_pse_record;
  74. typedef struct _bluetooth_sdp_pce_record {
  75. bluetooth_sdp_hdr_overlay hdr;
  76. } bluetooth_sdp_pce_record;
  77. typedef struct _bluetooth_sdp_ops_record {
  78. bluetooth_sdp_hdr_overlay hdr;
  79. int supported_formats_list_len;
  80. uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH];
  81. } bluetooth_sdp_ops_record;
  82. typedef struct _bluetooth_sdp_sap_record {
  83. bluetooth_sdp_hdr_overlay hdr;
  84. } bluetooth_sdp_sap_record;
  85. typedef union {
  86. bluetooth_sdp_hdr_overlay hdr;
  87. bluetooth_sdp_mas_record mas;
  88. bluetooth_sdp_mns_record mns;
  89. bluetooth_sdp_pse_record pse;
  90. bluetooth_sdp_pce_record pce;
  91. bluetooth_sdp_ops_record ops;
  92. bluetooth_sdp_sap_record sap;
  93. } bluetooth_sdp_record;
  94. /** Callback for SDP search */
  95. typedef void (*btsdp_search_callback)(bt_status_t status,
  96. const RawAddress& bd_addr,
  97. const bluetooth::Uuid& uuid,
  98. int num_records,
  99. bluetooth_sdp_record* records);
  100. typedef struct {
  101. /** Set to sizeof(btsdp_callbacks_t) */
  102. size_t size;
  103. btsdp_search_callback sdp_search_cb;
  104. } btsdp_callbacks_t;
  105. typedef struct {
  106. /** Set to size of this struct */
  107. size_t size;
  108. /** Register BT SDP search callbacks */
  109. bt_status_t (*init)(btsdp_callbacks_t* callbacks);
  110. /** Unregister BT SDP */
  111. bt_status_t (*deinit)();
  112. /** Search for SDP records with specific uuid on remote device */
  113. bt_status_t (*sdp_search)(RawAddress* bd_addr, const bluetooth::Uuid& uuid);
  114. /**
  115. * Use listen in the socket interface to create rfcomm and/or l2cap PSM
  116. * channels, (without UUID and service_name and set the BTSOCK_FLAG_NO_SDP
  117. * flag in flags). Then use createSdpRecord to create the SDP record
  118. * associated with the rfcomm/l2cap channels.
  119. *
  120. * Returns a handle to the SDP record, which can be parsed to
  121. * remove_sdp_record.
  122. *
  123. * record (in) The SDP record to create
  124. * record_handle (out)The corresponding record handle will be written to
  125. * this pointer.
  126. */
  127. bt_status_t (*create_sdp_record)(bluetooth_sdp_record* record,
  128. int* record_handle);
  129. /** Remove a SDP record created by createSdpRecord */
  130. bt_status_t (*remove_sdp_record)(int sdp_handle);
  131. } btsdp_interface_t;
  132. __END_DECLS