]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/getsockname.c
Fix @return Doxygen commands to be singular instead of plural.
[mirror_edk2.git] / StdLib / BsdSocketLib / getsockname.c
CommitLineData
d7ce7006 1/** @file\r
2 Implement the getsockname 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 Get the local socket address.\r
20\r
21 The ::getsockname routine retrieves the local system address from the socket.\r
22 The\r
23 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.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 [out] address Network address to receive the local system address\r
29\r
30 @param [in] address_len Length of the local network address structure\r
31\r
7dc13291 32 @return ::getsockname returns zero (0) if successful or -1 when an error occurs.\r
d7ce7006 33 In the case of an error, errno contains more details.\r
34\r
35 **/\r
36int\r
37getsockname (\r
38 int s,\r
39 struct sockaddr * address,\r
40 socklen_t * address_len\r
41 )\r
42{\r
43 int RetVal;\r
44 EFI_SOCKET_PROTOCOL * pSocketProtocol;\r
45 EFI_STATUS Status;\r
46\r
47 //\r
48 // Assume failure\r
49 //\r
50 RetVal = -1;\r
51\r
52 //\r
53 // Locate the context for this socket\r
54 //\r
55 pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );\r
56 if ( NULL != pSocketProtocol ) {\r
57 //\r
58 // Get the local socket address\r
59 //\r
60 Status = pSocketProtocol->pfnGetLocal ( pSocketProtocol,\r
61 address,\r
62 address_len,\r
63 &errno );\r
64 if ( !EFI_ERROR ( Status )) {\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