Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 1 | /* |
| 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 Jella | 091164c | 2013-06-04 20:20:27 +0530 | [diff] [blame] | 22 | #define BTSOCK_FLAG_ENCRYPT (1) |
| 23 | #define BTSOCK_FLAG_AUTH (1 << 1) |
| 24 | #define BTSOCK_FLAG_AUTH_HIGH (1 << 2) |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 25 | |
| 26 | typedef enum { |
| 27 | BTSOCK_RFCOMM = 1, |
| 28 | BTSOCK_SCO = 2, |
| 29 | BTSOCK_L2CAP = 3 |
| 30 | } btsock_type_t; |
| 31 | |
Srinu Jella | 3a51aba | 2013-09-12 17:59:45 +0530 | [diff] [blame] | 32 | typedef enum { |
| 33 | BTSOCK_OPT_GET_MODEM_BITS = 1, |
| 34 | BTSOCK_OPT_SET_MODEM_BITS = 2, |
| 35 | BTSOCK_OPT_CLR_MODEM_BITS = 3, |
Srinu Jella | 33005ff | 2014-03-19 19:56:56 +0530 | [diff] [blame] | 36 | BTSOCK_OPT_SET_PUT_MTU = 4, |
Srinu Jella | d25b8b9 | 2015-01-30 15:04:50 +0530 | [diff] [blame] | 37 | BTSOCK_OPT_GET_CONG_STATUS = 5 |
Srinu Jella | 3a51aba | 2013-09-12 17:59:45 +0530 | [diff] [blame] | 38 | } btsock_option_type_t; |
| 39 | |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 40 | /** Represents the standard BT SOCKET interface. */ |
| 41 | typedef struct { |
| 42 | short size; |
| 43 | bt_bdaddr_t bd_addr; |
| 44 | int channel; |
| 45 | int status; |
| 46 | } __attribute__((packed)) sock_connect_signal_t; |
| 47 | |
| 48 | typedef 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 Jella | 3a51aba | 2013-09-12 17:59:45 +0530 | [diff] [blame] | 62 | /* |
| 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 Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 71 | |
| 72 | } btsock_interface_t; |
| 73 | |
| 74 | __END_DECLS |
| 75 | |
| 76 | #endif /* ANDROID_INCLUDE_BT_SOCK_H */ |