xref: /openbmc/linux/net/bluetooth/mgmt_util.h (revision 236bdb88)
1 /*
2    BlueZ - Bluetooth protocol stack for Linux
3    Copyright (C) 2015  Intel Coropration
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License version 2 as
7    published by the Free Software Foundation;
8 
9    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
12    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
13    CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
14    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 
18    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
19    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
20    SOFTWARE IS DISCLAIMED.
21 */
22 
23 struct mgmt_mesh_tx {
24 	struct list_head list;
25 	int index;
26 	size_t param_len;
27 	struct sock *sk;
28 	u8 handle;
29 	u8 instance;
30 	u8 param[sizeof(struct mgmt_cp_mesh_send) + 31];
31 };
32 
33 struct mgmt_pending_cmd {
34 	struct list_head list;
35 	u16 opcode;
36 	int index;
37 	void *param;
38 	size_t param_len;
39 	struct sock *sk;
40 	struct sk_buff *skb;
41 	void *user_data;
42 	int (*cmd_complete)(struct mgmt_pending_cmd *cmd, u8 status);
43 };
44 
45 struct sk_buff *mgmt_alloc_skb(struct hci_dev *hdev, u16 opcode,
46 			       unsigned int size);
47 int mgmt_send_event_skb(unsigned short channel, struct sk_buff *skb, int flag,
48 			struct sock *skip_sk);
49 int mgmt_send_event(u16 event, struct hci_dev *hdev, unsigned short channel,
50 		    void *data, u16 data_len, int flag, struct sock *skip_sk);
51 int mgmt_cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status);
52 int mgmt_cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status,
53 		      void *rp, size_t rp_len);
54 
55 struct mgmt_pending_cmd *mgmt_pending_find(unsigned short channel, u16 opcode,
56 					   struct hci_dev *hdev);
57 struct mgmt_pending_cmd *mgmt_pending_find_data(unsigned short channel,
58 						u16 opcode,
59 						struct hci_dev *hdev,
60 						const void *data);
61 void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev,
62 			  void (*cb)(struct mgmt_pending_cmd *cmd, void *data),
63 			  void *data);
64 struct mgmt_pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode,
65 					  struct hci_dev *hdev,
66 					  void *data, u16 len);
67 struct mgmt_pending_cmd *mgmt_pending_new(struct sock *sk, u16 opcode,
68 					  struct hci_dev *hdev,
69 					  void *data, u16 len);
70 void mgmt_pending_free(struct mgmt_pending_cmd *cmd);
71 void mgmt_pending_remove(struct mgmt_pending_cmd *cmd);
72 void mgmt_mesh_foreach(struct hci_dev *hdev,
73 		       void (*cb)(struct mgmt_mesh_tx *mesh_tx, void *data),
74 		       void *data, struct sock *sk);
75 struct mgmt_mesh_tx *mgmt_mesh_find(struct hci_dev *hdev, u8 handle);
76 struct mgmt_mesh_tx *mgmt_mesh_next(struct hci_dev *hdev, struct sock *sk);
77 struct mgmt_mesh_tx *mgmt_mesh_add(struct sock *sk, struct hci_dev *hdev,
78 				   void *data, u16 len);
79 void mgmt_mesh_remove(struct mgmt_mesh_tx *mesh_tx);
80