]>
Commit | Line | Data |
---|---|---|
cbf316f2 | 1 | /** @file |
7b414b4e | 2 | This library provides IpIo layer upon EFI IP4 Protocol.\r |
cbf316f2 | 3 | |
7b414b4e | 4 | Copyright (c) 2005 - 2008, Intel Corporation |
cbf316f2 | 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 | ||
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 | |
51 | typedef 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 | |
64 | typedef 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 | ||
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 | // | |
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 | ||
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 { | |
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 | 161 | typedef EFI_IP4_OVERRIDE_DATA IP_IO_OVERRIDE; |
cbf316f2 | 162 | |
163 | typedef 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 | 183 | IP_IO * |
7b414b4e | 184 | EFIAPI |
cbf316f2 | 185 | IpIoCreate ( |
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 | 200 | EFI_STATUS |
7b414b4e | 201 | EFIAPI |
cbf316f2 | 202 | IpIoDestroy ( |
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 | 215 | EFI_STATUS |
7b414b4e | 216 | EFIAPI |
cbf316f2 | 217 | IpIoStop ( |
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 | 232 | EFI_STATUS |
233 | IpIoOpen ( | |
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 | |
5f597758 LG |
245 | @param Context |
246 | @param NotifyData \r | |
7b414b4e | 247 | @param Dest The destination IP address to send this packet to.\r |
248 | @param OverrideData The data to override some configuration of the IP\r | |
249 | instance used for sending.\r | |
250 | \r | |
251 | @retval EFI_SUCCESS The operation is completed successfully.\r | |
252 | @retval EFI_NOT_STARTED The IpIo is not configured.\r | |
253 | @retval EFI_OUT_OF_RESOURCES Failed due to resource limit.\r | |
254 | \r | |
255 | **/ | |
cbf316f2 | 256 | EFI_STATUS |
7b414b4e | 257 | EFIAPI |
cbf316f2 | 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 | ||
7b414b4e | 268 | /**\r |
5f597758 | 269 | Cancel the IP transmit token which wraps this Packet.\r |
7b414b4e | 270 | \r |
5f597758 LG |
271 | @param IpIo Pointer to the IP_IO instance.\r |
272 | @param Packet Pointer to the packet to cancel.\r | |
273 | ||
7b414b4e | 274 | **/ |
cbf316f2 | 275 | VOID |
7b414b4e | 276 | EFIAPI |
cbf316f2 | 277 | IpIoCancelTxToken ( |
278 | IN IP_IO *IpIo, | |
279 | IN VOID *Packet | |
280 | ); | |
281 | ||
7b414b4e | 282 | /**\r |
283 | Add a new IP instance for sending data.\r | |
284 | \r | |
285 | @param IpIo Pointer to a IP_IO instance to add a new IP\r | |
286 | instance for sending purpose.\r | |
287 | \r | |
288 | @return Pointer to the created IP_IO_IP_INFO structure, NULL is failed.\r | |
289 | \r | |
290 | **/ | |
cbf316f2 | 291 | IP_IO_IP_INFO * |
7b414b4e | 292 | EFIAPI |
cbf316f2 | 293 | IpIoAddIp ( |
294 | IN IP_IO *IpIo | |
295 | ); | |
296 | ||
7b414b4e | 297 | /**\r |
298 | Configure the IP instance of this IpInfo and start the receiving if Ip4ConfigData\r | |
299 | is not NULL.\r | |
300 | \r | |
301 | @param IpInfo Pointer to the IP_IO_IP_INFO instance.\r | |
302 | @param Ip4ConfigData The IP4 configure data used to configure the ip\r | |
303 | instance, if NULL the ip instance is reseted. If\r | |
304 | UseDefaultAddress is set to TRUE, and the configure\r | |
305 | operation succeeds, the default address information\r | |
306 | is written back in this Ip4ConfigData.\r | |
307 | \r | |
308 | @retval EFI_STATUS The status returned by IP4->Configure or\r | |
309 | IP4->Receive.\r | |
310 | \r | |
311 | **/ | |
cbf316f2 | 312 | EFI_STATUS |
7b414b4e | 313 | EFIAPI |
cbf316f2 | 314 | IpIoConfigIp ( |
315 | IN IP_IO_IP_INFO *IpInfo, | |
316 | IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData OPTIONAL | |
317 | ); | |
318 | ||
7b414b4e | 319 | /**\r |
320 | Destroy an IP instance maintained in IpIo->IpList for\r | |
321 | sending purpose.\r | |
322 | \r | |
323 | @param IpIo Pointer to the IP_IO instance.\r | |
324 | @param IpInfo Pointer to the IpInfo to be removed.\r | |
325 | \r | |
326 | @return None.\r | |
327 | \r | |
328 | **/ | |
cbf316f2 | 329 | VOID |
7b414b4e | 330 | EFIAPI |
cbf316f2 | 331 | IpIoRemoveIp ( |
332 | IN IP_IO *IpIo, | |
333 | IN IP_IO_IP_INFO *IpInfo | |
334 | ); | |
335 | ||
7b414b4e | 336 | /**\r |
337 | Find the first IP protocol maintained in IpIo whose local\r | |
338 | address is the same with Src.\r | |
339 | \r | |
340 | @param IpIo Pointer to the pointer of the IP_IO instance.\r | |
341 | @param Src The local IP address.\r | |
342 | \r | |
343 | @return Pointer to the IP protocol can be used for sending purpose and its local\r | |
344 | @return address is the same with Src.\r | |
345 | \r | |
346 | **/ | |
cbf316f2 | 347 | IP_IO_IP_INFO * |
7b414b4e | 348 | EFIAPI |
cbf316f2 | 349 | IpIoFindSender ( |
350 | IN OUT IP_IO **IpIo, | |
351 | IN IP4_ADDR Src | |
352 | ); | |
353 | ||
7b414b4e | 354 | /**\r |
355 | Get the ICMP error map information, the ErrorStatus will be returned.\r | |
356 | The IsHard and Notify are optional. If they are not NULL, this rouine will\r | |
357 | fill them.\r | |
358 | We move IcmpErrMap[] to local variable to enable EBC build.\r | |
359 | \r | |
360 | @param IcmpError IcmpError Type\r | |
361 | @param IsHard Whether it is a hard error\r | |
362 | @param Notify Whether it need to notify SockError\r | |
363 | \r | |
364 | @return ICMP Error Status\r | |
365 | \r | |
366 | **/\r | |
cbf316f2 | 367 | EFI_STATUS |
7b414b4e | 368 | EFIAPI |
cbf316f2 | 369 | IpIoGetIcmpErrStatus ( |
370 | IN ICMP_ERROR IcmpError, | |
371 | OUT BOOLEAN *IsHard, OPTIONAL | |
372 | OUT BOOLEAN *Notify OPTIONAL | |
373 | ); | |
374 | ||
375 | #endif |