]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/getsockopt.c
Remove SocketPkg references
[mirror_edk2.git] / StdLib / BsdSocketLib / getsockopt.c
1 /** @file
2 Implement the getsockopt 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 Get 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 [out] option_value Buffer to receive the option value
25 @param [in,out] option_len Length of the buffer in bytes,
26 upon return length of the option value in bytes
27
28 @retval Zero (0) upon success
29 @retval Minus one (-1) upon failure, errno set with additional error information
30
31 **/
32 int
33 getsockopt (
34 IN int s,
35 IN int level,
36 IN int option_name,
37 OUT void * __restrict option_value,
38 IN OUT socklen_t * __restrict option_len
39 )
40 {
41 int OptionStatus;
42 EFI_SOCKET_PROTOCOL * pSocketProtocol;
43 EFI_STATUS Status;
44
45 //
46 // Locate the context for this socket
47 //
48 pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );
49 if ( NULL != pSocketProtocol ) {
50 //
51 // Get the socket option
52 //
53 Status = pSocketProtocol->pfnOptionGet ( pSocketProtocol,
54 level,
55 option_name,
56 option_value,
57 option_len,
58 &errno );
59 }
60
61 //
62 // Return the operation stauts
63 //
64 OptionStatus = ( 0 == errno ) ? 0 : -1;
65 return OptionStatus;
66 }