Home | History | Annotate | Download | only in include
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2003-2014 Broadcom Corporation
      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 **  Name:          vendor_ble.h
     22 **
     23 **  Description:   This file contains vendor specific feature header
     24 **                 for BLE
     25 ******************************************************************************/
     26 #ifndef VENDOR_BLE_H
     27 #define VENDOR_BLE_H
     28 
     29 #include "btm_int.h"
     30 #include "btm_ble_api.h"
     31 #include "vendor_api.h"
     32 
     33 /* RPA offload VSC specifics */
     34 #define BTM_BLE_META_IRK_ENABLE         0x01
     35 #define BTM_BLE_META_ADD_IRK_ENTRY      0x02
     36 #define BTM_BLE_META_REMOVE_IRK_ENTRY   0x03
     37 #define BTM_BLE_META_CLEAR_IRK_LIST     0x04
     38 #define BTM_BLE_META_READ_IRK_ENTRY     0x05
     39 #define BTM_BLE_META_CS_RESOLVE_ADDR    0x00000001
     40 #define BTM_BLE_IRK_ENABLE_LEN          2
     41 
     42 /* BLE meta vsc header: 1 bytes of sub_code, 1 byte of PCF action */
     43 #define BTM_BLE_META_HDR_LENGTH     3
     44 #define BTM_BLE_PF_FEAT_SEL_LEN     18
     45 #define BTM_BLE_PCF_ENABLE_LEN      2
     46 #define BTM_BLE_META_ADDR_LEN       7
     47 #define BTM_BLE_META_UUID_LEN       40
     48 #define BTM_BLE_META_ADD_IRK_LEN        24
     49 #define BTM_BLE_META_REMOVE_IRK_LEN     8
     50 #define BTM_BLE_META_CLEAR_IRK_LEN      1
     51 #define BTM_BLE_META_READ_IRK_LEN       2
     52 #define BTM_BLE_META_ADD_WL_ATTR_LEN    9
     53 
     54 #define BTM_BLE_PF_SELECT_NONE              0
     55 #define BTM_BLE_PF_ADDR_FILTER_BIT          BTM_BLE_PF_BIT_TO_MASK(BTM_BLE_PF_ADDR_FILTER)
     56 #define BTM_BLE_PF_SRVC_DATA_BIT            BTM_BLE_PF_BIT_TO_MASK(BTM_BLE_PF_SRVC_DATA)
     57 #define BTM_BLE_PF_SRVC_UUID_BIT            BTM_BLE_PF_BIT_TO_MASK(BTM_BLE_PF_SRVC_UUID)
     58 #define BTM_BLE_PF_SRVC_SOL_UUID_BIT        BTM_BLE_PF_BIT_TO_MASK(BTM_BLE_PF_SRVC_SOL_UUID)
     59 #define BTM_BLE_PF_LOCAL_NAME_BIT           BTM_BLE_PF_BIT_TO_MASK(BTM_BLE_PF_LOCAL_NAME)
     60 #define BTM_BLE_PF_MANU_DATA_BIT            BTM_BLE_PF_BIT_TO_MASK(BTM_BLE_PF_MANU_DATA)
     61 #define BTM_BLE_PF_SRVC_DATA_PATTERN_BIT    BTM_BLE_PF_BIT_TO_MASK(BTM_BLE_PF_SRVC_DATA_PATTERN)
     62 typedef UINT8 tBTM_BLE_PF_SEL_MASK;
     63 
     64 #define BTM_BLE_MAX_FILTER_COUNTER  (BTM_BLE_MAX_ADDR_FILTER + 1) /* per device filter + one generic filter indexed by 0 */
     65 
     66 #define BTM_CS_IRK_LIST_INVALID     0xff
     67 
     68 typedef struct
     69 {
     70     BOOLEAN         in_use;
     71     BD_ADDR         bd_addr;        /* must be the address used in controller */
     72     BD_ADDR         psuedo_bda;        /* the random pseudo address */
     73     UINT8           index;
     74 }tBTM_BLE_IRK_ENTRY;
     75 
     76 
     77 typedef struct
     78 {
     79     BD_ADDR         *irk_q;
     80     BD_ADDR         *irk_q_random_pseudo;
     81     UINT8           *irk_q_action;
     82     UINT8           q_next;
     83     UINT8           q_pending;
     84 } tBTM_BLE_IRK_Q;
     85 
     86 /* control block for BLE customer specific feature */
     87 typedef struct
     88 {
     89     BOOLEAN             enable;
     90 
     91     UINT8               op_type;
     92     tBLE_BD_ADDR        cur_filter_target;
     93 
     94     UINT8               irk_list_size;
     95     UINT8               irk_avail_size;
     96     tBTM_BLE_IRK_ENTRY  *irk_list;
     97     tBTM_BLE_IRK_Q      irk_pend_q;
     98     UINT8                max_filter_supported;
     99     tBTM_BLE_PF_CMPL_CBACK *p_scan_pf_cback;
    100 }tBTM_BLE_VENDOR_CB;
    101 
    102 #ifdef __cplusplus
    103 extern "C"
    104 {
    105 #endif
    106 
    107 #if VENDOR_DYNAMIC_MEMORY == FALSE
    108 BTM_API extern tBTM_BLE_VENDOR_CB  btm_ble_vendor_cb;
    109 #else
    110 BTM_API extern tBTM_BLE_VENDOR_CB *btm_ble_vendor_ptr;
    111 #define btm_ble_vendor_cb (*btm_ble_vendor_ptr)
    112 #endif
    113 
    114 extern void btm_ble_vendor_irk_list_known_dev(BOOLEAN enable);
    115 extern tBTM_STATUS btm_ble_read_irk_entry(BD_ADDR target_bda);
    116 extern void btm_ble_vendor_disable_irk_list(void);
    117 extern BOOLEAN btm_ble_vendor_irk_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec);
    118 extern void btm_ble_vendor_irk_list_remove_dev(tBTM_SEC_DEV_REC *p_dev_rec);
    119 extern tBTM_STATUS btm_ble_enable_vendor_feature (BOOLEAN enable, UINT32 feature_bit);
    120 
    121 extern void btm_ble_vendor_init(UINT8 max_irk_list_sz);
    122 extern void btm_ble_vendor_cleanup(void);
    123 extern BOOLEAN btm_ble_vendor_write_device_wl_attribute (tBLE_ADDR_TYPE addr_type, BD_ADDR bd_addr, UINT8 attribute);
    124 extern tBTM_STATUS btm_ble_vendor_enable_irk_feature(BOOLEAN enable);
    125 
    126 #ifdef __cplusplus
    127 }
    128 #endif
    129 
    130 #endif
    131 
    132 
    133