]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Implement the setsockopt API.\r | |
3 | \r | |
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 | |
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 | #include <SocketInternals.h>\r | |
14 | \r | |
15 | \r | |
16 | /** Set the socket options\r | |
17 | \r | |
18 | The\r | |
19 | <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html">POSIX</a>\r | |
20 | documentation is available online.\r | |
21 | \r | |
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 [in] option_value Buffer containing the option value\r | |
26 | @param [in] option_len Length of the value in bytes\r | |
27 | \r | |
28 | @return This routine returns zero (0) upon success and -1 when an error occurs.\r | |
29 | In the case of an error, ::errno contains more details.\r | |
30 | **/\r | |
31 | int\r | |
32 | setsockopt (\r | |
33 | IN int s,\r | |
34 | IN int level,\r | |
35 | IN int option_name,\r | |
36 | IN CONST void * option_value,\r | |
37 | IN socklen_t option_len\r | |
38 | )\r | |
39 | {\r | |
40 | int OptionStatus;\r | |
41 | EFI_SOCKET_PROTOCOL * pSocketProtocol;\r | |
42 | \r | |
43 | // Locate the context for this socket\r | |
44 | pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );\r | |
45 | if ( NULL != pSocketProtocol ) {\r | |
46 | // Set the socket option\r | |
47 | (void) pSocketProtocol->pfnOptionSet (pSocketProtocol,\r | |
48 | level,\r | |
49 | option_name,\r | |
50 | option_value,\r | |
51 | option_len,\r | |
52 | &errno );\r | |
53 | }\r | |
54 | // Return the operation stauts\r | |
55 | OptionStatus = ( 0 == errno ) ? 0 : -1;\r | |
56 | return OptionStatus;\r | |
57 | }\r |