14bc52338SCy Schubert /* 24bc52338SCy Schubert * Operating Channel Validation (OCV) 34bc52338SCy Schubert * Copyright (c) 2018, Mathy Vanhoef 44bc52338SCy Schubert * 54bc52338SCy Schubert * This software may be distributed under the terms of the BSD license. 64bc52338SCy Schubert * See README for more details. 74bc52338SCy Schubert */ 84bc52338SCy Schubert 94bc52338SCy Schubert #ifndef OCV_H 104bc52338SCy Schubert #define OCV_H 114bc52338SCy Schubert 124bc52338SCy Schubert struct wpa_channel_info; 134bc52338SCy Schubert 144bc52338SCy Schubert struct oci_info { 154bc52338SCy Schubert /* Values in the OCI element */ 164bc52338SCy Schubert u8 op_class; 174bc52338SCy Schubert u8 channel; 184bc52338SCy Schubert u8 seg1_idx; 194bc52338SCy Schubert 204bc52338SCy Schubert /* Derived values for easier verification */ 214bc52338SCy Schubert int freq; 224bc52338SCy Schubert int sec_channel; 234bc52338SCy Schubert int chanwidth; 244bc52338SCy Schubert }; 254bc52338SCy Schubert 264bc52338SCy Schubert #define OCV_OCI_LEN 3 274bc52338SCy Schubert #define OCV_OCI_EXTENDED_LEN (3 + OCV_OCI_LEN) 284bc52338SCy Schubert #define OCV_OCI_KDE_LEN (2 + RSN_SELECTOR_LEN + OCV_OCI_LEN) 294bc52338SCy Schubert 30*c1d255d3SCy Schubert enum oci_verify_result { 31*c1d255d3SCy Schubert OCI_SUCCESS, OCI_NOT_FOUND, OCI_INVALID_LENGTH, OCI_PARSE_ERROR, 32*c1d255d3SCy Schubert OCI_PRIMARY_FREQ_MISMATCH, OCI_CHANNEL_WIDTH_MISMATCH, 33*c1d255d3SCy Schubert OCI_SECONDARY_FREQ_MISMATCH, OCI_SEG_1_INDEX_MISMATCH 34*c1d255d3SCy Schubert }; 35*c1d255d3SCy Schubert 364bc52338SCy Schubert extern char ocv_errorstr[256]; 374bc52338SCy Schubert 384bc52338SCy Schubert int ocv_derive_all_parameters(struct oci_info *oci); 394bc52338SCy Schubert int ocv_insert_oci(struct wpa_channel_info *ci, u8 **argpos); 404bc52338SCy Schubert int ocv_insert_oci_kde(struct wpa_channel_info *ci, u8 **argpos); 414bc52338SCy Schubert int ocv_insert_extended_oci(struct wpa_channel_info *ci, u8 *pos); 42*c1d255d3SCy Schubert enum oci_verify_result 43*c1d255d3SCy Schubert ocv_verify_tx_params(const u8 *oci_ie, size_t oci_ie_len, 444bc52338SCy Schubert struct wpa_channel_info *ci, int tx_chanwidth, 454bc52338SCy Schubert int tx_seg1_idx); 464bc52338SCy Schubert 474bc52338SCy Schubert #endif /* OCV_H */ 48