diff options
-rw-r--r-- | include/net/bluetooth/mgmt.h | 6 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 36 |
2 files changed, 42 insertions, 0 deletions
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 95974daa725e..d353d64bfffb 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -27,6 +27,12 @@ struct mgmt_hdr { | |||
27 | } __packed; | 27 | } __packed; |
28 | #define MGMT_HDR_SIZE 4 | 28 | #define MGMT_HDR_SIZE 4 |
29 | 29 | ||
30 | #define MGMT_OP_READ_VERSION 0x0001 | ||
31 | struct mgmt_rp_read_version { | ||
32 | __u8 version; | ||
33 | __le16 revision; | ||
34 | } __packed; | ||
35 | |||
30 | #define MGMT_EV_CMD_COMPLETE 0x0001 | 36 | #define MGMT_EV_CMD_COMPLETE 0x0001 |
31 | struct mgmt_ev_cmd_complete { | 37 | struct mgmt_ev_cmd_complete { |
32 | __le16 opcode; | 38 | __le16 opcode; |
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 | |||
35 | static 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 | |||
32 | static int cmd_status(struct sock *sk, u16 cmd, u8 status) | 65 | static 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); |