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