Lines Matching refs:sock
95 static void btsock_l2cap_server_listen(l2cap_socket* sock);
122 static char packet_get_head_l(l2cap_socket* sock, uint8_t** data, in packet_get_head_l() argument
124 struct packet* p = sock->first_packet; in packet_get_head_l()
128 if (data) *data = sock->first_packet->data; in packet_get_head_l()
129 if (len) *len = sock->first_packet->len; in packet_get_head_l()
130 sock->first_packet = p->next; in packet_get_head_l()
131 if (sock->first_packet) in packet_get_head_l()
132 sock->first_packet->prev = NULL; in packet_get_head_l()
134 sock->last_packet = NULL; in packet_get_head_l()
136 if (len) sock->bytes_buffered -= *len; in packet_get_head_l()
154 static char packet_put_head_l(l2cap_socket* sock, const void* data, in packet_put_head_l() argument
168 p->next = sock->first_packet; in packet_put_head_l()
169 sock->first_packet = p; in packet_put_head_l()
173 sock->last_packet = p; in packet_put_head_l()
175 sock->bytes_buffered += len; in packet_put_head_l()
181 static char packet_put_tail_l(l2cap_socket* sock, const void* data, in packet_put_tail_l() argument
183 if (sock->bytes_buffered >= L2CAP_MAX_RX_BUFFER) { in packet_put_tail_l()
190 p->prev = sock->last_packet; in packet_put_tail_l()
191 sock->last_packet = p; in packet_put_tail_l()
195 sock->first_packet = p; in packet_put_tail_l()
197 sock->bytes_buffered += len; in packet_put_tail_l()
209 l2cap_socket* sock = socks; in btsock_l2cap_find_by_id_l() local
211 while (sock && sock->id != id) sock = sock->next; in btsock_l2cap_find_by_id_l()
213 return sock; in btsock_l2cap_find_by_id_l()
216 static void btsock_l2cap_free_l(l2cap_socket* sock) { in btsock_l2cap_free_l() argument
220 while (t && t != sock) t = t->next; in btsock_l2cap_free_l()
227 sock->addr, sock->id, sock->is_le_coc ? BTSOCK_L2CAP_LE : BTSOCK_L2CAP, in btsock_l2cap_free_l()
228 android::bluetooth::SOCKET_CONNECTION_STATE_DISCONNECTED, sock->tx_bytes, in btsock_l2cap_free_l()
229 sock->rx_bytes, sock->app_uid, sock->channel, in btsock_l2cap_free_l()
230 sock->server ? android::bluetooth::SOCKET_ROLE_LISTEN in btsock_l2cap_free_l()
233 if (sock->next) sock->next->prev = sock->prev; in btsock_l2cap_free_l()
235 if (sock->prev) in btsock_l2cap_free_l()
236 sock->prev->next = sock->next; in btsock_l2cap_free_l()
238 socks = sock->next; in btsock_l2cap_free_l()
240 shutdown(sock->our_fd, SHUT_RDWR); in btsock_l2cap_free_l()
241 close(sock->our_fd); in btsock_l2cap_free_l()
242 if (sock->app_fd != -1) { in btsock_l2cap_free_l()
243 close(sock->app_fd); in btsock_l2cap_free_l()
245 LOG(ERROR) << "SOCK_LIST: free(id = " << sock->id << ") - NO app_fd!"; in btsock_l2cap_free_l()
248 while (packet_get_head_l(sock, &buf, NULL)) osi_free(buf); in btsock_l2cap_free_l()
251 if (sock->is_le_coc) { in btsock_l2cap_free_l()
253 if (sock->handle >= 0 && (!sock->server)) { in btsock_l2cap_free_l()
254 BTA_JvL2capClose(sock->handle); in btsock_l2cap_free_l()
256 if ((sock->channel >= 0) && (sock->server)) { in btsock_l2cap_free_l()
257 BTA_JvFreeChannel(sock->channel, BTA_JV_CONN_TYPE_L2CAP_LE); in btsock_l2cap_free_l()
258 if (!sock->fixed_chan) { in btsock_l2cap_free_l()
260 << sock->channel; in btsock_l2cap_free_l()
261 BTA_JvL2capStopServer(sock->channel, sock->id); in btsock_l2cap_free_l()
266 if ((sock->handle >= 0) && (!sock->server)) { in btsock_l2cap_free_l()
267 if (sock->fixed_chan) in btsock_l2cap_free_l()
268 BTA_JvL2capCloseLE(sock->handle); in btsock_l2cap_free_l()
270 BTA_JvL2capClose(sock->handle); in btsock_l2cap_free_l()
272 if ((sock->channel >= 0) && (sock->server)) { in btsock_l2cap_free_l()
273 if (sock->fixed_chan) in btsock_l2cap_free_l()
274 BTA_JvFreeChannel(sock->channel, BTA_JV_CONN_TYPE_L2CAP_LE); in btsock_l2cap_free_l()
276 BTA_JvFreeChannel(sock->channel, BTA_JV_CONN_TYPE_L2CAP); in btsock_l2cap_free_l()
278 if (!sock->fixed_chan) { in btsock_l2cap_free_l()
280 << sock->channel; in btsock_l2cap_free_l()
281 BTA_JvL2capStopServer(sock->channel, sock->id); in btsock_l2cap_free_l()
286 DVLOG(2) << __func__ << ": free id:" << sock->id; in btsock_l2cap_free_l()
287 osi_free(sock); in btsock_l2cap_free_l()
295 l2cap_socket* sock = (l2cap_socket*)osi_calloc(sizeof(*sock)); in btsock_l2cap_alloc_l() local
311 sock->our_fd = fds[0]; in btsock_l2cap_alloc_l()
312 sock->app_fd = fds[1]; in btsock_l2cap_alloc_l()
313 sock->security = security; in btsock_l2cap_alloc_l()
314 sock->server = is_server; in btsock_l2cap_alloc_l()
315 sock->connected = false; in btsock_l2cap_alloc_l()
316 sock->handle = 0; in btsock_l2cap_alloc_l()
317 sock->server_psm_sent = false; in btsock_l2cap_alloc_l()
318 sock->app_uid = -1; in btsock_l2cap_alloc_l()
320 if (name) strncpy(sock->name, name, sizeof(sock->name) - 1); in btsock_l2cap_alloc_l()
321 if (addr) sock->addr = *addr; in btsock_l2cap_alloc_l()
323 sock->first_packet = NULL; in btsock_l2cap_alloc_l()
324 sock->last_packet = NULL; in btsock_l2cap_alloc_l()
326 sock->tx_mtu = L2CAP_LE_MIN_MTU; in btsock_l2cap_alloc_l()
328 sock->next = socks; in btsock_l2cap_alloc_l()
329 sock->prev = NULL; in btsock_l2cap_alloc_l()
330 if (socks) socks->prev = sock; in btsock_l2cap_alloc_l()
331 sock->id = last_sock_id + 1; in btsock_l2cap_alloc_l()
332 sock->tx_bytes = 0; in btsock_l2cap_alloc_l()
333 sock->rx_bytes = 0; in btsock_l2cap_alloc_l()
334 socks = sock; in btsock_l2cap_alloc_l()
340 while (t && t->id != sock->id) { in btsock_l2cap_alloc_l()
343 if (!t && sock->id) /* non-zeor handle is unique -> we're done */ in btsock_l2cap_alloc_l()
346 if (!++sock->id) /* no zero IDs allowed */ in btsock_l2cap_alloc_l()
347 sock->id++; in btsock_l2cap_alloc_l()
349 last_sock_id = sock->id; in btsock_l2cap_alloc_l()
350 DVLOG(2) << __func__ << " SOCK_LIST: alloc id:" << sock->id; in btsock_l2cap_alloc_l()
351 return sock; in btsock_l2cap_alloc_l()
354 osi_free(sock); in btsock_l2cap_alloc_l()
374 static inline bool send_app_psm_or_chan_l(l2cap_socket* sock) { in send_app_psm_or_chan_l() argument
375 DVLOG(2) << __func__ << ": channel: " << sock->channel; in send_app_psm_or_chan_l()
376 return sock_send_all(sock->our_fd, (const uint8_t*)&sock->channel, in send_app_psm_or_chan_l()
377 sizeof(sock->channel)) == sizeof(sock->channel); in send_app_psm_or_chan_l()
405 l2cap_socket* sock; in on_srv_l2cap_listen_started() local
408 sock = btsock_l2cap_find_by_id_l(id); in on_srv_l2cap_listen_started()
409 if (!sock) return; in on_srv_l2cap_listen_started()
414 btsock_l2cap_free_l(sock); in on_srv_l2cap_listen_started()
418 sock->handle = p_start->handle; in on_srv_l2cap_listen_started()
419 DVLOG(2) << __func__ << ": sock->handle: " << sock->handle in on_srv_l2cap_listen_started()
420 << ", id: " << sock->id; in on_srv_l2cap_listen_started()
423 sock->addr, sock->id, sock->is_le_coc ? BTSOCK_L2CAP_LE : BTSOCK_L2CAP, in on_srv_l2cap_listen_started()
426 0, 0, sock->app_uid, sock->channel, in on_srv_l2cap_listen_started()
427 sock->server ? android::bluetooth::SOCKET_ROLE_LISTEN in on_srv_l2cap_listen_started()
430 if (!sock->server_psm_sent) { in on_srv_l2cap_listen_started()
431 if (!send_app_psm_or_chan_l(sock)) { in on_srv_l2cap_listen_started()
433 DVLOG(2) << "send_app_psm() failed, close rs->id: " << sock->id; in on_srv_l2cap_listen_started()
434 btsock_l2cap_free_l(sock); in on_srv_l2cap_listen_started()
436 sock->server_psm_sent = true; in on_srv_l2cap_listen_started()
442 l2cap_socket* sock; in on_cl_l2cap_init() local
445 sock = btsock_l2cap_find_by_id_l(id); in on_cl_l2cap_init()
446 if (!sock) return; in on_cl_l2cap_init()
449 btsock_l2cap_free_l(sock); in on_cl_l2cap_init()
453 sock->handle = p_init->handle; in on_cl_l2cap_init()
461 l2cap_socket* sock) { in on_srv_l2cap_psm_connect_l() argument
464 btsock_l2cap_alloc_l(sock->name, &p_open->rem_bda, false, 0); in on_srv_l2cap_psm_connect_l()
466 accept_rs->security = sock->security; in on_srv_l2cap_psm_connect_l()
467 accept_rs->fixed_chan = sock->fixed_chan; in on_srv_l2cap_psm_connect_l()
468 accept_rs->channel = sock->channel; in on_srv_l2cap_psm_connect_l()
469 accept_rs->handle = sock->handle; in on_srv_l2cap_psm_connect_l()
470 accept_rs->app_uid = sock->app_uid; in on_srv_l2cap_psm_connect_l()
471 sock->handle = in on_srv_l2cap_psm_connect_l()
473 accept_rs->is_le_coc = sock->is_le_coc; in on_srv_l2cap_psm_connect_l()
474 accept_rs->tx_mtu = sock->tx_mtu = p_open->tx_mtu; in on_srv_l2cap_psm_connect_l()
479 accept_rs->id = sock->id; in on_srv_l2cap_psm_connect_l()
480 sock->id = new_listen_id; in on_srv_l2cap_psm_connect_l()
491 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, in on_srv_l2cap_psm_connect_l()
492 SOCK_THREAD_FD_EXCEPTION, sock->id); in on_srv_l2cap_psm_connect_l()
497 DVLOG(2) << "server fd: << " << sock->our_fd << ", scn:" << sock->channel; in on_srv_l2cap_psm_connect_l()
498 send_app_connect_signal(sock->our_fd, &accept_rs->addr, sock->channel, 0, in on_srv_l2cap_psm_connect_l()
499 accept_rs->app_fd, sock->rx_mtu, p_open->tx_mtu); in on_srv_l2cap_psm_connect_l()
504 btsock_l2cap_server_listen(sock); in on_srv_l2cap_psm_connect_l()
508 l2cap_socket* sock) { in on_srv_l2cap_le_connect_l() argument
511 btsock_l2cap_alloc_l(sock->name, &p_open->rem_bda, false, 0); in on_srv_l2cap_le_connect_l()
516 accept_rs->id = sock->id; in on_srv_l2cap_le_connect_l()
517 sock->id = new_listen_id; in on_srv_l2cap_le_connect_l()
521 accept_rs->security = sock->security; in on_srv_l2cap_le_connect_l()
522 accept_rs->fixed_chan = sock->fixed_chan; in on_srv_l2cap_le_connect_l()
523 accept_rs->channel = sock->channel; in on_srv_l2cap_le_connect_l()
524 accept_rs->app_uid = sock->app_uid; in on_srv_l2cap_le_connect_l()
525 accept_rs->tx_mtu = sock->tx_mtu = p_open->tx_mtu; in on_srv_l2cap_le_connect_l()
540 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, in on_srv_l2cap_le_connect_l()
541 SOCK_THREAD_FD_EXCEPTION, sock->id); in on_srv_l2cap_le_connect_l()
546 DVLOG(2) << "server fd: << " << sock->our_fd << ", scn:" << sock->channel; in on_srv_l2cap_le_connect_l()
547 send_app_connect_signal(sock->our_fd, &accept_rs->addr, sock->channel, 0, in on_srv_l2cap_le_connect_l()
548 accept_rs->app_fd, sock->rx_mtu, p_open->tx_mtu); in on_srv_l2cap_le_connect_l()
553 l2cap_socket* sock) { in on_cl_l2cap_psm_connect_l() argument
554 sock->addr = p_open->rem_bda; in on_cl_l2cap_psm_connect_l()
555 sock->tx_mtu = p_open->tx_mtu; in on_cl_l2cap_psm_connect_l()
557 if (!send_app_psm_or_chan_l(sock)) { in on_cl_l2cap_psm_connect_l()
562 if (!send_app_connect_signal(sock->our_fd, &sock->addr, sock->channel, 0, -1, in on_cl_l2cap_psm_connect_l()
563 sock->rx_mtu, p_open->tx_mtu)) { in on_cl_l2cap_psm_connect_l()
569 sock->addr, sock->id, sock->is_le_coc ? BTSOCK_L2CAP_LE : BTSOCK_L2CAP, in on_cl_l2cap_psm_connect_l()
571 sock->app_uid, sock->channel, in on_cl_l2cap_psm_connect_l()
572 sock->server ? android::bluetooth::SOCKET_ROLE_LISTEN in on_cl_l2cap_psm_connect_l()
576 DVLOG(2) << " connect signal sent, slot id: " << sock->id in on_cl_l2cap_psm_connect_l()
577 << ", chan: " << sock->channel << ", server: " << sock->server; in on_cl_l2cap_psm_connect_l()
578 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, SOCK_THREAD_FD_RD, in on_cl_l2cap_psm_connect_l()
579 sock->id); in on_cl_l2cap_psm_connect_l()
580 sock->connected = true; in on_cl_l2cap_psm_connect_l()
584 l2cap_socket* sock) { in on_cl_l2cap_le_connect_l() argument
585 sock->addr = p_open->rem_bda; in on_cl_l2cap_le_connect_l()
586 sock->tx_mtu = p_open->tx_mtu; in on_cl_l2cap_le_connect_l()
588 if (!send_app_psm_or_chan_l(sock)) { in on_cl_l2cap_le_connect_l()
593 if (!send_app_connect_signal(sock->our_fd, &sock->addr, sock->channel, 0, -1, in on_cl_l2cap_le_connect_l()
594 sock->rx_mtu, p_open->tx_mtu)) { in on_cl_l2cap_le_connect_l()
600 sock->addr, sock->id, sock->is_le_coc ? BTSOCK_L2CAP_LE : BTSOCK_L2CAP, in on_cl_l2cap_le_connect_l()
602 sock->app_uid, sock->channel, in on_cl_l2cap_le_connect_l()
603 sock->server ? android::bluetooth::SOCKET_ROLE_LISTEN in on_cl_l2cap_le_connect_l()
607 DVLOG(2) << " connect signal sent, slot id: " << sock->id in on_cl_l2cap_le_connect_l()
608 << ", chan: " << sock->channel << ", server: " << sock->server; in on_cl_l2cap_le_connect_l()
609 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, SOCK_THREAD_FD_RD, in on_cl_l2cap_le_connect_l()
610 sock->id); in on_cl_l2cap_le_connect_l()
611 sock->connected = true; in on_cl_l2cap_le_connect_l()
615 l2cap_socket* sock; in on_l2cap_connect() local
620 sock = btsock_l2cap_find_by_id_l(id); in on_l2cap_connect()
621 if (!sock) { in on_l2cap_connect()
626 sock->tx_mtu = le_open->tx_mtu; in on_l2cap_connect()
627 if (sock->fixed_chan && le_open->status == BTA_JV_SUCCESS) { in on_l2cap_connect()
628 if (!sock->server) { in on_l2cap_connect()
629 on_cl_l2cap_le_connect_l(le_open, sock); in on_l2cap_connect()
631 on_srv_l2cap_le_connect_l(le_open, sock); in on_l2cap_connect()
633 } else if (!sock->fixed_chan && psm_open->status == BTA_JV_SUCCESS) { in on_l2cap_connect()
634 if (!sock->server) { in on_l2cap_connect()
635 on_cl_l2cap_psm_connect_l(psm_open, sock); in on_l2cap_connect()
637 on_srv_l2cap_psm_connect_l(psm_open, sock); in on_l2cap_connect()
640 btsock_l2cap_free_l(sock); in on_l2cap_connect()
645 l2cap_socket* sock; in on_l2cap_close() local
648 sock = btsock_l2cap_find_by_id_l(id); in on_l2cap_close()
649 if (!sock) return; in on_l2cap_close()
652 sock->addr, sock->id, sock->is_le_coc ? BTSOCK_L2CAP_LE : BTSOCK_L2CAP, in on_l2cap_close()
654 sock->app_uid, sock->channel, in on_l2cap_close()
655 sock->server ? android::bluetooth::SOCKET_ROLE_LISTEN in on_l2cap_close()
658 DVLOG(2) << __func__ << ": slot id: " << sock->id << ", fd: " << sock->our_fd in on_l2cap_close()
659 << (sock->fixed_chan ? ", fixed_chan:" : ", PSM: ") << sock->channel in on_l2cap_close()
660 << ", server:" << sock->server; in on_l2cap_close()
663 if (!sock->fixed_chan && (sock->server)) { in on_l2cap_close()
664 BTA_JvFreeChannel(sock->channel, BTA_JV_CONN_TYPE_L2CAP); in on_l2cap_close()
666 btsock_l2cap_free_l(sock); in on_l2cap_close()
670 l2cap_socket* sock; in on_l2cap_outgoing_congest() local
673 sock = btsock_l2cap_find_by_id_l(id); in on_l2cap_outgoing_congest()
674 if (!sock) return; in on_l2cap_outgoing_congest()
676 sock->outgoing_congest = p->cong ? 1 : 0; in on_l2cap_outgoing_congest()
678 if (!sock->outgoing_congest) { in on_l2cap_outgoing_congest()
680 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, SOCK_THREAD_FD_RD, in on_l2cap_outgoing_congest()
681 sock->id); in on_l2cap_outgoing_congest()
687 l2cap_socket* sock = btsock_l2cap_find_by_id_l(id); in on_l2cap_write_done() local
688 if (!sock) return; in on_l2cap_write_done()
690 int app_uid = sock->app_uid; in on_l2cap_write_done()
691 if (!sock->outgoing_congest) { in on_l2cap_write_done()
694 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, SOCK_THREAD_FD_RD, in on_l2cap_write_done()
695 sock->id); in on_l2cap_write_done()
698 sock->tx_bytes += len; in on_l2cap_write_done()
703 l2cap_socket* sock; in on_l2cap_data_ind() local
709 sock = btsock_l2cap_find_by_id_l(id); in on_l2cap_data_ind()
710 if (!sock) return; in on_l2cap_data_ind()
712 app_uid = sock->app_uid; in on_l2cap_data_ind()
714 if (sock->fixed_chan) { /* we do these differently */ in on_l2cap_data_ind()
720 if (packet_put_tail_l(sock, data, p_buf->len)) { in on_l2cap_data_ind()
722 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, SOCK_THREAD_FD_WR, in on_l2cap_data_ind()
723 sock->id); in on_l2cap_data_ind()
727 BTA_JvL2capCloseLE(sock->handle); in on_l2cap_data_ind()
728 btsock_l2cap_free_l(sock); in on_l2cap_data_ind()
734 if (BTA_JvL2capReady(sock->handle, &count) == BTA_JV_SUCCESS) { in on_l2cap_data_ind()
736 if (BTA_JvL2capRead(sock->handle, sock->id, buffer.data(), count) == in on_l2cap_data_ind()
738 if (packet_put_tail_l(sock, buffer.data(), count)) { in on_l2cap_data_ind()
740 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, in on_l2cap_data_ind()
741 SOCK_THREAD_FD_WR, sock->id); in on_l2cap_data_ind()
745 BTA_JvL2capClose(sock->handle); in on_l2cap_data_ind()
746 btsock_l2cap_free_l(sock); in on_l2cap_data_ind()
752 sock->rx_bytes += bytes_read; in on_l2cap_data_ind()
835 l2cap_socket* sock = btsock_l2cap_find_by_id_l(id); in on_l2cap_psm_assigned() local
836 if (!sock) { in on_l2cap_psm_assigned()
841 sock->channel = psm; in on_l2cap_psm_assigned()
843 btsock_l2cap_server_listen(sock); in on_l2cap_psm_assigned()
846 static void btsock_l2cap_server_listen(l2cap_socket* sock) { in btsock_l2cap_server_listen() argument
847 DVLOG(2) << __func__ << ": fixed_chan: " << sock->fixed_chan in btsock_l2cap_server_listen()
848 << ", channel: " << sock->channel in btsock_l2cap_server_listen()
849 << ", is_le_coc: " << sock->is_le_coc; in btsock_l2cap_server_listen()
851 if (sock->fixed_chan) { in btsock_l2cap_server_listen()
852 BTA_JvL2capStartServerLE(sock->channel, btsock_l2cap_cbk, sock->id); in btsock_l2cap_server_listen()
857 sock->is_le_coc ? BTA_JV_CONN_TYPE_L2CAP_LE : BTA_JV_CONN_TYPE_L2CAP; in btsock_l2cap_server_listen()
861 if (sock->channel <= 0) { in btsock_l2cap_server_listen()
862 BTA_JvGetChannelId(connection_type, sock->id, 0); in btsock_l2cap_server_listen()
871 if (!sock->is_le_coc) { in btsock_l2cap_server_listen()
875 BTA_JvL2capStartServer(connection_type, sock->security, 0, in btsock_l2cap_server_listen()
876 std::move(ertm_info), sock->channel, sock->rx_mtu, in btsock_l2cap_server_listen()
877 std::move(cfg), btsock_l2cap_cbk, sock->id); in btsock_l2cap_server_listen()
904 l2cap_socket* sock = btsock_l2cap_alloc_l(name, addr, listen, flags); in btsock_l2cap_listen_or_connect() local
905 if (!sock) { in btsock_l2cap_listen_or_connect()
909 sock->fixed_chan = fixed_chan; in btsock_l2cap_listen_or_connect()
910 sock->channel = channel; in btsock_l2cap_listen_or_connect()
911 sock->app_uid = app_uid; in btsock_l2cap_listen_or_connect()
912 sock->is_le_coc = is_le_coc; in btsock_l2cap_listen_or_connect()
913 sock->rx_mtu = is_le_coc ? L2CAP_SDU_LENGTH_LE_MAX : L2CAP_SDU_LENGTH_MAX; in btsock_l2cap_listen_or_connect()
917 btsock_l2cap_server_listen(sock); in btsock_l2cap_listen_or_connect()
920 BTA_JvL2capConnectLE(channel, sock->addr, btsock_l2cap_cbk, sock->id); in btsock_l2cap_listen_or_connect()
923 sock->is_le_coc ? BTA_JV_CONN_TYPE_L2CAP_LE : BTA_JV_CONN_TYPE_L2CAP; in btsock_l2cap_listen_or_connect()
930 if (!sock->is_le_coc) { in btsock_l2cap_listen_or_connect()
935 connection_type, sock->security, 0, std::move(ertm_info), channel, in btsock_l2cap_listen_or_connect()
936 sock->rx_mtu, std::move(cfg), sock->addr, btsock_l2cap_cbk, sock->id); in btsock_l2cap_listen_or_connect()
940 *sock_fd = sock->app_fd; in btsock_l2cap_listen_or_connect()
944 sock->app_fd = -1; in btsock_l2cap_listen_or_connect()
947 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, in btsock_l2cap_listen_or_connect()
948 SOCK_THREAD_FD_EXCEPTION, sock->id); in btsock_l2cap_listen_or_connect()
969 static bool flush_incoming_que_on_wr_signal_l(l2cap_socket* sock) { in flush_incoming_que_on_wr_signal_l() argument
973 while (packet_get_head_l(sock, &buf, &len)) { in flush_incoming_que_on_wr_signal_l()
975 OSI_NO_INTR(sent = send(sock->our_fd, buf, len, MSG_DONTWAIT)); in flush_incoming_que_on_wr_signal_l()
981 packet_put_head_l(sock, buf + sent, len - sent); in flush_incoming_que_on_wr_signal_l()
986 packet_put_head_l(sock, buf, len); in flush_incoming_que_on_wr_signal_l()
1014 l2cap_socket* sock = btsock_l2cap_find_by_id_l(user_id); in btsock_l2cap_signaled() local
1015 if (!sock) return; in btsock_l2cap_signaled()
1017 if ((flags & SOCK_THREAD_FD_RD) && !sock->server) { in btsock_l2cap_signaled()
1019 if (sock->connected) { in btsock_l2cap_signaled()
1021 bool ioctl_success = ioctl(sock->our_fd, FIONREAD, &size) == 0; in btsock_l2cap_signaled()
1029 size = std::min(size, (int)sock->tx_mtu); in btsock_l2cap_signaled()
1037 if (count > sock->tx_mtu) { in btsock_l2cap_signaled()
1041 count = sock->tx_mtu; in btsock_l2cap_signaled()
1051 if (sock->fixed_chan) { in btsock_l2cap_signaled()
1053 BTA_JvL2capWriteFixed(sock->channel, sock->addr, PTR_TO_UINT(buffer), in btsock_l2cap_signaled()
1057 BTA_JvL2capWrite(sock->handle, PTR_TO_UINT(buffer), buffer, user_id); in btsock_l2cap_signaled()
1065 if (flush_incoming_que_on_wr_signal_l(sock) && sock->connected) in btsock_l2cap_signaled()
1066 btsock_thread_add_fd(pth, sock->our_fd, BTSOCK_L2CAP, SOCK_THREAD_FD_WR, in btsock_l2cap_signaled()
1067 sock->id); in btsock_l2cap_signaled()
1071 if (drop_it || ioctl(sock->our_fd, FIONREAD, &size) != 0 || size == 0) in btsock_l2cap_signaled()
1072 btsock_l2cap_free_l(sock); in btsock_l2cap_signaled()