]>
Commit | Line | Data |
---|---|---|
3bdf9aae | 1 | /** @file\r |
2 | Implement the TCP6 driver support for the socket layer.\r | |
3 | \r | |
0e565888 OM |
4 | Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials are licensed and made available\r | |
6 | under the terms and conditions of the BSD License which accompanies this\r | |
7 | distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php.\r | |
3bdf9aae | 9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | \r | |
14 | \section ConnectionManagement Connection Management\r | |
0e565888 | 15 | \r |
3bdf9aae | 16 | The ::EslTcp6Listen routine initially places the SOCK_STREAM or\r |
17 | SOCK_SEQPACKET socket into a listen state. When a remote machine\r | |
18 | makes a connection to the socket, the TCPv6 network layer calls\r | |
19 | ::EslTcp6ListenComplete to complete the connection processing.\r | |
20 | EslTcp6ListenComplete manages the connections by placing them in\r | |
21 | FIFO order in a queue to be serviced by the application. When the\r | |
22 | number of connections exceeds the backlog (ESL_SOCKET::MaxFifoDepth),\r | |
23 | the new connection is closed. Eventually, the application indirectly\r | |
24 | calls ::EslTcp6Accept to remove the next connection from the queue\r | |
25 | and get the associated socket.\r | |
26 | \r | |
27 | **/\r | |
28 | \r | |
29 | #include "Socket.h"\r | |
30 | \r | |
31 | \r | |
32 | /**\r | |
33 | Attempt to connect to a remote TCP port\r | |
34 | \r | |
35 | This routine starts the connection processing for a SOCK_STREAM\r | |
36 | or SOCK_SEQPAKCET socket using the TCPv6 network layer. It\r | |
37 | configures the local TCPv6 connection point and then attempts to\r | |
38 | connect to a remote system. Upon completion, the\r | |
39 | ::EslTcp6ConnectComplete routine gets called with the connection\r | |
40 | status.\r | |
41 | \r | |
42 | This routine is called by ::EslSocketConnect to initiate the TCPv6\r | |
43 | network specific connect operations. The connection processing is\r | |
44 | initiated by this routine and finished by ::EslTcp6ConnectComplete.\r | |
45 | This pair of routines walks through the list of local TCPv6\r | |
46 | connection points until a connection to the remote system is\r | |
47 | made.\r | |
48 | \r | |
49 | @param [in] pSocket Address of an ::ESL_SOCKET structure.\r | |
50 | \r | |
51 | @retval EFI_SUCCESS The connection was successfully established.\r | |
52 | @retval EFI_NOT_READY The connection is in progress, call this routine again.\r | |
53 | @retval Others The connection attempt failed.\r | |
54 | \r | |
55 | **/\r | |
56 | EFI_STATUS\r | |
57 | EslTcp6ConnectStart (\r | |
58 | IN ESL_SOCKET * pSocket\r | |
59 | );\r | |
60 | \r | |
61 | \r | |
62 | /**\r | |
63 | Process the connection attempt\r | |
64 | \r | |
65 | A system has initiated a connection attempt with a socket in the\r | |
66 | listen state. Attempt to complete the connection.\r | |
67 | \r | |
68 | The TCPv6 layer calls this routine when a connection is made to\r | |
69 | the socket in the listen state. See the\r | |
70 | \ref ConnectionManagement section.\r | |
71 | \r | |
72 | @param [in] Event The listen completion event\r | |
73 | \r | |
74 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
75 | \r | |
76 | **/\r | |
77 | VOID\r | |
78 | EslTcp6ListenComplete (\r | |
79 | IN EFI_EVENT Event,\r | |
80 | IN ESL_PORT * pPort\r | |
81 | );\r | |
82 | \r | |
83 | \r | |
84 | /**\r | |
85 | Accept a network connection.\r | |
86 | \r | |
87 | This routine waits for a network connection to the socket and\r | |
88 | returns the remote network address to the caller if requested.\r | |
89 | \r | |
90 | This routine is called by ::EslSocketAccept to handle the TCPv6 protocol\r | |
91 | specific accept operations for SOCK_STREAM and SOCK_SEQPACKET sockets.\r | |
92 | See the \ref ConnectionManagement section.\r | |
93 | \r | |
94 | @param [in] pSocket Address of an ::ESL_SOCKET structure.\r | |
95 | \r | |
96 | @param [in] pSockAddr Address of a buffer to receive the remote\r | |
97 | network address.\r | |
98 | \r | |
99 | @param [in, out] pSockAddrLength Length in bytes of the address buffer.\r | |
100 | On output specifies the length of the\r | |
101 | remote network address.\r | |
102 | \r | |
103 | @retval EFI_SUCCESS Remote address is available\r | |
104 | @retval Others Remote address not available\r | |
105 | \r | |
106 | **/\r | |
107 | EFI_STATUS\r | |
108 | EslTcp6Accept (\r | |
109 | IN ESL_SOCKET * pSocket,\r | |
110 | IN struct sockaddr * pSockAddr,\r | |
111 | IN OUT socklen_t * pSockAddrLength\r | |
112 | )\r | |
113 | {\r | |
114 | ESL_PORT * pPort;\r | |
115 | struct sockaddr_in6 * pRemoteAddress;\r | |
116 | ESL_TCP6_CONTEXT * pTcp6;\r | |
117 | EFI_STATUS Status;\r | |
118 | \r | |
119 | DBG_ENTER ( );\r | |
120 | \r | |
121 | //\r | |
122 | // Validate the socket length\r | |
123 | //\r | |
124 | pRemoteAddress = (struct sockaddr_in6 *) pSockAddr;\r | |
125 | if (( NULL == pSockAddrLength )\r | |
126 | || ( sizeof ( *pRemoteAddress ) > *pSockAddrLength )) {\r | |
127 | //\r | |
128 | // Invalid socket address\r | |
129 | //\r | |
130 | Status = EFI_INVALID_PARAMETER;\r | |
131 | pSocket->errno = EINVAL;\r | |
132 | DEBUG (( DEBUG_ACCEPT,\r | |
133 | "ERROR - Invalid address length\r\n" ));\r | |
134 | }\r | |
135 | else {\r | |
136 | //\r | |
137 | // Assume success\r | |
138 | //\r | |
139 | Status = EFI_SUCCESS;\r | |
140 | \r | |
141 | //\r | |
142 | // Locate the address context\r | |
143 | //\r | |
144 | pPort = pSocket->pPortList;\r | |
145 | pTcp6 = &pPort->Context.Tcp6;\r | |
146 | \r | |
147 | //\r | |
148 | // Fill-in the remote address structure\r | |
149 | //\r | |
150 | ZeroMem ( pRemoteAddress, sizeof ( *pRemoteAddress ));\r | |
151 | pRemoteAddress->sin6_len = sizeof ( *pRemoteAddress );\r | |
152 | pRemoteAddress->sin6_family = AF_INET6;\r | |
153 | pRemoteAddress->sin6_port = SwapBytes16 ( pTcp6->ConfigData.AccessPoint.RemotePort );\r | |
154 | CopyMem ( &pRemoteAddress->sin6_addr.__u6_addr.__u6_addr8 [ 0 ],\r | |
155 | &pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],\r | |
156 | sizeof ( pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr ));\r | |
157 | }\r | |
158 | \r | |
159 | //\r | |
160 | // Return the operation status\r | |
161 | //\r | |
162 | DBG_EXIT_STATUS ( Status );\r | |
163 | return Status;\r | |
164 | }\r | |
165 | \r | |
166 | \r | |
167 | /**\r | |
168 | Process the remote connection completion event.\r | |
169 | \r | |
170 | This routine handles the completion of a connection attempt. It\r | |
171 | releases the port (TCPv6 adapter connection) in the case of an\r | |
172 | error and start a connection attempt on the next port. If the\r | |
173 | connection attempt was successful then this routine releases all\r | |
174 | of the other ports.\r | |
175 | \r | |
176 | This routine is called by the TCPv6 layer when a connect request\r | |
177 | completes. It sets the ESL_SOCKET::bConnected flag to notify the\r | |
178 | ::EslTcp6ConnectComplete routine that the connection is available.\r | |
179 | The flag is set when the connection is established or no more ports\r | |
180 | exist in the list. The connection status is passed via\r | |
181 | ESL_SOCKET::ConnectStatus.\r | |
182 | \r | |
183 | @param [in] Event The connect completion event\r | |
184 | \r | |
185 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
186 | \r | |
187 | **/\r | |
188 | VOID\r | |
189 | EslTcp6ConnectComplete (\r | |
190 | IN EFI_EVENT Event,\r | |
191 | IN ESL_PORT * pPort\r | |
192 | )\r | |
193 | {\r | |
194 | BOOLEAN bRemoveFirstPort;\r | |
195 | BOOLEAN bRemovePorts;\r | |
196 | ESL_PORT * pNextPort;\r | |
197 | ESL_SOCKET * pSocket;\r | |
198 | ESL_TCP6_CONTEXT * pTcp6;\r | |
199 | EFI_STATUS Status;\r | |
200 | \r | |
201 | DBG_ENTER ( );\r | |
202 | \r | |
203 | //\r | |
204 | // Locate the TCP context\r | |
205 | //\r | |
206 | pSocket = pPort->pSocket;\r | |
207 | pTcp6 = &pPort->Context.Tcp6;\r | |
208 | \r | |
209 | //\r | |
210 | // Get the connection status\r | |
211 | //\r | |
212 | bRemoveFirstPort = FALSE;\r | |
213 | bRemovePorts = FALSE;\r | |
214 | Status = pTcp6->ConnectToken.CompletionToken.Status;\r | |
215 | pSocket->ConnectStatus = Status;\r | |
216 | if ( !EFI_ERROR ( Status )) {\r | |
217 | //\r | |
218 | // The connection was successful\r | |
219 | //\r | |
220 | DEBUG (( DEBUG_CONNECT,\r | |
221 | "0x%08x: Port connected to [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",\r | |
222 | pPort,\r | |
223 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],\r | |
224 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[1],\r | |
225 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[2],\r | |
226 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[3],\r | |
227 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[4],\r | |
228 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[5],\r | |
229 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[6],\r | |
230 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[7],\r | |
231 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[8],\r | |
232 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[9],\r | |
233 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[10],\r | |
234 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[11],\r | |
235 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[12],\r | |
236 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[13],\r | |
237 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[14],\r | |
238 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[15],\r | |
239 | pTcp6->ConfigData.AccessPoint.RemotePort ));\r | |
240 | \r | |
ceecdc62 | 241 | //\r |
242 | // Start the receive operations\r | |
243 | //\r | |
244 | pSocket->bConfigured = TRUE;\r | |
245 | pSocket->State = SOCKET_STATE_CONNECTED;\r | |
246 | EslSocketRxStart ( pPort );\r | |
247 | \r | |
3bdf9aae | 248 | //\r |
249 | // Remove the rest of the ports\r | |
250 | //\r | |
251 | bRemovePorts = TRUE;\r | |
252 | }\r | |
253 | else {\r | |
254 | //\r | |
255 | // The connection failed\r | |
256 | //\r | |
44538ba5 | 257 | if ( pPort->bConfigured ) {\r |
258 | DEBUG (( DEBUG_CONNECT,\r | |
259 | "0x%08x: Port connection to [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d failed, Status: %r\r\n",\r | |
260 | pPort,\r | |
261 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],\r | |
262 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[1],\r | |
263 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[2],\r | |
264 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[3],\r | |
265 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[4],\r | |
266 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[5],\r | |
267 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[6],\r | |
268 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[7],\r | |
269 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[8],\r | |
270 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[9],\r | |
271 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[10],\r | |
272 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[11],\r | |
273 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[12],\r | |
274 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[13],\r | |
275 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[14],\r | |
276 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[15],\r | |
277 | pTcp6->ConfigData.AccessPoint.RemotePort,\r | |
278 | Status ));\r | |
279 | }\r | |
3bdf9aae | 280 | \r |
281 | //\r | |
282 | // Close the current port\r | |
283 | //\r | |
284 | Status = EslSocketPortClose ( pPort );\r | |
285 | if ( !EFI_ERROR ( Status )) {\r | |
286 | DEBUG (( DEBUG_CONNECT,\r | |
287 | "0x%08x: Port closed\r\n",\r | |
288 | pPort ));\r | |
289 | }\r | |
290 | else {\r | |
291 | DEBUG (( DEBUG_CONNECT,\r | |
292 | "ERROR - Failed to close port 0x%08x, Status: %r\r\n",\r | |
293 | pPort,\r | |
294 | Status ));\r | |
295 | }\r | |
296 | \r | |
297 | //\r | |
298 | // Try to connect using the next port\r | |
299 | //\r | |
300 | Status = EslTcp6ConnectStart ( pSocket );\r | |
301 | if ( EFI_NOT_READY != Status ) {\r | |
3bdf9aae | 302 | bRemoveFirstPort = TRUE;\r |
303 | }\r | |
304 | }\r | |
305 | \r | |
306 | //\r | |
307 | // Remove the ports if necessary\r | |
308 | //\r | |
309 | if ( bRemoveFirstPort || bRemovePorts ) {\r | |
310 | //\r | |
311 | // Remove the first port if necessary\r | |
312 | //\r | |
313 | pPort = pSocket->pPortList;\r | |
314 | if (( !bRemoveFirstPort ) && ( NULL != pPort )) {\r | |
315 | pPort = pPort->pLinkSocket;\r | |
316 | }\r | |
317 | \r | |
318 | //\r | |
319 | // Remove the rest of the list\r | |
320 | //\r | |
321 | while ( NULL != pPort ) {\r | |
322 | pNextPort = pPort->pLinkSocket;\r | |
323 | EslSocketPortClose ( pPort );\r | |
324 | if ( !EFI_ERROR ( Status )) {\r | |
325 | DEBUG (( DEBUG_CONNECT,\r | |
326 | "0x%08x: Port closed\r\n",\r | |
327 | pPort ));\r | |
328 | }\r | |
329 | else {\r | |
330 | DEBUG (( DEBUG_CONNECT,\r | |
331 | "ERROR - Failed to close port 0x%08x, Status: %r\r\n",\r | |
332 | pPort,\r | |
333 | Status ));\r | |
334 | }\r | |
335 | pPort = pNextPort;\r | |
336 | }\r | |
337 | \r | |
338 | //\r | |
339 | // Notify the poll routine\r | |
340 | //\r | |
341 | pSocket->bConnected = TRUE;\r | |
342 | }\r | |
343 | \r | |
344 | DBG_EXIT ( );\r | |
345 | }\r | |
346 | \r | |
347 | \r | |
348 | /**\r | |
349 | Poll for completion of the connection attempt.\r | |
350 | \r | |
351 | This routine polls the ESL_SOCKET::bConnected flag to determine\r | |
352 | when the connection attempt is complete.\r | |
353 | \r | |
354 | This routine is called from ::EslSocketConnect to determine when\r | |
355 | the connection is complete. The ESL_SOCKET::bConnected flag is\r | |
356 | set by ::EslTcp6ConnectComplete when the TCPv6 layer establishes\r | |
357 | a connection or runs out of local network adapters. This routine\r | |
358 | gets the connection status from ESL_SOCKET::ConnectStatus.\r | |
359 | \r | |
360 | @param [in] pSocket Address of an ::ESL_SOCKET structure.\r | |
361 | \r | |
362 | @retval EFI_SUCCESS The connection was successfully established.\r | |
363 | @retval EFI_NOT_READY The connection is in progress, call this routine again.\r | |
364 | @retval Others The connection attempt failed.\r | |
365 | \r | |
366 | **/\r | |
367 | EFI_STATUS\r | |
368 | EslTcp6ConnectPoll (\r | |
369 | IN ESL_SOCKET * pSocket\r | |
370 | )\r | |
371 | {\r | |
372 | EFI_STATUS Status;\r | |
373 | \r | |
374 | DBG_ENTER ( );\r | |
375 | \r | |
376 | //\r | |
377 | // Determine if the connection is complete\r | |
378 | //\r | |
379 | if ( !pSocket->bConnected ) {\r | |
380 | //\r | |
381 | // Not connected\r | |
382 | //\r | |
383 | pSocket->errno = EAGAIN;\r | |
384 | Status = EFI_NOT_READY;\r | |
385 | }\r | |
386 | else {\r | |
387 | //\r | |
388 | // The connection processing is complete\r | |
389 | //\r | |
390 | pSocket->bConnected = FALSE;\r | |
391 | \r | |
392 | //\r | |
393 | // Translate the connection status\r | |
394 | //\r | |
395 | Status = pSocket->ConnectStatus;\r | |
396 | switch ( Status ) {\r | |
44538ba5 | 397 | default:\r |
398 | case EFI_DEVICE_ERROR:\r | |
399 | pSocket->errno = EIO;\r | |
400 | break;\r | |
0e565888 | 401 | \r |
44538ba5 | 402 | case EFI_ABORTED:\r |
403 | pSocket->errno = ECONNABORTED;\r | |
404 | break;\r | |
0e565888 | 405 | \r |
44538ba5 | 406 | case EFI_ACCESS_DENIED:\r |
407 | pSocket->errno = EACCES;\r | |
408 | break;\r | |
0e565888 | 409 | \r |
44538ba5 | 410 | case EFI_CONNECTION_RESET:\r |
411 | pSocket->errno = ECONNRESET;\r | |
412 | break;\r | |
0e565888 | 413 | \r |
44538ba5 | 414 | case EFI_INVALID_PARAMETER:\r |
415 | pSocket->errno = EADDRNOTAVAIL;\r | |
416 | break;\r | |
0e565888 | 417 | \r |
44538ba5 | 418 | case EFI_HOST_UNREACHABLE:\r |
419 | case EFI_NO_RESPONSE:\r | |
420 | pSocket->errno = EHOSTUNREACH;\r | |
421 | break;\r | |
0e565888 | 422 | \r |
44538ba5 | 423 | case EFI_NO_MAPPING:\r |
424 | pSocket->errno = EAFNOSUPPORT;\r | |
425 | break;\r | |
0e565888 | 426 | \r |
44538ba5 | 427 | case EFI_NO_MEDIA:\r |
428 | case EFI_NETWORK_UNREACHABLE:\r | |
429 | pSocket->errno = ENETDOWN;\r | |
430 | break;\r | |
0e565888 | 431 | \r |
44538ba5 | 432 | case EFI_OUT_OF_RESOURCES:\r |
433 | pSocket->errno = ENOBUFS;\r | |
434 | break;\r | |
0e565888 | 435 | \r |
44538ba5 | 436 | case EFI_PORT_UNREACHABLE:\r |
437 | case EFI_PROTOCOL_UNREACHABLE:\r | |
438 | case EFI_CONNECTION_REFUSED:\r | |
439 | pSocket->errno = ECONNREFUSED;\r | |
440 | break;\r | |
0e565888 | 441 | \r |
44538ba5 | 442 | case EFI_SUCCESS:\r |
443 | pSocket->errno = 0;\r | |
44538ba5 | 444 | break;\r |
0e565888 | 445 | \r |
44538ba5 | 446 | case EFI_TIMEOUT:\r |
447 | pSocket->errno = ETIMEDOUT;\r | |
448 | break;\r | |
0e565888 | 449 | \r |
44538ba5 | 450 | case EFI_UNSUPPORTED:\r |
451 | pSocket->errno = EOPNOTSUPP;\r | |
452 | break;\r | |
3bdf9aae | 453 | }\r |
44538ba5 | 454 | \r |
455 | //\r | |
456 | // Display the translation\r | |
457 | //\r | |
458 | DEBUG (( DEBUG_CONNECT,\r | |
459 | "ERROR - errno: %d, Status: %r\r\n",\r | |
460 | pSocket->errno,\r | |
461 | Status ));\r | |
3bdf9aae | 462 | }\r |
463 | \r | |
464 | //\r | |
465 | // Return the initialization status\r | |
466 | //\r | |
467 | DBG_EXIT_STATUS ( Status );\r | |
468 | return Status;\r | |
469 | }\r | |
470 | \r | |
471 | \r | |
472 | /**\r | |
473 | Attempt to connect to a remote TCP port\r | |
474 | \r | |
475 | This routine starts the connection processing for a SOCK_STREAM\r | |
476 | or SOCK_SEQPAKCET socket using the TCPv6 network layer. It\r | |
477 | configures the local TCPv6 connection point and then attempts to\r | |
478 | connect to a remote system. Upon completion, the\r | |
479 | ::EslTcp6ConnectComplete routine gets called with the connection\r | |
480 | status.\r | |
481 | \r | |
482 | This routine is called by ::EslSocketConnect to initiate the TCPv6\r | |
483 | network specific connect operations. The connection processing is\r | |
484 | initiated by this routine and finished by ::EslTcp6ConnectComplete.\r | |
485 | This pair of routines walks through the list of local TCPv6\r | |
486 | connection points until a connection to the remote system is\r | |
487 | made.\r | |
488 | \r | |
489 | @param [in] pSocket Address of an ::ESL_SOCKET structure.\r | |
490 | \r | |
491 | @retval EFI_SUCCESS The connection was successfully established.\r | |
492 | @retval EFI_NOT_READY The connection is in progress, call this routine again.\r | |
493 | @retval Others The connection attempt failed.\r | |
494 | \r | |
495 | **/\r | |
496 | EFI_STATUS\r | |
497 | EslTcp6ConnectStart (\r | |
498 | IN ESL_SOCKET * pSocket\r | |
499 | )\r | |
500 | {\r | |
501 | ESL_PORT * pPort;\r | |
502 | ESL_TCP6_CONTEXT * pTcp6;\r | |
503 | EFI_TCP6_PROTOCOL * pTcp6Protocol;\r | |
3a2fc878 | 504 | EFI_SIMPLE_NETWORK_MODE SnpModeData;\r |
3bdf9aae | 505 | EFI_STATUS Status;\r |
506 | \r | |
507 | DBG_ENTER ( );\r | |
0e565888 | 508 | \r |
3bdf9aae | 509 | //\r |
510 | // Determine if any more local adapters are available\r | |
511 | //\r | |
512 | pPort = pSocket->pPortList;\r | |
513 | if ( NULL != pPort ) {\r | |
514 | //\r | |
515 | // Configure the port\r | |
516 | //\r | |
517 | pTcp6 = &pPort->Context.Tcp6;\r | |
518 | pTcp6->ConfigData.AccessPoint.ActiveFlag = TRUE;\r | |
519 | pTcp6->ConfigData.TrafficClass = 0;\r | |
520 | pTcp6->ConfigData.HopLimit = 255;\r | |
521 | pTcp6Protocol = pPort->pProtocol.TCPv6;\r | |
522 | Status = pTcp6Protocol->Configure ( pTcp6Protocol,\r | |
523 | &pTcp6->ConfigData );\r | |
524 | if ( EFI_ERROR ( Status )) {\r | |
525 | DEBUG (( DEBUG_CONNECT,\r | |
526 | "ERROR - Failed to configure the Tcp6 port, Status: %r\r\n",\r | |
527 | Status ));\r | |
3bdf9aae | 528 | }\r |
529 | else {\r | |
530 | DEBUG (( DEBUG_CONNECT,\r | |
531 | "0x%08x: Port configured\r\n",\r | |
532 | pPort ));\r | |
533 | pPort->bConfigured = TRUE;\r | |
534 | \r | |
535 | //\r | |
3a2fc878 | 536 | // Verify the port connection\r |
3bdf9aae | 537 | //\r |
3a2fc878 | 538 | Status = pTcp6Protocol->GetModeData ( pTcp6Protocol,\r |
539 | NULL,\r | |
540 | NULL,\r | |
541 | NULL,\r | |
542 | NULL,\r | |
543 | &SnpModeData );\r | |
544 | if ( !EFI_ERROR ( Status )) {\r | |
545 | if ( SnpModeData.MediaPresentSupported\r | |
546 | && ( !SnpModeData.MediaPresent )) {\r | |
547 | //\r | |
548 | // Port is not connected to the network\r | |
549 | //\r | |
44538ba5 | 550 | Status = EFI_NO_MEDIA;\r |
3a2fc878 | 551 | }\r |
552 | else {\r | |
553 | //\r | |
554 | // Attempt the connection to the remote system\r | |
555 | //\r | |
556 | Status = pTcp6Protocol->Connect ( pTcp6Protocol,\r | |
557 | &pTcp6->ConnectToken );\r | |
558 | }\r | |
559 | }\r | |
44538ba5 | 560 | if ( EFI_ERROR ( Status )) {\r |
3bdf9aae | 561 | //\r |
562 | // Connection error\r | |
563 | //\r | |
564 | DEBUG (( DEBUG_CONNECT,\r | |
565 | "ERROR - Port 0x%08x not connected, Status: %r\r\n",\r | |
566 | pPort,\r | |
567 | Status ));\r | |
3bdf9aae | 568 | }\r |
569 | }\r | |
44538ba5 | 570 | if ( !EFI_ERROR ( Status )) {\r |
571 | //\r | |
572 | // Connection in progress\r | |
573 | //\r | |
574 | pSocket->errno = EINPROGRESS;\r | |
575 | DEBUG (( DEBUG_CONNECT,\r | |
576 | "0x%08x: Port attempting connection to [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",\r | |
577 | pPort,\r | |
578 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],\r | |
579 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[1],\r | |
580 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[2],\r | |
581 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[3],\r | |
582 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[4],\r | |
583 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[5],\r | |
584 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[6],\r | |
585 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[7],\r | |
586 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[8],\r | |
587 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[9],\r | |
588 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[10],\r | |
589 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[11],\r | |
590 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[12],\r | |
591 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[13],\r | |
592 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[14],\r | |
593 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[15],\r | |
594 | pTcp6->ConfigData.AccessPoint.RemotePort ));\r | |
595 | }\r | |
596 | else {\r | |
597 | //\r | |
598 | // Error return path is through EslTcp6ConnectComplete to\r | |
599 | // enable retry on other ports\r | |
600 | //\r | |
601 | // Status to errno translation gets done in EslTcp4ConnectPoll\r | |
602 | //\r | |
603 | pTcp6->ConnectToken.CompletionToken.Status = Status;\r | |
0e565888 | 604 | \r |
44538ba5 | 605 | //\r |
606 | // Continue with the next port\r | |
607 | //\r | |
608 | gBS->CheckEvent ( pTcp6->ConnectToken.CompletionToken.Event );\r | |
609 | gBS->SignalEvent ( pTcp6->ConnectToken.CompletionToken.Event );\r | |
610 | }\r | |
611 | Status = EFI_NOT_READY;\r | |
3bdf9aae | 612 | }\r |
613 | else {\r | |
614 | //\r | |
615 | // No more local adapters available\r | |
616 | //\r | |
617 | pSocket->errno = ENETUNREACH;\r | |
618 | Status = EFI_NO_RESPONSE;\r | |
619 | }\r | |
620 | \r | |
621 | //\r | |
622 | // Return the operation status\r | |
623 | //\r | |
624 | DBG_EXIT_STATUS ( Status );\r | |
625 | return Status;\r | |
626 | }\r | |
627 | \r | |
628 | \r | |
629 | /**\r | |
630 | Establish the known port to listen for network connections.\r | |
631 | \r | |
632 | This routine places the port into a state that enables connection\r | |
633 | attempts.\r | |
634 | \r | |
635 | This routine is called by ::EslSocketListen to handle the network\r | |
636 | specifics of the listen operation for SOCK_STREAM and SOCK_SEQPACKET\r | |
637 | sockets. See the \ref ConnectionManagement section.\r | |
638 | \r | |
639 | @param [in] pSocket Address of an ::ESL_SOCKET structure.\r | |
640 | \r | |
641 | @retval EFI_SUCCESS - Socket successfully created\r | |
642 | @retval Other - Failed to enable the socket for listen\r | |
643 | \r | |
644 | **/\r | |
645 | EFI_STATUS\r | |
646 | EslTcp6Listen (\r | |
647 | IN ESL_SOCKET * pSocket\r | |
648 | )\r | |
649 | {\r | |
650 | ESL_PORT * pNextPort;\r | |
651 | ESL_PORT * pPort;\r | |
652 | ESL_TCP6_CONTEXT * pTcp6;\r | |
653 | EFI_TCP6_PROTOCOL * pTcp6Protocol;\r | |
654 | EFI_STATUS Status;\r | |
655 | \r | |
656 | DBG_ENTER ( );\r | |
657 | \r | |
658 | //\r | |
659 | // Verify the socket layer synchronization\r | |
660 | //\r | |
661 | VERIFY_TPL ( TPL_SOCKETS );\r | |
662 | \r | |
663 | //\r | |
664 | // Use for/break instead of goto\r | |
665 | //\r | |
666 | for ( ; ; ) {\r | |
667 | //\r | |
668 | // Assume no ports are available\r | |
669 | //\r | |
670 | pSocket->errno = EOPNOTSUPP;\r | |
671 | Status = EFI_NOT_READY;\r | |
672 | \r | |
673 | //\r | |
674 | // Walk the list of ports\r | |
675 | //\r | |
676 | pPort = pSocket->pPortList;\r | |
677 | while ( NULL != pPort ) {\r | |
678 | //\r | |
679 | // Assume success\r | |
680 | //\r | |
681 | pSocket->errno = 0;\r | |
682 | \r | |
683 | //\r | |
684 | // Use for/break insteak of goto\r | |
685 | //\r | |
686 | for ( ; ; ) {\r | |
687 | //\r | |
688 | // Create the listen completion event\r | |
689 | //\r | |
690 | pTcp6 = &pPort->Context.Tcp6;\r | |
691 | Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL,\r | |
692 | TPL_SOCKETS,\r | |
693 | (EFI_EVENT_NOTIFY)EslTcp6ListenComplete,\r | |
694 | pPort,\r | |
695 | &pTcp6->ListenToken.CompletionToken.Event );\r | |
696 | if ( EFI_ERROR ( Status )) {\r | |
697 | DEBUG (( DEBUG_ERROR | DEBUG_LISTEN,\r | |
698 | "ERROR - Failed to create the listen completion event, Status: %r\r\n",\r | |
699 | Status ));\r | |
700 | pSocket->errno = ENOMEM;\r | |
701 | break;\r | |
702 | }\r | |
703 | DEBUG (( DEBUG_POOL,\r | |
704 | "0x%08x: Created listen completion event\r\n",\r | |
705 | pTcp6->ListenToken.CompletionToken.Event ));\r | |
706 | \r | |
707 | //\r | |
708 | // Configure the port\r | |
709 | //\r | |
710 | pTcp6Protocol = pPort->pProtocol.TCPv6;\r | |
711 | Status = pTcp6Protocol->Configure ( pTcp6Protocol,\r | |
712 | &pTcp6->ConfigData );\r | |
713 | if ( EFI_ERROR ( Status )) {\r | |
714 | DEBUG (( DEBUG_LISTEN,\r | |
715 | "ERROR - Failed to configure the Tcp6 port, Status: %r\r\n",\r | |
716 | Status ));\r | |
717 | switch ( Status ) {\r | |
718 | case EFI_ACCESS_DENIED:\r | |
719 | pSocket->errno = EACCES;\r | |
720 | break;\r | |
721 | \r | |
722 | default:\r | |
723 | case EFI_DEVICE_ERROR:\r | |
724 | pSocket->errno = EIO;\r | |
725 | break;\r | |
726 | \r | |
727 | case EFI_INVALID_PARAMETER:\r | |
728 | pSocket->errno = EADDRNOTAVAIL;\r | |
729 | break;\r | |
730 | \r | |
731 | case EFI_NO_MAPPING:\r | |
732 | pSocket->errno = EAFNOSUPPORT;\r | |
733 | break;\r | |
734 | \r | |
735 | case EFI_OUT_OF_RESOURCES:\r | |
736 | pSocket->errno = ENOBUFS;\r | |
737 | break;\r | |
738 | \r | |
739 | case EFI_UNSUPPORTED:\r | |
740 | pSocket->errno = EOPNOTSUPP;\r | |
741 | break;\r | |
742 | }\r | |
743 | break;\r | |
744 | }\r | |
745 | DEBUG (( DEBUG_LISTEN,\r | |
746 | "0x%08x: Port configured\r\n",\r | |
747 | pPort ));\r | |
748 | pPort->bConfigured = TRUE;\r | |
749 | \r | |
750 | //\r | |
751 | // Start the listen operation on the port\r | |
752 | //\r | |
753 | Status = pTcp6Protocol->Accept ( pTcp6Protocol,\r | |
754 | &pTcp6->ListenToken );\r | |
755 | if ( EFI_ERROR ( Status )) {\r | |
756 | DEBUG (( DEBUG_LISTEN,\r | |
757 | "ERROR - Failed Tcp6 accept, Status: %r\r\n",\r | |
758 | Status ));\r | |
759 | switch ( Status ) {\r | |
760 | case EFI_ACCESS_DENIED:\r | |
761 | pSocket->errno = EACCES;\r | |
762 | break;\r | |
763 | \r | |
764 | default:\r | |
765 | case EFI_DEVICE_ERROR:\r | |
766 | pSocket->errno = EIO;\r | |
767 | break;\r | |
768 | \r | |
769 | case EFI_INVALID_PARAMETER:\r | |
770 | pSocket->errno = EADDRNOTAVAIL;\r | |
771 | break;\r | |
772 | \r | |
773 | case EFI_NOT_STARTED:\r | |
774 | pSocket->errno = ENETDOWN;\r | |
775 | break;\r | |
776 | \r | |
777 | case EFI_OUT_OF_RESOURCES:\r | |
778 | pSocket->errno = ENOBUFS;\r | |
779 | break;\r | |
780 | }\r | |
781 | break;\r | |
782 | }\r | |
783 | DEBUG (( DEBUG_LISTEN,\r | |
784 | "0x%08x: Listen pending on Port\r\n",\r | |
785 | pPort ));\r | |
786 | \r | |
787 | //\r | |
788 | // Listen is pending on this port\r | |
789 | //\r | |
790 | break;\r | |
791 | }\r | |
792 | \r | |
793 | //\r | |
794 | // Get the next port\r | |
795 | //\r | |
796 | pNextPort = pPort->pLinkSocket;\r | |
797 | \r | |
798 | //\r | |
799 | // Close the port upon error\r | |
800 | //\r | |
801 | if ( EFI_ERROR ( Status )) {\r | |
802 | EslSocketPortCloseStart ( pPort, TRUE, DEBUG_LISTEN );\r | |
803 | }\r | |
804 | \r | |
805 | //\r | |
806 | // Set the next port\r | |
807 | //\r | |
808 | pPort = pNextPort;\r | |
809 | }\r | |
0e565888 | 810 | \r |
3bdf9aae | 811 | //\r |
812 | // Determine if any ports are in the listen state\r | |
813 | //\r | |
814 | if ( NULL == pSocket->pPortList ) {\r | |
815 | //\r | |
816 | // No ports in the listen state\r | |
817 | //\r | |
818 | pSocket->MaxFifoDepth = 0;\r | |
819 | \r | |
820 | //\r | |
821 | // Return the last error detected\r | |
822 | //\r | |
823 | break;\r | |
824 | }\r | |
825 | \r | |
826 | //\r | |
827 | // Mark the socket as configured\r | |
828 | //\r | |
829 | pSocket->bConfigured = TRUE;\r | |
b497a8a8 | 830 | Status = EFI_SUCCESS;\r |
831 | pSocket->errno = 0;\r | |
3bdf9aae | 832 | \r |
833 | //\r | |
834 | // All done\r | |
835 | //\r | |
836 | DEBUG (( DEBUG_LISTEN,\r | |
837 | "0x%08x: pSocket - Listen pending on socket\r\n",\r | |
838 | pSocket ));\r | |
839 | break;\r | |
840 | }\r | |
841 | \r | |
842 | //\r | |
843 | // Return the operation status\r | |
844 | //\r | |
845 | DBG_EXIT_STATUS ( Status );\r | |
846 | return Status;\r | |
847 | }\r | |
848 | \r | |
849 | \r | |
850 | /**\r | |
851 | Process the connection attempt\r | |
852 | \r | |
853 | A system has initiated a connection attempt with a socket in the\r | |
854 | listen state. Attempt to complete the connection.\r | |
855 | \r | |
856 | The TCPv6 layer calls this routine when a connection is made to\r | |
857 | the socket in the listen state. See the\r | |
858 | \ref ConnectionManagement section.\r | |
859 | \r | |
860 | @param [in] Event The listen completion event\r | |
861 | \r | |
862 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
863 | \r | |
864 | **/\r | |
865 | VOID\r | |
866 | EslTcp6ListenComplete (\r | |
867 | IN EFI_EVENT Event,\r | |
868 | IN ESL_PORT * pPort\r | |
869 | )\r | |
870 | {\r | |
871 | EFI_HANDLE ChildHandle;\r | |
872 | struct sockaddr_in6 LocalAddress;\r | |
873 | EFI_TCP6_CONFIG_DATA * pConfigData;\r | |
3bdf9aae | 874 | ESL_PORT * pNewPort;\r |
875 | ESL_SOCKET * pNewSocket;\r | |
876 | ESL_SOCKET * pSocket;\r | |
877 | ESL_TCP6_CONTEXT * pTcp6;\r | |
878 | EFI_TCP6_PROTOCOL * pTcp6Protocol;\r | |
879 | EFI_STATUS Status;\r | |
880 | EFI_HANDLE TcpPortHandle;\r | |
881 | EFI_STATUS TempStatus;\r | |
882 | \r | |
883 | DBG_ENTER ( );\r | |
884 | VERIFY_AT_TPL ( TPL_SOCKETS );\r | |
885 | \r | |
886 | //\r | |
887 | // Assume success\r | |
888 | //\r | |
889 | Status = EFI_SUCCESS;\r | |
890 | \r | |
891 | //\r | |
892 | // Determine if this connection fits into the connection FIFO\r | |
893 | //\r | |
894 | pSocket = pPort->pSocket;\r | |
895 | TcpPortHandle = pPort->Context.Tcp6.ListenToken.NewChildHandle;\r | |
896 | if (( SOCKET_STATE_LISTENING == pSocket->State )\r | |
897 | && ( pSocket->MaxFifoDepth > pSocket->FifoDepth )) {\r | |
898 | //\r | |
899 | // Allocate a socket for this connection\r | |
900 | //\r | |
901 | ChildHandle = NULL;\r | |
3bdf9aae | 902 | Status = EslSocketAllocate ( &ChildHandle,\r |
903 | DEBUG_CONNECTION,\r | |
904 | &pNewSocket );\r | |
905 | if ( !EFI_ERROR ( Status )) {\r | |
906 | //\r | |
907 | // Clone the socket parameters\r | |
908 | //\r | |
909 | pNewSocket->pApi = pSocket->pApi;\r | |
910 | pNewSocket->Domain = pSocket->Domain;\r | |
911 | pNewSocket->Protocol = pSocket->Protocol;\r | |
912 | pNewSocket->Type = pSocket->Type;\r | |
913 | \r | |
914 | //\r | |
915 | // Build the local address\r | |
916 | //\r | |
917 | pTcp6 = &pPort->Context.Tcp6;\r | |
918 | LocalAddress.sin6_len = (uint8_t)pNewSocket->pApi->MinimumAddressLength;\r | |
919 | LocalAddress.sin6_family = AF_INET6;\r | |
920 | LocalAddress.sin6_port = 0;\r | |
921 | CopyMem ( &LocalAddress.sin6_addr.__u6_addr.__u6_addr8 [ 0 ],\r | |
922 | &pTcp6->ConfigData.AccessPoint.StationAddress.Addr [ 0 ],\r | |
923 | sizeof ( pTcp6->ConfigData.AccessPoint.StationAddress.Addr ));\r | |
924 | \r | |
925 | //\r | |
926 | // Allocate a port for this connection\r | |
927 | // Note in this instance Configure may not be called with NULL!\r | |
928 | //\r | |
929 | Status = EslSocketPortAllocate ( pNewSocket,\r | |
930 | pPort->pService,\r | |
931 | TcpPortHandle,\r | |
932 | (struct sockaddr *)&LocalAddress,\r | |
933 | FALSE,\r | |
934 | DEBUG_CONNECTION,\r | |
935 | &pNewPort );\r | |
936 | if ( !EFI_ERROR ( Status )) {\r | |
937 | //\r | |
938 | // Restart the listen operation on the port\r | |
939 | //\r | |
940 | pTcp6Protocol = pPort->pProtocol.TCPv6;\r | |
941 | Status = pTcp6Protocol->Accept ( pTcp6Protocol,\r | |
942 | &pTcp6->ListenToken );\r | |
943 | \r | |
944 | //\r | |
945 | // Close the TCP port using SocketClose\r | |
946 | //\r | |
947 | TcpPortHandle = NULL;\r | |
948 | pTcp6 = &pNewPort->Context.Tcp6;\r | |
949 | \r | |
950 | //\r | |
951 | // Check for an accept call error\r | |
952 | //\r | |
953 | if ( !EFI_ERROR ( Status )) {\r | |
954 | //\r | |
955 | // Get the port configuration\r | |
956 | //\r | |
957 | pNewPort->bConfigured = TRUE;\r | |
958 | pConfigData = &pTcp6->ConfigData;\r | |
959 | pConfigData->ControlOption = &pTcp6->Option;\r | |
960 | pTcp6Protocol = pNewPort->pProtocol.TCPv6;\r | |
961 | Status = pTcp6Protocol->GetModeData ( pTcp6Protocol,\r | |
962 | NULL,\r | |
963 | pConfigData,\r | |
964 | NULL,\r | |
965 | NULL,\r | |
966 | NULL );\r | |
967 | if ( !EFI_ERROR ( Status )) {\r | |
968 | //\r | |
969 | // Add the new socket to the connection FIFO\r | |
970 | //\r | |
971 | if ( NULL == pSocket->pFifoTail ) {\r | |
972 | //\r | |
973 | // First connection\r | |
974 | //\r | |
975 | pSocket->pFifoHead = pNewSocket;\r | |
976 | }\r | |
977 | else {\r | |
978 | //\r | |
979 | // Add to end of list.\r | |
980 | //\r | |
981 | pSocket->pFifoTail->pNextConnection = pNewSocket;\r | |
982 | }\r | |
983 | pSocket->pFifoTail = pNewSocket;\r | |
984 | pSocket->FifoDepth += 1;\r | |
985 | \r | |
986 | //\r | |
987 | // Update the socket state\r | |
988 | //\r | |
989 | pNewSocket->State = SOCKET_STATE_IN_FIFO;\r | |
990 | \r | |
991 | //\r | |
992 | // Log the connection\r | |
993 | //\r | |
994 | DEBUG (( DEBUG_CONNECTION | DEBUG_INFO,\r | |
995 | "0x%08x: Socket on port [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d connected to [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",\r | |
996 | pNewSocket,\r | |
997 | pConfigData->AccessPoint.StationAddress.Addr[0],\r | |
998 | pConfigData->AccessPoint.StationAddress.Addr[1],\r | |
999 | pConfigData->AccessPoint.StationAddress.Addr[2],\r | |
1000 | pConfigData->AccessPoint.StationAddress.Addr[3],\r | |
1001 | pConfigData->AccessPoint.StationAddress.Addr[4],\r | |
1002 | pConfigData->AccessPoint.StationAddress.Addr[5],\r | |
1003 | pConfigData->AccessPoint.StationAddress.Addr[6],\r | |
1004 | pConfigData->AccessPoint.StationAddress.Addr[7],\r | |
1005 | pConfigData->AccessPoint.StationAddress.Addr[8],\r | |
1006 | pConfigData->AccessPoint.StationAddress.Addr[9],\r | |
1007 | pConfigData->AccessPoint.StationAddress.Addr[10],\r | |
1008 | pConfigData->AccessPoint.StationAddress.Addr[11],\r | |
1009 | pConfigData->AccessPoint.StationAddress.Addr[12],\r | |
1010 | pConfigData->AccessPoint.StationAddress.Addr[13],\r | |
1011 | pConfigData->AccessPoint.StationAddress.Addr[14],\r | |
1012 | pConfigData->AccessPoint.StationAddress.Addr[15],\r | |
1013 | pConfigData->AccessPoint.StationPort,\r | |
1014 | pConfigData->AccessPoint.RemoteAddress.Addr[0],\r | |
1015 | pConfigData->AccessPoint.RemoteAddress.Addr[1],\r | |
1016 | pConfigData->AccessPoint.RemoteAddress.Addr[2],\r | |
1017 | pConfigData->AccessPoint.RemoteAddress.Addr[3],\r | |
1018 | pConfigData->AccessPoint.RemoteAddress.Addr[4],\r | |
1019 | pConfigData->AccessPoint.RemoteAddress.Addr[5],\r | |
1020 | pConfigData->AccessPoint.RemoteAddress.Addr[6],\r | |
1021 | pConfigData->AccessPoint.RemoteAddress.Addr[7],\r | |
1022 | pConfigData->AccessPoint.RemoteAddress.Addr[8],\r | |
1023 | pConfigData->AccessPoint.RemoteAddress.Addr[9],\r | |
1024 | pConfigData->AccessPoint.RemoteAddress.Addr[10],\r | |
1025 | pConfigData->AccessPoint.RemoteAddress.Addr[11],\r | |
1026 | pConfigData->AccessPoint.RemoteAddress.Addr[12],\r | |
1027 | pConfigData->AccessPoint.RemoteAddress.Addr[13],\r | |
1028 | pConfigData->AccessPoint.RemoteAddress.Addr[14],\r | |
1029 | pConfigData->AccessPoint.RemoteAddress.Addr[15],\r | |
1030 | pConfigData->AccessPoint.RemotePort ));\r | |
1031 | DEBUG (( DEBUG_CONNECTION | DEBUG_INFO,\r | |
1032 | "0x%08x: Listen socket adding socket 0x%08x to FIFO, depth: %d\r\n",\r | |
1033 | pSocket,\r | |
1034 | pNewSocket,\r | |
1035 | pSocket->FifoDepth ));\r | |
1036 | \r | |
1037 | //\r | |
1038 | // Start the receive operation\r | |
1039 | //\r | |
1040 | EslSocketRxStart ( pNewPort );\r | |
1041 | }\r | |
1042 | else {\r | |
1043 | DEBUG (( DEBUG_ERROR | DEBUG_CONNECTION | DEBUG_INFO,\r | |
1044 | "ERROR - GetModeData failed on port 0x%08x, Status: %r\r\n",\r | |
1045 | pNewPort,\r | |
1046 | Status ));\r | |
1047 | }\r | |
1048 | }\r | |
1049 | else {\r | |
1050 | //\r | |
1051 | // The listen failed on this port\r | |
1052 | //\r | |
1053 | DEBUG (( DEBUG_LISTEN | DEBUG_INFO,\r | |
1054 | "ERROR - Listen failed on port 0x%08x, Status: %r\r\n",\r | |
1055 | pPort,\r | |
1056 | Status ));\r | |
1057 | \r | |
1058 | //\r | |
1059 | // Close the listening port\r | |
1060 | //\r | |
1061 | EslSocketPortCloseStart ( pPort, TRUE, DEBUG_LISTEN );\r | |
1062 | }\r | |
1063 | }\r | |
1064 | \r | |
1065 | //\r | |
1066 | // Done with the socket if necessary\r | |
1067 | //\r | |
1068 | if ( EFI_ERROR ( Status )) {\r | |
1069 | TempStatus = EslSocketCloseStart ( &pNewSocket->SocketProtocol,\r | |
1070 | TRUE,\r | |
1071 | &pSocket->errno );\r | |
1072 | ASSERT ( EFI_SUCCESS == TempStatus );\r | |
1073 | }\r | |
1074 | }\r | |
1075 | }\r | |
1076 | else {\r | |
1077 | DEBUG (( DEBUG_CONNECTION,\r | |
1078 | "0x%08x: Socket FIFO full, connection refused\r\n",\r | |
1079 | pSocket ));\r | |
1080 | \r | |
1081 | //\r | |
1082 | // The FIFO is full or the socket is in the wrong state\r | |
1083 | //\r | |
1084 | Status = EFI_BUFFER_TOO_SMALL;\r | |
1085 | }\r | |
1086 | \r | |
1087 | //\r | |
1088 | // Close the connection if necessary\r | |
1089 | //\r | |
1090 | if (( EFI_ERROR ( Status ))\r | |
1091 | && ( NULL == TcpPortHandle )) {\r | |
1092 | //\r | |
1093 | // TODO: Finish this code path\r | |
1094 | // The new connection does not fit into the connection FIFO\r | |
1095 | //\r | |
1096 | // Process:\r | |
1097 | // Call close\r | |
1098 | // Release the resources\r | |
0e565888 | 1099 | \r |
3bdf9aae | 1100 | }\r |
1101 | \r | |
1102 | DBG_EXIT ( );\r | |
1103 | }\r | |
1104 | \r | |
1105 | \r | |
1106 | /**\r | |
1107 | Get the local socket address.\r | |
1108 | \r | |
1109 | This routine returns the IPv6 address and TCP port number associated\r | |
1110 | with the local socket.\r | |
1111 | \r | |
1112 | This routine is called by ::EslSocketGetLocalAddress to determine the\r | |
1113 | network address for the SOCK_STREAM or SOCK_SEQPACKET socket.\r | |
1114 | \r | |
1115 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
1116 | \r | |
1117 | @param [out] pSockAddr Network address to receive the local system address\r | |
1118 | \r | |
1119 | **/\r | |
1120 | VOID\r | |
1121 | EslTcp6LocalAddressGet (\r | |
1122 | IN ESL_PORT * pPort,\r | |
1123 | OUT struct sockaddr * pSockAddr\r | |
1124 | )\r | |
1125 | {\r | |
1126 | struct sockaddr_in6 * pLocalAddress;\r | |
1127 | ESL_TCP6_CONTEXT * pTcp6;\r | |
1128 | \r | |
1129 | DBG_ENTER ( );\r | |
1130 | \r | |
1131 | //\r | |
1132 | // Return the local address\r | |
1133 | //\r | |
1134 | pTcp6 = &pPort->Context.Tcp6;\r | |
1135 | pLocalAddress = (struct sockaddr_in6 *)pSockAddr;\r | |
1136 | pLocalAddress->sin6_family = AF_INET6;\r | |
1137 | pLocalAddress->sin6_port = SwapBytes16 ( pTcp6->ConfigData.AccessPoint.StationPort );\r | |
1138 | CopyMem ( &pLocalAddress->sin6_addr,\r | |
1139 | &pTcp6->ConfigData.AccessPoint.StationAddress.Addr[0],\r | |
1140 | sizeof ( pLocalAddress->sin6_addr ));\r | |
1141 | \r | |
1142 | DBG_EXIT ( );\r | |
1143 | }\r | |
1144 | \r | |
1145 | \r | |
1146 | /**\r | |
1147 | Set the local port address.\r | |
1148 | \r | |
1149 | This routine sets the local port address.\r | |
1150 | \r | |
1151 | This support routine is called by ::EslSocketPortAllocate.\r | |
1152 | \r | |
1153 | @param [in] pPort Address of an ESL_PORT structure\r | |
1154 | @param [in] pSockAddr Address of a sockaddr structure that contains the\r | |
1155 | connection point on the local machine. An IPv6 address\r | |
1156 | of INADDR_ANY specifies that the connection is made to\r | |
1157 | all of the network stacks on the platform. Specifying a\r | |
1158 | specific IPv6 address restricts the connection to the\r | |
1159 | network stack supporting that address. Specifying zero\r | |
1160 | for the port causes the network layer to assign a port\r | |
1161 | number from the dynamic range. Specifying a specific\r | |
1162 | port number causes the network layer to use that port.\r | |
1163 | \r | |
1164 | @param [in] bBindTest TRUE = run bind testing\r | |
1165 | \r | |
1166 | @retval EFI_SUCCESS The operation was successful\r | |
1167 | \r | |
1168 | **/\r | |
1169 | EFI_STATUS\r | |
1170 | EslTcp6LocalAddressSet (\r | |
1171 | IN ESL_PORT * pPort,\r | |
1172 | IN CONST struct sockaddr * pSockAddr,\r | |
1173 | IN BOOLEAN bBindTest\r | |
1174 | )\r | |
1175 | {\r | |
1176 | EFI_TCP6_ACCESS_POINT * pAccessPoint;\r | |
1177 | CONST struct sockaddr_in6 * pIpAddress;\r | |
1178 | EFI_STATUS Status;\r | |
1179 | \r | |
1180 | DBG_ENTER ( );\r | |
1181 | \r | |
1182 | //\r | |
1183 | // Validate the address\r | |
1184 | //\r | |
1185 | pIpAddress = (struct sockaddr_in6 *)pSockAddr;\r | |
1186 | //\r | |
1187 | // TODO: Fix the following check\r | |
1188 | //\r | |
1189 | /*\r | |
1190 | if ( INADDR_BROADCAST == pIpAddress->sin6_addr.s_addr ) {\r | |
1191 | //\r | |
1192 | // The local address must not be the broadcast address\r | |
1193 | //\r | |
1194 | Status = EFI_INVALID_PARAMETER;\r | |
1195 | pPort->pSocket->errno = EADDRNOTAVAIL;\r | |
1196 | }\r | |
1197 | else {\r | |
1198 | */\r | |
1199 | {\r | |
1200 | //\r | |
1201 | // Set the local address\r | |
1202 | //\r | |
1203 | pAccessPoint = &pPort->Context.Tcp6.ConfigData.AccessPoint;\r | |
1204 | CopyMem ( &pAccessPoint->StationAddress.Addr[0],\r | |
1205 | &pIpAddress->sin6_addr.__u6_addr.__u6_addr8 [ 0 ],\r | |
1206 | sizeof ( pIpAddress->sin6_addr.__u6_addr.__u6_addr8 [ 0 ]));\r | |
1207 | \r | |
1208 | //\r | |
1209 | // Validate the IP address\r | |
1210 | //\r | |
1211 | pAccessPoint->StationPort = 0;\r | |
1212 | Status = bBindTest ? EslSocketBindTest ( pPort, EADDRNOTAVAIL )\r | |
1213 | : EFI_SUCCESS;\r | |
1214 | if ( !EFI_ERROR ( Status )) {\r | |
1215 | //\r | |
1216 | // Set the port number\r | |
1217 | //\r | |
1218 | pAccessPoint->StationPort = SwapBytes16 ( pIpAddress->sin6_port );\r | |
f74dc4bb | 1219 | pPort->pSocket->bAddressSet = TRUE;\r |
3bdf9aae | 1220 | \r |
1221 | //\r | |
1222 | // Display the local address\r | |
1223 | //\r | |
1224 | DEBUG (( DEBUG_BIND,\r | |
1225 | "0x%08x: Port, Local Tcp6 Address: [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",\r | |
1226 | pPort,\r | |
1227 | pAccessPoint->StationAddress.Addr[0],\r | |
1228 | pAccessPoint->StationAddress.Addr[1],\r | |
1229 | pAccessPoint->StationAddress.Addr[2],\r | |
1230 | pAccessPoint->StationAddress.Addr[3],\r | |
1231 | pAccessPoint->StationAddress.Addr[4],\r | |
1232 | pAccessPoint->StationAddress.Addr[5],\r | |
1233 | pAccessPoint->StationAddress.Addr[6],\r | |
1234 | pAccessPoint->StationAddress.Addr[7],\r | |
1235 | pAccessPoint->StationAddress.Addr[8],\r | |
1236 | pAccessPoint->StationAddress.Addr[9],\r | |
1237 | pAccessPoint->StationAddress.Addr[10],\r | |
1238 | pAccessPoint->StationAddress.Addr[11],\r | |
1239 | pAccessPoint->StationAddress.Addr[12],\r | |
1240 | pAccessPoint->StationAddress.Addr[13],\r | |
1241 | pAccessPoint->StationAddress.Addr[14],\r | |
1242 | pAccessPoint->StationAddress.Addr[15],\r | |
1243 | pAccessPoint->StationPort ));\r | |
1244 | }\r | |
1245 | }\r | |
1246 | \r | |
1247 | //\r | |
1248 | // Return the operation status\r | |
1249 | //\r | |
1250 | DBG_EXIT_STATUS ( Status );\r | |
1251 | return Status;\r | |
1252 | }\r | |
1253 | \r | |
1254 | \r | |
1255 | /**\r | |
1256 | Free a receive packet\r | |
1257 | \r | |
1258 | This routine performs the network specific operations necessary\r | |
1259 | to free a receive packet.\r | |
1260 | \r | |
1261 | This routine is called by ::EslSocketPortCloseTxDone to free a\r | |
1262 | receive packet.\r | |
1263 | \r | |
1264 | @param [in] pPacket Address of an ::ESL_PACKET structure.\r | |
1265 | @param [in, out] pRxBytes Address of the count of RX bytes\r | |
1266 | \r | |
1267 | **/\r | |
1268 | VOID\r | |
1269 | EslTcp6PacketFree (\r | |
1270 | IN ESL_PACKET * pPacket,\r | |
1271 | IN OUT size_t * pRxBytes\r | |
1272 | )\r | |
1273 | {\r | |
1274 | DBG_ENTER ( );\r | |
1275 | \r | |
1276 | //\r | |
1277 | // Account for the receive bytes\r | |
1278 | //\r | |
1279 | *pRxBytes -= pPacket->Op.Tcp6Rx.RxData.DataLength;\r | |
1280 | DBG_EXIT ( );\r | |
1281 | }\r | |
1282 | \r | |
1283 | \r | |
1284 | /**\r | |
1285 | Initialize the network specific portions of an ::ESL_PORT structure.\r | |
1286 | \r | |
1287 | This routine initializes the network specific portions of an\r | |
1288 | ::ESL_PORT structure for use by the socket.\r | |
1289 | \r | |
1290 | This support routine is called by ::EslSocketPortAllocate\r | |
1291 | to connect the socket with the underlying network adapter\r | |
1292 | running the TCPv6 protocol.\r | |
1293 | \r | |
1294 | @param [in] pPort Address of an ESL_PORT structure\r | |
1295 | @param [in] DebugFlags Flags for debug messages\r | |
1296 | \r | |
1297 | @retval EFI_SUCCESS - Socket successfully created\r | |
1298 | \r | |
1299 | **/\r | |
1300 | EFI_STATUS\r | |
1301 | EslTcp6PortAllocate (\r | |
1302 | IN ESL_PORT * pPort,\r | |
1303 | IN UINTN DebugFlags\r | |
1304 | )\r | |
1305 | {\r | |
1306 | EFI_TCP6_ACCESS_POINT * pAccessPoint;\r | |
1307 | ESL_SOCKET * pSocket;\r | |
1308 | ESL_TCP6_CONTEXT * pTcp6;\r | |
1309 | EFI_STATUS Status;\r | |
1310 | \r | |
1311 | DBG_ENTER ( );\r | |
1312 | \r | |
1313 | //\r | |
1314 | // Use for/break instead of goto\r | |
1315 | for ( ; ; ) {\r | |
1316 | //\r | |
1317 | // Allocate the close event\r | |
1318 | //\r | |
1319 | pSocket = pPort->pSocket;\r | |
1320 | pTcp6 = &pPort->Context.Tcp6;\r | |
1321 | Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL,\r | |
1322 | TPL_SOCKETS,\r | |
1323 | (EFI_EVENT_NOTIFY)EslSocketPortCloseComplete,\r | |
1324 | pPort,\r | |
1325 | &pTcp6->CloseToken.CompletionToken.Event);\r | |
1326 | if ( EFI_ERROR ( Status )) {\r | |
1327 | DEBUG (( DEBUG_ERROR | DebugFlags,\r | |
1328 | "ERROR - Failed to create the close event, Status: %r\r\n",\r | |
1329 | Status ));\r | |
1330 | pSocket->errno = ENOMEM;\r | |
1331 | break;\r | |
1332 | }\r | |
1333 | DEBUG (( DEBUG_CLOSE | DEBUG_POOL,\r | |
1334 | "0x%08x: Created close event\r\n",\r | |
1335 | pTcp6->CloseToken.CompletionToken.Event ));\r | |
1336 | \r | |
1337 | //\r | |
1338 | // Allocate the connection event\r | |
1339 | //\r | |
1340 | Status = gBS->CreateEvent ( EVT_NOTIFY_SIGNAL,\r | |
1341 | TPL_SOCKETS,\r | |
1342 | (EFI_EVENT_NOTIFY)EslTcp6ConnectComplete,\r | |
1343 | pPort,\r | |
1344 | &pTcp6->ConnectToken.CompletionToken.Event);\r | |
1345 | if ( EFI_ERROR ( Status )) {\r | |
1346 | DEBUG (( DEBUG_ERROR | DebugFlags,\r | |
1347 | "ERROR - Failed to create the connect event, Status: %r\r\n",\r | |
1348 | Status ));\r | |
1349 | pSocket->errno = ENOMEM;\r | |
1350 | break;\r | |
1351 | }\r | |
1352 | DEBUG (( DEBUG_CLOSE | DEBUG_POOL,\r | |
1353 | "0x%08x: Created connect event\r\n",\r | |
1354 | pTcp6->ConnectToken.CompletionToken.Event ));\r | |
1355 | \r | |
1356 | //\r | |
1357 | // Initialize the port\r | |
1358 | //\r | |
1359 | pSocket->TxPacketOffset = OFFSET_OF ( ESL_PACKET, Op.Tcp6Tx.TxData );\r | |
1360 | pSocket->TxTokenEventOffset = OFFSET_OF ( ESL_IO_MGMT, Token.Tcp6Tx.CompletionToken.Event );\r | |
1361 | pSocket->TxTokenOffset = OFFSET_OF ( EFI_TCP6_IO_TOKEN, Packet.TxData );\r | |
1362 | \r | |
1363 | //\r | |
1364 | // Save the cancel, receive and transmit addresses\r | |
1365 | // pPort->pfnRxCancel = NULL; since the UEFI implementation returns EFI_UNSUPPORTED\r | |
1366 | //\r | |
1367 | pPort->pfnConfigure = (PFN_NET_CONFIGURE)pPort->pProtocol.TCPv6->Configure;\r | |
1368 | pPort->pfnRxPoll = (PFN_NET_POLL)pPort->pProtocol.TCPv6->Poll;\r | |
1369 | pPort->pfnRxStart = (PFN_NET_IO_START)pPort->pProtocol.TCPv6->Receive;\r | |
1370 | pPort->pfnTxStart = (PFN_NET_IO_START)pPort->pProtocol.TCPv6->Transmit;\r | |
1371 | \r | |
1372 | //\r | |
1373 | // Set the configuration flags\r | |
1374 | //\r | |
1375 | pAccessPoint = &pPort->Context.Tcp6.ConfigData.AccessPoint;\r | |
1376 | pAccessPoint->ActiveFlag = FALSE;\r | |
1377 | pTcp6->ConfigData.TrafficClass = 0;\r | |
1378 | pTcp6->ConfigData.HopLimit = 255;\r | |
1379 | break;\r | |
1380 | }\r | |
1381 | \r | |
1382 | //\r | |
1383 | // Return the operation status\r | |
1384 | //\r | |
1385 | DBG_EXIT_STATUS ( Status );\r | |
1386 | return Status;\r | |
1387 | }\r | |
1388 | \r | |
1389 | \r | |
1390 | /**\r | |
1391 | Close a Tcp6 port.\r | |
1392 | \r | |
1393 | This routine releases the network specific resources allocated by\r | |
1394 | ::EslTcp6PortAllocate.\r | |
1395 | \r | |
1396 | This routine is called by ::EslSocketPortClose.\r | |
1397 | See the \ref PortCloseStateMachine section.\r | |
0e565888 | 1398 | \r |
3bdf9aae | 1399 | @param [in] pPort Address of an ::ESL_PORT structure.\r |
1400 | \r | |
1401 | @retval EFI_SUCCESS The port is closed\r | |
1402 | @retval other Port close error\r | |
1403 | \r | |
1404 | **/\r | |
1405 | EFI_STATUS\r | |
1406 | EslTcp6PortClose (\r | |
1407 | IN ESL_PORT * pPort\r | |
1408 | )\r | |
1409 | {\r | |
1410 | UINTN DebugFlags;\r | |
1411 | ESL_TCP6_CONTEXT * pTcp6;\r | |
1412 | EFI_STATUS Status;\r | |
0e565888 | 1413 | \r |
3bdf9aae | 1414 | DBG_ENTER ( );\r |
1415 | \r | |
1416 | //\r | |
1417 | // Locate the port in the socket list\r | |
1418 | //\r | |
1419 | Status = EFI_SUCCESS;\r | |
1420 | DebugFlags = pPort->DebugFlags;\r | |
1421 | pTcp6 = &pPort->Context.Tcp6;\r | |
1422 | \r | |
1423 | //\r | |
1424 | // Done with the connect event\r | |
1425 | //\r | |
1426 | if ( NULL != pTcp6->ConnectToken.CompletionToken.Event ) {\r | |
1427 | Status = gBS->CloseEvent ( pTcp6->ConnectToken.CompletionToken.Event );\r | |
1428 | if ( !EFI_ERROR ( Status )) {\r | |
1429 | DEBUG (( DebugFlags | DEBUG_POOL,\r | |
1430 | "0x%08x: Closed connect event\r\n",\r | |
1431 | pTcp6->ConnectToken.CompletionToken.Event ));\r | |
1432 | }\r | |
1433 | else {\r | |
1434 | DEBUG (( DEBUG_ERROR | DebugFlags,\r | |
1435 | "ERROR - Failed to close the connect event, Status: %r\r\n",\r | |
1436 | Status ));\r | |
1437 | ASSERT ( EFI_SUCCESS == Status );\r | |
1438 | }\r | |
1439 | }\r | |
1440 | \r | |
1441 | //\r | |
1442 | // Done with the close event\r | |
1443 | //\r | |
1444 | if ( NULL != pTcp6->CloseToken.CompletionToken.Event ) {\r | |
1445 | Status = gBS->CloseEvent ( pTcp6->CloseToken.CompletionToken.Event );\r | |
1446 | if ( !EFI_ERROR ( Status )) {\r | |
1447 | DEBUG (( DebugFlags | DEBUG_POOL,\r | |
1448 | "0x%08x: Closed close event\r\n",\r | |
1449 | pTcp6->CloseToken.CompletionToken.Event ));\r | |
1450 | }\r | |
1451 | else {\r | |
1452 | DEBUG (( DEBUG_ERROR | DebugFlags,\r | |
1453 | "ERROR - Failed to close the close event, Status: %r\r\n",\r | |
1454 | Status ));\r | |
1455 | ASSERT ( EFI_SUCCESS == Status );\r | |
1456 | }\r | |
1457 | }\r | |
1458 | \r | |
1459 | //\r | |
1460 | // Done with the listen completion event\r | |
1461 | //\r | |
1462 | if ( NULL != pTcp6->ListenToken.CompletionToken.Event ) {\r | |
1463 | Status = gBS->CloseEvent ( pTcp6->ListenToken.CompletionToken.Event );\r | |
1464 | if ( !EFI_ERROR ( Status )) {\r | |
1465 | DEBUG (( DebugFlags | DEBUG_POOL,\r | |
1466 | "0x%08x: Closed listen completion event\r\n",\r | |
1467 | pTcp6->ListenToken.CompletionToken.Event ));\r | |
1468 | }\r | |
1469 | else {\r | |
1470 | DEBUG (( DEBUG_ERROR | DebugFlags,\r | |
1471 | "ERROR - Failed to close the listen completion event, Status: %r\r\n",\r | |
1472 | Status ));\r | |
1473 | ASSERT ( EFI_SUCCESS == Status );\r | |
1474 | }\r | |
1475 | }\r | |
1476 | \r | |
1477 | //\r | |
1478 | // Return the operation status\r | |
1479 | //\r | |
1480 | DBG_EXIT_STATUS ( Status );\r | |
1481 | return Status;\r | |
1482 | }\r | |
1483 | \r | |
1484 | \r | |
1485 | /**\r | |
1486 | Perform the network specific close operation on the port.\r | |
1487 | \r | |
1488 | This routine performs a cancel operations on the TCPv6 port to\r | |
1489 | shutdown the receive operations on the port.\r | |
1490 | \r | |
1491 | This routine is called by the ::EslSocketPortCloseTxDone\r | |
1492 | routine after the port completes all of the transmission.\r | |
1493 | \r | |
1494 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
1495 | \r | |
1496 | @retval EFI_SUCCESS The port is closed, not normally returned\r | |
1497 | @retval EFI_NOT_READY The port is still closing\r | |
1498 | @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r | |
1499 | most likely the routine was called already.\r | |
1500 | \r | |
1501 | **/\r | |
1502 | EFI_STATUS\r | |
1503 | EslTcp6PortCloseOp (\r | |
1504 | IN ESL_PORT * pPort\r | |
1505 | )\r | |
1506 | {\r | |
1507 | ESL_TCP6_CONTEXT * pTcp6;\r | |
1508 | EFI_TCP6_PROTOCOL * pTcp6Protocol;\r | |
1509 | EFI_STATUS Status;\r | |
1510 | \r | |
1511 | DBG_ENTER ( );\r | |
1512 | \r | |
1513 | //\r | |
1514 | // Close the configured port\r | |
1515 | //\r | |
1516 | Status = EFI_SUCCESS;\r | |
1517 | pTcp6 = &pPort->Context.Tcp6;\r | |
1518 | pTcp6Protocol = pPort->pProtocol.TCPv6;\r | |
1519 | pTcp6->CloseToken.AbortOnClose = pPort->bCloseNow;\r | |
1520 | Status = pTcp6Protocol->Close ( pTcp6Protocol,\r | |
1521 | &pTcp6->CloseToken );\r | |
1522 | if ( !EFI_ERROR ( Status )) {\r | |
1523 | DEBUG (( pPort->DebugFlags | DEBUG_CLOSE | DEBUG_INFO,\r | |
1524 | "0x%08x: Port close started\r\n",\r | |
1525 | pPort ));\r | |
1526 | }\r | |
1527 | else {\r | |
1528 | DEBUG (( DEBUG_ERROR | pPort->DebugFlags | DEBUG_CLOSE | DEBUG_INFO,\r | |
1529 | "ERROR - Close failed on port 0x%08x, Status: %r\r\n",\r | |
1530 | pPort,\r | |
1531 | Status ));\r | |
1532 | }\r | |
1533 | \r | |
1534 | //\r | |
1535 | // Return the operation status\r | |
1536 | //\r | |
1537 | DBG_EXIT_STATUS ( Status );\r | |
1538 | return Status;\r | |
1539 | }\r | |
1540 | \r | |
1541 | \r | |
1542 | /**\r | |
1543 | Receive data from a network connection.\r | |
1544 | \r | |
1545 | This routine attempts to return buffered data to the caller. The\r | |
1546 | data is removed from the urgent queue if the message flag MSG_OOB\r | |
1547 | is specified, otherwise data is removed from the normal queue.\r | |
1548 | See the \ref ReceiveEngine section.\r | |
1549 | \r | |
1550 | This routine is called by ::EslSocketReceive to handle the network\r | |
1551 | specific receive operation to support SOCK_STREAM and SOCK_SEQPACKET\r | |
1552 | sockets.\r | |
1553 | \r | |
1554 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
1555 | \r | |
1556 | @param [in] pPacket Address of an ::ESL_PACKET structure.\r | |
0e565888 | 1557 | \r |
3bdf9aae | 1558 | @param [in] pbConsumePacket Address of a BOOLEAN indicating if the packet is to be consumed\r |
0e565888 | 1559 | \r |
3bdf9aae | 1560 | @param [in] BufferLength Length of the the buffer\r |
0e565888 | 1561 | \r |
3bdf9aae | 1562 | @param [in] pBuffer Address of a buffer to receive the data.\r |
0e565888 | 1563 | \r |
3bdf9aae | 1564 | @param [in] pDataLength Number of received data bytes in the buffer.\r |
1565 | \r | |
1566 | @param [out] pAddress Network address to receive the remote system address\r | |
1567 | \r | |
1568 | @param [out] pSkipBytes Address to receive the number of bytes skipped\r | |
1569 | \r | |
1570 | @return Returns the address of the next free byte in the buffer.\r | |
1571 | \r | |
1572 | **/\r | |
1573 | UINT8 *\r | |
1574 | EslTcp6Receive (\r | |
1575 | IN ESL_PORT * pPort,\r | |
1576 | IN ESL_PACKET * pPacket,\r | |
1577 | IN BOOLEAN * pbConsumePacket,\r | |
1578 | IN size_t BufferLength,\r | |
1579 | IN UINT8 * pBuffer,\r | |
1580 | OUT size_t * pDataLength,\r | |
1581 | OUT struct sockaddr * pAddress,\r | |
1582 | OUT size_t * pSkipBytes\r | |
1583 | )\r | |
1584 | {\r | |
1585 | size_t DataLength;\r | |
1586 | struct sockaddr_in6 * pRemoteAddress;\r | |
1587 | ESL_TCP6_CONTEXT * pTcp6;\r | |
1588 | \r | |
1589 | DBG_ENTER ( );\r | |
1590 | \r | |
1591 | //\r | |
1592 | // Return the remote system address if requested\r | |
1593 | //\r | |
1594 | if ( NULL != pAddress ) {\r | |
1595 | //\r | |
1596 | // Build the remote address\r | |
1597 | //\r | |
1598 | pTcp6 = &pPort->Context.Tcp6;\r | |
1599 | DEBUG (( DEBUG_RX,\r | |
1600 | "Getting packet remote address: [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",\r | |
1601 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],\r | |
1602 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[1],\r | |
1603 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[2],\r | |
1604 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[3],\r | |
1605 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[4],\r | |
1606 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[5],\r | |
1607 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[6],\r | |
1608 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[7],\r | |
1609 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[8],\r | |
1610 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[9],\r | |
1611 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[10],\r | |
1612 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[11],\r | |
1613 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[12],\r | |
1614 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[13],\r | |
1615 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[14],\r | |
1616 | pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[15],\r | |
1617 | pTcp6->ConfigData.AccessPoint.RemotePort ));\r | |
1618 | pRemoteAddress = (struct sockaddr_in6 *)pAddress;\r | |
1619 | CopyMem ( &pRemoteAddress->sin6_addr,\r | |
1620 | &pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],\r | |
1621 | sizeof ( pRemoteAddress->sin6_addr ));\r | |
1622 | pRemoteAddress->sin6_port = SwapBytes16 ( pTcp6->ConfigData.AccessPoint.RemotePort );\r | |
1623 | }\r | |
1624 | \r | |
1625 | //\r | |
1626 | // Determine the amount of received data\r | |
1627 | //\r | |
1628 | DataLength = pPacket->ValidBytes;\r | |
1629 | if ( BufferLength < DataLength ) {\r | |
1630 | DataLength = BufferLength;\r | |
1631 | }\r | |
1632 | \r | |
1633 | //\r | |
1634 | // Move the data into the buffer\r | |
1635 | //\r | |
1636 | DEBUG (( DEBUG_RX,\r | |
1637 | "0x%08x: Port copy packet 0x%08x data into 0x%08x, 0x%08x bytes\r\n",\r | |
1638 | pPort,\r | |
1639 | pPacket,\r | |
1640 | pBuffer,\r | |
1641 | DataLength ));\r | |
1642 | CopyMem ( pBuffer, pPacket->pBuffer, DataLength );\r | |
1643 | \r | |
fcb6f89d | 1644 | //\r |
1645 | // Set the next buffer address\r | |
1646 | //\r | |
1647 | pBuffer += DataLength;\r | |
1648 | \r | |
3bdf9aae | 1649 | //\r |
1650 | // Determine if the data is being read\r | |
1651 | //\r | |
1652 | if ( *pbConsumePacket ) {\r | |
1653 | //\r | |
1654 | // Account for the bytes consumed\r | |
1655 | //\r | |
1656 | pPacket->pBuffer += DataLength;\r | |
1657 | pPacket->ValidBytes -= DataLength;\r | |
1658 | DEBUG (( DEBUG_RX,\r | |
1659 | "0x%08x: Port account for 0x%08x bytes\r\n",\r | |
1660 | pPort,\r | |
1661 | DataLength ));\r | |
1662 | \r | |
1663 | //\r | |
1664 | // Determine if the entire packet was consumed\r | |
1665 | //\r | |
1666 | if (( 0 == pPacket->ValidBytes )\r | |
1667 | || ( SOCK_STREAM != pPort->pSocket->Type )) {\r | |
1668 | //\r | |
1669 | // All done with this packet\r | |
1670 | // Account for any discarded data\r | |
1671 | //\r | |
1672 | *pSkipBytes = pPacket->ValidBytes;\r | |
1673 | }\r | |
1674 | else\r | |
1675 | {\r | |
1676 | //\r | |
1677 | // More data to consume later\r | |
1678 | //\r | |
1679 | *pbConsumePacket = FALSE;\r | |
1680 | }\r | |
1681 | }\r | |
1682 | \r | |
1683 | //\r | |
1684 | // Return the data length and the buffer address\r | |
1685 | //\r | |
1686 | *pDataLength = DataLength;\r | |
1687 | DBG_EXIT_HEX ( pBuffer );\r | |
1688 | return pBuffer;\r | |
1689 | }\r | |
1690 | \r | |
1691 | \r | |
1692 | /**\r | |
1693 | Get the remote socket address.\r | |
1694 | \r | |
1695 | This routine returns the address of the remote connection point\r | |
1696 | associated with the SOCK_STREAM or SOCK_SEQPACKET socket.\r | |
1697 | \r | |
1698 | This routine is called by ::EslSocketGetPeerAddress to detemine\r | |
1699 | the TCPv6 address and por number associated with the network adapter.\r | |
1700 | \r | |
1701 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
1702 | \r | |
1703 | @param [out] pAddress Network address to receive the remote system address\r | |
1704 | \r | |
1705 | **/\r | |
1706 | VOID\r | |
1707 | EslTcp6RemoteAddressGet (\r | |
1708 | IN ESL_PORT * pPort,\r | |
1709 | OUT struct sockaddr * pAddress\r | |
1710 | )\r | |
1711 | {\r | |
1712 | struct sockaddr_in6 * pRemoteAddress;\r | |
1713 | ESL_TCP6_CONTEXT * pTcp6;\r | |
1714 | \r | |
1715 | DBG_ENTER ( );\r | |
1716 | \r | |
1717 | //\r | |
1718 | // Return the remote address\r | |
1719 | //\r | |
1720 | pTcp6 = &pPort->Context.Tcp6;\r | |
1721 | pRemoteAddress = (struct sockaddr_in6 *)pAddress;\r | |
1722 | pRemoteAddress->sin6_family = AF_INET6;\r | |
1723 | pRemoteAddress->sin6_port = SwapBytes16 ( pTcp6->ConfigData.AccessPoint.RemotePort );\r | |
1724 | CopyMem ( &pRemoteAddress->sin6_addr,\r | |
1725 | &pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr[0],\r | |
1726 | sizeof ( pRemoteAddress->sin6_addr ));\r | |
1727 | \r | |
1728 | DBG_EXIT ( );\r | |
1729 | }\r | |
1730 | \r | |
1731 | \r | |
1732 | /**\r | |
1733 | Set the remote address\r | |
1734 | \r | |
1735 | This routine sets the remote address in the port.\r | |
1736 | \r | |
1737 | This routine is called by ::EslSocketConnect to specify the\r | |
1738 | remote network address.\r | |
1739 | \r | |
1740 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
1741 | \r | |
1742 | @param [in] pSockAddr Network address of the remote system.\r | |
1743 | \r | |
1744 | @param [in] SockAddrLength Length in bytes of the network address.\r | |
1745 | \r | |
1746 | @retval EFI_SUCCESS The operation was successful\r | |
1747 | \r | |
1748 | **/\r | |
1749 | EFI_STATUS\r | |
1750 | EslTcp6RemoteAddressSet (\r | |
1751 | IN ESL_PORT * pPort,\r | |
1752 | IN CONST struct sockaddr * pSockAddr,\r | |
1753 | IN socklen_t SockAddrLength\r | |
1754 | )\r | |
1755 | {\r | |
1756 | CONST struct sockaddr_in6 * pRemoteAddress;\r | |
1757 | ESL_TCP6_CONTEXT * pTcp6;\r | |
1758 | EFI_STATUS Status;\r | |
1759 | \r | |
1760 | DBG_ENTER ( );\r | |
1761 | \r | |
1762 | //\r | |
1763 | // Set the remote address\r | |
1764 | //\r | |
1765 | pTcp6 = &pPort->Context.Tcp6;\r | |
1766 | pRemoteAddress = (struct sockaddr_in6 *)pSockAddr;\r | |
1767 | CopyMem ( &pTcp6->ConfigData.AccessPoint.RemoteAddress.Addr [ 0 ],\r | |
1768 | &pRemoteAddress->sin6_addr.__u6_addr.__u6_addr8 [ 0 ],\r | |
1769 | sizeof ( pRemoteAddress->sin6_addr.__u6_addr.__u6_addr8 ));\r | |
1770 | pTcp6->ConfigData.AccessPoint.RemotePort = SwapBytes16 ( pRemoteAddress->sin6_port );\r | |
1771 | Status = EFI_SUCCESS;\r | |
1772 | \r | |
1773 | //\r | |
1774 | // TODO: Fix the following check\r | |
1775 | //\r | |
1776 | /*\r | |
1777 | if ( INADDR_BROADCAST == pRemoteAddress->sin6_addr.s_addr ) {\r | |
1778 | DEBUG (( DEBUG_CONNECT,\r | |
1779 | "ERROR - Invalid remote address\r\n" ));\r | |
1780 | Status = EFI_INVALID_PARAMETER;\r | |
1781 | pPort->pSocket->errno = EAFNOSUPPORT;\r | |
1782 | }\r | |
1783 | */\r | |
1784 | \r | |
1785 | //\r | |
1786 | // Return the operation status\r | |
1787 | //\r | |
1788 | DBG_EXIT_STATUS ( Status );\r | |
1789 | return Status;\r | |
1790 | }\r | |
1791 | \r | |
1792 | \r | |
1793 | /**\r | |
1794 | Process the receive completion\r | |
1795 | \r | |
1796 | This routine queues the data in FIFO order in either the urgent\r | |
1797 | or normal data queues depending upon the type of data received.\r | |
1798 | See the \ref ReceiveEngine section.\r | |
1799 | \r | |
1800 | This routine is called by the TCPv6 driver when some data is\r | |
1801 | received.\r | |
1802 | \r | |
1803 | Buffer the data that was just received.\r | |
1804 | \r | |
1805 | @param [in] Event The receive completion event\r | |
1806 | \r | |
1807 | @param [in] pIo Address of an ::ESL_IO_MGMT structure\r | |
1808 | \r | |
1809 | **/\r | |
1810 | VOID\r | |
1811 | EslTcp6RxComplete (\r | |
1812 | IN EFI_EVENT Event,\r | |
1813 | IN ESL_IO_MGMT * pIo\r | |
1814 | )\r | |
1815 | {\r | |
1816 | BOOLEAN bUrgent;\r | |
1817 | size_t LengthInBytes;\r | |
1818 | ESL_PACKET * pPacket;\r | |
1819 | EFI_STATUS Status;\r | |
1820 | \r | |
1821 | DBG_ENTER ( );\r | |
1822 | \r | |
1823 | //\r | |
1824 | // Get the operation status.\r | |
1825 | //\r | |
1826 | Status = pIo->Token.Tcp6Rx.CompletionToken.Status;\r | |
1827 | \r | |
1828 | //\r | |
1829 | // +--------------------+ +---------------------------+\r | |
1830 | // | ESL_IO_MGMT | | ESL_PACKET |\r | |
1831 | // | | | |\r | |
1832 | // | +---------------+ +-----------------------+ |\r | |
1833 | // | | Token | | EFI_Tcp6_RECEIVE_DATA | |\r | |
1834 | // | | RxData --> | | |\r | |
1835 | // | | | +-----------------------+---+\r | |
1836 | // | | Event | | Data Buffer |\r | |
1837 | // +----+---------------+ | |\r | |
1838 | // | |\r | |
1839 | // +---------------------------+\r | |
1840 | //\r | |
1841 | //\r | |
1842 | // Duplicate the buffer address and length for use by the\r | |
1843 | // buffer handling code in EslTcp6Receive. These fields are\r | |
1844 | // used when a partial read is done of the data from the\r | |
1845 | // packet.\r | |
1846 | //\r | |
1847 | pPacket = pIo->pPacket;\r | |
1848 | pPacket->pBuffer = pPacket->Op.Tcp6Rx.RxData.FragmentTable[0].FragmentBuffer;\r | |
1849 | LengthInBytes = pPacket->Op.Tcp6Rx.RxData.DataLength;\r | |
1850 | pPacket->ValidBytes = LengthInBytes;\r | |
1851 | \r | |
1852 | //\r | |
1853 | // Get the data type so that it may be linked to the\r | |
1854 | // correct receive buffer list on the ESL_SOCKET structure\r | |
1855 | //\r | |
1856 | bUrgent = pPacket->Op.Tcp6Rx.RxData.UrgentFlag;\r | |
1857 | \r | |
1858 | //\r | |
1859 | // Complete this request\r | |
1860 | //\r | |
1861 | EslSocketRxComplete ( pIo, Status, LengthInBytes, bUrgent );\r | |
1862 | DBG_EXIT ( );\r | |
1863 | }\r | |
1864 | \r | |
1865 | \r | |
1866 | /**\r | |
1867 | Start a receive operation\r | |
1868 | \r | |
1869 | This routine posts a receive buffer to the TCPv6 driver.\r | |
1870 | See the \ref ReceiveEngine section.\r | |
1871 | \r | |
1872 | This support routine is called by EslSocketRxStart.\r | |
1873 | \r | |
1874 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
1875 | @param [in] pIo Address of an ::ESL_IO_MGMT structure.\r | |
1876 | \r | |
1877 | **/\r | |
1878 | VOID\r | |
1879 | EslTcp6RxStart (\r | |
1880 | IN ESL_PORT * pPort,\r | |
1881 | IN ESL_IO_MGMT * pIo\r | |
1882 | )\r | |
1883 | {\r | |
1884 | ESL_PACKET * pPacket;\r | |
1885 | \r | |
1886 | DBG_ENTER ( );\r | |
1887 | \r | |
1888 | //\r | |
1889 | // Initialize the buffer for receive\r | |
1890 | //\r | |
1891 | pPacket = pIo->pPacket;\r | |
1892 | pIo->Token.Tcp6Rx.Packet.RxData = &pPacket->Op.Tcp6Rx.RxData;\r | |
1893 | pPacket->Op.Tcp6Rx.RxData.DataLength = sizeof ( pPacket->Op.Tcp6Rx.Buffer );\r | |
1894 | pPacket->Op.Tcp6Rx.RxData.FragmentCount = 1;\r | |
1895 | pPacket->Op.Tcp6Rx.RxData.FragmentTable[0].FragmentLength = pPacket->Op.Tcp6Rx.RxData.DataLength;\r | |
1896 | pPacket->Op.Tcp6Rx.RxData.FragmentTable[0].FragmentBuffer = &pPacket->Op.Tcp6Rx.Buffer[0];\r | |
1897 | \r | |
1898 | DBG_EXIT ( );\r | |
1899 | }\r | |
1900 | \r | |
1901 | \r | |
1902 | /**\r | |
1903 | Determine if the socket is configured.\r | |
1904 | \r | |
1905 | This routine uses the flag ESL_SOCKET::bConfigured to determine\r | |
1906 | if the network layer's configuration routine has been called.\r | |
1907 | \r | |
1908 | This routine is called by EslSocketIsConfigured to verify\r | |
1909 | that the socket has been configured.\r | |
1910 | \r | |
1911 | @param [in] pSocket Address of an ::ESL_SOCKET structure.\r | |
1912 | \r | |
1913 | @retval EFI_SUCCESS - The port is connected\r | |
1914 | @retval EFI_NOT_STARTED - The port is not connected\r | |
1915 | \r | |
1916 | **/\r | |
1917 | EFI_STATUS\r | |
1918 | EslTcp6SocketIsConfigured (\r | |
1919 | IN ESL_SOCKET * pSocket\r | |
1920 | )\r | |
1921 | {\r | |
1922 | EFI_STATUS Status;\r | |
1923 | \r | |
1924 | DBG_ENTER ( );\r | |
1925 | \r | |
1926 | //\r | |
1927 | // Determine the socket configuration status\r | |
1928 | //\r | |
1929 | Status = pSocket->bConfigured ? EFI_SUCCESS : EFI_NOT_STARTED;\r | |
1930 | \r | |
1931 | //\r | |
1932 | // Return the port connected state.\r | |
1933 | //\r | |
1934 | DBG_EXIT_STATUS ( Status );\r | |
1935 | return Status;\r | |
1936 | }\r | |
1937 | \r | |
1938 | \r | |
1939 | /**\r | |
1940 | Buffer data for transmission over a network connection.\r | |
1941 | \r | |
1942 | This routine buffers data for the transmit engine in one of two\r | |
1943 | queues, one for urgent (out-of-band) data and the other for normal\r | |
1944 | data. The urgent data is provided to TCP as soon as it is available,\r | |
1945 | allowing the TCP layer to schedule transmission of the urgent data\r | |
1946 | between packets of normal data.\r | |
1947 | \r | |
1948 | This routine is called by ::EslSocketTransmit to buffer\r | |
1949 | data for transmission. When the \ref TransmitEngine has resources,\r | |
1950 | this routine will start the transmission of the next buffer on\r | |
1951 | the network connection.\r | |
1952 | \r | |
1953 | Transmission errors are returned during the next transmission or\r | |
1954 | during the close operation. Only buffering errors are returned\r | |
1955 | during the current transmission attempt.\r | |
1956 | \r | |
1957 | @param [in] pSocket Address of an ::ESL_SOCKET structure\r | |
0e565888 | 1958 | \r |
3bdf9aae | 1959 | @param [in] Flags Message control flags\r |
0e565888 | 1960 | \r |
3bdf9aae | 1961 | @param [in] BufferLength Length of the the buffer\r |
0e565888 | 1962 | \r |
3bdf9aae | 1963 | @param [in] pBuffer Address of a buffer to receive the data.\r |
0e565888 | 1964 | \r |
3bdf9aae | 1965 | @param [in] pDataLength Number of received data bytes in the buffer.\r |
1966 | \r | |
1967 | @param [in] pAddress Network address of the remote system address\r | |
1968 | \r | |
1969 | @param [in] AddressLength Length of the remote network address structure\r | |
1970 | \r | |
1971 | @retval EFI_SUCCESS - Socket data successfully buffered\r | |
1972 | \r | |
1973 | **/\r | |
1974 | EFI_STATUS\r | |
1975 | EslTcp6TxBuffer (\r | |
1976 | IN ESL_SOCKET * pSocket,\r | |
1977 | IN int Flags,\r | |
1978 | IN size_t BufferLength,\r | |
1979 | IN CONST UINT8 * pBuffer,\r | |
1980 | OUT size_t * pDataLength,\r | |
1981 | IN const struct sockaddr * pAddress,\r | |
1982 | IN socklen_t AddressLength\r | |
1983 | )\r | |
1984 | {\r | |
1985 | BOOLEAN bUrgent;\r | |
1986 | BOOLEAN bUrgentQueue;\r | |
1987 | ESL_PACKET * pPacket;\r | |
1988 | ESL_IO_MGMT ** ppActive;\r | |
1989 | ESL_IO_MGMT ** ppFree;\r | |
1990 | ESL_PORT * pPort;\r | |
1991 | ESL_PACKET ** ppQueueHead;\r | |
1992 | ESL_PACKET ** ppQueueTail;\r | |
1993 | ESL_PACKET * pPreviousPacket;\r | |
3bdf9aae | 1994 | size_t * pTxBytes;\r |
1995 | EFI_TCP6_TRANSMIT_DATA * pTxData;\r | |
1996 | EFI_STATUS Status;\r | |
1997 | EFI_TPL TplPrevious;\r | |
1998 | \r | |
1999 | DBG_ENTER ( );\r | |
2000 | \r | |
2001 | //\r | |
2002 | // Assume failure\r | |
2003 | //\r | |
2004 | Status = EFI_UNSUPPORTED;\r | |
2005 | pSocket->errno = ENOTCONN;\r | |
2006 | *pDataLength = 0;\r | |
2007 | \r | |
2008 | //\r | |
2009 | // Verify that the socket is connected\r | |
2010 | //\r | |
2011 | if ( SOCKET_STATE_CONNECTED == pSocket->State ) {\r | |
2012 | //\r | |
2013 | // Locate the port\r | |
2014 | //\r | |
2015 | pPort = pSocket->pPortList;\r | |
2016 | if ( NULL != pPort ) {\r | |
2017 | //\r | |
2018 | // Determine the queue head\r | |
2019 | //\r | |
3bdf9aae | 2020 | bUrgent = (BOOLEAN)( 0 != ( Flags & MSG_OOB ));\r |
2021 | bUrgentQueue = bUrgent\r | |
2022 | && ( !pSocket->bOobInLine )\r | |
2023 | && pSocket->pApi->bOobSupported;\r | |
2024 | if ( bUrgentQueue ) {\r | |
2025 | ppQueueHead = &pSocket->pTxOobPacketListHead;\r | |
2026 | ppQueueTail = &pSocket->pTxOobPacketListTail;\r | |
2027 | ppActive = &pPort->pTxOobActive;\r | |
2028 | ppFree = &pPort->pTxOobFree;\r | |
2029 | pTxBytes = &pSocket->TxOobBytes;\r | |
2030 | }\r | |
2031 | else {\r | |
2032 | ppQueueHead = &pSocket->pTxPacketListHead;\r | |
2033 | ppQueueTail = &pSocket->pTxPacketListTail;\r | |
2034 | ppActive = &pPort->pTxActive;\r | |
2035 | ppFree = &pPort->pTxFree;\r | |
2036 | pTxBytes = &pSocket->TxBytes;\r | |
2037 | }\r | |
2038 | \r | |
2039 | //\r | |
2040 | // Verify that there is enough room to buffer another\r | |
2041 | // transmit operation\r | |
2042 | //\r | |
2043 | if ( pSocket->MaxTxBuf > *pTxBytes ) {\r | |
2044 | if ( pPort->bTxFlowControl ) {\r | |
2045 | DEBUG (( DEBUG_TX,\r | |
2046 | "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\r\n0x%08x: pPort, TX flow control released, Max bytes: %d > %d bufferred bytes\r\n",\r | |
2047 | pPort,\r | |
2048 | pSocket->MaxTxBuf,\r | |
2049 | *pTxBytes ));\r | |
2050 | pPort->bTxFlowControl = FALSE;\r | |
2051 | }\r | |
2052 | \r | |
2053 | //\r | |
2054 | // Attempt to allocate the packet\r | |
2055 | //\r | |
2056 | Status = EslSocketPacketAllocate ( &pPacket,\r | |
2057 | sizeof ( pPacket->Op.Tcp6Tx )\r | |
2058 | - sizeof ( pPacket->Op.Tcp6Tx.Buffer )\r | |
2059 | + BufferLength,\r | |
2060 | 0,\r | |
2061 | DEBUG_TX );\r | |
2062 | if ( !EFI_ERROR ( Status )) {\r | |
2063 | //\r | |
2064 | // Initialize the transmit operation\r | |
2065 | //\r | |
2066 | pTxData = &pPacket->Op.Tcp6Tx.TxData;\r | |
2067 | pTxData->Push = TRUE || bUrgent;\r | |
2068 | pTxData->Urgent = bUrgent;\r | |
2069 | pTxData->DataLength = (UINT32) BufferLength;\r | |
2070 | pTxData->FragmentCount = 1;\r | |
2071 | pTxData->FragmentTable[0].FragmentLength = (UINT32) BufferLength;\r | |
2072 | pTxData->FragmentTable[0].FragmentBuffer = &pPacket->Op.Tcp6Tx.Buffer[0];\r | |
2073 | \r | |
2074 | //\r | |
2075 | // Copy the data into the buffer\r | |
2076 | //\r | |
2077 | CopyMem ( &pPacket->Op.Tcp6Tx.Buffer[0],\r | |
2078 | pBuffer,\r | |
2079 | BufferLength );\r | |
2080 | \r | |
2081 | //\r | |
2082 | // Synchronize with the socket layer\r | |
2083 | //\r | |
2084 | RAISE_TPL ( TplPrevious, TPL_SOCKETS );\r | |
2085 | \r | |
2086 | //\r | |
2087 | // Stop transmission after an error\r | |
2088 | //\r | |
2089 | if ( !EFI_ERROR ( pSocket->TxError )) {\r | |
2090 | //\r | |
2091 | // Display the request\r | |
2092 | //\r | |
2093 | DEBUG (( DEBUG_TX,\r | |
2094 | "Send %d %s bytes from 0x%08x\r\n",\r | |
2095 | BufferLength,\r | |
2096 | bUrgent ? L"urgent" : L"normal",\r | |
2097 | pBuffer ));\r | |
2098 | \r | |
2099 | //\r | |
2100 | // Queue the data for transmission\r | |
2101 | //\r | |
2102 | pPacket->pNext = NULL;\r | |
2103 | pPreviousPacket = *ppQueueTail;\r | |
2104 | if ( NULL == pPreviousPacket ) {\r | |
2105 | *ppQueueHead = pPacket;\r | |
2106 | }\r | |
2107 | else {\r | |
2108 | pPreviousPacket->pNext = pPacket;\r | |
2109 | }\r | |
2110 | *ppQueueTail = pPacket;\r | |
2111 | DEBUG (( DEBUG_TX,\r | |
2112 | "0x%08x: Packet on %s transmit list\r\n",\r | |
2113 | pPacket,\r | |
2114 | bUrgentQueue ? L"urgent" : L"normal" ));\r | |
2115 | \r | |
2116 | //\r | |
2117 | // Account for the buffered data\r | |
2118 | //\r | |
2119 | *pTxBytes += BufferLength;\r | |
2120 | *pDataLength = BufferLength;\r | |
2121 | \r | |
2122 | //\r | |
2123 | // Start the transmit engine if it is idle\r | |
2124 | //\r | |
2125 | if ( NULL != *ppFree ) {\r | |
2126 | EslSocketTxStart ( pPort,\r | |
2127 | ppQueueHead,\r | |
2128 | ppQueueTail,\r | |
2129 | ppActive,\r | |
2130 | ppFree );\r | |
2131 | }\r | |
2132 | }\r | |
2133 | else {\r | |
2134 | //\r | |
2135 | // Previous transmit error\r | |
2136 | // Stop transmission\r | |
2137 | //\r | |
2138 | Status = pSocket->TxError;\r | |
2139 | pSocket->errno = EIO;\r | |
2140 | \r | |
2141 | //\r | |
2142 | // Free the packet\r | |
2143 | //\r | |
2144 | EslSocketPacketFree ( pPacket, DEBUG_TX );\r | |
2145 | }\r | |
2146 | \r | |
2147 | //\r | |
2148 | // Release the socket layer synchronization\r | |
2149 | //\r | |
2150 | RESTORE_TPL ( TplPrevious );\r | |
2151 | }\r | |
2152 | else {\r | |
2153 | //\r | |
2154 | // Packet allocation failed\r | |
2155 | //\r | |
2156 | pSocket->errno = ENOMEM;\r | |
2157 | }\r | |
2158 | }\r | |
2159 | else {\r | |
2160 | if ( !pPort->bTxFlowControl ) {\r | |
2161 | DEBUG (( DEBUG_TX,\r | |
2162 | "0x%08x: pPort, TX flow control applied, Max bytes %d <= %d bufferred bytes\r\nTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\r\n",\r | |
2163 | pPort,\r | |
2164 | pSocket->MaxTxBuf,\r | |
2165 | *pTxBytes ));\r | |
2166 | pPort->bTxFlowControl = TRUE;\r | |
2167 | }\r | |
2168 | //\r | |
2169 | // Not enough buffer space available\r | |
2170 | //\r | |
2171 | pSocket->errno = EAGAIN;\r | |
2172 | Status = EFI_NOT_READY;\r | |
2173 | }\r | |
2174 | }\r | |
2175 | }\r | |
2176 | \r | |
2177 | //\r | |
2178 | // Return the operation status\r | |
2179 | //\r | |
2180 | DBG_EXIT_STATUS ( Status );\r | |
2181 | return Status;\r | |
2182 | }\r | |
2183 | \r | |
2184 | \r | |
2185 | /**\r | |
2186 | Process the normal data transmit completion\r | |
2187 | \r | |
2188 | This routine use ::EslSocketTxComplete to perform the transmit\r | |
2189 | completion processing for normal data.\r | |
2190 | \r | |
2191 | This routine is called by the TCPv6 network layer when a\r | |
2192 | normal data transmit request completes.\r | |
2193 | \r | |
2194 | @param [in] Event The normal transmit completion event\r | |
2195 | \r | |
2196 | @param [in] pIo The ESL_IO_MGMT structure address\r | |
2197 | \r | |
2198 | **/\r | |
2199 | VOID\r | |
2200 | EslTcp6TxComplete (\r | |
2201 | IN EFI_EVENT Event,\r | |
2202 | IN ESL_IO_MGMT * pIo\r | |
2203 | )\r | |
2204 | {\r | |
2205 | UINT32 LengthInBytes;\r | |
2206 | ESL_PACKET * pPacket;\r | |
2207 | ESL_PORT * pPort;\r | |
2208 | ESL_SOCKET * pSocket;\r | |
2209 | EFI_STATUS Status;\r | |
0e565888 | 2210 | \r |
3bdf9aae | 2211 | DBG_ENTER ( );\r |
2212 | \r | |
2213 | //\r | |
2214 | // Locate the active transmit packet\r | |
2215 | //\r | |
2216 | pPacket = pIo->pPacket;\r | |
2217 | pPort = pIo->pPort;\r | |
2218 | pSocket = pPort->pSocket;\r | |
2219 | \r | |
2220 | //\r | |
2221 | // Get the transmit length and status\r | |
2222 | //\r | |
2223 | LengthInBytes = pPacket->Op.Tcp6Tx.TxData.DataLength;\r | |
2224 | pSocket->TxBytes -= LengthInBytes;\r | |
2225 | Status = pIo->Token.Tcp6Tx.CompletionToken.Status;\r | |
2226 | \r | |
2227 | //\r | |
2228 | // Complete the transmit operation\r | |
2229 | //\r | |
2230 | EslSocketTxComplete ( pIo,\r | |
2231 | LengthInBytes,\r | |
2232 | Status,\r | |
2233 | "Normal ",\r | |
2234 | &pSocket->pTxPacketListHead,\r | |
2235 | &pSocket->pTxPacketListTail,\r | |
2236 | &pPort->pTxActive,\r | |
2237 | &pPort->pTxFree );\r | |
2238 | DBG_EXIT ( );\r | |
2239 | }\r | |
2240 | \r | |
2241 | \r | |
2242 | /**\r | |
2243 | Process the urgent data transmit completion\r | |
2244 | \r | |
2245 | This routine use ::EslSocketTxComplete to perform the transmit\r | |
2246 | completion processing for urgent data.\r | |
2247 | \r | |
2248 | This routine is called by the TCPv6 network layer when a\r | |
2249 | urgent data transmit request completes.\r | |
2250 | \r | |
2251 | @param [in] Event The urgent transmit completion event\r | |
2252 | \r | |
2253 | @param [in] pIo The ESL_IO_MGMT structure address\r | |
2254 | \r | |
2255 | **/\r | |
2256 | VOID\r | |
2257 | EslTcp6TxOobComplete (\r | |
2258 | IN EFI_EVENT Event,\r | |
2259 | IN ESL_IO_MGMT * pIo\r | |
2260 | )\r | |
2261 | {\r | |
2262 | UINT32 LengthInBytes;\r | |
2263 | ESL_PACKET * pPacket;\r | |
2264 | ESL_PORT * pPort;\r | |
2265 | ESL_SOCKET * pSocket;\r | |
2266 | EFI_STATUS Status;\r | |
2267 | \r | |
2268 | DBG_ENTER ( );\r | |
2269 | \r | |
2270 | //\r | |
2271 | // Locate the active transmit packet\r | |
2272 | //\r | |
2273 | pPacket = pIo->pPacket;\r | |
2274 | pPort = pIo->pPort;\r | |
2275 | pSocket = pPort->pSocket;\r | |
2276 | \r | |
2277 | //\r | |
2278 | // Get the transmit length and status\r | |
2279 | //\r | |
2280 | LengthInBytes = pPacket->Op.Tcp6Tx.TxData.DataLength;\r | |
2281 | pSocket->TxOobBytes -= LengthInBytes;\r | |
2282 | Status = pIo->Token.Tcp6Tx.CompletionToken.Status;\r | |
2283 | \r | |
2284 | //\r | |
2285 | // Complete the transmit operation\r | |
2286 | //\r | |
2287 | EslSocketTxComplete ( pIo,\r | |
2288 | LengthInBytes,\r | |
2289 | Status,\r | |
2290 | "Urgent ",\r | |
2291 | &pSocket->pTxOobPacketListHead,\r | |
2292 | &pSocket->pTxOobPacketListTail,\r | |
2293 | &pPort->pTxOobActive,\r | |
2294 | &pPort->pTxOobFree );\r | |
2295 | DBG_EXIT ( );\r | |
2296 | }\r | |
2297 | \r | |
2298 | \r | |
2dc09dd5 LL |
2299 | /**\r |
2300 | Verify the adapter's IP address\r | |
2301 | \r | |
2302 | This support routine is called by EslSocketBindTest.\r | |
2303 | \r | |
2304 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
2305 | @param [in] pConfigData Address of the configuration data\r | |
2306 | \r | |
2307 | @retval EFI_SUCCESS - The IP address is valid\r | |
2308 | @retval EFI_NOT_STARTED - The IP address is invalid\r | |
2309 | \r | |
2310 | **/\r | |
2311 | EFI_STATUS\r | |
2312 | EslTcp6VerifyLocalIpAddress (\r | |
2313 | IN ESL_PORT * pPort,\r | |
2314 | IN EFI_TCP6_CONFIG_DATA * pConfigData\r | |
2315 | )\r | |
2316 | {\r | |
2317 | UINTN AddressCount;\r | |
2318 | EFI_IP6_ADDRESS_INFO * pAddressInfo;\r | |
2319 | UINTN DataSize;\r | |
2320 | EFI_TCP6_ACCESS_POINT * pAccess;\r | |
2321 | EFI_IP6_CONFIG_INTERFACE_INFO * pIpConfigData;\r | |
2322 | EFI_IP6_CONFIG_PROTOCOL * pIpConfigProtocol;\r | |
2323 | ESL_SERVICE * pService;\r | |
2324 | EFI_STATUS Status;\r | |
2325 | \r | |
2326 | DBG_ENTER ( );\r | |
2327 | \r | |
2328 | //\r | |
2329 | // Use break instead of goto\r | |
2330 | //\r | |
2331 | pIpConfigData = NULL;\r | |
2332 | for ( ; ; ) {\r | |
2333 | //\r | |
2334 | // Determine if the IP address is specified\r | |
2335 | //\r | |
2336 | pAccess = &pConfigData->AccessPoint;\r | |
2337 | DEBUG (( DEBUG_BIND,\r | |
2338 | "Requested IP address: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\r\n",\r | |
2339 | pAccess->StationAddress.Addr[0],\r | |
2340 | pAccess->StationAddress.Addr[1],\r | |
2341 | pAccess->StationAddress.Addr[2],\r | |
2342 | pAccess->StationAddress.Addr[3],\r | |
2343 | pAccess->StationAddress.Addr[4],\r | |
2344 | pAccess->StationAddress.Addr[5],\r | |
2345 | pAccess->StationAddress.Addr[6],\r | |
2346 | pAccess->StationAddress.Addr[7],\r | |
2347 | pAccess->StationAddress.Addr[8],\r | |
2348 | pAccess->StationAddress.Addr[9],\r | |
2349 | pAccess->StationAddress.Addr[10],\r | |
2350 | pAccess->StationAddress.Addr[11],\r | |
2351 | pAccess->StationAddress.Addr[12],\r | |
2352 | pAccess->StationAddress.Addr[13],\r | |
2353 | pAccess->StationAddress.Addr[14],\r | |
2354 | pAccess->StationAddress.Addr[15]));\r | |
2355 | if (( 0 == pAccess->StationAddress.Addr [ 0 ])\r | |
2356 | && ( 0 == pAccess->StationAddress.Addr [ 1 ])\r | |
2357 | && ( 0 == pAccess->StationAddress.Addr [ 2 ])\r | |
2358 | && ( 0 == pAccess->StationAddress.Addr [ 3 ])\r | |
2359 | && ( 0 == pAccess->StationAddress.Addr [ 4 ])\r | |
2360 | && ( 0 == pAccess->StationAddress.Addr [ 5 ])\r | |
2361 | && ( 0 == pAccess->StationAddress.Addr [ 6 ])\r | |
2362 | && ( 0 == pAccess->StationAddress.Addr [ 7 ])\r | |
2363 | && ( 0 == pAccess->StationAddress.Addr [ 8 ])\r | |
2364 | && ( 0 == pAccess->StationAddress.Addr [ 9 ])\r | |
2365 | && ( 0 == pAccess->StationAddress.Addr [ 10 ])\r | |
2366 | && ( 0 == pAccess->StationAddress.Addr [ 11 ])\r | |
2367 | && ( 0 == pAccess->StationAddress.Addr [ 12 ])\r | |
2368 | && ( 0 == pAccess->StationAddress.Addr [ 13 ])\r | |
2369 | && ( 0 == pAccess->StationAddress.Addr [ 14 ])\r | |
2370 | && ( 0 == pAccess->StationAddress.Addr [ 15 ]))\r | |
2371 | {\r | |
2372 | Status = EFI_SUCCESS;\r | |
2373 | break;\r | |
2374 | }\r | |
2375 | \r | |
2376 | //\r | |
2377 | // Open the configuration protocol\r | |
2378 | //\r | |
2379 | pService = pPort->pService;\r | |
2380 | Status = gBS->OpenProtocol ( pService->Controller,\r | |
2381 | &gEfiIp6ConfigProtocolGuid,\r | |
2382 | (VOID **)&pIpConfigProtocol,\r | |
2383 | NULL,\r | |
2384 | NULL,\r | |
2385 | EFI_OPEN_PROTOCOL_GET_PROTOCOL );\r | |
2386 | if ( EFI_ERROR ( Status )) {\r | |
2387 | DEBUG (( DEBUG_ERROR,\r | |
2388 | "ERROR - IP Configuration Protocol not available, Status: %r\r\n",\r | |
2389 | Status ));\r | |
2390 | break;\r | |
2391 | }\r | |
2392 | \r | |
2393 | //\r | |
2394 | // Get the IP configuration data size\r | |
2395 | //\r | |
2396 | DataSize = 0;\r | |
2397 | Status = pIpConfigProtocol->GetData ( pIpConfigProtocol,\r | |
2398 | Ip6ConfigDataTypeInterfaceInfo,\r | |
2399 | &DataSize,\r | |
2400 | NULL );\r | |
2401 | if ( EFI_BUFFER_TOO_SMALL != Status ) {\r | |
2402 | DEBUG (( DEBUG_ERROR,\r | |
2403 | "ERROR - Failed to get IP Configuration data size, Status: %r\r\n",\r | |
2404 | Status ));\r | |
2405 | break;\r | |
2406 | }\r | |
2407 | \r | |
2408 | //\r | |
2409 | // Allocate the configuration data buffer\r | |
2410 | //\r | |
2411 | pIpConfigData = AllocatePool ( DataSize );\r | |
2412 | if ( NULL == pIpConfigData ) {\r | |
2413 | DEBUG (( DEBUG_ERROR,\r | |
2414 | "ERROR - Not enough memory to allocate IP Configuration data!\r\n" ));\r | |
2415 | Status = EFI_OUT_OF_RESOURCES;\r | |
2416 | break;\r | |
2417 | }\r | |
2418 | \r | |
2419 | //\r | |
2420 | // Get the IP configuration\r | |
2421 | //\r | |
2422 | Status = pIpConfigProtocol->GetData ( pIpConfigProtocol,\r | |
2423 | Ip6ConfigDataTypeInterfaceInfo,\r | |
2424 | &DataSize,\r | |
2425 | pIpConfigData );\r | |
2426 | if ( EFI_ERROR ( Status )) {\r | |
2427 | DEBUG (( DEBUG_ERROR,\r | |
2428 | "ERROR - Failed to return IP Configuration data, Status: %r\r\n",\r | |
2429 | Status ));\r | |
2430 | break;\r | |
2431 | }\r | |
2432 | \r | |
2433 | //\r | |
2434 | // Display the current configuration\r | |
2435 | //\r | |
2436 | DEBUG (( DEBUG_BIND,\r | |
2437 | "Actual adapter IP address: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\r\n",\r | |
2438 | pIpConfigData->HwAddress.Addr [ 0 ],\r | |
2439 | pIpConfigData->HwAddress.Addr [ 1 ],\r | |
2440 | pIpConfigData->HwAddress.Addr [ 2 ],\r | |
2441 | pIpConfigData->HwAddress.Addr [ 3 ],\r | |
2442 | pIpConfigData->HwAddress.Addr [ 4 ],\r | |
2443 | pIpConfigData->HwAddress.Addr [ 5 ],\r | |
2444 | pIpConfigData->HwAddress.Addr [ 6 ],\r | |
2445 | pIpConfigData->HwAddress.Addr [ 7 ],\r | |
2446 | pIpConfigData->HwAddress.Addr [ 8 ],\r | |
2447 | pIpConfigData->HwAddress.Addr [ 9 ],\r | |
2448 | pIpConfigData->HwAddress.Addr [ 10 ],\r | |
2449 | pIpConfigData->HwAddress.Addr [ 11 ],\r | |
2450 | pIpConfigData->HwAddress.Addr [ 12 ],\r | |
2451 | pIpConfigData->HwAddress.Addr [ 13 ],\r | |
2452 | pIpConfigData->HwAddress.Addr [ 14 ],\r | |
2453 | pIpConfigData->HwAddress.Addr [ 15 ]));\r | |
2454 | \r | |
2455 | //\r | |
2456 | // Validate the hardware address\r | |
2457 | //\r | |
2458 | Status = EFI_SUCCESS;\r | |
2459 | if (( 16 == pIpConfigData->HwAddressSize )\r | |
2460 | && ( pAccess->StationAddress.Addr [ 0 ] == pIpConfigData->HwAddress.Addr [ 0 ])\r | |
2461 | && ( pAccess->StationAddress.Addr [ 1 ] == pIpConfigData->HwAddress.Addr [ 1 ])\r | |
2462 | && ( pAccess->StationAddress.Addr [ 2 ] == pIpConfigData->HwAddress.Addr [ 2 ])\r | |
2463 | && ( pAccess->StationAddress.Addr [ 3 ] == pIpConfigData->HwAddress.Addr [ 3 ])\r | |
2464 | && ( pAccess->StationAddress.Addr [ 4 ] == pIpConfigData->HwAddress.Addr [ 4 ])\r | |
2465 | && ( pAccess->StationAddress.Addr [ 5 ] == pIpConfigData->HwAddress.Addr [ 5 ])\r | |
2466 | && ( pAccess->StationAddress.Addr [ 6 ] == pIpConfigData->HwAddress.Addr [ 6 ])\r | |
2467 | && ( pAccess->StationAddress.Addr [ 7 ] == pIpConfigData->HwAddress.Addr [ 7 ])\r | |
2468 | && ( pAccess->StationAddress.Addr [ 8 ] == pIpConfigData->HwAddress.Addr [ 8 ])\r | |
2469 | && ( pAccess->StationAddress.Addr [ 9 ] == pIpConfigData->HwAddress.Addr [ 9 ])\r | |
2470 | && ( pAccess->StationAddress.Addr [ 10 ] == pIpConfigData->HwAddress.Addr [ 10 ])\r | |
2471 | && ( pAccess->StationAddress.Addr [ 11 ] == pIpConfigData->HwAddress.Addr [ 11 ])\r | |
2472 | && ( pAccess->StationAddress.Addr [ 12 ] == pIpConfigData->HwAddress.Addr [ 12 ])\r | |
2473 | && ( pAccess->StationAddress.Addr [ 13 ] == pIpConfigData->HwAddress.Addr [ 13 ])\r | |
2474 | && ( pAccess->StationAddress.Addr [ 14 ] == pIpConfigData->HwAddress.Addr [ 14 ])\r | |
2475 | && ( pAccess->StationAddress.Addr [ 15 ] == pIpConfigData->HwAddress.Addr [ 15 ])) {\r | |
2476 | break;\r | |
2477 | }\r | |
2478 | \r | |
2479 | //\r | |
2480 | // Walk the list of other IP addresses assigned to this adapter\r | |
2481 | //\r | |
2482 | for ( AddressCount = 0; pIpConfigData->AddressInfoCount > AddressCount; AddressCount += 1 ) {\r | |
2483 | pAddressInfo = &pIpConfigData->AddressInfo [ AddressCount ];\r | |
2484 | \r | |
2485 | //\r | |
2486 | // Display the IP address\r | |
2487 | //\r | |
2488 | DEBUG (( DEBUG_BIND,\r | |
2489 | "Actual adapter IP address: %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\r\n",\r | |
2490 | pAddressInfo->Address.Addr [ 0 ],\r | |
2491 | pAddressInfo->Address.Addr [ 1 ],\r | |
2492 | pAddressInfo->Address.Addr [ 2 ],\r | |
2493 | pAddressInfo->Address.Addr [ 3 ],\r | |
2494 | pAddressInfo->Address.Addr [ 4 ],\r | |
2495 | pAddressInfo->Address.Addr [ 5 ],\r | |
2496 | pAddressInfo->Address.Addr [ 6 ],\r | |
2497 | pAddressInfo->Address.Addr [ 7 ],\r | |
2498 | pAddressInfo->Address.Addr [ 8 ],\r | |
2499 | pAddressInfo->Address.Addr [ 9 ],\r | |
2500 | pAddressInfo->Address.Addr [ 10 ],\r | |
2501 | pAddressInfo->Address.Addr [ 11 ],\r | |
2502 | pAddressInfo->Address.Addr [ 12 ],\r | |
2503 | pAddressInfo->Address.Addr [ 13 ],\r | |
2504 | pAddressInfo->Address.Addr [ 14 ],\r | |
2505 | pAddressInfo->Address.Addr [ 15 ]));\r | |
2506 | \r | |
2507 | //\r | |
2508 | // Validate the IP address\r | |
2509 | //\r | |
2510 | if (( pAccess->StationAddress.Addr [ 0 ] == pAddressInfo->Address.Addr [ 0 ])\r | |
2511 | && ( pAccess->StationAddress.Addr [ 1 ] == pAddressInfo->Address.Addr [ 1 ])\r | |
2512 | && ( pAccess->StationAddress.Addr [ 2 ] == pAddressInfo->Address.Addr [ 2 ])\r | |
2513 | && ( pAccess->StationAddress.Addr [ 3 ] == pAddressInfo->Address.Addr [ 3 ])\r | |
2514 | && ( pAccess->StationAddress.Addr [ 4 ] == pAddressInfo->Address.Addr [ 4 ])\r | |
2515 | && ( pAccess->StationAddress.Addr [ 5 ] == pAddressInfo->Address.Addr [ 5 ])\r | |
2516 | && ( pAccess->StationAddress.Addr [ 6 ] == pAddressInfo->Address.Addr [ 6 ])\r | |
2517 | && ( pAccess->StationAddress.Addr [ 7 ] == pAddressInfo->Address.Addr [ 7 ])\r | |
2518 | && ( pAccess->StationAddress.Addr [ 8 ] == pAddressInfo->Address.Addr [ 8 ])\r | |
2519 | && ( pAccess->StationAddress.Addr [ 9 ] == pAddressInfo->Address.Addr [ 9 ])\r | |
2520 | && ( pAccess->StationAddress.Addr [ 10 ] == pAddressInfo->Address.Addr [ 10 ])\r | |
2521 | && ( pAccess->StationAddress.Addr [ 11 ] == pAddressInfo->Address.Addr [ 11 ])\r | |
2522 | && ( pAccess->StationAddress.Addr [ 12 ] == pAddressInfo->Address.Addr [ 12 ])\r | |
2523 | && ( pAccess->StationAddress.Addr [ 13 ] == pAddressInfo->Address.Addr [ 13 ])\r | |
2524 | && ( pAccess->StationAddress.Addr [ 14 ] == pAddressInfo->Address.Addr [ 14 ])\r | |
2525 | && ( pAccess->StationAddress.Addr [ 15 ] == pAddressInfo->Address.Addr [ 15 ])) {\r | |
2526 | break;\r | |
2527 | }\r | |
2528 | }\r | |
2529 | if ( pIpConfigData->AddressInfoCount > AddressCount ) {\r | |
2530 | break;\r | |
2531 | }\r | |
2532 | \r | |
2533 | //\r | |
2534 | // The IP address did not match\r | |
2535 | //\r | |
2536 | Status = EFI_NOT_STARTED;\r | |
2537 | break;\r | |
2538 | }\r | |
2539 | \r | |
2540 | //\r | |
2541 | // Free the buffer if necessary\r | |
2542 | //\r | |
2543 | if ( NULL != pIpConfigData ) {\r | |
2544 | FreePool ( pIpConfigData );\r | |
2545 | }\r | |
2546 | \r | |
2547 | //\r | |
2548 | // Return the IP address status\r | |
2549 | //\r | |
2550 | DBG_EXIT_STATUS ( Status );\r | |
2551 | return Status;\r | |
2552 | }\r | |
2553 | \r | |
2554 | \r | |
3bdf9aae | 2555 | /**\r |
2556 | Interface between the socket layer and the network specific\r | |
2557 | code that supports SOCK_STREAM and SOCK_SEQPACKET sockets\r | |
2558 | over TCPv6.\r | |
2559 | **/\r | |
2560 | CONST ESL_PROTOCOL_API cEslTcp6Api = {\r | |
2561 | "TCPv6",\r | |
2562 | IPPROTO_TCP,\r | |
2563 | OFFSET_OF ( ESL_PORT, Context.Tcp6.ConfigData ),\r | |
2564 | OFFSET_OF ( ESL_LAYER, pTcp6List ),\r | |
2565 | sizeof ( struct sockaddr_in6 ),\r | |
2566 | sizeof ( struct sockaddr_in6 ),\r | |
2567 | AF_INET6,\r | |
2568 | sizeof (((ESL_PACKET *)0 )->Op.Tcp6Rx ),\r | |
2569 | OFFSET_OF ( ESL_PACKET, Op.Tcp6Rx.Buffer ) - OFFSET_OF ( ESL_PACKET, Op ),\r | |
2570 | OFFSET_OF ( ESL_IO_MGMT, Token.Tcp6Rx.Packet.RxData ),\r | |
2571 | TRUE,\r | |
2572 | EADDRINUSE,\r | |
2573 | EslTcp6Accept,\r | |
2574 | EslTcp6ConnectPoll,\r | |
2575 | EslTcp6ConnectStart,\r | |
2576 | EslTcp6SocketIsConfigured,\r | |
2577 | EslTcp6LocalAddressGet,\r | |
2578 | EslTcp6LocalAddressSet,\r | |
2579 | EslTcp6Listen,\r | |
2580 | NULL, // OptionGet\r | |
2581 | NULL, // OptionSet\r | |
2582 | EslTcp6PacketFree,\r | |
2583 | EslTcp6PortAllocate,\r | |
2584 | EslTcp6PortClose,\r | |
2585 | EslTcp6PortCloseOp,\r | |
2586 | FALSE,\r | |
2587 | EslTcp6Receive,\r | |
2588 | EslTcp6RemoteAddressGet,\r | |
2589 | EslTcp6RemoteAddressSet,\r | |
2590 | EslTcp6RxComplete,\r | |
2591 | EslTcp6RxStart,\r | |
2592 | EslTcp6TxBuffer,\r | |
2593 | EslTcp6TxComplete,\r | |
2dc09dd5 | 2594 | EslTcp6TxOobComplete,\r |
a93b0f45 | 2595 | (PFN_API_VERIFY_LOCAL_IP_ADDRESS)EslTcp6VerifyLocalIpAddress\r |
3bdf9aae | 2596 | };\r |