]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/Dhcp4.h
MdePkg: Add definition for new warning code EFI_WARN_FILE_SYSTEM.
[mirror_edk2.git] / MdePkg / Include / Protocol / Dhcp4.h
CommitLineData
d1f95000 1/** @file\r
2 EFI_DHCP4_PROTOCOL as defined in UEFI 2.0.\r
3 EFI_DHCP4_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.\r
305a1279 4 These protocols are used to collect configuration information for the EFI IPv4 Protocol\r
d1f95000 5 drivers and to provide DHCPv4 server and PXE boot server discovery services.\r
6\r
9df063a0 7Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
af2dc6a7 8This program and the accompanying materials are licensed and made available under \r
9the terms and conditions of the BSD License that accompanies this distribution. \r
10The full text of the license may be found at\r
11http://opensource.org/licenses/bsd-license.php. \r
12 \r
13THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
d1f95000 15\r
5899caf0 16 @par Revision Reference: \r
af2dc6a7 17 This Protocol was introduced in UEFI Specification 2.0.\r
5899caf0 18\r
d1f95000 19**/\r
20\r
21#ifndef __EFI_DHCP4_PROTOCOL_H__\r
22#define __EFI_DHCP4_PROTOCOL_H__\r
23\r
24#define EFI_DHCP4_PROTOCOL_GUID \\r
25 { \\r
26 0x8a219718, 0x4ef5, 0x4761, {0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } \\r
27 }\r
28\r
29#define EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID \\r
30 { \\r
31 0x9d9a39d8, 0xbd42, 0x4a73, {0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } \\r
32 }\r
305a1279 33\r
d1f95000 34typedef struct _EFI_DHCP4_PROTOCOL EFI_DHCP4_PROTOCOL;\r
35\r
36\r
37#pragma pack(1)\r
38typedef struct {\r
74fec708
LG
39 ///\r
40 /// DHCP option code.\r
41 ///\r
d1f95000 42 UINT8 OpCode;\r
74fec708
LG
43 ///\r
44 /// Length of the DHCP option data. Not present if OpCode is 0 or 255.\r
45 ///\r
d1f95000 46 UINT8 Length;\r
74fec708
LG
47 ///\r
48 /// Start of the DHCP option data. Not present if OpCode is 0 or 255 or if Length is zero.\r
49 ///\r
d1f95000 50 UINT8 Data[1];\r
51} EFI_DHCP4_PACKET_OPTION;\r
52#pragma pack()\r
53\r
54\r
55#pragma pack(1)\r
74fec708
LG
56///\r
57/// EFI_DHCP4_PACKET defines the format of DHCPv4 packets. See RFC 2131 for more information.\r
58///\r
d1f95000 59typedef struct {\r
74fec708
LG
60 UINT8 OpCode;\r
61 UINT8 HwType;\r
62 UINT8 HwAddrLen;\r
63 UINT8 Hops;\r
64 UINT32 Xid;\r
65 UINT16 Seconds;\r
66 UINT16 Reserved;\r
af2dc6a7 67 EFI_IPv4_ADDRESS ClientAddr; ///< Client IP address from client.\r
68 EFI_IPv4_ADDRESS YourAddr; ///< Client IP address from server.\r
69 EFI_IPv4_ADDRESS ServerAddr; ///< IP address of next server in bootstrap.\r
70 EFI_IPv4_ADDRESS GatewayAddr; ///< Relay agent IP address.\r
71 UINT8 ClientHwAddr[16]; ///< Client hardware address.\r
74fec708
LG
72 CHAR8 ServerName[64];\r
73 CHAR8 BootFileName[128];\r
d1f95000 74}EFI_DHCP4_HEADER;\r
75#pragma pack()\r
76\r
77\r
78#pragma pack(1)\r
79typedef struct {\r
74fec708
LG
80 ///\r
81 /// Size of the EFI_DHCP4_PACKET buffer.\r
82 ///\r
d1f95000 83 UINT32 Size;\r
74fec708
LG
84 ///\r
85 /// Length of the EFI_DHCP4_PACKET from the first byte of the Header field \r
86 /// to the last byte of the Option[] field.\r
87 ///\r
d1f95000 88 UINT32 Length;\r
89\r
90 struct {\r
74fec708
LG
91 ///\r
92 /// DHCP packet header.\r
93 ///\r
d1f95000 94 EFI_DHCP4_HEADER Header;\r
74fec708
LG
95 ///\r
96 /// DHCP magik cookie in network byte order.\r
97 ///\r
d1f95000 98 UINT32 Magik;\r
74fec708
LG
99 ///\r
100 /// Start of the DHCP packed option data.\r
101 ///\r
d1f95000 102 UINT8 Option[1];\r
103 } Dhcp4;\r
104} EFI_DHCP4_PACKET;\r
105#pragma pack()\r
106\r
107\r
108typedef enum {\r
74fec708 109 ///\r
af2dc6a7 110 /// The EFI DHCPv4 Protocol driver is stopped.\r
74fec708 111 ///\r
d1f95000 112 Dhcp4Stopped = 0x0,\r
74fec708 113 ///\r
af2dc6a7 114 /// The EFI DHCPv4 Protocol driver is inactive.\r
74fec708 115 ///\r
d1f95000 116 Dhcp4Init = 0x1,\r
74fec708
LG
117 ///\r
118 /// The EFI DHCPv4 Protocol driver is collecting DHCP offer packets from DHCP servers.\r
119 ///\r
d1f95000 120 Dhcp4Selecting = 0x2,\r
74fec708
LG
121 ///\r
122 /// The EFI DHCPv4 Protocol driver has sent the request to the DHCP server and is waiting for a response.\r
123 ///\r
d1f95000 124 Dhcp4Requesting = 0x3,\r
74fec708
LG
125 ///\r
126 /// The DHCP configuration has completed.\r
127 ///\r
d1f95000 128 Dhcp4Bound = 0x4,\r
74fec708
LG
129 ///\r
130 /// The DHCP configuration is being renewed and another request has\r
131 /// been sent out, but it has not received a response from the server yet.\r
132 ///\r
d1f95000 133 Dhcp4Renewing = 0x5,\r
74fec708
LG
134 ///\r
135 /// The DHCP configuration has timed out and the EFI DHCPv4\r
136 /// Protocol driver is trying to extend the lease time.\r
137 ///\r
d1f95000 138 Dhcp4Rebinding = 0x6,\r
74fec708 139 ///\r
af2dc6a7 140 /// The EFI DHCPv4 Protocol driver was initialized with a previously\r
74fec708
LG
141 /// allocated or known IP address.\r
142 ///\r
d1f95000 143 Dhcp4InitReboot = 0x7,\r
74fec708
LG
144 ///\r
145 /// The EFI DHCPv4 Protocol driver is seeking to reuse the previously\r
146 /// allocated IP address by sending a request to the DHCP server.\r
147 ///\r
d1f95000 148 Dhcp4Rebooting = 0x8\r
149} EFI_DHCP4_STATE;\r
150\r
151\r
152typedef enum{\r
74fec708 153 ///\r
0acd6015 154 /// The packet to start the configuration sequence is about to be sent.\r
74fec708 155 ///\r
d1f95000 156 Dhcp4SendDiscover = 0x01,\r
74fec708 157 ///\r
0acd6015 158 /// A reply packet was just received.\r
74fec708 159 ///\r
d1f95000 160 Dhcp4RcvdOffer = 0x02,\r
74fec708
LG
161 ///\r
162 /// It is time for Dhcp4Callback to select an offer.\r
163 ///\r
d1f95000 164 Dhcp4SelectOffer = 0x03,\r
74fec708
LG
165 ///\r
166 /// A request packet is about to be sent.\r
167 ///\r
d1f95000 168 Dhcp4SendRequest = 0x04,\r
74fec708
LG
169 ///\r
170 /// A DHCPACK packet was received and will be passed to Dhcp4Callback.\r
171 ///\r
d1f95000 172 Dhcp4RcvdAck = 0x05,\r
74fec708
LG
173 ///\r
174 /// A DHCPNAK packet was received and will be passed to Dhcp4Callback.\r
175 ///\r
d1f95000 176 Dhcp4RcvdNak = 0x06,\r
74fec708
LG
177 ///\r
178 /// A decline packet is about to be sent.\r
179 ///\r
d1f95000 180 Dhcp4SendDecline = 0x07,\r
74fec708
LG
181 ///\r
182 /// The DHCP configuration process has completed. No packet is associated with this event.\r
183 ///\r
d1f95000 184 Dhcp4BoundCompleted = 0x08,\r
74fec708
LG
185 ///\r
186 /// It is time to enter the Dhcp4Renewing state and to contact the server \r
187 /// that originally issued the network address. No packet is associated with this event.\r
188 ///\r
d1f95000 189 Dhcp4EnterRenewing = 0x09,\r
74fec708
LG
190 ///\r
191 /// It is time to enter the Dhcp4Rebinding state and to contact any server. \r
192 /// No packet is associated with this event.\r
193 ///\r
d1f95000 194 Dhcp4EnterRebinding = 0x0a,\r
74fec708
LG
195 ///\r
196 /// The configured IP address was lost either because the lease has expired, \r
197 /// the user released the configuration, or a DHCPNAK packet was received in \r
198 /// the Dhcp4Renewing or Dhcp4Rebinding state. No packet is associated with this event.\r
199 ///\r
d1f95000 200 Dhcp4AddressLost = 0x0b,\r
74fec708
LG
201 ///\r
202 /// The DHCP process failed because a DHCPNAK packet was received or the user \r
203 /// aborted the DHCP process at a time when the configuration was not available yet. \r
204 /// No packet is associated with this event.\r
205 ///\r
d1f95000 206 Dhcp4Fail = 0x0c\r
207} EFI_DHCP4_EVENT;\r
208\r
305a1279 209/**\r
faac3f0c 210 Callback routine.\r
211 \r
212 EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver\r
213 to intercept events that occurred in the configuration process. This structure\r
214 provides advanced control of each state transition of the DHCP process. The\r
215 returned status code determines the behavior of the EFI DHCPv4 Protocol driver.\r
216 There are three possible returned values, which are described in the following\r
217 table.\r
305a1279 218\r
af2dc6a7 219 @param This The pointer to the EFI DHCPv4 Protocol instance that is used to\r
305a1279 220 configure this callback function.\r
af2dc6a7 221 @param Context The pointer to the context that is initialized by\r
305a1279 222 EFI_DHCP4_PROTOCOL.Configure().\r
d1f95000 223 @param CurrentState The current operational state of the EFI DHCPv4 Protocol\r
305a1279 224 driver.\r
d1f95000 225 @param Dhcp4Event The event that occurs in the current state, which usually means a\r
305a1279 226 state transition.\r
227 @param Packet The DHCP packet that is going to be sent or already received.\r
d1f95000 228 @param NewPacket The packet that is used to replace the above Packet.\r
305a1279 229\r
d1f95000 230 @retval EFI_SUCCESS Tells the EFI DHCPv4 Protocol driver to continue the DHCP process.\r
0acd6015 231 When it is in the Dhcp4Selecting state, it tells the EFI DHCPv4 Protocol\r
232 driver to stop collecting additional packets. The driver will exit\r
233 the Dhcp4Selecting state and enter the Dhcp4Requesting state.\r
305a1279 234 @retval EFI_NOT_READY Only used in the Dhcp4Selecting state. The EFI DHCPv4 Protocol\r
0acd6015 235 driver will continue to wait for more packets until the retry\r
305a1279 236 timeout expires.\r
d1f95000 237 @retval EFI_ABORTED Tells the EFI DHCPv4 Protocol driver to abort the current process and\r
305a1279 238 return to the Dhcp4Init or Dhcp4InitReboot state.\r
239\r
d1f95000 240**/\r
305a1279 241typedef\r
242EFI_STATUS\r
8b13229b 243(EFIAPI *EFI_DHCP4_CALLBACK)(\r
d1f95000 244 IN EFI_DHCP4_PROTOCOL *This,\r
245 IN VOID *Context,\r
246 IN EFI_DHCP4_STATE CurrentState,\r
247 IN EFI_DHCP4_EVENT Dhcp4Event,\r
305a1279 248 IN EFI_DHCP4_PACKET *Packet OPTIONAL,\r
d1f95000 249 OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL\r
250 );\r
251\r
d1f95000 252typedef struct {\r
74fec708 253 ///\r
af2dc6a7 254 /// The number of times to try sending a packet during the Dhcp4SendDiscover\r
0acd6015 255 /// event and waiting for a response during the Dhcp4RcvdOffer event.\r
74fec708
LG
256 /// Set to zero to use the default try counts and timeout values.\r
257 ///\r
305a1279 258 UINT32 DiscoverTryCount;\r
74fec708 259 ///\r
af2dc6a7 260 /// The maximum amount of time (in seconds) to wait for returned packets in each \r
74fec708
LG
261 /// of the retries. Timeout values of zero will default to a timeout value \r
262 /// of one second. Set to NULL to use default timeout values.\r
263 ///\r
d1f95000 264 UINT32 *DiscoverTimeout;\r
74fec708 265 ///\r
af2dc6a7 266 /// The number of times to try sending a packet during the Dhcp4SendRequest event\r
0acd6015 267 /// and waiting for a response during the Dhcp4RcvdAck event before accepting\r
268 /// failure. Set to zero to use the default try counts and timeout values.\r
74fec708 269 ///\r
d1f95000 270 UINT32 RequestTryCount;\r
74fec708 271 ///\r
af2dc6a7 272 /// The maximum amount of time (in seconds) to wait for return packets in each of the retries. \r
74fec708
LG
273 /// Timeout values of zero will default to a timeout value of one second. \r
274 /// Set to NULL to use default timeout values.\r
275 ///\r
d1f95000 276 UINT32 *RequestTimeout;\r
74fec708 277 ///\r
0acd6015 278 /// For a DHCPDISCOVER, setting this parameter to the previously allocated IP\r
279 /// address will cause the EFI DHCPv4 Protocol driver to enter the Dhcp4InitReboot state. \r
280 /// And set this field to 0.0.0.0 to enter the Dhcp4Init state.\r
281 /// For a DHCPINFORM this parameter should be set to the client network address\r
282 /// which was assigned to the client during a DHCPDISCOVER.\r
74fec708 283 ///\r
d1f95000 284 EFI_IPv4_ADDRESS ClientAddress;\r
74fec708
LG
285 ///\r
286 /// The callback function to intercept various events that occurred in \r
287 /// the DHCP configuration process. Set to NULL to ignore all those events.\r
288 ///\r
d1f95000 289 EFI_DHCP4_CALLBACK Dhcp4Callback;\r
74fec708 290 ///\r
af2dc6a7 291 /// The pointer to the context that will be passed to Dhcp4Callback when it is called.\r
74fec708
LG
292 ///\r
293 VOID *CallbackContext;\r
294 ///\r
295 /// Number of DHCP options in the OptionList.\r
296 ///\r
d1f95000 297 UINT32 OptionCount;\r
74fec708 298 ///\r
0acd6015 299 /// List of DHCP options to be included in every packet that is sent during the\r
300 /// Dhcp4SendDiscover event. Pad options are appended automatically by DHCP driver\r
301 /// in outgoing DHCP packets. If OptionList itself contains pad option, they are\r
302 /// ignored by the driver. OptionList can be freed after EFI_DHCP4_PROTOCOL.Configure()\r
303 /// returns. Ignored if OptionCount is zero.\r
74fec708 304 ///\r
d1f95000 305 EFI_DHCP4_PACKET_OPTION **OptionList;\r
306} EFI_DHCP4_CONFIG_DATA;\r
307\r
308\r
309typedef struct {\r
74fec708
LG
310 ///\r
311 /// The EFI DHCPv4 Protocol driver operating state. \r
312 ///\r
d1f95000 313 EFI_DHCP4_STATE State;\r
74fec708
LG
314 ///\r
315 /// The configuration data of the current EFI DHCPv4 Protocol driver instance.\r
316 ///\r
d1f95000 317 EFI_DHCP4_CONFIG_DATA ConfigData;\r
74fec708
LG
318 ///\r
319 /// The client IP address that was acquired from the DHCP server. If it is zero,\r
320 /// the DHCP acquisition has not completed yet and the following fields in this structure are undefined.\r
321 ///\r
d1f95000 322 EFI_IPv4_ADDRESS ClientAddress;\r
74fec708
LG
323 ///\r
324 /// The local hardware address.\r
325 ///\r
d1f95000 326 EFI_MAC_ADDRESS ClientMacAddress;\r
74fec708
LG
327 ///\r
328 /// The server IP address that is providing the DHCP service to this client.\r
329 ///\r
d1f95000 330 EFI_IPv4_ADDRESS ServerAddress;\r
74fec708
LG
331 ///\r
332 /// The router IP address that was acquired from the DHCP server. \r
333 /// May be zero if the server does not offer this address.\r
334 ///\r
d1f95000 335 EFI_IPv4_ADDRESS RouterAddress;\r
74fec708
LG
336 ///\r
337 /// The subnet mask of the connected network that was acquired from the DHCP server.\r
338 ///\r
d1f95000 339 EFI_IPv4_ADDRESS SubnetMask;\r
74fec708
LG
340 ///\r
341 /// The lease time (in 1-second units) of the configured IP address. \r
342 /// The value 0xFFFFFFFF means that the lease time is infinite. \r
343 /// A default lease of 7 days is used if the DHCP server does not provide a value.\r
344 ///\r
d1f95000 345 UINT32 LeaseTime;\r
74fec708
LG
346 ///\r
347 /// The cached latest DHCPACK or DHCPNAK or BOOTP REPLY packet. May be NULL if no packet is cached.\r
348 ///\r
d1f95000 349 EFI_DHCP4_PACKET *ReplyPacket;\r
350} EFI_DHCP4_MODE_DATA;\r
351\r
352\r
353typedef struct {\r
74fec708
LG
354 ///\r
355 /// Alternate listening address. It can be a unicast, multicast, or broadcast address.\r
356 ///\r
d1f95000 357 EFI_IPv4_ADDRESS ListenAddress;\r
74fec708
LG
358 ///\r
359 /// The subnet mask of above listening unicast/broadcast IP address. \r
360 /// Ignored if ListenAddress is a multicast address.\r
361 ///\r
d1f95000 362 EFI_IPv4_ADDRESS SubnetMask;\r
74fec708
LG
363 ///\r
364 /// Alternate station source (or listening) port number. \r
365 /// If zero, then the default station port number (68) will be used.\r
366 ///\r
d1f95000 367 UINT16 ListenPort;\r
368} EFI_DHCP4_LISTEN_POINT;\r
369\r
370\r
371typedef struct {\r
74fec708
LG
372 ///\r
373 /// The completion status of transmitting and receiving.\r
374 ///\r
305a1279 375 EFI_STATUS Status;\r
74fec708
LG
376 ///\r
377 /// If not NULL, the event that will be signaled when the collection process \r
378 /// completes. If NULL, this function will busy-wait until the collection process competes.\r
379 ///\r
305a1279 380 EFI_EVENT CompletionEvent;\r
74fec708 381 ///\r
af2dc6a7 382 /// The pointer to the server IP address. This address may be a unicast, multicast, or broadcast address.\r
74fec708 383 ///\r
305a1279 384 EFI_IPv4_ADDRESS RemoteAddress;\r
74fec708 385 ///\r
af2dc6a7 386 /// The server listening port number. If zero, the default server listening port number (67) will be used.\r
74fec708 387 ///\r
305a1279 388 UINT16 RemotePort;\r
74fec708 389 ///\r
af2dc6a7 390 /// The pointer to the gateway address to override the existing setting.\r
74fec708 391 ///\r
305a1279 392 EFI_IPv4_ADDRESS GatewayAddress;\r
74fec708
LG
393 ///\r
394 /// The number of entries in ListenPoints. If zero, the default station address and port number 68 are used.\r
395 ///\r
305a1279 396 UINT32 ListenPointCount;\r
74fec708
LG
397 ///\r
398 /// An array of station address and port number pairs that are used as receiving filters. \r
399 /// The first entry is also used as the source address and source port of the outgoing packet.\r
400 ///\r
305a1279 401 EFI_DHCP4_LISTEN_POINT *ListenPoints;\r
74fec708 402 ///\r
af2dc6a7 403 /// The number of seconds to collect responses. Zero is invalid.\r
74fec708 404 ///\r
305a1279 405 UINT32 TimeoutValue;\r
74fec708 406 ///\r
af2dc6a7 407 /// The pointer to the packet to be transmitted.\r
74fec708 408 ///\r
305a1279 409 EFI_DHCP4_PACKET *Packet;\r
74fec708
LG
410 ///\r
411 /// Number of received packets.\r
412 ///\r
305a1279 413 UINT32 ResponseCount;\r
74fec708 414 ///\r
af2dc6a7 415 /// The pointer to the allocated list of received packets.\r
74fec708 416 ///\r
305a1279 417 EFI_DHCP4_PACKET *ResponseList;\r
d1f95000 418} EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN;\r
419\r
420\r
421/**\r
422 Returns the current operating mode and cached data packet for the EFI DHCPv4 Protocol driver.\r
faac3f0c 423 \r
424 The GetModeData() function returns the current operating mode and cached data\r
425 packet for the EFI DHCPv4 Protocol driver.\r
d1f95000 426\r
af2dc6a7 427 @param This The pointer to the EFI_DHCP4_PROTOCOL instance.\r
428 @param Dhcp4ModeData The pointer to storage for the EFI_DHCP4_MODE_DATA structure.\r
d1f95000 429\r
430 @retval EFI_SUCCESS The mode data was returned.\r
431 @retval EFI_INVALID_PARAMETER This is NULL.\r
432\r
433**/\r
305a1279 434typedef\r
435EFI_STATUS\r
8b13229b 436(EFIAPI *EFI_DHCP4_GET_MODE_DATA)(\r
d1f95000 437 IN EFI_DHCP4_PROTOCOL *This,\r
438 OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData\r
ed66e1bc 439 );\r
d1f95000 440\r
441/**\r
442 Initializes, changes, or resets the operational settings for the EFI DHCPv4 Protocol driver.\r
443\r
faac3f0c 444 The Configure() function is used to initialize, change, or reset the operational\r
445 settings of the EFI DHCPv4 Protocol driver for the communication device on which\r
446 the EFI DHCPv4 Service Binding Protocol is installed. This function can be\r
447 successfully called only if both of the following are true:\r
448 * This instance of the EFI DHCPv4 Protocol driver is in the Dhcp4Stopped, Dhcp4Init,\r
449 Dhcp4InitReboot, or Dhcp4Bound states.\r
450 * No other EFI DHCPv4 Protocol driver instance that is controlled by this EFI\r
451 DHCPv4 Service Binding Protocol driver instance has configured this EFI DHCPv4\r
452 Protocol driver.\r
453 When this driver is in the Dhcp4Stopped state, it can transfer into one of the\r
454 following two possible initial states:\r
455 * Dhcp4Init\r
af2dc6a7 456 * Dhcp4InitReboot.\r
faac3f0c 457 The driver can transfer into these states by calling Configure() with a non-NULL\r
458 Dhcp4CfgData. The driver will transfer into the appropriate state based on the\r
459 supplied client network address in the ClientAddress parameter and DHCP options\r
460 in the OptionList parameter as described in RFC 2131.\r
461 When Configure() is called successfully while Dhcp4CfgData is set to NULL, the\r
462 default configuring data will be reset in the EFI DHCPv4 Protocol driver and\r
463 the state of the EFI DHCPv4 Protocol driver will not be changed. If one instance\r
464 wants to make it possible for another instance to configure the EFI DHCPv4 Protocol\r
465 driver, it must call this function with Dhcp4CfgData set to NULL.\r
466\r
af2dc6a7 467 @param This The pointer to the EFI_DHCP4_PROTOCOL instance.\r
468 @param Dhcp4CfgData The pointer to the EFI_DHCP4_CONFIG_DATA.\r
d1f95000 469\r
470 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the Dhcp4Init or\r
471 Dhcp4InitReboot state, if the original state of this driver\r
0acd6015 472 was Dhcp4Stopped, Dhcp4Init,Dhcp4InitReboot, or Dhcp4Bound\r
473 and the value of Dhcp4CfgData was not NULL.\r
474 Otherwise, the state was left unchanged.\r
d1f95000 475 @retval EFI_ACCESS_DENIED This instance of the EFI DHCPv4 Protocol driver was not in the\r
476 Dhcp4Stopped, Dhcp4Init, Dhcp4InitReboot, or Dhcp4Bound state;\r
477 Or onother instance of this EFI DHCPv4 Protocol driver is already\r
478 in a valid configured state.\r
74fec708
LG
479 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r
480 This is NULL.\r
481 DiscoverTryCount > 0 and DiscoverTimeout is NULL\r
482 RequestTryCount > 0 and RequestTimeout is NULL.\r
483 OptionCount >0 and OptionList is NULL.\r
484 ClientAddress is not a valid unicast address.\r
d1f95000 485 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
486 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
487\r
488**/\r
305a1279 489typedef\r
d1f95000 490EFI_STATUS\r
8b13229b 491(EFIAPI *EFI_DHCP4_CONFIGURE)(\r
d1f95000 492 IN EFI_DHCP4_PROTOCOL *This,\r
493 IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData OPTIONAL\r
ed66e1bc 494 );\r
d1f95000 495\r
496\r
497/**\r
498 Starts the DHCP configuration process.\r
499\r
faac3f0c 500 The Start() function starts the DHCP configuration process. This function can\r
501 be called only when the EFI DHCPv4 Protocol driver is in the Dhcp4Init or\r
502 Dhcp4InitReboot state.\r
503 If the DHCP process completes successfully, the state of the EFI DHCPv4 Protocol\r
504 driver will be transferred through Dhcp4Selecting and Dhcp4Requesting to the\r
505 Dhcp4Bound state. The CompletionEvent will then be signaled if it is not NULL.\r
506 If the process aborts, either by the user or by some unexpected network error,\r
507 the state is restored to the Dhcp4Init state. The Start() function can be called\r
508 again to restart the process.\r
509 Refer to RFC 2131 for precise state transitions during this process. At the\r
510 time when each event occurs in this process, the callback function that was set\r
511 by EFI_DHCP4_PROTOCOL.Configure() will be called and the user can take this\r
512 opportunity to control the process.\r
513 \r
af2dc6a7 514 @param This The pointer to the EFI_DHCP4_PROTOCOL instance.\r
515 @param CompletionEvent If not NULL, it indicates the event that will be signaled when the\r
d1f95000 516 EFI DHCPv4 Protocol driver is transferred into the\r
517 Dhcp4Bound state or when the DHCP process is aborted.\r
518 EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
519 check the completion status. If NULL,\r
520 EFI_DHCP4_PROTOCOL.Start() will wait until the driver\r
521 is transferred into the Dhcp4Bound state or the process fails.\r
522\r
523 @retval EFI_SUCCESS The DHCP configuration process has started, or it has completed\r
524 when CompletionEvent is NULL.\r
525 @retval EFI_NOT_STARTED The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped\r
526 state. EFI_DHCP4_PROTOCOL. Configure() needs to be called.\r
527 @retval EFI_INVALID_PARAMETER This is NULL.\r
528 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
529 @retval EFI_TIMEOUT The DHCP configuration process failed because no response was\r
530 received from the server within the specified timeout value.\r
531 @retval EFI_ABORTED The user aborted the DHCP process.\r
532 @retval EFI_ALREADY_STARTED Some other EFI DHCPv4 Protocol instance already started the\r
533 DHCP process.\r
534 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
c5c3e7e2 535 @retval EFI_NO_MEDIA There was a media error.\r
d1f95000 536\r
537**/\r
305a1279 538typedef\r
d1f95000 539EFI_STATUS\r
8b13229b 540(EFIAPI *EFI_DHCP4_START)(\r
d1f95000 541 IN EFI_DHCP4_PROTOCOL *This,\r
542 IN EFI_EVENT CompletionEvent OPTIONAL\r
ed66e1bc 543 );\r
d1f95000 544\r
545/**\r
546 Extends the lease time by sending a request packet.\r
faac3f0c 547 \r
548 The RenewRebind() function is used to manually extend the lease time when the\r
af2dc6a7 549 EFI DHCPv4 Protocol driver is in the Dhcp4Bound state, and the lease time has\r
faac3f0c 550 not expired yet. This function will send a request packet to the previously\r
551 found server (or to any server when RebindRequest is TRUE) and transfer the\r
552 state into the Dhcp4Renewing state (or Dhcp4Rebinding when RebindingRequest is\r
553 TRUE). When a response is received, the state is returned to Dhcp4Bound.\r
554 If no response is received before the try count is exceeded (the RequestTryCount\r
555 field that is specified in EFI_DHCP4_CONFIG_DATA) but before the lease time that\r
556 was issued by the previous server expires, the driver will return to the Dhcp4Bound\r
af2dc6a7 557 state, and the previous configuration is restored. The outgoing and incoming packets\r
faac3f0c 558 can be captured by the EFI_DHCP4_CALLBACK function.\r
d1f95000 559\r
af2dc6a7 560 @param This The pointer to the EFI_DHCP4_PROTOCOL instance.\r
d1f95000 561 @param RebindRequest If TRUE, this function broadcasts the request packets and enters\r
562 the Dhcp4Rebinding state. Otherwise, it sends a unicast\r
563 request packet and enters the Dhcp4Renewing state.\r
564 @param CompletionEvent If not NULL, this event is signaled when the renew/rebind phase\r
565 completes or some error occurs.\r
566 EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
567 check the completion status. If NULL,\r
568 EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait\r
569 until the DHCP process finishes.\r
570\r
571 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the\r
572 Dhcp4Renewing state or is back to the Dhcp4Bound state.\r
573 @retval EFI_NOT_STARTED The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped\r
574 state. EFI_DHCP4_PROTOCOL.Configure() needs to\r
575 be called.\r
576 @retval EFI_INVALID_PARAMETER This is NULL.\r
577 @retval EFI_TIMEOUT There was no response from the server when the try count was\r
578 exceeded.\r
579 @retval EFI_ACCESS_DENIED The driver is not in the Dhcp4Bound state.\r
580 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
581\r
582**/\r
583typedef\r
584EFI_STATUS\r
8b13229b 585(EFIAPI *EFI_DHCP4_RENEW_REBIND)(\r
d1f95000 586 IN EFI_DHCP4_PROTOCOL *This,\r
587 IN BOOLEAN RebindRequest,\r
588 IN EFI_EVENT CompletionEvent OPTIONAL\r
ed66e1bc 589 );\r
d1f95000 590\r
591/**\r
592 Releases the current address configuration.\r
593\r
faac3f0c 594 The Release() function releases the current configured IP address by doing either\r
595 of the following:\r
596 * Sending a DHCPRELEASE packet when the EFI DHCPv4 Protocol driver is in the\r
597 Dhcp4Bound state\r
598 * Setting the previously assigned IP address that was provided with the\r
599 EFI_DHCP4_PROTOCOL.Configure() function to 0.0.0.0 when the driver is in\r
600 Dhcp4InitReboot state\r
601 After a successful call to this function, the EFI DHCPv4 Protocol driver returns\r
af2dc6a7 602 to the Dhcp4Init state, and any subsequent incoming packets will be discarded silently.\r
faac3f0c 603\r
af2dc6a7 604 @param This The pointer to the EFI_DHCP4_PROTOCOL instance.\r
d1f95000 605\r
606 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the Dhcp4Init phase.\r
607 @retval EFI_INVALID_PARAMETER This is NULL.\r
608 @retval EFI_ACCESS_DENIED The EFI DHCPv4 Protocol driver is not Dhcp4InitReboot state.\r
609 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
610\r
611**/\r
305a1279 612typedef\r
d1f95000 613EFI_STATUS\r
8b13229b 614(EFIAPI *EFI_DHCP4_RELEASE)(\r
d1f95000 615 IN EFI_DHCP4_PROTOCOL *This\r
ed66e1bc 616 );\r
d1f95000 617\r
618/**\r
619 Stops the current address configuration.\r
faac3f0c 620 \r
621 The Stop() function is used to stop the DHCP configuration process. After this\r
622 function is called successfully, the EFI DHCPv4 Protocol driver is transferred\r
623 into the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL.Configure() needs to be called\r
624 before DHCP configuration process can be started again. This function can be\r
625 called when the EFI DHCPv4 Protocol driver is in any state.\r
d1f95000 626\r
af2dc6a7 627 @param This The pointer to the EFI_DHCP4_PROTOCOL instance.\r
305a1279 628\r
d1f95000 629 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the Dhcp4Stopped phase.\r
630 @retval EFI_INVALID_PARAMETER This is NULL.\r
631\r
632**/\r
305a1279 633typedef\r
d1f95000 634EFI_STATUS\r
8b13229b 635(EFIAPI *EFI_DHCP4_STOP)(\r
d1f95000 636 IN EFI_DHCP4_PROTOCOL *This\r
ed66e1bc 637 );\r
d1f95000 638\r
639/**\r
640 Builds a DHCP packet, given the options to be appended or deleted or replaced.\r
641\r
faac3f0c 642 The Build() function is used to assemble a new packet from the original packet\r
643 by replacing or deleting existing options or appending new options. This function\r
644 does not change any state of the EFI DHCPv4 Protocol driver and can be used at\r
645 any time.\r
646\r
af2dc6a7 647 @param This The pointer to the EFI_DHCP4_PROTOCOL instance.\r
eecd469b 648 @param SeedPacket Initial packet to be used as a base for building new packet.\r
d1f95000 649 @param DeleteCount Number of opcodes in the DeleteList.\r
650 @param DeleteList List of opcodes to be deleted from the seed packet.\r
651 Ignored if DeleteCount is zero.\r
652 @param AppendCount Number of entries in the OptionList.\r
af2dc6a7 653 @param AppendList The pointer to a DHCP option list to be appended to SeedPacket.\r
d1f95000 654 If SeedPacket also contains options in this list, they are\r
655 replaced by new options (except pad option). Ignored if\r
656 AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION\r
af2dc6a7 657 @param NewPacket The pointer to storage for the pointer to the new allocated packet.\r
d1f95000 658 Use the EFI Boot Service FreePool() on the resulting pointer\r
659 when done with the packet.\r
660\r
661 @retval EFI_SUCCESS The new packet was built.\r
662 @retval EFI_OUT_OF_RESOURCES Storage for the new packet could not be allocated.\r
74fec708
LG
663 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
664 This is NULL.\r
665 SeedPacket is NULL.\r
666 SeedPacket is not a well-formed DHCP packet.\r
667 AppendCount is not zero and AppendList is NULL.\r
668 DeleteCount is not zero and DeleteList is NULL.\r
669 NewPacket is NULL\r
670 Both DeleteCount and AppendCount are zero and\r
671 NewPacket is not NULL.\r
d1f95000 672\r
673**/\r
674typedef\r
675EFI_STATUS\r
8b13229b 676(EFIAPI *EFI_DHCP4_BUILD)(\r
d1f95000 677 IN EFI_DHCP4_PROTOCOL *This,\r
678 IN EFI_DHCP4_PACKET *SeedPacket,\r
679 IN UINT32 DeleteCount,\r
680 IN UINT8 *DeleteList OPTIONAL,\r
681 IN UINT32 AppendCount,\r
682 IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,\r
683 OUT EFI_DHCP4_PACKET **NewPacket\r
ed66e1bc 684 );\r
faac3f0c 685\r
686\r
d1f95000 687/**\r
688 Transmits a DHCP formatted packet and optionally waits for responses.\r
faac3f0c 689 \r
690 The TransmitReceive() function is used to transmit a DHCP packet and optionally\r
691 wait for the response from servers. This function does not change the state of\r
af2dc6a7 692 the EFI DHCPv4 Protocol driver. It can be used at any time because of this.\r
d1f95000 693\r
af2dc6a7 694 @param This The pointer to the EFI_DHCP4_PROTOCOL instance.\r
695 @param Token The pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure.\r
d1f95000 696\r
697 @retval EFI_SUCCESS The packet was successfully queued for transmission.\r
74fec708
LG
698 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
699 This is NULL.\r
700 Token.RemoteAddress is zero.\r
701 Token.Packet is NULL.\r
702 Token.Packet is not a well-formed DHCP packet.\r
703 The transaction ID in Token.Packet is in use by another DHCP process.\r
d1f95000 704 @retval EFI_NOT_READY The previous call to this function has not finished yet. Try to call\r
705 this function after collection process completes.\r
706 @retval EFI_NO_MAPPING The default station address is not available yet.\r
707 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
ff7630cc 708 @retval EFI_UNSUPPORTED The implementation doesn't support this function\r
d1f95000 709 @retval Others Some other unexpected error occurred.\r
710\r
711**/\r
305a1279 712typedef\r
d1f95000 713EFI_STATUS\r
8b13229b 714(EFIAPI *EFI_DHCP4_TRANSMIT_RECEIVE)(\r
d1f95000 715 IN EFI_DHCP4_PROTOCOL *This,\r
716 IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token\r
ed66e1bc 717 );\r
d1f95000 718\r
719\r
720/**\r
721 Parses the packed DHCP option data.\r
faac3f0c 722 \r
723 The Parse() function is used to retrieve the option list from a DHCP packet.\r
ff7630cc 724 If *OptionCount isn't zero, and there is enough space for all the DHCP options\r
faac3f0c 725 in the Packet, each element of PacketOptionList is set to point to somewhere in\r
726 the Packet->Dhcp4.Option where a new DHCP option begins. If RFC3396 is supported,\r
630b4187 727 the caller should reassemble the parsed DHCP options to get the final result.\r
ff7630cc 728 If *OptionCount is zero or there isn't enough space for all of them, the number\r
faac3f0c 729 of DHCP options in the Packet is returned in OptionCount.\r
d1f95000 730\r
af2dc6a7 731 @param This The pointer to the EFI_DHCP4_PROTOCOL instance.\r
732 @param Packet The pointer to packet to be parsed.\r
d1f95000 733 @param OptionCount On input, the number of entries in the PacketOptionList.\r
734 On output, the number of entries that were written into the\r
735 PacketOptionList.\r
af2dc6a7 736 @param PacketOptionList A list of packet option entries to be filled in. End option or pad\r
d1f95000 737 options are not included.\r
738\r
739 @retval EFI_SUCCESS The packet was successfully parsed.\r
74fec708
LG
740 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
741 This is NULL.\r
af2dc6a7 742 The packet is NULL.\r
743 The packet is not a well-formed DHCP packet.\r
74fec708 744 OptionCount is NULL.\r
d1f95000 745 @retval EFI_BUFFER_TOO_SMALL One or more of the following conditions is TRUE:\r
746 1) *OptionCount is smaller than the number of options that\r
747 were found in the Packet.\r
748 2) PacketOptionList is NULL.\r
af2dc6a7 749 @retval EFI_OUT_OF_RESOURCE The packet failed to parse because of a resource shortage.\r
d1f95000 750\r
751**/\r
752typedef\r
753EFI_STATUS\r
8b13229b 754(EFIAPI *EFI_DHCP4_PARSE)(\r
d1f95000 755 IN EFI_DHCP4_PROTOCOL *This,\r
756 IN EFI_DHCP4_PACKET *Packet,\r
757 IN OUT UINT32 *OptionCount,\r
758 OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL\r
ed66e1bc 759 );\r
d1f95000 760\r
44717a39 761///\r
762/// This protocol is used to collect configuration information for the EFI IPv4 Protocol drivers\r
763/// and to provide DHCPv4 server and PXE boot server discovery services.\r
764///\r
d1f95000 765struct _EFI_DHCP4_PROTOCOL {\r
766 EFI_DHCP4_GET_MODE_DATA GetModeData;\r
767 EFI_DHCP4_CONFIGURE Configure;\r
768 EFI_DHCP4_START Start;\r
769 EFI_DHCP4_RENEW_REBIND RenewRebind;\r
770 EFI_DHCP4_RELEASE Release;\r
771 EFI_DHCP4_STOP Stop;\r
772 EFI_DHCP4_BUILD Build;\r
773 EFI_DHCP4_TRANSMIT_RECEIVE TransmitReceive;\r
774 EFI_DHCP4_PARSE Parse;\r
775};\r
776\r
777extern EFI_GUID gEfiDhcp4ProtocolGuid;\r
778extern EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid;\r
779\r
780#endif\r