1 /* 2 * Copyright (C) 2024 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 OHOS_IP_QOS_MONITOR_H 17 #define OHOS_IP_QOS_MONITOR_H 18 19 #include <mutex> 20 #include "self_cure_service.h" 21 #include "wifi_netlink.h" 22 #include "wifi_net_observer.h" 23 24 namespace OHOS { 25 namespace Wifi { 26 class IpQosMonitor { 27 public: 28 static IpQosMonitor &GetInstance(); 29 void StartMonitor(int32_t arg = 0); 30 void QueryPackets(int32_t arg = 0); 31 void HandleTcpReportMsgComplete(const std::vector<int64_t> &elems, int32_t cmd); 32 void ParseTcpReportMsg(const std::vector<int64_t> &elems, int32_t cmd); 33 void HandleTcpPktsResp(const std::vector<int64_t> &elems); 34 bool ParseNetworkInternetGood(const std::vector<int64_t> &elems); 35 int64_t GetCurrentTcpTxCounter(); 36 int64_t GetCurrentTcpRxCounter(); 37 void ResetTxRxProperty(); 38 bool GetTxRxStatus(); 39 private: 40 bool AllowSelfCureNetwork(int32_t currentRssi); 41 int32_t mInstId = 0; 42 bool mInternetSelfCureAllowed = true; 43 bool mHttpDetectedAllowed = true; 44 int64_t mLastTcpTxCounter = 0; 45 int64_t mLastTcpRxCounter = 0; 46 int32_t mInternetFailedCounter = 0; 47 sptr<NetStateObserver> mNetWorkDetect; 48 bool lastTxRxGood_ = false; 49 std::mutex txRxStatusMtx_; 50 }; 51 52 } // namespace Wifi 53 } // namespace OHOS 54 #endif // OHOS_IP_QOS_MONITOR_H