1/*
2 * Copyright (C) 2021 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_MESSAGE_H
17#define OHOS_DHCP_MESSAGE_H
18
19#include <stdint.h>
20#include "dhcp_s_define.h"
21#include "dhcp_option.h"
22
23#define BOOTREQUEST 1
24#define BOOTREPLY 2
25
26#define DHCP_MSG_HEADER_SIZE 234
27
28enum DhcpMessageType {
29    DHCPDISCOVER = 1,
30    DHCPOFFER = 2,
31    DHCPREQUEST = 3,
32    DHCPDECLINE = 4,
33    DHCPACK = 5,
34    DHCPNAK = 6,
35    DHCPRELEASE = 7,
36    DHCPINFORM = 8
37};
38
39enum DhcpReplyType {
40    REPLY_NONE = 0,
41    REPLY_OFFER,
42    REPLY_ACK,
43    REPLY_NAK,
44};
45
46typedef struct DhcpMessage DhcpMessage;
47struct DhcpMessage {
48    uint8_t op;
49    uint8_t htype;
50    uint8_t hlen;
51    uint8_t hops;
52    uint32_t xid;
53    uint16_t secs;
54    uint16_t flags;
55    uint32_t ciaddr;
56    uint32_t yiaddr;
57    uint32_t siaddr;
58    uint32_t giaddr;
59
60    uint8_t chaddr[DHCP_HWADDR_LENGTH];
61
62    uint8_t sname[DHCP_HOST_NAME_LENGTH];
63    uint8_t file[DHCP_BOOT_FILE_LENGTH];
64    uint8_t options[DHCP_OPTIONS_SIZE];
65};
66typedef struct DhcpMessage *PDhcpMessage;
67
68typedef struct DhcpMsgInfo DhcpMsgInfo;
69struct DhcpMsgInfo {
70    DhcpMessage packet;
71    int length;
72    DhcpOptionList options;
73};
74typedef struct DhcpMsgInfo *PDhcpMsgInfo;
75
76#endif
77