1 /*
2  * Copyright (C) 2021-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 DATA_FLOW_STATISTICS_H
17 #define DATA_FLOW_STATISTICS_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace NetManagerStandard {
23 class DataFlowStatistics {
24 public:
25     DataFlowStatistics() = default;
26     ~DataFlowStatistics() = default;
27 
28     /**
29      * Obtains the bytes received over the cellular network.
30      *
31      * @return The number of received bytes.
32      */
33     int64_t GetCellularRxBytes();
34 
35     /**
36      * Obtains the bytes sent over the cellular network.
37      *
38      * @return The number of sent bytes.
39      */
40     int64_t GetCellularTxBytes();
41 
42     /**
43      * Obtains the bytes received through all NICs.
44      *
45      * @return The number of received bytes.
46      */
47     int64_t GetAllRxBytes();
48 
49     /**
50      * Obtains the bytes sent through all NICs.
51      *
52      * @return The number of sent bytes.
53      */
54     int64_t GetAllTxBytes();
55 
56     /**
57      * Obtains the bytes received through a specified UID.
58      *
59      * @param uid
60      * @return The number of received bytes.
61      */
62     int64_t GetUidRxBytes(uint32_t uid);
63 
64     /**
65      * Obtains the bytes sent through a specified UID.
66      *
67      * @param uid
68      * @return The number of sent bytes.
69      */
70     int64_t GetUidTxBytes(uint32_t uid);
71 
72     /**
73      * Obtains the bytes received through a specified NIC.
74      *
75      * @param iface The name of the interface.
76      * @return The number of received bytes.
77      */
78     int64_t GetIfaceRxBytes(const std::string &interfaceName);
79 
80     /**
81      * Obtains the bytes sent through a specified NIC.
82      *
83      * @param iface The name of the interface.
84      * @return The number of sent bytes.
85      */
86     int64_t GetIfaceTxBytes(const std::string &interfaceName);
87 
88     /**
89      * Obtains the packets received through a specified NIC.
90      *
91      * @param iface The name of the interface.
92      * @return The number of received packets.
93      */
94     int64_t GetIfaceRxPackets(const std::string &interfaceName);
95 
96     /**
97      * Obtains the packets sent through a specified NIC.
98      *
99      * @param iface The name of the interface.
100      * @return The number of sent packets.
101      */
102     int64_t GetIfaceTxPackets(const std::string &interfaceName);
103 };
104 } // namespace NetManagerStandard
105 } // namespace OHOS
106 #endif // DATA_FLOW_STATISTICS_H
107