]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/setsockopt.c
Fix send to properly wait while long transmits are in progress
[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
21 @param [in] s Socket file descriptor returned from ::socket.\r
22 @param [in] level Option protocol level\r
23 @param [in] option_name Name of the option\r
24 @param [in] option_value Buffer containing the option value\r
25 @param [in] option_len Length of the value in bytes\r
26\r
27 @retval Zero (0) upon success\r
28 @retval Minus one (-1) upon failure, errno set with additional error information\r
29\r
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
42 EFI_STATUS Status;\r
43 \r
44 //\r
45 // Locate the context for this socket\r
46 //\r
47 pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );\r
48 if ( NULL != pSocketProtocol ) {\r
49 //\r
50 // Set the socket option\r
51 //\r
52 Status = pSocketProtocol->pfnOptionSet ( pSocketProtocol,\r
53 level,\r
54 option_name,\r
55 option_value,\r
56 option_len,\r
57 &errno );\r
58 }\r
59 \r
60 //\r
61 // Return the operation stauts\r
62 //\r
63 OptionStatus = ( 0 == errno ) ? 0 : -1;\r
64 return OptionStatus;\r
65}\r