net/bluetooth/mgmt_config.c

Source file repositories/reference/linux-study-clean/net/bluetooth/mgmt_config.c

File Facts

System
Linux kernel
Corpus path
net/bluetooth/mgmt_config.c
Extension
.c
Size
10037 bytes
Lines
368
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct mgmt_rp_read_def_system_config {
		/* Please see mgmt-api.txt for documentation of these values */
		HDEV_PARAM_U16(def_page_scan_type);
		HDEV_PARAM_U16(def_page_scan_int);
		HDEV_PARAM_U16(def_page_scan_window);
		HDEV_PARAM_U16(def_inq_scan_type);
		HDEV_PARAM_U16(def_inq_scan_int);
		HDEV_PARAM_U16(def_inq_scan_window);
		HDEV_PARAM_U16(def_br_lsto);
		HDEV_PARAM_U16(def_page_timeout);
		HDEV_PARAM_U16(sniff_min_interval);
		HDEV_PARAM_U16(sniff_max_interval);
		HDEV_PARAM_U16(le_adv_min_interval);
		HDEV_PARAM_U16(le_adv_max_interval);
		HDEV_PARAM_U16(def_multi_adv_rotation_duration);
		HDEV_PARAM_U16(le_scan_interval);
		HDEV_PARAM_U16(le_scan_window);
		HDEV_PARAM_U16(le_scan_int_suspend);
		HDEV_PARAM_U16(le_scan_window_suspend);
		HDEV_PARAM_U16(le_scan_int_discovery);
		HDEV_PARAM_U16(le_scan_window_discovery);
		HDEV_PARAM_U16(le_scan_int_adv_monitor);
		HDEV_PARAM_U16(le_scan_window_adv_monitor);
		HDEV_PARAM_U16(le_scan_int_connect);
		HDEV_PARAM_U16(le_scan_window_connect);
		HDEV_PARAM_U16(le_conn_min_interval);
		HDEV_PARAM_U16(le_conn_max_interval);
		HDEV_PARAM_U16(le_conn_latency);
		HDEV_PARAM_U16(le_supv_timeout);
		HDEV_PARAM_U16(def_le_autoconnect_timeout);
		HDEV_PARAM_U16(advmon_allowlist_duration);
		HDEV_PARAM_U16(advmon_no_filter_duration);
		HDEV_PARAM_U8(enable_advmon_interleave_scan);
		HDEV_PARAM_U32(idle_timeout);
	} __packed rp = {
		TLV_SET_U16(0x0000, def_page_scan_type),
		TLV_SET_U16(0x0001, def_page_scan_int),
		TLV_SET_U16(0x0002, def_page_scan_window),
		TLV_SET_U16(0x0003, def_inq_scan_type),
		TLV_SET_U16(0x0004, def_inq_scan_int),
		TLV_SET_U16(0x0005, def_inq_scan_window),
		TLV_SET_U16(0x0006, def_br_lsto),
		TLV_SET_U16(0x0007, def_page_timeout),
		TLV_SET_U16(0x0008, sniff_min_interval),
		TLV_SET_U16(0x0009, sniff_max_interval),
		TLV_SET_U16(0x000a, le_adv_min_interval),
		TLV_SET_U16(0x000b, le_adv_max_interval),
		TLV_SET_U16(0x000c, def_multi_adv_rotation_duration),
		TLV_SET_U16(0x000d, le_scan_interval),
		TLV_SET_U16(0x000e, le_scan_window),
		TLV_SET_U16(0x000f, le_scan_int_suspend),
		TLV_SET_U16(0x0010, le_scan_window_suspend),
		TLV_SET_U16(0x0011, le_scan_int_discovery),
		TLV_SET_U16(0x0012, le_scan_window_discovery),
		TLV_SET_U16(0x0013, le_scan_int_adv_monitor),
		TLV_SET_U16(0x0014, le_scan_window_adv_monitor),
		TLV_SET_U16(0x0015, le_scan_int_connect),
		TLV_SET_U16(0x0016, le_scan_window_connect),
		TLV_SET_U16(0x0017, le_conn_min_interval),
		TLV_SET_U16(0x0018, le_conn_max_interval),
		TLV_SET_U16(0x0019, le_conn_latency),
		TLV_SET_U16(0x001a, le_supv_timeout),
		TLV_SET_U16_JIFFIES_TO_MSECS(0x001b,
					     def_le_autoconnect_timeout),
		TLV_SET_U16(0x001d, advmon_allowlist_duration),
		TLV_SET_U16(0x001e, advmon_no_filter_duration),
		TLV_SET_U8(0x001f, enable_advmon_interleave_scan),
		TLV_SET_U32(0x0020, idle_timeout),
	};

	bt_dev_dbg(hdev, "sock %p", sk);

	ret = mgmt_cmd_complete(sk, hdev->id,
				MGMT_OP_READ_DEF_SYSTEM_CONFIG,
				0, &rp, sizeof(rp));
	return ret;
}

#define TO_TLV(x)		((struct mgmt_tlv *)(x))
#define TLV_GET_LE32(tlv)	le32_to_cpu(*((__le32 *)(TO_TLV(tlv)->value)))
#define TLV_GET_LE16(tlv)	le16_to_cpu(*((__le16 *)(TO_TLV(tlv)->value)))
#define TLV_GET_U8(tlv)		(*((__u8 *)(TO_TLV(tlv)->value)))

int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
			  u16 data_len)
{
	u16 buffer_left = data_len;
	u8 *buffer = data;

	if (buffer_left < sizeof(struct mgmt_tlv)) {

Annotation

Implementation Notes