]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/Ip4.h
a72244e2c8cc6b05caab21d6302ce075fa45e671
[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, 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 @param This Pointer to the EFI_IP4_PROTOCOL instance.
164 @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.
165 @param MnpConfigData Pointer to the managed network configuration data structure.
166 @param SnpData Pointer to the simple network mode data structure.
167
168 @retval EFI_SUCCESS The operation completed successfully.
169 @retval EFI_INVALID_PARAMETER This is NULL.
170 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
171
172 **/
173 typedef
174 EFI_STATUS
175 (EFIAPI *EFI_IP4_GET_MODE_DATA) (
176 IN CONST EFI_IP4_PROTOCOL *This,
177 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
178 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
179 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
180 )
181 ;
182
183 /**
184 Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
185
186 @param This Pointer to the EFI_IP4_PROTOCOL instance.
187 @param IpConfigData Pointer to the EFI IPv4 Protocol configuration data structure.
188
189 @retval EFI_SUCCESS The driver instance was successfully opened.
190 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
191 RARP, etc.) is not finished yet.
192 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
193 @retval EFI_UNSUPPORTED One or more of the following conditions is TRUE:
194 A configuration protocol (DHCP, BOOTP, RARP, etc.) could
195 not be located when clients choose to use the default IPv4
196 address. This EFI IPv4 Protocol implementation does not
197 support this requested filter or timeout setting.
198 @retval EFI_OUT_OF_RESOURCES The EFI IPv4 Protocol driver instance data could not be allocated.
199 @retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the
200 IPv4 address or subnet mask can be changed. The interface must
201 also be stopped when switching to/from raw packet mode.
202 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv4
203 Protocol driver instance is not opened.
204
205 **/
206 typedef
207 EFI_STATUS
208 (EFIAPI *EFI_IP4_CONFIGURE) (
209 IN EFI_IP4_PROTOCOL *This,
210 IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
211 )
212 ;
213
214 /**
215 Joins and leaves multicast groups.
216
217 @param This Pointer to the EFI_IP4_PROTOCOL instance.
218 @param JoinFlag Set to TRUE to join the multicast group session and FALSE to leave.
219 @param GroupAddress Pointer to the IPv4 multicast address.
220
221 @retval EFI_SUCCESS The operation completed successfully.
222 @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:
223 - This is NULL.
224 - JoinFlag is TRUE and GroupAddress is NULL.
225 - GroupAddress is not NULL and *GroupAddress is
226 not a multicast IPv4 address.
227 @retval EFI_NOT_STARTED This instance has not been started.
228 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
229 RARP, etc.) is not finished yet.
230 @retval EFI_OUT_OF_RESOURCES System resources could not be allocated.
231 @retval EFI_UNSUPPORTED This EFI IPv4 Protocol implementation does not support multicast groups.
232 @retval EFI_ALREADY_STARTED The group address is already in the group table (when
233 JoinFlag is TRUE).
234 @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE).
235 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
236
237 **/
238 typedef
239 EFI_STATUS
240 (EFIAPI *EFI_IP4_GROUPS) (
241 IN EFI_IP4_PROTOCOL *This,
242 IN BOOLEAN JoinFlag,
243 IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
244 )
245 ;
246
247 /**
248 Adds and deletes routing table entries.
249
250 @param This Pointer to the EFI_IP4_PROTOCOL instance.
251 @param DeleteRoute Set to TRUE to delete this route from the routing table. Set to
252 FALSE to add this route to the routing table. SubnetAddress
253 and SubnetMask are used as the key to each route entry.
254 @param SubnetAddress The address of the subnet that needs to be routed.
255 @param SubnetMask The subnet mask of SubnetAddress.
256 @param GatewayAddress The unicast gateway IPv4 address for this route.
257
258 @retval EFI_SUCCESS The operation completed successfully.
259 @retval EFI_NOT_STARTED The driver instance has not been started.
260 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
261 RARP, etc.) is not finished yet.
262 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
263 - This is NULL.
264 - SubnetAddress is NULL.
265 - SubnetMask is NULL.
266 - GatewayAddress is NULL.
267 - *SubnetAddress is not a valid subnet address.
268 - *SubnetMask is not a valid subnet mask.
269 - *GatewayAddress is not a valid unicast IPv4 address.
270 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
271 @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).
272 @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when
273 DeleteRoute is FALSE).
274
275 **/
276 typedef
277 EFI_STATUS
278 (EFIAPI *EFI_IP4_ROUTES) (
279 IN EFI_IP4_PROTOCOL *This,
280 IN BOOLEAN DeleteRoute,
281 IN EFI_IPv4_ADDRESS *SubnetAddress,
282 IN EFI_IPv4_ADDRESS *SubnetMask,
283 IN EFI_IPv4_ADDRESS *GatewayAddress
284 )
285 ;
286
287 /**
288 Places outgoing data packets into the transmit queue.
289
290 @param This Pointer to the EFI_IP4_PROTOCOL instance.
291 @param Token Pointer to the transmit token.
292
293 @retval EFI_SUCCESS The data has been queued for transmission.
294 @retval EFI_NOT_STARTED This instance has not been started.
295 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
296 RARP, etc.) is not finished yet.
297 @retval EFI_INVALID_PARAMETER One or more pameters are invalid.
298 @retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event
299 was already in the transmit queue.
300 @retval EFI_NOT_READY The completion token could not be queued because the transmit
301 queue is full.
302 @retval EFI_NOT_FOUND Not route is found to destination address.
303 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
304 @retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too
305 short to transmit.
306 @retval EFI_BAD_BUFFER_SIZE The length of the IPv4 header + option length + total data length is
307 greater than MTU (or greater than the maximum packet size if
308 Token.Packet.TxData.OverrideData.
309 DoNotFragment is TRUE.)
310
311 **/
312 typedef
313 EFI_STATUS
314 (EFIAPI *EFI_IP4_TRANSMIT) (
315 IN EFI_IP4_PROTOCOL *This,
316 IN EFI_IP4_COMPLETION_TOKEN *Token
317 )
318 ;
319
320 /**
321 Places a receiving request into the receiving queue.
322
323 @param This Pointer to the EFI_IP4_PROTOCOL instance.
324 @param Token Pointer to a token that is associated with the receive data descriptor.
325
326 @retval EFI_SUCCESS The receive completion token was cached.
327 @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.
328 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, RARP, etc.)
329 is not finished yet.
330 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
331 - This is NULL.
332 - Token is NULL.
333 - Token.Event is NULL.
334 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system
335 resources (usually memory).
336 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
337 The EFI IPv4 Protocol instance has been reset to startup defaults.
338 EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already
339 in the receive queue.
340 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
341 @retval EFI_ICMP_ERROR An ICMP error packet was received.
342
343 **/
344 typedef
345 EFI_STATUS
346 (EFIAPI *EFI_IP4_RECEIVE) (
347 IN EFI_IP4_PROTOCOL *This,
348 IN EFI_IP4_COMPLETION_TOKEN *Token
349 )
350 ;
351
352 /**
353 Abort an asynchronous transmit or receive request.
354
355 @param This Pointer to the EFI_IP4_PROTOCOL instance.
356 @param Token Pointer to a token that has been issued by
357 EFI_IP4_PROTOCOL.Transmit() or
358 EFI_IP4_PROTOCOL.Receive(). If NULL, all pending
359 tokens are aborted. Type EFI_IP4_COMPLETION_TOKEN is
360 defined in EFI_IP4_PROTOCOL.Transmit().
361
362 @retval EFI_SUCCESS The asynchronous I/O request was aborted and
363 Token.->Event was signaled. When Token is NULL, all
364 pending requests were aborted and their events were signaled.
365 @retval EFI_INVALID_PARAMETER This is NULL.
366 @retval EFI_NOT_STARTED This instance has not been started.
367 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
368 RARP, etc.) is not finished yet.
369 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was
370 not found in the transmit or receive queue. It has either completed
371 or was not issued by Transmit() and Receive().
372
373 **/
374 typedef
375 EFI_STATUS
376 (EFIAPI *EFI_IP4_CANCEL) (
377 IN EFI_IP4_PROTOCOL *This,
378 IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
379 )
380 ;
381
382 /**
383 Polls for incoming data packets and processes outgoing data packets.
384
385 @param This Pointer to the EFI_IP4_PROTOCOL instance.
386
387 @retval EFI_SUCCESS Incoming or outgoing data was processed.
388 @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.
389 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
390 RARP, etc.) is not finished yet.
391 @retval EFI_INVALID_PARAMETER This is NULL.
392 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
393 @retval EFI_NOT_READY No incoming or outgoing data is processed.
394 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
395 Consider increasing the polling rate.
396
397 **/
398 typedef
399 EFI_STATUS
400 (EFIAPI *EFI_IP4_POLL) (
401 IN EFI_IP4_PROTOCOL *This
402 )
403 ;
404
405 struct _EFI_IP4_PROTOCOL {
406 EFI_IP4_GET_MODE_DATA GetModeData;
407 EFI_IP4_CONFIGURE Configure;
408 EFI_IP4_GROUPS Groups;
409 EFI_IP4_ROUTES Routes;
410 EFI_IP4_TRANSMIT Transmit;
411 EFI_IP4_RECEIVE Receive;
412 EFI_IP4_CANCEL Cancel;
413 EFI_IP4_POLL Poll;
414 };
415
416 extern EFI_GUID gEfiIp4ServiceBindingProtocolGuid;
417 extern EFI_GUID gEfiIp4ProtocolGuid;
418
419 #endif