Mistake on this page?
Report an issue in GitHub or email us
whd_utils.h
1 /*
2  * Copyright 2020 Cypress Semiconductor Corporation
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /**
19  * @file WHD utilities
20  *
21  * Utilities to help do specialized (not general purpose) WHD specific things
22  */
23 #include "whd_chip.h"
24 #include "whd_events_int.h"
25 #include "whd_types_int.h"
26 
27 #ifndef INCLUDED_WHD_UTILS_H_
28 #define INCLUDED_WHD_UTILS_H_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /** Searches for a specific WiFi Information Element in a byte array
35  *
36  * Traverse a string of 1-byte tag/1-byte length/variable-length value
37  * triples, returning a pointer to the substring whose first element
38  * matches tag
39  *
40  * @note : This function has been copied directly from the standard Broadcom host driver file wl/exe/wlu.c
41  *
42  *
43  * @param tlv_buf : The byte array containing the Information Elements (IEs)
44  * @param buflen : The length of the tlv_buf byte array
45  * @param key : The Information Element tag to search for
46  *
47  * @return NULL : if no matching Information Element was found
48  * Non-Null : Pointer to the start of the matching Information Element
49  */
50 
51 whd_tlv8_header_t *whd_parse_tlvs(const whd_tlv8_header_t *tlv_buf, uint32_t buflen, dot11_ie_id_t key);
52 
53 /** Checks if a WiFi Information Element is a WPA entry
54  *
55  * Is this body of this tlvs entry a WPA entry? If
56  * not update the tlvs buffer pointer/length
57  *
58  * @note : This function has been copied directly from the standard Broadcom host driver file wl/exe/wlu.c
59  *
60  * @param wpaie : The byte array containing the Information Element (IE)
61  * @param tlvs : The larger IE array to be updated if not a WPA IE
62  * @param tlvs_len : The current length of larger IE array
63  *
64  * @return WHD_TRUE : if IE matches the WPA OUI (Organizationally Unique Identifier) and its type = 1
65  * WHD_FALSE : otherwise
66  */
67 whd_bool_t whd_is_wpa_ie(vendor_specific_ie_header_t *wpaie, whd_tlv8_header_t **tlvs, uint32_t *tlvs_len);
68 
69 /** Searches for a specific WiFi Information Element in a byte array
70  *
71  * Traverse a string of 1-byte tag/1-byte length/variable-length value
72  * triples, returning a pointer to the substring whose first element
73  * matches tag
74  *
75  * @note : This function has been copied directly from the standard Broadcom host driver file wl/exe/wlu.c
76  *
77  *
78  * @param tlv_buf : The byte array containing the Information Elements (IEs)
79  * @param buflen : The length of the tlv_buf byte array
80  * @param key : The Information Element tag to search for
81  *
82  * @return NULL : if no matching Information Element was found
83  * Non-Null : Pointer to the start of the matching Information Element
84  */
85 whd_tlv8_header_t *whd_parse_dot11_tlvs(const whd_tlv8_header_t *tlv_buf, uint32_t buflen, dot11_ie_id_t key);
86 
87 /******************************************************
88 * Debug helper functionality
89 ******************************************************/
90 #ifdef WPRINT_ENABLE_WHD_DEBUG
91 const char *whd_event_to_string(whd_event_num_t var);
92 char *whd_ssid_to_string(uint8_t *value, uint8_t length, char *ssid_buf, uint8_t ssid_buf_len);
93 const char *whd_status_to_string(whd_event_status_t status);
94 const char *whd_reason_to_string(whd_event_reason_t reason);
95 char *whd_ether_ntoa(const uint8_t *ea, char *buf, uint8_t buf_len);
96 #endif /* ifdef WPRINT_ENABLE_WHD_DEBUG */
97 
98 /**
99  ******************************************************************************
100  * Prints partial details of a scan result on a single line
101  * @param[in] record : A pointer to the whd_scan_result_t record
102  *
103  */
104 extern void whd_print_scan_result(whd_scan_result_t *record);
105 
106 /**
107  ******************************************************************************
108  * Convert a security bitmap to string
109  * @param[in] security : security of type whd_security_t
110  * @param[in] out_str : a character array to store output
111  * @param[in] out_str_len : length of out_str char array
112  *
113  */
114 extern void whd_convert_security_type_to_string(whd_security_t security, char *out_str, uint16_t out_str_len);
115 
116 /*!
117  ******************************************************************************
118  * Convert an IOCTL to a string.
119  *
120  * @param[in] cmd The ioct_log value.
121  * @param[out] ioctl_str The string value after conversion.
122  * @param[out] ioctl_str_len The string length of the IOCTL string.
123  *
124  * @result
125  */
126 void whd_ioctl_to_string(uint32_t cmd, char *ioctl_str, uint16_t ioctl_str_len);
127 
128 /*!
129  ******************************************************************************
130  * Convert event, status and reason value coming from firmware to string.
131  *
132  * @param[in] cmd The event value in numeric form.
133  * @param[in] flag The status value in numeric form.
134  * @param[in] reason The reson value in numeric form.
135  * @param[out] ioctl_str The string representation of event, status and reason.
136  * @param[out] ioctl_str_len The str_len of ioctl_str.
137  *
138  * @result
139  */
140 void whd_event_info_to_string(uint32_t cmd, uint16_t flag, uint32_t reason, char *ioctl_str, uint16_t ioctl_str_len);
141 
142 /*!
143  ******************************************************************************
144  * Prints Hexdump and ASCII dump for data passed as argument.
145  *
146  * @param[in] data The data which has to be converted into hex and ascii format.
147  * @param[in] data_len The length of data.
148  *
149  * @result
150  */
151 void whd_hexdump(uint8_t *data, uint32_t data_len);
152 
153 extern wl_chanspec_t whd_channel_to_wl_band(whd_driver_t whd_driver, uint32_t channel);
154 
155 /*!
156  ******************************************************************************
157  * Convert an ipv4 string to a uint32_t.
158  *
159  * @param[in] ip4addr : IP address in string format
160  * @param[in] len : length of the ip address string
161  * @param[out] dest : IP address format in uint32
162  *
163  * @return
164  */
165 bool whd_str_to_ip(const char *ip4addr, size_t len, void *dest);
166 
167 /*!
168  ******************************************************************************
169  * Print binary IPv4 address to a string.
170  * String must contain enough room for full address, 16 bytes exact.
171  * @param[in] ip4addr : IPv4 address
172  * @param[out] p : ipv4 address in string format
173  *
174  * @return
175  */
176 uint8_t whd_ip4_to_string(const void *ip4addr, char *p);
177 
178 #ifdef __cplusplus
179 } /* extern "C" */
180 #endif
181 #endif
182 
Structure for storing scan results.
Definition: whd_types.h:690
whd_security_t
Enumeration of Wi-Fi security modes.
Definition: whd_types.h:182
uint16_t wl_chanspec_t
Channel specified in uint16_t.
Definition: whd_types.h:720
whd_bool_t
Boolean values.
Definition: whd_types.h:162
Defines common constants used with WHD within src folder.
Header for Event detection.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.