blob: 7fa4522c12c2f247248b0e00e3d090e0c6214170 [file] [log] [blame]
Hai Shalom74f70d42019-02-11 14:42:39 -08001/*
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
12struct wpa_channel_info;
13
14struct 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
Hai Shalom899fcc72020-10-19 14:38:18 -070030enum 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
Hai Shalom74f70d42019-02-11 14:42:39 -080036extern char ocv_errorstr[256];
37
38int ocv_derive_all_parameters(struct oci_info *oci);
39int ocv_insert_oci(struct wpa_channel_info *ci, u8 **argpos);
40int ocv_insert_oci_kde(struct wpa_channel_info *ci, u8 **argpos);
41int ocv_insert_extended_oci(struct wpa_channel_info *ci, u8 *pos);
Hai Shalom899fcc72020-10-19 14:38:18 -070042enum oci_verify_result
43ocv_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);
Hai Shalom74f70d42019-02-11 14:42:39 -080046
47#endif /* OCV_H */