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 |
22 | #include <Library/UefiBootServicesTableLib.h>\r |
23 | #include <Library/UefiLib.h>\r |
24 | \r |
25 | #include <Protocol/EfiSocket.h>\r |
26 | #include <Protocol/ServiceBinding.h>\r |
27 | #include <Protocol/Tcp4.h>\r |
28 | #include <Protocol/Udp4.h>\r |
29 | \r |
30 | #include <sys/time.h>\r |
31 | \r |
32 | //------------------------------------------------------------------------------\r |
33 | // Constants\r |
34 | //------------------------------------------------------------------------------\r |
35 | \r |
36 | #define DEBUG_TPL 0x40000000 ///< Display TPL change messages\r |
37 | \r |
38 | #define TPL_SOCKETS TPL_CALLBACK ///< TPL for routine synchronization\r |
39 | \r |
40 | //------------------------------------------------------------------------------\r |
41 | // Macros\r |
42 | //------------------------------------------------------------------------------\r |
43 | \r |
44 | #if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */\r |
45 | #define DBG_ENTER() DEBUG (( DEBUG_INFO, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry\r |
46 | #define DBG_EXIT() DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ "\n" )) ///< Display routine exit\r |
47 | #define DBG_EXIT_DEC(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value\r |
48 | #define DBG_EXIT_HEX(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value\r |
49 | #define DBG_EXIT_STATUS(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value\r |
50 | #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 |
51 | #else // _MSC_VER\r |
52 | #define DBG_ENTER()\r |
53 | #define DBG_EXIT()\r |
54 | #define DBG_EXIT_DEC(Status)\r |
55 | #define DBG_EXIT_HEX(Status)\r |
56 | #define DBG_EXIT_STATUS(Status)\r |
57 | #define DBG_EXIT_TF(Status)\r |
58 | #endif // _MSC_VER\r |
59 | \r |
60 | #define DIM(x) ( sizeof ( x ) / sizeof ( x[0] )) ///< Compute the number of entries in an array\r |
61 | \r |
62 | /**\r |
63 | Verify new TPL value\r |
64 | \r |
65 | This macro which is enabled when debug is enabled verifies that\r |
66 | the new TPL value is >= the current TPL value.\r |
67 | **/\r |
68 | #ifdef VERIFY_TPL\r |
69 | #undef VERIFY_TPL\r |
70 | #endif // VERIFY_TPL\r |
71 | \r |
72 | #if !defined(MDEPKG_NDEBUG)\r |
73 | \r |
74 | #define VERIFY_TPL(tpl) \\r |
75 | { \\r |
76 | EFI_TPL PreviousTpl; \\r |
77 | \\r |
78 | PreviousTpl = gBS->RaiseTPL ( TPL_HIGH_LEVEL ); \\r |
79 | gBS->RestoreTPL ( PreviousTpl ); \\r |
80 | if ( PreviousTpl > tpl ) { \\r |
81 | DEBUG (( DEBUG_ERROR | DEBUG_TPL, \\r |
82 | "Current TPL: %d, New TPL: %d\r\n", \\r |
83 | PreviousTpl, tpl )); \\r |
84 | ASSERT ( PreviousTpl <= tpl ); \\r |
85 | } \\r |
86 | }\r |
87 | \r |
88 | #else // MDEPKG_NDEBUG\r |
89 | \r |
90 | #define VERIFY_TPL(tpl)\r |
91 | \r |
92 | #endif // MDEPKG_NDEBUG\r |
93 | \r |
94 | #define RAISE_TPL(PreviousTpl, tpl) \\r |
95 | VERIFY_TPL ( tpl ); \\r |
96 | PreviousTpl = gBS->RaiseTPL ( tpl ); \\r |
97 | DEBUG (( DEBUG_TPL | DEBUG_TPL, \\r |
98 | "%d: TPL\r\n", \\r |
99 | tpl ))\r |
100 | \r |
101 | #define RESTORE_TPL(tpl) \\r |
102 | gBS->RestoreTPL ( tpl ); \\r |
103 | DEBUG (( DEBUG_TPL | DEBUG_TPL, \\r |
104 | "%d: TPL\r\n", \\r |
105 | tpl ))\r |
106 | \r |
107 | //------------------------------------------------------------------------------\r |
108 | // Data Types\r |
109 | //------------------------------------------------------------------------------\r |
110 | \r |
111 | typedef struct _DT_SERVICE DT_SERVICE; ///< Forward delcaration\r |
112 | \r |
113 | typedef\r |
114 | EFI_STATUS\r |
115 | (* PFN_SB_INITIALIZE) (\r |
116 | DT_SERVICE * pService\r |
117 | );\r |
118 | \r |
119 | typedef\r |
120 | VOID\r |
121 | (* PFN_SB_SHUTDOWN) (\r |
122 | DT_SERVICE * pService\r |
123 | );\r |
124 | \r |
125 | /**\r |
126 | Protocol binding and installation control structure\r |
127 | \r |
128 | The driver uses this structure to simplify the driver binding processing.\r |
129 | **/\r |
130 | typedef struct {\r |
131 | CHAR16 * pName; ///< Protocol name\r |
132 | EFI_GUID * pNetworkBinding; ///< Network service binding protocol for socket support\r |
133 | CONST EFI_GUID * pTagGuid; ///< Tag to mark protocol in use\r |
134 | PFN_SB_INITIALIZE pfnInitialize;///< Routine to initialize the service\r |
135 | PFN_SB_SHUTDOWN pfnShutdown; ///< Routine to shutdown the service\r |
136 | } DT_SOCKET_BINDING;\r |
137 | \r |
138 | //------------------------------------------------------------------------------\r |
139 | // GUIDs\r |
140 | //------------------------------------------------------------------------------\r |
141 | \r |
142 | extern CONST EFI_GUID mEslRawServiceGuid;\r |
143 | extern CONST EFI_GUID mEslTcp4ServiceGuid;\r |
144 | extern CONST EFI_GUID mEslUdp4ServiceGuid;\r |
145 | \r |
146 | //------------------------------------------------------------------------------\r |
147 | // Data\r |
148 | //------------------------------------------------------------------------------\r |
149 | \r |
150 | extern CONST DT_SOCKET_BINDING cEslSocketBinding [];\r |
151 | extern CONST UINTN cEslSocketBindingEntries;\r |
152 | \r |
153 | //------------------------------------------------------------------------------\r |
154 | // Service Support Routines\r |
155 | //------------------------------------------------------------------------------\r |
156 | \r |
157 | /**\r |
158 | Connect to the network service bindings\r |
159 | \r |
160 | Walk the network service protocols on the controller handle and\r |
161 | locate any that are not in use. Create service structures to\r |
162 | manage the service binding for the socket driver.\r |
163 | \r |
164 | @param [in] BindingHandle Handle for protocol binding.\r |
165 | @param [in] Controller Handle of device to work with.\r |
166 | \r |
167 | @retval EFI_SUCCESS This driver is added to Controller.\r |
168 | @retval other This driver does not support this device.\r |
169 | \r |
170 | **/\r |
171 | EFI_STATUS\r |
172 | EFIAPI\r |
173 | EslServiceConnect (\r |
174 | IN EFI_HANDLE BindingHandle,\r |
175 | IN EFI_HANDLE Controller\r |
176 | );\r |
177 | \r |
178 | /**\r |
179 | Shutdown the network connections to this controller by removing\r |
180 | NetworkInterfaceIdentifier protocol and closing the DevicePath\r |
181 | and PciIo protocols on Controller.\r |
182 | \r |
183 | @param [in] BindingHandle Handle for protocol binding.\r |
184 | @param [in] Controller Handle of device to stop driver on.\r |
185 | \r |
186 | @retval EFI_SUCCESS This driver is removed Controller.\r |
187 | @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r |
188 | @retval other This driver was not removed from this device.\r |
189 | \r |
190 | **/\r |
191 | EFI_STATUS\r |
192 | EFIAPI\r |
193 | EslServiceDisconnect (\r |
194 | IN EFI_HANDLE BindingHandle,\r |
195 | IN EFI_HANDLE Controller\r |
196 | );\r |
197 | \r |
198 | /**\r |
199 | Install the socket service\r |
200 | \r |
201 | @param [in] pImageHandle Address of the image handle\r |
202 | \r |
203 | @retval EFI_SUCCESS Service installed successfully\r |
204 | **/\r |
205 | EFI_STATUS\r |
206 | EFIAPI\r |
207 | EslServiceInstall (\r |
208 | IN EFI_HANDLE * pImageHandle\r |
209 | );\r |
210 | \r |
211 | /**\r |
212 | Initialize the service layer\r |
213 | \r |
214 | @param [in] ImageHandle Handle for the image.\r |
215 | \r |
216 | **/\r |
217 | VOID\r |
218 | EFIAPI\r |
219 | EslServiceLoad (\r |
220 | IN EFI_HANDLE ImageHandle\r |
221 | );\r |
222 | \r |
223 | /**\r |
224 | Uninstall the socket service\r |
225 | \r |
226 | @param [in] ImageHandle Handle for the image.\r |
227 | \r |
228 | @retval EFI_SUCCESS Service installed successfully\r |
229 | **/\r |
230 | EFI_STATUS\r |
231 | EFIAPI\r |
232 | EslServiceUninstall (\r |
233 | IN EFI_HANDLE ImageHandle\r |
234 | );\r |
235 | \r |
236 | /**\r |
237 | Shutdown the service layer\r |
238 | \r |
239 | **/\r |
240 | VOID\r |
241 | EFIAPI\r |
242 | EslServiceUnload (\r |
243 | VOID\r |
244 | );\r |
245 | \r |
246 | //------------------------------------------------------------------------------\r |
247 | // Socket Service Binding Protocol Routines\r |
248 | //------------------------------------------------------------------------------\r |
249 | \r |
250 | /**\r |
251 | Creates a child handle and installs a protocol.\r |
252 | \r |
253 | The CreateChild() function installs a protocol on ChildHandle.\r |
254 | If pChildHandle is a pointer to NULL, then a new handle is created and returned in pChildHandle.\r |
255 | If pChildHandle is not a pointer to NULL, then the protocol installs on the existing pChildHandle.\r |
256 | \r |
257 | @param [in] pThis Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r |
258 | @param [in] pChildHandle Pointer to the handle of the child to create. If it is NULL,\r |
259 | then a new handle is created. If it is a pointer to an existing UEFI handle,\r |
260 | then the protocol is added to the existing UEFI handle.\r |
261 | \r |
262 | @retval EFI_SUCCES The protocol was added to ChildHandle.\r |
263 | @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r |
264 | @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r |
265 | the child\r |
266 | @retval other The child handle was not created\r |
267 | \r |
268 | **/\r |
269 | EFI_STATUS\r |
270 | EFIAPI\r |
271 | EslSocketCreateChild (\r |
272 | IN EFI_SERVICE_BINDING_PROTOCOL * pThis,\r |
273 | IN OUT EFI_HANDLE * pChildHandle\r |
274 | );\r |
275 | \r |
276 | /**\r |
277 | Destroys a child handle with a protocol installed on it.\r |
278 | \r |
279 | The DestroyChild() function does the opposite of CreateChild(). It removes a protocol\r |
280 | that was installed by CreateChild() from ChildHandle. If the removed protocol is the\r |
281 | last protocol on ChildHandle, then ChildHandle is destroyed.\r |
282 | \r |
283 | @param [in] pThis Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r |
284 | @param [in] ChildHandle Handle of the child to destroy\r |
285 | \r |
286 | @retval EFI_SUCCES The protocol was removed from ChildHandle.\r |
287 | @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.\r |
288 | @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.\r |
289 | @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle\r |
290 | because its services are being used.\r |
291 | @retval other The child handle was not destroyed\r |
292 | \r |
293 | **/\r |
294 | EFI_STATUS\r |
295 | EFIAPI\r |
296 | EslSocketDestroyChild (\r |
297 | IN EFI_SERVICE_BINDING_PROTOCOL * pThis,\r |
298 | IN EFI_HANDLE ChildHandle\r |
299 | );\r |
300 | \r |
301 | //------------------------------------------------------------------------------\r |
302 | // Socket Protocol Routines\r |
303 | //------------------------------------------------------------------------------\r |
304 | \r |
305 | /**\r |
306 | Bind a name to a socket.\r |
307 | \r |
308 | The ::SocketBind routine connects a name to a socket on the local machine. The\r |
309 | <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html">POSIX</a>\r |
310 | documentation for the bind routine is available online for reference.\r |
311 | \r |
312 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
313 | \r |
314 | @param [in] pSockAddr Address of a sockaddr structure that contains the\r |
315 | connection point on the local machine. An IPv4 address\r |
316 | of INADDR_ANY specifies that the connection is made to\r |
317 | all of the network stacks on the platform. Specifying a\r |
318 | specific IPv4 address restricts the connection to the\r |
319 | network stack supporting that address. Specifying zero\r |
320 | for the port causes the network layer to assign a port\r |
321 | number from the dynamic range. Specifying a specific\r |
322 | port number causes the network layer to use that port.\r |
323 | \r |
324 | @param [in] SockAddrLen Specifies the length in bytes of the sockaddr structure.\r |
325 | \r |
326 | @param [out] pErrno Address to receive the errno value upon completion.\r |
327 | \r |
328 | @retval EFI_SUCCESS - Socket successfully created\r |
329 | \r |
330 | **/\r |
331 | EFI_STATUS\r |
332 | EslSocketBind (\r |
333 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
334 | IN const struct sockaddr * pSockAddr,\r |
335 | IN socklen_t SockAddrLength,\r |
336 | OUT int * pErrno\r |
337 | );\r |
338 | \r |
339 | /**\r |
340 | Determine if the socket is closed\r |
341 | \r |
342 | Reverses the operations of the ::SocketAllocate() routine.\r |
343 | \r |
344 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
345 | @param [out] pErrno Address to receive the errno value upon completion.\r |
346 | \r |
347 | @retval EFI_SUCCESS Socket successfully closed\r |
348 | @retval EFI_NOT_READY Close still in progress\r |
349 | @retval EFI_ALREADY Close operation already in progress\r |
350 | @retval Other Failed to close the socket\r |
351 | \r |
352 | **/\r |
353 | EFI_STATUS\r |
354 | EslSocketClosePoll (\r |
355 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
356 | IN int * pErrno\r |
357 | );\r |
358 | \r |
359 | /**\r |
360 | Start the close operation on the socket\r |
361 | \r |
362 | Start closing the socket by closing all of the ports. Upon\r |
363 | completion, the ::SocketPoll() routine finishes closing the\r |
364 | socket.\r |
365 | \r |
366 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
367 | @param [in] bCloseNow Boolean to control close behavior\r |
368 | @param [out] pErrno Address to receive the errno value upon completion.\r |
369 | \r |
370 | @retval EFI_SUCCESS Socket successfully closed\r |
371 | @retval EFI_NOT_READY Close still in progress\r |
372 | @retval EFI_ALREADY Close operation already in progress\r |
373 | @retval Other Failed to close the socket\r |
374 | \r |
375 | **/\r |
376 | EFI_STATUS\r |
377 | EslSocketCloseStart (\r |
378 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
379 | IN BOOLEAN bCloseNow,\r |
380 | IN int * pErrno\r |
381 | );\r |
382 | \r |
383 | /**\r |
384 | Connect to a remote system via the network.\r |
385 | \r |
386 | The ::SocketConnect routine attempts to establish a connection to a\r |
387 | socket on the local or remote system using the specified address.\r |
388 | The POSIX\r |
389 | <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html">connect</a>\r |
390 | documentation is available online.\r |
391 | \r |
392 | There are three states associated with a connection:\r |
393 | <ul>\r |
394 | <li>Not connected</li>\r |
395 | <li>Connection in progress</li>\r |
396 | <li>Connected</li>\r |
397 | </ul>\r |
398 | In the "Not connected" state, calls to ::connect start the connection\r |
399 | processing and update the state to "Connection in progress". During\r |
400 | the "Connection in progress" state, connect polls for connection completion\r |
401 | and moves the state to "Connected" after the connection is established.\r |
402 | Note that these states are only visible when the file descriptor is marked\r |
403 | with O_NONBLOCK. Also, the POLL_WRITE bit is set when the connection\r |
404 | completes and may be used by poll or select as an indicator to call\r |
405 | connect again.\r |
406 | \r |
407 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
408 | \r |
409 | @param [in] pSockAddr Network address of the remote system.\r |
410 | \r |
411 | @param [in] SockAddrLength Length in bytes of the network address.\r |
412 | \r |
413 | @param [out] pErrno Address to receive the errno value upon completion.\r |
414 | \r |
415 | @retval EFI_SUCCESS The connection was successfully established.\r |
416 | @retval EFI_NOT_READY The connection is in progress, call this routine again.\r |
417 | @retval Others The connection attempt failed.\r |
418 | \r |
419 | **/\r |
420 | EFI_STATUS\r |
421 | EslSocketConnect (\r |
422 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
423 | IN const struct sockaddr * pSockAddr,\r |
424 | IN socklen_t SockAddrLength,\r |
425 | IN int * pErrno\r |
426 | );\r |
427 | \r |
428 | /**\r |
429 | Get the local address.\r |
430 | \r |
431 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
432 | \r |
433 | @param [out] pAddress Network address to receive the local system address\r |
434 | \r |
435 | @param [in,out] pAddressLength Length of the local network address structure\r |
436 | \r |
437 | @param [out] pErrno Address to receive the errno value upon completion.\r |
438 | \r |
439 | @retval EFI_SUCCESS - Local address successfully returned\r |
440 | \r |
441 | **/\r |
442 | EFI_STATUS\r |
443 | EslSocketGetLocalAddress (\r |
444 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
445 | OUT struct sockaddr * pAddress,\r |
446 | IN OUT socklen_t * pAddressLength,\r |
447 | IN int * pErrno\r |
448 | );\r |
449 | \r |
450 | /**\r |
451 | Get the peer address.\r |
452 | \r |
453 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
454 | \r |
455 | @param [out] pAddress Network address to receive the remote system address\r |
456 | \r |
457 | @param [in,out] pAddressLength Length of the remote network address structure\r |
458 | \r |
459 | @param [out] pErrno Address to receive the errno value upon completion.\r |
460 | \r |
461 | @retval EFI_SUCCESS - Remote address successfully returned\r |
462 | \r |
463 | **/\r |
464 | EFI_STATUS\r |
465 | EslSocketGetPeerAddress (\r |
466 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
467 | OUT struct sockaddr * pAddress,\r |
468 | IN OUT socklen_t * pAddressLength,\r |
469 | IN int * pErrno\r |
470 | );\r |
471 | \r |
472 | /**\r |
473 | Establish the known port to listen for network connections.\r |
474 | \r |
475 | The ::SocketListen routine places the port into a state that enables connection\r |
476 | attempts. Connections are placed into FIFO order in a queue to be serviced\r |
477 | by the application. The application calls the ::SocketAccept routine to remove\r |
478 | the next connection from the queue and get the associated socket. The\r |
479 | <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html">POSIX</a>\r |
480 | documentation for the bind routine is available online for reference.\r |
481 | \r |
482 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
483 | \r |
484 | @param [in] Backlog Backlog specifies the maximum FIFO depth for\r |
485 | the connections waiting for the application\r |
486 | to call accept. Connection attempts received\r |
487 | while the queue is full are refused.\r |
488 | \r |
489 | @param [out] pErrno Address to receive the errno value upon completion.\r |
490 | \r |
491 | @retval EFI_SUCCESS - Socket successfully created\r |
492 | @retval Other - Failed to enable the socket for listen\r |
493 | \r |
494 | **/\r |
495 | EFI_STATUS\r |
496 | EslSocketListen (\r |
497 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
498 | IN INT32 Backlog,\r |
499 | OUT int * pErrno\r |
500 | );\r |
501 | \r |
502 | /**\r |
503 | Get the socket options\r |
504 | \r |
505 | Retrieve the socket options one at a time by name. The\r |
506 | <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html">POSIX</a>\r |
507 | documentation is available online.\r |
508 | \r |
509 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
510 | @param [in] level Option protocol level\r |
511 | @param [in] option_name Name of the option\r |
512 | @param [out] option_value Buffer to receive the option value\r |
513 | @param [in,out] option_len Length of the buffer in bytes,\r |
514 | upon return length of the option value in bytes\r |
515 | @param [out] pErrno Address to receive the errno value upon completion.\r |
516 | \r |
517 | @retval EFI_SUCCESS - Socket data successfully received\r |
518 | \r |
519 | **/\r |
520 | EFI_STATUS\r |
521 | EslSocketOptionGet (\r |
522 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
523 | IN int level,\r |
524 | IN int option_name,\r |
525 | OUT void * __restrict option_value,\r |
526 | IN OUT socklen_t * __restrict option_len,\r |
527 | IN int * pErrno\r |
528 | );\r |
529 | \r |
530 | /**\r |
531 | Set the socket options\r |
532 | \r |
533 | Adjust the socket options one at a time by name. The\r |
534 | <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html">POSIX</a>\r |
535 | documentation is available online.\r |
536 | \r |
537 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
538 | @param [in] level Option protocol level\r |
539 | @param [in] option_name Name of the option\r |
540 | @param [in] option_value Buffer containing the option value\r |
541 | @param [in] option_len Length of the buffer in bytes\r |
542 | @param [out] pErrno Address to receive the errno value upon completion.\r |
543 | \r |
544 | @retval EFI_SUCCESS - Socket data successfully received\r |
545 | \r |
546 | **/\r |
547 | EFI_STATUS\r |
548 | EslSocketOptionSet (\r |
549 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
550 | IN int level,\r |
551 | IN int option_name,\r |
552 | IN CONST void * option_value,\r |
553 | IN socklen_t option_len,\r |
554 | IN int * pErrno\r |
555 | );\r |
556 | \r |
557 | /**\r |
558 | Poll a socket for pending activity.\r |
559 | \r |
560 | The SocketPoll routine checks a socket for pending activity associated\r |
561 | with the event mask. Activity is returned in the detected event buffer.\r |
562 | \r |
563 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
564 | \r |
565 | @param [in] Events Events of interest for this socket\r |
566 | \r |
567 | @param [in] pEvents Address to receive the detected events\r |
568 | \r |
569 | @param [out] pErrno Address to receive the errno value upon completion.\r |
570 | \r |
571 | @retval EFI_SUCCESS - Socket successfully polled\r |
572 | @retval EFI_INVALID_PARAMETER - When pEvents is NULL\r |
573 | \r |
574 | **/\r |
575 | EFI_STATUS\r |
576 | EslSocketPoll (\r |
577 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
578 | IN short Events,\r |
579 | IN short * pEvents,\r |
580 | IN int * pErrno\r |
581 | );\r |
582 | \r |
583 | /**\r |
584 | Receive data from a network connection.\r |
585 | \r |
586 | \r |
587 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
588 | \r |
589 | @param [in] Flags Message control flags\r |
590 | \r |
591 | @param [in] BufferLength Length of the the buffer\r |
592 | \r |
593 | @param [in] pBuffer Address of a buffer to receive the data.\r |
594 | \r |
595 | @param [in] pDataLength Number of received data bytes in the buffer.\r |
596 | \r |
597 | @param [out] pAddress Network address to receive the remote system address\r |
598 | \r |
599 | @param [in,out] pAddressLength Length of the remote network address structure\r |
600 | \r |
601 | @param [out] pErrno Address to receive the errno value upon completion.\r |
602 | \r |
603 | @retval EFI_SUCCESS - Socket data successfully received\r |
604 | \r |
605 | **/\r |
606 | EFI_STATUS\r |
607 | EslSocketReceive (\r |
608 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
609 | IN INT32 Flags,\r |
610 | IN size_t BufferLength,\r |
611 | IN UINT8 * pBuffer,\r |
612 | OUT size_t * pDataLength,\r |
613 | OUT struct sockaddr * pAddress,\r |
614 | IN OUT socklen_t * pAddressLength,\r |
615 | IN int * pErrno\r |
616 | );\r |
617 | \r |
618 | /**\r |
619 | Shutdown the socket receive and transmit operations\r |
620 | \r |
621 | The SocketShutdown routine stops the socket receive and transmit\r |
622 | operations.\r |
623 | \r |
624 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
625 | \r |
626 | @param [in] How Which operations to stop\r |
627 | \r |
628 | @param [out] pErrno Address to receive the errno value upon completion.\r |
629 | \r |
630 | @retval EFI_SUCCESS - Socket operations successfully shutdown\r |
631 | \r |
632 | **/\r |
633 | EFI_STATUS\r |
634 | EslSocketShutdown (\r |
635 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
636 | IN int How,\r |
637 | IN int * pErrno\r |
638 | );\r |
639 | \r |
640 | /**\r |
641 | Send data using a network connection.\r |
642 | \r |
643 | The SocketTransmit routine queues the data for transmission to the\r |
644 | remote network connection.\r |
645 | \r |
646 | @param [in] pSocketProtocol Address of the socket protocol structure.\r |
647 | \r |
648 | @param [in] Flags Message control flags\r |
649 | \r |
650 | @param [in] BufferLength Length of the the buffer\r |
651 | \r |
652 | @param [in] pBuffer Address of a buffer containing the data to send\r |
653 | \r |
654 | @param [in] pDataLength Address to receive the number of data bytes sent\r |
655 | \r |
656 | @param [in] pAddress Network address of the remote system address\r |
657 | \r |
658 | @param [in] AddressLength Length of the remote network address structure\r |
659 | \r |
660 | @param [out] pErrno Address to receive the errno value upon completion.\r |
661 | \r |
662 | @retval EFI_SUCCESS - Socket data successfully received\r |
663 | \r |
664 | **/\r |
665 | EFI_STATUS\r |
666 | EslSocketTransmit (\r |
667 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r |
668 | IN int Flags,\r |
669 | IN size_t BufferLength,\r |
670 | IN CONST UINT8 * pBuffer,\r |
671 | OUT size_t * pDataLength,\r |
672 | IN const struct sockaddr * pAddress,\r |
673 | IN socklen_t AddressLength,\r |
674 | IN int * pErrno\r |
675 | );\r |
676 | \r |
677 | //------------------------------------------------------------------------------\r |
678 | \r |
679 | #endif // _EFI_SOCKET_LIB_H_\r |