]>
Commit | Line | Data |
---|---|---|
97b38d4e | 1 | /** @file\r |
fb115c61 | 2 | This library is only intended to be used by UEFI network stack modules.\r |
3 | It provides the combined IpIo layer on the EFI IP4 Protocol and EFI IP6 protocol.\r | |
97b38d4e | 4 | \r |
d1102dba LG |
5 | Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r |
6 | This program and the accompanying materials are licensed and made available under\r | |
7 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
64a80549 | 8 | The full text of the license may be found at\r |
d1102dba | 9 | http://opensource.org/licenses/bsd-license.php.\r |
97b38d4e | 10 | \r |
d1102dba | 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
97b38d4e | 12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _IP_IO_H_\r | |
17 | #define _IP_IO_H_\r | |
18 | \r | |
19 | #include <Protocol/Ip4.h>\r | |
fb115c61 | 20 | #include <Protocol/Ip6.h>\r |
cdfdbb97 | 21 | \r |
97b38d4e | 22 | #include <Library/NetLib.h>\r |
23 | \r | |
24 | //\r | |
d1102dba | 25 | // type and code define for ICMP protocol error\r |
97b38d4e | 26 | // from IP\r |
27 | //\r | |
28 | #define ICMP_TYPE_UNREACH 3\r | |
cdfdbb97 | 29 | #define ICMP_TYPE_TIMXCEED 11\r |
97b38d4e | 30 | #define ICMP_TYPE_PARAMPROB 12\r |
31 | #define ICMP_TYPE_SOURCEQUENCH 4\r | |
32 | \r | |
33 | #define ICMP_CODE_UNREACH_NET 0\r | |
34 | #define ICMP_CODE_UNREACH_HOST 1\r | |
35 | #define ICMP_CODE_UNREACH_PROTOCOL 2\r | |
36 | #define ICMP_CODE_UNREACH_PORT 3\r | |
37 | #define ICMP_CODE_UNREACH_NEEDFRAG 4\r | |
38 | #define ICMP_CODE_UNREACH_SRCFAIL 5\r | |
39 | #define ICMP_CODE_UNREACH_NET_UNKNOWN 6\r | |
40 | #define ICMP_CODE_UNREACH_HOST_UNKNOWN 7\r | |
41 | #define ICMP_CODE_UNREACH_ISOLATED 8\r | |
42 | #define ICMP_CODE_UNREACH_NET_PROHIB 9\r | |
43 | #define ICMP_CODE_UNREACH_HOST_PROHIB 10\r | |
44 | #define ICMP_CODE_UNREACH_TOSNET 11\r | |
45 | #define ICMP_CODE_UNREACH_TOSHOST 12\r | |
46 | \r | |
cdfdbb97 | 47 | /**\r |
e9b67286 | 48 | Get the IP header length from the struct EFI_IP4_HEADER. HeaderLength is\r |
cdfdbb97 | 49 | Internet header length in 32-bit words, so HeaderLength<<2 is the real\r |
50 | length of IP header.\r | |
d1102dba | 51 | \r |
64a80549 | 52 | @param[out] HdrPtr A pointer to EFI_IP4_HEADER.\r |
d1102dba | 53 | \r |
64a80549 | 54 | @return The IP header length.\r |
cdfdbb97 | 55 | **/\r |
56 | #define EFI_IP4_HEADER_LEN(HdrPtr) ((HdrPtr)->HeaderLength << 2)\r | |
57 | \r | |
58 | /**\r | |
d1102dba LG |
59 | To types of ICMP error which consist of ICMP header, IP header and original\r |
60 | datagram's data, get length from sum of ICMP header length, IP header length\r | |
cdfdbb97 | 61 | and first 64 bits of datagram's data length.\r |
d1102dba | 62 | \r |
64a80549 | 63 | @param[in] IpHdr A pointer to EFI_IP4_HEADER.\r |
d1102dba | 64 | \r |
64a80549 | 65 | @return The ICMP error length.\r |
cdfdbb97 | 66 | **/\r |
67 | #define ICMP_ERRLEN(IpHdr) \\r | |
68 | (sizeof(IP4_ICMP_HEAD) + EFI_IP4_HEADER_LEN(IpHdr) + 8)\r | |
69 | \r | |
70 | /**\r | |
71 | Get the packet header from NET_BUF.\r | |
d1102dba | 72 | \r |
64a80549 | 73 | @param[out] Buf A pointer to NET_BUF.\r |
74 | @param[in] Type Header type.\r | |
d1102dba | 75 | \r |
64a80549 | 76 | @return The pointer to packet header.\r |
cdfdbb97 | 77 | **/\r |
78 | #define NET_PROTO_HDR(Buf, Type) ((Type *) ((Buf)->BlockOp[0].Head))\r | |
79 | \r | |
d1102dba | 80 | \r |
fb115c61 | 81 | extern EFI_IP4_CONFIG_DATA mIp4IoDefaultIpConfigData;\r |
82 | extern EFI_IP6_CONFIG_DATA mIp6IoDefaultIpConfigData;\r | |
83 | \r | |
cdfdbb97 | 84 | \r |
e29a2e7e | 85 | ///\r |
86 | /// This error will be delivered to the\r | |
87 | /// listening transportation layer protocol\r | |
88 | /// that consumes IpIO.\r | |
89 | ///\r | |
b45b45b2 | 90 | \r |
91 | #define ICMP_ERR_UNREACH_NET 0\r | |
92 | #define ICMP_ERR_UNREACH_HOST 1\r | |
93 | #define ICMP_ERR_UNREACH_PROTOCOL 2\r | |
94 | #define ICMP_ERR_UNREACH_PORT 3\r | |
95 | #define ICMP_ERR_MSGSIZE 4\r | |
96 | #define ICMP_ERR_UNREACH_SRCFAIL 5\r | |
97 | #define ICMP_ERR_TIMXCEED_INTRANS 6\r | |
98 | #define ICMP_ERR_TIMXCEED_REASS 7\r | |
99 | #define ICMP_ERR_QUENCH 8\r | |
100 | #define ICMP_ERR_PARAMPROB 9\r | |
101 | \r | |
102 | #define ICMP6_ERR_UNREACH_NET 0\r | |
103 | #define ICMP6_ERR_UNREACH_HOST 1\r | |
104 | #define ICMP6_ERR_UNREACH_PROTOCOL 2\r | |
105 | #define ICMP6_ERR_UNREACH_PORT 3\r | |
106 | #define ICMP6_ERR_PACKAGE_TOOBIG 4\r | |
107 | #define ICMP6_ERR_TIMXCEED_HOPLIMIT 5\r | |
108 | #define ICMP6_ERR_TIMXCEED_REASS 6\r | |
109 | #define ICMP6_ERR_PARAMPROB_HEADER 7\r | |
110 | #define ICMP6_ERR_PARAMPROB_NEXHEADER 8\r | |
111 | #define ICMP6_ERR_PARAMPROB_IPV6OPTION 9\r | |
fb115c61 | 112 | \r |
e29a2e7e | 113 | ///\r |
e9b67286 | 114 | /// The helper struct for IpIoGetIcmpErrStatus(). It is for internal use only.\r |
e29a2e7e | 115 | ///\r |
cdfdbb97 | 116 | typedef struct {\r |
fb115c61 | 117 | BOOLEAN IsHard;\r |
118 | BOOLEAN Notify;\r | |
97b38d4e | 119 | } ICMP_ERROR_INFO;\r |
120 | \r | |
fb115c61 | 121 | typedef union {\r |
122 | EFI_IP4_COMPLETION_TOKEN Ip4Token;\r | |
123 | EFI_IP6_COMPLETION_TOKEN Ip6Token;\r | |
124 | } IP_IO_IP_COMPLETION_TOKEN;\r | |
125 | \r | |
126 | typedef union {\r | |
127 | EFI_IP4_TRANSMIT_DATA Ip4TxData;\r | |
128 | EFI_IP6_TRANSMIT_DATA Ip6TxData;\r | |
129 | } IP_IO_IP_TX_DATA;\r | |
130 | \r | |
131 | typedef union {\r | |
132 | EFI_IP4_RECEIVE_DATA Ip4RxData;\r | |
133 | EFI_IP6_RECEIVE_DATA Ip6RxData;\r | |
134 | } IP_IO_IP_RX_DATA;\r | |
135 | \r | |
136 | typedef union {\r | |
137 | EFI_IP4_OVERRIDE_DATA Ip4OverrideData;\r | |
138 | EFI_IP6_OVERRIDE_DATA Ip6OverrideData;\r | |
139 | } IP_IO_OVERRIDE;\r | |
140 | \r | |
141 | typedef union {\r | |
142 | EFI_IP4_CONFIG_DATA Ip4CfgData;\r | |
143 | EFI_IP6_CONFIG_DATA Ip6CfgData;\r | |
144 | } IP_IO_IP_CONFIG_DATA;\r | |
145 | \r | |
b45b45b2 | 146 | typedef union {\r |
147 | EFI_IP4_HEADER *Ip4Hdr;\r | |
148 | EFI_IP6_HEADER *Ip6Hdr;\r | |
149 | } IP_IO_IP_HEADER;\r | |
150 | \r | |
151 | typedef union {\r | |
152 | IP4_ADDR SubnetMask;\r | |
153 | UINT8 PrefixLength;\r | |
154 | } IP_IO_IP_MASK;\r | |
155 | \r | |
2a2e33b2 | 156 | typedef union {\r |
157 | EFI_IP4_PROTOCOL *Ip4;\r | |
158 | EFI_IP6_PROTOCOL *Ip6;\r | |
159 | } IP_IO_IP_PROTOCOL;\r | |
160 | \r | |
e29a2e7e | 161 | ///\r |
162 | /// The IP session for an IP receive packet.\r | |
163 | ///\r | |
97b38d4e | 164 | typedef struct _EFI_NET_SESSION_DATA {\r |
64a80549 | 165 | EFI_IP_ADDRESS Source; ///< Source IP of the received packet.\r |
166 | EFI_IP_ADDRESS Dest; ///< Destination IP of the received packet.\r | |
167 | IP_IO_IP_HEADER IpHdr; ///< IP header of the received packet.\r | |
d1102dba LG |
168 | UINT32 IpHdrLen; ///< IP header length of the received packet.\r |
169 | ///< For IPv6, it includes the IP6 header\r | |
a09ee46d | 170 | ///< length and extension header length. For\r |
171 | ///< IPv4, it includes the IP4 header length\r | |
172 | ///< and options length.\r | |
64a80549 | 173 | UINT8 IpVersion; ///< The IP version of the received packet.\r |
97b38d4e | 174 | } EFI_NET_SESSION_DATA;\r |
175 | \r | |
e29a2e7e | 176 | /**\r |
177 | The prototype is called back when an IP packet is received.\r | |
d1102dba | 178 | \r |
64a80549 | 179 | @param[in] Status The result of the receive request.\r |
180 | @param[in] IcmpErr Valid when Status is EFI_ICMP_ERROR.\r | |
181 | @param[in] NetSession The IP session for the received packet.\r | |
182 | @param[in] Pkt The packet received.\r | |
e9b67286 | 183 | @param[in] Context The data provided by the user for the received packet when\r |
cdfdbb97 | 184 | the callback is registered in IP_IO_OPEN_DATA::RcvdContext.\r |
d1102dba | 185 | \r |
e29a2e7e | 186 | **/\r |
97b38d4e | 187 | typedef\r |
188 | VOID\r | |
e798cd87 | 189 | (EFIAPI *PKT_RCVD_NOTIFY) (\r |
d1102dba | 190 | IN EFI_STATUS Status,\r |
b45b45b2 | 191 | IN UINT8 IcmpErr,\r |
e29a2e7e | 192 | IN EFI_NET_SESSION_DATA *NetSession,\r |
193 | IN NET_BUF *Pkt,\r | |
194 | IN VOID *Context\r | |
97b38d4e | 195 | );\r |
196 | \r | |
e29a2e7e | 197 | /**\r |
198 | The prototype is called back when an IP packet is sent.\r | |
d1102dba | 199 | \r |
64a80549 | 200 | @param[in] Status Result of the IP packet being sent.\r |
cdfdbb97 | 201 | @param[in] Context The data provided by user for the received packet when\r |
202 | the callback is registered in IP_IO_OPEN_DATA::SndContext.\r | |
d1102dba | 203 | @param[in] Sender A Union type to specify a pointer of EFI_IP4_PROTOCOL\r |
2a2e33b2 | 204 | or EFI_IP6_PROTOCOL.\r |
64a80549 | 205 | @param[in] NotifyData The Context data specified when calling IpIoSend()\r |
d1102dba | 206 | \r |
e29a2e7e | 207 | **/\r |
97b38d4e | 208 | typedef\r |
209 | VOID\r | |
e798cd87 | 210 | (EFIAPI *PKT_SENT_NOTIFY) (\r |
2a2e33b2 | 211 | IN EFI_STATUS Status,\r |
212 | IN VOID *Context,\r | |
213 | IN IP_IO_IP_PROTOCOL Sender,\r | |
214 | IN VOID *NotifyData\r | |
97b38d4e | 215 | );\r |
216 | \r | |
e29a2e7e | 217 | ///\r |
fb115c61 | 218 | /// This data structure wraps Ip4/Ip6 instances. The IpIo Library uses it for all\r |
219 | /// Ip4/Ip6 operations.\r | |
e29a2e7e | 220 | ///\r |
97b38d4e | 221 | typedef struct _IP_IO {\r |
e29a2e7e | 222 | ///\r |
223 | /// The node used to link this IpIo to the active IpIo list.\r | |
224 | ///\r | |
97b38d4e | 225 | LIST_ENTRY Entry;\r |
226 | \r | |
e29a2e7e | 227 | ///\r |
228 | /// The list used to maintain the IP instance for different sending purpose.\r | |
229 | ///\r | |
97b38d4e | 230 | LIST_ENTRY IpList;\r |
d1102dba | 231 | \r |
97b38d4e | 232 | EFI_HANDLE Controller;\r |
233 | EFI_HANDLE Image;\r | |
234 | EFI_HANDLE ChildHandle;\r | |
e29a2e7e | 235 | //\r |
236 | // The IP instance consumed by this IP_IO\r | |
237 | //\r | |
2a2e33b2 | 238 | IP_IO_IP_PROTOCOL Ip;\r |
97b38d4e | 239 | BOOLEAN IsConfigured;\r |
240 | \r | |
e29a2e7e | 241 | ///\r |
64a80549 | 242 | /// Some ip configuration data can be changed.\r |
e29a2e7e | 243 | ///\r |
97b38d4e | 244 | UINT8 Protocol;\r |
245 | \r | |
e29a2e7e | 246 | ///\r |
64a80549 | 247 | /// Token and event used to get data from IP.\r |
e29a2e7e | 248 | ///\r |
d1102dba | 249 | IP_IO_IP_COMPLETION_TOKEN RcvToken;\r |
97b38d4e | 250 | \r |
e29a2e7e | 251 | ///\r |
64a80549 | 252 | /// List entry used to link the token passed to IP_IO.\r |
e29a2e7e | 253 | ///\r |
97b38d4e | 254 | LIST_ENTRY PendingSndList;\r |
255 | \r | |
256 | //\r | |
257 | // User interface used to get notify from IP_IO\r | |
258 | //\r | |
64a80549 | 259 | VOID *RcvdContext; ///< See IP_IO_OPEN_DATA::RcvdContext.\r |
260 | VOID *SndContext; ///< See IP_IO_OPEN_DATA::SndContext.\r | |
261 | PKT_RCVD_NOTIFY PktRcvdNotify; ///< See IP_IO_OPEN_DATA::PktRcvdNotify.\r | |
262 | PKT_SENT_NOTIFY PktSentNotify; ///< See IP_IO_OPEN_DATA::PktSentNotify.\r | |
b45b45b2 | 263 | UINT8 IpVersion;\r |
01b5ac88 FS |
264 | IP4_ADDR StationIp;\r |
265 | IP4_ADDR SubnetMask;\r | |
97b38d4e | 266 | } IP_IO;\r |
267 | \r | |
e29a2e7e | 268 | ///\r |
e9b67286 | 269 | /// The struct is for the user to pass IP configuration and callbacks to IP_IO.\r |
e29a2e7e | 270 | /// It is used by IpIoOpen().\r |
271 | ///\r | |
97b38d4e | 272 | typedef struct _IP_IO_OPEN_DATA {\r |
64a80549 | 273 | IP_IO_IP_CONFIG_DATA IpConfigData; ///< Configuration of the IP instance.\r |
274 | VOID *RcvdContext; ///< Context data used by receive callback.\r | |
275 | VOID *SndContext; ///< Context data used by send callback.\r | |
276 | PKT_RCVD_NOTIFY PktRcvdNotify; ///< Receive callback.\r | |
277 | PKT_SENT_NOTIFY PktSentNotify; ///< Send callback.\r | |
97b38d4e | 278 | } IP_IO_OPEN_DATA;\r |
279 | \r | |
e29a2e7e | 280 | ///\r |
281 | /// Internal struct book-keeping send request of IP_IO.\r | |
282 | ///\r | |
283 | /// An IP_IO_SEND_ENTRY will be created each time a send request is issued to\r | |
284 | /// IP_IO via IpIoSend().\r | |
285 | ///\r | |
97b38d4e | 286 | typedef struct _IP_IO_SEND_ENTRY {\r |
287 | LIST_ENTRY Entry;\r | |
288 | IP_IO *IpIo;\r | |
289 | VOID *Context;\r | |
290 | VOID *NotifyData;\r | |
2a2e33b2 | 291 | IP_IO_IP_PROTOCOL Ip;\r |
97b38d4e | 292 | NET_BUF *Pkt;\r |
fb115c61 | 293 | IP_IO_IP_COMPLETION_TOKEN SndToken;\r |
97b38d4e | 294 | } IP_IO_SEND_ENTRY;\r |
295 | \r | |
e29a2e7e | 296 | ///\r |
297 | /// The IP_IO_IP_INFO is used in IpIoSend() to override the default IP instance\r | |
298 | /// in IP_IO.\r | |
299 | ///\r | |
97b38d4e | 300 | typedef struct _IP_IO_IP_INFO {\r |
fb115c61 | 301 | EFI_IP_ADDRESS Addr;\r |
b45b45b2 | 302 | IP_IO_IP_MASK PreMask;\r |
97b38d4e | 303 | LIST_ENTRY Entry;\r |
304 | EFI_HANDLE ChildHandle;\r | |
2a2e33b2 | 305 | IP_IO_IP_PROTOCOL Ip;\r |
fb115c61 | 306 | IP_IO_IP_COMPLETION_TOKEN DummyRcvToken;\r |
97b38d4e | 307 | INTN RefCnt;\r |
b45b45b2 | 308 | UINT8 IpVersion;\r |
97b38d4e | 309 | } IP_IO_IP_INFO;\r |
310 | \r | |
311 | /**\r | |
312 | Create a new IP_IO instance.\r | |
2b208747 WF |
313 | \r |
314 | If IpVersion is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r | |
d1102dba | 315 | \r |
fb115c61 | 316 | This function uses IP4/IP6 service binding protocol in Controller to create\r |
317 | an IP4/IP6 child (aka IP4/IP6 instance).\r | |
97b38d4e | 318 | \r |
cdfdbb97 | 319 | @param[in] Image The image handle of the driver or application that\r |
e29a2e7e | 320 | consumes IP_IO.\r |
fb115c61 | 321 | @param[in] Controller The controller handle that has IP4 or IP6 service\r |
322 | binding protocol installed.\r | |
323 | @param[in] IpVersion The version of the IP protocol to use, either\r | |
d1102dba | 324 | IPv4 or IPv6.\r |
97b38d4e | 325 | \r |
64a80549 | 326 | @return The pointer to a newly created IP_IO instance, or NULL if failed.\r |
97b38d4e | 327 | \r |
328 | **/\r | |
329 | IP_IO *\r | |
330 | EFIAPI\r | |
331 | IpIoCreate (\r | |
332 | IN EFI_HANDLE Image,\r | |
fb115c61 | 333 | IN EFI_HANDLE Controller,\r |
b45b45b2 | 334 | IN UINT8 IpVersion\r |
97b38d4e | 335 | );\r |
336 | \r | |
337 | /**\r | |
338 | Destroy an IP_IO instance.\r | |
d1102dba | 339 | \r |
e29a2e7e | 340 | This function is paired with IpIoCreate(). The IP_IO will be closed first.\r |
341 | Resource will be freed afterwards. See IpIoClose().\r | |
97b38d4e | 342 | \r |
64a80549 | 343 | @param[in, out] IpIo The pointer to the IP_IO instance that needs to be\r |
e29a2e7e | 344 | destroyed.\r |
97b38d4e | 345 | \r |
64a80549 | 346 | @retval EFI_SUCCESS The IP_IO instance was destroyed successfully.\r |
347 | @retval Others An error condition occurred.\r | |
97b38d4e | 348 | \r |
349 | **/\r | |
350 | EFI_STATUS\r | |
351 | EFIAPI\r | |
352 | IpIoDestroy (\r | |
cdfdbb97 | 353 | IN OUT IP_IO *IpIo\r |
97b38d4e | 354 | );\r |
355 | \r | |
356 | /**\r | |
357 | Stop an IP_IO instance.\r | |
2b208747 WF |
358 | \r |
359 | If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r | |
d1102dba | 360 | \r |
e9b67286 | 361 | This function is paired with IpIoOpen(). The IP_IO will be unconfigured, and all\r |
362 | pending send/receive tokens will be canceled.\r | |
97b38d4e | 363 | \r |
64a80549 | 364 | @param[in, out] IpIo The pointer to the IP_IO instance that needs to stop.\r |
97b38d4e | 365 | \r |
6ccfeec2 FS |
366 | @retval EFI_SUCCESS The IP_IO instance stopped successfully.\r |
367 | @retval EFI_INVALID_PARAMETER Invalid input parameter.\r | |
368 | @retval Others Anrror condition occurred.\r | |
97b38d4e | 369 | \r |
370 | **/\r | |
371 | EFI_STATUS\r | |
372 | EFIAPI\r | |
373 | IpIoStop (\r | |
cdfdbb97 | 374 | IN OUT IP_IO *IpIo\r |
97b38d4e | 375 | );\r |
376 | \r | |
377 | /**\r | |
378 | Open an IP_IO instance for use.\r | |
2b208747 WF |
379 | \r |
380 | If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r | |
381 | \r | |
e29a2e7e | 382 | This function is called after IpIoCreate(). It is used for configuring the IP\r |
383 | instance and register the callbacks and their context data for sending and\r | |
384 | receiving IP packets.\r | |
97b38d4e | 385 | \r |
64a80549 | 386 | @param[in, out] IpIo The pointer to an IP_IO instance that needs\r |
cdfdbb97 | 387 | to open.\r |
388 | @param[in] OpenData The configuration data and callbacks for\r | |
389 | the IP_IO instance.\r | |
97b38d4e | 390 | \r |
6ccfeec2 FS |
391 | @retval EFI_SUCCESS The IP_IO instance opened with OpenData\r |
392 | successfully.\r | |
d1102dba | 393 | @retval EFI_ACCESS_DENIED The IP_IO instance is configured, avoid to\r |
6ccfeec2 FS |
394 | reopen it.\r |
395 | @retval EFI_UNSUPPORTED IPv4 RawData mode is no supported.\r | |
396 | @retval EFI_INVALID_PARAMETER Invalid input parameter.\r | |
397 | @retval Others Error condition occurred.\r | |
97b38d4e | 398 | \r |
399 | **/\r | |
400 | EFI_STATUS\r | |
e29a2e7e | 401 | EFIAPI\r |
97b38d4e | 402 | IpIoOpen (\r |
cdfdbb97 | 403 | IN OUT IP_IO *IpIo,\r |
404 | IN IP_IO_OPEN_DATA *OpenData\r | |
97b38d4e | 405 | );\r |
406 | \r | |
407 | /**\r | |
408 | Send out an IP packet.\r | |
d1102dba | 409 | \r |
2b208747 | 410 | This function is called after IpIoOpen(). The data to be sent is wrapped in\r |
8569a87e FS |
411 | Pkt. The IP instance wrapped in IpIo is used for sending by default but can be\r |
412 | overriden by Sender. Other sending configs, like source address and gateway\r | |
413 | address etc., are specified in OverrideData.\r | |
97b38d4e | 414 | \r |
8569a87e | 415 | @param[in, out] IpIo Pointer to an IP_IO instance used for sending IP\r |
cdfdbb97 | 416 | packet.\r |
8569a87e FS |
417 | @param[in, out] Pkt Pointer to the IP packet to be sent.\r |
418 | @param[in] Sender The IP protocol instance used for sending.\r | |
419 | @param[in] Context Optional context data.\r | |
420 | @param[in] NotifyData Optional notify data.\r | |
cdfdbb97 | 421 | @param[in] Dest The destination IP address to send this packet to.\r |
8569a87e | 422 | This parameter is optional when using IPv6.\r |
cdfdbb97 | 423 | @param[in] OverrideData The data to override some configuration of the IP\r |
424 | instance used for sending.\r | |
97b38d4e | 425 | \r |
8569a87e FS |
426 | @retval EFI_SUCCESS The operation is completed successfully.\r |
427 | @retval EFI_INVALID_PARAMETER The input parameter is not correct.\r | |
cdfdbb97 | 428 | @retval EFI_NOT_STARTED The IpIo is not configured.\r |
8569a87e | 429 | @retval EFI_OUT_OF_RESOURCES Failed due to resource limit.\r |
6dbfed92 | 430 | @retval Others Error condition occurred.\r |
97b38d4e | 431 | \r |
432 | **/\r | |
433 | EFI_STATUS\r | |
434 | EFIAPI\r | |
435 | IpIoSend (\r | |
cdfdbb97 | 436 | IN OUT IP_IO *IpIo,\r |
437 | IN OUT NET_BUF *Pkt,\r | |
438 | IN IP_IO_IP_INFO *Sender OPTIONAL,\r | |
439 | IN VOID *Context OPTIONAL,\r | |
440 | IN VOID *NotifyData OPTIONAL,\r | |
c167ef91 | 441 | IN EFI_IP_ADDRESS *Dest OPTIONAL,\r |
cdfdbb97 | 442 | IN IP_IO_OVERRIDE *OverrideData OPTIONAL\r |
97b38d4e | 443 | );\r |
444 | \r | |
445 | /**\r | |
64a80549 | 446 | Cancel the IP transmit token that wraps this Packet.\r |
97b38d4e | 447 | \r |
2b208747 WF |
448 | If IpIo is NULL, then ASSERT().\r |
449 | If Packet is NULL, then ASSERT().\r | |
450 | \r | |
64a80549 | 451 | @param[in] IpIo The pointer to the IP_IO instance.\r |
452 | @param[in] Packet The pointer to the packet of NET_BUF to cancel.\r | |
97b38d4e | 453 | \r |
454 | **/\r | |
455 | VOID\r | |
456 | EFIAPI\r | |
457 | IpIoCancelTxToken (\r | |
458 | IN IP_IO *IpIo,\r | |
459 | IN VOID *Packet\r | |
460 | );\r | |
461 | \r | |
462 | /**\r | |
463 | Add a new IP instance for sending data.\r | |
2b208747 WF |
464 | \r |
465 | If IpIo is NULL, then ASSERT().\r | |
466 | If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r | |
d1102dba | 467 | \r |
e29a2e7e | 468 | The function is used to add the IP_IO to the IP_IO sending list. The caller\r |
469 | can later use IpIoFindSender() to get the IP_IO and call IpIoSend() to send\r | |
470 | data.\r | |
97b38d4e | 471 | \r |
64a80549 | 472 | @param[in, out] IpIo The pointer to an IP_IO instance to add a new IP\r |
e9b67286 | 473 | instance for sending purposes.\r |
97b38d4e | 474 | \r |
64a80549 | 475 | @return The pointer to the created IP_IO_IP_INFO structure; NULL if failed.\r |
97b38d4e | 476 | \r |
477 | **/\r | |
478 | IP_IO_IP_INFO *\r | |
479 | EFIAPI\r | |
480 | IpIoAddIp (\r | |
cdfdbb97 | 481 | IN OUT IP_IO *IpIo\r |
97b38d4e | 482 | );\r |
483 | \r | |
484 | /**\r | |
fb115c61 | 485 | Configure the IP instance of this IpInfo and start the receiving if IpConfigData\r |
97b38d4e | 486 | is not NULL.\r |
487 | \r | |
2b208747 WF |
488 | If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r |
489 | \r | |
64a80549 | 490 | @param[in, out] IpInfo The pointer to the IP_IO_IP_INFO instance.\r |
d1102dba | 491 | @param[in, out] IpConfigData The IP4 or IP6 configure data used to configure\r |
fb115c61 | 492 | the IP instance. If NULL, the IP instance is reset.\r |
493 | If UseDefaultAddress is set to TRUE, and the configure\r | |
cdfdbb97 | 494 | operation succeeds, the default address information\r |
fb115c61 | 495 | is written back in this IpConfigData.\r |
97b38d4e | 496 | \r |
64a80549 | 497 | @retval EFI_SUCCESS The IP instance of this IpInfo was configured successfully,\r |
e9b67286 | 498 | or there is no need to reconfigure it.\r |
64a80549 | 499 | @retval Others The configuration failed.\r |
97b38d4e | 500 | \r |
501 | **/\r | |
502 | EFI_STATUS\r | |
503 | EFIAPI\r | |
504 | IpIoConfigIp (\r | |
cdfdbb97 | 505 | IN OUT IP_IO_IP_INFO *IpInfo,\r |
fb115c61 | 506 | IN OUT VOID *IpConfigData OPTIONAL\r |
97b38d4e | 507 | );\r |
508 | \r | |
509 | /**\r | |
510 | Destroy an IP instance maintained in IpIo->IpList for\r | |
511 | sending purpose.\r | |
2b208747 | 512 | \r |
d1102dba LG |
513 | If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().\r |
514 | \r | |
e29a2e7e | 515 | This function pairs with IpIoAddIp(). The IpInfo is previously created by\r |
516 | IpIoAddIp(). The IP_IO_IP_INFO::RefCnt is decremented and the IP instance\r | |
517 | will be dstroyed if the RefCnt is zero.\r | |
97b38d4e | 518 | \r |
64a80549 | 519 | @param[in] IpIo The pointer to the IP_IO instance.\r |
520 | @param[in] IpInfo The pointer to the IpInfo to be removed.\r | |
97b38d4e | 521 | \r |
97b38d4e | 522 | **/\r |
523 | VOID\r | |
524 | EFIAPI\r | |
525 | IpIoRemoveIp (\r | |
526 | IN IP_IO *IpIo,\r | |
527 | IN IP_IO_IP_INFO *IpInfo\r | |
528 | );\r | |
529 | \r | |
530 | /**\r | |
531 | Find the first IP protocol maintained in IpIo whose local\r | |
e9b67286 | 532 | address is the same as Src.\r |
d1102dba | 533 | \r |
e29a2e7e | 534 | This function is called when the caller needs the IpIo to send data to the\r |
535 | specified Src. The IpIo was added previously by IpIoAddIp().\r | |
97b38d4e | 536 | \r |
64a80549 | 537 | @param[in, out] IpIo The pointer to the pointer of the IP_IO instance.\r |
fb115c61 | 538 | @param[in] IpVersion The version of the IP protocol to use, either\r |
539 | IPv4 or IPv6.\r | |
cdfdbb97 | 540 | @param[in] Src The local IP address.\r |
97b38d4e | 541 | \r |
64a80549 | 542 | @return The pointer to the IP protocol can be used for sending purpose and its local\r |
6ccfeec2 | 543 | address is the same with Src. NULL if failed.\r |
97b38d4e | 544 | \r |
545 | **/\r | |
546 | IP_IO_IP_INFO *\r | |
547 | EFIAPI\r | |
548 | IpIoFindSender (\r | |
fb115c61 | 549 | IN OUT IP_IO **IpIo,\r |
b45b45b2 | 550 | IN UINT8 IpVersion,\r |
fb115c61 | 551 | IN EFI_IP_ADDRESS *Src\r |
97b38d4e | 552 | );\r |
553 | \r | |
554 | /**\r | |
e29a2e7e | 555 | Get the ICMP error map information.\r |
d1102dba | 556 | \r |
e29a2e7e | 557 | The ErrorStatus will be returned. The IsHard and Notify are optional. If they\r |
558 | are not NULL, this routine will fill them.\r | |
97b38d4e | 559 | \r |
3a1ab4bc | 560 | @param[in] IcmpError IcmpError Type.\r |
fb115c61 | 561 | @param[in] IpVersion The version of the IP protocol to use,\r |
d1102dba | 562 | either IPv4 or IPv6.\r |
3b1464d5 | 563 | @param[out] IsHard If TRUE, indicates that it is a hard error.\r |
564 | @param[out] Notify If TRUE, SockError needs to be notified.\r | |
97b38d4e | 565 | \r |
6dbfed92 | 566 | @retval EFI_UNSUPPORTED Unrecognizable ICMP error code\r |
64a80549 | 567 | @return The ICMP Error Status, such as EFI_NETWORK_UNREACHABLE.\r |
97b38d4e | 568 | \r |
569 | **/\r | |
570 | EFI_STATUS\r | |
571 | EFIAPI\r | |
572 | IpIoGetIcmpErrStatus (\r | |
b45b45b2 | 573 | IN UINT8 IcmpError,\r |
574 | IN UINT8 IpVersion,\r | |
e29a2e7e | 575 | OUT BOOLEAN *IsHard OPTIONAL,\r |
576 | OUT BOOLEAN *Notify OPTIONAL\r | |
97b38d4e | 577 | );\r |
578 | \r | |
fb115c61 | 579 | /**\r |
580 | Refresh the remote peer's Neighbor Cache entries.\r | |
581 | \r | |
582 | This function is called when the caller needs the IpIo to refresh the existing\r | |
d1102dba LG |
583 | IPv6 neighbor cache entries since the neighbor is considered reachable by the\r |
584 | node has recently received a confirmation that packets sent recently to the\r | |
585 | neighbor were received by its IP layer.\r | |
fb115c61 | 586 | \r |
64a80549 | 587 | @param[in] IpIo The pointer to an IP_IO instance\r |
fb115c61 | 588 | @param[in] Neighbor The IP address of the neighbor\r |
64a80549 | 589 | @param[in] Timeout The time in 100-ns units that this entry will\r |
d1102dba LG |
590 | remain in the neighbor cache. A value of\r |
591 | zero means that the entry is permanent.\r | |
592 | A value of non-zero means that the entry is\r | |
fb115c61 | 593 | dynamic and will be deleted after Timeout.\r |
594 | \r | |
64a80549 | 595 | @retval EFI_SUCCESS The operation completed successfully.\r |
fb115c61 | 596 | @retval EFI_NOT_STARTED The IpIo is not configured.\r |
64a80549 | 597 | @retval EFI_INVALID_PARAMETER The Neighbor Address is invalid.\r |
d1102dba LG |
598 | @retval EFI_NOT_FOUND The neighbor cache entry is not in the\r |
599 | neighbor table.\r | |
6dbfed92 | 600 | @retval EFI_UNSUPPORTED IP version is IPv4, which doesn't support neighbor cache refresh.\r |
64a80549 | 601 | @retval EFI_OUT_OF_RESOURCES Failed due to resource limitations.\r |
fb115c61 | 602 | \r |
603 | **/\r | |
604 | EFI_STATUS\r | |
2b208747 | 605 | EFIAPI\r |
fb115c61 | 606 | IpIoRefreshNeighbor (\r |
607 | IN IP_IO *IpIo,\r | |
608 | IN EFI_IP_ADDRESS *Neighbor,\r | |
d1102dba | 609 | IN UINT32 Timeout\r |
fb115c61 | 610 | );\r |
611 | \r | |
97b38d4e | 612 | #endif\r |
fb115c61 | 613 | \r |