2012-05-23 06:00:20 +08:00
|
|
|
/*
|
2005-04-17 06:20:36 +08:00
|
|
|
BlueZ - Bluetooth protocol stack for Linux
|
|
|
|
Copyright (C) 2000-2001 Qualcomm Incorporated
|
|
|
|
|
|
|
|
Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License version 2 as
|
|
|
|
published by the Free Software Foundation;
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
|
|
|
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
|
2012-05-23 06:00:20 +08:00
|
|
|
CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
2005-04-17 06:20:36 +08:00
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
2012-05-23 06:00:20 +08:00
|
|
|
ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
|
|
|
|
COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
|
2005-04-17 06:20:36 +08:00
|
|
|
SOFTWARE IS DISCLAIMED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BLUETOOTH_H
|
|
|
|
#define __BLUETOOTH_H
|
|
|
|
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <net/sock.h>
|
Bluetooth: /proc/net/ entries for bluetooth protocols
lsof command can tell the type of socket processes are using.
Internal lsof uses inode numbers on socket fs to resolve the type of
sockets. Files under /proc/net/, such as tcp, udp, unix, etc provides
such inode information.
Unfortunately bluetooth related protocols don't provide such inode
information. This patch series introduces /proc/net files for the protocols.
This patch against af_bluetooth.c provides facility to the implementation
of protocols. This patch extends bt_sock_list and introduces two exported
function bt_procfs_init, bt_procfs_cleanup.
The type bt_sock_list is already used in some of implementation of
protocols. bt_procfs_init prepare seq_operations which converts
protocol own bt_sock_list data to protocol own proc entry when the
entry is accessed.
What I, lsof user, need is just inode number of bluetooth
socket. However, people may want more information. The bt_procfs_init
takes a function pointer for customizing the show handler of
seq_operations.
In v4 patch, __acquires and __releases attributes are added to suppress
sparse warning. Suggested by Andrei Emeltchenko.
In v5 patch, linux/proc_fs.h is included to use PDE. Build error is
reported by Fengguang Wu.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2012-07-26 00:26:32 +08:00
|
|
|
#include <linux/seq_file.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-08-30 11:00:35 +08:00
|
|
|
#define BT_SUBSYS_VERSION 2
|
2016-09-09 00:07:07 +08:00
|
|
|
#define BT_SUBSYS_REVISION 22
|
2015-11-08 14:47:12 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifndef AF_BLUETOOTH
|
|
|
|
#define AF_BLUETOOTH 31
|
|
|
|
#define PF_BLUETOOTH AF_BLUETOOTH
|
|
|
|
#endif
|
|
|
|
|
2011-12-01 20:33:27 +08:00
|
|
|
/* Bluetooth versions */
|
|
|
|
#define BLUETOOTH_VER_1_1 1
|
|
|
|
#define BLUETOOTH_VER_1_2 2
|
|
|
|
#define BLUETOOTH_VER_2_0 3
|
Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth controllers
For some reason they tend to squat on the very first CSR/
Cambridge Silicon Radio VID/PID instead of paying fees.
This is an extremely common problem; the issue goes as back as 2013
and these devices are only getting more popular, even rebranded by
reputable vendors and sold by retailers everywhere.
So, at this point in time there are hundreds of modern dongles reusing
the ID of what originally was an early Bluetooth 1.1 controller.
Linux is the only place where they don't work due to spotty checks
in our detection code. It only covered a minimum subset.
So what's the big idea? Take advantage of the fact that all CSR
chips report the same internal version as both the LMP sub-version and
HCI revision number. It always matches, couple that with the manufacturer
code, that rarely lies, and we now have a good idea of who is who.
Additionally, by compiling a list of user-reported HCI/lsusb dumps, and
searching around for legit CSR dongles in similar product ranges we can
find what CSR BlueCore firmware supported which Bluetooth versions.
That way we can narrow down ranges of fakes for each of them.
e.g. Real CSR dongles with LMP subversion 0x73 are old enough that
support BT 1.1 only; so it's a dead giveaway when some
third-party BT 4.0 dongle reuses it.
So, to sum things up; there are multiple classes of fake controllers
reusing the same 0A12:0001 VID/PID. This has been broken for a while.
Known 'fake' bcdDevices: 0x0100, 0x0134, 0x1915, 0x2520, 0x7558, 0x8891
IC markings on 0x7558: FR3191AHAL 749H15143 (???)
https://bugzilla.kernel.org/show_bug.cgi?id=60824
Fixes: 81cac64ba258ae (Deal with USB devices that are faking CSR vendor)
Reported-by: Michał Wiśniewski <brylozketrzyn@gmail.com>
Tested-by: Mike Johnson <yuyuyak@gmail.com>
Tested-by: Ricardo Rodrigues <ekatonb@gmail.com>
Tested-by: M.Hanny Sabbagh <mhsabbagh@outlook.com>
Tested-by: Oussama BEN BRAHIM <b.brahim.oussama@gmail.com>
Tested-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com>
Signed-off-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2020-07-27 05:12:28 +08:00
|
|
|
#define BLUETOOTH_VER_2_1 4
|
|
|
|
#define BLUETOOTH_VER_4_0 6
|
2011-12-01 20:33:27 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Reserv for core and drivers use */
|
|
|
|
#define BT_SKB_RESERVE 8
|
|
|
|
|
|
|
|
#define BTPROTO_L2CAP 0
|
|
|
|
#define BTPROTO_HCI 1
|
|
|
|
#define BTPROTO_SCO 2
|
|
|
|
#define BTPROTO_RFCOMM 3
|
|
|
|
#define BTPROTO_BNEP 4
|
|
|
|
#define BTPROTO_CMTP 5
|
|
|
|
#define BTPROTO_HIDP 6
|
|
|
|
#define BTPROTO_AVDTP 7
|
|
|
|
|
|
|
|
#define SOL_HCI 0
|
|
|
|
#define SOL_L2CAP 6
|
|
|
|
#define SOL_SCO 17
|
|
|
|
#define SOL_RFCOMM 18
|
|
|
|
|
2009-01-16 04:58:04 +08:00
|
|
|
#define BT_SECURITY 4
|
|
|
|
struct bt_security {
|
|
|
|
__u8 level;
|
2011-07-09 05:31:46 +08:00
|
|
|
__u8 key_size;
|
2009-01-16 04:58:04 +08:00
|
|
|
};
|
|
|
|
#define BT_SECURITY_SDP 0
|
|
|
|
#define BT_SECURITY_LOW 1
|
|
|
|
#define BT_SECURITY_MEDIUM 2
|
|
|
|
#define BT_SECURITY_HIGH 3
|
2014-01-16 14:37:39 +08:00
|
|
|
#define BT_SECURITY_FIPS 4
|
2009-01-16 04:58:04 +08:00
|
|
|
|
2009-01-16 04:52:16 +08:00
|
|
|
#define BT_DEFER_SETUP 7
|
|
|
|
|
2011-01-03 17:14:36 +08:00
|
|
|
#define BT_FLUSHABLE 8
|
|
|
|
|
|
|
|
#define BT_FLUSHABLE_OFF 0
|
|
|
|
#define BT_FLUSHABLE_ON 1
|
|
|
|
|
2011-05-24 09:06:04 +08:00
|
|
|
#define BT_POWER 9
|
|
|
|
struct bt_power {
|
|
|
|
__u8 force_active;
|
|
|
|
};
|
|
|
|
#define BT_POWER_FORCE_ACTIVE_OFF 0
|
|
|
|
#define BT_POWER_FORCE_ACTIVE_ON 1
|
|
|
|
|
2011-11-03 07:18:28 +08:00
|
|
|
#define BT_CHANNEL_POLICY 10
|
|
|
|
|
|
|
|
/* BR/EDR only (default policy)
|
|
|
|
* AMP controllers cannot be used.
|
|
|
|
* Channel move requests from the remote device are denied.
|
|
|
|
* If the L2CAP channel is currently using AMP, move the channel to BR/EDR.
|
|
|
|
*/
|
|
|
|
#define BT_CHANNEL_POLICY_BREDR_ONLY 0
|
|
|
|
|
|
|
|
/* BR/EDR Preferred
|
|
|
|
* Allow use of AMP controllers.
|
|
|
|
* If the L2CAP channel is currently on AMP, move it to BR/EDR.
|
|
|
|
* Channel move requests from the remote device are allowed.
|
|
|
|
*/
|
|
|
|
#define BT_CHANNEL_POLICY_BREDR_PREFERRED 1
|
|
|
|
|
|
|
|
/* AMP Preferred
|
|
|
|
* Allow use of AMP controllers
|
|
|
|
* If the L2CAP channel is currently on BR/EDR and AMP controller
|
|
|
|
* resources are available, initiate a channel move to AMP.
|
|
|
|
* Channel move requests from the remote device are allowed.
|
|
|
|
* If the L2CAP socket has not been connected yet, try to create
|
|
|
|
* and configure the channel directly on an AMP controller rather
|
|
|
|
* than BR/EDR.
|
|
|
|
*/
|
|
|
|
#define BT_CHANNEL_POLICY_AMP_PREFERRED 2
|
|
|
|
|
2013-08-19 20:23:56 +08:00
|
|
|
#define BT_VOICE 11
|
|
|
|
struct bt_voice {
|
|
|
|
__u16 setting;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BT_VOICE_TRANSPARENT 0x0003
|
|
|
|
#define BT_VOICE_CVSD_16BIT 0x0060
|
|
|
|
|
2013-12-02 22:34:18 +08:00
|
|
|
#define BT_SNDMTU 12
|
|
|
|
#define BT_RCVMTU 13
|
2020-02-15 02:08:57 +08:00
|
|
|
#define BT_PHY 14
|
|
|
|
|
|
|
|
#define BT_PHY_BR_1M_1SLOT 0x00000001
|
|
|
|
#define BT_PHY_BR_1M_3SLOT 0x00000002
|
|
|
|
#define BT_PHY_BR_1M_5SLOT 0x00000004
|
|
|
|
#define BT_PHY_EDR_2M_1SLOT 0x00000008
|
|
|
|
#define BT_PHY_EDR_2M_3SLOT 0x00000010
|
|
|
|
#define BT_PHY_EDR_2M_5SLOT 0x00000020
|
|
|
|
#define BT_PHY_EDR_3M_1SLOT 0x00000040
|
|
|
|
#define BT_PHY_EDR_3M_3SLOT 0x00000080
|
|
|
|
#define BT_PHY_EDR_3M_5SLOT 0x00000100
|
|
|
|
#define BT_PHY_LE_1M_TX 0x00000200
|
|
|
|
#define BT_PHY_LE_1M_RX 0x00000400
|
|
|
|
#define BT_PHY_LE_2M_TX 0x00000800
|
|
|
|
#define BT_PHY_LE_2M_RX 0x00001000
|
|
|
|
#define BT_PHY_LE_CODED_TX 0x00002000
|
|
|
|
#define BT_PHY_LE_CODED_RX 0x00004000
|
2013-12-02 22:34:18 +08:00
|
|
|
|
2020-03-28 02:32:15 +08:00
|
|
|
#define BT_MODE 15
|
|
|
|
|
|
|
|
#define BT_MODE_BASIC 0x00
|
|
|
|
#define BT_MODE_ERTM 0x01
|
|
|
|
#define BT_MODE_STREAMING 0x02
|
|
|
|
#define BT_MODE_LE_FLOWCTL 0x03
|
|
|
|
#define BT_MODE_EXT_FLOWCTL 0x04
|
|
|
|
|
2020-06-12 03:50:41 +08:00
|
|
|
#define BT_PKT_STATUS 16
|
|
|
|
|
|
|
|
#define BT_SCM_PKT_STATUS 0x03
|
|
|
|
|
2021-09-07 18:12:40 +08:00
|
|
|
#define BT_CODEC 19
|
|
|
|
|
|
|
|
struct bt_codec_caps {
|
|
|
|
__u8 len;
|
|
|
|
__u8 data[];
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct bt_codec {
|
|
|
|
__u8 id;
|
|
|
|
__u16 cid;
|
|
|
|
__u16 vid;
|
|
|
|
__u8 data_path;
|
|
|
|
__u8 num_caps;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct bt_codecs {
|
|
|
|
__u8 num_codecs;
|
|
|
|
struct bt_codec codecs[];
|
|
|
|
} __packed;
|
|
|
|
|
2021-09-07 18:12:43 +08:00
|
|
|
#define BT_CODEC_CVSD 0x02
|
|
|
|
#define BT_CODEC_TRANSPARENT 0x03
|
2021-09-07 18:12:46 +08:00
|
|
|
#define BT_CODEC_MSBC 0x05
|
2021-09-07 18:12:42 +08:00
|
|
|
|
2012-02-17 15:32:42 +08:00
|
|
|
__printf(1, 2)
|
2014-09-23 02:17:41 +08:00
|
|
|
void bt_info(const char *fmt, ...);
|
2012-02-17 15:32:42 +08:00
|
|
|
__printf(1, 2)
|
2015-09-24 00:18:07 +08:00
|
|
|
void bt_warn(const char *fmt, ...);
|
|
|
|
__printf(1, 2)
|
2014-09-23 02:17:41 +08:00
|
|
|
void bt_err(const char *fmt, ...);
|
2020-05-06 15:57:52 +08:00
|
|
|
#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG)
|
|
|
|
void bt_dbg_set(bool enable);
|
|
|
|
bool bt_dbg_get(void);
|
|
|
|
__printf(1, 2)
|
|
|
|
void bt_dbg(const char *fmt, ...);
|
|
|
|
#endif
|
2015-09-17 02:21:53 +08:00
|
|
|
__printf(1, 2)
|
2019-12-11 09:54:43 +08:00
|
|
|
void bt_warn_ratelimited(const char *fmt, ...);
|
|
|
|
__printf(1, 2)
|
2015-09-17 02:21:53 +08:00
|
|
|
void bt_err_ratelimited(const char *fmt, ...);
|
2012-02-17 15:32:42 +08:00
|
|
|
|
|
|
|
#define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__)
|
2015-09-24 00:18:07 +08:00
|
|
|
#define BT_WARN(fmt, ...) bt_warn(fmt "\n", ##__VA_ARGS__)
|
2012-02-17 15:32:42 +08:00
|
|
|
#define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__)
|
2020-05-06 15:57:52 +08:00
|
|
|
|
|
|
|
#if IS_ENABLED(CONFIG_BT_FEATURE_DEBUG)
|
|
|
|
#define BT_DBG(fmt, ...) bt_dbg(fmt "\n", ##__VA_ARGS__)
|
|
|
|
#else
|
2012-02-17 15:32:42 +08:00
|
|
|
#define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__)
|
2020-05-06 15:57:52 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-08-31 00:16:55 +08:00
|
|
|
#define bt_dev_info(hdev, fmt, ...) \
|
|
|
|
BT_INFO("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
|
2015-09-24 00:18:07 +08:00
|
|
|
#define bt_dev_warn(hdev, fmt, ...) \
|
|
|
|
BT_WARN("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
|
2015-08-31 00:16:55 +08:00
|
|
|
#define bt_dev_err(hdev, fmt, ...) \
|
|
|
|
BT_ERR("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
|
|
|
|
#define bt_dev_dbg(hdev, fmt, ...) \
|
|
|
|
BT_DBG("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
|
|
|
|
|
2019-12-11 09:54:43 +08:00
|
|
|
#define bt_dev_warn_ratelimited(hdev, fmt, ...) \
|
|
|
|
bt_warn_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
|
2017-10-30 17:42:59 +08:00
|
|
|
#define bt_dev_err_ratelimited(hdev, fmt, ...) \
|
2019-12-11 18:34:36 +08:00
|
|
|
bt_err_ratelimited("%s: " fmt, (hdev)->name, ##__VA_ARGS__)
|
2017-10-30 17:42:59 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Connection and socket states */
|
|
|
|
enum {
|
|
|
|
BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
|
|
|
|
BT_OPEN,
|
|
|
|
BT_BOUND,
|
|
|
|
BT_LISTEN,
|
|
|
|
BT_CONNECT,
|
|
|
|
BT_CONNECT2,
|
|
|
|
BT_CONFIG,
|
|
|
|
BT_DISCONN,
|
|
|
|
BT_CLOSED
|
|
|
|
};
|
|
|
|
|
2012-02-17 17:40:55 +08:00
|
|
|
/* If unused will be removed by compiler */
|
|
|
|
static inline const char *state_to_string(int state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case BT_CONNECTED:
|
|
|
|
return "BT_CONNECTED";
|
|
|
|
case BT_OPEN:
|
|
|
|
return "BT_OPEN";
|
|
|
|
case BT_BOUND:
|
|
|
|
return "BT_BOUND";
|
|
|
|
case BT_LISTEN:
|
|
|
|
return "BT_LISTEN";
|
|
|
|
case BT_CONNECT:
|
|
|
|
return "BT_CONNECT";
|
|
|
|
case BT_CONNECT2:
|
|
|
|
return "BT_CONNECT2";
|
|
|
|
case BT_CONFIG:
|
|
|
|
return "BT_CONFIG";
|
|
|
|
case BT_DISCONN:
|
|
|
|
return "BT_DISCONN";
|
|
|
|
case BT_CLOSED:
|
|
|
|
return "BT_CLOSED";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "invalid state";
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* BD Address */
|
|
|
|
typedef struct {
|
|
|
|
__u8 b[6];
|
2010-07-19 13:00:13 +08:00
|
|
|
} __packed bdaddr_t;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-04-25 08:02:49 +08:00
|
|
|
/* BD Address type */
|
|
|
|
#define BDADDR_BREDR 0x00
|
|
|
|
#define BDADDR_LE_PUBLIC 0x01
|
|
|
|
#define BDADDR_LE_RANDOM 0x02
|
|
|
|
|
2016-10-06 04:51:42 +08:00
|
|
|
static inline bool bdaddr_type_is_valid(u8 type)
|
2013-01-20 20:27:18 +08:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case BDADDR_BREDR:
|
|
|
|
case BDADDR_LE_PUBLIC:
|
|
|
|
case BDADDR_LE_RANDOM:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-10-06 04:51:42 +08:00
|
|
|
static inline bool bdaddr_type_is_le(u8 type)
|
2013-01-20 20:27:18 +08:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case BDADDR_LE_PUBLIC:
|
|
|
|
case BDADDR_LE_RANDOM:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-10-02 13:59:21 +08:00
|
|
|
#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
|
|
|
|
#define BDADDR_NONE (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Copy, swap, convert BD Address */
|
2013-04-07 02:28:42 +08:00
|
|
|
static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return memcmp(ba1, ba2, sizeof(bdaddr_t));
|
|
|
|
}
|
2013-04-07 02:28:42 +08:00
|
|
|
static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
memcpy(dst, src, sizeof(bdaddr_t));
|
|
|
|
}
|
|
|
|
|
2017-09-02 04:41:17 +08:00
|
|
|
void baswap(bdaddr_t *dst, const bdaddr_t *src);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Common socket structures and functions */
|
|
|
|
|
|
|
|
#define bt_sk(__sk) ((struct bt_sock *) __sk)
|
|
|
|
|
|
|
|
struct bt_sock {
|
|
|
|
struct sock sk;
|
|
|
|
struct list_head accept_q;
|
|
|
|
struct sock *parent;
|
2012-05-16 23:17:10 +08:00
|
|
|
unsigned long flags;
|
2013-10-14 03:55:28 +08:00
|
|
|
void (*skb_msg_name)(struct sk_buff *, void *, int *);
|
2020-06-12 03:50:41 +08:00
|
|
|
void (*skb_put_cmsg)(struct sk_buff *, struct msghdr *, struct sock *);
|
2012-05-16 23:17:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
BT_SK_DEFER_SETUP,
|
|
|
|
BT_SK_SUSPEND,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bt_sock_list {
|
|
|
|
struct hlist_head head;
|
|
|
|
rwlock_t lock;
|
Bluetooth: /proc/net/ entries for bluetooth protocols
lsof command can tell the type of socket processes are using.
Internal lsof uses inode numbers on socket fs to resolve the type of
sockets. Files under /proc/net/, such as tcp, udp, unix, etc provides
such inode information.
Unfortunately bluetooth related protocols don't provide such inode
information. This patch series introduces /proc/net files for the protocols.
This patch against af_bluetooth.c provides facility to the implementation
of protocols. This patch extends bt_sock_list and introduces two exported
function bt_procfs_init, bt_procfs_cleanup.
The type bt_sock_list is already used in some of implementation of
protocols. bt_procfs_init prepare seq_operations which converts
protocol own bt_sock_list data to protocol own proc entry when the
entry is accessed.
What I, lsof user, need is just inode number of bluetooth
socket. However, people may want more information. The bt_procfs_init
takes a function pointer for customizing the show handler of
seq_operations.
In v4 patch, __acquires and __releases attributes are added to suppress
sparse warning. Suggested by Andrei Emeltchenko.
In v5 patch, linux/proc_fs.h is included to use PDE. Build error is
reported by Fengguang Wu.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2012-07-26 00:26:32 +08:00
|
|
|
#ifdef CONFIG_PROC_FS
|
|
|
|
int (* custom_seq_show)(struct seq_file *, void *);
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2009-10-05 13:58:39 +08:00
|
|
|
int bt_sock_register(int proto, const struct net_proto_family *ops);
|
2013-02-25 02:36:52 +08:00
|
|
|
void bt_sock_unregister(int proto);
|
2005-04-17 06:20:36 +08:00
|
|
|
void bt_sock_link(struct bt_sock_list *l, struct sock *s);
|
|
|
|
void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
|
2015-03-02 15:37:48 +08:00
|
|
|
int bt_sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
|
|
|
|
int flags);
|
|
|
|
int bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
|
|
|
|
size_t len, int flags);
|
2018-06-29 00:43:44 +08:00
|
|
|
__poll_t bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
|
2008-07-15 02:13:50 +08:00
|
|
|
int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
|
2005-04-17 06:20:36 +08:00
|
|
|
int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
|
2013-09-16 18:05:19 +08:00
|
|
|
int bt_sock_wait_ready(struct sock *sk, unsigned long flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2019-01-03 08:11:20 +08:00
|
|
|
void bt_accept_enqueue(struct sock *parent, struct sock *sk, bool bh);
|
2005-04-17 06:20:36 +08:00
|
|
|
void bt_accept_unlink(struct sock *sk);
|
|
|
|
struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock);
|
|
|
|
|
|
|
|
/* Skb helpers */
|
2012-03-24 07:56:56 +08:00
|
|
|
struct l2cap_ctrl {
|
2016-10-06 04:51:42 +08:00
|
|
|
u8 sframe:1,
|
2014-06-08 16:26:57 +08:00
|
|
|
poll:1,
|
|
|
|
final:1,
|
|
|
|
fcs:1,
|
|
|
|
sar:2,
|
|
|
|
super:2;
|
2016-10-06 04:51:42 +08:00
|
|
|
|
|
|
|
u16 reqseq;
|
|
|
|
u16 txseq;
|
|
|
|
u8 retries;
|
2015-03-31 04:21:01 +08:00
|
|
|
__le16 psm;
|
|
|
|
bdaddr_t bdaddr;
|
|
|
|
struct l2cap_chan *chan;
|
2012-03-24 07:56:56 +08:00
|
|
|
};
|
|
|
|
|
2020-06-12 03:50:41 +08:00
|
|
|
struct sco_ctrl {
|
|
|
|
u8 pkt_status;
|
|
|
|
};
|
|
|
|
|
2013-03-06 02:37:44 +08:00
|
|
|
struct hci_dev;
|
|
|
|
|
2015-01-12 05:50:44 +08:00
|
|
|
typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
|
2015-04-02 18:41:08 +08:00
|
|
|
typedef void (*hci_req_complete_skb_t)(struct hci_dev *hdev, u8 status,
|
|
|
|
u16 opcode, struct sk_buff *skb);
|
2013-03-06 02:37:44 +08:00
|
|
|
|
2015-11-05 15:31:40 +08:00
|
|
|
#define HCI_REQ_START BIT(0)
|
|
|
|
#define HCI_REQ_SKB BIT(1)
|
|
|
|
|
2015-10-26 05:45:53 +08:00
|
|
|
struct hci_ctrl {
|
Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2
This make use of hci_cmd_sync_queue for the following MGMT commands:
Add Advertising
Remove Advertising
Add Extended Advertising Parameters
Add Extended Advertising Data
mgmt-tester -s "Add Advertising"
Test Summary
------------
Add Advertising - Failure: LE off Passed
Add Advertising - Invalid Params 1 (AD too long) Passed
Add Advertising - Invalid Params 2 (Malformed len) Passed
Add Advertising - Invalid Params 3 (Malformed len) Passed
Add Advertising - Invalid Params 4 (Malformed len) Passed
Add Advertising - Invalid Params 5 (AD too long) Passed
Add Advertising - Invalid Params 6 (ScRsp too long) Passed
Add Advertising - Invalid Params 7 (Malformed len) Passed
Add Advertising - Invalid Params 8 (Malformed len) Passed
Add Advertising - Invalid Params 9 (Malformed len) Passed
Add Advertising - Invalid Params 10 (ScRsp too long) Passed
Add Advertising - Rejected (Timeout, !Powered) Passed
Add Advertising - Success 1 (Powered, Add Adv Inst) Passed
Add Advertising - Success 2 (!Powered, Add Adv Inst) Passed
Add Advertising - Success 3 (!Powered, Adv Enable) Passed
Add Advertising - Success 4 (Set Adv on override) Passed
Add Advertising - Success 5 (Set Adv off override) Passed
Add Advertising - Success 6 (Scan Rsp Dta, Adv ok) Passed
Add Advertising - Success 7 (Scan Rsp Dta, Scan ok) Passed
Add Advertising - Success 8 (Connectable Flag) Passed
Add Advertising - Success 9 (General Discov Flag) Passed
Add Advertising - Success 10 (Limited Discov Flag) Passed
Add Advertising - Success 11 (Managed Flags) Passed
Add Advertising - Success 12 (TX Power Flag) Passed
Add Advertising - Success 13 (ADV_SCAN_IND) Passed
Add Advertising - Success 14 (ADV_NONCONN_IND) Passed
Add Advertising - Success 15 (ADV_IND) Passed
Add Advertising - Success 16 (Connectable -> on) Passed
Add Advertising - Success 17 (Connectable -> off) Passed
Add Advertising - Success 18 (Power -> off, Remove) Passed
Add Advertising - Success 19 (Power -> off, Keep) Passed
Add Advertising - Success 20 (Add Adv override) Passed
Add Advertising - Success 21 (Timeout expires) Passed
Add Advertising - Success 22 (LE -> off, Remove) Passed
Add Advertising - Success (Empty ScRsp) Passed
Add Advertising - Success (ScRsp only) Passed
Add Advertising - Invalid Params (ScRsp too long) Passed
Add Advertising - Success (ScRsp appear) Passed
Add Advertising - Invalid Params (ScRsp appear long) Passed
Add Advertising - Success (Appear is null) Passed
Add Advertising - Success (Name is null) Passed
Add Advertising - Success (Complete name) Passed
Add Advertising - Success (Shortened name) Passed
Add Advertising - Success (Short name) Passed
Add Advertising - Success (Name + data) Passed
Add Advertising - Invalid Params (Name + data) Passed
Add Advertising - Success (Name+data+appear) Passed
Total: 47, Passed: 47 (100.0%), Failed: 0, Not Run: 0
Overall execution time: 2.17 seconds
mgmt-tester -s "Remove Advertising"
Test Summary
------------
Remove Advertising - Invalid Params 1 Passed
Remove Advertising - Success 1 Passed
Remove Advertising - Success 2 Passed
Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
Overall execution time: 0.0585 seconds
mgmt-tester -s "Ext Adv MGMT Params"
Test Summary:
------------
Ext Adv MGMT Params - Unpowered Passed
Ext Adv MGMT Params - Invalid parameters Passed
Ext Adv MGMT Params - Success Passed
Ext Adv MGMT Params - (5.0) Success Passed
Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0
Overall execution time: 0.0746 seconds
mgmt-tester -s "Ext Adv MGMT -"
Test Summary
------------
Ext Adv MGMT - Data set without Params Passed
Ext Adv MGMT - AD Data (5.0) Invalid parameters Passed
Ext Adv MGMT - AD Data (5.0) Success Passed
Ext Adv MGMT - AD Scan Response (5.0) Success Passed
Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0
Overall execution time: 0.0805 seconds
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2021-10-28 07:58:40 +08:00
|
|
|
struct sock *sk;
|
2016-10-06 04:51:42 +08:00
|
|
|
u16 opcode;
|
2015-11-05 15:31:40 +08:00
|
|
|
u8 req_flags;
|
2015-10-26 05:45:53 +08:00
|
|
|
u8 req_event;
|
2015-11-05 15:31:40 +08:00
|
|
|
union {
|
|
|
|
hci_req_complete_t req_complete;
|
|
|
|
hci_req_complete_skb_t req_complete_skb;
|
|
|
|
};
|
2015-03-31 04:21:02 +08:00
|
|
|
};
|
|
|
|
|
2021-12-04 08:15:40 +08:00
|
|
|
struct mgmt_ctrl {
|
|
|
|
struct hci_dev *hdev;
|
|
|
|
u16 opcode;
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct bt_skb_cb {
|
2016-10-06 04:51:42 +08:00
|
|
|
u8 pkt_type;
|
|
|
|
u8 force_active;
|
|
|
|
u16 expect;
|
|
|
|
u8 incoming:1;
|
2015-03-31 04:21:02 +08:00
|
|
|
union {
|
|
|
|
struct l2cap_ctrl l2cap;
|
2020-06-12 03:50:41 +08:00
|
|
|
struct sco_ctrl sco;
|
2015-10-26 05:45:53 +08:00
|
|
|
struct hci_ctrl hci;
|
2021-12-04 08:15:40 +08:00
|
|
|
struct mgmt_ctrl mgmt;
|
2015-03-31 04:21:02 +08:00
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
2009-08-21 09:25:57 +08:00
|
|
|
#define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-11-05 14:09:59 +08:00
|
|
|
#define hci_skb_pkt_type(skb) bt_cb((skb))->pkt_type
|
|
|
|
#define hci_skb_expect(skb) bt_cb((skb))->expect
|
|
|
|
#define hci_skb_opcode(skb) bt_cb((skb))->hci.opcode
|
2021-12-23 04:21:57 +08:00
|
|
|
#define hci_skb_event(skb) bt_cb((skb))->hci.req_event
|
Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2
This make use of hci_cmd_sync_queue for the following MGMT commands:
Add Advertising
Remove Advertising
Add Extended Advertising Parameters
Add Extended Advertising Data
mgmt-tester -s "Add Advertising"
Test Summary
------------
Add Advertising - Failure: LE off Passed
Add Advertising - Invalid Params 1 (AD too long) Passed
Add Advertising - Invalid Params 2 (Malformed len) Passed
Add Advertising - Invalid Params 3 (Malformed len) Passed
Add Advertising - Invalid Params 4 (Malformed len) Passed
Add Advertising - Invalid Params 5 (AD too long) Passed
Add Advertising - Invalid Params 6 (ScRsp too long) Passed
Add Advertising - Invalid Params 7 (Malformed len) Passed
Add Advertising - Invalid Params 8 (Malformed len) Passed
Add Advertising - Invalid Params 9 (Malformed len) Passed
Add Advertising - Invalid Params 10 (ScRsp too long) Passed
Add Advertising - Rejected (Timeout, !Powered) Passed
Add Advertising - Success 1 (Powered, Add Adv Inst) Passed
Add Advertising - Success 2 (!Powered, Add Adv Inst) Passed
Add Advertising - Success 3 (!Powered, Adv Enable) Passed
Add Advertising - Success 4 (Set Adv on override) Passed
Add Advertising - Success 5 (Set Adv off override) Passed
Add Advertising - Success 6 (Scan Rsp Dta, Adv ok) Passed
Add Advertising - Success 7 (Scan Rsp Dta, Scan ok) Passed
Add Advertising - Success 8 (Connectable Flag) Passed
Add Advertising - Success 9 (General Discov Flag) Passed
Add Advertising - Success 10 (Limited Discov Flag) Passed
Add Advertising - Success 11 (Managed Flags) Passed
Add Advertising - Success 12 (TX Power Flag) Passed
Add Advertising - Success 13 (ADV_SCAN_IND) Passed
Add Advertising - Success 14 (ADV_NONCONN_IND) Passed
Add Advertising - Success 15 (ADV_IND) Passed
Add Advertising - Success 16 (Connectable -> on) Passed
Add Advertising - Success 17 (Connectable -> off) Passed
Add Advertising - Success 18 (Power -> off, Remove) Passed
Add Advertising - Success 19 (Power -> off, Keep) Passed
Add Advertising - Success 20 (Add Adv override) Passed
Add Advertising - Success 21 (Timeout expires) Passed
Add Advertising - Success 22 (LE -> off, Remove) Passed
Add Advertising - Success (Empty ScRsp) Passed
Add Advertising - Success (ScRsp only) Passed
Add Advertising - Invalid Params (ScRsp too long) Passed
Add Advertising - Success (ScRsp appear) Passed
Add Advertising - Invalid Params (ScRsp appear long) Passed
Add Advertising - Success (Appear is null) Passed
Add Advertising - Success (Name is null) Passed
Add Advertising - Success (Complete name) Passed
Add Advertising - Success (Shortened name) Passed
Add Advertising - Success (Short name) Passed
Add Advertising - Success (Name + data) Passed
Add Advertising - Invalid Params (Name + data) Passed
Add Advertising - Success (Name+data+appear) Passed
Total: 47, Passed: 47 (100.0%), Failed: 0, Not Run: 0
Overall execution time: 2.17 seconds
mgmt-tester -s "Remove Advertising"
Test Summary
------------
Remove Advertising - Invalid Params 1 Passed
Remove Advertising - Success 1 Passed
Remove Advertising - Success 2 Passed
Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
Overall execution time: 0.0585 seconds
mgmt-tester -s "Ext Adv MGMT Params"
Test Summary:
------------
Ext Adv MGMT Params - Unpowered Passed
Ext Adv MGMT Params - Invalid parameters Passed
Ext Adv MGMT Params - Success Passed
Ext Adv MGMT Params - (5.0) Success Passed
Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0
Overall execution time: 0.0746 seconds
mgmt-tester -s "Ext Adv MGMT -"
Test Summary
------------
Ext Adv MGMT - Data set without Params Passed
Ext Adv MGMT - AD Data (5.0) Invalid parameters Passed
Ext Adv MGMT - AD Data (5.0) Success Passed
Ext Adv MGMT - AD Scan Response (5.0) Success Passed
Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0
Overall execution time: 0.0805 seconds
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2021-10-28 07:58:40 +08:00
|
|
|
#define hci_skb_sk(skb) bt_cb((skb))->hci.sk
|
2015-11-05 14:09:59 +08:00
|
|
|
|
2005-10-07 14:46:04 +08:00
|
|
|
static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
2012-05-23 15:04:20 +08:00
|
|
|
skb = alloc_skb(len + BT_SKB_RESERVE, how);
|
2015-11-05 15:31:39 +08:00
|
|
|
if (skb)
|
2005-04-17 06:20:36 +08:00
|
|
|
skb_reserve(skb, BT_SKB_RESERVE);
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
|
2011-06-07 17:18:06 +08:00
|
|
|
static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk,
|
|
|
|
unsigned long len, int nb, int *err)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
2012-05-23 15:04:20 +08:00
|
|
|
skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err);
|
2015-11-05 15:31:39 +08:00
|
|
|
if (skb)
|
2005-04-17 06:20:36 +08:00
|
|
|
skb_reserve(skb, BT_SKB_RESERVE);
|
2010-09-22 03:31:11 +08:00
|
|
|
|
|
|
|
if (!skb && *err)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
*err = sock_error(sk);
|
|
|
|
if (*err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (sk->sk_shutdown) {
|
|
|
|
*err = -ECONNRESET;
|
|
|
|
goto out;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
return skb;
|
2010-09-22 03:31:11 +08:00
|
|
|
|
|
|
|
out:
|
|
|
|
kfree_skb(skb);
|
|
|
|
return NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2021-09-04 06:27:29 +08:00
|
|
|
/* Shall not be called with lock_sock held */
|
|
|
|
static inline struct sk_buff *bt_skb_sendmsg(struct sock *sk,
|
|
|
|
struct msghdr *msg,
|
|
|
|
size_t len, size_t mtu,
|
|
|
|
size_t headroom, size_t tailroom)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
size_t size = min_t(size_t, len, mtu);
|
|
|
|
int err;
|
|
|
|
|
|
|
|
skb = bt_skb_send_alloc(sk, size + headroom + tailroom,
|
|
|
|
msg->msg_flags & MSG_DONTWAIT, &err);
|
|
|
|
if (!skb)
|
|
|
|
return ERR_PTR(err);
|
|
|
|
|
|
|
|
skb_reserve(skb, headroom);
|
|
|
|
skb_tailroom_reserve(skb, mtu, tailroom);
|
|
|
|
|
|
|
|
if (!copy_from_iter_full(skb_put(skb, size), size, &msg->msg_iter)) {
|
|
|
|
kfree_skb(skb);
|
|
|
|
return ERR_PTR(-EFAULT);
|
|
|
|
}
|
|
|
|
|
|
|
|
skb->priority = sk->sk_priority;
|
|
|
|
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
|
2021-09-04 06:27:30 +08:00
|
|
|
/* Similar to bt_skb_sendmsg but can split the msg into multiple fragments
|
|
|
|
* accourding to the MTU.
|
|
|
|
*/
|
|
|
|
static inline struct sk_buff *bt_skb_sendmmsg(struct sock *sk,
|
|
|
|
struct msghdr *msg,
|
|
|
|
size_t len, size_t mtu,
|
|
|
|
size_t headroom, size_t tailroom)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb, **frag;
|
|
|
|
|
|
|
|
skb = bt_skb_sendmsg(sk, msg, len, mtu, headroom, tailroom);
|
|
|
|
if (IS_ERR_OR_NULL(skb))
|
|
|
|
return skb;
|
|
|
|
|
|
|
|
len -= skb->len;
|
|
|
|
if (!len)
|
|
|
|
return skb;
|
|
|
|
|
|
|
|
/* Add remaining data over MTU as continuation fragments */
|
|
|
|
frag = &skb_shinfo(skb)->frag_list;
|
|
|
|
while (len) {
|
|
|
|
struct sk_buff *tmp;
|
|
|
|
|
|
|
|
tmp = bt_skb_sendmsg(sk, msg, len, mtu, headroom, tailroom);
|
2021-09-17 04:10:48 +08:00
|
|
|
if (IS_ERR(tmp)) {
|
2022-02-15 09:59:38 +08:00
|
|
|
return skb;
|
2021-09-04 06:27:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
len -= tmp->len;
|
|
|
|
|
|
|
|
*frag = tmp;
|
|
|
|
frag = &(*frag)->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
|
2016-10-06 04:51:42 +08:00
|
|
|
int bt_to_errno(u16 code);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-03-15 10:27:53 +08:00
|
|
|
void hci_sock_set_flag(struct sock *sk, int nr);
|
|
|
|
void hci_sock_clear_flag(struct sock *sk, int nr);
|
2015-03-15 10:28:00 +08:00
|
|
|
int hci_sock_test_flag(struct sock *sk, int nr);
|
2015-03-17 19:48:46 +08:00
|
|
|
unsigned short hci_sock_get_channel(struct sock *sk);
|
2016-08-28 02:23:38 +08:00
|
|
|
u32 hci_sock_get_cookie(struct sock *sk);
|
2015-03-15 10:27:53 +08:00
|
|
|
|
2013-09-24 02:37:36 +08:00
|
|
|
int hci_sock_init(void);
|
|
|
|
void hci_sock_cleanup(void);
|
2005-10-29 01:20:48 +08:00
|
|
|
|
2013-09-24 02:37:36 +08:00
|
|
|
int bt_sysfs_init(void);
|
|
|
|
void bt_sysfs_cleanup(void);
|
2005-10-29 01:20:48 +08:00
|
|
|
|
2013-09-24 02:37:36 +08:00
|
|
|
int bt_procfs_init(struct net *net, const char *name,
|
|
|
|
struct bt_sock_list *sk_list,
|
|
|
|
int (*seq_show)(struct seq_file *, void *));
|
|
|
|
void bt_procfs_cleanup(struct net *net, const char *name);
|
Bluetooth: /proc/net/ entries for bluetooth protocols
lsof command can tell the type of socket processes are using.
Internal lsof uses inode numbers on socket fs to resolve the type of
sockets. Files under /proc/net/, such as tcp, udp, unix, etc provides
such inode information.
Unfortunately bluetooth related protocols don't provide such inode
information. This patch series introduces /proc/net files for the protocols.
This patch against af_bluetooth.c provides facility to the implementation
of protocols. This patch extends bt_sock_list and introduces two exported
function bt_procfs_init, bt_procfs_cleanup.
The type bt_sock_list is already used in some of implementation of
protocols. bt_procfs_init prepare seq_operations which converts
protocol own bt_sock_list data to protocol own proc entry when the
entry is accessed.
What I, lsof user, need is just inode number of bluetooth
socket. However, people may want more information. The bt_procfs_init
takes a function pointer for customizing the show handler of
seq_operations.
In v4 patch, __acquires and __releases attributes are added to suppress
sparse warning. Suggested by Andrei Emeltchenko.
In v5 patch, linux/proc_fs.h is included to use PDE. Build error is
reported by Fengguang Wu.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
2012-07-26 00:26:32 +08:00
|
|
|
|
2010-03-21 12:27:45 +08:00
|
|
|
extern struct dentry *bt_debugfs;
|
2005-11-09 01:57:38 +08:00
|
|
|
|
2011-02-08 06:08:52 +08:00
|
|
|
int l2cap_init(void);
|
|
|
|
void l2cap_exit(void);
|
|
|
|
|
2015-06-09 17:47:23 +08:00
|
|
|
#if IS_ENABLED(CONFIG_BT_BREDR)
|
2011-02-08 06:08:52 +08:00
|
|
|
int sco_init(void);
|
|
|
|
void sco_exit(void);
|
2015-06-09 17:47:23 +08:00
|
|
|
#else
|
|
|
|
static inline int sco_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void sco_exit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
2011-02-08 06:08:52 +08:00
|
|
|
|
2015-03-07 03:08:51 +08:00
|
|
|
int mgmt_init(void);
|
|
|
|
void mgmt_exit(void);
|
|
|
|
|
2012-01-22 06:28:34 +08:00
|
|
|
void bt_sock_reclassify_lock(struct sock *sk, int proto);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* __BLUETOOTH_H */
|