---------- * Write currently connected IP address into host_addr (of len host_addr_len). * If unable to, set it to the empty string. * ---------- */
| 1730 | * ---------- |
| 1731 | */ |
| 1732 | static void |
| 1733 | getHostaddr(PGconn *conn, char *host_addr, int host_addr_len) |
| 1734 | { |
| 1735 | struct sockaddr_storage *addr = &conn->raddr.addr; |
| 1736 | |
| 1737 | if (addr->ss_family == AF_INET) |
| 1738 | { |
| 1739 | if (pg_inet_net_ntop(AF_INET, |
| 1740 | &((struct sockaddr_in *) addr)->sin_addr.s_addr, |
| 1741 | 32, |
| 1742 | host_addr, host_addr_len) == NULL) |
| 1743 | host_addr[0] = '\0'; |
| 1744 | } |
| 1745 | #ifdef HAVE_IPV6 |
| 1746 | else if (addr->ss_family == AF_INET6) |
| 1747 | { |
| 1748 | if (pg_inet_net_ntop(AF_INET6, |
| 1749 | &((struct sockaddr_in6 *) addr)->sin6_addr.s6_addr, |
| 1750 | 128, |
| 1751 | host_addr, host_addr_len) == NULL) |
| 1752 | host_addr[0] = '\0'; |
| 1753 | } |
| 1754 | #endif |
| 1755 | else |
| 1756 | host_addr[0] = '\0'; |
| 1757 | } |
| 1758 | |
| 1759 | /* |
| 1760 | * emitHostIdentityInfo - |
no test coverage detected