/******************************************************************************* ** ** Function L2cap_Register ** ** Description This function is called during the task startup ** to register interface functions with L2CAP. ** *******************************************************************************/ static bt_status_t L2cap_Register (UINT16 psm, BOOLEAN ConnType, UINT16 SecLevel) { BTIF_TRACE_DEBUG("L2cap_Register :: psm=%d", psm); if (!BTM_SetSecurityLevel (ConnType, "l2test", /*BTM_SEC_SERVICE_SDP_SERVER*/ BTM_SEC_PROTO_L2CAP, SecLevel, psm, 0, 0)) { BTIF_TRACE_DEBUG("Error:: BTM_SetSecurityLevel failed"); return BT_STATUS_FAIL; } #if 1 if(4113 == psm) { if (!BTM_SetSecurityLevel (ConnType, "l2test 4113", /*BTM_SEC_SERVICE_SDP_SERVER*/ BTM_SEC_PROTO_L2CAP, SecLevel, psm, 0, 0)) { BTIF_TRACE_DEBUG("Error:: BTM_SetSecurityLevel failed"); return BT_STATUS_FAIL; } } #endif g_Psm = L2CA_Register (psm, pl2test_l2c_appl); if(0 == g_Psm) { BTIF_TRACE_DEBUG("Error:: L2CA_Register failed"); return BT_STATUS_FAIL; } return BT_STATUS_SUCCESS; }
static UINT16 L2cap_ErtmConnect(UINT16 psm, BD_ADDR address, tL2CAP_ERTM_INFO *p_ertm_info) { BTIF_TRACE_DEBUG("L2cap_ErtmConnect:: %0x %0x %0x %0x %0x %0x", address[0],address[1],address[2],address[3],address[4],address[5]); if (0 == (g_lcid = L2CA_ErtmConnectReq (psm, address, p_ertm_info))) { BTIF_TRACE_DEBUG("Error:: L2CA_ErtmConnectReq failed for psm %d", psm); } return g_lcid; }
static BOOLEAN L2cap_ConfigReq(UINT16 cid, tL2CAP_CFG_INFO *p_cfg) { BTIF_TRACE_DEBUG("L2cap_ConfigReq:: Invoked\n"); if (p_cfg->fcr_present) { BTIF_TRACE_DEBUG("L2cap_ConfigReq:: mode %u, txwinsz %u, max_trans %u, rtrans_tout %u, mon_tout %u, mps %u\n", p_cfg->fcr.mode, p_cfg->fcr.tx_win_sz, p_cfg->fcr.max_transmit, p_cfg->fcr.rtrans_tout,p_cfg->fcr.mon_tout, p_cfg->fcr.mps); } return L2CA_ConfigReq (cid, p_cfg); }
/******************************************************************************* ** ** Function bta_dm_co_loc_oob ** ** Description This callout function is executed by DM to report the OOB ** data of the local device for the Simple Pairing process ** ** Parameters valid - TRUE, if the local OOB data is retrieved from LM ** c - Simple Pairing Hash C ** r - Simple Pairing Randomnizer R ** ** Returns void. ** *******************************************************************************/ void bta_dm_co_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r) { #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) BTIF_TRACE_DEBUG("bta_dm_co_loc_oob, valid = %d", valid); #ifdef BTIF_DM_OOB_TEST btif_dm_proc_loc_oob(valid, c, r); #endif #else BTIF_TRACE_DEBUG("bta_dm_co_loc_oob: func not ported\n"); #endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */ }
static UINT16 L2cap_Connect(UINT16 psm, bt_bdaddr_t *bd_addr) { BTIF_TRACE_DEBUG("L2cap_Connect:: %0x %0x %0x %0x %0x %0x", bd_addr->address[0],bd_addr->address[1], bd_addr->address[2],bd_addr->address[3],bd_addr->address[4],bd_addr->address[5]); if (0 == (g_lcid = L2CA_ConnectReq (psm, bd_addr->address))) { BTIF_TRACE_DEBUG("Error:: L2CA_ConnectReq failed for psm %d", psm); } return g_lcid; }
/******************************************************************************* ** ** Function bta_dm_co_ble_local_key_reload ** ** Description This callout function is to load the local BLE keys if available ** on the device. ** ** Parameters none ** ** Returns void. ** *******************************************************************************/ void bta_dm_co_ble_load_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er, tBTA_BLE_LOCAL_ID_KEYS *p_id_keys) { #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) BTIF_TRACE_DEBUG("##################################"); BTIF_TRACE_DEBUG("bta_dm_co_ble_load_local_keys: Load local keys if any are persisted"); BTIF_TRACE_DEBUG("##################################"); btif_dm_get_ble_local_keys( p_key_mask, er, p_id_keys); #endif ///defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE #if (SMP_INCLUDED == TRUE) btc_dm_get_ble_local_keys( p_key_mask, er, p_id_keys); #endif ///SMP_INCLUDED == TRUE }
/******************************************************************************* ** ** Function bta_dm_co_le_io_key_req ** ** Description This callout function is executed by DM to get BLE key information ** before SMP pairing gets going. ** ** Parameters bd_addr - The peer device ** *p_max_key_size - max key size local device supported. ** *p_init_key - initiator keys. ** *p_resp_key - responder keys. ** ** Returns void. ** *******************************************************************************/ void bta_dm_co_le_io_key_req(BD_ADDR bd_addr, UINT8 *p_max_key_size, tBTA_LE_KEY_TYPE *p_init_key, tBTA_LE_KEY_TYPE *p_resp_key ) { UNUSED(bd_addr); #if (SMP_INCLUDED == TRUE) BTIF_TRACE_DEBUG("##################################"); BTIF_TRACE_DEBUG("bta_dm_co_le_io_key_req: only setting max size to 16"); BTIF_TRACE_DEBUG("##################################"); *p_max_key_size = 16; *p_init_key = *p_resp_key = (BTA_LE_KEY_PENC | BTA_LE_KEY_PID | BTA_LE_KEY_PCSRK | BTA_LE_KEY_LENC | BTA_LE_KEY_LID | BTA_LE_KEY_LCSRK); #endif ///SMP_INCLUDED == TRUE }
/******************************************************************************* ** ** Function bta_fs_co_unlink ** ** Description This function is called to remove a file whose name ** is given by p_path. ** ** Parameters p_path - (input) name of file to remove (fully qualified path). ** app_id - (input) application ID specified in the enable functions. ** It can be used to identify which profile is the caller ** of the call-out function. ** ** Returns (tBTA_FS_CO_STATUS) status of the call. ** [BTA_FS_CO_OK if successful] ** [BTA_FS_CO_EACCES if read-only] ** [BTA_FS_CO_FAIL otherwise] ** *******************************************************************************/ tBTA_FS_CO_STATUS bta_fs_co_unlink(const char *p_path, UINT8 app_id) { BTIF_TRACE_DEBUG("bta_fs_co_unlink"); int err; tBTA_FS_CO_STATUS status = BTA_FS_CO_OK; char *dirName, *tmp=NULL; struct stat buffer; UNUSED(app_id); if(! p_path) return BTA_FS_CO_FAIL; /* buffer needs to be NULL terminated - so add one more byte to be zero'd out */ #if 0 dirName= (char*) calloc(1, strlen(p_path)); /* <--- this can cause problems */ #else dirName= (char*) calloc(1, strlen(p_path) + 1); #endif strncpy(dirName, p_path, strlen(p_path)); if((tmp=strrchr(dirName, '/'))) { *tmp='\0'; } if (stat(dirName, &buffer) == 0) { status=getAccess (6, &buffer, dirName); free(dirName); } else { BTIF_TRACE_DEBUG("stat() failed! "); free(dirName); return BTA_FS_CO_FAIL; } if(status!= BTA_FS_CO_OK) return status; if ((unlink (p_path)) != 0) { err = errno; if (err == EACCES) status = BTA_FS_CO_EACCES; else status = BTA_FS_CO_FAIL; } return (status); }
/******************************************************************************* ** ** Function bta_fs_co_setdir ** ** Description This function is executed by BTA when the server changes the ** local path ** ** Parameters p_path - the new path. ** app_id - application ID specified in the enable functions. ** It can be used to identify which profile is the caller ** of the call-out function. ** ** Returns void ** *******************************************************************************/ void bta_fs_co_setdir(const char *p_path, UINT8 app_id) { UNUSED(p_path); UNUSED(app_id); BTIF_TRACE_DEBUG("Entered %s. New path: %s", __FUNCTION__, p_path); }
/******************************************************************************* ** ** Function btc_storage_remove_ble_bonding_keys ** ** Description btc storage API - Deletes the bonded device from NVRAM ** ** Returns BT_STATUS_SUCCESS if the deletion was successful, ** BT_STATUS_FAIL otherwise ** *******************************************************************************/ static bt_status_t _btc_storage_remove_ble_bonding_keys(bt_bdaddr_t *remote_bd_addr) { int ret = 0; bdstr_t bdstr; bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr)); BTIF_TRACE_DEBUG(" %s in bd addr:%s",__FUNCTION__, bdstr); if (btc_config_exist(bdstr, BTC_BLE_STORAGE_ADDR_TYPE_STR)) { ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_ADDR_TYPE_STR); } if (btc_config_exist(bdstr, BTC_BLE_STORAGE_LE_KEY_PENC_STR)) { ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_KEY_PENC_STR); } if (btc_config_exist(bdstr, BTC_BLE_STORAGE_LE_KEY_PID_STR)) { ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_KEY_PID_STR); } if (btc_config_exist(bdstr, BTC_BLE_STORAGE_LE_KEY_PCSRK_STR)) { ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_KEY_PCSRK_STR); } if (btc_config_exist(bdstr, BTC_BLE_STORAGE_LE_KEY_LENC_STR)) { ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_KEY_LENC_STR); } if (btc_config_exist(bdstr, BTC_BLE_STORAGE_LE_KEY_LCSRK_STR)) { ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_KEY_LCSRK_STR); } //here don't remove section, because config_save will check it _btc_storage_save(); return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL; }
static bt_status_t _btc_storage_remove_ble_dev_type(bt_bdaddr_t *remote_bd_addr, bool flush) { bool ret = true; bdstr_t bdstr; uint32_t dev_type = 0; bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr)); BTIF_TRACE_DEBUG(" %s in bd addr:%s",__FUNCTION__, bdstr); ret = btc_config_get_int(bdstr, BTC_BLE_STORAGE_DEV_TYPE_STR, (int *)&dev_type); if (ret == false) { //cannot find the key, just return SUCCESS, indicate already removed return BT_STATUS_SUCCESS; } if (dev_type == BT_DEVICE_TYPE_DUMO) { ret = btc_config_set_int(bdstr, BTC_BLE_STORAGE_DEV_TYPE_STR, BT_DEVICE_TYPE_BREDR); } else if (dev_type == BT_DEVICE_TYPE_BLE) { ret = btc_config_remove(bdstr, BTC_BLE_STORAGE_DEV_TYPE_STR); } if (ret == false) { return BT_STATUS_FAIL; } if (flush) { _btc_storage_save(); } return BT_STATUS_SUCCESS; }
int btpan_tap_send(int tap_fd, const BD_ADDR src, const BD_ADDR dst, UINT16 proto, const char* buf, UINT16 len, BOOLEAN ext, BOOLEAN forward) { UNUSED(ext); UNUSED(forward); if(tap_fd != -1) { tETH_HDR eth_hdr; //if(is_empty_eth_addr(dst)) // memcpy(ð_hdr.h_dest, local_addr, ETH_ADDR_LEN); //else memcpy(ð_hdr.h_dest, dst, ETH_ADDR_LEN); memcpy(ð_hdr.h_src, src, ETH_ADDR_LEN); eth_hdr.h_proto = htons(proto); char packet[2000]; memcpy(packet, ð_hdr, sizeof(tETH_HDR)); if(len > 2000) { ALOGE("btpan_tap_send eth packet size:%d is exceeded limit!", len); return -1; } memcpy(packet + sizeof(tETH_HDR), buf, len); /* Send data to network interface */ //btnet_send(btpan_cb.conn[i].sock.sock, &buffer, (len + sizeof(tETH_HDR))); //dump_bin("packet to network", packet, len + sizeof(tETH_HDR)); int ret = write(tap_fd, packet, len + sizeof(tETH_HDR)); BTIF_TRACE_DEBUG("ret:%d", ret); return ret; } return -1; }
int btpan_tap_send(int tap_fd, const BD_ADDR src, const BD_ADDR dst, UINT16 proto, const char* buf, UINT16 len, BOOLEAN ext, BOOLEAN forward) { UNUSED(ext); UNUSED(forward); if (tap_fd != INVALID_FD) { tETH_HDR eth_hdr; memcpy(ð_hdr.h_dest, dst, ETH_ADDR_LEN); memcpy(ð_hdr.h_src, src, ETH_ADDR_LEN); eth_hdr.h_proto = htons(proto); char packet[TAP_MAX_PKT_WRITE_LEN + sizeof(tETH_HDR)]; memcpy(packet, ð_hdr, sizeof(tETH_HDR)); if (len > TAP_MAX_PKT_WRITE_LEN) { LOG_ERROR(LOG_TAG, "btpan_tap_send eth packet size:%d is exceeded limit!", len); return -1; } memcpy(packet + sizeof(tETH_HDR), buf, len); /* Send data to network interface */ int ret = write(tap_fd, packet, len + sizeof(tETH_HDR)); BTIF_TRACE_DEBUG("ret:%d", ret); return ret; } return -1; }
static int tap_if_up(const char *devname, const bt_bdaddr_t *addr) { struct ifreq ifr; int sk, err; sk = socket(AF_INET, SOCK_DGRAM, 0); if (sk < 0) return -1; //set mac addr memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, devname, IFNAMSIZ - 1); err = ioctl(sk, SIOCGIFHWADDR, &ifr); if (err < 0) { BTIF_TRACE_ERROR("Could not get network hardware for interface:%s, errno:%s", devname, strerror(errno)); close(sk); return -1; } strncpy(ifr.ifr_name, devname, IFNAMSIZ - 1); memcpy(ifr.ifr_hwaddr.sa_data, addr->address, 6); /* The IEEE has specified that the most significant bit of the most significant byte is used to * determine a multicast address. If its a 1, that means multicast, 0 means unicast. * Kernel returns an error if we try to set a multicast address for the tun-tap ethernet interface. * Mask this bit to avoid any issue with auto generated address. */ if (ifr.ifr_hwaddr.sa_data[0] & 0x01) { BTIF_TRACE_WARNING("Not a unicast MAC address, force multicast bit flipping"); ifr.ifr_hwaddr.sa_data[0] &= ~0x01; } err = ioctl(sk, SIOCSIFHWADDR, (caddr_t)&ifr); if (err < 0) { BTIF_TRACE_ERROR("Could not set bt address for interface:%s, errno:%s", devname, strerror(errno)); close(sk); return -1; } //bring it up memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, devname, IF_NAMESIZE - 1); ifr.ifr_flags |= IFF_UP; ifr.ifr_flags |= IFF_MULTICAST; err = ioctl(sk, SIOCSIFFLAGS, (caddr_t) &ifr); if (err < 0) { BTIF_TRACE_ERROR("Could not bring up network interface:%s, errno:%d", devname, errno); close(sk); return -1; } close(sk); BTIF_TRACE_DEBUG("network interface: %s is up", devname); return 0; }
/******************************************************************************* ** ** Function bta_fs_co_access ** ** Description This function is called to check the existence of ** a file or directory, and return whether or not it is a ** directory or length of the file. ** ** Parameters p_path - (input) file or directory to access (fully qualified path). ** mode - (input) [BTA_FS_ACC_EXIST, BTA_FS_ACC_READ, or BTA_FS_ACC_RDWR] ** p_is_dir - (output) returns TRUE if p_path specifies a directory. ** app_id - (input) application ID specified in the enable functions. ** It can be used to identify which profile is the caller ** of the call-out function. ** ** Returns (tBTA_FS_CO_STATUS) status of the call. ** [BTA_FS_CO_OK if it exists] ** [BTA_FS_CO_EACCES if permissions are wrong] ** [BTA_FS_CO_FAIL if it does not exist] ** *******************************************************************************/ tBTA_FS_CO_STATUS bta_fs_co_access(const char *p_path, int mode, BOOLEAN *p_is_dir, UINT8 app_id) { int os_mode = 0; tBTA_FS_CO_STATUS status = BTA_FS_CO_OK; struct stat buffer; UNUSED(app_id); #if (TRUE==BTA_FS_DEBUG) LOGI("***********CHECKING ACCESS TO = %s", p_path); #endif #if (defined BTA_PBS_INCLUDED) && (BTA_PBS_INCLUDED == TRUE) if (app_id == UI_PBS_ID) { *p_is_dir = TRUE; #if (TRUE==BTA_FS_DEBUG) LOGI("***********SUPPORTED REPO = %d", bta_pbs_cfg.supported_repositories); #endif //Check if SIM contact requested, and if so if it's supported. //If not, return error! if (strstr(p_path,"SIM1") && !(bta_pbs_cfg.supported_repositories & 0x2)) { LOGI("***********RETURNING FAIL!"); return BTA_FS_CO_FAIL; } #if (TRUE==BTA_FS_DEBUG) LOGI("***********RETURNING success!"); #endif return (status); } #endif *p_is_dir = FALSE; if (mode == BTA_FS_ACC_RDWR) os_mode = 6; else if (mode == BTA_FS_ACC_READ) os_mode = 4; if (stat(p_path, &buffer) == 0) { /* Determine if the object is a file or directory */ if (S_ISDIR(buffer.st_mode)) *p_is_dir = TRUE; } else { BTIF_TRACE_DEBUG("stat() failed! "); return BTA_FS_CO_FAIL; } status=getAccess (os_mode, &buffer, (char*)p_path); return (status); }
/******************************************************************************* ** ** Function bta_dm_co_rmt_oob ** ** Description This callout function is executed by DM to request the OOB ** data for the remote device for the Simple Pairing process ** Need to call bta_dm_ci_rmt_oob() in response ** ** Parameters bd_addr - The peer device ** ** Returns void. ** *******************************************************************************/ void bta_dm_co_rmt_oob(BD_ADDR bd_addr) { BT_OCTET16 p_c; BT_OCTET16 p_r; BOOLEAN result = FALSE; #ifdef BTIF_DM_OOB_TEST #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) result = btif_dm_proc_rmt_oob(bd_addr, p_c, p_r); #else BTIF_TRACE_DEBUG("bta_dm_rmt_oob: func not ported\n"); #endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */ #endif BTIF_TRACE_DEBUG("bta_dm_co_rmt_oob: result=%d", result); bta_dm_ci_rmt_oob(result, bd_addr, p_c, p_r); }
static inline bool should_forward(tETH_HDR* hdr) { uint16_t proto = ntohs(hdr->h_proto); if(proto == ETH_P_IP || proto == ETH_P_ARP || proto == ETH_P_IPV6) return true; BTIF_TRACE_DEBUG("unknown proto:%x", proto); return false; }
/******************************************************************************* ** ** Function bta_dm_co_io_req ** ** Description This callout function is executed by DM to get IO capabilities ** of the local device for the Simple Pairing process ** ** Parameters bd_addr - The peer device ** *p_io_cap - The local Input/Output capabilities ** *p_oob_data - TRUE, if OOB data is available for the peer device. ** *p_auth_req - TRUE, if MITM protection is required. ** ** Returns void. ** *******************************************************************************/ void bta_dm_co_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap, tBTA_OOB_DATA *p_oob_data, tBTA_AUTH_REQ *p_auth_req, BOOLEAN is_orig) { UNUSED(bd_addr); #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) #if (BTM_OOB_INCLUDED == TRUE) btif_dm_set_oob_for_io_req(p_oob_data); #endif btif_dm_proc_io_req(bd_addr, p_io_cap, p_oob_data, p_auth_req, is_orig); #else BTIF_TRACE_DEBUG("bta_dm_co_io_req: func not ported\n"); #endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */ BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_oob_data = %d", *p_oob_data); BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_io_cap = %d", *p_io_cap); BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_auth_req = %d", *p_auth_req); BTIF_TRACE_DEBUG("bta_dm_co_io_req is_orig = %d", is_orig); }
void btpan_close_handle(btpan_conn_t *p) { BTIF_TRACE_DEBUG("btpan_close_handle : close handle %d", p->handle); p->handle = -1; p->local_role = -1; p->remote_role = -1; memset(&p->peer, 0, 6); }
static bt_status_t btpan_jni_init(const btpan_callbacks_t* callbacks) { BTIF_TRACE_DEBUG("stack_initialized = %d, btpan_cb.enabled:%d", stack_initialized, btpan_cb.enabled); jni_initialized = TRUE; if(stack_initialized && !btpan_cb.enabled) btif_pan_init(); callback = *callbacks; return BT_STATUS_SUCCESS; }
static bt_status_t btpan_connect(const bt_bdaddr_t *bd_addr, int local_role, int remote_role) { BTIF_TRACE_DEBUG("local_role:%d, remote_role:%d", local_role, remote_role); int bta_local_role = btpan_role_to_bta(local_role); int bta_remote_role = btpan_role_to_bta(remote_role); btpan_new_conn(-1, bd_addr->address, bta_local_role, bta_remote_role); BTA_PanOpen((UINT8*)bd_addr->address, bta_local_role, bta_remote_role); return BT_STATUS_SUCCESS; }
/******************************************************************************* ** ** Function btif_pan_init ** ** Description initializes the pan interface ** ** Returns bt_status_t ** *******************************************************************************/ void btif_pan_init() { BTIF_TRACE_DEBUG("jni_initialized = %d, btpan_cb.enabled:%d", jni_initialized, btpan_cb.enabled); stack_initialized = TRUE; if (jni_initialized && !btpan_cb.enabled) { BTIF_TRACE_DEBUG("Enabling PAN...."); memset(&btpan_cb, 0, sizeof(btpan_cb)); btpan_cb.tap_fd = -1; btpan_cb.flow = 1; int i; for(i = 0; i < MAX_PAN_CONNS; i++) btpan_cleanup_conn(&btpan_cb.conns[i]); BTA_PanEnable(bta_pan_callback); btpan_cb.enabled = 1; btpan_enable(BTPAN_LOCAL_ROLE); } }
static BOOLEAN L2cap_ConnectRsp(BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 result, UINT16 status) { if (!L2CA_ConnectRsp (p_bd_addr, id, lcid, result, status)) { BTIF_TRACE_DEBUG("L2CA_ConnectRsp:: error "); return BT_STATUS_FAIL; } return BT_STATUS_SUCCESS; }
/******************************************************************************* ** ** Function bta_dm_co_io_rsp ** ** Description This callout function is executed by DM to report IO capabilities ** of the peer device for the Simple Pairing process ** ** Parameters bd_addr - The peer device ** io_cap - The remote Input/Output capabilities ** oob_data - TRUE, if OOB data is available for the peer device. ** auth_req - TRUE, if MITM protection is required. ** ** Returns void. ** *******************************************************************************/ void bta_dm_co_io_rsp(BD_ADDR bd_addr, tBTA_IO_CAP io_cap, tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req) { #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) btif_dm_proc_io_rsp(bd_addr, io_cap, oob_data, auth_req); #else BTIF_TRACE_DEBUG("bta_dm_co_io_rsp: func not ported\n"); #endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */ }
btpan_conn_t* btpan_new_conn(int handle, const BD_ADDR addr, int local_role, int remote_role) { for (int i = 0; i < MAX_PAN_CONNS; i++) { BTIF_TRACE_DEBUG("conns[%d]:%d", i, btpan_cb.conns[i].handle); if (btpan_cb.conns[i].handle == -1) { BTIF_TRACE_DEBUG("handle:%d, local_role:%d, remote_role:%d", handle, local_role, remote_role); btpan_cb.conns[i].handle = handle; bdcpy(btpan_cb.conns[i].peer, addr); btpan_cb.conns[i].local_role = local_role; btpan_cb.conns[i].remote_role = remote_role; return &btpan_cb.conns[i]; } } BTIF_TRACE_DEBUG("MAX_PAN_CONNS:%d exceeded, return NULL as failed", MAX_PAN_CONNS); return NULL; }
static UINT8 L2cap_DataWrite (UINT16 cid, char *p_data, UINT32 len) { BTIF_TRACE_DEBUG("L2cap_DataWrite:: Invoked"); BT_HDR *p_msg = NULL;(BT_HDR *) GKI_getpoolbuf (GKI_POOL_ID_3); UINT8 *ptr, *p_start; p_msg = (BT_HDR *) GKI_getpoolbuf (GKI_POOL_ID_3); BTIF_TRACE_DEBUG("GKI_getpoolbuf"); if (!p_msg) { BTIF_TRACE_DEBUG("No resource to allocate"); return BT_STATUS_FAIL; } p_msg->offset = L2CAP_MIN_OFFSET; ptr = p_start = (UINT8 *)(p_msg + 1) + L2CAP_MIN_OFFSET; p_msg->len = len; //Sends len bytes, irrespective of what you copy to the buffer memcpy(ptr, p_data, len); return L2CA_DataWrite(cid, p_msg); }
static inline int bta_role_to_btpan(int bta_pan_role) { int btpan_role = 0; BTIF_TRACE_DEBUG("bta_pan_role:0x%x", bta_pan_role); if (bta_pan_role & PAN_ROLE_NAP_SERVER) btpan_role |= BTPAN_ROLE_PANNAP; if (bta_pan_role & PAN_ROLE_CLIENT) btpan_role |= BTPAN_ROLE_PANU; return btpan_role; }
static BOOLEAN L2cap_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 result, UINT16 status, tL2CAP_ERTM_INFO *p_ertm_info) { if (!L2CA_ErtmConnectRsp (p_bd_addr, id, lcid, result, status, p_ertm_info)) { BTIF_TRACE_DEBUG("L2CA_ErtmConnectRsp:: error "); return BT_STATUS_FAIL; } return BT_STATUS_SUCCESS; }
static inline int btpan_role_to_bta(int btpan_role) { int bta_pan_role = PAN_ROLE_INACTIVE; BTIF_TRACE_DEBUG("btpan_role:0x%x", btpan_role); if (btpan_role & BTPAN_ROLE_PANNAP) bta_pan_role |= PAN_ROLE_NAP_SERVER; if (btpan_role & BTPAN_ROLE_PANU) bta_pan_role |= PAN_ROLE_CLIENT; return bta_pan_role; }
static bt_status_t btpan_enable(int local_role) { #if BTA_PAN_INCLUDED == TRUE BTIF_TRACE_DEBUG("%s - local_role: %d", __func__, local_role); int bta_pan_role = btpan_role_to_bta(local_role); BTA_PanSetRole(bta_pan_role, &bta_panu_info, NULL, &bta_pan_nap_info); btpan_dev_local_role = local_role; return BT_STATUS_SUCCESS; #else return BT_STATUS_FAIL; #endif }