]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/shutdown.c
UefiCpuPkg/MicrocodeUpdateDxe: Fix coding style issues in INF file
[mirror_edk2.git] / StdLib / BsdSocketLib / shutdown.c
1 /** @file
2 Implement the shutdown 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 Shutdown the socket receive and transmit operations
20
21 The shutdown routine stops socket receive and transmit operations.
22
23 The
24 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html">POSIX</a>
25 documentation is available online.
26
27 @param [in] s Socket file descriptor returned from ::socket.
28
29 @param [in] how Which operations to shutdown
30
31 @return This routine returns the zero (0) if successful or -1 when an
32 error occurs. In the latter case, ::errno contains more details.
33
34 **/
35 int
36 shutdown (
37 int s,
38 int how
39 )
40 {
41 int RetVal;
42 EFI_SOCKET_PROTOCOL * pSocketProtocol;
43 EFI_STATUS Status;
44
45 //
46 // Assume failure
47 //
48 RetVal = -1;
49
50 //
51 // Locate the context for this socket
52 //
53 pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );
54 if ( NULL != pSocketProtocol ) {
55 //
56 // Receive the data from the socket
57 //
58 Status = pSocketProtocol->pfnShutdown ( pSocketProtocol,
59 how,
60 &errno );
61 if ( !EFI_ERROR ( Status )) {
62 //
63 // Success
64 //
65 RetVal = 0;
66 }
67 }
68
69 //
70 // Return the operation status
71 //
72 return RetVal;
73 }