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