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