• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 TAG "nStackXCongestion"
24 
25 #define WIFI_BITRATE_ACCURACY 1000
26 #define WIFI_SIGNAL_MINIMUM (-100)
27 #define WIFI_QDISC_LENGTH 1000
28 
29 #define WIFI_STA_INFO_FAKE_RX_RATE 216
30 #define WIFI_STA_INFO_FAKE_TX_RATE 432
31 #define WIFI_STA_INFO_FAKE_SIGNAL (-22)
32 
CongModuleInit(void)33 int32_t CongModuleInit(void)
34 {
35     return NSTACKX_EOK;
36 }
37 
CongModuleClean(void)38 void CongModuleClean(void)
39 {
40 }
41 
GetWifiInfo(const char * devName,WifiStationInfo * info)42 int32_t GetWifiInfo(const char *devName, WifiStationInfo *info)
43 {
44     (void)devName;
45     info->rxRate = WIFI_STA_INFO_FAKE_RX_RATE;
46     info->txRate = WIFI_STA_INFO_FAKE_TX_RATE;
47     info->signal = WIFI_STA_INFO_FAKE_SIGNAL;
48     return NSTACKX_EOK;
49 }
50 
CongestionInitGetWifiHook(GetWifiInfoHook getWifiInfoHook)51 int32_t CongestionInitGetWifiHook(GetWifiInfoHook getWifiInfoHook)
52 {
53     return NSTACKX_EOK;
54 }
55 
GetQdiscLen(const char * devName,int32_t protocol,uint32_t * len)56 int32_t GetQdiscLen(const char *devName, int32_t protocol, uint32_t *len)
57 {
58     (void)devName;
59     (void)protocol;
60     if (len != NULL) {
61         *len = WIFI_QDISC_LENGTH;
62     } else {
63         return NSTACKX_EFAILED;
64     }
65     return NSTACKX_EOK;
66 }
67