• Home
  • Raw
  • Download

Lines Matching refs:slot

163   int slot = -1;  in find_rfc_slot_by_pending_sdp()  local
167 slot = i; in find_rfc_slot_by_pending_sdp()
170 return (slot == -1) ? NULL : &rfc_slots[slot]; in find_rfc_slot_by_pending_sdp()
191 rfc_slot_t *slot = find_free_slot(); in alloc_rfc_slot() local
192 if (!slot) { in alloc_rfc_slot()
207 slot->fd = fds[0]; in alloc_rfc_slot()
208 slot->app_fd = fds[1]; in alloc_rfc_slot()
209 slot->security = security; in alloc_rfc_slot()
210 slot->scn = channel; in alloc_rfc_slot()
211 slot->app_uid = -1; in alloc_rfc_slot()
214 memcpy(slot->service_uuid, uuid, sizeof(slot->service_uuid)); in alloc_rfc_slot()
215 slot->is_service_uuid_valid = true; in alloc_rfc_slot()
217 memset(slot->service_uuid, 0, sizeof(slot->service_uuid)); in alloc_rfc_slot()
218 slot->is_service_uuid_valid = false; in alloc_rfc_slot()
221 strlcpy(slot->service_name, name, sizeof(slot->service_name)); in alloc_rfc_slot()
223 memset(slot->service_name, 0, sizeof(slot->service_name)); in alloc_rfc_slot()
226 slot->addr = *addr; in alloc_rfc_slot()
228 slot->id = rfc_slot_id; in alloc_rfc_slot()
229 slot->f.server = server; in alloc_rfc_slot()
231 return slot; in alloc_rfc_slot()
293 rfc_slot_t *slot = alloc_rfc_slot(NULL, service_name, service_uuid, channel, flags, true); in btsock_rfc_listen() local
294 if (!slot) { in btsock_rfc_listen()
299 BTA_JvGetChannelId(BTA_JV_CONN_TYPE_RFCOMM, UINT_TO_PTR(slot->id), channel); in btsock_rfc_listen()
300 *sock_fd = slot->app_fd; // Transfer ownership of fd to caller. in btsock_rfc_listen()
308 slot->app_fd = INVALID_FD; // Drop our reference to the fd. in btsock_rfc_listen()
309 slot->app_uid = app_uid; in btsock_rfc_listen()
310 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_EXCEPTION, slot->id); in btsock_rfc_listen()
333 rfc_slot_t *slot = alloc_rfc_slot(bd_addr, NULL, service_uuid, channel, flags, false); in btsock_rfc_connect() local
334 if (!slot) { in btsock_rfc_connect()
340 …S ret = BTA_JvRfcommConnect(slot->security, slot->role, slot->scn, slot->addr.address, rfcomm_cbac… in btsock_rfc_connect()
343 cleanup_rfc_slot(slot); in btsock_rfc_connect()
347 if (!send_app_scn(slot)) { in btsock_rfc_connect()
349 cleanup_rfc_slot(slot); in btsock_rfc_connect()
358 BTA_JvStartDiscovery((uint8_t *)bd_addr->address, 1, &sdp_uuid, (void *)(uintptr_t)slot->id); in btsock_rfc_connect()
359 slot->f.pending_sdp_request = false; in btsock_rfc_connect()
360 slot->f.doing_sdp_request = true; in btsock_rfc_connect()
362 slot->f.pending_sdp_request = true; in btsock_rfc_connect()
363 slot->f.doing_sdp_request = false; in btsock_rfc_connect()
367 *sock_fd = slot->app_fd; // Transfer ownership of fd to caller. in btsock_rfc_connect()
368 slot->app_fd = INVALID_FD; // Drop our reference to the fd. in btsock_rfc_connect()
369 slot->app_uid = app_uid; in btsock_rfc_connect()
370 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_RD, slot->id); in btsock_rfc_connect()
378 static int create_server_sdp_record(rfc_slot_t *slot) { in create_server_sdp_record() argument
379 if(slot->scn == 0) { in create_server_sdp_record()
382 slot->sdp_handle = add_rfc_sdp_rec(slot->service_name, slot->service_uuid, slot->scn); in create_server_sdp_record()
383 return (slot->sdp_handle > 0); in create_server_sdp_record()
386 static void free_rfc_slot_scn(rfc_slot_t *slot) { in free_rfc_slot_scn() argument
387 if (slot->scn <= 0) in free_rfc_slot_scn()
390 if(slot->f.server && !slot->f.closing && slot->rfc_handle) { in free_rfc_slot_scn()
391 BTA_JvRfcommStopServer(slot->rfc_handle, (void *)(uintptr_t)slot->id); in free_rfc_slot_scn()
392 slot->rfc_handle = 0; in free_rfc_slot_scn()
395 if (slot->f.server) in free_rfc_slot_scn()
396 BTM_FreeSCN(slot->scn); in free_rfc_slot_scn()
397 slot->scn = 0; in free_rfc_slot_scn()
400 static void cleanup_rfc_slot(rfc_slot_t *slot) { in cleanup_rfc_slot() argument
401 if (slot->fd != INVALID_FD) { in cleanup_rfc_slot()
402 shutdown(slot->fd, SHUT_RDWR); in cleanup_rfc_slot()
403 close(slot->fd); in cleanup_rfc_slot()
404 slot->fd = INVALID_FD; in cleanup_rfc_slot()
407 if (slot->app_fd != INVALID_FD) { in cleanup_rfc_slot()
408 close(slot->app_fd); in cleanup_rfc_slot()
409 slot->app_fd = INVALID_FD; in cleanup_rfc_slot()
412 if (slot->sdp_handle > 0) { in cleanup_rfc_slot()
413 del_rfc_sdp_rec(slot->sdp_handle); in cleanup_rfc_slot()
414 slot->sdp_handle = 0; in cleanup_rfc_slot()
417 if (slot->rfc_handle && !slot->f.closing && !slot->f.server) { in cleanup_rfc_slot()
418 BTA_JvRfcommClose(slot->rfc_handle, (void *)(uintptr_t)slot->id); in cleanup_rfc_slot()
419 slot->rfc_handle = 0; in cleanup_rfc_slot()
422 free_rfc_slot_scn(slot); in cleanup_rfc_slot()
423 list_clear(slot->incoming_queue); in cleanup_rfc_slot()
425 slot->rfc_port_handle = 0; in cleanup_rfc_slot()
426 memset(&slot->f, 0, sizeof(slot->f)); in cleanup_rfc_slot()
427 slot->id = 0; in cleanup_rfc_slot()
428 slot->scn_notified = false; in cleanup_rfc_slot()
431 static bool send_app_scn(rfc_slot_t *slot) { in send_app_scn() argument
432 if(slot->scn_notified == true) { in send_app_scn()
436 slot->scn_notified = true; in send_app_scn()
437 …return sock_send_all(slot->fd, (const uint8_t*)&slot->scn, sizeof(slot->scn)) == sizeof(slot->scn); in send_app_scn()
457 rfc_slot_t *slot = find_rfc_slot_by_id(id); in on_cl_rfc_init() local
458 if (!slot) in on_cl_rfc_init()
462 slot->rfc_handle = p_init->handle; in on_cl_rfc_init()
464 cleanup_rfc_slot(slot); in on_cl_rfc_init()
473 rfc_slot_t *slot = find_rfc_slot_by_id(id); in on_srv_rfc_listen_started() local
474 if (!slot) in on_srv_rfc_listen_started()
478 slot->rfc_handle = p_start->handle; in on_srv_rfc_listen_started()
480 cleanup_rfc_slot(slot); in on_srv_rfc_listen_started()
513 rfc_slot_t *slot = find_rfc_slot_by_id(id); in on_cli_rfc_connect() local
514 if (!slot) in on_cli_rfc_connect()
518 cleanup_rfc_slot(slot); in on_cli_rfc_connect()
522 slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_open->handle); in on_cli_rfc_connect()
523 memcpy(slot->addr.address, p_open->rem_bda, 6); in on_cli_rfc_connect()
525 if (send_app_connect_signal(slot->fd, &slot->addr, slot->scn, 0, -1)) in on_cli_rfc_connect()
526 slot->f.connected = true; in on_cli_rfc_connect()
538 rfc_slot_t *slot = find_rfc_slot_by_id(id); in on_rfc_close() local
539 if (slot) in on_rfc_close()
540 cleanup_rfc_slot(slot); in on_rfc_close()
549 rfc_slot_t *slot = find_rfc_slot_by_id(id); in on_rfc_write_done() local
550 if (slot) { in on_rfc_write_done()
551 app_uid = slot->app_uid; in on_rfc_write_done()
552 if (!slot->f.outgoing_congest) { in on_rfc_write_done()
553 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_RD, slot->id); in on_rfc_write_done()
565 rfc_slot_t *slot = find_rfc_slot_by_id(id); in on_rfc_outgoing_congest() local
566 if (slot) { in on_rfc_outgoing_congest()
567 slot->f.outgoing_congest = p->cong ? 1 : 0; in on_rfc_outgoing_congest()
568 if (!slot->f.outgoing_congest) in on_rfc_outgoing_congest()
569 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_RD, slot->id); in on_rfc_outgoing_congest()
673 rfc_slot_t *slot = find_rfc_slot_by_id(id); in jv_dm_cback() local
674 if (slot && create_server_sdp_record(slot)) { in jv_dm_cback()
676 …BTA_JvRfcommStartServer(slot->security, slot->role, slot->scn, MAX_RFC_SESSION, rfcomm_cback, (voi… in jv_dm_cback()
677 } else if(slot) { in jv_dm_cback()
678 APPL_TRACE_ERROR("jv_dm_cback: cannot start server, slot found:%p", slot); in jv_dm_cback()
679 cleanup_rfc_slot(slot); in jv_dm_cback()
688 rfc_slot_t *slot = find_rfc_slot_by_id(id); in jv_dm_cback() local
690 if (slot && slot->f.doing_sdp_request) { in jv_dm_cback()
692 … (BTA_JvRfcommConnect(slot->security, slot->role, p_data->disc_comp.scn, slot->addr.address, rfcom… in jv_dm_cback()
693 slot->scn = p_data->disc_comp.scn; in jv_dm_cback()
694 slot->f.doing_sdp_request = false; in jv_dm_cback()
695 if (!send_app_scn(slot)) in jv_dm_cback()
696 cleanup_rfc_slot(slot); in jv_dm_cback()
698 cleanup_rfc_slot(slot); in jv_dm_cback()
700 } else if (slot) { in jv_dm_cback()
704 } else if (slot) { in jv_dm_cback()
705 cleanup_rfc_slot(slot); in jv_dm_cback()
709 slot = find_rfc_slot_by_pending_sdp(); in jv_dm_cback()
710 if (slot) { in jv_dm_cback()
713 memcpy(sdp_uuid.uu.uuid128, slot->service_uuid, sizeof(sdp_uuid.uu.uuid128)); in jv_dm_cback()
714 … BTA_JvStartDiscovery((uint8_t *)slot->addr.address, 1, &sdp_uuid, (void *)(uintptr_t)slot->id); in jv_dm_cback()
715 slot->f.pending_sdp_request = false; in jv_dm_cback()
716 slot->f.doing_sdp_request = true; in jv_dm_cback()
762 static bool flush_incoming_que_on_wr_signal(rfc_slot_t *slot) { in flush_incoming_que_on_wr_signal() argument
763 while (!list_is_empty(slot->incoming_queue)) { in flush_incoming_que_on_wr_signal()
764 BT_HDR *p_buf = list_front(slot->incoming_queue); in flush_incoming_que_on_wr_signal()
765 switch (send_data_to_app(slot->fd, p_buf)) { in flush_incoming_que_on_wr_signal()
769 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_WR, slot->id); in flush_incoming_que_on_wr_signal()
773 list_remove(slot->incoming_queue, p_buf); in flush_incoming_que_on_wr_signal()
777 list_remove(slot->incoming_queue, p_buf); in flush_incoming_que_on_wr_signal()
785 slot->rfc_handle, slot->rfc_port_handle, slot->id); in flush_incoming_que_on_wr_signal()
787 PORT_FlowControl_MaxCredit(slot->rfc_port_handle, true); in flush_incoming_que_on_wr_signal()
794 rfc_slot_t *slot = find_rfc_slot_by_id(user_id); in btsock_rfc_signaled() local
795 if (!slot) in btsock_rfc_signaled()
801 if (flags & SOCK_THREAD_FD_RD && !slot->f.server) { in btsock_rfc_signaled()
802 if (slot->f.connected) { in btsock_rfc_signaled()
805 if (!(flags & SOCK_THREAD_FD_EXCEPTION) || (ioctl(slot->fd, FIONREAD, &size) == 0 && size)) { in btsock_rfc_signaled()
806 BTA_JvRfcommWrite(slot->rfc_handle, slot->id); in btsock_rfc_signaled()
809 …ocket signaled for read while disconnected, slot: %d, channel: %d", __func__, slot->id, slot->scn); in btsock_rfc_signaled()
816 if (!slot->f.connected || !flush_incoming_que_on_wr_signal(slot)) { in btsock_rfc_signaled()
817 …rite while disconnected (or write failure), slot: %d, channel: %d", __func__, slot->id, slot->scn); in btsock_rfc_signaled()
825 if (need_close || ioctl(slot->fd, FIONREAD, &size) != 0 || !size) in btsock_rfc_signaled()
826 cleanup_rfc_slot(slot); in btsock_rfc_signaled()
841 rfc_slot_t *slot = find_rfc_slot_by_id(id); in bta_co_rfc_data_incoming() local
842 if (!slot) in bta_co_rfc_data_incoming()
845 app_uid = slot->app_uid; in bta_co_rfc_data_incoming()
848 if (list_is_empty(slot->incoming_queue)) { in bta_co_rfc_data_incoming()
849 switch (send_data_to_app(slot->fd, p_buf)) { in bta_co_rfc_data_incoming()
852 list_append(slot->incoming_queue, p_buf); in bta_co_rfc_data_incoming()
853 btsock_thread_add_fd(pth, slot->fd, BTSOCK_RFCOMM, SOCK_THREAD_FD_WR, slot->id); in bta_co_rfc_data_incoming()
863 cleanup_rfc_slot(slot); in bta_co_rfc_data_incoming()
867 list_append(slot->incoming_queue, p_buf); in bta_co_rfc_data_incoming()
884 rfc_slot_t *slot = find_rfc_slot_by_id(id); in bta_co_rfc_data_outgoing_size() local
885 if (!slot) in bta_co_rfc_data_outgoing_size()
888 if (ioctl(slot->fd, FIONREAD, size) == 0) { in bta_co_rfc_data_outgoing_size()
891 …s unable to determine bytes remaining to be read on fd %d: %s", __func__, slot->fd, strerror(errno… in bta_co_rfc_data_outgoing_size()
892 cleanup_rfc_slot(slot); in bta_co_rfc_data_outgoing_size()
905 rfc_slot_t *slot = find_rfc_slot_by_id(id); in bta_co_rfc_data_outgoing() local
906 if (!slot) in bta_co_rfc_data_outgoing()
910 OSI_NO_INTR(received = recv(slot->fd, buf, size, 0)); in bta_co_rfc_data_outgoing()
916 cleanup_rfc_slot(slot); in bta_co_rfc_data_outgoing()