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