]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/EfiSocketLib/Socket.h
Fix a bug about the iSCSI DHCP dependency issue.
[mirror_edk2.git] / StdLib / EfiSocketLib / Socket.h
CommitLineData
d7ce7006 1/** @file\r
2 Definitions for the Socket layer driver.\r
3\r
4 Copyright (c) 2011, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license\r
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#ifndef _SOCKET_H_\r
15#define _SOCKET_H_\r
16\r
17#include <Efi/EfiSocketLib.h>\r
18\r
19//------------------------------------------------------------------------------\r
20// Constants\r
21//------------------------------------------------------------------------------\r
22\r
23#define DEBUG_SOCKET 0x20000000 ///< Display Socket related messages\r
24#define DEBUG_BIND 0x10000000 ///< Display bind related messages\r
25#define DEBUG_LISTEN 0x08000000 ///< Display listen related messages\r
26#define DEBUG_CONNECTION 0x04000000 ///< Display connection list related messages\r
27#define DEBUG_POLL 0x02000000 ///< Display poll messages\r
28#define DEBUG_ACCEPT 0x01000000 ///< Display accept related messages\r
29#define DEBUG_RX 0x00800000 ///< Display receive messages\r
30#define DEBUG_TX 0x00400000 ///< Display transmit messages\r
31#define DEBUG_CLOSE 0x00200000 ///< Display close messages\r
32#define DEBUG_CONNECT 0x00100000 ///< Display connect messages\r
a88c3163 33#define DEBUG_OPTION 0x00080000 ///< Display option messages\r
d7ce7006 34\r
35#define MAX_PENDING_CONNECTIONS 1 ///< Maximum connection FIFO depth\r
7d5c23a7 36#define MAX_RX_DATA 0x01000000 ///< Maximum receive data size\r
a88c3163 37#define MAX_TX_DATA ( MAX_RX_DATA * 2 ) ///< Maximum buffered transmit data in bytes\r
7d5c23a7 38#define RX_PACKET_DATA 0x00100000 ///< Maximum number of bytes in a RX packet\r
a88c3163 39#define MAX_UDP_RETRANSMIT 16 ///< UDP retransmit attempts to handle address not mapped\r
d7ce7006 40\r
a88c3163 41#define ESL_STRUCTURE_ALIGNMENT_BYTES 15 ///< Number of bytes for structure alignment\r
42#define ESL_STRUCTURE_ALIGNMENT_MASK ( ~ESL_STRUCTURE_ALIGNMENT_BYTES ) ///< Mask to align structures\r
d7ce7006 43\r
a88c3163 44#define LAYER_SIGNATURE SIGNATURE_32 ('S','k','t','L') ///< ESL_LAYER memory signature\r
45#define SERVICE_SIGNATURE SIGNATURE_32 ('S','k','t','S') ///< ESL_SERVICE memory signature\r
46#define SOCKET_SIGNATURE SIGNATURE_32 ('S','c','k','t') ///< ESL_SOCKET memory signature\r
47#define PORT_SIGNATURE SIGNATURE_32 ('P','o','r','t') ///< ESL_PORT memory signature\r
d7ce7006 48\r
a88c3163 49\r
50/**\r
51 Socket states\r
52**/\r
d7ce7006 53typedef enum\r
54{\r
55 SOCKET_STATE_NOT_CONFIGURED = 0, ///< socket call was successful\r
56 SOCKET_STATE_BOUND, ///< bind call was successful\r
57 SOCKET_STATE_LISTENING, ///< listen call was successful\r
58 SOCKET_STATE_NO_PORTS, ///< No ports available\r
59 SOCKET_STATE_IN_FIFO, ///< Socket on FIFO\r
60 SOCKET_STATE_CONNECTING, ///< Connecting to a remote system\r
61 SOCKET_STATE_CONNECTED, ///< Accept or connect call was successful\r
62\r
63 //\r
64 // Close state must be the last in the list\r
65 //\r
66 SOCKET_STATE_CLOSED ///< Close call was successful\r
67} SOCKET_STATE;\r
68\r
a88c3163 69\r
70/**\r
71 Port states\r
72**/\r
d7ce7006 73typedef enum\r
74{\r
75 PORT_STATE_ALLOCATED = 0, ///< Port allocated\r
76 PORT_STATE_OPEN, ///< Port opened\r
77 PORT_STATE_RX_ERROR, ///< Receive error detected\r
78\r
79 //\r
a88c3163 80 // Close state must be last in the list!\r
81 //\r
82 // Using < <= > >= in tests code to detect port close state\r
83 // machine has started\r
d7ce7006 84 //\r
85 PORT_STATE_CLOSE_STARTED, ///< Close started on port\r
86 PORT_STATE_CLOSE_TX_DONE, ///< Transmits shutdown\r
a88c3163 87 PORT_STATE_CLOSE_DONE, ///< Port close operation complete\r
88 PORT_STATE_CLOSE_RX_DONE ///< Receives shutdown\r
d7ce7006 89} PORT_STATE;\r
90\r
91//------------------------------------------------------------------------------\r
92// Data Types\r
93//------------------------------------------------------------------------------\r
94\r
a88c3163 95typedef struct _ESL_IO_MGMT ESL_IO_MGMT;///< Forward declaration\r
96typedef struct _ESL_PACKET ESL_PACKET; ///< Forward declaration\r
97typedef struct _ESL_PORT ESL_PORT; ///< Forward declaration\r
98typedef struct _ESL_SOCKET ESL_SOCKET; ///< Forward declaration\r
99\r
100/**\r
101 Receive context for SOCK_RAW sockets using IPv4.\r
102**/\r
103typedef struct\r
104{\r
105 EFI_IP4_RECEIVE_DATA * pRxData; ///< Receive operation description\r
106} ESL_IP4_RX_DATA;\r
107\r
108\r
109/**\r
110 Transmit context for SOCK_RAW sockets using IPv4.\r
111**/\r
112typedef struct\r
113{\r
114 EFI_IP4_OVERRIDE_DATA Override; ///< Override data\r
115 EFI_IP4_TRANSMIT_DATA TxData; ///< Transmit operation description\r
116 UINT8 Buffer[ 1 ]; ///< Data buffer\r
117} ESL_IP4_TX_DATA;\r
d7ce7006 118\r
a88c3163 119\r
120/**\r
121 Receive context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv4.\r
122**/\r
d7ce7006 123typedef struct\r
124{\r
125 EFI_TCP4_RECEIVE_DATA RxData; ///< Receive operation description\r
a88c3163 126 UINT8 Buffer[ RX_PACKET_DATA ]; ///< Data buffer\r
127} ESL_TCP4_RX_DATA;\r
128\r
d7ce7006 129\r
a88c3163 130/**\r
131 Transmit context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv4.\r
132**/\r
d7ce7006 133typedef struct\r
134{\r
135 EFI_TCP4_TRANSMIT_DATA TxData; ///< Transmit operation description\r
a88c3163 136 UINT8 Buffer[ 1 ]; ///< Data buffer\r
137} ESL_TCP4_TX_DATA;\r
d7ce7006 138\r
a88c3163 139\r
3bdf9aae 140/**\r
141 Receive context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv6.\r
142**/\r
143typedef struct\r
144{\r
145 EFI_TCP6_RECEIVE_DATA RxData; ///< Receive operation description\r
146 UINT8 Buffer[ RX_PACKET_DATA ]; ///< Data buffer\r
147} ESL_TCP6_RX_DATA;\r
148\r
149\r
150/**\r
151 Transmit context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv6.\r
152**/\r
153typedef struct\r
154{\r
155 EFI_TCP6_TRANSMIT_DATA TxData; ///< Transmit operation description\r
156 UINT8 Buffer[ 1 ]; ///< Data buffer\r
157} ESL_TCP6_TX_DATA;\r
158\r
159\r
a88c3163 160/**\r
161 Receive context for SOCK_DGRAM sockets using UDPv4.\r
162**/\r
d7ce7006 163typedef struct\r
164{\r
a88c3163 165 EFI_UDP4_SESSION_DATA Session; ///< Remote network address\r
166 EFI_UDP4_RECEIVE_DATA * pRxData; ///< Receive operation description\r
167} ESL_UDP4_RX_DATA;\r
d7ce7006 168\r
a88c3163 169\r
170/**\r
171 Transmit context for SOCK_DGRAM sockets using UDPv4.\r
172**/\r
d7ce7006 173typedef struct\r
174{\r
175 EFI_UDP4_SESSION_DATA Session; ///< Remote network address\r
176 EFI_UDP4_TRANSMIT_DATA TxData; ///< Transmit operation description\r
a88c3163 177 UINTN RetransmitCount; ///< Retransmit to handle ARP negotiation\r
178 UINT8 Buffer[ 1 ]; ///< Data buffer\r
179} ESL_UDP4_TX_DATA;\r
180\r
d7ce7006 181\r
3bdf9aae 182/**\r
183 Receive context for SOCK_DGRAM sockets using UDPv6.\r
184**/\r
185typedef struct\r
186{\r
187 EFI_UDP6_SESSION_DATA Session; ///< Remote network address\r
188 EFI_UDP6_RECEIVE_DATA * pRxData; ///< Receive operation description\r
189} ESL_UDP6_RX_DATA;\r
190\r
191\r
192/**\r
193 Transmit context for SOCK_DGRAM sockets using UDPv6.\r
194**/\r
195typedef struct\r
196{\r
197 EFI_UDP6_SESSION_DATA Session; ///< Remote network address\r
198 EFI_UDP6_TRANSMIT_DATA TxData; ///< Transmit operation description\r
199 UINTN RetransmitCount; ///< Retransmit to handle ARP negotiation\r
200 UINT8 Buffer[ 1 ]; ///< Data buffer\r
201} ESL_UDP6_TX_DATA;\r
202\r
203\r
a88c3163 204/**\r
205 Network specific context for transmit and receive packets.\r
206**/\r
207typedef struct _ESL_PACKET {\r
208 ESL_PACKET * pNext; ///< Next packet in the receive list\r
d7ce7006 209 size_t PacketSize; ///< Size of this data structure\r
a88c3163 210 size_t ValidBytes; ///< Length of valid data in bytes\r
211 UINT8 * pBuffer; ///< Current data pointer\r
d7ce7006 212 union {\r
a88c3163 213 ESL_IP4_RX_DATA Ip4Rx; ///< Receive operation description\r
214 ESL_IP4_TX_DATA Ip4Tx; ///< Transmit operation description\r
215 ESL_TCP4_RX_DATA Tcp4Rx; ///< Receive operation description\r
216 ESL_TCP4_TX_DATA Tcp4Tx; ///< Transmit operation description\r
3bdf9aae 217 ESL_TCP6_RX_DATA Tcp6Rx; ///< Receive operation description\r
218 ESL_TCP6_TX_DATA Tcp6Tx; ///< Transmit operation description\r
a88c3163 219 ESL_UDP4_RX_DATA Udp4Rx; ///< Receive operation description\r
220 ESL_UDP4_TX_DATA Udp4Tx; ///< Transmit operation description\r
3bdf9aae 221 ESL_UDP6_RX_DATA Udp6Rx; ///< Receive operation description\r
222 ESL_UDP6_TX_DATA Udp6Tx; ///< Transmit operation description\r
a88c3163 223 } Op; ///< Network specific context\r
224} GCC_ESL_PACKET;\r
d7ce7006 225\r
226/**\r
227 Service control structure\r
228\r
229 The driver uses this structure to manage the network devices.\r
230**/\r
a88c3163 231typedef struct _ESL_SERVICE {\r
d7ce7006 232 UINTN Signature; ///< Structure identification\r
233\r
234 //\r
235 // Links\r
236 //\r
a88c3163 237 ESL_SERVICE * pNext; ///< Next service in the service list\r
d7ce7006 238\r
239 //\r
240 // Service data\r
241 //\r
a88c3163 242 CONST ESL_SOCKET_BINDING * pSocketBinding; ///< Name and shutdown routine\r
243 EFI_HANDLE Controller; ///< Controller for the service\r
244 EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Network layer service binding interface\r
d7ce7006 245\r
246 //\r
247 // Network data\r
248 //\r
a88c3163 249 ESL_PORT * pPortList; ///< List of ports using this service\r
250}GCC_ESL_SERVICE;\r
d7ce7006 251\r
252/**\r
a88c3163 253 IO management structure\r
d7ce7006 254\r
a88c3163 255 This structure manages a single operation with the network.\r
256**/\r
257typedef struct _ESL_IO_MGMT {\r
258 ESL_IO_MGMT * pNext; ///< Next TX management structure\r
259 ESL_PORT * pPort; ///< Port structure address\r
260 ESL_PACKET * pPacket; ///< Packet structure address\r
261 union {\r
262 EFI_IP4_COMPLETION_TOKEN Ip4Rx; ///< IP4 receive token\r
263 EFI_IP4_COMPLETION_TOKEN Ip4Tx; ///< IP4 transmit token\r
264 EFI_TCP4_IO_TOKEN Tcp4Rx; ///< TCP4 receive token\r
265 EFI_TCP4_IO_TOKEN Tcp4Tx; ///< TCP4 transmit token\r
3bdf9aae 266 EFI_TCP6_IO_TOKEN Tcp6Rx; ///< TCP6 receive token\r
267 EFI_TCP6_IO_TOKEN Tcp6Tx; ///< TCP6 transmit token\r
a88c3163 268 EFI_UDP4_COMPLETION_TOKEN Udp4Rx; ///< UDP4 receive token\r
269 EFI_UDP4_COMPLETION_TOKEN Udp4Tx; ///< UDP4 transmit token\r
3bdf9aae 270 EFI_UDP6_COMPLETION_TOKEN Udp6Rx; ///< UDP6 receive token\r
271 EFI_UDP6_COMPLETION_TOKEN Udp6Tx; ///< UDP6 transmit token\r
a88c3163 272 } Token; ///< Completion token for the network operation\r
58081f2c 273} GCC_IO_MGMT;\r
a88c3163 274\r
275/**\r
276 IP4 context structure\r
d7ce7006 277\r
a88c3163 278 The driver uses this structure to manage the IP4 connections.\r
d7ce7006 279**/\r
a88c3163 280typedef struct {\r
281 //\r
282 // IP4 context\r
283 //\r
284 EFI_IP4_MODE_DATA ModeData; ///< IP4 mode data, includes configuration data\r
285 EFI_IPv4_ADDRESS DestinationAddress; ///< Default destination address\r
286} ESL_IP4_CONTEXT;\r
287\r
d7ce7006 288\r
289/**\r
290 TCP4 context structure\r
291\r
292 The driver uses this structure to manage the TCP4 connections.\r
293**/\r
294typedef struct {\r
295 //\r
296 // TCP4 context\r
297 //\r
a88c3163 298 EFI_TCP4_CONFIG_DATA ConfigData; ///< TCP4 configuration data\r
299 EFI_TCP4_OPTION Option; ///< TCP4 port options\r
d7ce7006 300\r
301 //\r
302 // Tokens\r
303 //\r
a88c3163 304 EFI_TCP4_LISTEN_TOKEN ListenToken; ///< Listen control\r
d7ce7006 305 EFI_TCP4_CONNECTION_TOKEN ConnectToken; ///< Connection control\r
a88c3163 306 EFI_TCP4_CLOSE_TOKEN CloseToken; ///< Close control\r
307} ESL_TCP4_CONTEXT;\r
d7ce7006 308\r
3bdf9aae 309/**\r
310 TCP6 context structure\r
311\r
312 The driver uses this structure to manage the TCP6 connections.\r
313**/\r
314typedef struct {\r
315 //\r
316 // TCP6 context\r
317 //\r
318 EFI_TCP6_CONFIG_DATA ConfigData; ///< TCP6 configuration data\r
319 EFI_TCP6_OPTION Option; ///< TCP6 port options\r
320\r
321 //\r
322 // Tokens\r
323 //\r
324 EFI_TCP6_LISTEN_TOKEN ListenToken; ///< Listen control\r
325 EFI_TCP6_CONNECTION_TOKEN ConnectToken; ///< Connection control\r
326 EFI_TCP6_CLOSE_TOKEN CloseToken; ///< Close control\r
327} ESL_TCP6_CONTEXT;\r
328\r
d7ce7006 329/**\r
330 UDP4 context structure\r
331\r
332 The driver uses this structure to manage the UDP4 connections.\r
333**/\r
334typedef struct {\r
335 //\r
336 // UDP4 context\r
337 //\r
d7ce7006 338 EFI_UDP4_CONFIG_DATA ConfigData; ///< UDP4 configuration data\r
a88c3163 339} ESL_UDP4_CONTEXT;\r
d7ce7006 340\r
3bdf9aae 341/**\r
342 UDP6 context structure\r
343\r
344 The driver uses this structure to manage the UDP6 connections.\r
345**/\r
346typedef struct {\r
347 //\r
348 // UDP6 context\r
349 //\r
350 EFI_UDP6_CONFIG_DATA ConfigData; ///< UDP6 configuration data\r
351} ESL_UDP6_CONTEXT;\r
352\r
d7ce7006 353\r
a88c3163 354/**\r
355 Configure the network layer.\r
356\r
357 @param [in] pProtocol Protocol structure address\r
358 @param [in] pConfigData Address of the confiuration data\r
359\r
360 @return Returns EFI_SUCCESS if the operation is successfully\r
361 started.\r
362**/\r
363typedef\r
364EFI_STATUS\r
985fef80 365(EFIAPI * PFN_NET_CONFIGURE) (\r
a88c3163 366 IN VOID * pProtocol,\r
367 IN VOID * pConfigData\r
368 );\r
369\r
370/**\r
371 Hand an I/O operation to the network layer.\r
372\r
373 @param [in] pProtocol Protocol structure address\r
374 @param [in] pToken Completion token address\r
d7ce7006 375\r
a88c3163 376 @return Returns EFI_SUCCESS if the operation is successfully\r
377 started.\r
378**/\r
379typedef\r
380EFI_STATUS\r
985fef80 381(EFIAPI * PFN_NET_IO_START) (\r
a88c3163 382 IN VOID * pProtocol,\r
383 IN VOID * pToken\r
384 );\r
d7ce7006 385\r
3bdf9aae 386/**\r
387 Poll the LAN adapter for receive packets.\r
388\r
389 @param [in] pProtocol Protocol structure address\r
390 @param [in] pToken Completion token address\r
391\r
392 @return Returns EFI_SUCCESS if the operation is successfully\r
393 started.\r
394**/\r
395typedef\r
396EFI_STATUS\r
985fef80 397(EFIAPI * PFN_NET_POLL) (\r
3bdf9aae 398 IN VOID * pProtocol\r
399 );\r
400\r
d7ce7006 401/**\r
402 Port control structure\r
403\r
404 The driver uses this structure to manager the socket's connection\r
405 with the network driver.\r
406**/\r
a88c3163 407typedef struct _ESL_PORT {\r
d7ce7006 408 UINTN Signature; ///< Structure identification\r
409\r
410 //\r
411 // List links\r
412 //\r
a88c3163 413 ESL_PORT * pLinkService; ///< Link in service port list\r
414 ESL_PORT * pLinkSocket; ///< Link in socket port list\r
d7ce7006 415\r
416 //\r
417 // Structures\r
418 //\r
a88c3163 419 ESL_SERVICE * pService; ///< Service for this port\r
420 ESL_SOCKET * pSocket; ///< Socket for this port\r
d7ce7006 421\r
422 //\r
a88c3163 423 // Eliminate the pService references during port close\r
d7ce7006 424 //\r
a88c3163 425 EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Service binding for network layer\r
426 CONST ESL_SOCKET_BINDING * pSocketBinding; ///< Socket binding for network layer\r
d7ce7006 427\r
428 //\r
a88c3163 429 // Port management\r
d7ce7006 430 //\r
a88c3163 431 EFI_HANDLE Handle; ///< Network port handle\r
432 PORT_STATE State; ///< State of the port\r
433 UINTN DebugFlags; ///< Debug flags used to close the port\r
434 BOOLEAN bCloseNow; ///< TRUE = Close the port immediately\r
435 BOOLEAN bConfigured; ///< TRUE = Configure call made to network layer\r
436 PFN_NET_CONFIGURE pfnConfigure; ///< Configure the network layer\r
d7ce7006 437\r
438 //\r
439 // Transmit data management\r
440 //\r
a88c3163 441 BOOLEAN bTxFlowControl; ///< TX flow control applied\r
442 PFN_NET_IO_START pfnTxStart; ///< Start a transmit on the network\r
443 ESL_IO_MGMT * pTxActive; ///< Normal data queue\r
444 ESL_IO_MGMT * pTxFree; ///< Normal free queue\r
d7ce7006 445\r
a88c3163 446 ESL_IO_MGMT * pTxOobActive; ///< Urgent data queue\r
447 ESL_IO_MGMT * pTxOobFree; ///< Urgent free queue\r
d7ce7006 448\r
449 //\r
a88c3163 450 // Receive data management\r
d7ce7006 451 //\r
a88c3163 452 PFN_NET_IO_START pfnRxCancel; ///< Cancel a receive on the network\r
3bdf9aae 453 PFN_NET_POLL pfnRxPoll; ///< Poll the LAN adapter for receive packets\r
a88c3163 454 PFN_NET_IO_START pfnRxStart; ///< Start a receive on the network\r
455 ESL_IO_MGMT * pRxActive; ///< Active receive operation queue\r
456 ESL_IO_MGMT * pRxFree; ///< Free structure queue\r
d7ce7006 457\r
458 //\r
a88c3163 459 // Protocol specific management data\r
d7ce7006 460 //\r
a88c3163 461 union {\r
462 VOID * v; ///< VOID pointer\r
463 EFI_IP4_PROTOCOL * IPv4; ///< IP4 protocol pointer\r
464 EFI_TCP4_PROTOCOL * TCPv4; ///< TCP4 protocol pointer\r
3bdf9aae 465 EFI_TCP6_PROTOCOL * TCPv6; ///< TCP6 protocol pointer\r
a88c3163 466 EFI_UDP4_PROTOCOL * UDPv4; ///< UDP4 protocol pointer\r
3bdf9aae 467 EFI_UDP6_PROTOCOL * UDPv6; ///< UDP6 protocol pointer\r
a88c3163 468 } pProtocol; ///< Protocol structure address\r
469 union {\r
470 ESL_IP4_CONTEXT Ip4; ///< IPv4 management data\r
471 ESL_TCP4_CONTEXT Tcp4; ///< TCPv4 management data\r
3bdf9aae 472 ESL_TCP6_CONTEXT Tcp6; ///< TCPv6 management data\r
a88c3163 473 ESL_UDP4_CONTEXT Udp4; ///< UDPv4 management data\r
3bdf9aae 474 ESL_UDP6_CONTEXT Udp6; ///< UDPv6 management data\r
a88c3163 475 } Context; ///< Network specific context\r
476}GCC_ESL_PORT;\r
d7ce7006 477\r
478/**\r
479 Accept a network connection.\r
480\r
d7ce7006 481 @param [in] pSocket Address of the socket structure.\r
482\r
483 @param [in] pSockAddr Address of a buffer to receive the remote\r
484 network address.\r
485\r
486 @param [in, out] pSockAddrLength Length in bytes of the address buffer.\r
487 On output specifies the length of the\r
488 remote network address.\r
489\r
490 @retval EFI_SUCCESS Remote address is available\r
491 @retval Others Remote address not available\r
492\r
493 **/\r
a88c3163 494typedef\r
d7ce7006 495EFI_STATUS\r
a88c3163 496(* PFN_API_ACCEPT) (\r
497 IN ESL_SOCKET * pSocket,\r
d7ce7006 498 IN struct sockaddr * pSockAddr,\r
499 IN OUT socklen_t * pSockAddrLength\r
500 );\r
501\r
502/**\r
a88c3163 503 Poll for completion of the connection attempt.\r
d7ce7006 504\r
a88c3163 505 @param [in] pSocket Address of an ::ESL_SOCKET structure.\r
d7ce7006 506\r
a88c3163 507 @retval EFI_SUCCESS The connection was successfully established.\r
508 @retval EFI_NOT_READY The connection is in progress, call this routine again.\r
509 @retval Others The connection attempt failed.\r
d7ce7006 510\r
511 **/\r
a88c3163 512typedef\r
d7ce7006 513EFI_STATUS\r
a88c3163 514(* PFN_API_CONNECT_POLL) (\r
515 IN ESL_SOCKET * pSocket\r
d7ce7006 516 );\r
517\r
518/**\r
a88c3163 519 Attempt to connect to a remote TCP port\r
520\r
521 This routine starts the connection processing for a SOCK_STREAM\r
522 or SOCK_SEQPAKCET socket using the TCP network layer.\r
d7ce7006 523\r
a88c3163 524 This routine is called by ::EslSocketConnect to initiate the TCP\r
525 network specific connect operations.\r
d7ce7006 526\r
a88c3163 527 @param [in] pSocket Address of an ::ESL_SOCKET structure.\r
d7ce7006 528\r
529 @retval EFI_SUCCESS The connection was successfully established.\r
530 @retval EFI_NOT_READY The connection is in progress, call this routine again.\r
531 @retval Others The connection attempt failed.\r
532\r
533 **/\r
a88c3163 534typedef\r
d7ce7006 535EFI_STATUS\r
a88c3163 536(* PFN_API_CONNECT_START) (\r
537 IN ESL_SOCKET * pSocket\r
d7ce7006 538 );\r
539\r
540/**\r
a88c3163 541 Get the local socket address\r
d7ce7006 542\r
a88c3163 543 @param [in] pPort Address of an ::ESL_PORT structure.\r
d7ce7006 544\r
a88c3163 545 @param [out] pAddress Network address to receive the local system address\r
d7ce7006 546\r
547**/\r
a88c3163 548typedef\r
549VOID\r
550(* PFN_API_LOCAL_ADDR_GET) (\r
551 IN ESL_PORT * pPort,\r
552 OUT struct sockaddr * pAddress\r
d7ce7006 553 );\r
554\r
555/**\r
a88c3163 556 Set the local port address.\r
d7ce7006 557\r
a88c3163 558 This routine sets the local port address.\r
d7ce7006 559\r
a88c3163 560 This support routine is called by ::EslSocketPortAllocate.\r
d7ce7006 561\r
a88c3163 562 @param [in] ppPort Address of an ESL_PORT structure\r
563 @param [in] pSockAddr Address of a sockaddr structure that contains the\r
564 connection point on the local machine. An IPv4 address\r
565 of INADDR_ANY specifies that the connection is made to\r
566 all of the network stacks on the platform. Specifying a\r
567 specific IPv4 address restricts the connection to the\r
568 network stack supporting that address. Specifying zero\r
569 for the port causes the network layer to assign a port\r
570 number from the dynamic range. Specifying a specific\r
571 port number causes the network layer to use that port.\r
572 @param [in] bBindTest TRUE = run bind testing\r
d7ce7006 573\r
a88c3163 574 @retval EFI_SUCCESS The operation was successful\r
d7ce7006 575\r
a88c3163 576 **/\r
577typedef\r
d7ce7006 578EFI_STATUS\r
a88c3163 579(* PFN_API_LOCAL_ADDR_SET) (\r
580 IN ESL_PORT * pPort,\r
581 IN CONST struct sockaddr * pSockAddr,\r
582 IN BOOLEAN bBindTest\r
d7ce7006 583 );\r
584\r
58081f2c 585/**\r
586 Process the completion event\r
587\r
588 This routine handles the I/O completion event.\r
589\r
590 This routine is called by the low level network driver when\r
591 the operation is completed.\r
592\r
593 @param [in] Event The receive completion event\r
594\r
595 @param [in] pIo The address of an ::ESL_IO_MGMT structure\r
596\r
597**/\r
598typedef\r
599VOID\r
600(* PFN_API_IO_COMPLETE) (\r
601 IN EFI_EVENT Event,\r
602 IN ESL_IO_MGMT * pIo\r
603 );\r
604\r
d7ce7006 605/**\r
a88c3163 606 Determine if the socket is configured.\r
d7ce7006 607\r
d7ce7006 608\r
a88c3163 609 @param [in] pSocket Address of a ESL_SOCKET structure\r
610 \r
611 @retval EFI_SUCCESS - The port is connected\r
612 @retval EFI_NOT_STARTED - The port is not connected\r
d7ce7006 613\r
a88c3163 614 **/\r
615 typedef\r
616 EFI_STATUS\r
617 (* PFN_API_IS_CONFIGURED) (\r
618 IN ESL_SOCKET * pSocket\r
d7ce7006 619 );\r
620\r
621/**\r
622 Establish the known port to listen for network connections.\r
623\r
d7ce7006 624 @param [in] pSocket Address of the socket structure.\r
a88c3163 625\r
d7ce7006 626 @retval EFI_SUCCESS - Socket successfully created\r
627 @retval Other - Failed to enable the socket for listen\r
628\r
629**/\r
a88c3163 630typedef\r
d7ce7006 631EFI_STATUS\r
a88c3163 632(* PFN_API_LISTEN) (\r
633 IN ESL_SOCKET * pSocket\r
d7ce7006 634 );\r
635\r
636/**\r
a88c3163 637 Get the option value\r
d7ce7006 638\r
a88c3163 639 Retrieve the protocol options one at a time by name.\r
d7ce7006 640\r
a88c3163 641 @param [in] pSocket Address of a ESL_SOCKET structure\r
642 @param [in] OptionName Name of the option\r
643 @param [out] ppOptionData Buffer to receive address of option value\r
644 @param [out] pOptionLength Buffer to receive the option length\r
d7ce7006 645\r
a88c3163 646 @retval EFI_SUCCESS - Socket data successfully received\r
d7ce7006 647\r
648 **/\r
a88c3163 649typedef\r
d7ce7006 650EFI_STATUS\r
a88c3163 651(* PFN_API_OPTION_GET) (\r
652 IN ESL_SOCKET * pSocket,\r
653 IN int OptionName,\r
654 OUT CONST void ** __restrict ppOptionData,\r
655 OUT socklen_t * __restrict pOptionLength\r
d7ce7006 656 );\r
657\r
658/**\r
a88c3163 659 Set the option value\r
d7ce7006 660\r
a88c3163 661 Adjust the protocol options one at a time by name.\r
d7ce7006 662\r
a88c3163 663 @param [in] pSocket Address of a ESL_SOCKET structure\r
664 @param [in] OptionName Name of the option\r
665 @param [in] pOptionValue Buffer containing the option value\r
666 @param [in] OptionLength Length of the buffer in bytes\r
d7ce7006 667\r
a88c3163 668 @retval EFI_SUCCESS - Option successfully set\r
669\r
670 **/\r
671typedef\r
d7ce7006 672EFI_STATUS\r
a88c3163 673(* PFN_API_OPTION_SET) (\r
674 IN ESL_SOCKET * pSocket,\r
675 IN int OptionName,\r
676 IN CONST void * pOptionValue,\r
677 IN socklen_t OptionLength\r
d7ce7006 678 );\r
679\r
680/**\r
a88c3163 681 Free a receive packet\r
d7ce7006 682\r
a88c3163 683 This routine performs the network specific operations necessary\r
684 to free a receive packet.\r
d7ce7006 685\r
a88c3163 686 This routine is called by ::EslSocketPortCloseTxDone to free a\r
687 receive packet.\r
688\r
689 @param [in] pPacket Address of an ::ESL_PACKET structure.\r
690 @param [in, out] pRxBytes Address of the count of RX bytes\r
d7ce7006 691\r
692**/\r
a88c3163 693typedef\r
d7ce7006 694VOID\r
a88c3163 695(* PFN_API_PACKET_FREE) (\r
696 IN ESL_PACKET * pPacket,\r
697 IN OUT size_t * pRxBytes\r
d7ce7006 698 );\r
699\r
700/**\r
a88c3163 701 Initialize the network specific portions of an ::ESL_PORT structure.\r
d7ce7006 702\r
a88c3163 703 This routine initializes the network specific portions of an\r
704 ::ESL_PORT structure for use by the socket.\r
d7ce7006 705\r
a88c3163 706 This support routine is called by ::EslSocketPortAllocate\r
707 to connect the socket with the underlying network adapter\r
708 running the IPv4 protocol.\r
d7ce7006 709\r
a88c3163 710 @param [in] ppPort Address of an ESL_PORT structure\r
711 @param [in] DebugFlags Flags for debug messages\r
d7ce7006 712\r
a88c3163 713 @retval EFI_SUCCESS - Socket successfully created\r
714\r
715 **/\r
716typedef\r
d7ce7006 717EFI_STATUS\r
a88c3163 718(* PFN_API_PORT_ALLOC) (\r
719 IN ESL_PORT * pPort,\r
720 IN UINTN DebugFlags\r
d7ce7006 721 );\r
722\r
723/**\r
a88c3163 724 Close a network specific port.\r
d7ce7006 725\r
a88c3163 726 This routine releases the resources allocated by the\r
727 network specific PortAllocate routine.\r
728\r
729 This routine is called by ::EslSocketPortCloseRxDone as\r
730 the last step of closing processing.\r
731 See the \ref PortCloseStateMachine section.\r
732 \r
733 @param [in] pPort Address of an ::ESL_PORT structure.\r
734\r
735 @retval EFI_SUCCESS The port is closed\r
736 @retval other Port close error\r
d7ce7006 737\r
738**/\r
a88c3163 739typedef\r
d7ce7006 740EFI_STATUS\r
a88c3163 741(* PFN_API_PORT_CLOSE) (\r
742 IN ESL_PORT * pPort\r
d7ce7006 743 );\r
744\r
745/**\r
a88c3163 746 Perform the network specific close operation on the port.\r
d7ce7006 747\r
a88c3163 748 This routine performs the network specific operation to\r
749 shutdown receive operations on the port.\r
d7ce7006 750\r
a88c3163 751 This routine is called by the ::EslSocketPortCloseTxDone\r
752 routine after the port completes all of the transmission.\r
d7ce7006 753\r
a88c3163 754 @param [in] pPort Address of an ::ESL_PORT structure.\r
755\r
756 @retval EFI_SUCCESS The port is closed, not normally returned\r
d7ce7006 757 @retval EFI_NOT_READY The port is still closing\r
758 @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r
759 most likely the routine was called already.\r
760\r
761**/\r
a88c3163 762typedef\r
d7ce7006 763EFI_STATUS\r
a88c3163 764(* PFN_API_PORT_CLOSE_OP) (\r
765 IN ESL_PORT * pPort\r
d7ce7006 766 );\r
767\r
768/**\r
769 Receive data from a network connection.\r
770\r
a88c3163 771 This routine attempts to return buffered data to the caller. The\r
772 data is removed from the urgent queue if the message flag MSG_OOB\r
773 is specified, otherwise data is removed from the normal queue.\r
774 See the \ref ReceiveEngine section.\r
d7ce7006 775\r
a88c3163 776 This routine is called by ::EslSocketReceive to handle the network\r
777 specific receive operation.\r
778\r
779 @param [in] pPort Address of an ::ESL_PORT structure.\r
780\r
781 @param [in] pPacket Address of an ::ESL_PACKET structure.\r
d7ce7006 782 \r
a88c3163 783 @param [in] pbConsumePacket Address of a BOOLEAN indicating if the packet is to be consumed\r
d7ce7006 784 \r
785 @param [in] BufferLength Length of the the buffer\r
786 \r
787 @param [in] pBuffer Address of a buffer to receive the data.\r
788 \r
789 @param [in] pDataLength Number of received data bytes in the buffer.\r
790\r
791 @param [out] pAddress Network address to receive the remote system address\r
792\r
a88c3163 793 @param [out] pSkipBytes Address to receive the number of bytes skipped\r
d7ce7006 794\r
a88c3163 795 @return Returns the address of the next free byte in the buffer.\r
d7ce7006 796\r
797 **/\r
a88c3163 798typedef\r
799UINT8 *\r
800(* PFN_API_RECEIVE) (\r
801 IN ESL_PORT * pPort,\r
802 IN ESL_PACKET * pPacket,\r
803 IN BOOLEAN * pbConsumePacket,\r
d7ce7006 804 IN size_t BufferLength,\r
805 IN UINT8 * pBuffer,\r
806 OUT size_t * pDataLength,\r
807 OUT struct sockaddr * pAddress,\r
a88c3163 808 OUT size_t * pSkipBytes\r
d7ce7006 809 );\r
810\r
811/**\r
a88c3163 812 Get the remote socket address\r
d7ce7006 813\r
a88c3163 814 @param [in] pPort Address of an ::ESL_PORT structure.\r
d7ce7006 815\r
a88c3163 816 @param [out] pAddress Network address to receive the remote system address\r
817\r
818**/\r
819typedef\r
820VOID\r
821(* PFN_API_REMOTE_ADDR_GET) (\r
822 IN ESL_PORT * pPort,\r
823 OUT struct sockaddr * pAddress\r
d7ce7006 824 );\r
825\r
826/**\r
a88c3163 827 Set the remote address\r
d7ce7006 828\r
a88c3163 829 This routine sets the remote address in the port.\r
d7ce7006 830\r
a88c3163 831 This routine is called by ::EslSocketConnect to specify the\r
832 remote network address.\r
d7ce7006 833\r
a88c3163 834 @param [in] pPort Address of an ::ESL_PORT structure.\r
d7ce7006 835\r
a88c3163 836 @param [in] pSockAddr Network address of the remote system.\r
d7ce7006 837\r
a88c3163 838 @param [in] SockAddrLength Length in bytes of the network address.\r
d7ce7006 839\r
a88c3163 840 @retval EFI_SUCCESS The operation was successful\r
d7ce7006 841\r
842 **/\r
a88c3163 843typedef\r
844EFI_STATUS\r
845(* PFN_API_REMOTE_ADDR_SET) (\r
846 IN ESL_PORT * pPort,\r
847 IN CONST struct sockaddr * pSockAddr,\r
848 IN socklen_t SockAddrLength\r
d7ce7006 849 );\r
850\r
d7ce7006 851/**\r
a88c3163 852 Start a receive operation\r
d7ce7006 853\r
a88c3163 854 This routine prepares a packet for the receive operation.\r
855 See the \ref ReceiveEngine section.\r
d7ce7006 856\r
a88c3163 857 This support routine is called by EslSocketRxStart.\r
858\r
859 @param [in] pPort Address of an ::ESL_PORT structure.\r
860 @param [in] pIo Address of an ::ESL_IO_MGMT structure.\r
d7ce7006 861\r
862 **/\r
a88c3163 863typedef\r
864VOID\r
865(* PFN_API_RX_START) (\r
866 IN ESL_PORT * pPort,\r
867 IN ESL_IO_MGMT * pIo\r
d7ce7006 868 );\r
869\r
870/**\r
871 Buffer data for transmission over a network connection.\r
872\r
a88c3163 873 @param [in] pSocket Address of a ESL_SOCKET structure\r
d7ce7006 874\r
d7ce7006 875 @param [in] Flags Message control flags\r
a88c3163 876\r
d7ce7006 877 @param [in] BufferLength Length of the the buffer\r
a88c3163 878\r
d7ce7006 879 @param [in] pBuffer Address of a buffer to receive the data.\r
a88c3163 880\r
d7ce7006 881 @param [in] pDataLength Number of received data bytes in the buffer.\r
882\r
a88c3163 883 @param [in] pAddress Network address of the remote system address\r
884\r
885 @param [in] AddressLength Length of the remote network address structure\r
886\r
d7ce7006 887 @retval EFI_SUCCESS - Socket data successfully buffered\r
888\r
a88c3163 889**/\r
890typedef\r
d7ce7006 891EFI_STATUS\r
a88c3163 892(* PFN_API_TRANSMIT) (\r
893 IN ESL_SOCKET * pSocket,\r
d7ce7006 894 IN int Flags,\r
895 IN size_t BufferLength,\r
896 IN CONST UINT8 * pBuffer,\r
a88c3163 897 OUT size_t * pDataLength,\r
898 IN const struct sockaddr * pAddress,\r
899 IN socklen_t AddressLength\r
d7ce7006 900 );\r
901\r
902/**\r
a88c3163 903 Process the transmit completion\r
d7ce7006 904\r
a88c3163 905 This routine calls ::EslSocketTxComplete to handle the\r
906 transmit completion.\r
d7ce7006 907\r
a88c3163 908 This routine is called by the network layers upon the completion\r
909 of a transmit operation.\r
910\r
911 @param [in] Event The urgent transmit completion event\r
912\r
913 @param [in] pIo The ESL_IO_MGMT structure address\r
d7ce7006 914\r
915**/\r
a88c3163 916typedef\r
d7ce7006 917VOID\r
a88c3163 918(* PFN_API_TX_COMPLETE) (\r
d7ce7006 919 IN EFI_EVENT Event,\r
a88c3163 920 IN ESL_IO_MGMT * pIo\r
d7ce7006 921 );\r
922\r
923/**\r
a88c3163 924 Socket type control structure\r
925\r
926 This driver uses this structure to define the API for the socket type.\r
927**/\r
928typedef struct {\r
929 CONST CHAR8 * pName; ///< Protocol name\r
930 int DefaultProtocol; ///< Default protocol\r
931 UINTN ConfigDataOffset; ///< Offset in ::ESL_PORT to the configuration data\r
932 UINTN ServiceListOffset; ///< Offset in ::ESL_LAYER for the list of services\r
933 socklen_t MinimumAddressLength; ///< Minimum address length in bytes\r
934 socklen_t AddressLength; ///< Address length in bytes\r
935 sa_family_t AddressFamily; ///< Address family\r
936 UINTN RxPacketBytes; ///< Length of the RX packet allocation\r
937 UINTN RxZeroBytes; ///< Number of bytes to zero in RX packet\r
938 UINTN RxBufferOffset; ///< Offset of buffer address in ESL_IO_MGMT structure\r
939 BOOLEAN bOobSupported; ///< TRUE if out-of-band messages are supported\r
940 int BindTestErrno; ///< errno value if EslSocketBindTest fails\r
941 PFN_API_ACCEPT pfnAccept; ///< Accept a network connection\r
942 PFN_API_CONNECT_POLL pfnConnectPoll; ///< Poll for connection complete\r
943 PFN_API_CONNECT_START pfnConnectStart; ///< Start the connection to a remote system\r
944 PFN_API_IS_CONFIGURED pfnIsConfigured; ///< Determine if the socket is configured\r
945 PFN_API_LOCAL_ADDR_GET pfnLocalAddrGet; ///< Get the local address\r
946 PFN_API_LOCAL_ADDR_SET pfnLocalAddrSet; ///< Set the local address\r
947 PFN_API_LISTEN pfnListen; ///< Listen for connections on known server port\r
948 PFN_API_OPTION_GET pfnOptionGet; ///< Get the option value\r
949 PFN_API_OPTION_SET pfnOptionSet; ///< Set the option value\r
950 PFN_API_PACKET_FREE pfnPacketFree; ///< Free the receive packet\r
951 PFN_API_PORT_ALLOC pfnPortAllocate; ///< Allocate the network specific resources for the port\r
952 PFN_API_PORT_CLOSE pfnPortClose; ///< Close the network specific resources for the port\r
953 PFN_API_PORT_CLOSE_OP pfnPortCloseOp; ///< Perform the close operation on the port\r
954 BOOLEAN bPortCloseComplete; ///< TRUE = Close is complete after close operation\r
955 PFN_API_RECEIVE pfnReceive; ///< Attempt to receive some data\r
956 PFN_API_REMOTE_ADDR_GET pfnRemoteAddrGet; ///< Get remote address\r
957 PFN_API_REMOTE_ADDR_SET pfnRemoteAddrSet; ///< Set the remote system address\r
58081f2c 958 PFN_API_IO_COMPLETE pfnRxComplete; ///< RX completion\r
a88c3163 959 PFN_API_RX_START pfnRxStart; ///< Start a network specific receive operation\r
960 PFN_API_TRANSMIT pfnTransmit; ///< Attempt to buffer a packet for transmit\r
961 PFN_API_TX_COMPLETE pfnTxComplete; ///< TX completion for normal data\r
962 PFN_API_TX_COMPLETE pfnTxOobComplete; ///< TX completion for urgent data\r
963} ESL_PROTOCOL_API;\r
d7ce7006 964\r
d7ce7006 965\r
a88c3163 966/**\r
967 Socket control structure\r
d7ce7006 968\r
a88c3163 969 The driver uses this structure to manage the socket.\r
d7ce7006 970**/\r
a88c3163 971typedef struct _ESL_SOCKET {\r
972 UINTN Signature; ///< Structure identification\r
d7ce7006 973\r
a88c3163 974 //\r
975 // Protocol binding\r
976 //\r
977 EFI_SOCKET_PROTOCOL SocketProtocol; ///< Socket protocol declaration\r
978 CONST ESL_PROTOCOL_API * pApi; ///< API for the protocol\r
979\r
980 //\r
981 // Socket management\r
982 //\r
983 ESL_SOCKET * pNext; ///< Next socket in the list of sockets\r
984 int errno; ///< Error information for this socket\r
985 EFI_STATUS Status; ///< Asyncronous error information for this socket\r
986 SOCKET_STATE State; ///< Socket state\r
987 UINT32 DebugFlags; ///< Debug flags\r
d7ce7006 988\r
a88c3163 989 //\r
990 // Socket options\r
991 //\r
f74dc4bb 992 BOOLEAN bIncludeHeader; ///< TRUE if including the IP header\r
a88c3163 993 BOOLEAN bListenCalled; ///< TRUE if listen was successfully called\r
994 BOOLEAN bOobInLine; ///< TRUE if out-of-band messages are to be received inline with normal data\r
f74dc4bb 995 BOOLEAN bReUseAddr; ///< TRUE if using same address is allowed\r
d7ce7006 996\r
a88c3163 997 //\r
998 // Socket data\r
999 //\r
1000 int Domain; ///< Specifies family of protocols\r
1001 int Type; ///< Specifies how to make network connection\r
1002 int Protocol; ///< Specifies lower layer protocol to use\r
f74dc4bb 1003 BOOLEAN bAddressSet; ///< Set when the address is specified\r
a88c3163 1004 BOOLEAN bConfigured; ///< Set after the socket is configured\r
d7ce7006 1005\r
a88c3163 1006 BOOLEAN bRxDisable; ///< Receive disabled via shutdown\r
1007 size_t RxBytes; ///< Total Rx bytes\r
1008 size_t RxOobBytes; ///< Urgent Rx bytes\r
1009 EFI_STATUS RxError; ///< Error during receive\r
d7ce7006 1010\r
a88c3163 1011 BOOLEAN bTxDisable; ///< Transmit disabled via shutdown\r
1012 size_t TxBytes; ///< Normal Tx bytes\r
1013 size_t TxOobBytes; ///< Urgent Tx bytes\r
1014 EFI_STATUS TxError; ///< Error during transmit\r
1015\r
1016 //\r
1017 // Pending connection data\r
1018 //\r
1019 BOOLEAN bConnected; ///< Set when connected, cleared by poll\r
1020 EFI_STATUS ConnectStatus; ///< Connection status\r
1021 UINTN MaxFifoDepth; ///< Maximum FIFO depth\r
1022 UINTN FifoDepth; ///< Number of sockets in the FIFO\r
1023 ESL_SOCKET * pFifoHead; ///< Head of the FIFO\r
1024 ESL_SOCKET * pFifoTail; ///< Tail of the FIFO\r
1025 ESL_SOCKET * pNextConnection; ///< Link in the FIFO\r
1026\r
1027 //\r
1028 // Network use\r
1029 //\r
1030 ESL_PORT * pPortList; ///< List of ports managed by this socket\r
1031 EFI_EVENT WaitAccept; ///< Wait for accept completion\r
1032\r
1033 //\r
1034 // Receive data management\r
1035 //\r
1036 UINT32 MaxRxBuf; ///< Maximum size of the receive buffer\r
1037 struct timeval RxTimeout; ///< Receive timeout\r
1038 ESL_PACKET * pRxFree; ///< Free packet list\r
1039 ESL_PACKET * pRxOobPacketListHead;///< Urgent data list head\r
1040 ESL_PACKET * pRxOobPacketListTail;///< Urgent data list tail\r
1041 ESL_PACKET * pRxPacketListHead; ///< Normal data list head\r
1042 ESL_PACKET * pRxPacketListTail; ///< Normal data list tail\r
1043\r
1044 //\r
1045 // Transmit data management\r
1046 //\r
1047 UINTN TxPacketOffset; ///< Offset for data pointer in ::ESL_PACKET\r
1048 UINTN TxTokenEventOffset; ///< Offset to the Event in the TX token\r
1049 UINTN TxTokenOffset; ///< Offset for data pointer in TX token\r
1050 UINT32 MaxTxBuf; ///< Maximum size of the transmit buffer\r
1051 ESL_PACKET * pTxOobPacketListHead;///< Urgent data list head\r
1052 ESL_PACKET * pTxOobPacketListTail;///< Urgent data list tail\r
1053 ESL_PACKET * pTxPacketListHead; ///< Normal data list head\r
1054 ESL_PACKET * pTxPacketListTail; ///< Normal data list tail\r
1055}GCC_ESL_SOCKET;\r
1056\r
1057#define SOCKET_FROM_PROTOCOL(a) CR (a, ESL_SOCKET, SocketProtocol, SOCKET_SIGNATURE) ///< Locate ESL_SOCKET from protocol\r
d7ce7006 1058\r
1059/**\r
a88c3163 1060 Socket layer control structure\r
d7ce7006 1061\r
a88c3163 1062 The driver uses this structure to manage the driver.\r
1063**/\r
1064typedef struct {\r
1065 UINTN Signature; ///< Structure identification\r
d7ce7006 1066\r
a88c3163 1067 //\r
1068 // Service binding interface\r
1069 //\r
1070 CONST EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Driver's binding\r
d7ce7006 1071\r
a88c3163 1072 //\r
1073 // Image data\r
1074 //\r
1075 EFI_HANDLE ImageHandle; ///< Image handle\r
d7ce7006 1076\r
a88c3163 1077 //\r
1078 // Network services\r
1079 //\r
1080 ESL_SERVICE * pIp4List; ///< List of Ip4 services\r
1081 ESL_SERVICE * pTcp4List; ///< List of Tcp4 services\r
3bdf9aae 1082 ESL_SERVICE * pTcp6List; ///< List of Tcp6 services\r
a88c3163 1083 ESL_SERVICE * pUdp4List; ///< List of Udp4 services\r
3bdf9aae 1084 ESL_SERVICE * pUdp6List; ///< List of Udp6 services\r
d7ce7006 1085\r
a88c3163 1086 //\r
1087 // Socket management\r
1088 //\r
1089 ESL_SOCKET * pSocketList; ///< List of sockets\r
1090} ESL_LAYER;\r
d7ce7006 1091\r
a88c3163 1092#define LAYER_FROM_SERVICE(a) CR (a, ESL_LAYER, ServiceBinding, LAYER_SIGNATURE) ///< Locate ESL_LAYER from service binding\r
d7ce7006 1093\r
a88c3163 1094//------------------------------------------------------------------------------\r
1095// Data\r
1096//------------------------------------------------------------------------------\r
1097\r
1098extern ESL_LAYER mEslLayer;\r
1099\r
1100extern CONST ESL_PROTOCOL_API cEslIp4Api;\r
3bdf9aae 1101extern CONST ESL_PROTOCOL_API cEslIp6Api;\r
a88c3163 1102extern CONST ESL_PROTOCOL_API cEslTcp4Api;\r
3bdf9aae 1103extern CONST ESL_PROTOCOL_API cEslTcp6Api;\r
a88c3163 1104extern CONST ESL_PROTOCOL_API cEslUdp4Api;\r
3bdf9aae 1105extern CONST ESL_PROTOCOL_API cEslUdp6Api;\r
d7ce7006 1106\r
a88c3163 1107extern CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding;\r
d7ce7006 1108\r
a88c3163 1109//------------------------------------------------------------------------------\r
1110// Socket Support Routines\r
1111//------------------------------------------------------------------------------\r
1112\r
1113/**\r
1114 Allocate and initialize a ESL_SOCKET structure.\r
1115 \r
1116 This support function allocates an ::ESL_SOCKET structure\r
1117 and installs a protocol on ChildHandle. If pChildHandle is a\r
1118 pointer to NULL, then a new handle is created and returned in\r
1119 pChildHandle. If pChildHandle is not a pointer to NULL, then\r
1120 the protocol installs on the existing pChildHandle.\r
d7ce7006 1121\r
a88c3163 1122 @param [in, out] pChildHandle Pointer to the handle of the child to create.\r
1123 If it is NULL, then a new handle is created.\r
1124 If it is a pointer to an existing UEFI handle, \r
1125 then the protocol is added to the existing UEFI\r
1126 handle.\r
1127 @param [in] DebugFlags Flags for debug messages\r
1128 @param [in, out] ppSocket The buffer to receive an ::ESL_SOCKET structure address.\r
d7ce7006 1129\r
a88c3163 1130 @retval EFI_SUCCESS The protocol was added to ChildHandle.\r
1131 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
1132 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create\r
1133 the child\r
1134 @retval other The child handle was not created\r
1135 \r
d7ce7006 1136**/\r
1137EFI_STATUS\r
1138EFIAPI\r
a88c3163 1139EslSocketAllocate (\r
1140 IN OUT EFI_HANDLE * pChildHandle,\r
1141 IN UINTN DebugFlags,\r
1142 IN OUT ESL_SOCKET ** ppSocket\r
d7ce7006 1143 );\r
1144\r
1145/**\r
a88c3163 1146 Test the bind configuration.\r
d7ce7006 1147\r
a88c3163 1148 @param [in] pPort Address of the ::ESL_PORT structure.\r
1149 @param [in] ErrnoValue errno value if test fails\r
d7ce7006 1150\r
a88c3163 1151 @retval EFI_SUCCESS The connection was successfully established.\r
1152 @retval Others The connection attempt failed.\r
d7ce7006 1153\r
1154 **/\r
1155EFI_STATUS\r
a88c3163 1156EslSocketBindTest (\r
1157 IN ESL_PORT * pPort,\r
1158 IN int ErrnoValue\r
d7ce7006 1159 );\r
1160\r
1161/**\r
a88c3163 1162 Copy a fragmented buffer into a destination buffer.\r
d7ce7006 1163\r
a88c3163 1164 This support routine copies a fragmented buffer to the caller specified buffer.\r
d7ce7006 1165\r
a88c3163 1166 This routine is called by ::EslIp4Receive and ::EslUdp4Receive.\r
d7ce7006 1167\r
a88c3163 1168 @param [in] FragmentCount Number of fragments in the table\r
d7ce7006 1169\r
a88c3163 1170 @param [in] pFragmentTable Address of an EFI_IP4_FRAGMENT_DATA structure\r
d7ce7006 1171\r
a88c3163 1172 @param [in] BufferLength Length of the the buffer\r
d7ce7006 1173\r
a88c3163 1174 @param [in] pBuffer Address of a buffer to receive the data.\r
1175\r
1176 @param [in] pDataLength Number of received data bytes in the buffer.\r
1177\r
1178 @return Returns the address of the next free byte in the buffer.\r
d7ce7006 1179\r
1180**/\r
a88c3163 1181UINT8 *\r
1182EslSocketCopyFragmentedBuffer (\r
1183 IN UINT32 FragmentCount,\r
1184 IN EFI_IP4_FRAGMENT_DATA * pFragmentTable,\r
1185 IN size_t BufferLength,\r
1186 IN UINT8 * pBuffer,\r
1187 OUT size_t * pDataLength\r
d7ce7006 1188 );\r
1189\r
4652be0c 1190/**\r
1191 Free the socket.\r
1192\r
1193 This routine frees the socket structure and handle resources.\r
1194\r
1195 The ::close routine calls EslServiceFreeProtocol which then calls\r
1196 this routine to free the socket context structure and close the\r
1197 handle.\r
1198\r
1199 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
1200 \r
1201 @param [out] pErrno Address to receive the errno value upon completion.\r
1202\r
1203 @retval EFI_SUCCESS The socket resources were returned successfully.\r
1204\r
1205 **/\r
1206EFI_STATUS\r
1207EslSocketFree (\r
1208 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
1209 IN int * pErrno\r
1210 );\r
1211\r
d7ce7006 1212/**\r
a88c3163 1213 Free the ESL_IO_MGMT event and structure\r
d7ce7006 1214\r
a88c3163 1215 This support routine walks the free list to close the event in\r
1216 the ESL_IO_MGMT structure and remove the structure from the free\r
1217 list.\r
d7ce7006 1218\r
a88c3163 1219 See the \ref TransmitEngine section.\r
d7ce7006 1220\r
a88c3163 1221 @param [in] pPort Address of an ::ESL_PORT structure\r
1222 @param [in] ppFreeQueue Address of the free queue head\r
1223 @param [in] DebugFlags Flags for debug messages\r
1224 @param [in] pEventName Zero terminated string containing the event name\r
1225\r
1226 @retval EFI_SUCCESS - The structures were properly initialized\r
d7ce7006 1227\r
1228**/\r
1229EFI_STATUS\r
a88c3163 1230EslSocketIoFree (\r
1231 IN ESL_PORT * pPort,\r
1232 IN ESL_IO_MGMT ** ppFreeQueue,\r
1233 IN UINTN DebugFlags,\r
1234 IN CHAR8 * pEventName\r
d7ce7006 1235 );\r
1236\r
1237/**\r
a88c3163 1238 Initialize the ESL_IO_MGMT structures\r
d7ce7006 1239\r
a88c3163 1240 This support routine initializes the ESL_IO_MGMT structure and\r
1241 places them on to a free list.\r
d7ce7006 1242\r
a88c3163 1243 This routine is called by the PortAllocate routines to prepare\r
1244 the transmit engines. See the \ref TransmitEngine section.\r
d7ce7006 1245\r
a88c3163 1246 @param [in] pPort Address of an ::ESL_PORT structure\r
1247 @param [in, out] ppIo Address containing the first structure address. Upon\r
1248 return this buffer contains the next structure address.\r
1249 @param [in] TokenCount Number of structures to initialize\r
1250 @param [in] ppFreeQueue Address of the free queue head\r
1251 @param [in] DebugFlags Flags for debug messages\r
1252 @param [in] pEventName Zero terminated string containing the event name\r
1253 @param [in] pfnCompletion Completion routine address\r
d7ce7006 1254\r
a88c3163 1255 @retval EFI_SUCCESS - The structures were properly initialized\r
1256\r
1257**/\r
d7ce7006 1258EFI_STATUS\r
a88c3163 1259EslSocketIoInit (\r
1260 IN ESL_PORT * pPort,\r
1261 IN ESL_IO_MGMT ** ppIo,\r
1262 IN UINTN TokenCount,\r
1263 IN ESL_IO_MGMT ** ppFreeQueue,\r
1264 IN UINTN DebugFlags,\r
1265 IN CHAR8 * pEventName,\r
58081f2c 1266 IN PFN_API_IO_COMPLETE pfnCompletion\r
d7ce7006 1267 );\r
1268\r
1269/**\r
a88c3163 1270 Determine if the socket is configured\r
d7ce7006 1271\r
a88c3163 1272 This support routine is called to determine if the socket if the\r
1273 configuration call was made to the network layer. The following\r
1274 routines call this routine to verify that they may be successful\r
1275 in their operations:\r
1276 <ul>\r
1277 <li>::EslSocketGetLocalAddress</li>\r
1278 <li>::EslSocketGetPeerAddress</li>\r
1279 <li>::EslSocketPoll</li>\r
1280 <li>::EslSocketReceive</li>\r
1281 <li>::EslSocketTransmit</li>\r
1282 </ul>\r
d7ce7006 1283\r
a88c3163 1284 @param [in] pSocket Address of an ::ESL_SOCKET structure\r
d7ce7006 1285\r
a88c3163 1286 @retval EFI_SUCCESS - The socket is configured\r
d7ce7006 1287\r
1288**/\r
1289EFI_STATUS\r
a88c3163 1290EslSocketIsConfigured (\r
1291 IN ESL_SOCKET * pSocket\r
d7ce7006 1292 );\r
1293\r
1294/**\r
a88c3163 1295 Allocate a packet for a receive or transmit operation\r
d7ce7006 1296\r
a88c3163 1297 This support routine is called by ::EslSocketRxStart and the\r
1298 network specific TxBuffer routines to get buffer space for the\r
1299 next operation.\r
d7ce7006 1300\r
a88c3163 1301 @param [in] ppPacket Address to receive the ::ESL_PACKET structure\r
1302 @param [in] LengthInBytes Length of the packet structure\r
1303 @param [in] ZeroBytes Length of packet to zero\r
1304 @param [in] DebugFlags Flags for debug messages\r
d7ce7006 1305\r
a88c3163 1306 @retval EFI_SUCCESS - The packet was allocated successfully\r
d7ce7006 1307\r
a88c3163 1308 **/\r
d7ce7006 1309EFI_STATUS\r
a88c3163 1310EslSocketPacketAllocate (\r
1311 IN ESL_PACKET ** ppPacket,\r
1312 IN size_t LengthInBytes,\r
1313 IN size_t ZeroBytes,\r
1314 IN UINTN DebugFlags\r
d7ce7006 1315 );\r
1316\r
1317/**\r
a88c3163 1318 Free a packet used for receive or transmit operation\r
d7ce7006 1319\r
a88c3163 1320 This support routine is called by the network specific Close\r
1321 and TxComplete routines and during error cases in RxComplete\r
1322 and TxBuffer. Note that the network layers typically place\r
1323 receive packets on the ESL_SOCKET::pRxFree list for reuse.\r
d7ce7006 1324\r
a88c3163 1325 @param [in] pPacket Address of an ::ESL_PACKET structure\r
1326 @param [in] DebugFlags Flags for debug messages\r
d7ce7006 1327\r
a88c3163 1328 @retval EFI_SUCCESS - The packet was allocated successfully\r
d7ce7006 1329\r
a88c3163 1330 **/\r
1331EFI_STATUS\r
1332EslSocketPacketFree (\r
1333 IN ESL_PACKET * pPacket,\r
1334 IN UINTN DebugFlags\r
1335 );\r
d7ce7006 1336\r
a88c3163 1337/**\r
1338 Allocate and initialize a ESL_PORT structure.\r
d7ce7006 1339\r
a88c3163 1340 This routine initializes an ::ESL_PORT structure for use by\r
1341 the socket. This routine calls a routine via\r
1342 ESL_PROTOCOL_API::pfnPortAllocate to initialize the network\r
1343 specific resources. The resources are released later by the\r
1344 \ref PortCloseStateMachine.\r
d7ce7006 1345\r
a88c3163 1346 This support routine is called by ::EslSocketBind and\r
1347 ::EslTcp4ListenComplete to connect the socket with the\r
1348 underlying network adapter to the socket.\r
d7ce7006 1349\r
a88c3163 1350 @param [in] pSocket Address of an ::ESL_SOCKET structure.\r
1351 @param [in] pService Address of an ::ESL_SERVICE structure.\r
1352 @param [in] ChildHandle TCP4 child handle\r
1353 @param [in] pSockAddr Address of a sockaddr structure that contains the\r
1354 connection point on the local machine. An IPv4 address\r
1355 of INADDR_ANY specifies that the connection is made to\r
1356 all of the network stacks on the platform. Specifying a\r
1357 specific IPv4 address restricts the connection to the\r
1358 network stack supporting that address. Specifying zero\r
1359 for the port causes the network layer to assign a port\r
1360 number from the dynamic range. Specifying a specific\r
1361 port number causes the network layer to use that port.\r
1362 @param [in] bBindTest TRUE if EslSocketBindTest should be called\r
1363 @param [in] DebugFlags Flags for debug messages\r
1364 @param [out] ppPort Buffer to receive new ::ESL_PORT structure address\r
d7ce7006 1365\r
a88c3163 1366 @retval EFI_SUCCESS - Socket successfully created\r
d7ce7006 1367\r
a88c3163 1368 **/\r
d7ce7006 1369EFI_STATUS\r
a88c3163 1370EslSocketPortAllocate (\r
1371 IN ESL_SOCKET * pSocket,\r
1372 IN ESL_SERVICE * pService,\r
1373 IN EFI_HANDLE ChildHandle,\r
1374 IN CONST struct sockaddr * pSockAddr,\r
1375 IN BOOLEAN bBindTest,\r
1376 IN UINTN DebugFlags,\r
1377 OUT ESL_PORT ** ppPort\r
d7ce7006 1378 );\r
1379\r
1380/**\r
a88c3163 1381 Close a port.\r
1382\r
1383 This routine releases the resources allocated by ::EslSocketPortAllocate.\r
1384 This routine calls ESL_PROTOCOL_API::pfnPortClose to release the network\r
1385 specific resources.\r
1386\r
1387 This routine is called by:\r
1388 <ul>\r
1389 <li>::EslIp4PortAllocate - Port initialization failure</li>\r
1390 <li>::EslSocketPortCloseRxDone - Last step of close processing</li>\r
1391 <li>::EslTcp4ConnectComplete - Connection failure and reducint the port list to a single port</li>\r
1392 <li>::EslTcp4PortAllocate - Port initialization failure</li>\r
1393 <li>::EslUdp4PortAllocate - Port initialization failure</li>\r
1394 </ul>\r
1395 See the \ref PortCloseStateMachine section.\r
d7ce7006 1396 \r
a88c3163 1397 @param [in] pPort Address of an ::ESL_PORT structure.\r
d7ce7006 1398\r
a88c3163 1399 @retval EFI_SUCCESS The port is closed\r
1400 @retval other Port close error\r
1401\r
1402**/\r
d7ce7006 1403EFI_STATUS\r
a88c3163 1404EslSocketPortClose (\r
1405 IN ESL_PORT * pPort\r
d7ce7006 1406 );\r
1407\r
1408/**\r
a88c3163 1409 Process the port close completion event\r
d7ce7006 1410\r
a88c3163 1411 This routine attempts to complete the port close operation.\r
d7ce7006 1412\r
a88c3163 1413 This routine is called by the TCP layer upon completion of\r
1414 the close operation.\r
1415 See the \ref PortCloseStateMachine section.\r
d7ce7006 1416\r
a88c3163 1417 @param [in] Event The close completion event\r
1418\r
1419 @param [in] pPort Address of an ::ESL_PORT structure.\r
d7ce7006 1420\r
1421**/\r
1422VOID\r
a88c3163 1423EslSocketPortCloseComplete (\r
d7ce7006 1424 IN EFI_EVENT Event,\r
a88c3163 1425 IN ESL_PORT * pPort\r
d7ce7006 1426 );\r
1427\r
1428/**\r
a88c3163 1429 Port close state 3\r
d7ce7006 1430\r
a88c3163 1431 This routine determines the state of the receive operations and\r
1432 continues the close operation after the pending receive operations\r
1433 are cancelled.\r
d7ce7006 1434\r
a88c3163 1435 This routine is called by\r
1436 <ul>\r
1437 <li>::EslIp4RxComplete</li>\r
1438 <li>::EslSocketPortCloseComplete</li>\r
1439 <li>::EslSocketPortCloseTxDone</li>\r
1440 <li>::EslUdp4RxComplete</li>\r
1441 </ul>\r
1442 to determine the state of the receive operations.\r
1443 See the \ref PortCloseStateMachine section.\r
1444\r
1445 @param [in] pPort Address of an ::ESL_PORT structure.\r
1446\r
1447 @retval EFI_SUCCESS The port is closed\r
1448 @retval EFI_NOT_READY The port is still closing\r
1449 @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r
1450 most likely the routine was called already.\r
1451\r
1452**/\r
1453EFI_STATUS\r
1454EslSocketPortCloseRxDone (\r
1455 IN ESL_PORT * pPort\r
d7ce7006 1456 );\r
1457\r
1458/**\r
a88c3163 1459 Start the close operation on a port, state 1.\r
d7ce7006 1460\r
a88c3163 1461 This routine marks the port as closed and initiates the \ref\r
1462 PortCloseStateMachine. The first step is to allow the \ref\r
1463 TransmitEngine to run down.\r
d7ce7006 1464\r
a88c3163 1465 This routine is called by ::EslSocketCloseStart to initiate the socket\r
1466 network specific close operation on the socket.\r
d7ce7006 1467\r
a88c3163 1468 @param [in] pPort Address of an ::ESL_PORT structure.\r
1469 @param [in] bCloseNow Set TRUE to abort active transfers\r
1470 @param [in] DebugFlags Flags for debug messages\r
1471\r
1472 @retval EFI_SUCCESS The port is closed, not normally returned\r
1473 @retval EFI_NOT_READY The port has started the closing process\r
1474 @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r
1475 most likely the routine was called already.\r
1476\r
1477**/\r
1478EFI_STATUS\r
1479EslSocketPortCloseStart (\r
1480 IN ESL_PORT * pPort,\r
1481 IN BOOLEAN bCloseNow,\r
1482 IN UINTN DebugFlags\r
d7ce7006 1483 );\r
1484\r
1485/**\r
a88c3163 1486 Port close state 2\r
1487\r
1488 This routine determines the state of the transmit engine and\r
1489 continue the close operation after the transmission is complete.\r
1490 The next step is to stop the \ref ReceiveEngine.\r
1491 See the \ref PortCloseStateMachine section.\r
d7ce7006 1492\r
a88c3163 1493 This routine is called by ::EslSocketPortCloseStart to determine\r
1494 if the transmission is complete.\r
d7ce7006 1495\r
a88c3163 1496 @param [in] pPort Address of an ::ESL_PORT structure.\r
1497\r
1498 @retval EFI_SUCCESS The port is closed, not normally returned\r
1499 @retval EFI_NOT_READY The port is still closing\r
1500 @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r
1501 most likely the routine was called already.\r
d7ce7006 1502\r
1503**/\r
a88c3163 1504EFI_STATUS\r
1505EslSocketPortCloseTxDone (\r
1506 IN ESL_PORT * pPort\r
d7ce7006 1507 );\r
1508\r
1509/**\r
a88c3163 1510 Cancel the receive operations\r
d7ce7006 1511\r
a88c3163 1512 This routine cancels a pending receive operation.\r
1513 See the \ref ReceiveEngine section.\r
d7ce7006 1514\r
a88c3163 1515 This routine is called by ::EslSocketShutdown when the socket\r
1516 layer is being shutdown.\r
d7ce7006 1517\r
a88c3163 1518 @param [in] pPort Address of an ::ESL_PORT structure\r
1519 @param [in] pIo Address of an ::ESL_IO_MGMT structure\r
1520\r
1521 **/\r
d7ce7006 1522VOID\r
a88c3163 1523EslSocketRxCancel (\r
1524 IN ESL_PORT * pPort,\r
1525 IN ESL_IO_MGMT * pIo\r
d7ce7006 1526 );\r
1527\r
1528/**\r
a88c3163 1529 Process the receive completion\r
d7ce7006 1530\r
a88c3163 1531 This routine queues the data in FIFO order in either the urgent\r
1532 or normal data queues depending upon the type of data received.\r
1533 See the \ref ReceiveEngine section.\r
d7ce7006 1534\r
a88c3163 1535 This routine is called when some data is received by:\r
1536 <ul>\r
1537 <li>::EslIp4RxComplete</li>\r
1538 <li>::EslTcp4RxComplete</li>\r
1539 <li>::EslUdp4RxComplete</li>\r
1540 </ul>\r
d7ce7006 1541\r
a88c3163 1542 @param [in] pIo Address of an ::ESL_IO_MGMT structure\r
1543 @param [in] Status Receive status\r
1544 @param [in] LengthInBytes Length of the receive data\r
1545 @param [in] bUrgent TRUE if urgent data is received and FALSE\r
1546 for normal data.\r
d7ce7006 1547\r
a88c3163 1548**/\r
1549VOID\r
1550EslSocketRxComplete (\r
1551 IN ESL_IO_MGMT * pIo,\r
1552 IN EFI_STATUS Status,\r
1553 IN UINTN LengthInBytes,\r
1554 IN BOOLEAN bUrgent\r
1555 );\r
d7ce7006 1556\r
3bdf9aae 1557/**\r
1558 Poll a socket for pending receive activity.\r
1559\r
1560 This routine is called at elivated TPL and extends the idle\r
1561 loop which polls a socket down into the LAN driver layer to\r
1562 determine if there is any receive activity.\r
1563\r
1564 The ::EslSocketPoll, ::EslSocketReceive and ::EslSocketTransmit\r
1565 routines call this routine when there is nothing to do.\r
1566\r
1567 @param [in] pSocket Address of an ::EFI_SOCKET structure.\r
1568\r
1569 **/\r
1570VOID\r
1571EslSocketRxPoll (\r
1572 IN ESL_SOCKET * pSocket\r
1573 );\r
1574\r
a88c3163 1575/**\r
1576 Start a receive operation\r
d7ce7006 1577\r
a88c3163 1578 This routine posts a receive buffer to the network adapter.\r
1579 See the \ref ReceiveEngine section.\r
d7ce7006 1580\r
a88c3163 1581 This support routine is called by:\r
1582 <ul>\r
1583 <li>::EslIp4Receive to restart the receive engine to release flow control.</li>\r
1584 <li>::EslIp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>\r
1585 <li>::EslIp4SocketIsConfigured to start the recevie engine for the new socket.</li>\r
1586 <li>::EslTcp4ListenComplete to start the recevie engine for the new socket.</li>\r
1587 <li>::EslTcp4Receive to restart the receive engine to release flow control.</li>\r
1588 <li>::EslTcp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>\r
1589 <li>::EslUdp4Receive to restart the receive engine to release flow control.</li>\r
1590 <li>::EslUdp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>\r
1591 <li>::EslUdp4SocketIsConfigured to start the recevie engine for the new socket.</li>\r
1592 </ul>\r
d7ce7006 1593\r
a88c3163 1594 @param [in] pPort Address of an ::ESL_PORT structure.\r
d7ce7006 1595\r
a88c3163 1596 **/\r
1597VOID\r
1598EslSocketRxStart (\r
1599 IN ESL_PORT * pPort\r
1600 );\r
d7ce7006 1601\r
a88c3163 1602/**\r
1603 Complete the transmit operation\r
1604\r
1605 This support routine handles the transmit completion processing for\r
1606 the various network layers. It frees the ::ESL_IO_MGMT structure\r
1607 and and frees packet resources by calling ::EslSocketPacketFree.\r
1608 Transmit errors are logged in ESL_SOCKET::TxError.\r
1609 See the \ref TransmitEngine section.\r
1610\r
1611 This routine is called by:\r
1612 <ul>\r
1613 <li>::EslIp4TxComplete</li>\r
1614 <li>::EslTcp4TxComplete</li>\r
1615 <li>::EslTcp4TxOobComplete</li>\r
1616 <li>::EslUdp4TxComplete</li>\r
1617 </ul>\r
1618\r
1619 @param [in] pIo Address of an ::ESL_IO_MGMT structure\r
1620 @param [in] LengthInBytes Length of the data in bytes\r
1621 @param [in] Status Transmit operation status\r
1622 @param [in] pQueueType Zero terminated string describing queue type\r
1623 @param [in] ppQueueHead Transmit queue head address\r
1624 @param [in] ppQueueTail Transmit queue tail address\r
1625 @param [in] ppActive Active transmit queue address\r
1626 @param [in] ppFree Free transmit queue address\r
d7ce7006 1627\r
a88c3163 1628 **/\r
1629VOID\r
1630EslSocketTxComplete (\r
1631 IN ESL_IO_MGMT * pIo,\r
1632 IN UINT32 LengthInBytes,\r
1633 IN EFI_STATUS Status,\r
1634 IN CONST CHAR8 * pQueueType,\r
1635 IN ESL_PACKET ** ppQueueHead,\r
1636 IN ESL_PACKET ** ppQueueTail,\r
1637 IN ESL_IO_MGMT ** ppActive,\r
1638 IN ESL_IO_MGMT ** ppFree\r
d7ce7006 1639 );\r
1640\r
1641/**\r
1642 Transmit data using a network connection.\r
1643\r
a88c3163 1644 This support routine starts a transmit operation on the\r
1645 underlying network layer.\r
1646\r
1647 The network specific code calls this routine to start a\r
1648 transmit operation. See the \ref TransmitEngine section.\r
1649\r
1650 @param [in] pPort Address of an ::ESL_PORT structure\r
1651 @param [in] ppQueueHead Transmit queue head address\r
1652 @param [in] ppQueueTail Transmit queue tail address\r
1653 @param [in] ppActive Active transmit queue address\r
1654 @param [in] ppFree Free transmit queue address\r
d7ce7006 1655\r
1656 **/\r
1657VOID\r
a88c3163 1658EslSocketTxStart (\r
1659 IN ESL_PORT * pPort,\r
1660 IN ESL_PACKET ** ppQueueHead,\r
1661 IN ESL_PACKET ** ppQueueTail,\r
1662 IN ESL_IO_MGMT ** ppActive,\r
1663 IN ESL_IO_MGMT ** ppFree\r
d7ce7006 1664 );\r
1665\r
1666//------------------------------------------------------------------------------\r
1667\r
1668#endif // _SOCKET_H_\r