MCPcopy Create free account
hub / github.com/apache/cloudberry / getHostaddr

Function getHostaddr

src/interfaces/libpq/fe-connect.c:1732–1757  ·  view source on GitHub ↗

---------- * Write currently connected IP address into host_addr (of len host_addr_len). * If unable to, set it to the empty string. * ---------- */

Source from the content-addressed store, hash-verified

1730 * ----------
1731 */
1732static void
1733getHostaddr(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 -

Callers 1

PQconnectPollFunction · 0.85

Calls 1

pg_inet_net_ntopFunction · 0.85

Tested by

no test coverage detected