aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2010-12-13 14:07:04 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2010-12-22 19:57:37 -0500
commit02d981292ad3149e8e5f37cffbccedab1a8576d8 (patch)
treec28722fc51a0650c541ce10c8c188c5876881b73 /net
parente41d8b4e131a41f2a3b74aaa783b16aa46376d8e (diff)
Bluetooth: Add read_version management command
This patch implements the initial read_version command that userspace will use before any other management interface operations. Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/mgmt.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 7ea5489e7977..3e24c0bf18e7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -29,6 +29,39 @@
29#include <net/bluetooth/hci_core.h> 29#include <net/bluetooth/hci_core.h>
30#include <net/bluetooth/mgmt.h> 30#include <net/bluetooth/mgmt.h>
31 31
32#define MGMT_VERSION 0
33#define MGMT_REVISION 1
34
35static int read_version(struct sock *sk)
36{
37 struct sk_buff *skb;
38 struct mgmt_hdr *hdr;
39 struct mgmt_ev_cmd_complete *ev;
40 struct mgmt_rp_read_version *rp;
41
42 BT_DBG("sock %p", sk);
43
44 skb = alloc_skb(sizeof(*hdr) + sizeof(*ev) + sizeof(*rp), GFP_ATOMIC);
45 if (!skb)
46 return -ENOMEM;
47
48 hdr = (void *) skb_put(skb, sizeof(*hdr));
49 hdr->opcode = cpu_to_le16(MGMT_EV_CMD_COMPLETE);
50 hdr->len = cpu_to_le16(sizeof(*ev) + sizeof(*rp));
51
52 ev = (void *) skb_put(skb, sizeof(*ev));
53 put_unaligned_le16(MGMT_OP_READ_VERSION, &ev->opcode);
54
55 rp = (void *) skb_put(skb, sizeof(*rp));
56 rp->version = MGMT_VERSION;
57 put_unaligned_le16(MGMT_REVISION, &rp->revision);
58
59 if (sock_queue_rcv_skb(sk, skb) < 0)
60 kfree_skb(skb);
61
62 return 0;
63}
64
32static int cmd_status(struct sock *sk, u16 cmd, u8 status) 65static int cmd_status(struct sock *sk, u16 cmd, u8 status)
33{ 66{
34 struct sk_buff *skb; 67 struct sk_buff *skb;
@@ -87,6 +120,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
87 } 120 }
88 121
89 switch (opcode) { 122 switch (opcode) {
123 case MGMT_OP_READ_VERSION:
124 err = read_version(sk);
125 break;
90 default: 126 default:
91 BT_DBG("Unknown op %u", opcode); 127 BT_DBG("Unknown op %u", opcode);
92 err = cmd_status(sk, opcode, 0x01); 128 err = cmd_status(sk, opcode, 0x01);