net/bluetooth/mgmt.c
Source file repositories/reference/linux-study-clean/net/bluetooth/mgmt.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/mgmt.c- Extension
.c- Size
- 272701 bytes
- Lines
- 10635
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/unaligned.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hnet/bluetooth/hci_sock.hnet/bluetooth/l2cap.hnet/bluetooth/mgmt.hsmp.hmgmt_util.hmgmt_config.hmsft.heir.haosp.h
Detected Declarations
struct cmd_lookupfunction mgmt_errno_statusfunction mgmt_statusfunction mgmt_index_eventfunction mgmt_limited_eventfunction mgmt_eventfunction mgmt_event_skbfunction le_addr_typefunction mgmt_fill_version_infofunction read_versionfunction read_commandsfunction read_index_listfunction read_unconf_index_listfunction read_ext_index_listfunction is_configuredfunction get_missing_optionsfunction new_optionsfunction send_options_rspfunction read_config_infofunction get_supported_physfunction get_selected_physfunction get_configurable_physfunction get_supported_settingsfunction get_current_settingsfunction mgmt_get_adv_discov_flagsfunction mgmt_get_connectablefunction service_cache_syncfunction service_cache_offfunction rpa_expired_syncfunction rpa_expiredfunction discov_offfunction mesh_send_completefunction mesh_send_done_syncfunction mesh_nextfunction mesh_send_donefunction mgmt_init_hdevfunction read_controller_infofunction append_eir_data_to_buffunction read_ext_controller_infofunction ext_info_changedfunction send_settings_rspfunction mgmt_advertising_addedfunction mgmt_advertising_removedfunction cancel_adv_timeoutfunction restart_le_actionsfunction list_for_each_entryfunction new_settingsfunction mgmt_set_powered_complete
Annotated Snippet
struct cmd_lookup {
struct sock *sk;
struct hci_dev *hdev;
u8 mgmt_status;
};
static void settings_rsp(struct mgmt_pending_cmd *cmd, void *data)
{
struct cmd_lookup *match = data;
send_settings_rsp(cmd->sk, cmd->opcode, match->hdev);
if (match->sk == NULL) {
match->sk = cmd->sk;
sock_hold(match->sk);
}
}
static void cmd_status_rsp(struct mgmt_pending_cmd *cmd, void *data)
{
u8 *status = data;
mgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode, *status);
}
static void cmd_complete_rsp(struct mgmt_pending_cmd *cmd, void *data)
{
struct cmd_lookup *match = data;
/* dequeue cmd_sync entries using cmd as data as that is about to be
* removed/freed.
*/
hci_cmd_sync_dequeue(match->hdev, NULL, cmd, NULL);
if (cmd->cmd_complete) {
cmd->cmd_complete(cmd, match->mgmt_status);
return;
}
cmd_status_rsp(cmd, data);
}
static int generic_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)
{
return mgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode, status,
cmd->param, cmd->param_len);
}
static int addr_cmd_complete(struct mgmt_pending_cmd *cmd, u8 status)
{
return mgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode, status,
cmd->param, sizeof(struct mgmt_addr_info));
}
static u8 mgmt_bredr_support(struct hci_dev *hdev)
{
if (!lmp_bredr_capable(hdev))
return MGMT_STATUS_NOT_SUPPORTED;
else if (!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))
return MGMT_STATUS_REJECTED;
else
return MGMT_STATUS_SUCCESS;
}
static u8 mgmt_le_support(struct hci_dev *hdev)
{
if (!lmp_le_capable(hdev))
return MGMT_STATUS_NOT_SUPPORTED;
else if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED))
return MGMT_STATUS_REJECTED;
else
return MGMT_STATUS_SUCCESS;
}
static void mgmt_set_discoverable_complete(struct hci_dev *hdev, void *data,
int err)
{
struct mgmt_pending_cmd *cmd = data;
bt_dev_dbg(hdev, "err %d", err);
/* Make sure cmd still outstanding. */
if (err == -ECANCELED || !mgmt_pending_valid(hdev, cmd))
return;
hci_dev_lock(hdev);
if (err) {
u8 mgmt_err = mgmt_status(err);
mgmt_cmd_status(cmd->sk, cmd->hdev->id, cmd->opcode, mgmt_err);
Annotation
- Immediate include surface: `linux/module.h`, `linux/unaligned.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`, `net/bluetooth/hci_sock.h`, `net/bluetooth/l2cap.h`, `net/bluetooth/mgmt.h`, `smp.h`.
- Detected declarations: `struct cmd_lookup`, `function mgmt_errno_status`, `function mgmt_status`, `function mgmt_index_event`, `function mgmt_limited_event`, `function mgmt_event`, `function mgmt_event_skb`, `function le_addr_type`, `function mgmt_fill_version_info`, `function read_version`.
- 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.