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