]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/Include/Efi/EfiSocketLib.h
Merged socket development branch:
[mirror_edk2.git] / StdLib / Include / Efi / EfiSocketLib.h
CommitLineData
d7ce7006 1/** @file\r
2 Definitions for the EFI Socket layer library.\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\r
15#ifndef _EFI_SOCKET_LIB_H_\r
16#define _EFI_SOCKET_LIB_H_\r
17\r
18#include <Uefi.h>\r
19\r
20#include <Library/BaseMemoryLib.h>\r
21#include <Library/DebugLib.h>\r
a88c3163 22#include <Library/MemoryAllocationLib.h>\r
d7ce7006 23#include <Library/UefiBootServicesTableLib.h>\r
24#include <Library/UefiLib.h>\r
25\r
26#include <Protocol/EfiSocket.h>\r
27#include <Protocol/ServiceBinding.h>\r
28#include <Protocol/Tcp4.h>\r
3bdf9aae 29#include <Protocol/Tcp6.h>\r
d7ce7006 30#include <Protocol/Udp4.h>\r
3bdf9aae 31#include <Protocol/Udp6.h>\r
d7ce7006 32\r
33#include <sys/time.h>\r
34\r
35//------------------------------------------------------------------------------\r
36// Constants\r
37//------------------------------------------------------------------------------\r
38\r
39#define DEBUG_TPL 0x40000000 ///< Display TPL change messages\r
40\r
41#define TPL_SOCKETS TPL_CALLBACK ///< TPL for routine synchronization\r
42\r
43//------------------------------------------------------------------------------\r
44// Macros\r
45//------------------------------------------------------------------------------\r
46\r
47#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */\r
48#define DBG_ENTER() DEBUG (( DEBUG_INFO, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry\r
49#define DBG_EXIT() DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ "\n" )) ///< Display routine exit\r
50#define DBG_EXIT_DEC(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value\r
51#define DBG_EXIT_HEX(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value\r
52#define DBG_EXIT_STATUS(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value\r
53#define DBG_EXIT_TF(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value\r
54#else // _MSC_VER\r
a88c3163 55#define DBG_ENTER() ///< Display routine entry\r
56#define DBG_EXIT() ///< Display routine exit\r
57#define DBG_EXIT_DEC(Status) ///< Display routine exit with decimal value\r
58#define DBG_EXIT_HEX(Status) ///< Display routine exit with hex value\r
59#define DBG_EXIT_STATUS(Status) ///< Display routine exit with status value\r
60#define DBG_EXIT_TF(Status) ///< Display routine with TRUE/FALSE value\r
d7ce7006 61#endif // _MSC_VER\r
62\r
63#define DIM(x) ( sizeof ( x ) / sizeof ( x[0] )) ///< Compute the number of entries in an array\r
64\r
65/**\r
66 Verify new TPL value\r
67\r
68 This macro which is enabled when debug is enabled verifies that\r
69 the new TPL value is >= the current TPL value.\r
70**/\r
71#ifdef VERIFY_TPL\r
72#undef VERIFY_TPL\r
73#endif // VERIFY_TPL\r
74\r
75#if !defined(MDEPKG_NDEBUG)\r
76\r
a88c3163 77/**\r
78 Verify that the TPL is at the correct level\r
79**/\r
80#define VERIFY_AT_TPL(tpl) \\r
81{ \\r
82 EFI_TPL PreviousTpl; \\r
83 \\r
84 PreviousTpl = EfiGetCurrentTpl ( ); \\r
85 if ( PreviousTpl != tpl ) { \\r
86 DEBUG (( DEBUG_ERROR | DEBUG_TPL, \\r
87 "Current TPL: %d, New TPL: %d\r\n", \\r
88 PreviousTpl, tpl )); \\r
89 ASSERT ( PreviousTpl == tpl ); \\r
90 } \\r
91}\r
92\r
d7ce7006 93#define VERIFY_TPL(tpl) \\r
94{ \\r
95 EFI_TPL PreviousTpl; \\r
96 \\r
a88c3163 97 PreviousTpl = EfiGetCurrentTpl ( ); \\r
d7ce7006 98 if ( PreviousTpl > tpl ) { \\r
99 DEBUG (( DEBUG_ERROR | DEBUG_TPL, \\r
100 "Current TPL: %d, New TPL: %d\r\n", \\r
101 PreviousTpl, tpl )); \\r
102 ASSERT ( PreviousTpl <= tpl ); \\r
103 } \\r
104}\r
105\r
106#else // MDEPKG_NDEBUG\r
107\r
a88c3163 108#define VERIFY_AT_TPL(tpl) ///< Verify that the TPL is at the correct level\r
109#define VERIFY_TPL(tpl) ///< Verify that the TPL is at the correct level\r
d7ce7006 110\r
111#endif // MDEPKG_NDEBUG\r
112\r
a88c3163 113/**\r
114 Raise TPL to the specified level\r
115**/\r
d7ce7006 116#define RAISE_TPL(PreviousTpl, tpl) \\r
117 VERIFY_TPL ( tpl ); \\r
118 PreviousTpl = gBS->RaiseTPL ( tpl ); \\r
119 DEBUG (( DEBUG_TPL | DEBUG_TPL, \\r
120 "%d: TPL\r\n", \\r
121 tpl ))\r
122\r
a88c3163 123/**\r
124 Restore the TPL to the previous value\r
125**/\r
d7ce7006 126#define RESTORE_TPL(tpl) \\r
d7ce7006 127 DEBUG (( DEBUG_TPL | DEBUG_TPL, \\r
128 "%d: TPL\r\n", \\r
a88c3163 129 tpl )); \\r
130 gBS->RestoreTPL ( tpl )\r
d7ce7006 131\r
132//------------------------------------------------------------------------------\r
133// Data Types\r
134//------------------------------------------------------------------------------\r
135\r
a88c3163 136typedef struct _ESL_SERVICE ESL_SERVICE; ///< Forward delcaration\r
d7ce7006 137\r
138/**\r
139 Protocol binding and installation control structure\r
140\r
141 The driver uses this structure to simplify the driver binding processing.\r
142**/\r
143typedef struct {\r
144 CHAR16 * pName; ///< Protocol name\r
145 EFI_GUID * pNetworkBinding; ///< Network service binding protocol for socket support\r
a88c3163 146 EFI_GUID * pNetworkProtocolGuid;///< Network protocol GUID\r
d7ce7006 147 CONST EFI_GUID * pTagGuid; ///< Tag to mark protocol in use\r
a88c3163 148 UINTN ServiceListOffset; ///< Offset in ::ESL_LAYER for the list of services\r
149 UINTN RxIo; ///< Number of receive ESL_IO_MGMT structures for data\r
150 UINTN TxIoNormal; ///< Number of transmit ESL_IO_MGMT structures for normal data\r
151 UINTN TxIoUrgent; ///< Number of transmit ESL_IO_MGMT structures for urgent data\r
152} ESL_SOCKET_BINDING;\r
d7ce7006 153\r
154//------------------------------------------------------------------------------\r
155// GUIDs\r
156//------------------------------------------------------------------------------\r
157\r
a88c3163 158extern CONST EFI_GUID mEslIp4ServiceGuid; ///< Tag GUID for the IPv4 layer\r
3bdf9aae 159extern CONST EFI_GUID mEslIp6ServiceGuid; ///< Tag GUID for the IPv6 layer\r
a88c3163 160extern CONST EFI_GUID mEslTcp4ServiceGuid; ///< Tag GUID for the TCPv4 layer\r
3bdf9aae 161extern CONST EFI_GUID mEslTcp6ServiceGuid; ///< Tag GUID for the TCPv6 layer\r
a88c3163 162extern CONST EFI_GUID mEslUdp4ServiceGuid; ///< Tag GUID for the UDPv4 layer\r
3bdf9aae 163extern CONST EFI_GUID mEslUdp6ServiceGuid; ///< Tag GUID for the UDPv6 layer\r
d7ce7006 164\r
165//------------------------------------------------------------------------------\r
166// Data\r
167//------------------------------------------------------------------------------\r
168\r
a88c3163 169extern CONST ESL_SOCKET_BINDING cEslSocketBinding[];///< List of network service bindings\r
170extern CONST UINTN cEslSocketBindingEntries; ///< Number of network service bindings\r
d7ce7006 171\r
172//------------------------------------------------------------------------------\r
a88c3163 173// DXE Support Routines\r
d7ce7006 174//------------------------------------------------------------------------------\r
175\r
176/**\r
a88c3163 177 Creates a child handle and installs a protocol.\r
d7ce7006 178\r
a88c3163 179 When the socket application is linked against UseSocketDxe, the ::socket\r
180 routine indirectly calls this routine in SocketDxe to create a child\r
181 handle if necessary and install the socket protocol on the handle.\r
182 Upon return, EslServiceGetProtocol in UseSocketLib returns the\r
183 ::EFI_SOCKET_PROTOCOL address to the socket routine.\r
d7ce7006 184\r
a88c3163 185 @param [in] pThis Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
186 @param [in] pChildHandle Pointer to the handle of the child to create. If it is NULL,\r
187 then a new handle is created. If it is a pointer to an existing UEFI handle, \r
188 then the protocol is added to the existing UEFI handle.\r
d7ce7006 189\r
a88c3163 190 @retval EFI_SUCCESS The protocol was added to ChildHandle.\r
191 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
192 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r
193 the child\r
194 @retval other The child handle was not created\r
d7ce7006 195\r
196**/\r
197EFI_STATUS\r
198EFIAPI\r
a88c3163 199EslDxeCreateChild (\r
200 IN EFI_SERVICE_BINDING_PROTOCOL * pThis,\r
201 IN OUT EFI_HANDLE * pChildHandle\r
d7ce7006 202 );\r
203\r
204/**\r
a88c3163 205 Destroys a child handle with a protocol installed on it.\r
206 \r
207 When the socket application is linked against UseSocketDxe, the ::close\r
208 routine indirectly calls this routine in SocketDxe to undo the operations\r
209 done by the ::EslDxeCreateChild routine. This routine removes the socket\r
210 protocol from the handle and then destroys the child handle if there are\r
211 no other protocols attached.\r
d7ce7006 212\r
a88c3163 213 @param [in] pThis Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
214 @param [in] ChildHandle Handle of the child to destroy\r
d7ce7006 215\r
a88c3163 216 @retval EFI_SUCCESS The protocol was removed from ChildHandle.\r
217 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.\r
218 @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.\r
219 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle\r
220 because its services are being used.\r
221 @retval other The child handle was not destroyed\r
d7ce7006 222\r
223**/\r
224EFI_STATUS\r
225EFIAPI\r
a88c3163 226EslDxeDestroyChild (\r
227 IN EFI_SERVICE_BINDING_PROTOCOL * pThis,\r
228 IN EFI_HANDLE ChildHandle\r
d7ce7006 229 );\r
230\r
231/**\r
232Install the socket service\r
233\r
a88c3163 234SocketDxe uses this routine to announce the socket interface to\r
235the rest of EFI.\r
236\r
d7ce7006 237@param [in] pImageHandle Address of the image handle\r
238\r
239@retval EFI_SUCCESS Service installed successfully\r
240**/\r
241EFI_STATUS\r
242EFIAPI\r
a88c3163 243EslDxeInstall (\r
d7ce7006 244 IN EFI_HANDLE * pImageHandle\r
245 );\r
246\r
d7ce7006 247/**\r
248Uninstall the socket service\r
249\r
a88c3163 250SocketDxe uses this routine to notify EFI that the socket layer\r
251is no longer available.\r
252\r
d7ce7006 253@param [in] ImageHandle Handle for the image.\r
254\r
255@retval EFI_SUCCESS Service installed successfully\r
256**/\r
257EFI_STATUS\r
258EFIAPI\r
a88c3163 259EslDxeUninstall (\r
d7ce7006 260 IN EFI_HANDLE ImageHandle\r
261 );\r
262\r
a88c3163 263//------------------------------------------------------------------------------\r
264// Service Support Routines\r
265//------------------------------------------------------------------------------\r
266\r
d7ce7006 267/**\r
a88c3163 268 Connect to the network service bindings\r
269\r
270 Walk the network service protocols on the controller handle and\r
271 locate any that are not in use. Create ::ESL_SERVICE structures to\r
272 manage the network layer interfaces for the socket driver. Tag\r
273 each of the network interfaces that are being used. Finally, this\r
274 routine calls ESL_SOCKET_BINDING::pfnInitialize to prepare the network\r
275 interface for use by the socket layer.\r
276\r
277 @param [in] BindingHandle Handle for protocol binding.\r
278 @param [in] Controller Handle of device to work with.\r
279\r
280 @retval EFI_SUCCESS This driver is added to Controller.\r
281 @retval other This driver does not support this device.\r
d7ce7006 282\r
283**/\r
a88c3163 284EFI_STATUS\r
d7ce7006 285EFIAPI\r
a88c3163 286EslServiceConnect (\r
287 IN EFI_HANDLE BindingHandle,\r
288 IN EFI_HANDLE Controller\r
d7ce7006 289 );\r
290\r
d7ce7006 291/**\r
a88c3163 292 Shutdown the connections to the network layer by locating the\r
293 tags on the network interfaces established by ::EslServiceConnect.\r
294 This routine calls ESL_SOCKET_BINDING::pfnShutdown to shutdown the any\r
295 activity on the network interface and then free the ::ESL_SERVICE\r
296 structures.\r
d7ce7006 297\r
a88c3163 298 @param [in] BindingHandle Handle for protocol binding.\r
299 @param [in] Controller Handle of device to stop driver on.\r
d7ce7006 300\r
a88c3163 301 @retval EFI_SUCCESS This driver is removed Controller.\r
302 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
303 @retval other This driver was not removed from this device.\r
d7ce7006 304\r
305**/\r
306EFI_STATUS\r
307EFIAPI\r
a88c3163 308EslServiceDisconnect (\r
309 IN EFI_HANDLE BindingHandle,\r
310 IN EFI_HANDLE Controller\r
d7ce7006 311 );\r
312\r
313/**\r
a88c3163 314Initialize the service layer\r
d7ce7006 315\r
a88c3163 316@param [in] ImageHandle Handle for the image.\r
d7ce7006 317\r
a88c3163 318**/\r
319VOID\r
320EFIAPI\r
321EslServiceLoad (\r
322 IN EFI_HANDLE ImageHandle\r
323 );\r
d7ce7006 324\r
a88c3163 325/**\r
326 Shutdown the service layer\r
d7ce7006 327\r
328**/\r
a88c3163 329VOID\r
d7ce7006 330EFIAPI\r
a88c3163 331EslServiceUnload (\r
332 VOID\r
d7ce7006 333 );\r
334\r
335//------------------------------------------------------------------------------\r
336// Socket Protocol Routines\r
337//------------------------------------------------------------------------------\r
338\r
339/**\r
340 Bind a name to a socket.\r
341\r
a88c3163 342 This routine calls the network specific layer to save the network\r
343 address of the local connection point.\r
d7ce7006 344\r
a88c3163 345 The ::bind routine calls this routine to connect a name\r
346 (network address and port) to a socket on the local machine.\r
347\r
348 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
d7ce7006 349\r
350 @param [in] pSockAddr Address of a sockaddr structure that contains the\r
351 connection point on the local machine. An IPv4 address\r
352 of INADDR_ANY specifies that the connection is made to\r
353 all of the network stacks on the platform. Specifying a\r
354 specific IPv4 address restricts the connection to the\r
355 network stack supporting that address. Specifying zero\r
356 for the port causes the network layer to assign a port\r
357 number from the dynamic range. Specifying a specific\r
358 port number causes the network layer to use that port.\r
359\r
a88c3163 360 @param [in] SockAddrLength Specifies the length in bytes of the sockaddr structure.\r
d7ce7006 361\r
362 @param [out] pErrno Address to receive the errno value upon completion.\r
363\r
364 @retval EFI_SUCCESS - Socket successfully created\r
365\r
366 **/\r
367EFI_STATUS\r
368EslSocketBind (\r
369 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
a88c3163 370 IN CONST struct sockaddr * pSockAddr,\r
d7ce7006 371 IN socklen_t SockAddrLength,\r
372 OUT int * pErrno\r
373 );\r
374\r
375/**\r
376 Determine if the socket is closed\r
377\r
a88c3163 378 This routine checks the state of the socket to determine if\r
379 the network specific layer has completed the close operation.\r
380\r
381 The ::close routine polls this routine to determine when the\r
382 close operation is complete. The close operation needs to\r
383 reverse the operations of the ::EslSocketAllocate routine.\r
d7ce7006 384\r
a88c3163 385 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
d7ce7006 386 @param [out] pErrno Address to receive the errno value upon completion.\r
387\r
388 @retval EFI_SUCCESS Socket successfully closed\r
389 @retval EFI_NOT_READY Close still in progress\r
390 @retval EFI_ALREADY Close operation already in progress\r
391 @retval Other Failed to close the socket\r
392\r
393**/\r
394EFI_STATUS\r
395EslSocketClosePoll (\r
396 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
397 IN int * pErrno\r
398 );\r
399\r
400/**\r
401 Start the close operation on the socket\r
402\r
a88c3163 403 This routine calls the network specific layer to initiate the\r
404 close state machine. This routine then calls the network\r
405 specific layer to determine if the close state machine has gone\r
406 to completion. The result from this poll is returned to the\r
407 caller.\r
d7ce7006 408\r
a88c3163 409 The ::close routine calls this routine to start the close\r
410 operation which reverses the operations of the\r
411 ::EslSocketAllocate routine. The close routine then polls\r
412 the ::EslSocketClosePoll routine to determine when the\r
413 socket is closed.\r
414\r
415 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
d7ce7006 416 @param [in] bCloseNow Boolean to control close behavior\r
417 @param [out] pErrno Address to receive the errno value upon completion.\r
418\r
419 @retval EFI_SUCCESS Socket successfully closed\r
420 @retval EFI_NOT_READY Close still in progress\r
421 @retval EFI_ALREADY Close operation already in progress\r
422 @retval Other Failed to close the socket\r
423\r
424**/\r
425EFI_STATUS\r
426EslSocketCloseStart (\r
427 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
428 IN BOOLEAN bCloseNow,\r
429 IN int * pErrno\r
430 );\r
431\r
432/**\r
433 Connect to a remote system via the network.\r
434\r
a88c3163 435 This routine calls the network specific layer to establish\r
436 the remote system address and establish the connection to\r
437 the remote system.\r
d7ce7006 438\r
a88c3163 439 The ::connect routine calls this routine to establish a\r
440 connection with the specified remote system. This routine\r
441 is designed to be polled by the connect routine for completion\r
442 of the network connection.\r
443 \r
444 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
d7ce7006 445\r
a88c3163 446 @param [in] pSockAddr Network address of the remote system.\r
447 \r
d7ce7006 448 @param [in] SockAddrLength Length in bytes of the network address.\r
a88c3163 449 \r
d7ce7006 450 @param [out] pErrno Address to receive the errno value upon completion.\r
a88c3163 451 \r
d7ce7006 452 @retval EFI_SUCCESS The connection was successfully established.\r
453 @retval EFI_NOT_READY The connection is in progress, call this routine again.\r
454 @retval Others The connection attempt failed.\r
455\r
456 **/\r
457EFI_STATUS\r
458EslSocketConnect (\r
459 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
460 IN const struct sockaddr * pSockAddr,\r
461 IN socklen_t SockAddrLength,\r
462 IN int * pErrno\r
463 );\r
464\r
465/**\r
466 Get the local address.\r
467\r
a88c3163 468 This routine calls the network specific layer to get the network\r
469 address of the local host connection point.\r
d7ce7006 470\r
a88c3163 471 The ::getsockname routine calls this routine to obtain the network\r
472 address associated with the local host connection point.\r
473\r
474 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
475 \r
d7ce7006 476 @param [out] pAddress Network address to receive the local system address\r
477\r
478 @param [in,out] pAddressLength Length of the local network address structure\r
479\r
480 @param [out] pErrno Address to receive the errno value upon completion.\r
481\r
482 @retval EFI_SUCCESS - Local address successfully returned\r
483\r
484 **/\r
485EFI_STATUS\r
486EslSocketGetLocalAddress (\r
487 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
488 OUT struct sockaddr * pAddress,\r
489 IN OUT socklen_t * pAddressLength,\r
490 IN int * pErrno\r
491 );\r
492\r
493/**\r
494 Get the peer address.\r
495\r
a88c3163 496 This routine calls the network specific layer to get the remote\r
497 system connection point.\r
498\r
499 The ::getpeername routine calls this routine to obtain the network\r
500 address of the remote connection point.\r
d7ce7006 501\r
a88c3163 502 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
503 \r
d7ce7006 504 @param [out] pAddress Network address to receive the remote system address\r
505\r
506 @param [in,out] pAddressLength Length of the remote network address structure\r
507\r
508 @param [out] pErrno Address to receive the errno value upon completion.\r
509\r
510 @retval EFI_SUCCESS - Remote address successfully returned\r
511\r
512 **/\r
513EFI_STATUS\r
514EslSocketGetPeerAddress (\r
515 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
516 OUT struct sockaddr * pAddress,\r
517 IN OUT socklen_t * pAddressLength,\r
518 IN int * pErrno\r
519 );\r
520\r
521/**\r
522 Establish the known port to listen for network connections.\r
523\r
a88c3163 524 This routine calls into the network protocol layer to establish\r
525 a handler that is called upon connection completion. The handler\r
526 is responsible for inserting the connection into the FIFO.\r
d7ce7006 527\r
a88c3163 528 The ::listen routine indirectly calls this routine to place the\r
529 socket into a state that enables connection attempts. Connections\r
530 are placed in a FIFO that is serviced by the application. The\r
531 application calls the ::accept (::EslSocketAccept) routine to\r
532 remove the next connection from the FIFO and get the associated\r
533 socket and address.\r
534\r
535 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
d7ce7006 536\r
537 @param [in] Backlog Backlog specifies the maximum FIFO depth for\r
538 the connections waiting for the application\r
539 to call accept. Connection attempts received\r
540 while the queue is full are refused.\r
541\r
542 @param [out] pErrno Address to receive the errno value upon completion.\r
543\r
544 @retval EFI_SUCCESS - Socket successfully created\r
545 @retval Other - Failed to enable the socket for listen\r
546\r
547**/\r
548EFI_STATUS\r
549EslSocketListen (\r
550 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
551 IN INT32 Backlog,\r
552 OUT int * pErrno\r
553 );\r
554\r
555/**\r
556 Get the socket options\r
557\r
a88c3163 558 This routine handles the socket level options and passes the\r
559 others to the network specific layer.\r
d7ce7006 560\r
a88c3163 561 The ::getsockopt routine calls this routine to retrieve the\r
562 socket options one at a time by name.\r
563\r
564 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
565 @param [in] level Option protocol level\r
566 @param [in] OptionName Name of the option\r
567 @param [out] pOptionValue Buffer to receive the option value\r
568 @param [in,out] pOptionLength Length of the buffer in bytes,\r
569 upon return length of the option value in bytes\r
570 @param [out] pErrno Address to receive the errno value upon completion.\r
d7ce7006 571\r
572 @retval EFI_SUCCESS - Socket data successfully received\r
573\r
574 **/\r
575EFI_STATUS\r
576EslSocketOptionGet (\r
577 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
578 IN int level,\r
579 IN int option_name,\r
580 OUT void * __restrict option_value,\r
581 IN OUT socklen_t * __restrict option_len,\r
582 IN int * pErrno\r
583 );\r
584\r
585/**\r
586 Set the socket options\r
587\r
a88c3163 588 This routine handles the socket level options and passes the\r
589 others to the network specific layer.\r
590\r
591 The ::setsockopt routine calls this routine to adjust the socket\r
592 options one at a time by name.\r
d7ce7006 593\r
a88c3163 594 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
d7ce7006 595 @param [in] level Option protocol level\r
a88c3163 596 @param [in] OptionName Name of the option\r
597 @param [in] pOptionValue Buffer containing the option value\r
598 @param [in] OptionLength Length of the buffer in bytes\r
d7ce7006 599 @param [out] pErrno Address to receive the errno value upon completion.\r
600\r
a88c3163 601 @retval EFI_SUCCESS - Option successfully set\r
d7ce7006 602\r
603 **/\r
604EFI_STATUS\r
605EslSocketOptionSet (\r
606 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
607 IN int level,\r
608 IN int option_name,\r
609 IN CONST void * option_value,\r
610 IN socklen_t option_len,\r
611 IN int * pErrno\r
612 );\r
613\r
614/**\r
615 Poll a socket for pending activity.\r
616\r
a88c3163 617 This routine builds a detected event mask which is returned to\r
618 the caller in the buffer provided.\r
619\r
620 The ::poll routine calls this routine to determine if the socket\r
621 needs to be serviced as a result of connection, error, receive or\r
622 transmit activity.\r
d7ce7006 623\r
a88c3163 624 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
d7ce7006 625\r
626 @param [in] Events Events of interest for this socket\r
627\r
628 @param [in] pEvents Address to receive the detected events\r
629\r
630 @param [out] pErrno Address to receive the errno value upon completion.\r
631\r
632 @retval EFI_SUCCESS - Socket successfully polled\r
633 @retval EFI_INVALID_PARAMETER - When pEvents is NULL\r
634\r
635 **/\r
636EFI_STATUS\r
637EslSocketPoll (\r
638 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
639 IN short Events,\r
640 IN short * pEvents,\r
641 IN int * pErrno\r
642 );\r
643\r
644/**\r
645 Receive data from a network connection.\r
646\r
a88c3163 647 This routine calls the network specific routine to remove the\r
648 next portion of data from the receive queue and return it to the\r
649 caller.\r
d7ce7006 650\r
a88c3163 651 The ::recvfrom routine calls this routine to determine if any data\r
652 is received from the remote system. Note that the other routines\r
653 ::recv and ::read are layered on top of ::recvfrom.\r
d7ce7006 654\r
a88c3163 655 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
656 \r
d7ce7006 657 @param [in] Flags Message control flags\r
a88c3163 658 \r
d7ce7006 659 @param [in] BufferLength Length of the the buffer\r
a88c3163 660 \r
d7ce7006 661 @param [in] pBuffer Address of a buffer to receive the data.\r
a88c3163 662 \r
d7ce7006 663 @param [in] pDataLength Number of received data bytes in the buffer.\r
664\r
665 @param [out] pAddress Network address to receive the remote system address\r
666\r
667 @param [in,out] pAddressLength Length of the remote network address structure\r
668\r
669 @param [out] pErrno Address to receive the errno value upon completion.\r
670\r
671 @retval EFI_SUCCESS - Socket data successfully received\r
672\r
673 **/\r
674EFI_STATUS\r
675EslSocketReceive (\r
676 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
677 IN INT32 Flags,\r
678 IN size_t BufferLength,\r
679 IN UINT8 * pBuffer,\r
680 OUT size_t * pDataLength,\r
681 OUT struct sockaddr * pAddress,\r
682 IN OUT socklen_t * pAddressLength,\r
683 IN int * pErrno\r
684 );\r
685\r
686/**\r
687 Shutdown the socket receive and transmit operations\r
688\r
a88c3163 689 This routine sets a flag to stop future transmissions and calls\r
690 the network specific layer to cancel the pending receive operation.\r
d7ce7006 691\r
a88c3163 692 The ::shutdown routine calls this routine to stop receive and transmit\r
693 operations on the socket.\r
d7ce7006 694\r
a88c3163 695 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
696 \r
d7ce7006 697 @param [in] How Which operations to stop\r
a88c3163 698 \r
d7ce7006 699 @param [out] pErrno Address to receive the errno value upon completion.\r
700\r
701 @retval EFI_SUCCESS - Socket operations successfully shutdown\r
702\r
703 **/\r
704EFI_STATUS\r
705EslSocketShutdown (\r
706 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
707 IN int How,\r
708 IN int * pErrno\r
709 );\r
710\r
711/**\r
712 Send data using a network connection.\r
713\r
a88c3163 714 This routine calls the network specific layer to queue the data\r
715 for transmission. Eventually the buffer will reach the head of\r
716 the queue and will get transmitted over the network. For datagram\r
717 sockets there is no guarantee that the data reaches the application\r
718 running on the remote system.\r
d7ce7006 719\r
a88c3163 720 The ::sendto routine calls this routine to send data to the remote\r
721 system. Note that ::send and ::write are layered on top of ::sendto.\r
d7ce7006 722\r
a88c3163 723 @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r
724 \r
d7ce7006 725 @param [in] Flags Message control flags\r
a88c3163 726 \r
d7ce7006 727 @param [in] BufferLength Length of the the buffer\r
a88c3163 728 \r
d7ce7006 729 @param [in] pBuffer Address of a buffer containing the data to send\r
a88c3163 730 \r
d7ce7006 731 @param [in] pDataLength Address to receive the number of data bytes sent\r
732\r
733 @param [in] pAddress Network address of the remote system address\r
734\r
735 @param [in] AddressLength Length of the remote network address structure\r
736\r
737 @param [out] pErrno Address to receive the errno value upon completion.\r
738\r
a88c3163 739 @retval EFI_SUCCESS - Socket data successfully queued for transmit\r
d7ce7006 740\r
741 **/\r
742EFI_STATUS\r
743EslSocketTransmit (\r
744 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
745 IN int Flags,\r
746 IN size_t BufferLength,\r
747 IN CONST UINT8 * pBuffer,\r
748 OUT size_t * pDataLength,\r
749 IN const struct sockaddr * pAddress,\r
750 IN socklen_t AddressLength,\r
751 IN int * pErrno\r
752 );\r
753\r
754//------------------------------------------------------------------------------\r
755\r
756#endif // _EFI_SOCKET_LIB_H_\r