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