1518678f8Sopenharmony_ci/*
2518678f8Sopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3518678f8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4518678f8Sopenharmony_ci * you may not use this file except in compliance with the License.
5518678f8Sopenharmony_ci * You may obtain a copy of the License at
6518678f8Sopenharmony_ci *
7518678f8Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8518678f8Sopenharmony_ci *
9518678f8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10518678f8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11518678f8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12518678f8Sopenharmony_ci * See the License for the specific language governing permissions and
13518678f8Sopenharmony_ci * limitations under the License.
14518678f8Sopenharmony_ci */
15518678f8Sopenharmony_ci
16518678f8Sopenharmony_ci#ifndef OHOS_DHCP_SERVER_H
17518678f8Sopenharmony_ci#define OHOS_DHCP_SERVER_H
18518678f8Sopenharmony_ci
19518678f8Sopenharmony_ci#include "dhcp_config.h"
20518678f8Sopenharmony_ci#include "dhcp_s_define.h"
21518678f8Sopenharmony_ci#include "dhcp_message.h"
22518678f8Sopenharmony_ci
23518678f8Sopenharmony_cienum DhcpServerState { ST_IDEL = 0, ST_STARTING, ST_RUNNING, ST_RELOADNG, ST_STOPING, ST_STOPED };
24518678f8Sopenharmony_citypedef int (*DhcpServerCallback)(int, int, const char *ifname);
25518678f8Sopenharmony_citypedef void(*DeviceConnectFun)(const char *ifname);
26518678f8Sopenharmony_ci#ifdef __cplusplus
27518678f8Sopenharmony_ciextern "C" {
28518678f8Sopenharmony_ci#endif
29518678f8Sopenharmony_ci
30518678f8Sopenharmony_citypedef struct ServerContext ServerContext;
31518678f8Sopenharmony_citypedef struct {
32518678f8Sopenharmony_ci    char ifname[IFACE_NAME_SIZE];
33518678f8Sopenharmony_ci    ServerContext *instance;
34518678f8Sopenharmony_ci} DhcpServerContext, *PDhcpServerContext;
35518678f8Sopenharmony_ci
36518678f8Sopenharmony_ciPDhcpServerContext InitializeServer(DhcpConfig *config);
37518678f8Sopenharmony_ciint StartDhcpServer(PDhcpServerContext ctx);
38518678f8Sopenharmony_ciint StopDhcpServer(PDhcpServerContext ctx);
39518678f8Sopenharmony_ciint GetServerStatus(PDhcpServerContext ctx);
40518678f8Sopenharmony_civoid RegisterDhcpCallback(PDhcpServerContext ctx, DhcpServerCallback callback);
41518678f8Sopenharmony_civoid RegisterDeviceChangedCallback(PDhcpServerContext ctx, DeviceConnectFun func);
42518678f8Sopenharmony_ciint FreeServerContext(PDhcpServerContext *ctx);
43518678f8Sopenharmony_ciint SaveLease(PDhcpServerContext ctx);
44518678f8Sopenharmony_ciint ReceiveDhcpMessage(int sock, PDhcpMsgInfo msgInfo);
45518678f8Sopenharmony_civoid NotifyConnetDeviceChanged(int replyType, PDhcpServerContext ctx);
46518678f8Sopenharmony_ciint ReceiveDhcpMessage(int sock, PDhcpMsgInfo msgInfo);
47518678f8Sopenharmony_ciint GetVendorIdentifierOption(PDhcpMsgInfo received);
48518678f8Sopenharmony_ciint GetHostNameOption(PDhcpMsgInfo received, AddressBinding *bindin);
49518678f8Sopenharmony_ciint ReplyCommontOption(PDhcpServerContext ctx, PDhcpMsgInfo reply);
50518678f8Sopenharmony_ciint ParseDhcpOption(PDhcpMsgInfo received, AddressBinding *bindin);
51518678f8Sopenharmony_ciint GetUserClassOption(PDhcpMsgInfo received, AddressBinding *bindin);
52518678f8Sopenharmony_ciint GetRapidCommitOption(PDhcpMsgInfo received, AddressBinding *bindin);
53518678f8Sopenharmony_ciint GetOnlyIpv6Option(PDhcpMsgInfo received, AddressBinding *bindin);
54518678f8Sopenharmony_ciint GetPortalUrlOption(PDhcpMsgInfo received, AddressBinding *bindin);
55518678f8Sopenharmony_ci#ifdef __cplusplus
56518678f8Sopenharmony_ci}
57518678f8Sopenharmony_ci#endif
58518678f8Sopenharmony_ci#endif
59