• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
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 NETWORK_PROFILER_COMMON_H
17 #define NETWORK_PROFILER_COMMON_H
18 
19 #include <string.h>
20 #include <fstream>
21 #include <vector>
22 
23 namespace OHOS::Developtools::Profiler {
24 static constexpr uint8_t MAX_TNAME_LEN = 16;
25 static constexpr int32_t ALIGNAS_LEN = 8;
26 
27 void SplitParamValue(const std::string& str, const std::string &sep, std::vector<std::string>& ret);
28 std::string GetProcessNameByPid(int32_t pid);
29 
30 struct NetworkConfig {
31     int32_t shmSize = 0;
32     int32_t flushCount = 0;
33     int32_t clock = 0;
34     bool block = 0;
35 };
36 
37 enum class NetworkEventType : int32_t {
38     INVALID = -1,
39     TRAFFIC,
40     HTTP,
41 };
42 
43 struct alignas(ALIGNAS_LEN) NetworkEvent { //8 is 8 bit
44     int32_t type = static_cast<int32_t>(NetworkEventType::INVALID);
45     int32_t tid = 0;
46     struct timespec ts;
47     char threadName[MAX_TNAME_LEN] = {0};
48 };
49 }
50 
51 #endif // NETWORK_PROFILER_COMMON_H