]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/setsockopt.c
IntelFsp2WrapperPkg: Update gFspWrapperTokenSpaceGuid to gIntelFsp2WrapperTokenSpaceGuid.
[mirror_edk2.git] / StdLib / BsdSocketLib / setsockopt.c
CommitLineData
d7ce7006 1/** @file\r
2 Implement the setsockopt 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/** Set the socket options\r
d7ce7006 17\r
a88c3163 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
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 [in] option_value Buffer containing the option value\r
26 @param [in] option_len Length of the value in bytes\r
27\r
a88c3163 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
d7ce7006 30**/\r
31int\r
32setsockopt (\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
beaaa3b7 42\r
d7ce7006 43 // Locate the context for this socket\r
d7ce7006 44 pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );\r
45 if ( NULL != pSocketProtocol ) {\r
d7ce7006 46 // Set the socket option\r
beaaa3b7
OM
47 (void) pSocketProtocol->pfnOptionSet (pSocketProtocol,\r
48 level,\r
49 option_name,\r
50 option_value,\r
51 option_len,\r
52 &errno );\r
d7ce7006 53 }\r
d7ce7006 54 // Return the operation stauts\r
d7ce7006 55 OptionStatus = ( 0 == errno ) ? 0 : -1;\r
56 return OptionStatus;\r
57}\r