l2cap.c (f8ecb1142c7bfe06c09809b017c6c9d145930404) | l2cap.c (836ae835de05101c90cc1c5bdb966becb971b81b) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 148 unchanged lines hidden (view full) --- 157static void l2cap_emit_le_channel_opened(l2cap_channel_t *channel, uint8_t status); 158static void l2cap_emit_le_channel_closed(l2cap_channel_t * channel); 159static void l2cap_emit_le_incoming_connection(l2cap_channel_t *channel); 160static void l2cap_le_notify_channel_can_send(l2cap_channel_t *channel); 161static void l2cap_le_finialize_channel_close(l2cap_channel_t *channel); 162static inline l2cap_service_t * l2cap_le_get_service(uint16_t psm); 163#endif 164#ifdef L2CAP_USES_CHANNELS | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 148 unchanged lines hidden (view full) --- 157static void l2cap_emit_le_channel_opened(l2cap_channel_t *channel, uint8_t status); 158static void l2cap_emit_le_channel_closed(l2cap_channel_t * channel); 159static void l2cap_emit_le_incoming_connection(l2cap_channel_t *channel); 160static void l2cap_le_notify_channel_can_send(l2cap_channel_t *channel); 161static void l2cap_le_finialize_channel_close(l2cap_channel_t *channel); 162static inline l2cap_service_t * l2cap_le_get_service(uint16_t psm); 163#endif 164#ifdef L2CAP_USES_CHANNELS |
165static void l2cap_emit_simple_event_with_cid(l2cap_channel_t * channel, uint8_t event_code); |
|
165static void l2cap_dispatch_to_channel(l2cap_channel_t *channel, uint8_t type, uint8_t * data, uint16_t size); 166static l2cap_channel_t * l2cap_get_channel_for_local_cid(uint16_t local_cid); 167static l2cap_channel_t * l2cap_create_channel_entry(btstack_packet_handler_t packet_handler, l2cap_channel_type_t channel_type, bd_addr_t address, bd_addr_type_t address_type, 168 uint16_t psm, uint16_t local_mtu, gap_security_level_t security_level); 169static void l2cap_free_channel_entry(l2cap_channel_t * channel); 170#endif 171#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE 172static void l2cap_ertm_notify_channel_can_send(l2cap_channel_t * channel); --- 478 unchanged lines hidden (view full) --- 651 652 // validate local config 653 uint8_t result = l2cap_ertm_validate_local_config(ertm_config); 654 if (result) return result; 655 656 // configure L2CAP ERTM 657 l2cap_ertm_configure_channel(channel, ertm_config, buffer, size); 658 | 166static void l2cap_dispatch_to_channel(l2cap_channel_t *channel, uint8_t type, uint8_t * data, uint16_t size); 167static l2cap_channel_t * l2cap_get_channel_for_local_cid(uint16_t local_cid); 168static l2cap_channel_t * l2cap_create_channel_entry(btstack_packet_handler_t packet_handler, l2cap_channel_type_t channel_type, bd_addr_t address, bd_addr_type_t address_type, 169 uint16_t psm, uint16_t local_mtu, gap_security_level_t security_level); 170static void l2cap_free_channel_entry(l2cap_channel_t * channel); 171#endif 172#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE 173static void l2cap_ertm_notify_channel_can_send(l2cap_channel_t * channel); --- 478 unchanged lines hidden (view full) --- 652 653 // validate local config 654 uint8_t result = l2cap_ertm_validate_local_config(ertm_config); 655 if (result) return result; 656 657 // configure L2CAP ERTM 658 l2cap_ertm_configure_channel(channel, ertm_config, buffer, size); 659 |
659 // continue | 660 // default: continue |
660 channel->state = L2CAP_STATE_WILL_SEND_CONNECTION_RESPONSE_ACCEPT; 661 | 661 channel->state = L2CAP_STATE_WILL_SEND_CONNECTION_RESPONSE_ACCEPT; 662 |
663 // assert ERTM is supported by remote if mandatory for us 664 hci_connection_t * connection = hci_connection_for_handle(channel->con_handle); 665 if (connection == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 666 667 if ((channel->mode == L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION) && ((connection->l2cap_state.extended_feature_mask & 0x08) == 0)){ 668 669 // bail if ERTM was requested but is not supported 670 if (channel->ertm_mandatory){ 671 // We chose 'no resources available' for "ERTM mandatory but you don't even know ERTM exists" 672 log_info("ERTM not supported by remote but mandatory -> reject connection"); 673 channel->state = L2CAP_STATE_WILL_SEND_CONNECTION_RESPONSE_DECLINE; 674 channel->reason = 0x04; // no resources available 675 } 676 677 // fallback to Basic mode 678 else { 679 log_info("ERTM not supported by remote -> fallback Basic mode"); 680 l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_ERTM_BUFFER_RELEASED); 681 channel->mode = L2CAP_CHANNEL_MODE_BASIC; 682 } 683 } 684 |
|
662 // process 663 l2cap_run(); 664 665 return ERROR_CODE_SUCCESS; 666} 667 668uint8_t l2cap_ertm_set_busy(uint16_t local_cid){ 669 l2cap_channel_t * channel = l2cap_get_channel_for_local_cid( local_cid); --- 3326 unchanged lines hidden --- | 685 // process 686 l2cap_run(); 687 688 return ERROR_CODE_SUCCESS; 689} 690 691uint8_t l2cap_ertm_set_busy(uint16_t local_cid){ 692 l2cap_channel_t * channel = l2cap_get_channel_for_local_cid( local_cid); --- 3326 unchanged lines hidden --- |