]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Library/IpIoLib.h
Fix some typo.
[mirror_edk2.git] / MdeModulePkg / Include / Library / IpIoLib.h
1 /** @file
2 This library provides IpIo layer upon EFI IP4 Protocol.
3
4 Copyright (c) 2005 - 2008, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _IP_IO_H_
16 #define _IP_IO_H_
17
18 #include <Protocol/Ip4.h>
19 #include <Library/IpIoLib.h>
20 #include <Library/NetLib.h>
21
22 //
23 // type and code define for ICMP protocol error got
24 // from IP
25 //
26 #define ICMP_TYPE_UNREACH 3
27 #define ICMP_TYPE_TIMXCEED 11
28 #define ICMP_TYPE_PARAMPROB 12
29 #define ICMP_TYPE_SOURCEQUENCH 4
30
31 #define ICMP_CODE_UNREACH_NET 0
32 #define ICMP_CODE_UNREACH_HOST 1
33 #define ICMP_CODE_UNREACH_PROTOCOL 2
34 #define ICMP_CODE_UNREACH_PORT 3
35 #define ICMP_CODE_UNREACH_NEEDFRAG 4
36 #define ICMP_CODE_UNREACH_SRCFAIL 5
37 #define ICMP_CODE_UNREACH_NET_UNKNOWN 6
38 #define ICMP_CODE_UNREACH_HOST_UNKNOWN 7
39 #define ICMP_CODE_UNREACH_ISOLATED 8
40 #define ICMP_CODE_UNREACH_NET_PROHIB 9
41 #define ICMP_CODE_UNREACH_HOST_PROHIB 10
42 #define ICMP_CODE_UNREACH_TOSNET 11
43 #define ICMP_CODE_UNREACH_TOSHOST 12
44
45 //
46 // this error will be delivered to the
47 // listening transportation layer protocol
48 // consuming IpIO
49 //
50 typedef enum {
51 ICMP_ERR_UNREACH_NET = 0,
52 ICMP_ERR_UNREACH_HOST,
53 ICMP_ERR_UNREACH_PROTOCOL,
54 ICMP_ERR_UNREACH_PORT,
55 ICMP_ERR_MSGSIZE,
56 ICMP_ERR_UNREACH_SRCFAIL,
57 ICMP_ERR_TIMXCEED_INTRANS,
58 ICMP_ERR_TIMXCEED_REASS,
59 ICMP_ERR_QUENCH,
60 ICMP_ERR_PARAMPROB
61 } ICMP_ERROR;
62
63 typedef struct _ICMP_ERROR_INFO {
64 BOOLEAN IsHard;
65 BOOLEAN Notify;
66 } ICMP_ERROR_INFO;
67
68 #define EFI_IP4_HEADER_LEN(HdrPtr) ((HdrPtr)->HeaderLength << 2)
69
70 extern EFI_IP4_CONFIG_DATA mIpIoDefaultIpConfigData;
71
72 typedef struct _EFI_NET_SESSION_DATA {
73 IP4_ADDR Source;
74 IP4_ADDR Dest;
75 EFI_IP4_HEADER *IpHdr;
76 } EFI_NET_SESSION_DATA;
77
78 typedef
79 VOID
80 (*PKT_RCVD_NOTIFY) (
81 IN EFI_STATUS Status, // rcvd pkt result
82 IN ICMP_ERROR IcmpErr, // if Status == EFI_ICMP_ERROR, this
83 // field is valid for user
84 IN EFI_NET_SESSION_DATA *NetSession, // the communication point
85 IN NET_BUF *Pkt, // packet received
86 IN VOID *Context // the Context provided by user for receive data
87 );
88
89 typedef
90 VOID
91 (*PKT_SENT_NOTIFY) (
92 IN EFI_STATUS Status, // sent pkt result
93 IN VOID *Context, // the context provided by user for sending data
94 IN VOID *Sender, // the sender to be notified
95 IN VOID *NotifyData // sent pkt related data to notify
96 );
97
98 typedef struct _IP_IO {
99
100 //
101 // the node used to link this IpIo to the active IpIo list.
102 //
103 LIST_ENTRY Entry;
104
105 // the list used to maintain the IP instance for different sending purpose.
106 //
107 LIST_ENTRY IpList;
108
109 //
110 // the ip instance consumed by this IP IO
111 //
112 EFI_HANDLE Controller;
113 EFI_HANDLE Image;
114 EFI_HANDLE ChildHandle;
115 EFI_IP4_PROTOCOL *Ip;
116 BOOLEAN IsConfigured;
117
118 //
119 // some ip config data can be changed
120 //
121 UINT8 Protocol;
122
123 //
124 // token and event used to get data from IP
125 //
126 EFI_IP4_COMPLETION_TOKEN RcvToken;
127
128 //
129 // list entry used to link the token passed to IP_IO
130 //
131 LIST_ENTRY PendingSndList;
132
133 //
134 // User interface used to get notify from IP_IO
135 //
136 VOID *RcvdContext;
137 VOID *SndContext;
138 PKT_RCVD_NOTIFY PktRcvdNotify;
139 PKT_SENT_NOTIFY PktSentNotify;
140 } IP_IO;
141
142 typedef struct _IP_IO_OPEN_DATA {
143 EFI_IP4_CONFIG_DATA IpConfigData;
144 VOID *RcvdContext;
145 VOID *SndContext;
146 PKT_RCVD_NOTIFY PktRcvdNotify;
147 PKT_SENT_NOTIFY PktSentNotify;
148 } IP_IO_OPEN_DATA;
149
150 typedef struct _IP_IO_SEND_ENTRY {
151 LIST_ENTRY Entry;
152 IP_IO *IpIo;
153 VOID *Context;
154 VOID *NotifyData;
155 EFI_IP4_PROTOCOL *Ip;
156 NET_BUF *Pkt;
157 EFI_IP4_COMPLETION_TOKEN *SndToken;
158 } IP_IO_SEND_ENTRY;
159
160 typedef EFI_IP4_OVERRIDE_DATA IP_IO_OVERRIDE;
161
162 typedef struct _IP_IO_IP_INFO {
163 IP4_ADDR Addr;
164 IP4_ADDR SubnetMask;
165 LIST_ENTRY Entry;
166 EFI_HANDLE ChildHandle;
167 EFI_IP4_PROTOCOL *Ip;
168 EFI_IP4_COMPLETION_TOKEN DummyRcvToken;
169 INTN RefCnt;
170 } IP_IO_IP_INFO;
171
172 /**
173 Create a new IP_IO instance.
174
175 @param Image The image handle of an IP_IO consumer protocol.
176 @param Controller The controller handle of an IP_IO consumer protocol
177 installed on.
178
179 @return Pointer to a newly created IP_IO instance.
180
181 **/
182 IP_IO *
183 EFIAPI
184 IpIoCreate (
185 IN EFI_HANDLE Image,
186 IN EFI_HANDLE Controller
187 );
188
189 /**
190 Destroy an IP_IO instance.
191
192 @param IpIo Pointer to the IP_IO instance that needs to
193 destroy.
194
195 @retval EFI_SUCCESS The IP_IO instance destroyed successfully.
196 @retval other Error condition occurred.
197
198 **/
199 EFI_STATUS
200 EFIAPI
201 IpIoDestroy (
202 IN IP_IO *IpIo
203 );
204
205 /**
206 Stop an IP_IO instance.
207
208 @param IpIo Pointer to the IP_IO instance that needs to stop.
209
210 @retval EFI_SUCCESS The IP_IO instance stopped successfully.
211 @retval other Error condition occurred.
212
213 **/
214 EFI_STATUS
215 EFIAPI
216 IpIoStop (
217 IN IP_IO *IpIo
218 );
219
220 /**
221 Open an IP_IO instance for use.
222
223 @param IpIo Pointer to an IP_IO instance that needs to open.
224 @param OpenData The configuration data for the IP_IO instance.
225
226 @retval EFI_SUCCESS The IP_IO instance opened with OpenData
227 successfully.
228 @retval other Error condition occurred.
229
230 **/
231 EFI_STATUS
232 IpIoOpen (
233 IN IP_IO *IpIo,
234 IN IP_IO_OPEN_DATA *OpenData
235 );
236
237 /**
238 Send out an IP packet.
239
240 @param IpIo Pointer to an IP_IO instance used for sending IP
241 packet.
242 @param Pkt Pointer to the IP packet to be sent.
243 @param Sender The IP protocol instance used for sending.
244 @param Context
245 @param NotifyData
246 @param Dest The destination IP address to send this packet to.
247 @param OverrideData The data to override some configuration of the IP
248 instance used for sending.
249
250 @retval EFI_SUCCESS The operation is completed successfully.
251 @retval EFI_NOT_STARTED The IpIo is not configured.
252 @retval EFI_OUT_OF_RESOURCES Failed due to resource limit.
253
254 **/
255 EFI_STATUS
256 EFIAPI
257 IpIoSend (
258 IN IP_IO *IpIo,
259 IN NET_BUF *Pkt,
260 IN IP_IO_IP_INFO *Sender,
261 IN VOID *Context OPTIONAL,
262 IN VOID *NotifyData OPTIONAL,
263 IN IP4_ADDR Dest,
264 IN IP_IO_OVERRIDE *OverrideData
265 );
266
267 /**
268 Cancel the IP transmit token which wraps this Packet.
269
270 @param IpIo Pointer to the IP_IO instance.
271 @param Packet Pointer to the packet to cancel.
272
273 **/
274 VOID
275 EFIAPI
276 IpIoCancelTxToken (
277 IN IP_IO *IpIo,
278 IN VOID *Packet
279 );
280
281 /**
282 Add a new IP instance for sending data.
283
284 @param IpIo Pointer to a IP_IO instance to add a new IP
285 instance for sending purpose.
286
287 @return Pointer to the created IP_IO_IP_INFO structure, NULL is failed.
288
289 **/
290 IP_IO_IP_INFO *
291 EFIAPI
292 IpIoAddIp (
293 IN IP_IO *IpIo
294 );
295
296 /**
297 Configure the IP instance of this IpInfo and start the receiving if Ip4ConfigData
298 is not NULL.
299
300 @param IpInfo Pointer to the IP_IO_IP_INFO instance.
301 @param Ip4ConfigData The IP4 configure data used to configure the ip
302 instance, if NULL the ip instance is reseted. If
303 UseDefaultAddress is set to TRUE, and the configure
304 operation succeeds, the default address information
305 is written back in this Ip4ConfigData.
306
307 @retval EFI_STATUS The status returned by IP4->Configure or
308 IP4->Receive.
309
310 **/
311 EFI_STATUS
312 EFIAPI
313 IpIoConfigIp (
314 IN IP_IO_IP_INFO *IpInfo,
315 IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData OPTIONAL
316 );
317
318 /**
319 Destroy an IP instance maintained in IpIo->IpList for
320 sending purpose.
321
322 @param IpIo Pointer to the IP_IO instance.
323 @param IpInfo Pointer to the IpInfo to be removed.
324
325 @return None.
326
327 **/
328 VOID
329 EFIAPI
330 IpIoRemoveIp (
331 IN IP_IO *IpIo,
332 IN IP_IO_IP_INFO *IpInfo
333 );
334
335 /**
336 Find the first IP protocol maintained in IpIo whose local
337 address is the same with Src.
338
339 @param IpIo Pointer to the pointer of the IP_IO instance.
340 @param Src The local IP address.
341
342 @return Pointer to the IP protocol can be used for sending purpose and its local
343 @return address is the same with Src.
344
345 **/
346 IP_IO_IP_INFO *
347 EFIAPI
348 IpIoFindSender (
349 IN OUT IP_IO **IpIo,
350 IN IP4_ADDR Src
351 );
352
353 /**
354 Get the ICMP error map information, the ErrorStatus will be returned.
355 The IsHard and Notify are optional. If they are not NULL, this rouine will
356 fill them.
357 We move IcmpErrMap[] to local variable to enable EBC build.
358
359 @param IcmpError IcmpError Type
360 @param IsHard Whether it is a hard error
361 @param Notify Whether it need to notify SockError
362
363 @return ICMP Error Status
364
365 **/
366 EFI_STATUS
367 EFIAPI
368 IpIoGetIcmpErrStatus (
369 IN ICMP_ERROR IcmpError,
370 OUT BOOLEAN *IsHard, OPTIONAL
371 OUT BOOLEAN *Notify OPTIONAL
372 );
373
374 #endif