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_OPTION_H
17518678f8Sopenharmony_ci#define OHOS_DHCP_OPTION_H
18518678f8Sopenharmony_ci
19518678f8Sopenharmony_ci#include <stddef.h>
20518678f8Sopenharmony_ci#include <stdint.h>
21518678f8Sopenharmony_ci
22518678f8Sopenharmony_ci#define DHCP_OPTION_SIZE 256
23518678f8Sopenharmony_ci#define DHCP_END_OPTION_CODE 255
24518678f8Sopenharmony_ci
25518678f8Sopenharmony_ci#ifdef __cplusplus
26518678f8Sopenharmony_ciextern "C" {
27518678f8Sopenharmony_ci#endif
28518678f8Sopenharmony_ci
29518678f8Sopenharmony_citypedef struct DhcpOption DhcpOption;
30518678f8Sopenharmony_cistruct DhcpOption {
31518678f8Sopenharmony_ci    uint8_t code;
32518678f8Sopenharmony_ci    uint8_t length;
33518678f8Sopenharmony_ci    uint8_t data[DHCP_OPTION_SIZE];
34518678f8Sopenharmony_ci};
35518678f8Sopenharmony_citypedef struct DhcpOption *PDhcpOption;
36518678f8Sopenharmony_ci
37518678f8Sopenharmony_citypedef struct DhcpOptionNode DhcpOptionNode;
38518678f8Sopenharmony_cistruct DhcpOptionNode {
39518678f8Sopenharmony_ci    struct DhcpOptionNode *previous;
40518678f8Sopenharmony_ci    struct DhcpOptionNode *next;
41518678f8Sopenharmony_ci    DhcpOption option;
42518678f8Sopenharmony_ci};
43518678f8Sopenharmony_citypedef struct DhcpOptionNode *PDhcpOptionNode;
44518678f8Sopenharmony_ci
45518678f8Sopenharmony_citypedef struct DhcpOptionList DhcpOptionList;
46518678f8Sopenharmony_cistruct DhcpOptionList {
47518678f8Sopenharmony_ci    PDhcpOptionNode first;
48518678f8Sopenharmony_ci    PDhcpOptionNode last;
49518678f8Sopenharmony_ci    size_t size;
50518678f8Sopenharmony_ci};
51518678f8Sopenharmony_citypedef struct DhcpOptionList *PDhcpOptionList;
52518678f8Sopenharmony_ci
53518678f8Sopenharmony_ciint InitOptionList(PDhcpOptionList pOptions);
54518678f8Sopenharmony_ciint HasInitialized(PDhcpOptionList pOptions);
55518678f8Sopenharmony_ciint PushBackOption(PDhcpOptionList pOptions, PDhcpOption option);
56518678f8Sopenharmony_ciint PushFrontOption(PDhcpOptionList pOptions, PDhcpOption option);
57518678f8Sopenharmony_ciint RemoveOption(PDhcpOptionList pOptions, uint8_t code);
58518678f8Sopenharmony_ciPDhcpOptionNode GetOptionNode(PDhcpOptionList pOptions, uint8_t code);
59518678f8Sopenharmony_ciPDhcpOption GetOption(PDhcpOptionList pOptions, uint8_t code);
60518678f8Sopenharmony_civoid ClearOptions(PDhcpOptionList pOptions);
61518678f8Sopenharmony_civoid FreeOptionList(PDhcpOptionList pOptions);
62518678f8Sopenharmony_ciint FillOption(PDhcpOption pOption, const char *data, size_t len);
63518678f8Sopenharmony_ciint FillU32Option(PDhcpOption pOption, uint32_t u32);
64518678f8Sopenharmony_ciint FillOptionData(PDhcpOption pOption, const uint8_t *data, size_t len);
65518678f8Sopenharmony_ciint AppendAddressOption(PDhcpOption pOption, uint32_t address);
66518678f8Sopenharmony_ci
67518678f8Sopenharmony_ci#ifdef __cplusplus
68518678f8Sopenharmony_ci}
69518678f8Sopenharmony_ci#endif
70518678f8Sopenharmony_ci#endif
71