]>
Commit | Line | Data |
---|---|---|
d7ce7006 | 1 | /** @file\r |
2 | Implement the getsockopt API.\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.php\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 | #include <SocketInternals.h>\r | |
16 | \r | |
17 | \r | |
18 | /**\r | |
19 | Get the socket options\r | |
20 | \r | |
a88c3163 | 21 | The\r |
22 | <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html#">POSIX</a>\r | |
23 | documentation is available online.\r | |
24 | \r | |
d7ce7006 | 25 | @param [in] s Socket file descriptor returned from ::socket.\r |
26 | @param [in] level Option protocol level\r | |
27 | @param [in] option_name Name of the option\r | |
28 | @param [out] option_value Buffer to receive the option value\r | |
29 | @param [in,out] option_len Length of the buffer in bytes,\r | |
30 | upon return length of the option value in bytes\r | |
31 | \r | |
a88c3163 | 32 | @return This routine returns zero (0) if successful or -1 when an error occurs.\r |
33 | In the case of an error, ::errno contains more details.\r | |
d7ce7006 | 34 | \r |
35 | **/\r | |
36 | int\r | |
37 | getsockopt (\r | |
38 | IN int s,\r | |
39 | IN int level,\r | |
40 | IN int option_name,\r | |
41 | OUT void * __restrict option_value,\r | |
42 | IN OUT socklen_t * __restrict option_len\r | |
43 | )\r | |
44 | {\r | |
45 | int OptionStatus;\r | |
46 | EFI_SOCKET_PROTOCOL * pSocketProtocol;\r | |
47 | EFI_STATUS Status;\r | |
48 | \r | |
49 | //\r | |
50 | // Locate the context for this socket\r | |
51 | //\r | |
52 | pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );\r | |
53 | if ( NULL != pSocketProtocol ) {\r | |
54 | //\r | |
55 | // Get the socket option\r | |
56 | //\r | |
57 | Status = pSocketProtocol->pfnOptionGet ( pSocketProtocol,\r | |
58 | level,\r | |
59 | option_name,\r | |
60 | option_value,\r | |
61 | option_len,\r | |
62 | &errno );\r | |
63 | }\r | |
64 | \r | |
65 | //\r | |
66 | // Return the operation stauts\r | |
67 | //\r | |
68 | OptionStatus = ( 0 == errno ) ? 0 : -1;\r | |
69 | return OptionStatus;\r | |
70 | }\r |