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