1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
/*****************************************************************************
**
** Name: bnep_api.h
**
** Description: This interface file contains the interface to the Bluetooth
** Network Encapsilation Protocol (BNEP).
**
**
** Copyright (c) 2001-2004, WIDCOMM Inc., All Rights Reserved.
** WIDCOMM Bluetooth Core. Proprietary and confidential.
******************************************************************************/
#ifndef BNEP_API_H
#define BNEP_API_H
#include "l2c_api.h"
/*****************************************************************************
** Constants
*****************************************************************************/
/* Define the minimum offset needed in a GKI buffer for
** sending BNEP packets. Note, we are currently not sending
** extension headers, but may in the future, so allow
** space for them
*/
#define BNEP_MINIMUM_OFFSET (15 + L2CAP_MIN_OFFSET)
#define BNEP_INVALID_HANDLE 0xFFFF
/*****************************************************************************
** Type Definitions
*****************************************************************************/
/* Define the result codes from BNEP
*/
enum
{
BNEP_SUCCESS, /* Success */
BNEP_CONN_DISCONNECTED, /* Connection terminated */
BNEP_NO_RESOURCES, /* No resources */
BNEP_MTU_EXCEDED, /* Attempt to write long data */
BNEP_INVALID_OFFSET, /* Insufficient offset in GKI buffer */
BNEP_CONN_FAILED, /* Connection failed */
BNEP_CONN_FAILED_CFG, /* Connection failed cos of config */
BNEP_CONN_FAILED_SRC_UUID, /* Connection failed wrong source UUID */
BNEP_CONN_FAILED_DST_UUID, /* Connection failed wrong destination UUID */
BNEP_CONN_FAILED_UUID_SIZE, /* Connection failed wrong size UUID */
BNEP_Q_SIZE_EXCEEDED, /* Too many buffers to dest */
BNEP_TOO_MANY_FILTERS, /* Too many local filters specified */
BNEP_SET_FILTER_FAIL, /* Set Filter failed */
BNEP_WRONG_HANDLE, /* Wrong handle for the connection */
BNEP_WRONG_STATE, /* Connection is in wrong state */
BNEP_SECURITY_FAIL, /* Failed because of security */
BNEP_IGNORE_CMD, /* To ignore the rcvd command */
BNEP_TX_FLOW_ON, /* tx data flow enabled */
BNEP_TX_FLOW_OFF /* tx data flow disabled */
}; typedef UINT8 tBNEP_RESULT;
/***************************
** Callback Functions
****************************/
/* Connection state change callback prototype. Parameters are
** Connection handle
** BD Address of remote
** Connection state change result
** BNEP_SUCCESS indicates connection is success
** All values are used to indicate the reason for failure
** Flag to indicate if it is just a role change
*/
typedef void (tBNEP_CONN_STATE_CB) (UINT16 handle,
BD_ADDR rem_bda,
tBNEP_RESULT result,
BOOLEAN is_role_change);
/* Connection indication callback prototype. Parameters are
** BD Address of remote, remote UUID and local UUID
** and flag to indicate role change and handle to the connection
** When BNEP calls this function profile should
** use BNEP_ConnectResp call to accept or reject the request
*/
typedef void (tBNEP_CONNECT_IND_CB) (UINT16 handle,
BD_ADDR bd_addr,
tBT_UUID *remote_uuid,
tBT_UUID *local_uuid,
BOOLEAN is_role_change);
/* Data buffer received indication callback prototype. Parameters are
** Handle to the connection
** Source BD/Ethernet Address
** Dest BD/Ethernet address
** Protocol
** Pointer to the buffer
** Flag to indicate whether extension headers to be forwarded are present
*/
typedef void (tBNEP_DATA_BUF_CB) (UINT16 handle,
UINT8 *src,
UINT8 *dst,
UINT16 protocol,
BT_HDR *p_buf,
BOOLEAN fw_ext_present);
/* Data received indication callback prototype. Parameters are
** Handle to the connection
** Source BD/Ethernet Address
** Dest BD/Ethernet address
** Protocol
** Pointer to the beginning of the data
** Length of data
** Flag to indicate whether extension headers to be forwarded are present
*/
typedef void (tBNEP_DATA_IND_CB) (UINT16 handle,
UINT8 *src,
UINT8 *dst,
UINT16 protocol,
UINT8 *p_data,
UINT16 len,
BOOLEAN fw_ext_present);
/* Flow control callback for TX data. Parameters are
** Handle to the connection
** Event flow status
*/
typedef void (tBNEP_TX_DATA_FLOW_CB) (UINT16 handle,
tBNEP_RESULT event);
/* Filters received indication callback prototype. Parameters are
** Handle to the connection
** TRUE if the cb is called for indication
** Ignore this if it is indication, otherwise it is the result
** for the filter set operation performed by the local
** device
** Number of protocol filters present
** Pointer to the filters start. Filters are present in pairs
** of start of the range and end of the range.
** They will be present in big endian order. First
** two bytes will be starting of the first range and
** next two bytes will be ending of the range.
*/
typedef void (tBNEP_FILTER_IND_CB) (UINT16 handle,
BOOLEAN indication,
tBNEP_RESULT result,
UINT16 num_filters,
UINT8 *p_filters);
/* Multicast Filters received indication callback prototype. Parameters are
** Handle to the connection
** TRUE if the cb is called for indication
** Ignore this if it is indication, otherwise it is the result
** for the filter set operation performed by the local
** device
** Number of multicast filters present
** Pointer to the filters start. Filters are present in pairs
** of start of the range and end of the range.
** First six bytes will be starting of the first range and
** next six bytes will be ending of the range.
*/
typedef void (tBNEP_MFILTER_IND_CB) (UINT16 handle,
BOOLEAN indication,
tBNEP_RESULT result,
UINT16 num_mfilters,
UINT8 *p_mfilters);
/* This is the structure used by profile to register with BNEP */
typedef struct
{
tBNEP_CONNECT_IND_CB *p_conn_ind_cb; /* To indicate the conn request */
tBNEP_CONN_STATE_CB *p_conn_state_cb; /* To indicate conn state change */
tBNEP_DATA_IND_CB *p_data_ind_cb; /* To pass the data received */
tBNEP_DATA_BUF_CB *p_data_buf_cb; /* To pass the data buffer received */
tBNEP_TX_DATA_FLOW_CB *p_tx_data_flow_cb; /* data flow callback */
tBNEP_FILTER_IND_CB *p_filter_ind_cb; /* To indicate that peer set protocol filters */
tBNEP_MFILTER_IND_CB *p_mfilter_ind_cb; /* To indicate that peer set mcast filters */
} tBNEP_REGISTER;
/* This is the structure used by profile to get the status of BNEP */
typedef struct
{
#define BNEP_STATUS_FAILE 0
#define BNEP_STATUS_CONNECTED 1
UINT8 con_status;
UINT16 l2cap_cid;
BD_ADDR rem_bda;
UINT16 rem_mtu_size;
UINT16 xmit_q_depth;
UINT16 sent_num_filters;
UINT16 sent_mcast_filters;
UINT16 rcvd_num_filters;
UINT16 rcvd_mcast_filters;
tBT_UUID src_uuid;
tBT_UUID dst_uuid;
} tBNEP_STATUS;
/*****************************************************************************
** External Function Declarations
*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
**
** Function BNEP_Register
**
** Description This function is called by the upper layer to register
** its callbacks with BNEP
**
** Parameters: p_reg_info - contains all callback function pointers
**
**
** Returns BNEP_SUCCESS if registered successfully
** BNEP_FAILURE if connection state callback is missing
**
*******************************************************************************/
BNEP_API extern tBNEP_RESULT BNEP_Register (tBNEP_REGISTER *p_reg_info);
/*******************************************************************************
**
** Function BNEP_Deregister
**
** Description This function is called by the upper layer to de-register
** its callbacks.
**
** Parameters: void
**
**
** Returns void
**
*******************************************************************************/
BNEP_API extern void BNEP_Deregister (void);
/*******************************************************************************
**
** Function BNEP_Connect
**
** Description This function creates a BNEP connection to a remote
** device.
**
** Parameters: p_rem_addr - BD_ADDR of the peer
** src_uuid - source uuid for the connection
** dst_uuid - destination uuid for the connection
** p_handle - pointer to return the handle for the connection
**
** Returns BNEP_SUCCESS if connection started
** BNEP_NO_RESOURCES if no resources
**
*******************************************************************************/
BNEP_API extern tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
tBT_UUID *src_uuid,
tBT_UUID *dst_uuid,
UINT16 *p_handle);
/*******************************************************************************
**
** Function BNEP_ConnectResp
**
** Description This function is called in responce to connection indication
**
**
** Parameters: handle - handle given in the connection indication
** resp - responce for the connection indication
**
** Returns BNEP_SUCCESS if connection started
** BNEP_WRONG_HANDLE if the connection is not found
** BNEP_WRONG_STATE if the responce is not expected
**
*******************************************************************************/
BNEP_API extern tBNEP_RESULT BNEP_ConnectResp (UINT16 handle, tBNEP_RESULT resp);
/*******************************************************************************
**
** Function BNEP_Disconnect
**
** Description This function is called to close the specified connection.
**
** Parameters: handle - handle of the connection
**
** Returns BNEP_SUCCESS if connection is disconnected
** BNEP_WRONG_HANDLE if no connection is not found
**
*******************************************************************************/
BNEP_API extern tBNEP_RESULT BNEP_Disconnect (UINT16 handle);
/*******************************************************************************
**
** Function BNEP_WriteBuf
**
** Description This function sends data in a GKI buffer on BNEP connection
**
** Parameters: handle - handle of the connection to write
** p_dest_addr - BD_ADDR/Ethernet addr of the destination
** p_buf - pointer to address of buffer with data
** protocol - protocol type of the packet
** p_src_addr - (optional) BD_ADDR/ethernet address of the source
** (should be NULL if it is local BD Addr)
** fw_ext_present - forwarded extensions present
**
** Returns: BNEP_WRONG_HANDLE - if passed handle is not valid
** BNEP_MTU_EXCEDED - If the data length is greater than MTU
** BNEP_IGNORE_CMD - If the packet is filtered out
** BNEP_Q_SIZE_EXCEEDED - If the Tx Q is full
** BNEP_SUCCESS - If written successfully
**
*******************************************************************************/
BNEP_API extern tBNEP_RESULT BNEP_WriteBuf (UINT16 handle,
UINT8 *p_dest_addr,
BT_HDR *p_buf,
UINT16 protocol,
UINT8 *p_src_addr,
BOOLEAN fw_ext_present);
/*******************************************************************************
**
** Function BNEP_Write
**
** Description This function sends data over a BNEP connection
**
** Parameters: handle - handle of the connection to write
** p_dest_addr - BD_ADDR/Ethernet addr of the destination
** p_data - pointer to data start
** protocol - protocol type of the packet
** p_src_addr - (optional) BD_ADDR/ethernet address of the source
** (should be NULL if it is local BD Addr)
** fw_ext_present - forwarded extensions present
**
** Returns: BNEP_WRONG_HANDLE - if passed handle is not valid
** BNEP_MTU_EXCEDED - If the data length is greater than MTU
** BNEP_IGNORE_CMD - If the packet is filtered out
** BNEP_Q_SIZE_EXCEEDED - If the Tx Q is full
** BNEP_NO_RESOURCES - If not able to allocate a buffer
** BNEP_SUCCESS - If written successfully
**
*******************************************************************************/
BNEP_API extern tBNEP_RESULT BNEP_Write (UINT16 handle,
UINT8 *p_dest_addr,
UINT8 *p_data,
UINT16 len,
UINT16 protocol,
UINT8 *p_src_addr,
BOOLEAN fw_ext_present);
/*******************************************************************************
**
** Function BNEP_SetProtocolFilters
**
** Description This function sets the protocol filters on peer device
**
** Parameters: handle - Handle for the connection
** num_filters - total number of filter ranges
** p_start_array - Array of beginings of all protocol ranges
** p_end_array - Array of ends of all protocol ranges
**
** Returns BNEP_WRONG_HANDLE - if the connection handle is not valid
** BNEP_SET_FILTER_FAIL - if the connection is in wrong state
** BNEP_TOO_MANY_FILTERS - if too many filters
** BNEP_SUCCESS - if request sent successfully
**
*******************************************************************************/
BNEP_API extern tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle,
UINT16 num_filters,
UINT16 *p_start_array,
UINT16 *p_end_array);
/*******************************************************************************
**
** Function BNEP_SetMulticastFilters
**
** Description This function sets the filters for multicast addresses for BNEP.
**
** Parameters: handle - Handle for the connection
** num_filters - total number of filter ranges
** p_start_array - Pointer to sequence of beginings of all
** multicast address ranges
** p_end_array - Pointer to sequence of ends of all
** multicast address ranges
**
** Returns BNEP_WRONG_HANDLE - if the connection handle is not valid
** BNEP_SET_FILTER_FAIL - if the connection is in wrong state
** BNEP_TOO_MANY_FILTERS - if too many filters
** BNEP_SUCCESS - if request sent successfully
**
*******************************************************************************/
BNEP_API extern tBNEP_RESULT BNEP_SetMulticastFilters (UINT16 handle,
UINT16 num_filters,
UINT8 *p_start_array,
UINT8 *p_end_array);
/*******************************************************************************
**
** Function BNEP_GetMyBdAddr
**
** Description This function returns a pointer to the local device BD address.
** If the BD address has not been read yet, it returns NULL.
**
** Returns the BD address
**
*******************************************************************************/
BNEP_API extern UINT8 *BNEP_GetMyBdAddr (void);
/*******************************************************************************
**
** Function BNEP_SetTraceLevel
**
** Description This function sets the trace level for BNEP. If called with
** a value of 0xFF, it simply reads the current trace level.
**
** Returns the new (current) trace level
**
*******************************************************************************/
BNEP_API extern UINT8 BNEP_SetTraceLevel (UINT8 new_level);
/*******************************************************************************
**
** Function BNEP_Init
**
** Description This function initializes the BNEP unit. It should be called
** before accessing any other APIs to initialize the control block
**
** Returns void
**
*******************************************************************************/
BNEP_API extern void BNEP_Init (void);
/*******************************************************************************
**
** Function BNEP_GetStatus
**
** Description This function gets the status information for BNEP connection
**
** Returns BNEP_SUCCESS - if the status is available
** BNEP_NO_RESOURCES - if no structure is passed for output
** BNEP_WRONG_HANDLE - if the handle is invalid
** BNEP_WRONG_STATE - if not in connected state
**
*******************************************************************************/
BNEP_API extern tBNEP_RESULT BNEP_GetStatus (UINT16 handle, tBNEP_STATUS *p_status);
#ifdef __cplusplus
}
#endif
#endif
|