PostgreSQL Source Code
git master
|
#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 "common/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.
|
static |
Definition at line 1049 of file network.c.
References Assert, byte, and PGSQL_AF_INET.
Referenced by network_in(), and network_recv().
int bitncmp | ( | const unsigned char * | l, |
const unsigned char * | r, | ||
int | n | ||
) |
Definition at line 977 of file network.c.
References IS_HIGHBIT_SET.
Referenced by inet_gist_consistent(), inet_inclusion_cmp(), inet_spg_choose(), inet_spg_consistent_bitmap(), network_cmp_internal(), network_overlap(), network_sub(), network_subeq(), network_sup(), and network_supeq().
int bitncommon | ( | const unsigned char * | l, |
const unsigned char * | r, | ||
int | n | ||
) |
Definition at line 1011 of file network.c.
References byte.
Referenced by calc_inet_union_params(), calc_inet_union_params_indexed(), inet_gist_penalty(), inet_hist_match_divider(), inet_merge(), inet_spg_choose(), and inet_spg_picksplit().
Datum cidr_abbrev | ( | PG_FUNCTION_ARGS | ) |
Definition at line 648 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, inet_cidr_ntop(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_TEXT_P.
Datum cidr_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 88 of file network.c.
References network_in(), PG_GETARG_CSTRING, and PG_RETURN_INET_P.
Datum cidr_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 132 of file network.c.
References network_out(), PG_GETARG_INET_PP, and PG_RETURN_CSTRING.
Datum cidr_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 217 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 259 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 307 of file network.c.
References cidr_set_masklen_internal(), ereport, errcode(), errmsg(), ERROR, ip_maxbits, PG_GETARG_INET_PP, PG_GETARG_INT32, and PG_RETURN_INET_P.
Definition at line 327 of file network.c.
References Assert, ip_addr, ip_bits, ip_family, ip_maxbits, palloc0(), and SET_INET_VARSIZE.
Referenced by cidr_set_masklen(), inet_merge(), inet_spg_choose(), inet_spg_picksplit(), and inet_to_cidr().
void clean_ipv6_addr | ( | int | addr_family, |
char * | addr | ||
) |
Definition at line 1511 of file network.c.
Referenced by fill_hba_line(), inet_client_addr(), inet_server_addr(), pg_stat_get_activity(), and pg_stat_get_backend_client_addr().
Definition at line 910 of file network.c.
References macaddr::a, macaddr8::a, macaddr::b, macaddr8::b, macaddr::c, macaddr8::c, macaddr::d, macaddr8::d, DatumGetInetPP, DatumGetMacaddr8P, DatumGetMacaddrP, macaddr::e, macaddr8::e, macaddr::f, macaddr8::f, macaddr8::g, macaddr8::h, i, ip_addr, ip_family, and PGSQL_AF_INET.
Referenced by convert_to_scalar(), gbt_inet_compress(), and gbt_inet_consistent().
Datum hashinet | ( | PG_FUNCTION_ARGS | ) |
Definition at line 480 of file network.c.
References hash_any(), ip_addrsize, PG_GETARG_INET_PP, and VARDATA_ANY.
Datum hashinetextended | ( | PG_FUNCTION_ARGS | ) |
Definition at line 490 of file network.c.
References hash_any_extended(), ip_addrsize, PG_GETARG_INET_PP, PG_GETARG_INT64, and VARDATA_ANY.
Datum inet_abbrev | ( | PG_FUNCTION_ARGS | ) |
Definition at line 630 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, inet_net_ntop(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_TEXT_P.
Datum inet_client_addr | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1124 of file network.c.
References SockAddr::addr, clean_ipv6_addr(), MyProcPort, network_in(), NI_MAXHOST, NI_NUMERICHOST, NI_NUMERICSERV, 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 1163 of file network.c.
References SockAddr::addr, CStringGetDatum, DirectFunctionCall1, int4in(), MyProcPort, NI_MAXSERV, NI_NUMERICHOST, NI_NUMERICSERV, pg_getnameinfo_all(), PG_RETURN_DATUM, PG_RETURN_NULL, port, Port::raddr, and SockAddr::salen.
Datum inet_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 80 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_merge | ( | PG_FUNCTION_ARGS | ) |
Definition at line 884 of file network.c.
References a1, a2, bitncommon(), cidr_set_masklen_internal(), ereport, errcode(), errmsg(), ERROR, ip_addr, ip_bits, ip_family, Min, PG_GETARG_INET_PP, and PG_RETURN_INET_P.
Datum inet_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 124 of file network.c.
References network_out(), PG_GETARG_INET_PP, and PG_RETURN_CSTRING.
Datum inet_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 209 of file network.c.
References buf, network_recv(), PG_GETARG_POINTER, and PG_RETURN_INET_P.
Datum inet_same_family | ( | PG_FUNCTION_ARGS | ) |
Definition at line 872 of file network.c.
References a1, a2, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.
Datum inet_send | ( | PG_FUNCTION_ARGS | ) |
Definition at line 251 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 1200 of file network.c.
References SockAddr::addr, clean_ipv6_addr(), Port::laddr, MyProcPort, network_in(), NI_MAXHOST, NI_NUMERICHOST, NI_NUMERICSERV, pg_getnameinfo_all(), PG_RETURN_INET_P, PG_RETURN_NULL, port, and SockAddr::salen.
Datum inet_server_port | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1239 of file network.c.
References SockAddr::addr, CStringGetDatum, DirectFunctionCall1, int4in(), Port::laddr, MyProcPort, NI_MAXSERV, NI_NUMERICHOST, NI_NUMERICSERV, pg_getnameinfo_all(), PG_RETURN_DATUM, PG_RETURN_NULL, port, and SockAddr::salen.
Datum inet_set_masklen | ( | PG_FUNCTION_ARGS | ) |
Definition at line 283 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 268 of file network.c.
References cidr_set_masklen_internal(), elog, ERROR, ip_bits, ip_maxbits, PG_GETARG_INET_PP, and PG_RETURN_INET_P.
Datum inetand | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1298 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 1434 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 1424 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 1273 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 1330 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 1414 of file network.c.
References internal_inetpl(), PG_GETARG_INET_PP, PG_GETARG_INT64, and PG_RETURN_INET_P.
Definition at line 1362 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().
Datum network_broadcast | ( | PG_FUNCTION_ARGS | ) |
Definition at line 693 of file network.c.
References byte, ip_addr, ip_addrsize, ip_bits, ip_family, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Referenced by network_scan_last().
Datum network_cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 384 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_INT32.
Referenced by leftmostvalue_inet().
Definition at line 364 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_larger(), network_le(), network_lt(), network_ne(), and network_smaller().
Datum network_eq | ( | PG_FUNCTION_ARGS | ) |
Definition at line 414 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 674 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 423 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 432 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 581 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, inet_net_ntop(), ip_addr, ip_family, ip_maxbits, PG_GETARG_INET_PP, and PG_RETURN_TEXT_P.
Datum network_hostmask | ( | PG_FUNCTION_ARGS | ) |
Definition at line 824 of file network.c.
References byte, ip_addr, ip_addrsize, ip_bits, ip_family, ip_maxbits, palloc0(), PG_GETARG_INET_PP, PG_RETURN_INET_P, and SET_INET_VARSIZE.
Definition at line 34 of file network.c.
References addressOK(), ereport, errcode(), errdetail(), errmsg(), ERROR, inet_net_pton(), ip_addr, ip_addrsize, ip_bits, ip_family, ip_maxbits, 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_larger | ( | PG_FUNCTION_ARGS | ) |
Definition at line 465 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_INET_P.
Datum network_le | ( | PG_FUNCTION_ARGS | ) |
Definition at line 405 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 396 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 666 of file network.c.
References ip_bits, PG_GETARG_INET_PP, and PG_RETURN_INT32.
Datum network_ne | ( | PG_FUNCTION_ARGS | ) |
Definition at line 441 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 782 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 738 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 100 of file network.c.
References ereport, errcode(), errmsg(), ERROR, inet_net_ntop(), ip_addr, ip_bits, ip_family, pstrdup(), and snprintf().
Referenced by cidr_out(), and inet_out().
Datum network_overlap | ( | PG_FUNCTION_ARGS | ) |
|
static |
Definition at line 151 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 1098 of file network.c.
References DirectFunctionCall1, and network_network().
Referenced by network_prefix_quals().
Definition at line 1112 of file network.c.
References DirectFunctionCall1, DirectFunctionCall2, inet_set_masklen(), Int32GetDatum, and network_broadcast().
Referenced by network_prefix_quals().
Definition at line 229 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 607 of file network.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, inet_net_ntop(), ip_addr, ip_bits, ip_family, ip_maxbits, PG_GETARG_INET_PP, PG_RETURN_TEXT_P, and snprintf().
Datum network_smaller | ( | PG_FUNCTION_ARGS | ) |
Definition at line 453 of file network.c.
References a1, a2, network_cmp_internal(), PG_GETARG_INET_PP, and PG_RETURN_INET_P.
Datum network_sub | ( | PG_FUNCTION_ARGS | ) |
Definition at line 503 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 518 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 533 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 548 of file network.c.
References a1, a2, bitncmp(), ip_addr, ip_bits, ip_family, PG_GETARG_INET_PP, and PG_RETURN_BOOL.