• 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 constexpr uint8_t SIZE_THREAD_POOL = 16;
22 constexpr uint8_t GLOBAL_TIMEOUT = 30;
23 constexpr uint16_t DEFAULT_PORT = 8710;
24 constexpr bool ENABLE_IO_CHECKSUM = false;
25 const string IPV4_MAPPING_PREFIX = "::ffff:";
26 const string DEFAULT_SERVER_ADDR_IP = "::ffff:127.0.0.1";
27 const string DEFAULT_SERVER_ADDR = "::ffff:127.0.0.1:8710";
28 const string ENV_SERVER_PORT = "OHOS_HDC_SERVER_PORT";
29 
30 // ################################ macro define ###################################
31 constexpr uint8_t MINOR_TIMEOUT = 5;
32 constexpr uint8_t DWORD_SERIALIZE_SIZE = 4;
33 constexpr uint8_t CMD_ARG1_COUNT = 2;
34 constexpr uint8_t STREAM_MAIN = 0;  // work at main thread
35 constexpr uint8_t STREAM_WORK = 1;  // work at work thread
36 constexpr uint16_t TIME_BUF_SIZE = 32;
37 constexpr uint16_t BUF_SIZE_MICRO = 16;
38 constexpr uint16_t BUF_SIZE_TINY = 64;
39 constexpr uint16_t BUF_SIZE_SMALL = 256;
40 constexpr uint16_t BUF_SIZE_MEDIUM = 512;
41 constexpr uint16_t BUF_SIZE_DEFAULT = 1024;
42 constexpr uint16_t BUF_SIZE_DEFAULT2 = BUF_SIZE_DEFAULT * 2;
43 constexpr uint16_t BUF_SIZE_DEFAULT4 = BUF_SIZE_DEFAULT * 4;
44 constexpr uint16_t MAX_IP_PORT = 65535;
45 constexpr uint16_t MAX_CONNECTKEY_SIZE = 32;  // usb sn/tcp ipport
46 constexpr uint16_t TIME_BASE = 1000;          // time unit conversion base value
47 constexpr uint16_t AID_SHELL = 2000;
48 constexpr uint16_t UV_DEFAULT_INTERVAL = 250;  // ms
49 constexpr uint16_t VER_PROTOCOL = 0x01;
50 constexpr uint16_t MAX_PACKET_SIZE_HISPEED = 512;
51 constexpr uint16_t DEVICE_CHECK_INTERVAL = 3000;  // ms
52 constexpr uint16_t MAX_SIZE_IOBUF = 15360;
53 constexpr uint16_t MAX_USBFFS_BULK = 16384;
54 // double-word(hex)=[0]major[1][2]minor[3][4]version[5]fix(a-p)[6][7]reserve
55 constexpr uint32_t HDC_VERSION_NUMBER = 0x10101b00;  // 1.1.1b=0x10101100
56 constexpr uint32_t HDC_BUF_MAX_BYTES = INT_MAX;
57 constexpr uint32_t HDC_SOCKETPAIR_SIZE = MAX_SIZE_IOBUF * 10;
58 
59 const string WHITE_SPACES = " \t\n\r";
60 const string UT_TMP_PATH = "/tmp/hdc-ut";
61 const string LOG_FILE_NAME = "hdc.log";
62 const string LOG_BAK_NAME = "hdclast.log";
63 const string LOG_CACHE_NAME = ".hdc.cache.log";
64 constexpr uint64_t LOG_FILE_MAX_SIZE = 104857600;
65 const string SERVER_NAME = "HDCServer";
66 const string STRING_EMPTY = "";
67 const string HANDSHAKE_MESSAGE = "OHOS HDC";  // sep not char '-', not more than 11 bytes
68 const string PACKET_FLAG = "HW";              // must 2bytes
69 const string EMPTY_ECHO = "[Empty]";
70 const string MESSAGE_INFO = "[Info]";
71 const string MESSAGE_FAIL = "[Fail]";
72 const string MESSAGE_SUCCESS = "[Success]";
73 // input command
74 const string CMDSTR_SOFTWARE_VERSION = "version";
75 const string CMDSTR_SOFTWARE_HELP = "help";
76 const string CMDSTR_TARGET_DISCOVER = "discover";
77 const string CMDSTR_SERVICE_START = "start";
78 const string CMDSTR_SERVICE_KILL = "kill";
79 const string CMDSTR_GENERATE_KEY = "keygen";
80 const string CMDSTR_KILL_SERVER = "kserver";
81 const string CMDSTR_KILL_DAEMON = "kdaemon";
82 const string CMDSTR_LIST_TARGETS = "list targets";
83 const string CMDSTR_CONNECT_TARGET = "tconn";
84 const string CMDSTR_CONNECT_ANY = "any";
85 const string CMDSTR_SHELL = "shell";
86 const string CMDSTR_TARGET_REBOOT = "target boot";
87 const string CMDSTR_TARGET_MOUNT = "target mount";
88 const string CMDSTR_STARTUP_MODE = "smode";
89 const string CMDSTR_TARGET_MODE = "tmode";
90 const string CMDSTR_BUGREPORT = "bugreport";
91 const string CMDSTR_HILOG = "hilog";
92 const string CMDSTR_TMODE_USB = "usb";
93 #ifdef HDC_SUPPORT_UART
94 const string CMDSTR_TMODE_UART = "uart";
95 const string UART_HDC_NODE = "/dev/ttyAMA0";
96 const string CONSOLE_ACTIVE_NODE = "/sys/class/tty/console/active";
97 constexpr int uartIOWaitTime100 = 100;
98 constexpr int uartIOWaitTime = 1000;
99 constexpr uint16_t MAX_UART_SIZE_IOBUF = 4096; // MAX_SIZE_IOBUF;
100 #endif
101 const string CMDSTR_TMODE_TCP = "tcp";
102 const string CMDSTR_FILE_SEND = "file send";
103 const string CMDSTR_FILE_RECV = "file recv";
104 const string CMDSTR_FORWARD_FPORT = "fport";
105 const string CMDSTR_FORWARD_RPORT = "rport";
106 const string CMDSTR_APP_INSTALL = "install";
107 const string CMDSTR_APP_UNINSTALL = "uninstall";
108 const string CMDSTR_APP_SIDELOAD = "sideload";
109 const string CMDSTR_LIST_JDWP = "jpid";
110 const string CMDSTR_TRACK_JDWP = "track-jpid";
111 const string CMDSTR_INNER_ENABLE_KEEPALIVE = "alive";
112 }  // namespace Hdc
113 #endif  // HDC_DEFINE_H
114