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 COMMUNICATIONNETMANAGERBASE_STATISTICS_EXEC_H 17 #define COMMUNICATIONNETMANAGERBASE_STATISTICS_EXEC_H 18 19 #include <cstdint> 20 #include <string> 21 22 #include <napi/native_api.h> 23 24 #include "get_cellular_rxbytes_context.h" 25 #include "get_iface_rxbytes_context.h" 26 #include "get_iface_stats_context.h" 27 #include "get_iface_uid_stats_context.h" 28 #include "get_traffic_stats_by_network_context.h" 29 #include "get_traffic_stats_by_uid_network_context.h" 30 #include "get_uid_rxbytes_context.h" 31 #include "update_iface_stats_context.h" 32 #include "get_sockfd_rxbytes_context.h" 33 34 namespace OHOS { 35 namespace NetManagerStandard { 36 class StatisticsExec final { 37 public: 38 StatisticsExec() = delete; 39 ~StatisticsExec() = delete; 40 41 static bool ExecGetCellularRxBytes(GetCellularRxBytesContext *context); 42 static bool ExecGetCellularTxBytes(GetCellularTxBytesContext *context); 43 static bool ExecGetAllRxBytes(GetAllRxBytesContext *context); 44 static bool ExecGetAllTxBytes(GetAllTxBytesContext *context); 45 static bool ExecGetUidRxBytes(GetUidRxBytesContext *context); 46 static bool ExecGetUidTxBytes(GetUidTxBytesContext *context); 47 static bool ExecGetIfaceRxBytes(GetIfaceRxBytesContext *context); 48 static bool ExecGetIfaceTxBytes(GetIfaceTxBytesContext *context); 49 static bool ExecGetIfaceStats(GetIfaceStatsContext *context); 50 static bool ExecGetIfaceUidStats(GetIfaceUidStatsContext *context); 51 static bool ExecUpdateIfacesStats(UpdateIfacesStatsContext *context); 52 static bool ExecUpdateStatsData(UpdateStatsDataContext *context); 53 static bool ExecGetSockfdRxBytes(GetSockfdRxBytesContext *context); 54 static bool ExecGetSockfdTxBytes(GetSockfdTxBytesContext *context); 55 static bool ExecGetTrafficStatsByNetwork(GetTrafficStatsByNetworkContext *context); 56 static bool ExecGetTrafficStatsByUidNetwork(GetTrafficStatsByUidNetworkContext *context); 57 58 static napi_value GetCellularRxBytesCallback(GetCellularRxBytesContext *context); 59 static napi_value GetCellularTxBytesCallback(GetCellularTxBytesContext *context); 60 static napi_value GetAllRxBytesCallback(GetAllRxBytesContext *context); 61 static napi_value GetAllTxBytesCallback(GetAllTxBytesContext *context); 62 static napi_value GetUidRxBytesCallback(GetUidRxBytesContext *context); 63 static napi_value GetUidTxBytesCallback(GetUidTxBytesContext *context); 64 static napi_value GetIfaceRxBytesCallback(GetIfaceRxBytesContext *context); 65 static napi_value GetIfaceTxBytesCallback(GetIfaceTxBytesContext *context); 66 static napi_value GetIfaceStatsCallback(GetIfaceStatsContext *context); 67 static napi_value GetIfaceUidStatsCallback(GetIfaceUidStatsContext *context); 68 static napi_value UpdateIfacesStatsCallback(UpdateIfacesStatsContext *context); 69 static napi_value UpdateStatsDataCallback(UpdateStatsDataContext *context); 70 static napi_value GetSockfdRxBytesCallback(GetSockfdRxBytesContext *context); 71 static napi_value GetSockfdTxBytesCallback(GetSockfdTxBytesContext *context); 72 static napi_value GetGetTrafficStatsByNetworkCallback(GetTrafficStatsByNetworkContext *context); 73 static napi_value GetGetTrafficStatsByUidNetworkCallback(GetTrafficStatsByUidNetworkContext *context); 74 75 static napi_value CreateCodeMessage(napi_env env, const std::string &msg, int32_t code); 76 }; 77 } // namespace NetManagerStandard 78 } // namespace OHOS 79 #endif // COMMUNICATIONNETMANAGERBASE_STATISTICS_EXEC_H 80