]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/Dhcp4.h
Formalize comments for Protocols and PPIs.
[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
4ca9b6c4 7 Copyright (c) 2006 - 2008, Intel Corporation\r
305a1279 8 All rights reserved. This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
d1f95000 12\r
305a1279 13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
d1f95000 15\r
d1f95000 16**/\r
17\r
18#ifndef __EFI_DHCP4_PROTOCOL_H__\r
19#define __EFI_DHCP4_PROTOCOL_H__\r
20\r
21#define EFI_DHCP4_PROTOCOL_GUID \\r
22 { \\r
23 0x8a219718, 0x4ef5, 0x4761, {0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } \\r
24 }\r
25\r
26#define EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID \\r
27 { \\r
28 0x9d9a39d8, 0xbd42, 0x4a73, {0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } \\r
29 }\r
305a1279 30\r
d1f95000 31typedef struct _EFI_DHCP4_PROTOCOL EFI_DHCP4_PROTOCOL;\r
32\r
33\r
34#pragma pack(1)\r
35typedef struct {\r
36 UINT8 OpCode;\r
37 UINT8 Length;\r
38 UINT8 Data[1];\r
39} EFI_DHCP4_PACKET_OPTION;\r
40#pragma pack()\r
41\r
42\r
43#pragma pack(1)\r
44typedef struct {\r
45 UINT8 OpCode;\r
46 UINT8 HwType;\r
47 UINT8 HwAddrLen;\r
48 UINT8 Hops;\r
49 UINT32 Xid;\r
50 UINT16 Seconds;\r
51 UINT16 Reserved;\r
3354353d 52 EFI_IPv4_ADDRESS ClientAddr; ///< Client IP address from client\r
53 EFI_IPv4_ADDRESS YourAddr; ///< Client IP address from server\r
54 EFI_IPv4_ADDRESS ServerAddr; ///< IP address of next server in bootstrap\r
55 EFI_IPv4_ADDRESS GatewayAddr; ///< Relay agent IP address\r
56 UINT8 ClientHwAddr[16]; ///< Client hardware address\r
305a1279 57 CHAR8 ServerName[64];\r
d1f95000 58 CHAR8 BootFileName[128];\r
59}EFI_DHCP4_HEADER;\r
60#pragma pack()\r
61\r
62\r
63#pragma pack(1)\r
64typedef struct {\r
65 UINT32 Size;\r
66 UINT32 Length;\r
67\r
68 struct {\r
69 EFI_DHCP4_HEADER Header;\r
70 UINT32 Magik;\r
71 UINT8 Option[1];\r
72 } Dhcp4;\r
73} EFI_DHCP4_PACKET;\r
74#pragma pack()\r
75\r
76\r
77typedef enum {\r
78 Dhcp4Stopped = 0x0,\r
79 Dhcp4Init = 0x1,\r
80 Dhcp4Selecting = 0x2,\r
81 Dhcp4Requesting = 0x3,\r
82 Dhcp4Bound = 0x4,\r
83 Dhcp4Renewing = 0x5,\r
84 Dhcp4Rebinding = 0x6,\r
85 Dhcp4InitReboot = 0x7,\r
86 Dhcp4Rebooting = 0x8\r
87} EFI_DHCP4_STATE;\r
88\r
89\r
90typedef enum{\r
91 Dhcp4SendDiscover = 0x01,\r
92 Dhcp4RcvdOffer = 0x02,\r
93 Dhcp4SelectOffer = 0x03,\r
94 Dhcp4SendRequest = 0x04,\r
95 Dhcp4RcvdAck = 0x05,\r
96 Dhcp4RcvdNak = 0x06,\r
97 Dhcp4SendDecline = 0x07,\r
98 Dhcp4BoundCompleted = 0x08,\r
99 Dhcp4EnterRenewing = 0x09,\r
100 Dhcp4EnterRebinding = 0x0a,\r
101 Dhcp4AddressLost = 0x0b,\r
102 Dhcp4Fail = 0x0c\r
103} EFI_DHCP4_EVENT;\r
104\r
305a1279 105/**\r
106 Callback routine\r
107\r
d1f95000 108 @param This Pointer to the EFI DHCPv4 Protocol instance that is used to\r
305a1279 109 configure this callback function.\r
d1f95000 110 @param Context Pointer to the context that is initialized by\r
305a1279 111 EFI_DHCP4_PROTOCOL.Configure().\r
d1f95000 112 @param CurrentState The current operational state of the EFI DHCPv4 Protocol\r
305a1279 113 driver.\r
d1f95000 114 @param Dhcp4Event The event that occurs in the current state, which usually means a\r
305a1279 115 state transition.\r
116 @param Packet The DHCP packet that is going to be sent or already received.\r
d1f95000 117 @param NewPacket The packet that is used to replace the above Packet.\r
305a1279 118\r
d1f95000 119 @retval EFI_SUCCESS Tells the EFI DHCPv4 Protocol driver to continue the DHCP process.\r
305a1279 120 @retval EFI_NOT_READY Only used in the Dhcp4Selecting state. The EFI DHCPv4 Protocol\r
d1f95000 121 driver will continue to wait for more DHCPOFFER packets until the retry\r
305a1279 122 timeout expires.\r
d1f95000 123 @retval EFI_ABORTED Tells the EFI DHCPv4 Protocol driver to abort the current process and\r
305a1279 124 return to the Dhcp4Init or Dhcp4InitReboot state.\r
125\r
d1f95000 126**/\r
305a1279 127typedef\r
128EFI_STATUS\r
8b13229b 129(EFIAPI *EFI_DHCP4_CALLBACK)(\r
d1f95000 130 IN EFI_DHCP4_PROTOCOL *This,\r
131 IN VOID *Context,\r
132 IN EFI_DHCP4_STATE CurrentState,\r
133 IN EFI_DHCP4_EVENT Dhcp4Event,\r
305a1279 134 IN EFI_DHCP4_PACKET *Packet OPTIONAL,\r
d1f95000 135 OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL\r
136 );\r
137\r
138\r
139typedef struct {\r
305a1279 140 UINT32 DiscoverTryCount;\r
d1f95000 141 UINT32 *DiscoverTimeout;\r
142 UINT32 RequestTryCount;\r
143 UINT32 *RequestTimeout;\r
144 EFI_IPv4_ADDRESS ClientAddress;\r
145 EFI_DHCP4_CALLBACK Dhcp4Callback;\r
146 void *CallbackContext;\r
147 UINT32 OptionCount;\r
148 EFI_DHCP4_PACKET_OPTION **OptionList;\r
149} EFI_DHCP4_CONFIG_DATA;\r
150\r
151\r
152typedef struct {\r
153 EFI_DHCP4_STATE State;\r
154 EFI_DHCP4_CONFIG_DATA ConfigData;\r
155 EFI_IPv4_ADDRESS ClientAddress;\r
156 EFI_MAC_ADDRESS ClientMacAddress;\r
157 EFI_IPv4_ADDRESS ServerAddress;\r
158 EFI_IPv4_ADDRESS RouterAddress;\r
159 EFI_IPv4_ADDRESS SubnetMask;\r
160 UINT32 LeaseTime;\r
161 EFI_DHCP4_PACKET *ReplyPacket;\r
162} EFI_DHCP4_MODE_DATA;\r
163\r
164\r
165typedef struct {\r
166 EFI_IPv4_ADDRESS ListenAddress;\r
167 EFI_IPv4_ADDRESS SubnetMask;\r
168 UINT16 ListenPort;\r
169} EFI_DHCP4_LISTEN_POINT;\r
170\r
171\r
172typedef struct {\r
305a1279 173 EFI_STATUS Status;\r
174 EFI_EVENT CompletionEvent;\r
175 EFI_IPv4_ADDRESS RemoteAddress;\r
176 UINT16 RemotePort;\r
177 EFI_IPv4_ADDRESS GatewayAddress;\r
178 UINT32 ListenPointCount;\r
179 EFI_DHCP4_LISTEN_POINT *ListenPoints;\r
180 UINT32 TimeoutValue;\r
181 EFI_DHCP4_PACKET *Packet;\r
182 UINT32 ResponseCount;\r
183 EFI_DHCP4_PACKET *ResponseList;\r
d1f95000 184} EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN;\r
185\r
186\r
187/**\r
188 Returns the current operating mode and cached data packet for the EFI DHCPv4 Protocol driver.\r
189\r
190 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
191 @param Dhcp4ModeData Pointer to storage for the EFI_DHCP4_MODE_DATA structure.\r
192\r
193 @retval EFI_SUCCESS The mode data was returned.\r
194 @retval EFI_INVALID_PARAMETER This is NULL.\r
195\r
196**/\r
305a1279 197typedef\r
198EFI_STATUS\r
8b13229b 199(EFIAPI *EFI_DHCP4_GET_MODE_DATA)(\r
d1f95000 200 IN EFI_DHCP4_PROTOCOL *This,\r
201 OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData\r
ed66e1bc 202 );\r
d1f95000 203\r
204/**\r
205 Initializes, changes, or resets the operational settings for the EFI DHCPv4 Protocol driver.\r
206\r
207 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
208 @param Dhcp4CfgData Pointer to the EFI_DHCP4_CONFIG_DATA.\r
209\r
210 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the Dhcp4Init or\r
211 Dhcp4InitReboot state, if the original state of this driver\r
212 was Dhcp4Stopped and the value of Dhcp4CfgData was\r
213 not NULL. Otherwise, the state was left unchanged.\r
214 @retval EFI_ACCESS_DENIED This instance of the EFI DHCPv4 Protocol driver was not in the\r
215 Dhcp4Stopped, Dhcp4Init, Dhcp4InitReboot, or Dhcp4Bound state;\r
216 Or onother instance of this EFI DHCPv4 Protocol driver is already\r
217 in a valid configured state.\r
218 @retval EFI_INVALID_PARAMETER Some parameter is NULL.\r
219 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
220 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
221\r
222**/\r
305a1279 223typedef\r
d1f95000 224EFI_STATUS\r
8b13229b 225(EFIAPI *EFI_DHCP4_CONFIGURE)(\r
d1f95000 226 IN EFI_DHCP4_PROTOCOL *This,\r
227 IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData OPTIONAL\r
ed66e1bc 228 );\r
d1f95000 229\r
230\r
231/**\r
232 Starts the DHCP configuration process.\r
233\r
234 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
235 @param CompletionEvent If not NULL, indicates the event that will be signaled when the\r
236 EFI DHCPv4 Protocol driver is transferred into the\r
237 Dhcp4Bound state or when the DHCP process is aborted.\r
238 EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
239 check the completion status. If NULL,\r
240 EFI_DHCP4_PROTOCOL.Start() will wait until the driver\r
241 is transferred into the Dhcp4Bound state or the process fails.\r
242\r
243 @retval EFI_SUCCESS The DHCP configuration process has started, or it has completed\r
244 when CompletionEvent is NULL.\r
245 @retval EFI_NOT_STARTED The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped\r
246 state. EFI_DHCP4_PROTOCOL. Configure() needs to be called.\r
247 @retval EFI_INVALID_PARAMETER This is NULL.\r
248 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
249 @retval EFI_TIMEOUT The DHCP configuration process failed because no response was\r
250 received from the server within the specified timeout value.\r
251 @retval EFI_ABORTED The user aborted the DHCP process.\r
252 @retval EFI_ALREADY_STARTED Some other EFI DHCPv4 Protocol instance already started the\r
253 DHCP process.\r
254 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
255\r
256**/\r
305a1279 257typedef\r
d1f95000 258EFI_STATUS\r
8b13229b 259(EFIAPI *EFI_DHCP4_START)(\r
d1f95000 260 IN EFI_DHCP4_PROTOCOL *This,\r
261 IN EFI_EVENT CompletionEvent OPTIONAL\r
ed66e1bc 262 );\r
d1f95000 263\r
264/**\r
265 Extends the lease time by sending a request packet.\r
266\r
267 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
268 @param RebindRequest If TRUE, this function broadcasts the request packets and enters\r
269 the Dhcp4Rebinding state. Otherwise, it sends a unicast\r
270 request packet and enters the Dhcp4Renewing state.\r
271 @param CompletionEvent If not NULL, this event is signaled when the renew/rebind phase\r
272 completes or some error occurs.\r
273 EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
274 check the completion status. If NULL,\r
275 EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait\r
276 until the DHCP process finishes.\r
277\r
278 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the\r
279 Dhcp4Renewing state or is back to the Dhcp4Bound state.\r
280 @retval EFI_NOT_STARTED The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped\r
281 state. EFI_DHCP4_PROTOCOL.Configure() needs to\r
282 be called.\r
283 @retval EFI_INVALID_PARAMETER This is NULL.\r
284 @retval EFI_TIMEOUT There was no response from the server when the try count was\r
285 exceeded.\r
286 @retval EFI_ACCESS_DENIED The driver is not in the Dhcp4Bound state.\r
287 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
288\r
289**/\r
290typedef\r
291EFI_STATUS\r
8b13229b 292(EFIAPI *EFI_DHCP4_RENEW_REBIND)(\r
d1f95000 293 IN EFI_DHCP4_PROTOCOL *This,\r
294 IN BOOLEAN RebindRequest,\r
295 IN EFI_EVENT CompletionEvent OPTIONAL\r
ed66e1bc 296 );\r
d1f95000 297\r
298/**\r
299 Releases the current address configuration.\r
300\r
301 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
302\r
303 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the Dhcp4Init phase.\r
304 @retval EFI_INVALID_PARAMETER This is NULL.\r
305 @retval EFI_ACCESS_DENIED The EFI DHCPv4 Protocol driver is not Dhcp4InitReboot state.\r
306 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
307\r
308**/\r
305a1279 309typedef\r
d1f95000 310EFI_STATUS\r
8b13229b 311(EFIAPI *EFI_DHCP4_RELEASE)(\r
d1f95000 312 IN EFI_DHCP4_PROTOCOL *This\r
ed66e1bc 313 );\r
d1f95000 314\r
315/**\r
316 Stops the current address configuration.\r
317\r
318 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
305a1279 319\r
d1f95000 320 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the Dhcp4Stopped phase.\r
321 @retval EFI_INVALID_PARAMETER This is NULL.\r
322\r
323**/\r
305a1279 324typedef\r
d1f95000 325EFI_STATUS\r
8b13229b 326(EFIAPI *EFI_DHCP4_STOP)(\r
d1f95000 327 IN EFI_DHCP4_PROTOCOL *This\r
ed66e1bc 328 );\r
d1f95000 329\r
330/**\r
331 Builds a DHCP packet, given the options to be appended or deleted or replaced.\r
332\r
333 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
eecd469b 334 @param SeedPacket Initial packet to be used as a base for building new packet.\r
d1f95000 335 @param DeleteCount Number of opcodes in the DeleteList.\r
336 @param DeleteList List of opcodes to be deleted from the seed packet.\r
337 Ignored if DeleteCount is zero.\r
338 @param AppendCount Number of entries in the OptionList.\r
339 @param AppendList Pointer to a DHCP option list to be appended to SeedPacket.\r
340 If SeedPacket also contains options in this list, they are\r
341 replaced by new options (except pad option). Ignored if\r
342 AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION\r
343 @param NewPacket Pointer to storage for the pointer to the new allocated packet.\r
344 Use the EFI Boot Service FreePool() on the resulting pointer\r
345 when done with the packet.\r
346\r
347 @retval EFI_SUCCESS The new packet was built.\r
348 @retval EFI_OUT_OF_RESOURCES Storage for the new packet could not be allocated.\r
349 @retval EFI_INVALID_PARAMETER Some parameter is NULL.\r
350\r
351**/\r
352typedef\r
353EFI_STATUS\r
8b13229b 354(EFIAPI *EFI_DHCP4_BUILD)(\r
d1f95000 355 IN EFI_DHCP4_PROTOCOL *This,\r
356 IN EFI_DHCP4_PACKET *SeedPacket,\r
357 IN UINT32 DeleteCount,\r
358 IN UINT8 *DeleteList OPTIONAL,\r
359 IN UINT32 AppendCount,\r
360 IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,\r
361 OUT EFI_DHCP4_PACKET **NewPacket\r
ed66e1bc 362 );\r
d1f95000 363/**\r
364 Transmits a DHCP formatted packet and optionally waits for responses.\r
365\r
366 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
367 @param Token Pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure.\r
368\r
369 @retval EFI_SUCCESS The packet was successfully queued for transmission.\r
370 @retval EFI_INVALID_PARAMETER Some parameter is NULL.\r
371 @retval EFI_NOT_READY The previous call to this function has not finished yet. Try to call\r
372 this function after collection process completes.\r
373 @retval EFI_NO_MAPPING The default station address is not available yet.\r
374 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
375 @retval Others Some other unexpected error occurred.\r
376\r
377**/\r
305a1279 378typedef\r
d1f95000 379EFI_STATUS\r
8b13229b 380(EFIAPI *EFI_DHCP4_TRANSMIT_RECEIVE)(\r
d1f95000 381 IN EFI_DHCP4_PROTOCOL *This,\r
382 IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token\r
ed66e1bc 383 );\r
d1f95000 384\r
385\r
386/**\r
387 Parses the packed DHCP option data.\r
388\r
389 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
390 @param Packet Pointer to packet to be parsed.\r
391 @param OptionCount On input, the number of entries in the PacketOptionList.\r
392 On output, the number of entries that were written into the\r
393 PacketOptionList.\r
394 @param PacketOptionList List of packet option entries to be filled in. End option or pad\r
395 options are not included.\r
396\r
397 @retval EFI_SUCCESS The packet was successfully parsed.\r
398 @retval EFI_INVALID_PARAMETER Some parameter is NULL.\r
399 @retval EFI_BUFFER_TOO_SMALL One or more of the following conditions is TRUE:\r
400 1) *OptionCount is smaller than the number of options that\r
401 were found in the Packet.\r
402 2) PacketOptionList is NULL.\r
403\r
404**/\r
405typedef\r
406EFI_STATUS\r
8b13229b 407(EFIAPI *EFI_DHCP4_PARSE)(\r
d1f95000 408 IN EFI_DHCP4_PROTOCOL *This,\r
409 IN EFI_DHCP4_PACKET *Packet,\r
410 IN OUT UINT32 *OptionCount,\r
411 OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL\r
ed66e1bc 412 );\r
d1f95000 413\r
44717a39 414///\r
415/// This protocol is used to collect configuration information for the EFI IPv4 Protocol drivers\r
416/// and to provide DHCPv4 server and PXE boot server discovery services.\r
417///\r
d1f95000 418struct _EFI_DHCP4_PROTOCOL {\r
419 EFI_DHCP4_GET_MODE_DATA GetModeData;\r
420 EFI_DHCP4_CONFIGURE Configure;\r
421 EFI_DHCP4_START Start;\r
422 EFI_DHCP4_RENEW_REBIND RenewRebind;\r
423 EFI_DHCP4_RELEASE Release;\r
424 EFI_DHCP4_STOP Stop;\r
425 EFI_DHCP4_BUILD Build;\r
426 EFI_DHCP4_TRANSMIT_RECEIVE TransmitReceive;\r
427 EFI_DHCP4_PARSE Parse;\r
428};\r
429\r
430extern EFI_GUID gEfiDhcp4ProtocolGuid;\r
431extern EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid;\r
432\r
433#endif\r