1 /*
2  * Copyright 2024 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 /*******************************************************************************
18  *  L2CAP Socket Interface
19  ******************************************************************************/
20 
21 #ifndef BTIF_SOCK_L2CAP_H
22 #define BTIF_SOCK_L2CAP_H
23 
24 #include <hardware/bluetooth.h>
25 #include <hardware/bt_sock.h>
26 
27 #include "btif_uid.h"
28 #include "types/raw_address.h"
29 
30 bt_status_t btsock_l2cap_init(int handle, uid_set_t* set);
31 bt_status_t btsock_l2cap_cleanup();
32 bt_status_t btsock_l2cap_listen(const char* name, int channel, int* sock_fd, int flags, int app_uid,
33                                 btsock_data_path_t data_path, const char* socket_name,
34                                 uint64_t hub_id, uint64_t endpoint_id, int max_rx_packet_size);
35 bt_status_t btsock_l2cap_connect(const RawAddress* bd_addr, int channel, int* sock_fd, int flags,
36                                  int app_uid, btsock_data_path_t data_path, const char* socket_name,
37                                  uint64_t hub_id, uint64_t endpoint_id, int max_rx_packet_size);
38 void btsock_l2cap_signaled(int fd, int flags, uint32_t user_id);
39 void on_l2cap_psm_assigned(int id, int psm);
40 bt_status_t btsock_l2cap_disconnect(const RawAddress* bd_addr);
41 bt_status_t btsock_l2cap_get_l2cap_local_cid(bluetooth::Uuid& conn_uuid, uint16_t* cid);
42 bt_status_t btsock_l2cap_get_l2cap_remote_cid(bluetooth::Uuid& conn_uuid, uint16_t* cid);
43 void on_btsocket_l2cap_opened_complete(uint64_t socket_id, bool success);
44 void on_btsocket_l2cap_close(uint64_t socket_id);
45 
46 #endif
47