]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/getsockname.c
2 Implement the getsockname API.
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
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.
15 #include <SocketInternals.h>
19 Get the local socket address.
21 The getsockname routine retrieves the local system address from the socket.
24 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html#">POSIX</a>
25 documentation is available online.
27 @param [in] s Socket file descriptor returned from ::socket.
29 @param [out] address Network address to receive the local system address
31 @param [in] address_len Length of the local network address structure
33 @return This routine returns zero (0) if successful or -1 when an error occurs.
34 In the case of an error, ::errno contains more details.
40 struct sockaddr
* address
,
41 socklen_t
* address_len
45 EFI_SOCKET_PROTOCOL
* pSocketProtocol
;
54 // Locate the context for this socket
56 pSocketProtocol
= BslFdToSocketProtocol ( s
, NULL
, &errno
);
57 if ( NULL
!= pSocketProtocol
) {
59 // Get the local socket address
61 Status
= pSocketProtocol
->pfnGetLocal ( pSocketProtocol
,
65 if ( !EFI_ERROR ( Status
)) {
71 // Return the operation status