• 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 #ifndef HDC_DEFINE_H
16 #define HDC_DEFINE_H
17 #include "define_plus.h"
18 
19 namespace Hdc {
20 // ############################## config #######################################
21 #ifndef USE_CONFIG_UV_THREADS
22 constexpr size_t SIZE_THREAD_POOL = 16;
23 #endif
24 constexpr size_t SIZE_THREAD_POOL_MIN = 16;
25 constexpr size_t SIZE_THREAD_POOL_MAX = 256;
26 constexpr uint8_t GLOBAL_TIMEOUT = 30;
27 constexpr uint16_t DEFAULT_PORT = 8710;
28 constexpr uint16_t MAX_LOG_FILE_COUNT = 30;
29 constexpr bool ENABLE_IO_CHECKSUM = false;
30 const string IPV4_MAPPING_PREFIX = "::ffff:";
31 const string DEFAULT_SERVER_ADDR_IP = "::ffff:127.0.0.1";
32 const string DEFAULT_SERVER_ADDR = "::ffff:127.0.0.1:8710";
33 const string ENV_SERVER_PORT = "OHOS_HDC_SERVER_PORT";
34 const string ENV_SERVER_LOG = "OHOS_HDC_LOG_LEVEL";
35 
36 // ################################ macro define ###################################
37 constexpr uint8_t MINOR_TIMEOUT = 5;
38 constexpr uint8_t MILL_SECONDS = 10;
39 constexpr uint8_t WAIT_SECONDS = 30;
40 constexpr uint8_t DWORD_SERIALIZE_SIZE = 4;
41 constexpr uint8_t OFFSET = 2;
42 constexpr uint8_t CMD_ARG1_COUNT = 2;
43 constexpr uint8_t COUNT = 10;
44 constexpr uint8_t STREAM_MAIN = 0;  // work at main thread
45 constexpr uint8_t STREAM_WORK = 1;  // work at work thread
46 constexpr uint8_t STREAM_SIZE = 2;
47 constexpr uint16_t TIME_BUF_SIZE = 32;
48 constexpr uint16_t BUF_SIZE_MICRO = 16;
49 constexpr uint16_t BUF_SIZE_TINY = 64;
50 constexpr uint16_t BUF_SIZE_SMALL = 256;
51 constexpr uint16_t BUF_SIZE_MEDIUM = 512;
52 constexpr uint16_t BUF_SIZE_DEFAULT = 1024;
53 constexpr uint16_t BUF_SIZE_DEFAULT2 = BUF_SIZE_DEFAULT * 2;
54 constexpr uint16_t BUF_SIZE_DEFAULT4 = BUF_SIZE_DEFAULT * 4;
55 constexpr uint16_t MAX_IP_PORT = 65535;
56 constexpr uint16_t MAX_CONNECTKEY_SIZE = 32;  // usb sn/tcp ipport
57 constexpr uint16_t TIME_BASE = 1000;          // time unit conversion base value
58 constexpr uint16_t UV_DEFAULT_INTERVAL = 250;  // ms
59 constexpr uint16_t VER_PROTOCOL = 0x01;
60 constexpr uint16_t MAX_PACKET_SIZE_HISPEED = 512;
61 constexpr uint16_t DEVICE_CHECK_INTERVAL = 3000;  // ms
62 constexpr uint16_t MAX_SIZE_IOBUF = 61440;
63 constexpr uint16_t MAX_USBFFS_BULK = 62464;
64 constexpr double DECODE_SCALE = 0.75;
65 constexpr uint16_t LAST_EQUAL_NUM = 2;
66 constexpr uint16_t UV_START_TIMEOUT = 10;
67 constexpr uint16_t UV_START_REPEAT = 10;
68 constexpr uint16_t UV_LISTEN_LBACKOG = 4;
69 constexpr uint16_t BUF_EXTEND_SIZE = 4;
70 constexpr uint16_t BUF_MULTIPLE = 2;
71 constexpr uint16_t EXPECTED_LEN = 9;
72 constexpr uint16_t MAX_APP_PARAM_SIZE = 512;
73 constexpr uint16_t MIN_APP_PARAM_SIZE = 4;
74 constexpr uint16_t FORWORD_PORT_RM_BUF_SIZE = 9;
75 constexpr uint16_t FORWORD_PORT_OTHER_BUF_SIZE = 6;
76 constexpr uint16_t CMD_REMOTE_SIZE = 8;
77 constexpr uint16_t PORT_MAX_LEN = 5;
78 constexpr uint16_t START_SERVER_FOR_CLIENT_TIME = 300;
79 constexpr uint16_t CMD_FILE_PENULT_PARAM = 2;
80 
81 // double-word(hex)=[0]major[1][2]minor[3][4]version[5]fix(a-p)[6][7]reserve
82 // |----------------------------------------------------------------|
83 // | 31-28 | 27-24 | 23-20 | 19-16 | 15-12 | 11-08 |     07-00      |
84 // |----------------------------------------------------------------|
85 // | major |reserve| minor |reserve|version|  fix  |   reserve      |
86 // |----------------------------------------------------------------|
87 // 0x30000100 is 3.0.0b
88 constexpr uint32_t HDC_VERSION_NUMBER = 0x30000100;
89 constexpr uint32_t HDC_BUF_MAX_BYTES = INT_MAX;
90 #ifdef HDC_HOST
91 constexpr uint32_t HOST_SOCKETPAIR_SIZE = 1024 * 1024;
92 #endif
93 constexpr uint32_t HDC_SOCKETPAIR_SIZE = MAX_SIZE_IOBUF * 2;
94 // "\f" asicc is 12
95 const string HDC_HOST_DAEMON_BUF_SEPARATOR = "\f";
96 constexpr int32_t RSA_KEY_BITS = 3072;
97 
98 const string WHITE_SPACES = " \t\n\r";
99 const string UT_TMP_PATH = "/tmp/hdc-ut";
100 const string LOG_FILE_NAME = "hdc.log";
101 const string LOG_FILE_NAME_PREFIX = "hdc-";
102 const string LOG_CACHE_NAME = ".hdc.cache.log";
103 constexpr uint64_t LOG_FILE_MAX_SIZE = 104857600;
104 const string SERVER_NAME = "HDCServer";
105 const string STRING_EMPTY = "";
106 const string HANDSHAKE_MESSAGE = "OHOS HDC";  // sep not char '-', not more than 11 bytes
107 const string HANDSHAKE_FAILED = "HS FAILED";
108 const string PACKET_FLAG = "HW";              // must 2bytes
109 const string EMPTY_ECHO = "[Empty]";
110 const string MESSAGE_INFO = "[Info]";
111 const string MESSAGE_FAIL = "[Fail]";
112 const string MESSAGE_SUCCESS = "[Success]";
113 // input command
114 const string CMDSTR_SOFTWARE_VERSION = "version";
115 const string CMDSTR_SOFTWARE_HELP = "help";
116 const string CMDSTR_TARGET_DISCOVER = "discover";
117 const string CMDSTR_SERVICE_START = "start";
118 const string CMDSTR_SERVICE_KILL = "kill";
119 const string CMDSTR_GENERATE_KEY = "keygen";
120 const string CMDSTR_KILL_SERVER = "kserver";
121 const string CMDSTR_KILL_DAEMON = "kdaemon";
122 const string CMDSTR_LIST_TARGETS = "list targets";
123 const string CMDSTR_CHECK_SERVER = "checkserver";
124 const string CMDSTR_CHECK_DEVICE = "checkdevice";
125 const string CMDSTR_WAIT_FOR = "wait";
126 const string CMDSTR_CONNECT_TARGET = "tconn";
127 const string CMDSTR_CONNECT_ANY = "any";
128 const string CMDSTR_SHELL = "shell";
129 const string CMDSTR_TARGET_REBOOT = "target boot";
130 const string CMDSTR_TARGET_MOUNT = "target mount";
131 const string CMDSTR_STARTUP_MODE = "smode";
132 const string CMDSTR_TARGET_MODE = "tmode";
133 const string CMDSTR_BUGREPORT = "bugreport";
134 const string CMDSTR_HILOG = "hilog";
135 const string CMDSTR_TMODE_USB = "usb";
136 #ifdef _WIN32
137 const string HILOG_NAME = "hilog.exe";
138 const string SPLIT = "\\";
139 #endif
140 #ifdef HDC_SUPPORT_UART
141 const string CMDSTR_TMODE_UART = "uart";
142 const string UART_HDC_NODE = "/dev/ttyS4";
143 const string CONSOLE_ACTIVE_NODE = "/sys/class/tty/console/active";
144 constexpr int UART_IO_WAIT_TIME_100 = 100;
145 constexpr int UART_IO_WAIT_TIME = 1000;
146 constexpr uint16_t MAX_UART_SIZE_IOBUF = 4096; // MAX_SIZE_IOBUF;
147 #endif
148 const string CMDSTR_TMODE_TCP = "tcp";
149 #ifdef HDC_EMULATOR
150 const string CMDSTR_TMODE_BRIDGE = "bridge";
151 #endif
152 const string CMDSTR_FILE_SEND = "file send";
153 const string CMDSTR_FILE_RECV = "file recv";
154 const string CMDSTR_REMOTE_PARAMETER = "remote";
155 const string CMDSTR_FORWARD_FPORT = "fport";
156 const string CMDSTR_FORWARD_RPORT = "rport";
157 const string CMDSTR_APP_INSTALL = "install";
158 const string CMDSTR_APP_UNINSTALL = "uninstall";
159 const string CMDSTR_APP_SIDELOAD = "sideload";
160 const string CMDSTR_LIST_JDWP = "jpid";
161 const string CMDSTR_TRACK_JDWP = "track-jpid";
162 const string CMDSTR_INNER_ENABLE_KEEPALIVE = "alive";
163 const string CMDSTR_FLASHD_UPDATE = "update";
164 const string CMDSTR_FLASHD_FLASH = "flash";
165 const string CMDSTR_FLASHD_ERASE = "erase";
166 const string CMDSTR_FLASHD_FORMAT = "format";
167 }  // namespace Hdc
168 #endif  // HDC_DEFINE_H
169