1518678f8Sopenharmony_ci/*
2518678f8Sopenharmony_ci * Copyright (C) 2021 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_MESSAGE_H
17518678f8Sopenharmony_ci#define OHOS_DHCP_MESSAGE_H
18518678f8Sopenharmony_ci
19518678f8Sopenharmony_ci#include <stdint.h>
20518678f8Sopenharmony_ci#include "dhcp_s_define.h"
21518678f8Sopenharmony_ci#include "dhcp_option.h"
22518678f8Sopenharmony_ci
23518678f8Sopenharmony_ci#define BOOTREQUEST 1
24518678f8Sopenharmony_ci#define BOOTREPLY 2
25518678f8Sopenharmony_ci
26518678f8Sopenharmony_ci#define DHCP_MSG_HEADER_SIZE 234
27518678f8Sopenharmony_ci
28518678f8Sopenharmony_cienum DhcpMessageType {
29518678f8Sopenharmony_ci    DHCPDISCOVER = 1,
30518678f8Sopenharmony_ci    DHCPOFFER = 2,
31518678f8Sopenharmony_ci    DHCPREQUEST = 3,
32518678f8Sopenharmony_ci    DHCPDECLINE = 4,
33518678f8Sopenharmony_ci    DHCPACK = 5,
34518678f8Sopenharmony_ci    DHCPNAK = 6,
35518678f8Sopenharmony_ci    DHCPRELEASE = 7,
36518678f8Sopenharmony_ci    DHCPINFORM = 8
37518678f8Sopenharmony_ci};
38518678f8Sopenharmony_ci
39518678f8Sopenharmony_cienum DhcpReplyType {
40518678f8Sopenharmony_ci    REPLY_NONE = 0,
41518678f8Sopenharmony_ci    REPLY_OFFER,
42518678f8Sopenharmony_ci    REPLY_ACK,
43518678f8Sopenharmony_ci    REPLY_NAK,
44518678f8Sopenharmony_ci};
45518678f8Sopenharmony_ci
46518678f8Sopenharmony_citypedef struct DhcpMessage DhcpMessage;
47518678f8Sopenharmony_cistruct DhcpMessage {
48518678f8Sopenharmony_ci    uint8_t op;
49518678f8Sopenharmony_ci    uint8_t htype;
50518678f8Sopenharmony_ci    uint8_t hlen;
51518678f8Sopenharmony_ci    uint8_t hops;
52518678f8Sopenharmony_ci    uint32_t xid;
53518678f8Sopenharmony_ci    uint16_t secs;
54518678f8Sopenharmony_ci    uint16_t flags;
55518678f8Sopenharmony_ci    uint32_t ciaddr;
56518678f8Sopenharmony_ci    uint32_t yiaddr;
57518678f8Sopenharmony_ci    uint32_t siaddr;
58518678f8Sopenharmony_ci    uint32_t giaddr;
59518678f8Sopenharmony_ci
60518678f8Sopenharmony_ci    uint8_t chaddr[DHCP_HWADDR_LENGTH];
61518678f8Sopenharmony_ci
62518678f8Sopenharmony_ci    uint8_t sname[DHCP_HOST_NAME_LENGTH];
63518678f8Sopenharmony_ci    uint8_t file[DHCP_BOOT_FILE_LENGTH];
64518678f8Sopenharmony_ci    uint8_t options[DHCP_OPTIONS_SIZE];
65518678f8Sopenharmony_ci};
66518678f8Sopenharmony_citypedef struct DhcpMessage *PDhcpMessage;
67518678f8Sopenharmony_ci
68518678f8Sopenharmony_citypedef struct DhcpMsgInfo DhcpMsgInfo;
69518678f8Sopenharmony_cistruct DhcpMsgInfo {
70518678f8Sopenharmony_ci    DhcpMessage packet;
71518678f8Sopenharmony_ci    int length;
72518678f8Sopenharmony_ci    DhcpOptionList options;
73518678f8Sopenharmony_ci};
74518678f8Sopenharmony_citypedef struct DhcpMsgInfo *PDhcpMsgInfo;
75518678f8Sopenharmony_ci
76518678f8Sopenharmony_ci#endif
77