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