net/socket/getsockname.c: Add psock_getsockname function

This commit is contained in:
Xiang Xiao
2018-08-26 14:43:13 -06:00
committed by Gregory Nutt
parent fd1405d976
commit 3eedabfded
2 changed files with 108 additions and 36 deletions
+40
View File
@@ -1070,6 +1070,46 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
int psock_setsockopt(FAR struct socket *psock, int level, int option,
FAR const void *value, socklen_t value_len);
/****************************************************************************
* Name: psock_getsockname
*
* Description:
* The psock_getsockname() function retrieves the locally-bound name of the
* the specified socket, stores this address in the sockaddr structure pointed
* to by the 'addr' argument, and stores the length of this address in the
* object pointed to by the 'addrlen' argument.
*
* If the actual length of the address is greater than the length of the
* supplied sockaddr structure, the stored address will be truncated.
*
* If the socket has not been bound to a local name, the value stored in
* the object pointed to by address is unspecified.
*
* Parameters:
* psock Socket structure of socket to operate on
* addr sockaddr structure to receive data [out]
* addrlen Length of sockaddr structure [in/out]
*
* Returned Value:
* On success, 0 is returned, the 'addr' argument points to the address
* of the socket, and the 'addrlen' argument points to the length of the
* address. Otherwise, -1 is returned and errno is set to indicate the error.
* Possible errno values that may be returned include:
*
* EBADF - The socket argument is not a valid file descriptor.
* ENOTSOCK - The socket argument does not refer to a socket.
* EOPNOTSUPP - The operation is not supported for this socket's protocol.
* ENOTCONN - The socket is not connected or otherwise has not had the
* peer pre-specified.
* EINVAL - The socket has been shut down.
* ENOBUFS - Insufficient resources were available in the system to
* complete the function.
*
****************************************************************************/
int psock_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
FAR socklen_t *addrlen);
/****************************************************************************
* Name: psock_getpeername
*