1b1b8bc3fSopenharmony_ci/*
2b1b8bc3fSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3b1b8bc3fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4b1b8bc3fSopenharmony_ci * you may not use this file except in compliance with the License.
5b1b8bc3fSopenharmony_ci * You may obtain a copy of the License at
6b1b8bc3fSopenharmony_ci *
7b1b8bc3fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8b1b8bc3fSopenharmony_ci *
9b1b8bc3fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10b1b8bc3fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11b1b8bc3fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12b1b8bc3fSopenharmony_ci * See the License for the specific language governing permissions and
13b1b8bc3fSopenharmony_ci * limitations under the License.
14b1b8bc3fSopenharmony_ci */
15b1b8bc3fSopenharmony_ci#ifndef CLAT_CONSTANTS_H
16b1b8bc3fSopenharmony_ci#define CLAT_CONSTANTS_H
17b1b8bc3fSopenharmony_ci
18b1b8bc3fSopenharmony_ci#include <string>
19b1b8bc3fSopenharmony_ci
20b1b8bc3fSopenharmony_cinamespace OHOS {
21b1b8bc3fSopenharmony_cinamespace NetManagerStandard {
22b1b8bc3fSopenharmony_cienum Nat464UpdateFlag {
23b1b8bc3fSopenharmony_ci    NAT464_SERVICE_CONTINUE,
24b1b8bc3fSopenharmony_ci    NAT464_SERVICE_STOP,
25b1b8bc3fSopenharmony_ci};
26b1b8bc3fSopenharmony_ci
27b1b8bc3fSopenharmony_cienum Nat464ServiceState {
28b1b8bc3fSopenharmony_ci    NAT464_SERVICE_STATE_IDLE,
29b1b8bc3fSopenharmony_ci    NAT464_SERVICE_STATE_DISCOVERING,
30b1b8bc3fSopenharmony_ci    NAT464_SERVICE_STATE_RUNNING,
31b1b8bc3fSopenharmony_ci};
32b1b8bc3fSopenharmony_ci
33b1b8bc3fSopenharmony_cienum ClatdConvertType {
34b1b8bc3fSopenharmony_ci    CONVERT_FROM_V6_TO_V4,
35b1b8bc3fSopenharmony_ci    CONVERT_FROM_V4_TO_V6,
36b1b8bc3fSopenharmony_ci};
37b1b8bc3fSopenharmony_ci
38b1b8bc3fSopenharmony_cienum ClatdPacketPosition {
39b1b8bc3fSopenharmony_ci    CLATD_TUNHDR,
40b1b8bc3fSopenharmony_ci    CLATD_IPHDR,
41b1b8bc3fSopenharmony_ci    CLATD_FRAGHDR,
42b1b8bc3fSopenharmony_ci    CLATD_TPHDR,
43b1b8bc3fSopenharmony_ci    CLATD_ICMP_IPHDR,
44b1b8bc3fSopenharmony_ci    CLATD_ICMP_FRAGHDR,
45b1b8bc3fSopenharmony_ci    CLATD_ICMP_TPHDR,
46b1b8bc3fSopenharmony_ci    CLATD_PAYLOAD,
47b1b8bc3fSopenharmony_ci    CLATD_MAX
48b1b8bc3fSopenharmony_ci};
49b1b8bc3fSopenharmony_ci
50b1b8bc3fSopenharmony_cistatic constexpr size_t IP_TP_PACKET_POSITION_DELTA = 2; // packet position delta between CLATD_IPHDR and CLATD_TPHDR
51b1b8bc3fSopenharmony_ci
52b1b8bc3fSopenharmony_cistatic constexpr size_t TCP_HDR_MIN_LEN = 20;
53b1b8bc3fSopenharmony_cistatic constexpr size_t TCP_HDR_MAX_LEN = 60;
54b1b8bc3fSopenharmony_cistatic constexpr int IPV4_HDR_MIN_LEN = 20;
55b1b8bc3fSopenharmony_cistatic constexpr int IPV6_HDR_LEN = 40;
56b1b8bc3fSopenharmony_cistatic constexpr int FRAG_HDR_LEN = 8;
57b1b8bc3fSopenharmony_cistatic constexpr int MTU_DELTA = IPV6_HDR_LEN - IPV4_HDR_MIN_LEN + FRAG_HDR_LEN;
58b1b8bc3fSopenharmony_cistatic constexpr int CLAT_MAX_MTU = 65536 + MTU_DELTA;
59b1b8bc3fSopenharmony_cistatic constexpr int CLAT_DATA_LINK_HDR_LEN = 22; // 14 bytes ethernet header + at most 8 bytes VLAN Tag
60b1b8bc3fSopenharmony_ci
61b1b8bc3fSopenharmony_cistatic constexpr int CLAT_IPV6_MIN_MTU = 1280;
62b1b8bc3fSopenharmony_cistatic constexpr uint16_t TP_CSUM_UNNECESSARY = 1;
63b1b8bc3fSopenharmony_ci
64b1b8bc3fSopenharmony_cistatic constexpr const char *CLAT_PREFIX = "tunv4-";
65b1b8bc3fSopenharmony_cistatic constexpr int CLAT_PREFIX_BYTE_LEN = 12;
66b1b8bc3fSopenharmony_cistatic constexpr int CLAT_SUFFIX_OFFSET_IN_32 = 3; // 96-bit prefix + 32-bit suffix, the suffix is the 4th 32-bit word
67b1b8bc3fSopenharmony_ci
68b1b8bc3fSopenharmony_cistatic constexpr int WORD_32BIT_IN_BYTE_UNIT = 4; // 4-bytes unit for tcphdr->doff and iphdr->ihl
69b1b8bc3fSopenharmony_ci
70b1b8bc3fSopenharmony_cistatic constexpr uint8_t IPV6_VERSION_FLAG = 0x60;
71b1b8bc3fSopenharmony_cistatic constexpr int V4ADDR_BIT_LEN = 32;
72b1b8bc3fSopenharmony_cistatic constexpr int V6ADDR_BIT_LEN = 128;
73b1b8bc3fSopenharmony_cistatic constexpr const char *INIT_V4ADDR_STRING = "192.0.0.0"; // Reserved ip addr in RFC 5736
74b1b8bc3fSopenharmony_cistatic constexpr int INIT_V4ADDR_PREFIX_BIT_LEN = 29;
75b1b8bc3fSopenharmony_ci
76b1b8bc3fSopenharmony_cistatic constexpr size_t CLAT_V6ADDR_RANDOMIZE_OFFSET = 8;
77b1b8bc3fSopenharmony_cistatic constexpr size_t CLAT_V6ADDR_RANDOMIZE_BIT_LENGTH = 8;
78b1b8bc3fSopenharmony_cistatic constexpr size_t CLAT_V6ADDR_NEUTRALIZE_OFFSET = 3;
79b1b8bc3fSopenharmony_ci
80b1b8bc3fSopenharmony_cistatic constexpr uint16_t WKN_DNS_PORT = 53;
81b1b8bc3fSopenharmony_cistatic constexpr const char *DEFAULT_V4_ADDR = "0.0.0.0/0";
82b1b8bc3fSopenharmony_ci
83b1b8bc3fSopenharmony_cistatic constexpr const char *SOLICITED_NODE_PREFIX = "ff02::1:ff00:0000"; // Solicited-Node Address in RFC 4291
84b1b8bc3fSopenharmony_cistatic constexpr size_t SOLICITED_NODE_SUFFIX_OFFSET = 13;
85b1b8bc3fSopenharmony_ci
86b1b8bc3fSopenharmony_cistatic constexpr uint16_t IPV6_FRAG_OFFSET_BIT_SUPPLEMENTARY = 3; // offset field in ipv6 fragment header is top 13 bit
87b1b8bc3fSopenharmony_ci
88b1b8bc3fSopenharmony_cistatic constexpr int INVALID_IFINDEX = 0;
89b1b8bc3fSopenharmony_ci
90b1b8bc3fSopenharmony_cistatic constexpr const char *IFACE_LINK_UP = "up";
91b1b8bc3fSopenharmony_ci
92b1b8bc3fSopenharmony_cistatic constexpr size_t IPV6_SRC_OFFSET = 8;
93b1b8bc3fSopenharmony_cistatic constexpr uint8_t NDP_NOUNCE_OPT = 14;
94b1b8bc3fSopenharmony_ci
95b1b8bc3fSopenharmony_cistatic constexpr const char *IPV4_ONLY_HOST = "ipv4only.arpa.";
96b1b8bc3fSopenharmony_ci
97b1b8bc3fSopenharmony_cistatic constexpr uint32_t INITIAL_DISCOVERY_CYCLE_MS = 100;
98b1b8bc3fSopenharmony_ci
99b1b8bc3fSopenharmony_cistatic constexpr uint32_t MAX_DISCOVERY_CYCLE_MS = 100000;
100b1b8bc3fSopenharmony_ci
101b1b8bc3fSopenharmony_cistatic constexpr uint32_t DISCOVERY_CYCLE_MULTIPLIER = 2;
102b1b8bc3fSopenharmony_ci
103b1b8bc3fSopenharmony_cistatic constexpr uint32_t CLATD_TIMER_CYCLE_MS = 5000;
104b1b8bc3fSopenharmony_ci
105b1b8bc3fSopenharmony_ci} // namespace NetManagerStandard
106b1b8bc3fSopenharmony_ci} // namespace OHOS
107b1b8bc3fSopenharmony_ci#endif