1 /*
2  * Copyright (C) 2021 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 #include "nstackx_congestion.h"
17 
18 #include "nstackx_error.h"
19 #include "nstackx_log.h"
20 #include "nstackx_util.h"
21 #include "securec.h"
22 
23 #define WIFI_QDISC_LENGTH 1000
24 
25 #define WIFI_STA_INFO_FAKE_RX_RATE 216
26 #define WIFI_STA_INFO_FAKE_TX_RATE 432
27 #define WIFI_STA_INFO_FAKE_SIGNAL (-22)
28 
CongModuleInit(void)29 int32_t CongModuleInit(void)
30 {
31     return NSTACKX_EOK;
32 }
33 
CongModuleClean(void)34 void CongModuleClean(void)
35 {
36 }
37 
GetWifiInfo(const char * devName,WifiStationInfo * info)38 int32_t GetWifiInfo(const char *devName, WifiStationInfo *info)
39 {
40     (void)devName;
41     info->rxRate = WIFI_STA_INFO_FAKE_RX_RATE;
42     info->txRate = WIFI_STA_INFO_FAKE_TX_RATE;
43     info->signal = WIFI_STA_INFO_FAKE_SIGNAL;
44     return NSTACKX_EOK;
45 }
46 
CongestionInitGetWifiHook(GetWifiInfoHook getWifiInfoHook)47 int32_t CongestionInitGetWifiHook(GetWifiInfoHook getWifiInfoHook)
48 {
49     return NSTACKX_EOK;
50 }
51 
GetQdiscLen(const char * devName,int32_t protocol,uint32_t * len)52 int32_t GetQdiscLen(const char *devName, int32_t protocol, uint32_t *len)
53 {
54     (void)devName;
55     (void)protocol;
56     if (len != NULL) {
57         *len = WIFI_QDISC_LENGTH;
58     } else {
59         return NSTACKX_EFAILED;
60     }
61     return NSTACKX_EOK;
62 }
63