1 /* Copyright (c) 2014, The Linux Foundation. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions
5  * are met:
6  *  * Redistributions of source code must retain the above copyright
7  *    notice, this list of conditions and the following disclaimer.
8  *  * Redistributions in binary form must reproduce the above copyright
9  *    notice, this list of conditions and the following disclaimer in
10  *    the documentation and/or other materials provided with the
11  *    distribution.
12  *  * Neither the name of The Linux Foundation nor the names of its
13  *    contributors may be used to endorse or promote products derived
14  *    from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __WIFI_HAL_LLSTATSCOMMAND_H__
30 #define __WIFI_HAL_LLSTATSCOMMAND_H__
31 
32 #include <stdint.h>
33 #include <fcntl.h>
34 #include <sys/socket.h>
35 #include <netlink/genl/genl.h>
36 #include <netlink/genl/family.h>
37 #include <netlink/genl/ctrl.h>
38 #include <linux/rtnetlink.h>
39 #include <netpacket/packet.h>
40 #include <linux/filter.h>
41 #include <linux/errqueue.h>
42 
43 #include <linux/pkt_sched.h>
44 #include <netlink/object-api.h>
45 #include <netlink/netlink.h>
46 #include <netlink/socket.h>
47 #include <net/if.h>
48 
49 #include "nl80211_copy.h"
50 #include "common.h"
51 #include "cpp_bindings.h"
52 #include "tdls.h"
53 
54 #ifdef __GNUC__
55 #define PRINTF_FORMAT(a,b) __attribute__ ((format (printf, (a), (b))))
56 #define STRUCT_PACKED __attribute__ ((packed))
57 #else
58 #define PRINTF_FORMAT(a,b)
59 #define STRUCT_PACKED
60 #endif
61 
62 #ifdef __cplusplus
63 extern "C"
64 {
65 #endif /* __cplusplus */
66 
67 #define IS_GLOBAL_TDLS_SUPPORTED        BIT(0)
68 #define IS_PER_MAC_TDLS_SUPPORTED       BIT(1)
69 #define IS_OFF_CHANNEL_TDLS_SUPPORTED   BIT(2)
70 
71 typedef struct {
72     int maxConcurrentTdlsSessionNum;
73     u32 tdlsSupportedFeatures;
74 } wifiTdlsCapabilities;
75 
76 class TdlsCommand: public WifiVendorCommand
77 {
78 private:
79     static TdlsCommand *mTdlsCommandInstance;
80     wifi_tdls_status mTDLSgetStatusRspParams;
81     wifi_request_id mRequestId;
82     wifi_tdls_handler mHandler;
83     wifiTdlsCapabilities mTDLSgetCaps;
84 
85     TdlsCommand(wifi_handle handle, int id, u32 vendor_id, u32 subcmd);
86 
87 public:
88     static TdlsCommand* instance(wifi_handle handle);
89     virtual ~TdlsCommand();
90 
91     virtual void setSubCmd(u32 subcmd);
92 
93     virtual wifi_error requestResponse();
94 
95     virtual int handleEvent(WifiEvent &event);
96 
97     virtual int handleResponse(WifiEvent &reply);
98 
99     virtual wifi_error setCallbackHandler(wifi_tdls_handler nHandler, u32 event);
100 
101     virtual void unregisterHandler(u32 subCmd);
102 
103     virtual void getStatusRspParams(wifi_tdls_status *status);
104 
105     virtual void getCapsRspParams(wifi_tdls_capabilities *caps);
106 };
107 
108 #ifdef __cplusplus
109 }
110 #endif /* __cplusplus */
111 #endif
112