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