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