net/bluetooth/hci_event.c
Source file repositories/reference/linux-study-clean/net/bluetooth/hci_event.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/hci_event.c- Extension
.c- Size
- 205571 bytes
- Lines
- 7873
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/unaligned.hlinux/crypto.hcrypto/algapi.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hnet/bluetooth/mgmt.hhci_debugfs.hhci_codec.hsmp.hmsft.heir.h
Detected Declarations
function Copyrightfunction hci_cc_inquiry_cancelfunction hci_cc_periodic_inqfunction hci_cc_exit_periodic_inqfunction hci_cc_remote_name_req_cancelfunction hci_cc_role_discoveryfunction hci_cc_read_link_policyfunction hci_cc_write_link_policyfunction hci_cc_read_def_link_policyfunction hci_cc_write_def_link_policyfunction hci_cc_resetfunction hci_cc_read_stored_link_keyfunction hci_cc_delete_stored_link_keyfunction hci_cc_write_local_namefunction hci_cc_read_local_namefunction hci_cc_write_auth_enablefunction hci_cc_write_encrypt_modefunction hci_cc_write_scan_enablefunction hci_cc_set_event_filterfunction hci_cc_read_class_of_devfunction hci_cc_write_class_of_devfunction hci_cc_read_voice_settingfunction hci_cc_write_voice_settingfunction hci_cc_read_num_supported_iacfunction hci_cc_write_ssp_modefunction hci_cc_write_sc_supportfunction hci_cc_read_local_versionfunction hci_cc_read_enc_key_sizefunction hci_cc_read_local_commandsfunction hci_cc_read_auth_payload_timeoutfunction hci_cc_write_auth_payload_timeoutfunction hci_cc_read_local_featuresfunction hci_cc_read_local_ext_featuresfunction hci_cc_read_buffer_sizefunction hci_cc_read_bd_addrfunction hci_cc_read_local_pairing_optsfunction hci_cc_read_page_scan_activityfunction hci_cc_write_page_scan_activityfunction hci_cc_read_page_scan_typefunction hci_cc_write_page_scan_typefunction hci_cc_read_clockfunction hci_cc_read_inq_rsp_tx_powerfunction hci_cc_read_def_err_data_reportingfunction hci_cc_write_def_err_data_reportingfunction hci_cc_pin_code_replyfunction hci_cc_pin_code_neg_replyfunction hci_cc_le_read_buffer_sizefunction hci_cc_le_read_local_features
Annotated Snippet
hci_dev_test_flag(hdev, HCI_CONFIG)) {
hdev->hci_ver = rp->hci_ver;
hdev->hci_rev = __le16_to_cpu(rp->hci_rev);
hdev->lmp_ver = rp->lmp_ver;
hdev->manufacturer = __le16_to_cpu(rp->manufacturer);
hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver);
}
return rp->status;
}
static u8 hci_cc_read_enc_key_size(struct hci_dev *hdev, void *data,
struct sk_buff *skb)
{
struct hci_rp_read_enc_key_size *rp = data;
struct hci_conn *conn;
u16 handle;
u8 status = rp->status;
bt_dev_dbg(hdev, "status 0x%2.2x", status);
handle = le16_to_cpu(rp->handle);
hci_dev_lock(hdev);
conn = hci_conn_hash_lookup_handle(hdev, handle);
if (!conn) {
status = 0xFF;
goto done;
}
/* While unexpected, the read_enc_key_size command may fail. The most
* secure approach is to then assume the key size is 0 to force a
* disconnection.
*/
if (status) {
bt_dev_err(hdev, "failed to read key size for handle %u",
handle);
conn->enc_key_size = 0;
} else {
u8 *key_enc_size = hci_conn_key_enc_size(conn);
conn->enc_key_size = rp->key_size;
status = 0;
/* Attempt to check if the key size is too small or if it has
* been downgraded from the last time it was stored as part of
* the link_key.
*/
if (conn->enc_key_size < hdev->min_enc_key_size ||
(key_enc_size && conn->enc_key_size < *key_enc_size)) {
/* As slave role, the conn->state has been set to
* BT_CONNECTED and l2cap conn req might not be received
* yet, at this moment the l2cap layer almost does
* nothing with the non-zero status.
* So we also clear encrypt related bits, and then the
* handler of l2cap conn req will get the right secure
* state at a later time.
*/
status = HCI_ERROR_AUTH_FAILURE;
clear_bit(HCI_CONN_ENCRYPT, &conn->flags);
clear_bit(HCI_CONN_AES_CCM, &conn->flags);
}
/* Update the key encryption size with the connection one */
if (key_enc_size && *key_enc_size != conn->enc_key_size)
*key_enc_size = conn->enc_key_size;
}
hci_encrypt_cfm(conn, status);
done:
hci_dev_unlock(hdev);
return status;
}
static u8 hci_cc_read_local_commands(struct hci_dev *hdev, void *data,
struct sk_buff *skb)
{
struct hci_rp_read_local_commands *rp = data;
bt_dev_dbg(hdev, "status 0x%2.2x", rp->status);
if (rp->status)
return rp->status;
if (hci_dev_test_flag(hdev, HCI_SETUP) ||
hci_dev_test_flag(hdev, HCI_CONFIG))
memcpy(hdev->commands, rp->commands, sizeof(hdev->commands));
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/crypto.h`, `crypto/algapi.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`, `net/bluetooth/mgmt.h`, `hci_debugfs.h`, `hci_codec.h`.
- Detected declarations: `function Copyright`, `function hci_cc_inquiry_cancel`, `function hci_cc_periodic_inq`, `function hci_cc_exit_periodic_inq`, `function hci_cc_remote_name_req_cancel`, `function hci_cc_role_discovery`, `function hci_cc_read_link_policy`, `function hci_cc_write_link_policy`, `function hci_cc_read_def_link_policy`, `function hci_cc_write_def_link_policy`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.