1 /*
2  * Copyright (C) 2021-2022 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_CONFIG_H
17 #define OHOS_DHCP_CONFIG_H
18 
19 #include <stdint.h>
20 #include "dhcp_address_pool.h"
21 #include "dhcp_s_define.h"
22 #include "dhcp_option.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 typedef struct DhcpConfig DhcpConfig;
29 struct DhcpConfig {
30     char ifname[IFACE_NAME_SIZE];           /* Network interface name. */
31     uint32_t serverId;                      /* Server identifier. */
32     uint32_t netmask;                       /* Default subnet mask. */
33     uint32_t gateway;                       /* Default gateway. */
34     uint32_t leaseTime;                     /* Lease time value, default DHCP_LEASE_TIME. */
35     uint32_t renewalTime;                   /* Renewal time value. */
36     uint32_t rebindingTime;                 /* Rebinding time value. */
37     uint32_t distribution;                  /* Ip distribue mode [0|1]: 0-random, 1-sequence(default). */
38     uint32_t broadcast;                     /* Broadcast flags enable [0|1]: 0-no, 1-yes(default). */
39     IpAddressRange pool;                    /* Address Range. */
40     DhcpOptionList options;                 /* Append dhcp options. */
41 };
42 typedef struct DhcpConfig *PDhcpConfig;
43 
44 typedef struct DhcpConfigNode DhcpConfigNode;
45 struct DhcpConfigNode {
46     DhcpConfig config;
47     DhcpConfigNode *next;
48 };
49 typedef struct DhcpConfigNode *PDhcpConfigNode;
50 
51 typedef struct DhcpConfigList DhcpConfigList;
52 struct DhcpConfigList {
53     int size;
54     DhcpConfigNode *first;
55 };
56 typedef struct DhcpConfigList *PDhcpConfigList;
57 
58 int LoadConfig(const char *configFile, const char *ifname, DhcpConfig *config);
59 
60 #ifdef __cplusplus
61 }
62 #endif
63 #endif
64