]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/Ip4.h
Formalize comments for Protocols and PPIs.
[mirror_edk2.git] / MdePkg / Include / Protocol / Ip4.h
CommitLineData
d1f95000 1/** @file\r
c311f86b 2 \r
3 This file defines the EFI IPv4 (Internet Protocol version 4)\r
4 Protocol interface. It is split into the following three main\r
5 sections:\r
6 - EFI IPv4 Service Binding Protocol\r
7 - EFI IPv4 Variable\r
8 - EFI IPv4 Protocol The EFI IPv4 Protocol provides basic\r
9 network IPv4 packet I/O services, which includes support for\r
10 a subset of the Internet Control Message Protocol (ICMP) and\r
11 may include support for the Internet Group Management\r
12 Protocol (IGMP).\r
13 \r
4ca9b6c4 14 Copyright (c) 2006 - 2008, Intel Corporation \r
d1f95000 15 All rights reserved. This program and the accompanying materials \r
16 are licensed and made available under the terms and conditions of the BSD License \r
17 which accompanies this distribution. The full text of the license may be found at \r
18 http://opensource.org/licenses/bsd-license.php \r
19\r
20 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
21 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
22\r
d1f95000 23**/\r
24\r
25#ifndef __EFI_IP4_PROTOCOL_H__\r
26#define __EFI_IP4_PROTOCOL_H__\r
27\r
28#include <Protocol/ManagedNetwork.h>\r
29\r
30#define EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID \\r
31 { \\r
32 0xc51711e7, 0xb4bf, 0x404a, {0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } \\r
33 }\r
34\r
35#define EFI_IP4_PROTOCOL_GUID \\r
36 { \\r
37 0x41d94cd2, 0x35b6, 0x455a, {0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } \\r
38 }\r
39\r
40typedef struct _EFI_IP4_PROTOCOL EFI_IP4_PROTOCOL;\r
41 \r
42typedef struct {\r
43 EFI_HANDLE InstanceHandle;\r
44 EFI_IPv4_ADDRESS Ip4Address;\r
45 EFI_IPv4_ADDRESS SubnetMask;\r
46} EFI_IP4_ADDRESS_PAIR; \r
47\r
48typedef struct {\r
49 EFI_HANDLE DriverHandle;\r
50 UINT32 AddressCount;\r
51 EFI_IP4_ADDRESS_PAIR AddressPairs[1];\r
52} EFI_IP4_VARIABLE_DATA;\r
53\r
54typedef struct {\r
55 UINT8 DefaultProtocol;\r
56 BOOLEAN AcceptAnyProtocol;\r
57 BOOLEAN AcceptIcmpErrors;\r
58 BOOLEAN AcceptBroadcast;\r
59 BOOLEAN AcceptPromiscuous;\r
60 BOOLEAN UseDefaultAddress;\r
61 EFI_IPv4_ADDRESS StationAddress;\r
62 EFI_IPv4_ADDRESS SubnetMask;\r
63 UINT8 TypeOfService;\r
64 UINT8 TimeToLive;\r
65 BOOLEAN DoNotFragment;\r
66 BOOLEAN RawData;\r
67 UINT32 ReceiveTimeout;\r
68 UINT32 TransmitTimeout;\r
69} EFI_IP4_CONFIG_DATA;\r
70\r
71\r
72typedef struct {\r
73 EFI_IPv4_ADDRESS SubnetAddress;\r
74 EFI_IPv4_ADDRESS SubnetMask;\r
75 EFI_IPv4_ADDRESS GatewayAddress;\r
76} EFI_IP4_ROUTE_TABLE;\r
77\r
78typedef struct {\r
79 UINT8 Type;\r
80 UINT8 Code;\r
81} EFI_IP4_ICMP_TYPE;\r
82\r
83typedef struct {\r
84 BOOLEAN IsStarted;\r
85 EFI_IP4_CONFIG_DATA ConfigData;\r
86 BOOLEAN IsConfigured;\r
87 UINT32 GroupCount;\r
88 EFI_IPv4_ADDRESS *GroupTable;\r
89 UINT32 RouteCount;\r
90 EFI_IP4_ROUTE_TABLE *RouteTable;\r
91 UINT32 IcmpTypeCount;\r
92 EFI_IP4_ICMP_TYPE *IcmpTypeList;\r
93} EFI_IP4_MODE_DATA;\r
94\r
95#pragma pack(1)\r
96\r
97typedef struct {\r
d1f95000 98 UINT8 HeaderLength:4;\r
99 UINT8 Version:4;\r
d1f95000 100 UINT8 TypeOfService;\r
101 UINT16 TotalLength;\r
102 UINT16 Identification;\r
103 UINT16 Fragmentation;\r
104 UINT8 TimeToLive;\r
105 UINT8 Protocol;\r
106 UINT16 Checksum;\r
107 EFI_IPv4_ADDRESS SourceAddress;\r
108 EFI_IPv4_ADDRESS DestinationAddress;\r
109} EFI_IP4_HEADER;\r
110#pragma pack()\r
111\r
112\r
113typedef struct {\r
114 UINT32 FragmentLength;\r
115 VOID *FragmentBuffer;\r
116} EFI_IP4_FRAGMENT_DATA;\r
117\r
118\r
119typedef struct {\r
120 EFI_TIME TimeStamp;\r
121 EFI_EVENT RecycleSignal;\r
122 UINT32 HeaderLength;\r
123 EFI_IP4_HEADER *Header;\r
124 UINT32 OptionsLength;\r
125 VOID *Options;\r
126 UINT32 DataLength;\r
127 UINT32 FragmentCount;\r
128 EFI_IP4_FRAGMENT_DATA FragmentTable[1];\r
129} EFI_IP4_RECEIVE_DATA;\r
130\r
131\r
132typedef struct {\r
133 EFI_IPv4_ADDRESS SourceAddress;\r
134 EFI_IPv4_ADDRESS GatewayAddress;\r
135 UINT8 Protocol;\r
136 UINT8 TypeOfService;\r
137 UINT8 TimeToLive;\r
138 BOOLEAN DoNotFragment;\r
139} EFI_IP4_OVERRIDE_DATA;\r
140\r
141typedef struct {\r
142 EFI_IPv4_ADDRESS DestinationAddress;\r
143 EFI_IP4_OVERRIDE_DATA *OverrideData; //OPTIONAL\r
144 UINT32 OptionsLength; //OPTIONAL\r
145 VOID *OptionsBuffer; //OPTIONAL\r
146 UINT32 TotalDataLength;\r
147 UINT32 FragmentCount;\r
148 EFI_IP4_FRAGMENT_DATA FragmentTable[1];\r
149} EFI_IP4_TRANSMIT_DATA;\r
150\r
151typedef struct {\r
152 EFI_EVENT Event;\r
153 EFI_STATUS Status;\r
154 union {\r
155 EFI_IP4_RECEIVE_DATA *RxData;\r
156 EFI_IP4_TRANSMIT_DATA *TxData;\r
157 } Packet;\r
158} EFI_IP4_COMPLETION_TOKEN;\r
159\r
160/**\r
161 Gets the current operational settings for this instance of the EFI IPv4 Protocol driver.\r
162\r
163 @param This Pointer to the EFI_IP4_PROTOCOL instance.\r
164 @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.\r
165 @param MnpConfigData Pointer to the managed network configuration data structure.\r
4ca9b6c4 166 @param SnpModeData Pointer to the simple network mode data structure.\r
d1f95000 167\r
168 @retval EFI_SUCCESS The operation completed successfully.\r
169 @retval EFI_INVALID_PARAMETER This is NULL.\r
170 @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.\r
171\r
172**/\r
173typedef\r
174EFI_STATUS\r
8b13229b 175(EFIAPI *EFI_IP4_GET_MODE_DATA)(\r
d1f95000 176 IN CONST EFI_IP4_PROTOCOL *This,\r
177 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r
178 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
179 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
ed66e1bc 180 ); \r
d1f95000 181\r
182/**\r
183 Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.\r
184\r
185 @param This Pointer to the EFI_IP4_PROTOCOL instance.\r
186 @param IpConfigData Pointer to the EFI IPv4 Protocol configuration data structure.\r
187\r
188 @retval EFI_SUCCESS The driver instance was successfully opened.\r
189 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,\r
190 RARP, etc.) is not finished yet.\r
191 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
192 @retval EFI_UNSUPPORTED One or more of the following conditions is TRUE:\r
193 A configuration protocol (DHCP, BOOTP, RARP, etc.) could\r
194 not be located when clients choose to use the default IPv4\r
195 address. This EFI IPv4 Protocol implementation does not\r
196 support this requested filter or timeout setting.\r
197 @retval EFI_OUT_OF_RESOURCES The EFI IPv4 Protocol driver instance data could not be allocated.\r
198 @retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the\r
199 IPv4 address or subnet mask can be changed. The interface must\r
200 also be stopped when switching to/from raw packet mode.\r
201 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv4\r
4ca9b6c4 202 Protocol driver instance is not opened.\r
d1f95000 203\r
204**/\r
205typedef \r
206EFI_STATUS\r
8b13229b 207(EFIAPI *EFI_IP4_CONFIGURE)(\r
d1f95000 208 IN EFI_IP4_PROTOCOL *This,\r
209 IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL\r
ed66e1bc 210 ); \r
d1f95000 211\r
212/**\r
213 Joins and leaves multicast groups.\r
214\r
215 @param This Pointer to the EFI_IP4_PROTOCOL instance.\r
216 @param JoinFlag Set to TRUE to join the multicast group session and FALSE to leave.\r
217 @param GroupAddress Pointer to the IPv4 multicast address.\r
218\r
219 @retval EFI_SUCCESS The operation completed successfully.\r
220 @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:\r
221 - This is NULL.\r
222 - JoinFlag is TRUE and GroupAddress is NULL.\r
223 - GroupAddress is not NULL and *GroupAddress is\r
224 not a multicast IPv4 address.\r
225 @retval EFI_NOT_STARTED This instance has not been started.\r
226 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,\r
227 RARP, etc.) is not finished yet.\r
228 @retval EFI_OUT_OF_RESOURCES System resources could not be allocated.\r
229 @retval EFI_UNSUPPORTED This EFI IPv4 Protocol implementation does not support multicast groups.\r
230 @retval EFI_ALREADY_STARTED The group address is already in the group table (when\r
231 JoinFlag is TRUE).\r
232 @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE).\r
233 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
234\r
235**/\r
236typedef \r
237EFI_STATUS\r
8b13229b 238(EFIAPI *EFI_IP4_GROUPS)(\r
d1f95000 239 IN EFI_IP4_PROTOCOL *This,\r
240 IN BOOLEAN JoinFlag,\r
241 IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL\r
ed66e1bc 242 ); \r
d1f95000 243\r
244/**\r
245 Adds and deletes routing table entries.\r
246\r
247 @param This Pointer to the EFI_IP4_PROTOCOL instance.\r
248 @param DeleteRoute Set to TRUE to delete this route from the routing table. Set to\r
249 FALSE to add this route to the routing table. SubnetAddress\r
250 and SubnetMask are used as the key to each route entry.\r
251 @param SubnetAddress The address of the subnet that needs to be routed.\r
252 @param SubnetMask The subnet mask of SubnetAddress.\r
253 @param GatewayAddress The unicast gateway IPv4 address for this route.\r
254\r
255 @retval EFI_SUCCESS The operation completed successfully.\r
256 @retval EFI_NOT_STARTED The driver instance has not been started.\r
257 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,\r
258 RARP, etc.) is not finished yet.\r
259 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
260 - This is NULL.\r
261 - SubnetAddress is NULL.\r
262 - SubnetMask is NULL.\r
263 - GatewayAddress is NULL.\r
264 - *SubnetAddress is not a valid subnet address.\r
265 - *SubnetMask is not a valid subnet mask.\r
266 - *GatewayAddress is not a valid unicast IPv4 address.\r
267 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.\r
268 @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).\r
269 @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when\r
270 DeleteRoute is FALSE).\r
271 \r
272**/\r
273typedef \r
274EFI_STATUS\r
8b13229b 275(EFIAPI *EFI_IP4_ROUTES)(\r
d1f95000 276 IN EFI_IP4_PROTOCOL *This,\r
277 IN BOOLEAN DeleteRoute,\r
278 IN EFI_IPv4_ADDRESS *SubnetAddress,\r
279 IN EFI_IPv4_ADDRESS *SubnetMask,\r
280 IN EFI_IPv4_ADDRESS *GatewayAddress \r
ed66e1bc 281 ); \r
d1f95000 282\r
283/**\r
284 Places outgoing data packets into the transmit queue.\r
285\r
286 @param This Pointer to the EFI_IP4_PROTOCOL instance.\r
287 @param Token Pointer to the transmit token.\r
288\r
289 @retval EFI_SUCCESS The data has been queued for transmission.\r
290 @retval EFI_NOT_STARTED This instance has not been started.\r
291 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,\r
292 RARP, etc.) is not finished yet.\r
293 @retval EFI_INVALID_PARAMETER One or more pameters are invalid.\r
294 @retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event\r
295 was already in the transmit queue.\r
296 @retval EFI_NOT_READY The completion token could not be queued because the transmit\r
297 queue is full. \r
298 @retval EFI_NOT_FOUND Not route is found to destination address.\r
299 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.\r
300 @retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too\r
301 short to transmit.\r
302 @retval EFI_BAD_BUFFER_SIZE The length of the IPv4 header + option length + total data length is\r
303 greater than MTU (or greater than the maximum packet size if\r
304 Token.Packet.TxData.OverrideData.\r
305 DoNotFragment is TRUE.)\r
306\r
307**/\r
308typedef \r
309EFI_STATUS\r
8b13229b 310(EFIAPI *EFI_IP4_TRANSMIT)(\r
d1f95000 311 IN EFI_IP4_PROTOCOL *This,\r
312 IN EFI_IP4_COMPLETION_TOKEN *Token\r
ed66e1bc 313 ); \r
d1f95000 314\r
315/**\r
316 Places a receiving request into the receiving queue.\r
317\r
318 @param This Pointer to the EFI_IP4_PROTOCOL instance.\r
319 @param Token Pointer to a token that is associated with the receive data descriptor.\r
320\r
321 @retval EFI_SUCCESS The receive completion token was cached.\r
322 @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.\r
323 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, RARP, etc.)\r
324 is not finished yet.\r
325 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
326 - This is NULL.\r
327 - Token is NULL.\r
328 - Token.Event is NULL.\r
329 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system\r
330 resources (usually memory).\r
331 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
332 The EFI IPv4 Protocol instance has been reset to startup defaults.\r
333 EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already\r
334 in the receive queue.\r
335 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.\r
336 @retval EFI_ICMP_ERROR An ICMP error packet was received.\r
337\r
338**/\r
339typedef \r
340EFI_STATUS\r
8b13229b 341(EFIAPI *EFI_IP4_RECEIVE)(\r
d1f95000 342 IN EFI_IP4_PROTOCOL *This,\r
343 IN EFI_IP4_COMPLETION_TOKEN *Token\r
ed66e1bc 344 ); \r
d1f95000 345\r
346/**\r
347 Abort an asynchronous transmit or receive request.\r
348\r
349 @param This Pointer to the EFI_IP4_PROTOCOL instance.\r
350 @param Token Pointer to a token that has been issued by\r
351 EFI_IP4_PROTOCOL.Transmit() or\r
352 EFI_IP4_PROTOCOL.Receive(). If NULL, all pending\r
353 tokens are aborted. Type EFI_IP4_COMPLETION_TOKEN is\r
354 defined in EFI_IP4_PROTOCOL.Transmit().\r
355\r
356 @retval EFI_SUCCESS The asynchronous I/O request was aborted and\r
357 Token.->Event was signaled. When Token is NULL, all\r
358 pending requests were aborted and their events were signaled.\r
359 @retval EFI_INVALID_PARAMETER This is NULL.\r
360 @retval EFI_NOT_STARTED This instance has not been started.\r
361 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,\r
362 RARP, etc.) is not finished yet.\r
363 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was\r
364 not found in the transmit or receive queue. It has either completed\r
365 or was not issued by Transmit() and Receive().\r
366\r
367**/\r
368typedef\r
369EFI_STATUS\r
8b13229b 370(EFIAPI *EFI_IP4_CANCEL)(\r
d1f95000 371 IN EFI_IP4_PROTOCOL *This,\r
372 IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL\r
ed66e1bc 373 ); \r
d1f95000 374 \r
375/**\r
376 Polls for incoming data packets and processes outgoing data packets.\r
377\r
378 @param This Pointer to the EFI_IP4_PROTOCOL instance.\r
379\r
380 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
381 @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.\r
382 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,\r
383 RARP, etc.) is not finished yet.\r
384 @retval EFI_INVALID_PARAMETER This is NULL.\r
385 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
386 @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
387 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.\r
388 Consider increasing the polling rate.\r
389\r
390**/\r
391typedef \r
392EFI_STATUS\r
8b13229b 393(EFIAPI *EFI_IP4_POLL)(\r
d1f95000 394 IN EFI_IP4_PROTOCOL *This\r
ed66e1bc 395 ); \r
d1f95000 396\r
44717a39 397///\r
398/// The EFI IPv4 Protocol implements a simple packet-oriented interface that can be \r
399/// used by drivers, daemons, and applications to transmit and receive network packets.\r
400///\r
d1f95000 401struct _EFI_IP4_PROTOCOL {\r
402 EFI_IP4_GET_MODE_DATA GetModeData;\r
403 EFI_IP4_CONFIGURE Configure;\r
404 EFI_IP4_GROUPS Groups;\r
405 EFI_IP4_ROUTES Routes;\r
406 EFI_IP4_TRANSMIT Transmit;\r
407 EFI_IP4_RECEIVE Receive;\r
408 EFI_IP4_CANCEL Cancel;\r
409 EFI_IP4_POLL Poll;\r
410};\r
411\r
412extern EFI_GUID gEfiIp4ServiceBindingProtocolGuid;\r
413extern EFI_GUID gEfiIp4ProtocolGuid;\r
414\r
415#endif\r