#include "postgres.h"#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include "access/hash.h"#include "catalog/pg_type.h"#include "libpq/ip.h"#include "libpq/libpq-be.h"#include "libpq/pqformat.h"#include "miscadmin.h"#include "utils/builtins.h"#include "utils/inet.h"
Go to the source code of this file.
Macros | |
| #define | ip_family(inetptr) (((inet_struct *) VARDATA_ANY(inetptr))->family) |
| #define | ip_bits(inetptr) (((inet_struct *) VARDATA_ANY(inetptr))->bits) |
| #define | ip_addr(inetptr) (((inet_struct *) VARDATA_ANY(inetptr))->ipaddr) |
| #define | ip_maxbits(inetptr) (ip_family(inetptr) == PGSQL_AF_INET ? 32 : 128) |
| #define | SET_INET_VARSIZE(dst) |
| #define ip_addr | ( | inetptr | ) | (((inet_struct *) VARDATA_ANY(inetptr))->ipaddr) |
Definition at line 51 of file network.c.
Referenced by cidr_abbrev(), cidr_set_masklen(), convert_network_to_scalar(), inet_abbrev(), inet_to_cidr(), inetand(), inetmi(), inetnot(), inetor(), internal_inetpl(), network_broadcast(), network_cmp_internal(), network_host(), network_hostmask(), network_in(), network_netmask(), network_network(), network_out(), network_recv(), network_send(), network_show(), network_sub(), network_subeq(), network_sup(), and network_supeq().
| #define ip_bits | ( | inetptr | ) | (((inet_struct *) VARDATA_ANY(inetptr))->bits) |
Definition at line 48 of file network.c.
Referenced by cidr_abbrev(), cidr_set_masklen(), inet_abbrev(), inet_set_masklen(), inet_to_cidr(), inetand(), inetnot(), inetor(), internal_inetpl(), network_broadcast(), network_cmp_internal(), network_hostmask(), network_in(), network_masklen(), network_netmask(), network_network(), network_out(), network_recv(), network_send(), network_show(), network_sub(), network_subeq(), network_sup(), and network_supeq().
| #define ip_family | ( | inetptr | ) | (((inet_struct *) VARDATA_ANY(inetptr))->family) |
Definition at line 45 of file network.c.
Referenced by cidr_abbrev(), convert_network_to_scalar(), inet_abbrev(), inetand(), inetmi(), inetnot(), inetor(), internal_inetpl(), ip_addrsize(), network_broadcast(), network_cmp_internal(), network_family(), network_host(), network_hostmask(), network_in(), network_netmask(), network_network(), network_out(), network_recv(), network_send(), network_show(), network_sub(), network_subeq(), network_sup(), and network_supeq().
| #define ip_maxbits | ( | inetptr | ) | (ip_family(inetptr) == PGSQL_AF_INET ? 32 : 128) |
Definition at line 54 of file network.c.
Referenced by cidr_set_masklen(), inet_set_masklen(), inet_to_cidr(), network_cmp_internal(), network_host(), network_hostmask(), network_in(), network_netmask(), network_recv(), and network_show().
| #define SET_INET_VARSIZE | ( | dst | ) |
Definition at line 57 of file network.c.
Referenced by inetand(), inetnot(), inetor(), internal_inetpl(), network_broadcast(), network_hostmask(), network_in(), network_netmask(), network_network(), and network_recv().
|
static |
Definition at line 995 of file network.c.
References Assert, byte, and PGSQL_AF_INET.
Referenced by network_in(), and network_recv().
|
static |
Definition at line 966 of file network.c.
References IS_HIGHBIT_SET, and memcmp().
Referenced by network_cmp_internal(), network_sub(), network_subeq(), network_sup(), and network_supeq().
| Datum cidr_abbrev | ( | PG_FUNCTION_ARGS | ) |
Definition at line 670 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, inet_cidr_ntop(), ip_addr, ip_bits, ip_family, NULL, PG_GETARG_INET_PP, and PG_RETURN_TEXT_P.
| Datum cidr_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 137 of file network.c.
References network_in(), PG_GETARG_CSTRING, and PG_RETURN_INET_P.
| Datum cidr_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 181 of file network.c.
References network_out(), PG_GETARG_INET_PP, and PG_RETURN_CSTRING.
| Datum cidr_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 266 of file network.c.
References buf, network_recv(), PG_GETARG_POINTER, and PG_RETURN_INET_P.
| Datum cidr_send | ( | PG_FUNCTION_ARGS | ) |
Definition at line 308 of file network.c.
References network_send(), PG_GETARG_INET_PP, and PG_RETURN_BYTEA_P.
| Datum cidr_set_masklen | ( | PG_FUNCTION_ARGS | ) |
Definition at line 382 of file network.c.
References byte, ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize(), ip_bits, ip_maxbits, palloc(), PG_GETARG_INET_PP, PG_GETARG_INT32, PG_RETURN_INET_P, and VARSIZE_ANY.
| void clean_ipv6_addr | ( | int | addr_family, |
| char * | addr | ||
| ) |
Definition at line 1457 of file network.c.
Referenced by inet_client_addr(), inet_server_addr(), pg_stat_get_activity(), and pg_stat_get_backend_client_addr().
Definition at line 903 of file network.c.
References macaddr::a, macaddr::b, macaddr::c, CIDROID, macaddr::d, DatumGetInetPP, DatumGetMacaddrP, macaddr::e, elog, ERROR, macaddr::f, i, INETOID, ip_addr, ip_family, MACADDROID, and PGSQL_AF_INET.
Referenced by convert_to_scalar(), gbt_inet_compress(), and gbt_inet_consistent().
| Datum hashinet | ( | PG_FUNCTION_ARGS | ) |
Definition at line 527 of file network.c.
References hash_any(), ip_addrsize(), PG_GETARG_INET_PP, and VARDATA_ANY.
| Datum inet_abbrev | ( | PG_FUNCTION_ARGS | ) |
Definition at line 652 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, inet_net_ntop(), ip_addr, ip_bits, ip_family, NULL, PG_GETARG_INET_PP, and PG_RETURN_TEXT_P.
| Datum inet_client_addr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1070 of file network.c.
References SockAddr::addr, clean_ipv6_addr(), MyProcPort, network_in(), NI_MAXHOST, NI_NUMERICHOST, NI_NUMERICSERV, NULL, pg_getnameinfo_all(), PG_RETURN_INET_P, PG_RETURN_NULL, port, Port::raddr, and SockAddr::salen.
| Datum inet_client_port | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1109 of file network.c.
References SockAddr::addr, CStringGetDatum, DirectFunctionCall1, int4in(), MyProcPort, NI_MAXSERV, NI_NUMERICHOST, NI_NUMERICSERV, NULL, pg_getnameinfo_all(), PG_RETURN_DATUM, PG_RETURN_NULL, port, Port::raddr, and SockAddr::salen.
| Datum inet_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 129 of file network.c.
References network_in(), PG_GETARG_CSTRING, and PG_RETURN_INET_P.
Referenced by leftmostvalue_inet(), pg_stat_get_activity(), and pg_stat_get_backend_client_addr().
| Datum inet_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 173 of file network.c.
References network_out(), PG_GETARG_INET_PP, and PG_RETURN_CSTRING.
| Datum inet_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 258 of file network.c.
References buf, network_recv(), PG_GETARG_POINTER, and PG_RETURN_INET_P.
| Datum inet_send | ( | PG_FUNCTION_ARGS | ) |
Definition at line 300 of file network.c.
References network_send(), PG_GETARG_INET_PP, and PG_RETURN_BYTEA_P.
| Datum inet_server_addr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1146 of file network.c.
References SockAddr::addr, clean_ipv6_addr(), Port::laddr, MyProcPort, network_in(), NI_MAXHOST, NI_NUMERICHOST, NI_NUMERICSERV, NULL, pg_getnameinfo_all(), PG_RETURN_INET_P, PG_RETURN_NULL, port, and SockAddr::salen.
| Datum inet_server_port | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1185 of file network.c.
References SockAddr::addr, CStringGetDatum, DirectFunctionCall1, int4in(), Port::laddr, MyProcPort, NI_MAXSERV, NI_NUMERICHOST, NI_NUMERICSERV, NULL, pg_getnameinfo_all(), PG_RETURN_DATUM, PG_RETURN_NULL, port, and SockAddr::salen.
| Datum inet_set_masklen | ( | PG_FUNCTION_ARGS | ) |
Definition at line 358 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_bits, ip_maxbits, palloc(), PG_GETARG_INET_PP, PG_GETARG_INT32, PG_RETURN_INET_P, and VARSIZE_ANY.
Referenced by network_scan_last().
| Datum inet_to_cidr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 317 of file network.c.
References byte, elog, ERROR, ip_addr, ip_addrsize(), ip_bits, ip_maxbits, palloc(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and VARSIZE_ANY.
| Datum inetand | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1244 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize(), ip_bits, ip_family, Max, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
| Datum inetmi | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1380 of file network.c.
References byte, ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize(), ip_family, PG_GETARG_INET_PP, and PG_RETURN_INT64.
| Datum inetmi_int8 | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1370 of file network.c.
References internal_inetpl(), PG_GETARG_INET_PP, PG_GETARG_INT64, and PG_RETURN_INET_P.
| Datum inetnot | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1219 of file network.c.
References ip_addr, ip_addrsize(), ip_bits, ip_family, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
| Datum inetor | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1276 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize(), ip_bits, ip_family, Max, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
| Datum inetpl | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1360 of file network.c.
References internal_inetpl(), PG_GETARG_INET_PP, PG_GETARG_INT64, and PG_RETURN_INET_P.
Definition at line 1308 of file network.c.
References ereport, errcode(), errmsg(), ERROR, ip_addr, ip_addrsize(), ip_bits, ip_family, palloc0(), and SET_INET_VARSIZE.
Referenced by inetmi_int8(), and inetpl().
|
static |
Definition at line 66 of file network.c.
References ip_family, PGSQL_AF_INET, and PGSQL_AF_INET6.
Referenced by cidr_set_masklen(), hashinet(), inet_to_cidr(), inetand(), inetmi(), inetnot(), inetor(), internal_inetpl(), network_in(), network_recv(), and network_send().
| Datum network_broadcast | ( | PG_FUNCTION_ARGS | ) |
Definition at line 715 of file network.c.
References byte, ip_addr, ip_bits, ip_family, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, PGSQL_AF_INET, and SET_INET_VARSIZE.
Referenced by network_scan_last().
| Datum network_cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 458 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_INT32.
Definition at line 438 of file network.c.
References bitncmp(), ip_addr, ip_bits, ip_family, ip_maxbits, and Min.
Referenced by network_cmp(), network_eq(), network_ge(), network_gt(), network_le(), network_lt(), and network_ne().
| Datum network_eq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 488 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
| Datum network_family | ( | PG_FUNCTION_ARGS | ) |
Definition at line 696 of file network.c.
References ip_family, PG_GETARG_INET_PP, PG_RETURN_INT32, PGSQL_AF_INET, and PGSQL_AF_INET6.
| Datum network_ge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 497 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
| Datum network_gt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 506 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
| Datum network_host | ( | PG_FUNCTION_ARGS | ) |
Definition at line 603 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, inet_net_ntop(), ip_addr, ip_family, ip_maxbits, NULL, PG_GETARG_INET_PP, and PG_RETURN_TEXT_P.
| Datum network_hostmask | ( | PG_FUNCTION_ARGS | ) |
Definition at line 850 of file network.c.
References byte, ip_addr, ip_bits, ip_family, ip_maxbits, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, PGSQL_AF_INET, and SET_INET_VARSIZE.
Definition at line 83 of file network.c.
References addressOK(), ereport, errcode(), errdetail(), errmsg(), ERROR, inet_net_pton(), ip_addr, ip_addrsize(), ip_bits, ip_family, ip_maxbits, NULL, palloc0(), PGSQL_AF_INET, PGSQL_AF_INET6, and SET_INET_VARSIZE.
Referenced by cidr_in(), inet_client_addr(), inet_in(), and inet_server_addr().
| Datum network_le | ( | PG_FUNCTION_ARGS | ) |
Definition at line 479 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
| Datum network_lt | ( | PG_FUNCTION_ARGS | ) |
Definition at line 470 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
| Datum network_masklen | ( | PG_FUNCTION_ARGS | ) |
Definition at line 688 of file network.c.
References ip_bits, PG_GETARG_INET_PP, and PG_RETURN_INT32.
| Datum network_ne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 515 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_BOOL.
| Datum network_netmask | ( | PG_FUNCTION_ARGS | ) |
Definition at line 808 of file network.c.
References byte, ip_addr, ip_bits, ip_family, ip_maxbits, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
| Datum network_network | ( | PG_FUNCTION_ARGS | ) |
Definition at line 764 of file network.c.
References byte, ip_addr, ip_bits, ip_family, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Referenced by network_scan_first().
Definition at line 149 of file network.c.
References ereport, errcode(), errmsg(), ERROR, inet_net_ntop(), ip_addr, ip_bits, ip_family, NULL, pstrdup(), and snprintf().
Referenced by cidr_out(), and inet_out().
|
static |
Definition at line 200 of file network.c.
References addressOK(), ereport, errcode(), errdetail(), errmsg(), ERROR, i, ip_addr, ip_addrsize(), ip_bits, ip_family, ip_maxbits, palloc0(), PGSQL_AF_INET, PGSQL_AF_INET6, pq_getmsgbyte(), and SET_INET_VARSIZE.
Referenced by cidr_recv(), and inet_recv().
Definition at line 1044 of file network.c.
References DirectFunctionCall1, and network_network().
Referenced by network_prefix_quals().
Definition at line 1058 of file network.c.
References DirectFunctionCall1, DirectFunctionCall2, inet_set_masklen(), Int32GetDatum, and network_broadcast().
Referenced by network_prefix_quals().
Definition at line 278 of file network.c.
References buf, i, ip_addr, ip_addrsize(), ip_bits, ip_family, pq_begintypsend(), pq_endtypsend(), and pq_sendbyte().
Referenced by cidr_send(), and inet_send().
| Datum network_show | ( | PG_FUNCTION_ARGS | ) |
Definition at line 629 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, inet_net_ntop(), ip_addr, ip_bits, ip_family, ip_maxbits, NULL, PG_GETARG_INET_PP, PG_RETURN_TEXT_P, and snprintf().
| Datum network_sub | ( | PG_FUNCTION_ARGS | ) |
Definition at line 540 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.
| Datum network_subeq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 555 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.
| Datum network_sup | ( | PG_FUNCTION_ARGS | ) |
Definition at line 570 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.
| Datum network_supeq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 585 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.