Bluetooth: Add BT_PHY socket option
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v4 1/1 Bluetooth: Add BT_PHY socket option
From: Luiz Augusto von Dentz <[email protected]>
This adds BT_PHY socket option (read-only) which can be used to read the PHYs in use by the underline connection.
Signed-off-by Luiz Augusto von Dentz <[email protected]>
--- include/net/bluetooth/bluetooth.h | 17 +++++ include/net/bluetooth/hci_core.h | 2 + net/bluetooth/hci_conn.c | 107 ++++++++++++++++++++++++++++++ net/bluetooth/l2cap_sock.c | 13 ++++ net/bluetooth/sco.c | 13 ++++ 5 files changed, 152 insertions(+)
include/net/bluetooth/bluetooth.h +17 -0
@@ -121,6 +121,23 @@ struct bt_voice {#define BT_SNDMTU 12#define BT_RCVMTU 13 +#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 __printf(1, 2)void bt_info (const char *fmt, ...);
include/net/bluetooth/hci_core.h +2 -0
@@ -1477,6 +1477,8 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode);struct sk_buff *hci_cmd_sync (struct hci_dev *hdev,u16 opcode,u32 plen,const void *param,u32 timeout); +u32 hci_conn_get_phy (struct hci_conn *conn); +/* ----- HCI Sockets ----- */ void hci_send_to_sock (struct hci_dev *hdev,struct sk_buff *skb); void hci_send_to_channel(unsigned short channel, struct sk_buff *skb,
net/bluetooth/hci_conn.c +107 -0
110 lines not on this page · raw message
net/bluetooth/l2cap_sock.c +13 -0
@@ -499,6 +499,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,struct l2cap_chan *chan =l2cap_pi (sk)->chan;struct bt_security sec;struct bt_power pwr; +u32 phys;int len, err =0 ;BT_DBG ("sk %p" , sk);
@@ -603,6 +604,18 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, err = -EFAULT ;break ; +case BT_PHY : +if (sk->sk_state ==BT_CONNECTED ) { + err = -ENOTCONN ; +break ; + } + + phys =hci_conn_get_phy (chan->conn->hcon); + +if (put_user (phys, (u32 __user *) optval)) + err = -EFAULT ; +break ; +default : err = -ENOPROTOOPT ;break ;
net/bluetooth/sco.c +13 -0
@@ -922,6 +922,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname,struct sock *sk = sock->sk;int len, err =0 ;struct bt_voice voice; +u32 phys;BT_DBG ("sk %p" , sk);
@@ -956,6 +957,18 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname,break ; +case BT_PHY : +if (sk->sk_state ==BT_CONNECTED ) { + err = -ENOTCONN ; +break ; + } + + phys =hci_conn_get_phy (sco_pi (sk)->conn->hcon); + +if (put_user (phys, (u32 __user *) optval)) + err = -EFAULT ; +break ; +default : err = -ENOPROTOOPT ;break ;
Signature · 1 line
2.21.1
Marcel Holtmann
maintainerHi Luiz,
Quoted 11 lines
This adds
BT_PHYsocket option (read-only) which can be used to read the PHYs in use by the underline connection.Signed-off-by Luiz Augusto von Dentz <[email protected]>---
include/net/bluetooth/bluetooth.h | 17 +++++ include/net/bluetooth/hci_core.h | 2 + net/bluetooth/hci_conn.c | 107 ++++++++++++++++++++++++++++++ net/bluetooth/l2cap_sock.c | 13 ++++ net/bluetooth/sco.c | 13 ++++ 5 files changed, 152 insertions(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel