• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SERVER_H
17 #define OHOS_DHCP_SERVER_H
18 
19 #include "dhcp_config.h"
20 #include "dhcp_s_define.h"
21 #include "dhcp_message.h"
22 
23 enum DhcpServerState { ST_IDEL = 0, ST_STARTING, ST_RUNNING, ST_RELOADNG, ST_STOPING, ST_STOPED };
24 typedef int (*DhcpServerCallback)(int, int, const char *ifname);
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef struct ServerContext ServerContext;
31 typedef struct {
32     char ifname[IFACE_NAME_SIZE];
33     ServerContext *instance;
34 } DhcpServerContext, *PDhcpServerContext;
35 
36 PDhcpServerContext InitializeServer(DhcpConfig *config);
37 int StartDhcpServer(PDhcpServerContext ctx);
38 int StopDhcpServer(PDhcpServerContext ctx);
39 int GetServerStatus(PDhcpServerContext ctx);
40 void RegisterDhcpCallback(PDhcpServerContext ctx, DhcpServerCallback callback);
41 int FreeServerContext(PDhcpServerContext *ctx);
42 int SaveLease(PDhcpServerContext ctx);
43 int ReceiveDhcpMessage(int sock, PDhcpMsgInfo msgInfo);
44 #ifdef __cplusplus
45 }
46 #endif
47 #endif
48