• Home
  • Raw
  • Download

Lines Matching refs:slot

174   int slot = -1;  in find_rfc_slot_by_pending_sdp()  local
179 slot = i; in find_rfc_slot_by_pending_sdp()
182 return (slot == -1) ? NULL : &rfc_slots[slot]; in find_rfc_slot_by_pending_sdp()
204 rfc_slot_t* slot = find_free_slot(); in alloc_rfc_slot() local
205 if (!slot) { in alloc_rfc_slot()
220 slot->fd = fds[0]; in alloc_rfc_slot()
221 slot->app_fd = fds[1]; in alloc_rfc_slot()
222 slot->security = security; in alloc_rfc_slot()
223 slot->scn = channel; in alloc_rfc_slot()
224 slot->app_uid = -1; in alloc_rfc_slot()
226 slot->is_service_uuid_valid = !uuid.IsEmpty(); in alloc_rfc_slot()
227 slot->service_uuid = uuid; in alloc_rfc_slot()
230 strlcpy(slot->service_name, name, sizeof(slot->service_name)); in alloc_rfc_slot()
232 memset(slot->service_name, 0, sizeof(slot->service_name)); in alloc_rfc_slot()
235 slot->addr = *addr; in alloc_rfc_slot()
237 slot->addr = RawAddress::kEmpty; in alloc_rfc_slot()
239 slot->id = rfc_slot_id; in alloc_rfc_slot()
240 slot->f.server = server; in alloc_rfc_slot()
241 slot->tx_bytes = 0; in alloc_rfc_slot()
242 slot->rx_bytes = 0; in alloc_rfc_slot()
243 return slot; in alloc_rfc_slot()
314 rfc_slot_t* slot = in btsock_rfc_listen() local
316 if (!slot) { in btsock_rfc_listen()
322 BTA_JvGetChannelId(BTA_JV_CONN_TYPE_RFCOMM, slot->id, channel); in btsock_rfc_listen()
323 *sock_fd = slot->app_fd; // Transfer ownership of fd to caller. in btsock_rfc_listen()
332 slot->app_fd = INVALID_FD; // Drop our reference to the fd. in btsock_rfc_listen()
333 slot->app_uid = app_uid; in btsock_rfc_listen()
334 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_EXCEPTION, in btsock_rfc_listen()
335 slot->id); in btsock_rfc_listen()
356 rfc_slot_t* slot = in btsock_rfc_connect() local
358 if (!slot) { in btsock_rfc_connect()
365 BTA_JvRfcommConnect(slot->security, slot->role, slot->scn, slot->addr, in btsock_rfc_connect()
366 rfcomm_cback, slot->id); in btsock_rfc_connect()
370 cleanup_rfc_slot(slot); in btsock_rfc_connect()
374 if (!send_app_scn(slot)) { in btsock_rfc_connect()
376 cleanup_rfc_slot(slot); in btsock_rfc_connect()
381 BTA_JvStartDiscovery(*bd_addr, 1, service_uuid, slot->id); in btsock_rfc_connect()
382 slot->f.pending_sdp_request = false; in btsock_rfc_connect()
383 slot->f.doing_sdp_request = true; in btsock_rfc_connect()
385 slot->f.pending_sdp_request = true; in btsock_rfc_connect()
386 slot->f.doing_sdp_request = false; in btsock_rfc_connect()
390 *sock_fd = slot->app_fd; // Transfer ownership of fd to caller. in btsock_rfc_connect()
391 slot->app_fd = INVALID_FD; // Drop our reference to the fd. in btsock_rfc_connect()
392 slot->app_uid = app_uid; in btsock_rfc_connect()
393 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_RD, in btsock_rfc_connect()
394 slot->id); in btsock_rfc_connect()
399 static int create_server_sdp_record(rfc_slot_t* slot) { in create_server_sdp_record() argument
400 if (slot->scn == 0) { in create_server_sdp_record()
403 slot->sdp_handle = in create_server_sdp_record()
404 add_rfc_sdp_rec(slot->service_name, slot->service_uuid, slot->scn); in create_server_sdp_record()
405 return (slot->sdp_handle > 0); in create_server_sdp_record()
408 static void free_rfc_slot_scn(rfc_slot_t* slot) { in free_rfc_slot_scn() argument
409 if (slot->scn <= 0) return; in free_rfc_slot_scn()
411 if (slot->f.server && !slot->f.closing && slot->rfc_handle) { in free_rfc_slot_scn()
412 BTA_JvRfcommStopServer(slot->rfc_handle, slot->id); in free_rfc_slot_scn()
413 slot->rfc_handle = 0; in free_rfc_slot_scn()
416 if (slot->f.server) BTM_FreeSCN(slot->scn); in free_rfc_slot_scn()
417 slot->scn = 0; in free_rfc_slot_scn()
420 static void cleanup_rfc_slot(rfc_slot_t* slot) { in cleanup_rfc_slot() argument
421 if (slot->fd != INVALID_FD) { in cleanup_rfc_slot()
422 shutdown(slot->fd, SHUT_RDWR); in cleanup_rfc_slot()
423 close(slot->fd); in cleanup_rfc_slot()
425 slot->addr, slot->id, BTSOCK_RFCOMM, in cleanup_rfc_slot()
427 slot->tx_bytes, slot->rx_bytes, slot->app_uid, slot->scn, in cleanup_rfc_slot()
428 slot->f.server ? android::bluetooth::SOCKET_ROLE_LISTEN in cleanup_rfc_slot()
430 slot->fd = INVALID_FD; in cleanup_rfc_slot()
433 if (slot->app_fd != INVALID_FD) { in cleanup_rfc_slot()
434 close(slot->app_fd); in cleanup_rfc_slot()
435 slot->app_fd = INVALID_FD; in cleanup_rfc_slot()
438 if (slot->sdp_handle > 0) { in cleanup_rfc_slot()
439 del_rfc_sdp_rec(slot->sdp_handle); in cleanup_rfc_slot()
440 slot->sdp_handle = 0; in cleanup_rfc_slot()
443 if (slot->rfc_handle && !slot->f.closing && !slot->f.server) { in cleanup_rfc_slot()
444 BTA_JvRfcommClose(slot->rfc_handle, slot->id); in cleanup_rfc_slot()
445 slot->rfc_handle = 0; in cleanup_rfc_slot()
448 free_rfc_slot_scn(slot); in cleanup_rfc_slot()
449 list_clear(slot->incoming_queue); in cleanup_rfc_slot()
451 slot->rfc_port_handle = 0; in cleanup_rfc_slot()
452 memset(&slot->f, 0, sizeof(slot->f)); in cleanup_rfc_slot()
453 slot->id = 0; in cleanup_rfc_slot()
454 slot->scn_notified = false; in cleanup_rfc_slot()
455 slot->tx_bytes = 0; in cleanup_rfc_slot()
456 slot->rx_bytes = 0; in cleanup_rfc_slot()
459 static bool send_app_scn(rfc_slot_t* slot) { in send_app_scn() argument
460 if (slot->scn_notified) { in send_app_scn()
464 slot->scn_notified = true; in send_app_scn()
465 return sock_send_all(slot->fd, (const uint8_t*)&slot->scn, in send_app_scn()
466 sizeof(slot->scn)) == sizeof(slot->scn); in send_app_scn()
487 rfc_slot_t* slot = find_rfc_slot_by_id(id); in on_cl_rfc_init() local
488 if (!slot) return; in on_cl_rfc_init()
491 slot->rfc_handle = p_init->handle; in on_cl_rfc_init()
493 cleanup_rfc_slot(slot); in on_cl_rfc_init()
500 rfc_slot_t* slot = find_rfc_slot_by_id(id); in on_srv_rfc_listen_started() local
501 if (!slot) return; in on_srv_rfc_listen_started()
504 slot->rfc_handle = p_start->handle; in on_srv_rfc_listen_started()
506 slot->addr, slot->id, BTSOCK_RFCOMM, in on_srv_rfc_listen_started()
509 0, 0, slot->app_uid, slot->scn, in on_srv_rfc_listen_started()
510 slot->f.server ? android::bluetooth::SOCKET_ROLE_LISTEN in on_srv_rfc_listen_started()
513 cleanup_rfc_slot(slot); in on_srv_rfc_listen_started()
549 rfc_slot_t* slot = find_rfc_slot_by_id(id); in on_cli_rfc_connect() local
550 if (!slot) return; in on_cli_rfc_connect()
553 cleanup_rfc_slot(slot); in on_cli_rfc_connect()
557 slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_open->handle); in on_cli_rfc_connect()
558 slot->addr = p_open->rem_bda; in on_cli_rfc_connect()
561 slot->addr, slot->id, BTSOCK_RFCOMM, in on_cli_rfc_connect()
563 slot->app_uid, slot->scn, in on_cli_rfc_connect()
564 slot->f.server ? android::bluetooth::SOCKET_ROLE_LISTEN in on_cli_rfc_connect()
567 if (send_app_connect_signal(slot->fd, &slot->addr, slot->scn, 0, -1)) { in on_cli_rfc_connect()
568 slot->f.connected = true; in on_cli_rfc_connect()
580 rfc_slot_t* slot = find_rfc_slot_by_id(id); in on_rfc_close() local
581 if (slot) { in on_rfc_close()
583 slot->addr, slot->id, BTSOCK_RFCOMM, in on_rfc_close()
585 slot->app_uid, slot->scn, in on_rfc_close()
586 slot->f.server ? android::bluetooth::SOCKET_ROLE_LISTEN in on_rfc_close()
588 cleanup_rfc_slot(slot); in on_rfc_close()
602 rfc_slot_t* slot = find_rfc_slot_by_id(id); in on_rfc_write_done() local
603 if (slot) { in on_rfc_write_done()
604 app_uid = slot->app_uid; in on_rfc_write_done()
605 if (!slot->f.outgoing_congest) { in on_rfc_write_done()
606 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_RD, in on_rfc_write_done()
607 slot->id); in on_rfc_write_done()
609 slot->tx_bytes += p->len; in on_rfc_write_done()
618 rfc_slot_t* slot = find_rfc_slot_by_id(id); in on_rfc_outgoing_congest() local
619 if (slot) { in on_rfc_outgoing_congest()
620 slot->f.outgoing_congest = p->cong ? 1 : 0; in on_rfc_outgoing_congest()
621 if (!slot->f.outgoing_congest) in on_rfc_outgoing_congest()
622 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_RD, in on_rfc_outgoing_congest()
623 slot->id); in on_rfc_outgoing_congest()
733 rfc_slot_t* slot = find_rfc_slot_by_id(id); in jv_dm_cback() local
735 if (slot && create_server_sdp_record(slot)) { in jv_dm_cback()
737 BTA_JvRfcommStartServer(slot->security, slot->role, slot->scn, in jv_dm_cback()
738 MAX_RFC_SESSION, rfcomm_cback, slot->id); in jv_dm_cback()
739 } else if (slot) { in jv_dm_cback()
741 slot); in jv_dm_cback()
742 cleanup_rfc_slot(slot); in jv_dm_cback()
749 rfc_slot_t* slot = find_rfc_slot_by_id(id); in jv_dm_cback() local
751 if (slot && slot->f.doing_sdp_request) { in jv_dm_cback()
754 if (BTA_JvRfcommConnect(slot->security, slot->role, in jv_dm_cback()
755 p_data->disc_comp.scn, slot->addr, in jv_dm_cback()
756 rfcomm_cback, slot->id) == BTA_JV_SUCCESS) { in jv_dm_cback()
757 slot->scn = p_data->disc_comp.scn; in jv_dm_cback()
758 slot->f.doing_sdp_request = false; in jv_dm_cback()
759 if (!send_app_scn(slot)) cleanup_rfc_slot(slot); in jv_dm_cback()
761 cleanup_rfc_slot(slot); in jv_dm_cback()
763 } else if (slot) { in jv_dm_cback()
771 } else if (slot) { in jv_dm_cback()
772 cleanup_rfc_slot(slot); in jv_dm_cback()
776 slot = find_rfc_slot_by_pending_sdp(); in jv_dm_cback()
777 if (slot) { in jv_dm_cback()
778 BTA_JvStartDiscovery(slot->addr, 1, &slot->service_uuid, slot->id); in jv_dm_cback()
779 slot->f.pending_sdp_request = false; in jv_dm_cback()
780 slot->f.doing_sdp_request = true; in jv_dm_cback()
821 static bool flush_incoming_que_on_wr_signal(rfc_slot_t* slot) { in flush_incoming_que_on_wr_signal() argument
822 while (!list_is_empty(slot->incoming_queue)) { in flush_incoming_que_on_wr_signal()
823 BT_HDR* p_buf = (BT_HDR*)list_front(slot->incoming_queue); in flush_incoming_que_on_wr_signal()
824 switch (send_data_to_app(slot->fd, p_buf)) { in flush_incoming_que_on_wr_signal()
828 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_WR, in flush_incoming_que_on_wr_signal()
829 slot->id); in flush_incoming_que_on_wr_signal()
833 list_remove(slot->incoming_queue, p_buf); in flush_incoming_que_on_wr_signal()
837 list_remove(slot->incoming_queue, p_buf); in flush_incoming_que_on_wr_signal()
846 slot->rfc_handle, slot->rfc_port_handle, slot->id); in flush_incoming_que_on_wr_signal()
847 PORT_FlowControl_MaxCredit(slot->rfc_port_handle, true); in flush_incoming_que_on_wr_signal()
854 rfc_slot_t* slot = find_rfc_slot_by_id(user_id); in btsock_rfc_signaled() local
855 if (!slot) return; in btsock_rfc_signaled()
858 if (flags & SOCK_THREAD_FD_RD && !slot->f.server) { in btsock_rfc_signaled()
859 if (slot->f.connected) { in btsock_rfc_signaled()
863 (ioctl(slot->fd, FIONREAD, &size) == 0 && size)) { in btsock_rfc_signaled()
864 BTA_JvRfcommWrite(slot->rfc_handle, slot->id); in btsock_rfc_signaled()
870 __func__, slot->id, slot->scn); in btsock_rfc_signaled()
877 if (!slot->f.connected || !flush_incoming_que_on_wr_signal(slot)) { in btsock_rfc_signaled()
881 __func__, slot->id, slot->scn); in btsock_rfc_signaled()
889 if (need_close || ioctl(slot->fd, FIONREAD, &size) != 0 || !size) in btsock_rfc_signaled()
890 cleanup_rfc_slot(slot); in btsock_rfc_signaled()
899 rfc_slot_t* slot = find_rfc_slot_by_id(id); in bta_co_rfc_data_incoming() local
900 if (!slot) return 0; in bta_co_rfc_data_incoming()
902 app_uid = slot->app_uid; in bta_co_rfc_data_incoming()
905 if (list_is_empty(slot->incoming_queue)) { in bta_co_rfc_data_incoming()
906 switch (send_data_to_app(slot->fd, p_buf)) { in bta_co_rfc_data_incoming()
909 list_append(slot->incoming_queue, p_buf); in bta_co_rfc_data_incoming()
910 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_WR, in bta_co_rfc_data_incoming()
911 slot->id); in bta_co_rfc_data_incoming()
921 cleanup_rfc_slot(slot); in bta_co_rfc_data_incoming()
925 list_append(slot->incoming_queue, p_buf); in bta_co_rfc_data_incoming()
928 slot->rx_bytes += bytes_rx; in bta_co_rfc_data_incoming()
937 rfc_slot_t* slot = find_rfc_slot_by_id(id); in bta_co_rfc_data_outgoing_size() local
938 if (!slot) return false; in bta_co_rfc_data_outgoing_size()
940 if (ioctl(slot->fd, FIONREAD, size) != 0) { in bta_co_rfc_data_outgoing_size()
943 __func__, slot->fd, strerror(errno)); in bta_co_rfc_data_outgoing_size()
944 cleanup_rfc_slot(slot); in bta_co_rfc_data_outgoing_size()
953 rfc_slot_t* slot = find_rfc_slot_by_id(id); in bta_co_rfc_data_outgoing() local
954 if (!slot) return false; in bta_co_rfc_data_outgoing()
957 OSI_NO_INTR(received = recv(slot->fd, buf, size, 0)); in bta_co_rfc_data_outgoing()
962 cleanup_rfc_slot(slot); in bta_co_rfc_data_outgoing()