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