1 /*
2  * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
3 
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above
10  *       copyright notice, this list of conditions and the following
11  *       disclaimer in the documentation and/or other materials provided
12  *       with the distribution.
13  *     * Neither the name of The Linux Foundation nor the names of its
14  *       contributors may be used to endorse or promote products derived
15  *       from this software without specific prior written permission.
16 
17  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef __NAN_CERT_H__
31 #define __NAN_CERT_H__
32 
33 
34 #ifdef __cplusplus
35 extern "C"
36 {
37 #endif /* __cplusplus */
38 
39 #define NAN_CERT_VERSION                        2
40 #define NAN_MAX_DEBUG_MESSAGE_DATA_LEN          100
41 
42 typedef struct {
43     /* NAN master rank being advertised by DE */
44     u64 master_rank;
45     /* NAN master preference being advertised by DE */
46     u8 master_pref;
47     /* random value being advertised by DE */
48     u8 random_factor;
49     /* hop_count from anchor master */
50     u8 hop_count;
51     u32 beacon_transmit_time;
52     /* NDP channel Frequency */
53     u32 ndp_channel_freq;
54 } NanStaParameter;
55 
56 /* NAN Data Path Supported Band */
57 typedef enum {
58     NAN_DATA_PATH_SUPPORTED_BAND_2G = 1,
59     NAN_DATA_PATH_SUPPORTED_BAND_5G = 2,
60     NAN_DATA_PATH_SUPPORT_DUAL_BAND = 3
61 } NdpSupportedBand;
62 
63 /* NAN Responder mode policy */
64 typedef enum {
65     NAN_DATA_RESPONDER_MODE_AUTO    = 0,
66     NAN_DATA_RESPONDER_MODE_ACCEPT  = 1,
67     NAN_DATA_RESPONDER_MODE_REJECT  = 2,
68     NAN_DATA_RESPONDER_MODE_COUNTER = 3,
69     NAN_DATA_RESPONDER_MODE_COUNTER_NO_CHANNEL_CHANGE = 4
70 } NanDataResponderMode;
71 
72 /* NAN Data Path M4 response type */
73 typedef enum {
74     NAN_DATA_PATH_M4_RESPONSE_ACCEPT = 1,
75     NAN_DATA_PATH_M4_RESPONSE_REJECT = 2,
76     NAN_DATA_PATH_M4_RESPONSE_BADMIC = 3
77 } NdpM4ResponseType;
78 
79 /* NAN NMF Security Clear type */
80 typedef enum {
81     NAN_NMF_CLEAR_DISABLE = 0,
82     NAN_NMF_CLEAR_ENABLE = 1
83 } NanNmfClearConfig;
84 
85 /* NAN Schedule type */
86 typedef enum {
87     NAN_SCHED_VALID = 0,
88     NAN_SCHED_INVALID_BAD_FA = 1,
89     NAN_SCHED_INVALID_BAD_NDC = 2,
90     NAN_SCHED_INVALID_BAD_IMMU = 3
91 } NanSchedType;
92 
93  /*
94   * Definitions of debug subcommand type for the
95   * generic debug command.
96   */
97 typedef enum {
98     NAN_TEST_MODE_CMD_NAN_AVAILABILITY = 1,
99     NAN_TEST_MODE_CMD_NDP_INCLUDE_IMMUTABLE = 2,
100     NAN_TEST_MODE_CMD_NDP_AVOID_CHANNEL = 3,
101     NAN_TEST_MODE_CMD_NAN_SUPPORTED_BANDS = 4,
102     NAN_TEST_MODE_CMD_AUTO_RESPONDER_MODE = 5,
103     NAN_TEST_MODE_CMD_M4_RESPONSE_TYPE = 6,
104     NAN_TEST_MODE_CMD_NAN_SCHED_TYPE = 7,
105     NAN_TEST_MODE_CMD_NAN_NMF_CLEAR_CONFIG = 8,
106     NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_ULW_NOTIFY = 9,
107     NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NEGOTIATE = 10,
108     NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NOTIFY = 11,
109     NAN_TEST_MODE_CMD_NAN_AVAILABILITY_MAP_ORDER = 12
110 } NanDebugModeCmd;
111 
112 /*
113  * This debug command carries any one command type
114  * followed by corresponding command data content
115  * as indicated below.
116  *
117  * command: NAN_TEST_MODE_CMD_NAN_AVAILABILITY
118  * content: NAN Avaiability attribute blob
119  *
120  * command: NAN_TEST_MODE_CMD_NDP_INCLUDE_IMMUTABLE
121  * content: u32 value (0 - Ignore 1 - Include immuatable,
122  *                     2 - Don't include immutable)
123  *
124  * command: NAN_TEST_MODE_CMD_NDP_AVOID_CHANNEL
125  * content: u32 channel_frequency; (0 - Ignore)
126  *
127  * command: NAN_TEST_MODE_CMD_NAN_SUPPORTED_BANDS
128  * content: u32 supported_bands; (0 . Ignore, 1 . 2g,
129  *                                2 . 5g, 3 . 2g & 5g)
130  *
131  * command: NAN_TEST_MODE_CMD_AUTO_RESPONDER_MODE
132  * content: u32 auto_resp_mode; (0 . Auto, 1 . Accept,
133  *                               2 . Reject, 3 . Counter)
134  *
135  * command: NAN_TEST_MODE_CMD_M4_RESPONSE_TYPE
136  * content: u32 m4_response_type; (0.Ignore, 1.Accept,
137  *                                 2.Reject, 3.BadMic)
138  *
139  * command: NAN_TEST_MODE_CMD_NAN_SCHED_TYPE
140  * content: u32 invalid_nan_schedule; (0. Valid sched,
141  *                                     1.Invalid Sched bad FA,
142  *                                     2.Invalid schedbad NDC,
143  *                                     3.Invalid sched bad Immutable)
144  *
145  * command: NAN_TEST_MODE_CMD_NAN_NMF_CLEAR_CONFIG
146  * content: u32 nmf_security_config_val;(0:NAN_NMF_CLEAR_DISABLE,
147  *                                       1:NAN_NMF_CLEAR_ENABLE)
148  *
149  * command: NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_ULW_NOTIFY
150  * content: u32 channel_availability;(0/1)
151  *
152  * command: NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NEGOTIATE
153  * content: responder_nmi_mac (Responder NMI Mac Address)
154  *
155  * command: NAN_TEST_MODE_CMD_NAN_SCHED_UPDATE_NDL_NOTIFY
156  * content: NONE
157  *
158  * command: NAN_TEST_MODE_CMD_NAN_AVAILABILITY_MAP_ORDER
159  * content: u32 map_order_val; (0/1)
160  *
161  */
162 typedef struct PACKED {
163     /*
164      * To indicate the debug command type.
165      */
166     u32 cmd;
167     /*
168      * To hold the data for the above command
169      * type.
170      */
171     u8 debug_cmd_data[NAN_MAX_DEBUG_MESSAGE_DATA_LEN];
172 } NanDebugParams;
173 
174 /*
175    Function to get the sta_parameter expected by Sigma
176    as per CAPI spec.
177 */
178 wifi_error nan_get_sta_parameter(transaction_id id,
179                                  wifi_interface_handle iface,
180                                  NanStaParameter* msg);
181 
182 wifi_error nan_debug_command_config(transaction_id id,
183                                    wifi_interface_handle iface,
184                                    NanDebugParams msg,
185                                    int debug_msg_length);
186 #ifdef __cplusplus
187 }
188 #endif /* __cplusplus */
189 #endif /* __NAN_CERT_H__ */
190 
191