]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/setsockopt.c
Fix send to properly wait while long transmits are in progress
[mirror_edk2.git] / StdLib / BsdSocketLib / setsockopt.c
1 /** @file
2 Implement the setsockopt API.
3
4 Copyright (c) 2011, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <SocketInternals.h>
16
17
18 /**
19 Set the socket options
20
21 @param [in] s Socket file descriptor returned from ::socket.
22 @param [in] level Option protocol level
23 @param [in] option_name Name of the option
24 @param [in] option_value Buffer containing the option value
25 @param [in] option_len Length of the value in bytes
26
27 @retval Zero (0) upon success
28 @retval Minus one (-1) upon failure, errno set with additional error information
29
30 **/
31 int
32 setsockopt (
33 IN int s,
34 IN int level,
35 IN int option_name,
36 IN CONST void * option_value,
37 IN socklen_t option_len
38 )
39 {
40 int OptionStatus;
41 EFI_SOCKET_PROTOCOL * pSocketProtocol;
42 EFI_STATUS Status;
43
44 //
45 // Locate the context for this socket
46 //
47 pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );
48 if ( NULL != pSocketProtocol ) {
49 //
50 // Set the socket option
51 //
52 Status = pSocketProtocol->pfnOptionSet ( pSocketProtocol,
53 level,
54 option_name,
55 option_value,
56 option_len,
57 &errno );
58 }
59
60 //
61 // Return the operation stauts
62 //
63 OptionStatus = ( 0 == errno ) ? 0 : -1;
64 return OptionStatus;
65 }