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