]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Ip4.h
d19cc7b34d380d8626b2beaabe9629f61de4dd23
[mirror_edk2.git] / MdePkg / Include / Protocol / Ip4.h
1 /** @file
2
3 This file defines the EFI IPv4 (Internet Protocol version 4)
4 Protocol interface. It is split into the following three main
5 sections:
6 - EFI IPv4 Service Binding Protocol
7 - EFI IPv4 Variable
8 - EFI IPv4 Protocol The EFI IPv4 Protocol provides basic
9 network IPv4 packet I/O services, which includes support for
10 a subset of the Internet Control Message Protocol (ICMP) and
11 may include support for the Internet Group Management
12 Protocol (IGMP).
13
14 Copyright (c) 2006 - 2008, Intel Corporation
15 All rights reserved. This program and the accompanying materials
16 are licensed and made available under the terms and conditions of the BSD License
17 which accompanies this distribution. The full text of the license may be found at
18 http://opensource.org/licenses/bsd-license.php
19
20 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
21 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22
23 **/
24
25 #ifndef __EFI_IP4_PROTOCOL_H__
26 #define __EFI_IP4_PROTOCOL_H__
27
28 #include <Protocol/ManagedNetwork.h>
29
30 #define EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID \
31 { \
32 0xc51711e7, 0xb4bf, 0x404a, {0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } \
33 }
34
35 #define EFI_IP4_PROTOCOL_GUID \
36 { \
37 0x41d94cd2, 0x35b6, 0x455a, {0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } \
38 }
39
40 typedef struct _EFI_IP4_PROTOCOL EFI_IP4_PROTOCOL;
41
42 typedef struct {
43 EFI_HANDLE InstanceHandle;
44 EFI_IPv4_ADDRESS Ip4Address;
45 EFI_IPv4_ADDRESS SubnetMask;
46 } EFI_IP4_ADDRESS_PAIR;
47
48 typedef struct {
49 EFI_HANDLE DriverHandle;
50 UINT32 AddressCount;
51 EFI_IP4_ADDRESS_PAIR AddressPairs[1];
52 } EFI_IP4_VARIABLE_DATA;
53
54 typedef struct {
55 UINT8 DefaultProtocol;
56 BOOLEAN AcceptAnyProtocol;
57 BOOLEAN AcceptIcmpErrors;
58 BOOLEAN AcceptBroadcast;
59 BOOLEAN AcceptPromiscuous;
60 BOOLEAN UseDefaultAddress;
61 EFI_IPv4_ADDRESS StationAddress;
62 EFI_IPv4_ADDRESS SubnetMask;
63 UINT8 TypeOfService;
64 UINT8 TimeToLive;
65 BOOLEAN DoNotFragment;
66 BOOLEAN RawData;
67 UINT32 ReceiveTimeout;
68 UINT32 TransmitTimeout;
69 } EFI_IP4_CONFIG_DATA;
70
71
72 typedef struct {
73 EFI_IPv4_ADDRESS SubnetAddress;
74 EFI_IPv4_ADDRESS SubnetMask;
75 EFI_IPv4_ADDRESS GatewayAddress;
76 } EFI_IP4_ROUTE_TABLE;
77
78 typedef struct {
79 UINT8 Type;
80 UINT8 Code;
81 } EFI_IP4_ICMP_TYPE;
82
83 typedef struct {
84 BOOLEAN IsStarted;
85 EFI_IP4_CONFIG_DATA ConfigData;
86 BOOLEAN IsConfigured;
87 UINT32 GroupCount;
88 EFI_IPv4_ADDRESS *GroupTable;
89 UINT32 RouteCount;
90 EFI_IP4_ROUTE_TABLE *RouteTable;
91 UINT32 IcmpTypeCount;
92 EFI_IP4_ICMP_TYPE *IcmpTypeList;
93 } EFI_IP4_MODE_DATA;
94
95 #pragma pack(1)
96
97 typedef struct {
98 UINT8 HeaderLength:4;
99 UINT8 Version:4;
100 UINT8 TypeOfService;
101 UINT16 TotalLength;
102 UINT16 Identification;
103 UINT16 Fragmentation;
104 UINT8 TimeToLive;
105 UINT8 Protocol;
106 UINT16 Checksum;
107 EFI_IPv4_ADDRESS SourceAddress;
108 EFI_IPv4_ADDRESS DestinationAddress;
109 } EFI_IP4_HEADER;
110 #pragma pack()
111
112
113 typedef struct {
114 UINT32 FragmentLength;
115 VOID *FragmentBuffer;
116 } EFI_IP4_FRAGMENT_DATA;
117
118
119 typedef struct {
120 EFI_TIME TimeStamp;
121 EFI_EVENT RecycleSignal;
122 UINT32 HeaderLength;
123 EFI_IP4_HEADER *Header;
124 UINT32 OptionsLength;
125 VOID *Options;
126 UINT32 DataLength;
127 UINT32 FragmentCount;
128 EFI_IP4_FRAGMENT_DATA FragmentTable[1];
129 } EFI_IP4_RECEIVE_DATA;
130
131
132 typedef struct {
133 EFI_IPv4_ADDRESS SourceAddress;
134 EFI_IPv4_ADDRESS GatewayAddress;
135 UINT8 Protocol;
136 UINT8 TypeOfService;
137 UINT8 TimeToLive;
138 BOOLEAN DoNotFragment;
139 } EFI_IP4_OVERRIDE_DATA;
140
141 typedef struct {
142 EFI_IPv4_ADDRESS DestinationAddress;
143 EFI_IP4_OVERRIDE_DATA *OverrideData; //OPTIONAL
144 UINT32 OptionsLength; //OPTIONAL
145 VOID *OptionsBuffer; //OPTIONAL
146 UINT32 TotalDataLength;
147 UINT32 FragmentCount;
148 EFI_IP4_FRAGMENT_DATA FragmentTable[1];
149 } EFI_IP4_TRANSMIT_DATA;
150
151 typedef struct {
152 EFI_EVENT Event;
153 EFI_STATUS Status;
154 union {
155 EFI_IP4_RECEIVE_DATA *RxData;
156 EFI_IP4_TRANSMIT_DATA *TxData;
157 } Packet;
158 } EFI_IP4_COMPLETION_TOKEN;
159
160 /**
161 Gets the current operational settings for this instance of the EFI IPv4 Protocol driver.
162
163 The GetModeData() function returns the current operational mode data for this
164 driver instance. The data fields in EFI_IP4_MODE_DATA are read only. This
165 function is used optionally to retrieve the operational mode data of underlying
166 networks or drivers.
167
168 @param This Pointer to the EFI_IP4_PROTOCOL instance.
169 @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.
170 @param MnpConfigData Pointer to the managed network configuration data structure.
171 @param SnpModeData Pointer to the simple network mode data structure.
172
173 @retval EFI_SUCCESS The operation completed successfully.
174 @retval EFI_INVALID_PARAMETER This is NULL.
175 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
176
177 **/
178 typedef
179 EFI_STATUS
180 (EFIAPI *EFI_IP4_GET_MODE_DATA)(
181 IN CONST EFI_IP4_PROTOCOL *This,
182 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
183 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
184 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
185 );
186
187 /**
188 Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
189
190 The Configure() function is used to set, change, or reset the operational
191 parameters and filter settings for this EFI IPv4 Protocol instance. Until these
192 parameters have been set, no network traffic can be sent or received by this
193 instance. Once the parameters have been reset (by calling this function with
194 IpConfigData set to NULL), no more traffic can be sent or received until these
195 parameters have been set again. Each EFI IPv4 Protocol instance can be started
196 and stopped independently of each other by enabling or disabling their receive
197 filter settings with the Configure() function.
198
199 When IpConfigData.UseDefaultAddress is set to FALSE, the new station address will
200 be appended as an alias address into the addresses list in the EFI IPv4 Protocol
201 driver. While set to TRUE, Configure() will trigger the EFI_IP4_CONFIG_PROTOCOL
202 to retrieve the default IPv4 address if it is not available yet. Clients could
203 frequently call GetModeData() to check the status to ensure that the default IPv4
204 address is ready.
205
206 If operational parameters are reset or changed, any pending transmit and receive
207 requests will be cancelled. Their completion token status will be set to EFI_ABORTED
208 and their events will be signaled.
209
210 @param This Pointer to the EFI_IP4_PROTOCOL instance.
211 @param IpConfigData Pointer to the EFI IPv4 Protocol configuration data structure.
212
213 @retval EFI_SUCCESS The driver instance was successfully opened.
214 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
215 RARP, etc.) is not finished yet.
216 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
217 @retval EFI_UNSUPPORTED One or more of the following conditions is TRUE:
218 A configuration protocol (DHCP, BOOTP, RARP, etc.) could
219 not be located when clients choose to use the default IPv4
220 address. This EFI IPv4 Protocol implementation does not
221 support this requested filter or timeout setting.
222 @retval EFI_OUT_OF_RESOURCES The EFI IPv4 Protocol driver instance data could not be allocated.
223 @retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the
224 IPv4 address or subnet mask can be changed. The interface must
225 also be stopped when switching to/from raw packet mode.
226 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv4
227 Protocol driver instance is not opened.
228
229 **/
230 typedef
231 EFI_STATUS
232 (EFIAPI *EFI_IP4_CONFIGURE)(
233 IN EFI_IP4_PROTOCOL *This,
234 IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
235 );
236
237 /**
238 Joins and leaves multicast groups.
239
240 The Groups() function is used to join and leave multicast group sessions. Joining
241 a group will enable reception of matching multicast packets. Leaving a group will
242 disable the multicast packet reception.
243
244 If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.
245
246 @param This Pointer to the EFI_IP4_PROTOCOL instance.
247 @param JoinFlag Set to TRUE to join the multicast group session and FALSE to leave.
248 @param GroupAddress Pointer to the IPv4 multicast address.
249
250 @retval EFI_SUCCESS The operation completed successfully.
251 @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:
252 - This is NULL.
253 - JoinFlag is TRUE and GroupAddress is NULL.
254 - GroupAddress is not NULL and *GroupAddress is
255 not a multicast IPv4 address.
256 @retval EFI_NOT_STARTED This instance has not been started.
257 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
258 RARP, etc.) is not finished yet.
259 @retval EFI_OUT_OF_RESOURCES System resources could not be allocated.
260 @retval EFI_UNSUPPORTED This EFI IPv4 Protocol implementation does not support multicast groups.
261 @retval EFI_ALREADY_STARTED The group address is already in the group table (when
262 JoinFlag is TRUE).
263 @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE).
264 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
265
266 **/
267 typedef
268 EFI_STATUS
269 (EFIAPI *EFI_IP4_GROUPS)(
270 IN EFI_IP4_PROTOCOL *This,
271 IN BOOLEAN JoinFlag,
272 IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
273 );
274
275 /**
276 Adds and deletes routing table entries.
277
278 The Routes() function adds a route to or deletes a route from the routing table.
279
280 Routes are determined by comparing the SubnetAddress with the destination IPv4
281 address arithmetically AND-ed with the SubnetMask. The gateway address must be
282 on the same subnet as the configured station address.
283
284 The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.
285 The default route matches all destination IPv4 addresses that do not match any
286 other routes.
287
288 A GatewayAddress that is zero is a nonroute. Packets are sent to the destination
289 IP address if it can be found in the ARP cache or on the local subnet. One automatic
290 nonroute entry will be inserted into the routing table for outgoing packets that
291 are addressed to a local subnet (gateway address of 0.0.0.0).
292
293 Each EFI IPv4 Protocol instance has its own independent routing table. Those EFI
294 IPv4 Protocol instances that use the default IPv4 address will also have copies
295 of the routing table that was provided by the EFI_IP4_CONFIG_PROTOCOL, and these
296 copies will be updated whenever the EIF IPv4 Protocol driver reconfigures its
297 instances. As a result, client modification to the routing table will be lost.
298
299 @param This Pointer to the EFI_IP4_PROTOCOL instance.
300 @param DeleteRoute Set to TRUE to delete this route from the routing table. Set to
301 FALSE to add this route to the routing table. SubnetAddress
302 and SubnetMask are used as the key to each route entry.
303 @param SubnetAddress The address of the subnet that needs to be routed.
304 @param SubnetMask The subnet mask of SubnetAddress.
305 @param GatewayAddress The unicast gateway IPv4 address for this route.
306
307 @retval EFI_SUCCESS The operation completed successfully.
308 @retval EFI_NOT_STARTED The driver instance has not been started.
309 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
310 RARP, etc.) is not finished yet.
311 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
312 - This is NULL.
313 - SubnetAddress is NULL.
314 - SubnetMask is NULL.
315 - GatewayAddress is NULL.
316 - *SubnetAddress is not a valid subnet address.
317 - *SubnetMask is not a valid subnet mask.
318 - *GatewayAddress is not a valid unicast IPv4 address.
319 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
320 @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).
321 @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when
322 DeleteRoute is FALSE).
323
324 **/
325 typedef
326 EFI_STATUS
327 (EFIAPI *EFI_IP4_ROUTES)(
328 IN EFI_IP4_PROTOCOL *This,
329 IN BOOLEAN DeleteRoute,
330 IN EFI_IPv4_ADDRESS *SubnetAddress,
331 IN EFI_IPv4_ADDRESS *SubnetMask,
332 IN EFI_IPv4_ADDRESS *GatewayAddress
333 );
334
335 /**
336 Places outgoing data packets into the transmit queue.
337
338 The Transmit() function places a sending request in the transmit queue of this
339 EFI IPv4 Protocol instance. Whenever the packet in the token is sent out or some
340 errors occur, the event in the token will be signaled and the status is updated.
341
342 @param This Pointer to the EFI_IP4_PROTOCOL instance.
343 @param Token Pointer to the transmit token.
344
345 @retval EFI_SUCCESS The data has been queued for transmission.
346 @retval EFI_NOT_STARTED This instance has not been started.
347 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
348 RARP, etc.) is not finished yet.
349 @retval EFI_INVALID_PARAMETER One or more pameters are invalid.
350 @retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event
351 was already in the transmit queue.
352 @retval EFI_NOT_READY The completion token could not be queued because the transmit
353 queue is full.
354 @retval EFI_NOT_FOUND Not route is found to destination address.
355 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
356 @retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too
357 short to transmit.
358 @retval EFI_BAD_BUFFER_SIZE The length of the IPv4 header + option length + total data length is
359 greater than MTU (or greater than the maximum packet size if
360 Token.Packet.TxData.OverrideData.
361 DoNotFragment is TRUE.)
362
363 **/
364 typedef
365 EFI_STATUS
366 (EFIAPI *EFI_IP4_TRANSMIT)(
367 IN EFI_IP4_PROTOCOL *This,
368 IN EFI_IP4_COMPLETION_TOKEN *Token
369 );
370
371 /**
372 Places a receiving request into the receiving queue.
373
374 The Receive() function places a completion token into the receive packet queue.
375 This function is always asynchronous.
376
377 The Token.Event field in the completion token must be filled in by the caller
378 and cannot be NULL. When the receive operation completes, the EFI IPv4 Protocol
379 driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
380 is signaled.
381
382 @param This Pointer to the EFI_IP4_PROTOCOL instance.
383 @param Token Pointer to a token that is associated with the receive data descriptor.
384
385 @retval EFI_SUCCESS The receive completion token was cached.
386 @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.
387 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, RARP, etc.)
388 is not finished yet.
389 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
390 - This is NULL.
391 - Token is NULL.
392 - Token.Event is NULL.
393 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system
394 resources (usually memory).
395 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
396 The EFI IPv4 Protocol instance has been reset to startup defaults.
397 EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already
398 in the receive queue.
399 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
400 @retval EFI_ICMP_ERROR An ICMP error packet was received.
401
402 **/
403 typedef
404 EFI_STATUS
405 (EFIAPI *EFI_IP4_RECEIVE)(
406 IN EFI_IP4_PROTOCOL *This,
407 IN EFI_IP4_COMPLETION_TOKEN *Token
408 );
409
410 /**
411 Abort an asynchronous transmit or receive request.
412
413 The Cancel() function is used to abort a pending transmit or receive request.
414 If the token is in the transmit or receive request queues, after calling this
415 function, Token->Status will be set to EFI_ABORTED and then Token->Event will
416 be signaled. If the token is not in one of the queues, which usually means the
417 asynchronous operation has completed, this function will not signal the token
418 and EFI_NOT_FOUND is returned.
419
420 @param This Pointer to the EFI_IP4_PROTOCOL instance.
421 @param Token Pointer to a token that has been issued by
422 EFI_IP4_PROTOCOL.Transmit() or
423 EFI_IP4_PROTOCOL.Receive(). If NULL, all pending
424 tokens are aborted. Type EFI_IP4_COMPLETION_TOKEN is
425 defined in EFI_IP4_PROTOCOL.Transmit().
426
427 @retval EFI_SUCCESS The asynchronous I/O request was aborted and
428 Token.->Event was signaled. When Token is NULL, all
429 pending requests were aborted and their events were signaled.
430 @retval EFI_INVALID_PARAMETER This is NULL.
431 @retval EFI_NOT_STARTED This instance has not been started.
432 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
433 RARP, etc.) is not finished yet.
434 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was
435 not found in the transmit or receive queue. It has either completed
436 or was not issued by Transmit() and Receive().
437
438 **/
439 typedef
440 EFI_STATUS
441 (EFIAPI *EFI_IP4_CANCEL)(
442 IN EFI_IP4_PROTOCOL *This,
443 IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
444 );
445
446 /**
447 Polls for incoming data packets and processes outgoing data packets.
448
449 The Poll() function polls for incoming data packets and processes outgoing data
450 packets. Network drivers and applications can call the EFI_IP4_PROTOCOL.Poll()
451 function to increase the rate that data packets are moved between the communications
452 device and the transmit and receive queues.
453
454 In some systems the periodic timer event may not poll the underlying communications
455 device fast enough to transmit and/or receive all data packets without missing
456 incoming packets or dropping outgoing packets. Drivers and applications that are
457 experiencing packet loss should try calling the EFI_IP4_PROTOCOL.Poll() function
458 more often.
459
460 @param This Pointer to the EFI_IP4_PROTOCOL instance.
461
462 @retval EFI_SUCCESS Incoming or outgoing data was processed.
463 @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.
464 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
465 RARP, etc.) is not finished yet.
466 @retval EFI_INVALID_PARAMETER This is NULL.
467 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
468 @retval EFI_NOT_READY No incoming or outgoing data is processed.
469 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
470 Consider increasing the polling rate.
471
472 **/
473 typedef
474 EFI_STATUS
475 (EFIAPI *EFI_IP4_POLL)(
476 IN EFI_IP4_PROTOCOL *This
477 );
478
479 ///
480 /// The EFI IPv4 Protocol implements a simple packet-oriented interface that can be
481 /// used by drivers, daemons, and applications to transmit and receive network packets.
482 ///
483 struct _EFI_IP4_PROTOCOL {
484 EFI_IP4_GET_MODE_DATA GetModeData;
485 EFI_IP4_CONFIGURE Configure;
486 EFI_IP4_GROUPS Groups;
487 EFI_IP4_ROUTES Routes;
488 EFI_IP4_TRANSMIT Transmit;
489 EFI_IP4_RECEIVE Receive;
490 EFI_IP4_CANCEL Cancel;
491 EFI_IP4_POLL Poll;
492 };
493
494 extern EFI_GUID gEfiIp4ServiceBindingProtocolGuid;
495 extern EFI_GUID gEfiIp4ProtocolGuid;
496
497 #endif