sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
dhcp.h
Go to the documentation of this file.
1
6
7
/*
8
* Copyright (c) 2001-2004 Leon Woestenberg <leon.woestenberg@gmx.net>
9
* Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands.
10
* All rights reserved.
11
*
12
* Redistribution and use in source and binary forms, with or without modification,
13
* are permitted provided that the following conditions are met:
14
*
15
* 1. Redistributions of source code must retain the above copyright notice,
16
* this list of conditions and the following disclaimer.
17
* 2. Redistributions in binary form must reproduce the above copyright notice,
18
* this list of conditions and the following disclaimer in the documentation
19
* and/or other materials provided with the distribution.
20
* 3. The name of the author may not be used to endorse or promote products
21
* derived from this software without specific prior written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32
* OF SUCH DAMAGE.
33
*
34
* This file is part of the lwIP TCP/IP stack.
35
*
36
* Author: Leon Woestenberg <leon.woestenberg@gmx.net>
37
*
38
*/
39
#ifndef LWIP_HDR_PROT_DHCP_H
40
#define LWIP_HDR_PROT_DHCP_H
41
42
#include "
lwip/opt.h
"
43
#include "
lwip/arch.h
"
44
#include "
lwip/prot/ip4.h
"
45
46
#ifdef __cplusplus
47
extern
"C"
{
48
#endif
49
50
/* DHCP message item offsets and length */
51
#define DHCP_CHADDR_LEN 16U
52
#define DHCP_SNAME_OFS 44U
53
#define DHCP_SNAME_LEN 64U
54
#define DHCP_FILE_OFS 108U
55
#define DHCP_FILE_LEN 128U
56
#define DHCP_MSG_LEN 236U
57
#define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4U)
/* 4 byte: cookie */
58
59
#ifdef PACK_STRUCT_USE_INCLUDES
60
# include "arch/bpstruct.h"
61
#endif
62
PACK_STRUCT_BEGIN
64
struct
dhcp_msg
65
{
66
PACK_STRUCT_FLD_8(u8_t op);
67
PACK_STRUCT_FLD_8(u8_t htype);
68
PACK_STRUCT_FLD_8(u8_t hlen);
69
PACK_STRUCT_FLD_8(u8_t hops);
70
PACK_STRUCT_FIELD(u32_t xid);
71
PACK_STRUCT_FIELD(u16_t secs);
72
PACK_STRUCT_FIELD(u16_t flags);
73
PACK_STRUCT_FLD_S(ip4_addr_p_t ciaddr);
74
PACK_STRUCT_FLD_S(ip4_addr_p_t yiaddr);
75
PACK_STRUCT_FLD_S(ip4_addr_p_t siaddr);
76
PACK_STRUCT_FLD_S(ip4_addr_p_t giaddr);
77
PACK_STRUCT_FLD_8(u8_t chaddr[DHCP_CHADDR_LEN]);
78
PACK_STRUCT_FLD_8(u8_t sname[DHCP_SNAME_LEN]);
79
PACK_STRUCT_FLD_8(u8_t file[DHCP_FILE_LEN]);
80
PACK_STRUCT_FIELD(u32_t cookie);
81
#define DHCP_MIN_OPTIONS_LEN 68U
83
#if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN))
84
# undef DHCP_OPTIONS_LEN
85
#endif
87
#if (!defined(DHCP_OPTIONS_LEN))
89
# define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN
90
#endif
91
PACK_STRUCT_FLD_8(u8_t options[
DHCP_OPTIONS_LEN
]);
92
} PACK_STRUCT_STRUCT;
93
PACK_STRUCT_END
94
#ifdef PACK_STRUCT_USE_INCLUDES
95
# include "arch/epstruct.h"
96
#endif
97
98
99
/* DHCP client states */
100
typedef
enum
{
101
DHCP_STATE_OFF = 0,
102
DHCP_STATE_REQUESTING = 1,
103
DHCP_STATE_INIT = 2,
104
DHCP_STATE_REBOOTING = 3,
105
DHCP_STATE_REBINDING = 4,
106
DHCP_STATE_RENEWING = 5,
107
DHCP_STATE_SELECTING = 6,
108
DHCP_STATE_INFORMING = 7,
109
DHCP_STATE_CHECKING = 8,
110
DHCP_STATE_PERMANENT = 9,
/* not yet implemented */
111
DHCP_STATE_BOUND = 10,
112
DHCP_STATE_RELEASING = 11,
/* not yet implemented */
113
DHCP_STATE_BACKING_OFF = 12
114
} dhcp_state_enum_t;
115
116
/* DHCP op codes */
117
#define DHCP_BOOTREQUEST 1
118
#define DHCP_BOOTREPLY 2
119
120
/* DHCP message types */
121
#define DHCP_DISCOVER 1
122
#define DHCP_OFFER 2
123
#define DHCP_REQUEST 3
124
#define DHCP_DECLINE 4
125
#define DHCP_ACK 5
126
#define DHCP_NAK 6
127
#define DHCP_RELEASE 7
128
#define DHCP_INFORM 8
129
130
#define DHCP_MAGIC_COOKIE 0x63825363UL
131
132
/* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions */
133
134
/* BootP options */
135
#define DHCP_OPTION_PAD 0
136
#define DHCP_OPTION_SUBNET_MASK 1
/* RFC 2132 3.3 */
137
#define DHCP_OPTION_ROUTER 3
138
#define DHCP_OPTION_DNS_SERVER 6
139
#define DHCP_OPTION_HOSTNAME 12
140
#define DHCP_OPTION_IP_TTL 23
141
#define DHCP_OPTION_MTU 26
142
#define DHCP_OPTION_BROADCAST 28
143
#define DHCP_OPTION_TCP_TTL 37
144
#define DHCP_OPTION_NTP 42
145
#define DHCP_OPTION_END 255
146
147
/* DHCP options */
148
#define DHCP_OPTION_REQUESTED_IP 50
/* RFC 2132 9.1, requested IP address */
149
#define DHCP_OPTION_LEASE_TIME 51
/* RFC 2132 9.2, time in seconds, in 4 bytes */
150
#define DHCP_OPTION_OVERLOAD 52
/* RFC2132 9.3, use file and/or sname field for options */
151
152
#define DHCP_OPTION_MESSAGE_TYPE 53
/* RFC 2132 9.6, important for DHCP */
153
#define DHCP_OPTION_MESSAGE_TYPE_LEN 1
154
155
#define DHCP_OPTION_SERVER_ID 54
/* RFC 2132 9.7, server IP address */
156
#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55
/* RFC 2132 9.8, requested option types */
157
158
#define DHCP_OPTION_MAX_MSG_SIZE 57
/* RFC 2132 9.10, message size accepted >= 576 */
159
#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2
160
161
#define DHCP_OPTION_T1 58
/* T1 renewal time */
162
#define DHCP_OPTION_T2 59
/* T2 rebinding time */
163
#define DHCP_OPTION_US 60
164
#define DHCP_OPTION_CLIENT_ID 61
165
#define DHCP_OPTION_TFTP_SERVERNAME 66
166
#define DHCP_OPTION_BOOTFILE 67
167
168
/* possible combinations of overloading the file and sname fields with options */
169
#define DHCP_OVERLOAD_NONE 0
170
#define DHCP_OVERLOAD_FILE 1
171
#define DHCP_OVERLOAD_SNAME 2
172
#define DHCP_OVERLOAD_SNAME_FILE 3
173
174
175
#ifdef __cplusplus
176
}
177
#endif
178
179
#endif
/* LWIP_HDR_PROT_DHCP_H */
arch.h
opt.h
DHCP_OPTIONS_LEN
#define DHCP_OPTIONS_LEN
Definition
dhcp.h:89
ip4.h
dhcp_msg
Definition
dhcp.h:65
core
ps2ip
include
lwip_include
lwip
prot
dhcp.h
Generated by
1.18.0