/*
* char *
- * inet_cidr_ntop(af, src, bits, dst, size)
+ * pg_inet_cidr_ntop(af, src, bits, dst, size)
* convert network number from network to presentation format.
* generates CIDR style result always.
* return:
* Paul Vixie (ISC), July 1996
*/
char *
-inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size)
+pg_inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size)
{
switch (af)
{
/*
* int
- * inet_net_pton(af, src, dst, size)
+ * pg_inet_net_pton(af, src, dst, size)
* convert network number from presentation to network format.
* accepts hex octets, hex strings, decimal octets, and /CIDR.
* "size" is in bytes and describes "dst".
*
*/
int
-inet_net_pton(int af, const char *src, void *dst, size_t size)
+pg_inet_net_pton(int af, const char *src, void *dst, size_t size)
{
switch (af)
{
/*
* int
- * inet_net_pton(af, src, dst, *bits)
+ * inet_net_pton_ipv4(af, src, dst, *bits)
* convert network address from presentation to network format.
* accepts inet_pton()'s input for this "af" plus trailing "/CIDR".
* "dst" is assumed large enough for its "af". "bits" is set to the
else
ip_family(dst) = PGSQL_AF_INET;
- bits = inet_net_pton(ip_family(dst), src, ip_addr(dst),
- is_cidr ? ip_addrsize(dst) : -1);
+ bits = pg_inet_net_pton(ip_family(dst), src, ip_addr(dst),
+ is_cidr ? ip_addrsize(dst) : -1);
if ((bits < 0) || (bits > ip_maxbits(dst)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
char *dst;
int len;
- dst = inet_net_ntop(ip_family(src), ip_addr(src), ip_bits(src),
- tmp, sizeof(tmp));
+ dst = pg_inet_net_ntop(ip_family(src), ip_addr(src), ip_bits(src),
+ tmp, sizeof(tmp));
if (dst == NULL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
/* force display of max bits, regardless of masklen... */
- if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip),
- tmp, sizeof(tmp)) == NULL)
+ if (pg_inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip),
+ tmp, sizeof(tmp)) == NULL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("could not format inet value: %m")));
int len;
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
- if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip),
- tmp, sizeof(tmp)) == NULL)
+ if (pg_inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip),
+ tmp, sizeof(tmp)) == NULL)
ereport(ERROR,
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
errmsg("could not format inet value: %m")));
char *dst;
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
- dst = inet_net_ntop(ip_family(ip), ip_addr(ip),
- ip_bits(ip), tmp, sizeof(tmp));
+ dst = pg_inet_net_ntop(ip_family(ip), ip_addr(ip),
+ ip_bits(ip), tmp, sizeof(tmp));
if (dst == NULL)
ereport(ERROR,
char *dst;
char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
- dst = inet_cidr_ntop(ip_family(ip), ip_addr(ip),
- ip_bits(ip), tmp, sizeof(tmp));
+ dst = pg_inet_cidr_ntop(ip_family(ip), ip_addr(ip),
+ ip_bits(ip), tmp, sizeof(tmp));
if (dst == NULL)
ereport(ERROR,
#endif
/* port/inet_net_ntop.c */
-extern char *inet_net_ntop(int af, const void *src, int bits,
- char *dst, size_t size);
+extern char *pg_inet_net_ntop(int af, const void *src, int bits,
+ char *dst, size_t size);
/* port/pg_strong_random.c */
extern bool pg_strong_random(void *buf, size_t len);
extern int xidComparator(const void *arg1, const void *arg2);
/* inet_cidr_ntop.c */
-extern char *inet_cidr_ntop(int af, const void *src, int bits,
- char *dst, size_t size);
+extern char *pg_inet_cidr_ntop(int af, const void *src, int bits,
+ char *dst, size_t size);
/* inet_net_pton.c */
-extern int inet_net_pton(int af, const char *src,
- void *dst, size_t size);
+extern int pg_inet_net_pton(int af, const char *src,
+ void *dst, size_t size);
/* network.c */
extern double convert_network_to_scalar(Datum value, Oid typid, bool *failure);
if (addr->ss_family == AF_INET)
{
- if (inet_net_ntop(AF_INET,
- &((struct sockaddr_in *) addr)->sin_addr.s_addr,
- 32,
- host_addr, host_addr_len) == NULL)
+ if (pg_inet_net_ntop(AF_INET,
+ &((struct sockaddr_in *) addr)->sin_addr.s_addr,
+ 32,
+ host_addr, host_addr_len) == NULL)
host_addr[0] = '\0';
}
#ifdef HAVE_IPV6
else if (addr->ss_family == AF_INET6)
{
- if (inet_net_ntop(AF_INET6,
- &((struct sockaddr_in6 *) addr)->sin6_addr.s6_addr,
- 128,
- host_addr, host_addr_len) == NULL)
+ if (pg_inet_net_ntop(AF_INET6,
+ &((struct sockaddr_in6 *) addr)->sin6_addr.s6_addr,
+ 128,
+ host_addr, host_addr_len) == NULL)
host_addr[0] = '\0';
}
#endif
{
if (sa->sa_family == AF_INET)
{
- if (inet_net_ntop(AF_INET, &((struct sockaddr_in *) sa)->sin_addr,
- sa->sa_family == AF_INET ? 32 : 128,
- node, nodelen) == NULL)
+ if (pg_inet_net_ntop(AF_INET,
+ &((struct sockaddr_in *) sa)->sin_addr,
+ sa->sa_family == AF_INET ? 32 : 128,
+ node, nodelen) == NULL)
return EAI_MEMORY;
}
else
#else
/*
* In a frontend build, we can't include inet.h, but we still need to have
- * sensible definitions of these two constants. Note that inet_net_ntop()
+ * sensible definitions of these two constants. Note that pg_inet_net_ntop()
* assumes that PGSQL_AF_INET is equal to AF_INET.
*/
#define PGSQL_AF_INET (AF_INET + 0)
/*
* char *
- * inet_net_ntop(af, src, bits, dst, size)
+ * pg_inet_net_ntop(af, src, bits, dst, size)
* convert host/network address from network to presentation format.
* "src"'s size is determined from its "af".
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* note:
* 192.5.5.1/28 has a nonzero host part, which means it isn't a network
- * as called for by inet_net_pton() but it can be a host address with
+ * as called for by pg_inet_net_pton() but it can be a host address with
* an included netmask.
* author:
* Paul Vixie (ISC), October 1998
*/
char *
-inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
+pg_inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
{
/*
* We need to cover both the address family constants used by the PG inet