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