1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef WLANTYPES_H
17#define WLANTYPES_H
18
19#include <stdbool.h>
20#include <stdint.h>
21
22#ifndef HDI_BUFF_MAX_SIZE
23#define HDI_BUFF_MAX_SIZE (1024 * 200)
24#endif
25
26#ifndef HDI_CHECK_VALUE_RETURN
27#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \
28    if ((lv) compare (rv)) { \
29        return ret; \
30    } \
31} while (false)
32#endif
33
34#ifndef HDI_CHECK_VALUE_RET_GOTO
35#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \
36    if ((lv) compare (rv)) { \
37        ret = value; \
38        goto table; \
39    } \
40} while (false)
41#endif
42
43#ifdef __cplusplus
44extern "C" {
45#endif /* __cplusplus */
46
47struct HdfSBuf;
48
49struct HdfFeatureInfo {
50    char* ifName;
51    int32_t type;
52};
53
54struct HdfStaInfo {
55    uint8_t* mac;
56    uint32_t macLen;
57};
58
59struct HdfWifiDriverScanSsid {
60    char* ssid;
61    int32_t ssidLen;
62};
63
64struct HdfWifiScan {
65    struct HdfWifiDriverScanSsid* ssids;
66    uint32_t ssidsLen;
67    int32_t* freqs;
68    uint32_t freqsLen;
69    uint8_t* extraIes;
70    uint32_t extraIesLen;
71    uint8_t* bssid;
72    uint32_t bssidLen;
73    uint8_t prefixSsidScanFlag;
74    uint8_t fastConnectFlag;
75};
76
77struct HdfNetDeviceInfo {
78    uint32_t index;
79    char* ifName;
80    uint32_t ifNameLen;
81    uint8_t iftype;
82    uint8_t* mac;
83    uint32_t macLen;
84};
85
86struct HdfNetDeviceInfoResult {
87    struct HdfNetDeviceInfo* deviceInfos;
88    uint32_t deviceInfosLen;
89};
90
91struct HdfWifiScanResult {
92    uint32_t flags;
93    uint8_t* bssid;
94    uint32_t bssidLen;
95    uint16_t caps;
96    uint32_t freq;
97    uint16_t beaconInt;
98    int32_t qual;
99    int32_t level;
100    uint32_t age;
101    uint8_t* variable;
102    uint32_t variableLen;
103    uint8_t* ie;
104    uint32_t ieLen;
105    uint8_t* beaconIe;
106    uint32_t beaconIeLen;
107};
108
109struct HdfWifiInfo {
110    int32_t band;
111    uint32_t size;
112} __attribute__ ((aligned(8)));
113
114struct MeasChannelParam {
115    int32_t channelId;
116    int32_t measTime;
117} __attribute__ ((aligned(8)));
118
119struct MeasChannelResult {
120    int32_t channelId;
121    int32_t chload;
122    int32_t noise;
123} __attribute__ ((aligned(8)));
124
125struct ProjectionScreenCmdParam {
126    int32_t cmdId;
127    int8_t* buf;
128    uint32_t bufLen;
129};
130
131struct WifiStationInfo {
132    uint32_t rxRate;
133    uint32_t txRate;
134    uint32_t flags;
135    uint8_t rxVhtmcs;
136    uint8_t txVhtmcs;
137    uint8_t rxMcs;
138    uint8_t txMcs;
139    uint8_t rxVhtNss;
140    uint8_t txVhtNss;
141} __attribute__ ((aligned(8)));
142
143struct AdjustChannelInfo {
144    int32_t msgId;
145    uint8_t chanNumber;
146    uint8_t bandwidth;
147    uint8_t switchType;
148    uint8_t statusCode;
149} __attribute__ ((aligned(8)));
150
151bool HdfFeatureInfoBlockMarshalling(struct HdfSBuf *data, const struct HdfFeatureInfo *dataBlock);
152
153bool HdfFeatureInfoBlockUnmarshalling(struct HdfSBuf *data, struct HdfFeatureInfo *dataBlock);
154
155void HdfFeatureInfoFree(struct HdfFeatureInfo *dataBlock, bool freeSelf);
156
157bool HdfStaInfoBlockMarshalling(struct HdfSBuf *data, const struct HdfStaInfo *dataBlock);
158
159bool HdfStaInfoBlockUnmarshalling(struct HdfSBuf *data, struct HdfStaInfo *dataBlock);
160
161void HdfStaInfoFree(struct HdfStaInfo *dataBlock, bool freeSelf);
162
163bool HdfWifiDriverScanSsidBlockMarshalling(struct HdfSBuf *data, const struct HdfWifiDriverScanSsid *dataBlock);
164
165bool HdfWifiDriverScanSsidBlockUnmarshalling(struct HdfSBuf *data, struct HdfWifiDriverScanSsid *dataBlock);
166
167void HdfWifiDriverScanSsidFree(struct HdfWifiDriverScanSsid *dataBlock, bool freeSelf);
168
169bool HdfWifiScanBlockMarshalling(struct HdfSBuf *data, const struct HdfWifiScan *dataBlock);
170
171bool HdfWifiScanBlockUnmarshalling(struct HdfSBuf *data, struct HdfWifiScan *dataBlock);
172
173void HdfWifiScanFree(struct HdfWifiScan *dataBlock, bool freeSelf);
174
175bool HdfNetDeviceInfoBlockMarshalling(struct HdfSBuf *data, const struct HdfNetDeviceInfo *dataBlock);
176
177bool HdfNetDeviceInfoBlockUnmarshalling(struct HdfSBuf *data, struct HdfNetDeviceInfo *dataBlock);
178
179void HdfNetDeviceInfoFree(struct HdfNetDeviceInfo *dataBlock, bool freeSelf);
180
181bool HdfNetDeviceInfoResultBlockMarshalling(struct HdfSBuf *data, const struct HdfNetDeviceInfoResult *dataBlock);
182
183bool HdfNetDeviceInfoResultBlockUnmarshalling(struct HdfSBuf *data, struct HdfNetDeviceInfoResult *dataBlock);
184
185void HdfNetDeviceInfoResultFree(struct HdfNetDeviceInfoResult *dataBlock, bool freeSelf);
186
187bool HdfWifiScanResultBlockMarshalling(struct HdfSBuf *data, const struct HdfWifiScanResult *dataBlock);
188
189bool HdfWifiScanResultBlockUnmarshalling(struct HdfSBuf *data, struct HdfWifiScanResult *dataBlock);
190
191void HdfWifiScanResultFree(struct HdfWifiScanResult *dataBlock, bool freeSelf);
192
193bool HdfWifiInfoBlockMarshalling(struct HdfSBuf *data, const struct HdfWifiInfo *dataBlock);
194
195bool HdfWifiInfoBlockUnmarshalling(struct HdfSBuf *data, struct HdfWifiInfo *dataBlock);
196
197void HdfWifiInfoFree(struct HdfWifiInfo *dataBlock, bool freeSelf);
198
199bool MeasChannelParamBlockMarshalling(struct HdfSBuf *data, const struct MeasChannelParam *dataBlock);
200
201bool MeasChannelParamBlockUnmarshalling(struct HdfSBuf *data, struct MeasChannelParam *dataBlock);
202
203void MeasChannelParamFree(struct MeasChannelParam *dataBlock, bool freeSelf);
204
205bool MeasChannelResultBlockMarshalling(struct HdfSBuf *data, const struct MeasChannelResult *dataBlock);
206
207bool MeasChannelResultBlockUnmarshalling(struct HdfSBuf *data, struct MeasChannelResult *dataBlock);
208
209void MeasChannelResultFree(struct MeasChannelResult *dataBlock, bool freeSelf);
210
211bool ProjectionScreenCmdParamBlockMarshalling(struct HdfSBuf *data, const struct ProjectionScreenCmdParam *dataBlock);
212
213bool ProjectionScreenCmdParamBlockUnmarshalling(struct HdfSBuf *data, struct ProjectionScreenCmdParam *dataBlock);
214
215void ProjectionScreenCmdParamFree(struct ProjectionScreenCmdParam *dataBlock, bool freeSelf);
216
217bool WifiStationInfoBlockMarshalling(struct HdfSBuf *data, const struct WifiStationInfo *dataBlock);
218
219bool WifiStationInfoBlockUnmarshalling(struct HdfSBuf *data, struct WifiStationInfo *dataBlock);
220
221void WifiStationInfoFree(struct WifiStationInfo *dataBlock, bool freeSelf);
222
223bool AdjustChannelInfoBlockMarshalling(struct HdfSBuf *data, const struct AdjustChannelInfo *dataBlock);
224
225bool AdjustChannelInfoBlockUnmarshalling(struct HdfSBuf *data, struct AdjustChannelInfo *dataBlock);
226
227void AdjustChannelInfoFree(struct AdjustChannelInfo *dataBlock, bool freeSelf);
228
229#ifdef __cplusplus
230}
231#endif /* __cplusplus */
232
233#endif // WLANTYPES_H