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 
17 #ifndef __BT_SDP_H__
18 #define __BT_SDP_H__
19 
20 #include <stdint.h>
21 // #include "bluetooth.h"
22 #include "common/bt_defs.h"
23 
24 #define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15
25 
26 /**
27  * These events are handled by the state machine
28  */
29 typedef enum {
30     SDP_TYPE_RAW,        // Used to carry raw SDP search data for unknown UUIDs
31     SDP_TYPE_MAP_MAS,    // Message Access Profile - Server
32     SDP_TYPE_MAP_MNS,    // Message Access Profile - Client (Notification Server)
33     SDP_TYPE_PBAP_PSE,   // Phone Book Profile - Server
34     SDP_TYPE_PBAP_PCE,   // Phone Book Profile - Client
35     SDP_TYPE_OPP_SERVER, // Object Push Profile
36     SDP_TYPE_SAP_SERVER  // SIM Access Profile
37 } bluetooth_sdp_types;
38 
39 typedef struct _bluetooth_sdp_hdr {
40     bluetooth_sdp_types type;
41     bt_uuid_t   uuid;
42     uint32_t    service_name_length;
43     char       *service_name;
44     int32_t     rfcomm_channel_number;
45     int32_t     l2cap_psm;
46     int32_t     profile_version;
47 } bluetooth_sdp_hdr;
48 
49 /**
50  * Some signals need additional pointers, hence we introduce a
51  * generic way to handle these pointers.
52  */
53 typedef struct _bluetooth_sdp_hdr_overlay {
54     bluetooth_sdp_types type;
55     bt_uuid_t   uuid;
56     uint32_t    service_name_length;
57     char       *service_name;
58     int32_t     rfcomm_channel_number;
59     int32_t     l2cap_psm;
60     int32_t     profile_version;
61 
62     // User pointers, only used for some signals - see bluetooth_sdp_ops_record
63     int         user1_ptr_len;
64     uint8_t    *user1_ptr;
65     int         user2_ptr_len;
66     uint8_t    *user2_ptr;
67 } bluetooth_sdp_hdr_overlay;
68 
69 typedef struct _bluetooth_sdp_mas_record {
70     bluetooth_sdp_hdr_overlay hdr;
71     uint32_t    mas_instance_id;
72     uint32_t    supported_features;
73     uint32_t    supported_message_types;
74 } bluetooth_sdp_mas_record;
75 
76 typedef struct _bluetooth_sdp_mns_record {
77     bluetooth_sdp_hdr_overlay hdr;
78     uint32_t    supported_features;
79 } bluetooth_sdp_mns_record;
80 
81 typedef struct _bluetooth_sdp_pse_record {
82     bluetooth_sdp_hdr_overlay hdr;
83     uint32_t    supported_features;
84     uint32_t    supported_repositories;
85 } bluetooth_sdp_pse_record;
86 
87 typedef struct _bluetooth_sdp_pce_record {
88     bluetooth_sdp_hdr_overlay hdr;
89 } bluetooth_sdp_pce_record;
90 
91 typedef struct _bluetooth_sdp_ops_record {
92     bluetooth_sdp_hdr_overlay hdr;
93     int         supported_formats_list_len;
94     uint8_t     supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH];
95 } bluetooth_sdp_ops_record;
96 
97 typedef struct _bluetooth_sdp_sap_record {
98     bluetooth_sdp_hdr_overlay hdr;
99 } bluetooth_sdp_sap_record;
100 
101 typedef union {
102     bluetooth_sdp_hdr_overlay   hdr;
103     bluetooth_sdp_mas_record    mas;
104     bluetooth_sdp_mns_record    mns;
105     bluetooth_sdp_pse_record    pse;
106     bluetooth_sdp_pce_record    pce;
107     bluetooth_sdp_ops_record    ops;
108     bluetooth_sdp_sap_record    sap;
109 } bluetooth_sdp_record;
110 
111 #endif /* __BT_SDP_H__ */
112