PostgreSQL Source Code git master
ip.h File Reference
#include <netdb.h>
#include <sys/socket.h>
#include "libpq/pqcomm.h"
Include dependency graph for ip.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int pg_getaddrinfo_all (const char *hostname, const char *servname, const struct addrinfo *hintp, struct addrinfo **result)
 
void pg_freeaddrinfo_all (int hint_ai_family, struct addrinfo *ai)
 
int pg_getnameinfo_all (const struct sockaddr_storage *addr, int salen, char *node, int nodelen, char *service, int servicelen, int flags)
 

Function Documentation

◆ pg_freeaddrinfo_all()

void pg_freeaddrinfo_all ( int  hint_ai_family,
struct addrinfo *  ai 
)

Definition at line 85 of file ip.c.

86{
87 if (hint_ai_family == AF_UNIX)
88 {
89 /* struct was built by getaddrinfo_unix (see pg_getaddrinfo_all) */
90 while (ai != NULL)
91 {
92 struct addrinfo *p = ai;
93
94 ai = ai->ai_next;
95 free(p->ai_addr);
96 free(p);
97 }
98 }
99 else
100 {
101 /* struct was built by getaddrinfo() */
102 if (ai != NULL)
103 freeaddrinfo(ai);
104 }
105}
#define free(a)
Definition: header.h:65

References free.

Referenced by ident_inet(), ListenServerPort(), parse_hba_auth_opt(), parse_hba_line(), PerformRadiusTransaction(), and PQconnectPoll().

◆ pg_getaddrinfo_all()

int pg_getaddrinfo_all ( const char *  hostname,
const char *  servname,
const struct addrinfo *  hintp,
struct addrinfo **  result 
)

Definition at line 56 of file ip.c.

58{
59 int rc;
60
61 /* not all versions of getaddrinfo() zero *result on failure */
62 *result = NULL;
63
64 if (hintp->ai_family == AF_UNIX)
65 return getaddrinfo_unix(servname, hintp, result);
66
67 /* NULL has special meaning to getaddrinfo(). */
68 rc = getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname,
69 servname, hintp, result);
70
71 return rc;
72}
static int getaddrinfo_unix(const char *path, const struct addrinfo *hintsp, struct addrinfo **result)
Definition: ip.c:156
static char * hostname
Definition: pg_regress.c:114

References getaddrinfo_unix(), and hostname.

Referenced by ident_inet(), ListenServerPort(), parse_hba_auth_opt(), parse_hba_line(), PerformRadiusTransaction(), and PQconnectPoll().

◆ pg_getnameinfo_all()

int pg_getnameinfo_all ( const struct sockaddr_storage *  addr,
int  salen,
char *  node,
int  nodelen,
char *  service,
int  servicelen,
int  flags 
)

Definition at line 117 of file ip.c.

121{
122 int rc;
123
124 if (addr && addr->ss_family == AF_UNIX)
125 rc = getnameinfo_unix((const struct sockaddr_un *) addr, salen,
126 node, nodelen,
127 service, servicelen,
128 flags);
129 else
130 rc = getnameinfo((const struct sockaddr *) addr, salen,
131 node, nodelen,
132 service, servicelen,
133 flags);
134
135 if (rc != 0)
136 {
137 if (node)
138 strlcpy(node, "???", nodelen);
139 if (service)
140 strlcpy(service, "???", servicelen);
141 }
142
143 return rc;
144}
static int getnameinfo_unix(const struct sockaddr_un *sa, int salen, char *node, int nodelen, char *service, int servicelen, int flags)
Definition: ip.c:231
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
Definition: un.h:12

References getnameinfo_unix(), and strlcpy().

Referenced by BackendInitialize(), check_hostname(), ClientAuthentication(), emitHostIdentityInfo(), fill_hba_line(), ident_inet(), inet_client_addr(), inet_client_port(), inet_server_addr(), inet_server_port(), ListenServerPort(), log_status_format(), pg_stat_get_activity(), pg_stat_get_backend_client_addr(), and pg_stat_get_backend_client_port().