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