-/**
- * Look up the local or remote side of a connected socket structure.
- *
- * \param fd The socket descriptor of the connected socket.
- * \param getname Either \p getsockname() for local, or \p getpeername() for
- * remote side.
- *
- * \return A static character string identifying hostname and port of the
- * chosen side.
- *
- * \sa getsockname(2), getpeername(2).
- */
-static char *__get_sock_name(int fd, int (*getname)(int, struct sockaddr*,
- socklen_t *))
-{
- struct sockaddr_storage ss;
- socklen_t sslen = sizeof(ss);
-
- if (getname(fd, (struct sockaddr *)&ss, &sslen) < 0) {
- static char *dont_know = "(don't know)";
- PARA_ERROR_LOG("can not determine address from fd %d: %s\n",
- fd, strerror(errno));
- return dont_know;
- }
- return host_and_port(&ss);
-}
-
-/**
- * Look up the local side of a connected socket structure.
- *
- * \param sockfd The file descriptor of the socket.
- *
- * \return A pointer to a static buffer containing hostname an port. This
- * buffer must not be freed by the caller.
- *
- * \sa remote_name().
- */
-char *local_name(int sockfd)
-{
- return __get_sock_name(sockfd, getsockname);
-}
-
-/**
- * Look up the remote side of a connected socket structure.
- *
- * \param sockfd The file descriptor of the socket.
- *
- * \return Analogous to the return value of \ref local_name() but for the
- * remote side.
- *
- * \sa local_name().
- */
-char *remote_name(int sockfd)
-{
- return __get_sock_name(sockfd, getpeername);
-}
-