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