xref: /freebsd/contrib/wpa/src/common/ocv.h (revision c1d255d3ffdbe447de3ab875bf4e7d7accc5bfc5)
1 /*
2  * Operating Channel Validation (OCV)
3  * Copyright (c) 2018, Mathy Vanhoef
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef OCV_H
10 #define OCV_H
11 
12 struct wpa_channel_info;
13 
14 struct oci_info {
15 	/* Values in the OCI element */
16 	u8 op_class;
17 	u8 channel;
18 	u8 seg1_idx;
19 
20 	/* Derived values for easier verification */
21 	int freq;
22 	int sec_channel;
23 	int chanwidth;
24 };
25 
26 #define OCV_OCI_LEN		3
27 #define OCV_OCI_EXTENDED_LEN	(3 + OCV_OCI_LEN)
28 #define OCV_OCI_KDE_LEN		(2 + RSN_SELECTOR_LEN + OCV_OCI_LEN)
29 
30 enum oci_verify_result {
31 	OCI_SUCCESS, OCI_NOT_FOUND, OCI_INVALID_LENGTH, OCI_PARSE_ERROR,
32 	OCI_PRIMARY_FREQ_MISMATCH, OCI_CHANNEL_WIDTH_MISMATCH,
33 	OCI_SECONDARY_FREQ_MISMATCH, OCI_SEG_1_INDEX_MISMATCH
34 };
35 
36 extern char ocv_errorstr[256];
37 
38 int ocv_derive_all_parameters(struct oci_info *oci);
39 int ocv_insert_oci(struct wpa_channel_info *ci, u8 **argpos);
40 int ocv_insert_oci_kde(struct wpa_channel_info *ci, u8 **argpos);
41 int ocv_insert_extended_oci(struct wpa_channel_info *ci, u8 *pos);
42 enum oci_verify_result
43 ocv_verify_tx_params(const u8 *oci_ie, size_t oci_ie_len,
44 		     struct wpa_channel_info *ci, int tx_chanwidth,
45 		     int tx_seg1_idx);
46 
47 #endif /* OCV_H */
48