]>
Commit | Line | Data |
---|---|---|
a3bcde70 HT |
1 | /** @file\r |
2 | Implementation of EFI_TCP4_PROTOCOL and EFI_TCP6_PROTOCOL.\r | |
3 | \r | |
8f586b85 | 4 | (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r |
ba025280 | 5 | Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r |
a3bcde70 HT |
6 | \r |
7 | This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php.\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #include "TcpMain.h"\r | |
18 | \r | |
19 | /**\r | |
20 | Check the integrity of the data buffer.\r | |
21 | \r | |
22 | @param[in] DataLen The total length of the data buffer.\r | |
23 | @param[in] FragmentCount The fragment count of the fragment table.\r | |
24 | @param[in] FragmentTable Pointer to the fragment table of the data\r | |
25 | buffer.\r | |
26 | \r | |
27 | @retval EFI_SUCCESS The integrity check passed.\r | |
28 | @retval EFI_INVALID_PARAMETER The integrity check failed.\r | |
29 | \r | |
30 | **/\r | |
31 | EFI_STATUS\r | |
32 | TcpChkDataBuf (\r | |
33 | IN UINT32 DataLen,\r | |
34 | IN UINT32 FragmentCount,\r | |
35 | IN EFI_TCP4_FRAGMENT_DATA *FragmentTable\r | |
36 | )\r | |
37 | {\r | |
38 | UINT32 Index;\r | |
39 | \r | |
40 | UINT32 Len;\r | |
41 | \r | |
42 | for (Index = 0, Len = 0; Index < FragmentCount; Index++) {\r | |
43 | Len = Len + FragmentTable[Index].FragmentLength;\r | |
44 | }\r | |
45 | \r | |
46 | if (DataLen != Len) {\r | |
47 | return EFI_INVALID_PARAMETER;\r | |
48 | }\r | |
49 | \r | |
50 | return EFI_SUCCESS;\r | |
51 | }\r | |
52 | \r | |
53 | /**\r | |
54 | Get the current operational status.\r | |
55 | \r | |
56 | @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r | |
57 | @param[out] Tcp4State Pointer to the buffer to receive the current TCP\r | |
58 | state. Optional parameter that may be NULL.\r | |
59 | @param[out] Tcp4ConfigData Pointer to the buffer to receive the current TCP\r | |
60 | configuration. Optional parameter that may be NULL.\r | |
61 | @param[out] Ip4ModeData Pointer to the buffer to receive the current\r | |
62 | IPv4 configuration. Optional parameter that may be NULL.\r | |
63 | @param[out] MnpConfigData Pointer to the buffer to receive the current MNP\r | |
64 | configuration data indirectly used by the TCPv4\r | |
65 | Instance. Optional parameter that may be NULL.\r | |
66 | @param[out] SnpModeData Pointer to the buffer to receive the current SNP\r | |
67 | configuration data indirectly used by the TCPv4\r | |
68 | Instance. Optional parameter that may be NULL.\r | |
69 | \r | |
70 | @retval EFI_SUCCESS The mode data was read.\r | |
71 | @retval EFI_NOT_STARTED No configuration data is available because this\r | |
72 | instance hasn't been started.\r | |
73 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
74 | \r | |
75 | **/\r | |
76 | EFI_STATUS\r | |
77 | EFIAPI\r | |
78 | Tcp4GetModeData (\r | |
581900d9 | 79 | IN EFI_TCP4_PROTOCOL *This,\r |
80 | OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,\r | |
81 | OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,\r | |
82 | OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r | |
83 | OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r | |
84 | OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r | |
a3bcde70 HT |
85 | )\r |
86 | {\r | |
87 | TCP4_MODE_DATA TcpMode;\r | |
88 | SOCKET *Sock;\r | |
89 | \r | |
90 | if (NULL == This) {\r | |
91 | return EFI_INVALID_PARAMETER;\r | |
92 | }\r | |
93 | \r | |
94 | Sock = SOCK_FROM_THIS (This);\r | |
95 | \r | |
96 | TcpMode.Tcp4State = Tcp4State;\r | |
97 | TcpMode.Tcp4ConfigData = Tcp4ConfigData;\r | |
98 | TcpMode.Ip4ModeData = Ip4ModeData;\r | |
99 | TcpMode.MnpConfigData = MnpConfigData;\r | |
100 | TcpMode.SnpModeData = SnpModeData;\r | |
101 | \r | |
102 | return SockGetMode (Sock, &TcpMode);\r | |
103 | }\r | |
104 | \r | |
105 | /**\r | |
106 | Initialize or brutally reset the operational parameters for\r | |
107 | this EFI TCPv4 instance.\r | |
108 | \r | |
109 | @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r | |
110 | @param[in] TcpConfigData Pointer to the configure data to configure the\r | |
111 | instance. Optional parameter that may be NULL.\r | |
112 | \r | |
113 | @retval EFI_SUCCESS The operational settings were set, changed, or\r | |
114 | reset successfully.\r | |
115 | @retval EFI_NO_MAPPING When using a default address, configuration\r | |
116 | (through DHCP, BOOTP, RARP, etc.) is not\r | |
117 | finished.\r | |
118 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
119 | @retval EFI_ACCESS_DENIED Configuring TCP instance when it is already\r | |
120 | configured.\r | |
121 | @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r | |
122 | @retval EFI_UNSUPPORTED One or more of the control options are not\r | |
123 | supported in the implementation.\r | |
124 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.\r | |
125 | \r | |
126 | **/\r | |
127 | EFI_STATUS\r | |
128 | EFIAPI\r | |
129 | Tcp4Configure (\r | |
130 | IN EFI_TCP4_PROTOCOL * This,\r | |
131 | IN EFI_TCP4_CONFIG_DATA * TcpConfigData OPTIONAL\r | |
132 | )\r | |
133 | {\r | |
134 | EFI_TCP4_OPTION *Option;\r | |
135 | SOCKET *Sock;\r | |
136 | EFI_STATUS Status;\r | |
137 | IP4_ADDR Ip;\r | |
138 | IP4_ADDR SubnetMask;\r | |
139 | \r | |
140 | if (NULL == This) {\r | |
141 | return EFI_INVALID_PARAMETER;\r | |
142 | }\r | |
143 | \r | |
144 | //\r | |
145 | // Tcp protocol related parameter check will be conducted here\r | |
146 | //\r | |
147 | if (NULL != TcpConfigData) {\r | |
148 | \r | |
149 | CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof (IP4_ADDR));\r | |
6c12fe63 | 150 | if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {\r |
a3bcde70 HT |
151 | return EFI_INVALID_PARAMETER;\r |
152 | }\r | |
6c12fe63 | 153 | \r |
a3bcde70 HT |
154 | if (TcpConfigData->AccessPoint.ActiveFlag && (0 == TcpConfigData->AccessPoint.RemotePort || (Ip == 0))) {\r |
155 | return EFI_INVALID_PARAMETER;\r | |
156 | }\r | |
157 | \r | |
158 | if (!TcpConfigData->AccessPoint.UseDefaultAddress) {\r | |
159 | \r | |
160 | CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR));\r | |
161 | CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR));\r | |
ba025280 JW |
162 | if (!IP4_IS_VALID_NETMASK (NTOHL (SubnetMask)) || \r |
163 | (SubnetMask != 0 && !NetIp4IsUnicast (NTOHL (Ip), NTOHL (SubnetMask)))) {\r | |
a3bcde70 HT |
164 | return EFI_INVALID_PARAMETER;\r |
165 | }\r | |
166 | }\r | |
167 | \r | |
168 | Option = TcpConfigData->ControlOption;\r | |
169 | if ((NULL != Option) && (Option->EnableSelectiveAck || Option->EnablePathMtuDiscovery)) {\r | |
170 | return EFI_UNSUPPORTED;\r | |
171 | }\r | |
172 | }\r | |
173 | \r | |
174 | Sock = SOCK_FROM_THIS (This);\r | |
175 | \r | |
176 | if (NULL == TcpConfigData) {\r | |
177 | return SockFlush (Sock);\r | |
178 | }\r | |
179 | \r | |
180 | Status = SockConfigure (Sock, TcpConfigData);\r | |
181 | \r | |
182 | if (EFI_NO_MAPPING == Status) {\r | |
183 | Sock->ConfigureState = SO_NO_MAPPING;\r | |
184 | }\r | |
185 | \r | |
186 | return Status;\r | |
187 | }\r | |
188 | \r | |
189 | /**\r | |
190 | Add or delete routing entries.\r | |
191 | \r | |
192 | @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r | |
193 | @param[in] DeleteRoute If TRUE, delete the specified route from routing\r | |
194 | table; if FALSE, add the specified route to\r | |
195 | routing table.\r | |
196 | @param[in] SubnetAddress The destination network.\r | |
197 | @param[in] SubnetMask The subnet mask for the destination network.\r | |
198 | @param[in] GatewayAddress The gateway address for this route.\r | |
199 | \r | |
200 | @retval EFI_SUCCESS The operation completed successfully.\r | |
201 | @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance has not been\r | |
202 | configured.\r | |
203 | @retval EFI_NO_MAPPING When using a default address, configuration\r | |
204 | (through DHCP, BOOTP, RARP, etc.) is not\r | |
205 | finished.\r | |
206 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
207 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to add the\r | |
208 | entry to the routing table.\r | |
209 | @retval EFI_NOT_FOUND This route is not in the routing table.\r | |
210 | @retval EFI_ACCESS_DENIED This route is already in the routing table.\r | |
211 | @retval EFI_UNSUPPORTED The TCP driver does not support this operation.\r | |
212 | \r | |
213 | **/\r | |
214 | EFI_STATUS\r | |
215 | EFIAPI\r | |
216 | Tcp4Routes (\r | |
217 | IN EFI_TCP4_PROTOCOL *This,\r | |
218 | IN BOOLEAN DeleteRoute,\r | |
219 | IN EFI_IPv4_ADDRESS *SubnetAddress,\r | |
220 | IN EFI_IPv4_ADDRESS *SubnetMask,\r | |
221 | IN EFI_IPv4_ADDRESS *GatewayAddress\r | |
222 | )\r | |
223 | {\r | |
224 | SOCKET *Sock;\r | |
225 | TCP4_ROUTE_INFO RouteInfo;\r | |
226 | \r | |
227 | if (NULL == This) {\r | |
228 | return EFI_INVALID_PARAMETER;\r | |
229 | }\r | |
230 | \r | |
231 | Sock = SOCK_FROM_THIS (This);\r | |
232 | \r | |
233 | RouteInfo.DeleteRoute = DeleteRoute;\r | |
2594a98e FS |
234 | RouteInfo.SubnetAddress = SubnetAddress;\r |
235 | RouteInfo.SubnetMask = SubnetMask;\r | |
236 | RouteInfo.GatewayAddress = GatewayAddress;\r | |
a3bcde70 HT |
237 | \r |
238 | return SockRoute (Sock, &RouteInfo);\r | |
239 | }\r | |
240 | \r | |
241 | /**\r | |
242 | Initiate a non-blocking TCP connection request for an active TCP instance.\r | |
243 | \r | |
244 | @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r | |
245 | @param[in] ConnectionToken Pointer to the connection token to return when\r | |
246 | the TCP three way handshake finishes.\r | |
247 | \r | |
248 | @retval EFI_SUCCESS The connection request successfully\r | |
249 | initiated.\r | |
250 | @retval EFI_NOT_STARTED This EFI_TCP4_PROTOCOL instance hasn't been\r | |
251 | configured.\r | |
252 | @retval EFI_ACCESS_DENIED The instance is not configured as an active one,\r | |
253 | or it is not in Tcp4StateClosed state.\r | |
254 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
255 | @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to\r | |
256 | initiate the active open.\r | |
257 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
258 | \r | |
259 | **/\r | |
260 | EFI_STATUS\r | |
261 | EFIAPI\r | |
262 | Tcp4Connect (\r | |
263 | IN EFI_TCP4_PROTOCOL *This,\r | |
264 | IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken\r | |
265 | )\r | |
266 | {\r | |
267 | SOCKET *Sock;\r | |
268 | \r | |
269 | if (NULL == This || NULL == ConnectionToken || NULL == ConnectionToken->CompletionToken.Event) {\r | |
270 | return EFI_INVALID_PARAMETER;\r | |
271 | }\r | |
272 | \r | |
273 | Sock = SOCK_FROM_THIS (This);\r | |
274 | \r | |
275 | return SockConnect (Sock, ConnectionToken);\r | |
276 | }\r | |
277 | \r | |
278 | /**\r | |
279 | Listen on the passive instance to accept an incoming connection request.\r | |
280 | \r | |
281 | @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r | |
282 | @param[in] ListenToken Pointer to the listen token to return when\r | |
283 | operation finishes.\r | |
284 | \r | |
285 | @retval EFI_SUCCESS The listen token was queued successfully.\r | |
286 | @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r | |
287 | configured.\r | |
288 | @retval EFI_ACCESS_DENIED The instatnce is not a passive one or it is not\r | |
289 | in Tcp4StateListen state or a same listen token\r | |
290 | has already existed in the listen token queue of\r | |
291 | this TCP instance.\r | |
292 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
293 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish\r | |
294 | the operation.\r | |
295 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
296 | \r | |
297 | **/\r | |
298 | EFI_STATUS\r | |
299 | EFIAPI\r | |
300 | Tcp4Accept (\r | |
301 | IN EFI_TCP4_PROTOCOL *This,\r | |
302 | IN EFI_TCP4_LISTEN_TOKEN *ListenToken\r | |
303 | )\r | |
304 | {\r | |
305 | SOCKET *Sock;\r | |
306 | \r | |
307 | if (NULL == This || NULL == ListenToken || NULL == ListenToken->CompletionToken.Event) {\r | |
308 | return EFI_INVALID_PARAMETER;\r | |
309 | }\r | |
310 | \r | |
311 | Sock = SOCK_FROM_THIS (This);\r | |
312 | \r | |
313 | return SockAccept (Sock, ListenToken);\r | |
314 | }\r | |
315 | \r | |
316 | /**\r | |
317 | Queues outgoing data into the transmit queue\r | |
318 | \r | |
319 | @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r | |
320 | @param[in] Token Pointer to the completion token to queue to the\r | |
321 | transmit queue.\r | |
322 | \r | |
323 | @retval EFI_SUCCESS The data has been queued for transmission.\r | |
324 | @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r | |
325 | configured.\r | |
326 | @retval EFI_NO_MAPPING When using a default address, configuration\r | |
327 | (DHCP, BOOTP, RARP, etc.) is not finished yet.\r | |
328 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid\r | |
329 | @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r | |
330 | * A transmit completion token with the same\r | |
331 | Token-> CompletionToken.Event was already in the\r | |
332 | transmission queue. * The current instance is in\r | |
333 | Tcp4StateClosed state. * The current instance is\r | |
334 | a passive one and it is in Tcp4StateListen\r | |
335 | state. * User has called Close() to disconnect\r | |
336 | this connection.\r | |
337 | @retval EFI_NOT_READY The completion token could not be queued because\r | |
338 | the transmit queue is full.\r | |
339 | @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of a\r | |
340 | resource shortage.\r | |
341 | @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or\r | |
342 | address.\r | |
343 | \r | |
344 | **/\r | |
345 | EFI_STATUS\r | |
346 | EFIAPI\r | |
347 | Tcp4Transmit (\r | |
348 | IN EFI_TCP4_PROTOCOL *This,\r | |
349 | IN EFI_TCP4_IO_TOKEN *Token\r | |
350 | )\r | |
351 | {\r | |
352 | SOCKET *Sock;\r | |
353 | EFI_STATUS Status;\r | |
354 | \r | |
355 | if (NULL == This ||\r | |
356 | NULL == Token ||\r | |
357 | NULL == Token->CompletionToken.Event ||\r | |
358 | NULL == Token->Packet.TxData ||\r | |
359 | 0 == Token->Packet.TxData->FragmentCount ||\r | |
360 | 0 == Token->Packet.TxData->DataLength\r | |
361 | ) {\r | |
362 | return EFI_INVALID_PARAMETER;\r | |
363 | }\r | |
364 | \r | |
365 | Status = TcpChkDataBuf (\r | |
366 | Token->Packet.TxData->DataLength,\r | |
367 | Token->Packet.TxData->FragmentCount,\r | |
368 | Token->Packet.TxData->FragmentTable\r | |
369 | );\r | |
370 | if (EFI_ERROR (Status)) {\r | |
371 | return Status;\r | |
372 | }\r | |
373 | \r | |
374 | Sock = SOCK_FROM_THIS (This);\r | |
375 | \r | |
376 | return SockSend (Sock, Token);\r | |
377 | }\r | |
378 | \r | |
379 | /**\r | |
380 | Place an asynchronous receive request into the receiving queue.\r | |
381 | \r | |
382 | @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r | |
383 | @param[in] Token Pointer to a token that is associated with the\r | |
384 | receive data descriptor.\r | |
385 | \r | |
386 | @retval EFI_SUCCESS The receive completion token was cached\r | |
387 | @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r | |
388 | configured.\r | |
389 | @retval EFI_NO_MAPPING When using a default address, configuration\r | |
390 | (DHCP, BOOTP, RARP, etc.) is not finished yet.\r | |
391 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r | |
392 | @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued\r | |
393 | due to a lack of system resources.\r | |
394 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
395 | @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r | |
396 | * A receive completion token with the same\r | |
397 | Token->CompletionToken.Event was already in the\r | |
398 | receive queue. * The current instance is in\r | |
399 | Tcp4StateClosed state. * The current instance is\r | |
400 | a passive one and it is in Tcp4StateListen\r | |
401 | state. * User has called Close() to disconnect\r | |
402 | this connection.\r | |
403 | @retval EFI_CONNECTION_FIN The communication peer has closed the connection,\r | |
404 | and there is no any buffered data in the receive\r | |
405 | buffer of this instance.\r | |
406 | @retval EFI_NOT_READY The receive request could not be queued because\r | |
407 | the receive queue is full.\r | |
408 | \r | |
409 | **/\r | |
410 | EFI_STATUS\r | |
411 | EFIAPI\r | |
412 | Tcp4Receive (\r | |
413 | IN EFI_TCP4_PROTOCOL *This,\r | |
414 | IN EFI_TCP4_IO_TOKEN *Token\r | |
415 | )\r | |
416 | {\r | |
417 | SOCKET *Sock;\r | |
418 | EFI_STATUS Status;\r | |
419 | \r | |
420 | if (NULL == This ||\r | |
421 | NULL == Token ||\r | |
422 | NULL == Token->CompletionToken.Event ||\r | |
423 | NULL == Token->Packet.RxData ||\r | |
424 | 0 == Token->Packet.RxData->FragmentCount ||\r | |
425 | 0 == Token->Packet.RxData->DataLength\r | |
426 | ) {\r | |
427 | return EFI_INVALID_PARAMETER;\r | |
428 | }\r | |
429 | \r | |
430 | Status = TcpChkDataBuf (\r | |
431 | Token->Packet.RxData->DataLength,\r | |
432 | Token->Packet.RxData->FragmentCount,\r | |
433 | Token->Packet.RxData->FragmentTable\r | |
434 | );\r | |
435 | if (EFI_ERROR (Status)) {\r | |
436 | return Status;\r | |
437 | }\r | |
438 | \r | |
439 | Sock = SOCK_FROM_THIS (This);\r | |
440 | \r | |
441 | return SockRcv (Sock, Token);\r | |
442 | \r | |
443 | }\r | |
444 | \r | |
445 | /**\r | |
446 | Disconnecting a TCP connection gracefully or reset a TCP connection.\r | |
447 | \r | |
448 | @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r | |
449 | @param[in] CloseToken Pointer to the close token to return when\r | |
450 | operation finishes.\r | |
451 | \r | |
452 | @retval EFI_SUCCESS The operation completed successfully.\r | |
453 | @retval EFI_NOT_STARTED The EFI_TCP4_PROTOCOL instance hasn't been\r | |
454 | configured.\r | |
455 | @retval EFI_ACCESS_DENIED One or more of the following are TRUE: *\r | |
456 | Configure() has been called with TcpConfigData\r | |
457 | set to NULL, and this function has not returned.\r | |
458 | * Previous Close() call on this instance has not\r | |
459 | finished.\r | |
460 | @retval EFI_INVALID_PARAMETER One ore more parameters are invalid.\r | |
461 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough resources to finish the\r | |
462 | operation.\r | |
463 | @retval EFI_DEVICE_ERROR Any unexpected category error not belonging to those\r | |
464 | listed above.\r | |
465 | \r | |
466 | **/\r | |
467 | EFI_STATUS\r | |
468 | EFIAPI\r | |
469 | Tcp4Close (\r | |
470 | IN EFI_TCP4_PROTOCOL *This,\r | |
471 | IN EFI_TCP4_CLOSE_TOKEN *CloseToken\r | |
472 | )\r | |
473 | {\r | |
474 | SOCKET *Sock;\r | |
475 | \r | |
476 | if (NULL == This || NULL == CloseToken || NULL == CloseToken->CompletionToken.Event) {\r | |
477 | return EFI_INVALID_PARAMETER;\r | |
478 | }\r | |
479 | \r | |
480 | Sock = SOCK_FROM_THIS (This);\r | |
481 | \r | |
482 | return SockClose (Sock, CloseToken, CloseToken->AbortOnClose);\r | |
483 | }\r | |
484 | \r | |
485 | /**\r | |
486 | Abort an asynchronous connection, listen, transmission or receive request.\r | |
487 | \r | |
5ffe214a JW |
488 | @param This The pointer to the EFI_TCP4_PROTOCOL instance.\r |
489 | @param Token The pointer to a token that has been issued by\r | |
490 | EFI_TCP4_PROTOCOL.Connect(),\r | |
491 | EFI_TCP4_PROTOCOL.Accept(),\r | |
492 | EFI_TCP4_PROTOCOL.Transmit() or\r | |
493 | EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending\r | |
494 | tokens issued by above four functions will be aborted. Type\r | |
495 | EFI_TCP4_COMPLETION_TOKEN is defined in\r | |
496 | EFI_TCP4_PROTOCOL.Connect().\r | |
497 | \r | |
498 | @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r | |
499 | is signaled.\r | |
500 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
501 | @retval EFI_NOT_STARTED This instance hasn't been configured.\r | |
502 | @retval EFI_NO_MAPPING When using the default address, configuration\r | |
503 | (DHCP, BOOTP,RARP, etc.) hasn't finished yet.\r | |
504 | @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the\r | |
505 | transmission or receive queue. It has either\r | |
506 | completed or wasn't issued by Transmit() and Receive().\r | |
a3bcde70 HT |
507 | \r |
508 | **/\r | |
509 | EFI_STATUS\r | |
510 | EFIAPI\r | |
511 | Tcp4Cancel (\r | |
512 | IN EFI_TCP4_PROTOCOL *This,\r | |
513 | IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL\r | |
514 | )\r | |
515 | {\r | |
5ffe214a JW |
516 | SOCKET *Sock;\r |
517 | \r | |
518 | if (NULL == This) {\r | |
519 | return EFI_INVALID_PARAMETER;\r | |
520 | }\r | |
521 | \r | |
522 | Sock = SOCK_FROM_THIS (This);\r | |
523 | \r | |
524 | return SockCancel (Sock, Token);\r | |
a3bcde70 HT |
525 | }\r |
526 | \r | |
527 | /**\r | |
528 | Poll to receive incoming data and transmit outgoing segments.\r | |
529 | \r | |
530 | @param[in] This Pointer to the EFI_TCP4_PROTOCOL instance.\r | |
531 | \r | |
532 | @retval EFI_SUCCESS Incoming or outgoing data was processed.\r | |
533 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
534 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
535 | @retval EFI_NOT_READY No incoming or outgoing data was processed.\r | |
536 | @retval EFI_TIMEOUT Data was dropped out of the transmission or\r | |
537 | receive queue. Consider increasing the polling\r | |
538 | rate.\r | |
539 | \r | |
540 | **/\r | |
541 | EFI_STATUS\r | |
542 | EFIAPI\r | |
543 | Tcp4Poll (\r | |
544 | IN EFI_TCP4_PROTOCOL *This\r | |
545 | )\r | |
546 | {\r | |
547 | SOCKET *Sock;\r | |
548 | EFI_STATUS Status;\r | |
549 | \r | |
550 | if (NULL == This) {\r | |
551 | return EFI_INVALID_PARAMETER;\r | |
552 | }\r | |
553 | \r | |
554 | Sock = SOCK_FROM_THIS (This);\r | |
555 | \r | |
556 | Status = Sock->ProtoHandler (Sock, SOCK_POLL, NULL);\r | |
557 | \r | |
558 | return Status;\r | |
559 | }\r | |
560 | \r | |
561 | /**\r | |
562 | Get the current operational status.\r | |
563 | \r | |
564 | The GetModeData() function copies the current operational settings of this EFI TCPv6\r | |
565 | Protocol instance into user-supplied buffers. This function can also be used to retrieve\r | |
566 | the operational setting of underlying drivers such as IPv6, MNP, or SNP.\r | |
567 | \r | |
568 | @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r | |
569 | @param[out] Tcp6State The buffer in which the current TCP state is\r | |
570 | returned. Optional parameter that may be NULL.\r | |
571 | @param[out] Tcp6ConfigData The buffer in which the current TCP configuration\r | |
572 | is returned. Optional parameter that may be NULL.\r | |
573 | @param[out] Ip6ModeData The buffer in which the current IPv6 configuration\r | |
574 | data used by the TCP instance is returned.\r | |
575 | Optional parameter that may be NULL.\r | |
576 | @param[out] MnpConfigData The buffer in which the current MNP configuration\r | |
577 | data indirectly used by the TCP instance is returned.\r | |
578 | Optional parameter that may be NULL.\r | |
579 | @param[out] SnpModeData The buffer in which the current SNP mode data\r | |
580 | indirectly used by the TCP instance is returned.\r | |
581 | Optional parameter that may be NULL.\r | |
582 | \r | |
583 | @retval EFI_SUCCESS The mode data was read.\r | |
584 | @retval EFI_NOT_STARTED No configuration data is available because this instance hasn't\r | |
585 | been started.\r | |
586 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
587 | \r | |
588 | **/\r | |
589 | EFI_STATUS\r | |
590 | EFIAPI\r | |
591 | Tcp6GetModeData (\r | |
592 | IN EFI_TCP6_PROTOCOL *This,\r | |
593 | OUT EFI_TCP6_CONNECTION_STATE *Tcp6State OPTIONAL,\r | |
594 | OUT EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL,\r | |
595 | OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,\r | |
596 | OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r | |
597 | OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r | |
598 | )\r | |
599 | {\r | |
600 | TCP6_MODE_DATA TcpMode;\r | |
601 | SOCKET *Sock;\r | |
602 | \r | |
603 | if (NULL == This) {\r | |
604 | return EFI_INVALID_PARAMETER;\r | |
605 | }\r | |
606 | \r | |
607 | Sock = SOCK_FROM_THIS (This);\r | |
608 | \r | |
609 | TcpMode.Tcp6State = Tcp6State;\r | |
610 | TcpMode.Tcp6ConfigData = Tcp6ConfigData;\r | |
611 | TcpMode.Ip6ModeData = Ip6ModeData;\r | |
612 | TcpMode.MnpConfigData = MnpConfigData;\r | |
613 | TcpMode.SnpModeData = SnpModeData;\r | |
614 | \r | |
615 | return SockGetMode (Sock, &TcpMode);\r | |
616 | }\r | |
617 | \r | |
618 | /**\r | |
619 | Initialize or brutally reset the operational parameters for this EFI TCPv6 instance.\r | |
620 | \r | |
621 | The Configure() function does the following:\r | |
622 | - Initialize this TCP instance, i.e., initialize the communication end settings and\r | |
623 | specify active open or passive open for an instance.\r | |
624 | - Reset this TCP instance brutally, i.e., cancel all pending asynchronous tokens, flush\r | |
625 | transmission and receiving buffer directly without informing the communication peer.\r | |
626 | \r | |
627 | No other TCPv6 Protocol operation except Poll() can be executed by this instance until\r | |
628 | it is configured properly. For an active TCP instance, after a proper configuration it\r | |
629 | may call Connect() to initiate a three-way handshake. For a passive TCP instance,\r | |
630 | its state transits to Tcp6StateListen after configuration, and Accept() may be\r | |
631 | called to listen the incoming TCP connection requests. If Tcp6ConfigData is set to NULL,\r | |
632 | the instance is reset. The resetting process will be done brutally, the state machine will\r | |
633 | be set to Tcp6StateClosed directly, the receive queue and transmit queue will be flushed,\r | |
634 | and no traffic is allowed through this instance.\r | |
635 | \r | |
636 | @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r | |
637 | @param[in] Tcp6ConfigData Pointer to the configure data to configure the instance.\r | |
638 | If Tcp6ConfigData is set to NULL, the instance is reset.\r | |
639 | \r | |
640 | @retval EFI_SUCCESS The operational settings were set, changed, or reset\r | |
641 | successfully.\r | |
642 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r | |
643 | address for this instance, but no source address was available for\r | |
644 | use.\r | |
645 | @retval EFI_INVALID_PARAMETER One or more of the following conditions are TRUE:\r | |
646 | - This is NULL.\r | |
647 | - Tcp6ConfigData->AccessPoint.StationAddress is neither zero nor\r | |
648 | one of the configured IP addresses in the underlying IPv6 driver.\r | |
649 | - Tcp6ConfigData->AccessPoint.RemoteAddress isn't a valid unicast\r | |
650 | IPv6 address.\r | |
651 | - Tcp6ConfigData->AccessPoint.RemoteAddress is zero or\r | |
652 | Tcp6ConfigData->AccessPoint.RemotePort is zero when\r | |
653 | Tcp6ConfigData->AccessPoint.ActiveFlag is TRUE.\r | |
654 | - A same access point has been configured in other TCP\r | |
655 | instance properly.\r | |
656 | @retval EFI_ACCESS_DENIED Configuring a TCP instance when it is configured without\r | |
657 | calling Configure() with NULL to reset it.\r | |
658 | @retval EFI_UNSUPPORTED One or more of the control options are not supported in\r | |
659 | the implementation.\r | |
660 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when\r | |
661 | executing Configure().\r | |
662 | @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r | |
663 | \r | |
664 | **/\r | |
665 | EFI_STATUS\r | |
666 | EFIAPI\r | |
667 | Tcp6Configure (\r | |
668 | IN EFI_TCP6_PROTOCOL *This,\r | |
669 | IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData OPTIONAL\r | |
670 | )\r | |
671 | {\r | |
672 | EFI_TCP6_OPTION *Option;\r | |
673 | SOCKET *Sock;\r | |
674 | EFI_STATUS Status;\r | |
675 | EFI_IPv6_ADDRESS *Ip;\r | |
676 | \r | |
677 | if (NULL == This) {\r | |
678 | return EFI_INVALID_PARAMETER;\r | |
679 | }\r | |
680 | \r | |
681 | //\r | |
682 | // Tcp protocol related parameter check will be conducted here\r | |
683 | //\r | |
684 | if (NULL != Tcp6ConfigData) {\r | |
685 | \r | |
686 | Ip = &Tcp6ConfigData->AccessPoint.RemoteAddress;\r | |
687 | if (!NetIp6IsUnspecifiedAddr (Ip) && !NetIp6IsValidUnicast (Ip)) {\r | |
688 | return EFI_INVALID_PARAMETER;\r | |
689 | }\r | |
690 | \r | |
691 | if (Tcp6ConfigData->AccessPoint.ActiveFlag &&\r | |
692 | (0 == Tcp6ConfigData->AccessPoint.RemotePort || NetIp6IsUnspecifiedAddr (Ip))\r | |
693 | ) {\r | |
694 | return EFI_INVALID_PARAMETER;\r | |
695 | }\r | |
696 | \r | |
697 | Ip = &Tcp6ConfigData->AccessPoint.StationAddress;\r | |
698 | if (!NetIp6IsUnspecifiedAddr (Ip) && !NetIp6IsValidUnicast (Ip)) {\r | |
699 | return EFI_INVALID_PARAMETER;\r | |
700 | }\r | |
701 | \r | |
702 | Option = Tcp6ConfigData->ControlOption;\r | |
703 | if ((NULL != Option) && (Option->EnableSelectiveAck || Option->EnablePathMtuDiscovery)) {\r | |
704 | return EFI_UNSUPPORTED;\r | |
705 | }\r | |
706 | }\r | |
707 | \r | |
708 | Sock = SOCK_FROM_THIS (This);\r | |
709 | \r | |
710 | if (NULL == Tcp6ConfigData) {\r | |
711 | return SockFlush (Sock);\r | |
712 | }\r | |
713 | \r | |
714 | Status = SockConfigure (Sock, Tcp6ConfigData);\r | |
715 | \r | |
716 | if (EFI_NO_MAPPING == Status) {\r | |
717 | Sock->ConfigureState = SO_NO_MAPPING;\r | |
718 | }\r | |
719 | \r | |
720 | return Status;\r | |
721 | }\r | |
722 | \r | |
723 | /**\r | |
724 | Initiate a nonblocking TCP connection request for an active TCP instance.\r | |
725 | \r | |
726 | The Connect() function will initiate an active open to the remote peer configured\r | |
727 | in a current TCP instance if it is configured active. If the connection succeeds or\r | |
728 | fails due to any error, the ConnectionToken->CompletionToken.Event will be signaled\r | |
729 | and ConnectionToken->CompletionToken.Status will be updated accordingly. This\r | |
730 | function can only be called for the TCP instance in the Tcp6StateClosed state. The\r | |
731 | instance will transfer into Tcp6StateSynSent if the function returns EFI_SUCCESS.\r | |
732 | If a TCP three-way handshake succeeds, its state will become Tcp6StateEstablished.\r | |
733 | Otherwise, the state will return to Tcp6StateClosed.\r | |
734 | \r | |
735 | @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r | |
736 | @param[in] ConnectionToken Pointer to the connection token to return when the TCP three\r | |
737 | way handshake finishes.\r | |
738 | \r | |
739 | @retval EFI_SUCCESS The connection request successfully initiated and the state of\r | |
740 | this TCP instance has been changed to Tcp6StateSynSent.\r | |
741 | @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r | |
742 | @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:\r | |
743 | - This instance is not configured as an active one.\r | |
744 | - This instance is not in Tcp6StateClosed state.\r | |
745 | @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r | |
746 | - This is NULL.\r | |
747 | - ConnectionToken is NULL.\r | |
748 | - ConnectionToken->CompletionToken.Event is NULL.\r | |
749 | @retval EFI_OUT_OF_RESOURCES The driver can't allocate enough resources to initiate the active open.\r | |
750 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
751 | \r | |
752 | **/\r | |
753 | EFI_STATUS\r | |
754 | EFIAPI\r | |
755 | Tcp6Connect (\r | |
756 | IN EFI_TCP6_PROTOCOL *This,\r | |
757 | IN EFI_TCP6_CONNECTION_TOKEN *ConnectionToken\r | |
758 | )\r | |
759 | {\r | |
760 | SOCKET *Sock;\r | |
761 | \r | |
762 | if (NULL == This || NULL == ConnectionToken || NULL == ConnectionToken->CompletionToken.Event) {\r | |
763 | return EFI_INVALID_PARAMETER;\r | |
764 | }\r | |
765 | \r | |
766 | Sock = SOCK_FROM_THIS (This);\r | |
767 | \r | |
768 | return SockConnect (Sock, ConnectionToken);\r | |
769 | }\r | |
770 | \r | |
771 | /**\r | |
772 | Listen on the passive instance to accept an incoming connection request. This is a\r | |
773 | nonblocking operation.\r | |
774 | \r | |
775 | The Accept() function initiates an asynchronous accept request to wait for an incoming\r | |
776 | connection on the passive TCP instance. If a remote peer successfully establishes a\r | |
777 | connection with this instance, a new TCP instance will be created and its handle will\r | |
778 | be returned in ListenToken->NewChildHandle. The newly created instance is configured\r | |
779 | by inheriting the passive instance's configuration and is ready for use upon return.\r | |
780 | The new instance is in the Tcp6StateEstablished state.\r | |
781 | \r | |
782 | The ListenToken->CompletionToken.Event will be signaled when a new connection is\r | |
783 | accepted, when a user aborts the listen or when a connection is reset.\r | |
784 | \r | |
785 | This function only can be called when a current TCP instance is in Tcp6StateListen state.\r | |
786 | \r | |
787 | @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r | |
788 | @param[in] ListenToken Pointer to the listen token to return when operation finishes.\r | |
789 | \r | |
790 | \r | |
791 | @retval EFI_SUCCESS The listen token queued successfully.\r | |
792 | @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r | |
793 | @retval EFI_ACCESS_DENIED One or more of the following are TRUE:\r | |
794 | - This instance is not a passive instance.\r | |
795 | - This instance is not in Tcp6StateListen state.\r | |
796 | - The same listen token has already existed in the listen\r | |
797 | token queue of this TCP instance.\r | |
798 | @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r | |
799 | - This is NULL.\r | |
800 | - ListenToken is NULL.\r | |
801 | - ListentToken->CompletionToken.Event is NULL.\r | |
802 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.\r | |
803 | @retval EFI_DEVICE_ERROR Any unexpected error not belonging to a category listed above.\r | |
804 | \r | |
805 | **/\r | |
806 | EFI_STATUS\r | |
807 | EFIAPI\r | |
808 | Tcp6Accept (\r | |
809 | IN EFI_TCP6_PROTOCOL *This,\r | |
810 | IN EFI_TCP6_LISTEN_TOKEN *ListenToken\r | |
811 | )\r | |
812 | {\r | |
813 | SOCKET *Sock;\r | |
814 | \r | |
815 | if (NULL == This || NULL == ListenToken || NULL == ListenToken->CompletionToken.Event) {\r | |
816 | return EFI_INVALID_PARAMETER;\r | |
817 | }\r | |
818 | \r | |
819 | Sock = SOCK_FROM_THIS (This);\r | |
820 | \r | |
821 | return SockAccept (Sock, ListenToken);\r | |
822 | }\r | |
823 | \r | |
824 | /**\r | |
825 | Queues outgoing data into the transmit queue.\r | |
826 | \r | |
827 | The Transmit() function queues a sending request to this TCP instance along with the\r | |
828 | user data. The status of the token is updated and the event in the token will be\r | |
829 | signaled once the data is sent out or an error occurs.\r | |
830 | \r | |
831 | @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r | |
832 | @param[in] Token Pointer to the completion token to queue to the transmit queue.\r | |
833 | \r | |
834 | @retval EFI_SUCCESS The data has been queued for transmission.\r | |
835 | @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r | |
836 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a\r | |
837 | source address for this instance, but no source address was\r | |
838 | available for use.\r | |
839 | @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r | |
840 | - This is NULL.\r | |
841 | - Token is NULL.\r | |
842 | - Token->CompletionToken.Event is NULL.\r | |
843 | - Token->Packet.TxData is NULL.\r | |
844 | - Token->Packet.FragmentCount is zero.\r | |
845 | - Token->Packet.DataLength is not equal to the sum of fragment lengths.\r | |
846 | @retval EFI_ACCESS_DENIED One or more of the following conditions are TRUE:\r | |
847 | - A transmit completion token with the same Token->\r | |
848 | CompletionToken.Event was already in the\r | |
849 | transmission queue.\r | |
850 | - The current instance is in Tcp6StateClosed state.\r | |
851 | - The current instance is a passive one and it is in\r | |
852 | Tcp6StateListen state.\r | |
853 | - User has called Close() to disconnect this connection.\r | |
854 | @retval EFI_NOT_READY The completion token could not be queued because the\r | |
855 | transmit queue is full.\r | |
856 | @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data because of resource\r | |
857 | shortage.\r | |
858 | @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.\r | |
859 | \r | |
860 | **/\r | |
861 | EFI_STATUS\r | |
862 | EFIAPI\r | |
863 | Tcp6Transmit (\r | |
864 | IN EFI_TCP6_PROTOCOL *This,\r | |
865 | IN EFI_TCP6_IO_TOKEN *Token\r | |
866 | )\r | |
867 | {\r | |
868 | SOCKET *Sock;\r | |
869 | EFI_STATUS Status;\r | |
870 | \r | |
871 | if (NULL == This ||\r | |
872 | NULL == Token ||\r | |
873 | NULL == Token->CompletionToken.Event ||\r | |
874 | NULL == Token->Packet.TxData ||\r | |
875 | 0 == Token->Packet.TxData->FragmentCount ||\r | |
876 | 0 == Token->Packet.TxData->DataLength\r | |
877 | ) {\r | |
878 | return EFI_INVALID_PARAMETER;\r | |
879 | }\r | |
880 | \r | |
881 | Status = TcpChkDataBuf (\r | |
882 | Token->Packet.TxData->DataLength,\r | |
883 | Token->Packet.TxData->FragmentCount,\r | |
884 | (EFI_TCP4_FRAGMENT_DATA *) Token->Packet.TxData->FragmentTable\r | |
885 | );\r | |
886 | if (EFI_ERROR (Status)) {\r | |
887 | return Status;\r | |
888 | }\r | |
889 | \r | |
890 | Sock = SOCK_FROM_THIS (This);\r | |
891 | \r | |
892 | return SockSend (Sock, Token);\r | |
893 | }\r | |
894 | \r | |
895 | /**\r | |
896 | Places an asynchronous receive request into the receiving queue.\r | |
897 | \r | |
898 | The Receive() function places a completion token into the receive packet queue. This\r | |
899 | function is always asynchronous. The caller must allocate the Token->CompletionToken.Event\r | |
900 | and the FragmentBuffer used to receive data. The caller also must fill the DataLength that\r | |
901 | represents the whole length of all FragmentBuffer. When the receive operation completes, the\r | |
902 | EFI TCPv6 Protocol driver updates the Token->CompletionToken.Status and Token->Packet.RxData\r | |
903 | fields, and the Token->CompletionToken.Event is signaled. If data obtained, the data and its length\r | |
904 | will be copied into the FragmentTable; at the same time the full length of received data will\r | |
905 | be recorded in the DataLength fields. Providing a proper notification function and context\r | |
906 | for the event enables the user to receive the notification and receiving status. That\r | |
907 | notification function is guaranteed to not be re-entered.\r | |
908 | \r | |
909 | @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r | |
910 | @param[in] Token Pointer to a token that is associated with the receive data\r | |
911 | descriptor.\r | |
912 | \r | |
913 | @retval EFI_SUCCESS The receive completion token was cached.\r | |
914 | @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r | |
915 | @retval EFI_NO_MAPPING The underlying IPv6 driver was responsible for choosing a source\r | |
916 | address for this instance, but no source address was available for use.\r | |
917 | @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r | |
918 | - This is NULL.\r | |
919 | - Token is NULL.\r | |
920 | - Token->CompletionToken.Event is NULL.\r | |
921 | - Token->Packet.RxData is NULL.\r | |
922 | - Token->Packet.RxData->DataLength is 0.\r | |
923 | - The Token->Packet.RxData->DataLength is not the\r | |
924 | sum of all FragmentBuffer length in FragmentTable.\r | |
925 | @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of\r | |
926 | system resources (usually memory).\r | |
927 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
928 | The EFI TCPv6 Protocol instance has been reset to startup defaults.\r | |
929 | @retval EFI_ACCESS_DENIED One or more of the following conditions is TRUE:\r | |
930 | - A receive completion token with the same Token->CompletionToken.Event\r | |
931 | was already in the receive queue.\r | |
932 | - The current instance is in Tcp6StateClosed state.\r | |
933 | - The current instance is a passive one and it is in\r | |
934 | Tcp6StateListen state.\r | |
935 | - User has called Close() to disconnect this connection.\r | |
936 | @retval EFI_CONNECTION_FIN The communication peer has closed the connection and there is no\r | |
937 | buffered data in the receive buffer of this instance.\r | |
938 | @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.\r | |
939 | \r | |
940 | **/\r | |
941 | EFI_STATUS\r | |
942 | EFIAPI\r | |
943 | Tcp6Receive (\r | |
944 | IN EFI_TCP6_PROTOCOL *This,\r | |
945 | IN EFI_TCP6_IO_TOKEN *Token\r | |
946 | )\r | |
947 | {\r | |
948 | SOCKET *Sock;\r | |
949 | EFI_STATUS Status;\r | |
950 | \r | |
951 | if (NULL == This ||\r | |
952 | NULL == Token ||\r | |
953 | NULL == Token->CompletionToken.Event ||\r | |
954 | NULL == Token->Packet.RxData ||\r | |
955 | 0 == Token->Packet.RxData->FragmentCount ||\r | |
956 | 0 == Token->Packet.RxData->DataLength\r | |
957 | ) {\r | |
958 | return EFI_INVALID_PARAMETER;\r | |
959 | }\r | |
960 | \r | |
961 | Status = TcpChkDataBuf (\r | |
962 | Token->Packet.RxData->DataLength,\r | |
963 | Token->Packet.RxData->FragmentCount,\r | |
964 | (EFI_TCP4_FRAGMENT_DATA *) Token->Packet.RxData->FragmentTable\r | |
965 | );\r | |
966 | if (EFI_ERROR (Status)) {\r | |
967 | return Status;\r | |
968 | }\r | |
969 | \r | |
970 | Sock = SOCK_FROM_THIS (This);\r | |
971 | \r | |
972 | return SockRcv (Sock, Token);\r | |
973 | }\r | |
974 | \r | |
975 | /**\r | |
976 | Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a\r | |
977 | nonblocking operation.\r | |
978 | \r | |
979 | Initiate an asynchronous close token to the TCP driver. After Close() is called, any buffered\r | |
980 | transmission data will be sent by the TCP driver, and the current instance will have a graceful close\r | |
981 | working flow described as RFC 793 if AbortOnClose is set to FALSE. Otherwise, a rest packet\r | |
982 | will be sent by TCP driver to fast disconnect this connection. When the close operation completes\r | |
983 | successfully the TCP instance is in Tcp6StateClosed state, all pending asynchronous\r | |
984 | operations are signaled, and any buffers used for TCP network traffic are flushed.\r | |
985 | \r | |
986 | @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r | |
987 | @param[in] CloseToken Pointer to the close token to return when operation finishes.\r | |
988 | \r | |
989 | @retval EFI_SUCCESS The Close() was called successfully.\r | |
990 | @retval EFI_NOT_STARTED This EFI TCPv6 Protocol instance has not been configured.\r | |
991 | @retval EFI_ACCESS_DENIED One or more of the following are TRUE:\r | |
992 | - CloseToken or CloseToken->CompletionToken.Event is already in use.\r | |
993 | - Previous Close() call on this instance has not finished.\r | |
994 | @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r | |
995 | - This is NULL.\r | |
996 | - CloseToken is NULL.\r | |
997 | - CloseToken->CompletionToken.Event is NULL.\r | |
998 | @retval EFI_OUT_OF_RESOURCES Could not allocate enough resource to finish the operation.\r | |
999 | @retval EFI_DEVICE_ERROR Any unexpected error not belonging to error categories given above.\r | |
1000 | \r | |
1001 | **/\r | |
1002 | EFI_STATUS\r | |
1003 | EFIAPI\r | |
1004 | Tcp6Close (\r | |
1005 | IN EFI_TCP6_PROTOCOL *This,\r | |
1006 | IN EFI_TCP6_CLOSE_TOKEN *CloseToken\r | |
1007 | )\r | |
1008 | {\r | |
1009 | SOCKET *Sock;\r | |
1010 | \r | |
1011 | if (NULL == This || NULL == CloseToken || NULL == CloseToken->CompletionToken.Event) {\r | |
1012 | return EFI_INVALID_PARAMETER;\r | |
1013 | }\r | |
1014 | \r | |
1015 | Sock = SOCK_FROM_THIS (This);\r | |
1016 | \r | |
1017 | return SockClose (Sock, CloseToken, CloseToken->AbortOnClose);\r | |
1018 | }\r | |
1019 | \r | |
1020 | /**\r | |
5ffe214a | 1021 | Abort an asynchronous connection, listen, transmission or receive request.\r |
a3bcde70 | 1022 | \r |
5ffe214a | 1023 | The Cancel() function aborts a pending connection, listen, transmit or\r |
a3bcde70 HT |
1024 | receive request.\r |
1025 | \r | |
5ffe214a | 1026 | If Token is not NULL and the token is in the connection, listen, transmission\r |
a3bcde70 | 1027 | or receive queue when it is being cancelled, its Token->Status will be set\r |
5ffe214a | 1028 | to EFI_ABORTED and then Token->Event will be signaled.\r |
a3bcde70 HT |
1029 | \r |
1030 | If the token is not in one of the queues, which usually means that the\r | |
1031 | asynchronous operation has completed, EFI_NOT_FOUND is returned.\r | |
1032 | \r | |
1033 | If Token is NULL all asynchronous token issued by Connect(), Accept(),\r | |
5ffe214a | 1034 | Transmit() and Receive() will be aborted.\r |
a3bcde70 HT |
1035 | \r |
1036 | @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r | |
1037 | @param[in] Token Pointer to a token that has been issued by\r | |
1038 | EFI_TCP6_PROTOCOL.Connect(),\r | |
1039 | EFI_TCP6_PROTOCOL.Accept(),\r | |
1040 | EFI_TCP6_PROTOCOL.Transmit() or\r | |
1041 | EFI_TCP6_PROTOCOL.Receive(). If NULL, all pending\r | |
1042 | tokens issued by above four functions will be aborted. Type\r | |
1043 | EFI_TCP6_COMPLETION_TOKEN is defined in\r | |
1044 | EFI_TCP_PROTOCOL.Connect().\r | |
1045 | \r | |
5ffe214a JW |
1046 | @retval EFI_SUCCESS The asynchronous I/O request is aborted and Token->Event\r |
1047 | is signaled.\r | |
1048 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
1049 | @retval EFI_NOT_STARTED This instance hasn't been configured.\r | |
1050 | @retval EFI_NOT_FOUND The asynchronous I/O request isn't found in the transmission or\r | |
1051 | receive queue. It has either completed or wasn't issued by\r | |
1052 | Transmit() and Receive().\r | |
a3bcde70 HT |
1053 | \r |
1054 | **/\r | |
1055 | EFI_STATUS\r | |
1056 | EFIAPI\r | |
1057 | Tcp6Cancel (\r | |
1058 | IN EFI_TCP6_PROTOCOL *This,\r | |
1059 | IN EFI_TCP6_COMPLETION_TOKEN *Token OPTIONAL\r | |
1060 | )\r | |
1061 | {\r | |
5ffe214a JW |
1062 | SOCKET *Sock;\r |
1063 | \r | |
1064 | if (NULL == This) {\r | |
1065 | return EFI_INVALID_PARAMETER;\r | |
1066 | }\r | |
1067 | \r | |
1068 | Sock = SOCK_FROM_THIS (This);\r | |
1069 | \r | |
1070 | return SockCancel (Sock, Token);\r | |
a3bcde70 HT |
1071 | }\r |
1072 | \r | |
1073 | /**\r | |
1074 | Poll to receive incoming data and transmit outgoing segments.\r | |
1075 | \r | |
1076 | The Poll() function increases the rate that data is moved between the network\r | |
1077 | and application, and can be called when the TCP instance is created successfully.\r | |
1078 | Its use is optional.\r | |
1079 | \r | |
1080 | @param[in] This Pointer to the EFI_TCP6_PROTOCOL instance.\r | |
1081 | \r | |
1082 | @retval EFI_SUCCESS Incoming or outgoing data was processed.\r | |
1083 | @retval EFI_INVALID_PARAMETER This is NULL.\r | |
1084 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
1085 | @retval EFI_NOT_READY No incoming or outgoing data is processed.\r | |
1086 | @retval EFI_TIMEOUT Data was dropped out of the transmission or receive queue.\r | |
1087 | Consider increasing the polling rate.\r | |
1088 | \r | |
1089 | **/\r | |
1090 | EFI_STATUS\r | |
1091 | EFIAPI\r | |
1092 | Tcp6Poll (\r | |
1093 | IN EFI_TCP6_PROTOCOL *This\r | |
1094 | )\r | |
1095 | {\r | |
1096 | SOCKET *Sock;\r | |
1097 | EFI_STATUS Status;\r | |
1098 | \r | |
1099 | if (NULL == This) {\r | |
1100 | return EFI_INVALID_PARAMETER;\r | |
1101 | }\r | |
1102 | \r | |
1103 | Sock = SOCK_FROM_THIS (This);\r | |
1104 | \r | |
1105 | Status = Sock->ProtoHandler (Sock, SOCK_POLL, NULL);\r | |
1106 | \r | |
1107 | return Status;\r | |
1108 | }\r | |
1109 | \r |