Skip to contentSkip to conversation

Bluetooth: Add flags field and setting function for HCI sockets

PATCH In review Marcel Holtmann 2 participants 2 messages Mar 15, 2015

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH v3 1/14 Bluetooth: Add flags field and setting function for HCI sockets

To filter out certain actions for certain HCI sockets introcuce a flags field that allows to configure specific settings on individual sockets.

Since the hci_pinfo structure is private in hci_sock.c, provide helper functions for setting and clearing a given flag.

---
 include/net/bluetooth/bluetooth.h |  3 +++
 net/bluetooth/hci_sock.c          | 11 +++++++++++
 2 files changed, 14 insertions(+)
include/net/bluetooth/bluetooth.h +3 -0
index e598ca096ec9..ae1f2ee1eaf3 100644
@@ -335,6 +335,9 @@ out:
 
 int bt_to_errno(__u16 code);
 
+void hci_sock_set_flag(struct sock *sk, int nr);
+void hci_sock_clear_flag(struct sock *sk, int nr);
+
 int hci_sock_init(void);
 void hci_sock_cleanup(void);
 
net/bluetooth/hci_sock.c +11 -0
index b614543b4fe3..bf5365c49c9c 100644
@@ -47,8 +47,19 @@ struct hci_pinfo {
 	struct hci_filter filter;
 	__u32             cmsg_mask;
 	unsigned short    channel;
+	unsigned long     flags;
 };
 
+void hci_sock_set_flag(struct sock *sk, int nr)
+{
+	set_bit(nr, &hci_pi(sk)->flags);
+}
+
+void hci_sock_clear_flag(struct sock *sk, int nr)
+{
+	clear_bit(nr, &hci_pi(sk)->flags);
+}
+
 static inline int hci_test_bit(int nr, const void *addr)
 {
 	return *((const __u32 *) addr + (nr >> 5)) & ((__u32) 1 << (nr & 31));
Signature · 1 line
2.1.0
#1 lore raw

Hi Marcel,

Quoted 11 lines · Marcel Holtmann

To filter out certain actions for certain HCI sockets introcuce a flags field that allows to configure specific settings on individual sockets.

Since the hci_pinfo structure is private in hci_sock.c, provide helper functions for setting and clearing a given flag.

---
 include/net/bluetooth/bluetooth.h |  3 +++
 net/bluetooth/hci_sock.c          | 11 +++++++++++
 2 files changed, 14 insertions(+)

All patches in this set have been applied to bluetooth-next. Thanks.

Johan