• 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 
16 #ifndef OHOS_DHCP_S_DEFINE_H
17 #define OHOS_DHCP_S_DEFINE_H
18 
19 #include "dhcp_define.h"
20 #define DHCP_LEASE_TIME 21600
21 #define DHCP_RENEWAL_TIME 10800
22 #define DHCP_REBINDING_TIME 17280
23 #define DHCP_DEFAULT_TIMEOUT 30
24 #define DHCP_ADDRESS_LENGTH 4
25 #define DHCP_HWADDR_LENGTH 16
26 #define DHCP_HOST_NAME_LENGTH 64
27 #define DHCP_BOOT_FILE_LENGTH 128
28 #define DHCP_LEASE_FILE_LENGTH 256
29 #define DHCP_FILE_LINE_LENGTH 1024
30 #define DHCP_REFRESH_LEASE_FILE_INTERVAL 120
31 #define DHCP_MESSAGE_FLAG_LENGTH 8
32 #define DHCP_MAX_PATH_LENGTH 256
33 #define DHCP_ONE_BYTE_BITS 8
34 
35 inline constexpr char DHCP_ROOT[] = "/data/service/el1/public/dhcp/";
36 inline constexpr char DHCPD_CONFIG_FILE[] = "/data/service/el1/public/dhcp/etc/dhcpd.conf";
37 inline constexpr char DHCPD_EXT_CONFIG_PATH[] = "/data/service/el1/public/dhcp/etc/dhcpd.d";
38 inline constexpr char DHCPD_LEASE_FILE[] = "/data/service/el1/public/dhcp/dhcpd_lease.lease";
39 inline constexpr char DHCPD_PID_FILE[] = "/data/service/el1/public/dhcp/dhcpd.pid";
40 inline constexpr char DHCPD_VERSION[] = "0.0.1";
41 
42 #define DHCPD_VERSION "0.0.1"
43 
44 #define DHCP_SERVER_PORT 67
45 #define DHCP_CLIENT_PORT 68
46 
47 #define DHCP_OPTIONS_SIZE   312
48 #define IFACE_NAME_SIZE     50
49 #define PID_MAX_LEN         16
50 
51 #define DHCP_RENEWAL_MULTIPLE 0.5
52 #define DHCP_REBIND_MULTIPLE 0.875
53 
54 #define DHCP_TRUE 1
55 #define DHCP_FALSE 0
56 enum DhcpNumber {
57     NUM_ZERO = 0,
58     NUM_ONE,
59     NUM_TWO,
60     NUM_THREE,
61     NUM_FOUR,
62     NUM_FIVE,
63     NUM_SIX,
64     NUM_SEVEN,
65     NUM_EIGHT,
66     NUM_NINE,
67     NUM_TEN,
68     NUM_ELEVEN,
69     NUM_TWELVE,
70     NUM_THIRTEEN,
71     NUM_FOURTEEN,
72 };
73 
74 enum DhcpReturnCode {
75     RET_SUCCESS = 0,
76     RET_FAILED,
77     RET_ERROR,
78     ERR_SELECT,
79     RET_BREAK,
80     RET_WAIT_SAVE,
81     RET_NO_SUPPORTED,
82     RET_SELECT_TIME_OUT
83 };
84 
85 #endif