• 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 OHOS_DHCPC_H
16 #define OHOS_DHCPC_H
17 
18 #include <pthread.h>
19 
20 #include "dhcp_define.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define WORKDIR                 "/data/service/el1/public/dhcp/"
27 #define DHCPC_NAME              "dhcp_client_service"
28 #define DHCPC_CONF              "dhcp_client_service.conf"
29 #define DHCPC_PID               "dhcp_client_service.pid"
30 #define DHCPC_VERSION           "1.0"
31 #define DHCPC_LEASE             "dhcp_client_service-%s.lease"
32 
33 enum DHCP_IP_TYPE {
34     DHCP_IP_TYPE_NONE =  0,
35     DHCP_IP_TYPE_ALL  =  1,
36     DHCP_IP_TYPE_V4   =  2,
37     DHCP_IP_TYPE_V6   =  3
38 };
39 
40 struct DhcpClientCfg {
41     char workDir[DIR_MAX_LEN];              /* Current process working directory. */
42     char confFile[DIR_MAX_LEN];             /* Current process Configuration Directory. */
43     char pidFile[DIR_MAX_LEN];              /* Current process pid file. */
44     char resultFile[DIR_MAX_LEN];           /* Save the obtained IPv4 result. */
45     char ifaceName[INFNAME_SIZE];           /* Name of the network interface used by the current process. */
46     int  ifaceIndex;                        /* Index of the network interface used by the current process. */
47     unsigned int ifaceIpv4;                 /* IPv4 of the network interface used by the current process. */
48     unsigned int getMode;                   /* Current process obtaining IPv4 address mode. */
49     unsigned char ifaceMac[MAC_ADDR_LEN];   /* Mac addr of the network interface used by the current process. */
50     unsigned char *pOptClientId;            /* DHCP packet options field clientid. */
51     bool timeoutExit;                       /* DHCP packet sending times out and exits automatically. */
52     char leaseFile[DIR_MAX_LEN];
53     char result6File[DIR_MAX_LEN];
54     pthread_t thrId;
55 };
56 
57 int StartProcess(void);
58 int StopProcess(const char *pidFile);
59 int GetProStatus(const char *pidFile);
60 
61 struct DhcpClientCfg *GetDhcpClientCfg(void);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 #endif
67