blob: bae41f4d080304bfb0e5c1e3f403a159421720bc [file] [log] [blame]
Andre Eisenbach05f49542012-09-18 12:15:26 -07001/*
2 * Copyright (C) 2012 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 ANDROID_INCLUDE_BT_SOCK_H
18#define ANDROID_INCLUDE_BT_SOCK_H
19
20__BEGIN_DECLS
21
Srinu Jella091164c2013-06-04 20:20:27 +053022#define BTSOCK_FLAG_ENCRYPT (1)
23#define BTSOCK_FLAG_AUTH (1 << 1)
24#define BTSOCK_FLAG_AUTH_HIGH (1 << 2)
Andre Eisenbach05f49542012-09-18 12:15:26 -070025
26typedef enum {
27 BTSOCK_RFCOMM = 1,
28 BTSOCK_SCO = 2,
29 BTSOCK_L2CAP = 3
30} btsock_type_t;
31
Srinu Jella3a51aba2013-09-12 17:59:45 +053032typedef enum {
33 BTSOCK_OPT_GET_MODEM_BITS = 1,
34 BTSOCK_OPT_SET_MODEM_BITS = 2,
35 BTSOCK_OPT_CLR_MODEM_BITS = 3,
Srinu Jella33005ff2014-03-19 19:56:56 +053036 BTSOCK_OPT_SET_PUT_MTU = 4,
Srinu Jellad25b8b92015-01-30 15:04:50 +053037 BTSOCK_OPT_GET_CONG_STATUS = 5
Srinu Jella3a51aba2013-09-12 17:59:45 +053038} btsock_option_type_t;
39
Andre Eisenbach05f49542012-09-18 12:15:26 -070040/** Represents the standard BT SOCKET interface. */
41typedef struct {
42 short size;
43 bt_bdaddr_t bd_addr;
44 int channel;
45 int status;
46} __attribute__((packed)) sock_connect_signal_t;
47
48typedef struct {
49
50 /** set to size of this struct*/
51 size_t size;
52 /**
53 * listen to a rfcomm uuid or channel. It returns the socket fd from which
54 * btsock_connect_signal can be read out when a remote device connected
55 */
56 bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags);
57 /*
58 * connect to a rfcomm uuid channel of remote device, It returns the socket fd from which
59 * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected
60 */
61 bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid, int channel, int* sock_fd, int flags);
Srinu Jella3a51aba2013-09-12 17:59:45 +053062 /*
63 * get socket option of rfcomm channel socket.
64 */
65 bt_status_t (*get_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, void *option_value, int *option_len);
66 /*
67 * set socket option of rfcomm channel socket.
68 */
69 bt_status_t (*set_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, void *option_value, int option_len);
70
Andre Eisenbach05f49542012-09-18 12:15:26 -070071
72} btsock_interface_t;
73
74__END_DECLS
75
76#endif /* ANDROID_INCLUDE_BT_SOCK_H */