]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/setsockopt.c
Add missing IPv6 address definitions.
[mirror_edk2.git] / StdLib / BsdSocketLib / setsockopt.c
CommitLineData
d7ce7006 1/** @file\r
2 Implement the setsockopt 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 Set the socket options\r
20\r
a88c3163 21 The\r
22 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.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 [in] option_value Buffer containing the option value\r
29 @param [in] option_len Length of the value in bytes\r
30\r
a88c3163 31 @return This routine returns zero (0) upon success and -1 when an error occurs.\r
32 In the case of an error, ::errno contains more details.\r
d7ce7006 33\r
34**/\r
35int\r
36setsockopt (\r
37 IN int s,\r
38 IN int level,\r
39 IN int option_name,\r
40 IN CONST void * option_value,\r
41 IN socklen_t option_len\r
42 )\r
43{\r
44 int OptionStatus;\r
45 EFI_SOCKET_PROTOCOL * pSocketProtocol;\r
46 EFI_STATUS Status;\r
47 \r
48 //\r
49 // Locate the context for this socket\r
50 //\r
51 pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );\r
52 if ( NULL != pSocketProtocol ) {\r
53 //\r
54 // Set the socket option\r
55 //\r
56 Status = pSocketProtocol->pfnOptionSet ( pSocketProtocol,\r
57 level,\r
58 option_name,\r
59 option_value,\r
60 option_len,\r
61 &errno );\r
62 }\r
63 \r
64 //\r
65 // Return the operation stauts\r
66 //\r
67 OptionStatus = ( 0 == errno ) ? 0 : -1;\r
68 return OptionStatus;\r
69}\r