The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Jakub Pawlowski | 5b790fe | 2017-09-18 09:00:20 -0700 | [diff] [blame^] | 3 | * Copyright 2004-2012 Broadcom Corporation |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
| 19 | /****************************************************************************** |
| 20 | * |
| 21 | * This is the private interface file for the BTA data gateway. |
| 22 | * |
| 23 | ******************************************************************************/ |
| 24 | #ifndef BTA_PAN_INT_H |
| 25 | #define BTA_PAN_INT_H |
| 26 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 27 | #include "bta_pan_api.h" |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 28 | #include "bta_sys.h" |
| 29 | #include "osi/include/fixed_queue.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 30 | |
| 31 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 32 | * Constants |
| 33 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 34 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 35 | /* PAN events */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 36 | enum { |
| 37 | /* these events are handled by the state machine */ |
| 38 | BTA_PAN_API_CLOSE_EVT = BTA_SYS_EVT_START(BTA_ID_PAN), |
| 39 | BTA_PAN_CI_TX_READY_EVT, |
| 40 | BTA_PAN_CI_RX_READY_EVT, |
| 41 | BTA_PAN_CI_TX_FLOW_EVT, |
| 42 | BTA_PAN_CI_RX_WRITE_EVT, |
| 43 | BTA_PAN_CI_RX_WRITEBUF_EVT, |
| 44 | BTA_PAN_CONN_OPEN_EVT, |
| 45 | BTA_PAN_CONN_CLOSE_EVT, |
| 46 | BTA_PAN_BNEP_FLOW_ENABLE_EVT, |
| 47 | BTA_PAN_RX_FROM_BNEP_READY_EVT, |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 48 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 49 | /* these events are handled outside of the state machine */ |
| 50 | BTA_PAN_API_ENABLE_EVT, |
| 51 | BTA_PAN_API_DISABLE_EVT, |
| 52 | BTA_PAN_API_SET_ROLE_EVT, |
| 53 | BTA_PAN_API_OPEN_EVT |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
Nitin Shivpure | 36f43cc | 2013-08-29 21:28:59 +0530 | [diff] [blame] | 56 | /* state machine states */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 57 | enum { BTA_PAN_IDLE_ST, BTA_PAN_OPEN_ST, BTA_PAN_CLOSING_ST }; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 58 | |
| 59 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 60 | * Data types |
| 61 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 62 | |
| 63 | /* data type for BTA_PAN_API_ENABLE_EVT */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 64 | typedef struct { |
| 65 | BT_HDR hdr; /* Event header */ |
| 66 | tBTA_PAN_CBACK* p_cback; /* PAN callback function */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 67 | } tBTA_PAN_API_ENABLE; |
| 68 | |
| 69 | /* data type for BTA_PAN_API_REG_ROLE_EVT */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 70 | typedef struct { |
| 71 | BT_HDR hdr; /* Event header */ |
| 72 | char user_name[BTA_SERVICE_NAME_LEN + 1]; /* Service name */ |
| 73 | char gn_name[BTA_SERVICE_NAME_LEN + 1]; /* Service name */ |
| 74 | char nap_name[BTA_SERVICE_NAME_LEN + 1]; /* Service name */ |
| 75 | tBTA_PAN_ROLE role; |
| 76 | uint8_t user_app_id; |
| 77 | uint8_t gn_app_id; |
| 78 | uint8_t nap_app_id; |
| 79 | tBTA_SEC user_sec_mask; /* Security mask */ |
| 80 | tBTA_SEC gn_sec_mask; /* Security mask */ |
| 81 | tBTA_SEC nap_sec_mask; /* Security mask */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 82 | |
| 83 | } tBTA_PAN_API_SET_ROLE; |
| 84 | |
| 85 | /* data type for BTA_PAN_API_OPEN_EVT */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 86 | typedef struct { |
| 87 | BT_HDR hdr; /* Event header */ |
| 88 | tBTA_PAN_ROLE local_role; /* local role */ |
| 89 | tBTA_PAN_ROLE peer_role; /* peer role */ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 90 | RawAddress bd_addr; /* peer bdaddr */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 91 | } tBTA_PAN_API_OPEN; |
| 92 | |
| 93 | /* data type for BTA_PAN_CI_TX_FLOW_EVT */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 94 | typedef struct { |
| 95 | BT_HDR hdr; /* Event header */ |
| 96 | bool enable; /* Flow control setting */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 97 | } tBTA_PAN_CI_TX_FLOW; |
| 98 | |
| 99 | /* data type for BTA_PAN_CONN_OPEN_EVT */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 100 | typedef struct { |
| 101 | BT_HDR hdr; /* Event header */ |
| 102 | tPAN_RESULT result; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 103 | |
| 104 | } tBTA_PAN_CONN; |
| 105 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 106 | /* union of all data types */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 107 | typedef union { |
| 108 | BT_HDR hdr; |
| 109 | tBTA_PAN_API_ENABLE api_enable; |
| 110 | tBTA_PAN_API_SET_ROLE api_set_role; |
| 111 | tBTA_PAN_API_OPEN api_open; |
| 112 | tBTA_PAN_CI_TX_FLOW ci_tx_flow; |
| 113 | tBTA_PAN_CONN conn; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 114 | } tBTA_PAN_DATA; |
| 115 | |
| 116 | /* state machine control block */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 117 | typedef struct { |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 118 | RawAddress bd_addr; /* peer bdaddr */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 119 | fixed_queue_t* |
| 120 | data_queue; /* Queue of buffers waiting to be passed to application */ |
| 121 | uint16_t handle; /* BTA PAN/BNEP handle */ |
| 122 | bool in_use; /* scb in use */ |
| 123 | tBTA_SEC sec_mask; /* Security mask */ |
| 124 | bool pan_flow_enable; /* BNEP flow control state */ |
| 125 | bool app_flow_enable; /* Application flow control state */ |
| 126 | uint8_t state; /* State machine state */ |
| 127 | tBTA_PAN_ROLE local_role; /* local role */ |
| 128 | tBTA_PAN_ROLE peer_role; /* peer role */ |
| 129 | uint8_t app_id; /* application id for the connection */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 130 | |
| 131 | } tBTA_PAN_SCB; |
| 132 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 133 | /* main control block */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 134 | typedef struct { |
| 135 | tBTA_PAN_SCB scb[BTA_PAN_NUM_CONN]; /* state machine control blocks */ |
| 136 | tBTA_PAN_CBACK* p_cback; /* PAN callback function */ |
| 137 | uint8_t app_id[3]; /* application id for PAN roles */ |
| 138 | uint8_t flow_mask; /* Data flow mask */ |
| 139 | uint8_t q_level; /* queue level set by application for TX data */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 140 | |
| 141 | } tBTA_PAN_CB; |
| 142 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 143 | /* pan data param */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 144 | typedef struct { |
| 145 | BT_HDR hdr; |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 146 | RawAddress src; |
| 147 | RawAddress dst; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 148 | uint16_t protocol; |
| 149 | bool ext; |
| 150 | bool forward; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 151 | |
| 152 | } tBTA_PAN_DATA_PARAMS; |
| 153 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 154 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 155 | * Global data |
| 156 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 157 | |
| 158 | /* PAN control block */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 159 | extern tBTA_PAN_CB bta_pan_cb; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 160 | |
| 161 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 162 | * Function prototypes |
| 163 | ****************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 164 | extern tBTA_PAN_SCB* bta_pan_scb_alloc(void); |
| 165 | extern void bta_pan_scb_dealloc(tBTA_PAN_SCB* p_scb); |
| 166 | extern uint8_t bta_pan_scb_to_idx(tBTA_PAN_SCB* p_scb); |
| 167 | extern tBTA_PAN_SCB* bta_pan_scb_by_handle(uint16_t handle); |
| 168 | extern bool bta_pan_hdl_event(BT_HDR* p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 169 | |
| 170 | /* action functions */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 171 | extern void bta_pan_enable(tBTA_PAN_DATA* p_data); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 172 | extern void bta_pan_disable(void); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 173 | extern void bta_pan_set_role(tBTA_PAN_DATA* p_data); |
| 174 | extern void bta_pan_open(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 175 | extern void bta_pan_api_close(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 176 | extern void bta_pan_set_shutdown(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 177 | extern void bta_pan_rx_path(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 178 | extern void bta_pan_tx_path(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 179 | extern void bta_pan_tx_flow(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 180 | extern void bta_pan_conn_open(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 181 | extern void bta_pan_conn_close(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 182 | extern void bta_pan_writebuf(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 183 | extern void bta_pan_write_buf(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
| 184 | extern void bta_pan_free_buf(tBTA_PAN_SCB* p_scb, tBTA_PAN_DATA* p_data); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 185 | |
| 186 | #endif /* BTA_PAN_INT_H */ |