]>
Commit | Line | Data |
---|---|---|
d7ce7006 | 1 | /** @file\r |
2 | Implement the getsockopt API.\r | |
3 | \r | |
beaaa3b7 OM |
4 | Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials are licensed and made available under\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
7 | The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php.\r | |
d7ce7006 | 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 | |
d7ce7006 | 12 | **/\r |
d7ce7006 | 13 | #include <SocketInternals.h>\r |
14 | \r | |
15 | \r | |
beaaa3b7 | 16 | /** Get the socket options\r |
d7ce7006 | 17 | \r |
a88c3163 | 18 | The\r |
19 | <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html#">POSIX</a>\r | |
20 | documentation is available online.\r | |
21 | \r | |
d7ce7006 | 22 | @param [in] s Socket file descriptor returned from ::socket.\r |
23 | @param [in] level Option protocol level\r | |
24 | @param [in] option_name Name of the option\r | |
25 | @param [out] option_value Buffer to receive the option value\r | |
26 | @param [in,out] option_len Length of the buffer in bytes,\r | |
27 | upon return length of the option value in bytes\r | |
28 | \r | |
a88c3163 | 29 | @return This routine returns zero (0) if successful or -1 when an error occurs.\r |
30 | In the case of an error, ::errno contains more details.\r | |
d7ce7006 | 31 | **/\r |
32 | int\r | |
33 | getsockopt (\r | |
34 | IN int s,\r | |
35 | IN int level,\r | |
36 | IN int option_name,\r | |
37 | OUT void * __restrict option_value,\r | |
38 | IN OUT socklen_t * __restrict option_len\r | |
39 | )\r | |
40 | {\r | |
41 | int OptionStatus;\r | |
42 | EFI_SOCKET_PROTOCOL * pSocketProtocol;\r | |
beaaa3b7 | 43 | \r |
d7ce7006 | 44 | // Locate the context for this socket\r |
d7ce7006 | 45 | pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );\r |
46 | if ( NULL != pSocketProtocol ) {\r | |
d7ce7006 | 47 | // Get the socket option\r |
beaaa3b7 | 48 | (void) pSocketProtocol->pfnOptionGet ( pSocketProtocol,\r |
d7ce7006 | 49 | level,\r |
50 | option_name,\r | |
51 | option_value,\r | |
52 | option_len,\r | |
53 | &errno );\r | |
54 | }\r | |
d7ce7006 | 55 | // Return the operation stauts\r |
d7ce7006 | 56 | OptionStatus = ( 0 == errno ) ? 0 : -1;\r |
57 | return OptionStatus;\r | |
58 | }\r |