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