prestogres 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +20 -0
- data/LICENSE +202 -0
- data/NOTICE +22 -0
- data/README.md +217 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/bin/prestogres +254 -0
- data/config/pcp.conf.sample +28 -0
- data/config/pgpool.conf +678 -0
- data/config/pool_hba.conf +84 -0
- data/config/pool_passwd +0 -0
- data/config/postgresql.conf +2 -0
- data/ext/.gitignore +6 -0
- data/ext/depend +26 -0
- data/ext/extconf.rb +4 -0
- data/ext/prestogres_config.c +12 -0
- data/pgpool2/.gitignore +36 -0
- data/pgpool2/AUTHORS +4 -0
- data/pgpool2/COPYING +12 -0
- data/pgpool2/ChangeLog +1 -0
- data/pgpool2/INSTALL +1 -0
- data/pgpool2/Makefile.am +159 -0
- data/pgpool2/Makefile.in +1187 -0
- data/pgpool2/NEWS +4960 -0
- data/pgpool2/README +1 -0
- data/pgpool2/README.euc_jp +1 -0
- data/pgpool2/README.online-recovery +62 -0
- data/pgpool2/TODO +103 -0
- data/pgpool2/ac_func_accept_argtypes.m4 +85 -0
- data/pgpool2/aclocal.m4 +1088 -0
- data/pgpool2/c-compiler.m4 +134 -0
- data/pgpool2/c-library.m4 +325 -0
- data/pgpool2/child.c +2097 -0
- data/pgpool2/config.guess +1532 -0
- data/pgpool2/config.h.in +332 -0
- data/pgpool2/config.sub +1640 -0
- data/pgpool2/configure +15752 -0
- data/pgpool2/configure.in +392 -0
- data/pgpool2/depcomp +522 -0
- data/pgpool2/doc/basebackup.sh +17 -0
- data/pgpool2/doc/pgpool-de.html +4220 -0
- data/pgpool2/doc/pgpool-en.html +5738 -0
- data/pgpool2/doc/pgpool-fr.html +4118 -0
- data/pgpool2/doc/pgpool-ja.css +198 -0
- data/pgpool2/doc/pgpool-ja.html +11279 -0
- data/pgpool2/doc/pgpool-zh_cn.html +4445 -0
- data/pgpool2/doc/pgpool.css +280 -0
- data/pgpool2/doc/pgpool_remote_start +13 -0
- data/pgpool2/doc/recovery.conf.sample +117 -0
- data/pgpool2/doc/tutorial-en.html +707 -0
- data/pgpool2/doc/tutorial-ja.html +422 -0
- data/pgpool2/doc/tutorial-memqcache-en.html +325 -0
- data/pgpool2/doc/tutorial-memqcache-ja.html +370 -0
- data/pgpool2/doc/tutorial-memqcache-zh_cn.html +322 -0
- data/pgpool2/doc/tutorial-watchdog-en.html +306 -0
- data/pgpool2/doc/tutorial-watchdog-ja.html +343 -0
- data/pgpool2/doc/tutorial-watchdog-zh_cn.html +301 -0
- data/pgpool2/doc/tutorial-zh_cn.html +537 -0
- data/pgpool2/doc/watchdog.png +0 -0
- data/pgpool2/doc/wd-en.html +236 -0
- data/pgpool2/doc/wd-en.jpg +0 -0
- data/pgpool2/doc/wd-ja.html +219 -0
- data/pgpool2/doc/wd-ja.jpg +0 -0
- data/pgpool2/doc/wd-zh_cn.html +201 -0
- data/pgpool2/doc/where_to_send_queries.odg +0 -0
- data/pgpool2/doc/where_to_send_queries.pdf +0 -0
- data/pgpool2/general.m4 +166 -0
- data/pgpool2/getopt_long.c +200 -0
- data/pgpool2/getopt_long.h +44 -0
- data/pgpool2/install-sh +251 -0
- data/pgpool2/ltmain.sh +8406 -0
- data/pgpool2/m4/libtool.m4 +7360 -0
- data/pgpool2/m4/ltoptions.m4 +368 -0
- data/pgpool2/m4/ltsugar.m4 +123 -0
- data/pgpool2/m4/ltversion.m4 +23 -0
- data/pgpool2/m4/lt~obsolete.m4 +92 -0
- data/pgpool2/main.c +2971 -0
- data/pgpool2/md5.c +444 -0
- data/pgpool2/md5.h +28 -0
- data/pgpool2/missing +360 -0
- data/pgpool2/mkinstalldirs +40 -0
- data/pgpool2/parser/Makefile.am +50 -0
- data/pgpool2/parser/Makefile.in +559 -0
- data/pgpool2/parser/copyfuncs.c +3310 -0
- data/pgpool2/parser/gram.c +39100 -0
- data/pgpool2/parser/gram.h +940 -0
- data/pgpool2/parser/gram.y +13408 -0
- data/pgpool2/parser/gramparse.h +74 -0
- data/pgpool2/parser/keywords.c +32 -0
- data/pgpool2/parser/keywords.h +39 -0
- data/pgpool2/parser/kwlist.h +425 -0
- data/pgpool2/parser/kwlookup.c +88 -0
- data/pgpool2/parser/list.c +1156 -0
- data/pgpool2/parser/makefuncs.c +518 -0
- data/pgpool2/parser/makefuncs.h +83 -0
- data/pgpool2/parser/memnodes.h +79 -0
- data/pgpool2/parser/nodes.c +29 -0
- data/pgpool2/parser/nodes.h +609 -0
- data/pgpool2/parser/outfuncs.c +5790 -0
- data/pgpool2/parser/parsenodes.h +2615 -0
- data/pgpool2/parser/parser.c +262 -0
- data/pgpool2/parser/parser.h +46 -0
- data/pgpool2/parser/pg_class.h +158 -0
- data/pgpool2/parser/pg_config_manual.h +273 -0
- data/pgpool2/parser/pg_list.h +352 -0
- data/pgpool2/parser/pg_trigger.h +147 -0
- data/pgpool2/parser/pg_wchar.h +492 -0
- data/pgpool2/parser/pool_memory.c +342 -0
- data/pgpool2/parser/pool_memory.h +77 -0
- data/pgpool2/parser/pool_parser.h +222 -0
- data/pgpool2/parser/pool_string.c +121 -0
- data/pgpool2/parser/pool_string.h +37 -0
- data/pgpool2/parser/primnodes.h +1280 -0
- data/pgpool2/parser/scan.c +4094 -0
- data/pgpool2/parser/scan.l +1451 -0
- data/pgpool2/parser/scanner.h +120 -0
- data/pgpool2/parser/scansup.c +221 -0
- data/pgpool2/parser/scansup.h +28 -0
- data/pgpool2/parser/snprintf.c +1102 -0
- data/pgpool2/parser/stringinfo.c +294 -0
- data/pgpool2/parser/stringinfo.h +178 -0
- data/pgpool2/parser/value.c +78 -0
- data/pgpool2/parser/value.h +62 -0
- data/pgpool2/parser/wchar.c +2048 -0
- data/pgpool2/pcp.conf.sample +28 -0
- data/pgpool2/pcp/Makefile.am +40 -0
- data/pgpool2/pcp/Makefile.in +771 -0
- data/pgpool2/pcp/libpcp_ext.h +250 -0
- data/pgpool2/pcp/md5.c +444 -0
- data/pgpool2/pcp/md5.h +28 -0
- data/pgpool2/pcp/pcp.c +1652 -0
- data/pgpool2/pcp/pcp.h +61 -0
- data/pgpool2/pcp/pcp_attach_node.c +172 -0
- data/pgpool2/pcp/pcp_detach_node.c +185 -0
- data/pgpool2/pcp/pcp_error.c +87 -0
- data/pgpool2/pcp/pcp_node_count.c +160 -0
- data/pgpool2/pcp/pcp_node_info.c +198 -0
- data/pgpool2/pcp/pcp_pool_status.c +166 -0
- data/pgpool2/pcp/pcp_proc_count.c +166 -0
- data/pgpool2/pcp/pcp_proc_info.c +261 -0
- data/pgpool2/pcp/pcp_promote_node.c +185 -0
- data/pgpool2/pcp/pcp_recovery_node.c +172 -0
- data/pgpool2/pcp/pcp_stop_pgpool.c +179 -0
- data/pgpool2/pcp/pcp_stream.c +385 -0
- data/pgpool2/pcp/pcp_stream.h +52 -0
- data/pgpool2/pcp/pcp_systemdb_info.c +194 -0
- data/pgpool2/pcp/pcp_watchdog_info.c +211 -0
- data/pgpool2/pcp_child.c +1493 -0
- data/pgpool2/pg_md5.c +305 -0
- data/pgpool2/pgpool.8.in +121 -0
- data/pgpool2/pgpool.conf +553 -0
- data/pgpool2/pgpool.conf.sample +666 -0
- data/pgpool2/pgpool.conf.sample-master-slave +665 -0
- data/pgpool2/pgpool.conf.sample-replication +664 -0
- data/pgpool2/pgpool.conf.sample-stream +664 -0
- data/pgpool2/pgpool.spec +264 -0
- data/pgpool2/pgpool_adm/TODO +7 -0
- data/pgpool2/pgpool_adm/pgpool_adm--1.0.sql +85 -0
- data/pgpool2/pgpool_adm/pgpool_adm.c +558 -0
- data/pgpool2/pgpool_adm/pgpool_adm.control +5 -0
- data/pgpool2/pgpool_adm/pgpool_adm.h +46 -0
- data/pgpool2/pgpool_adm/pgpool_adm.sql.in +85 -0
- data/pgpool2/pool.h +655 -0
- data/pgpool2/pool_auth.c +1390 -0
- data/pgpool2/pool_config.c +5007 -0
- data/pgpool2/pool_config.h +284 -0
- data/pgpool2/pool_config.l +3281 -0
- data/pgpool2/pool_config_md5.c +29 -0
- data/pgpool2/pool_connection_pool.c +812 -0
- data/pgpool2/pool_error.c +242 -0
- data/pgpool2/pool_globals.c +27 -0
- data/pgpool2/pool_hba.c +1723 -0
- data/pgpool2/pool_hba.conf.sample +67 -0
- data/pgpool2/pool_ip.c +567 -0
- data/pgpool2/pool_ip.h +65 -0
- data/pgpool2/pool_ipc.h +38 -0
- data/pgpool2/pool_lobj.c +242 -0
- data/pgpool2/pool_lobj.h +32 -0
- data/pgpool2/pool_memqcache.c +3818 -0
- data/pgpool2/pool_memqcache.h +268 -0
- data/pgpool2/pool_params.c +163 -0
- data/pgpool2/pool_passwd.c +249 -0
- data/pgpool2/pool_passwd.h +41 -0
- data/pgpool2/pool_path.c +193 -0
- data/pgpool2/pool_path.h +81 -0
- data/pgpool2/pool_process_context.c +247 -0
- data/pgpool2/pool_process_context.h +62 -0
- data/pgpool2/pool_process_query.c +5001 -0
- data/pgpool2/pool_process_reporting.c +1671 -0
- data/pgpool2/pool_process_reporting.h +44 -0
- data/pgpool2/pool_proto2.c +671 -0
- data/pgpool2/pool_proto_modules.c +3524 -0
- data/pgpool2/pool_proto_modules.h +185 -0
- data/pgpool2/pool_query_cache.c +1020 -0
- data/pgpool2/pool_query_context.c +1871 -0
- data/pgpool2/pool_query_context.h +105 -0
- data/pgpool2/pool_relcache.c +284 -0
- data/pgpool2/pool_relcache.h +78 -0
- data/pgpool2/pool_rewrite_outfuncs.c +9060 -0
- data/pgpool2/pool_rewrite_query.c +715 -0
- data/pgpool2/pool_rewrite_query.h +192 -0
- data/pgpool2/pool_select_walker.c +1150 -0
- data/pgpool2/pool_select_walker.h +68 -0
- data/pgpool2/pool_sema.c +161 -0
- data/pgpool2/pool_session_context.c +952 -0
- data/pgpool2/pool_session_context.h +203 -0
- data/pgpool2/pool_shmem.c +185 -0
- data/pgpool2/pool_signal.c +158 -0
- data/pgpool2/pool_signal.h +61 -0
- data/pgpool2/pool_ssl.c +339 -0
- data/pgpool2/pool_stream.c +962 -0
- data/pgpool2/pool_stream.h +61 -0
- data/pgpool2/pool_system.c +659 -0
- data/pgpool2/pool_timestamp.c +1215 -0
- data/pgpool2/pool_timestamp.h +38 -0
- data/pgpool2/pool_type.h +171 -0
- data/pgpool2/pool_worker_child.c +384 -0
- data/pgpool2/ps_status.c +404 -0
- data/pgpool2/recovery.c +435 -0
- data/pgpool2/redhat/pgpool.conf.sample.patch +52 -0
- data/pgpool2/redhat/pgpool.init +201 -0
- data/pgpool2/redhat/pgpool.sysconfig +7 -0
- data/pgpool2/redhat/rpm_installer/basebackup-replication.sh +53 -0
- data/pgpool2/redhat/rpm_installer/basebackup-stream.sh +55 -0
- data/pgpool2/redhat/rpm_installer/config_for_script +17 -0
- data/pgpool2/redhat/rpm_installer/failover.sh +64 -0
- data/pgpool2/redhat/rpm_installer/getsources.sh +141 -0
- data/pgpool2/redhat/rpm_installer/install.sh +1363 -0
- data/pgpool2/redhat/rpm_installer/pgpool_recovery_pitr +47 -0
- data/pgpool2/redhat/rpm_installer/pgpool_remote_start +15 -0
- data/pgpool2/redhat/rpm_installer/recovery.conf +4 -0
- data/pgpool2/redhat/rpm_installer/uninstall.sh +57 -0
- data/pgpool2/sample/dist_def_pgbench.sql +73 -0
- data/pgpool2/sample/pgpool.pam +3 -0
- data/pgpool2/sample/pgpool_recovery +20 -0
- data/pgpool2/sample/pgpool_recovery_pitr +19 -0
- data/pgpool2/sample/pgpool_remote_start +13 -0
- data/pgpool2/sample/replicate_def_pgbench.sql +18 -0
- data/pgpool2/sql/insert_lock.sql +15 -0
- data/pgpool2/sql/pgpool-recovery/pgpool-recovery.c +280 -0
- data/pgpool2/sql/pgpool-recovery/pgpool-recovery.sql.in +19 -0
- data/pgpool2/sql/pgpool-recovery/pgpool_recovery--1.0.sql +24 -0
- data/pgpool2/sql/pgpool-recovery/pgpool_recovery.control +5 -0
- data/pgpool2/sql/pgpool-recovery/uninstall_pgpool-recovery.sql +3 -0
- data/pgpool2/sql/pgpool-regclass/pgpool-regclass.c +206 -0
- data/pgpool2/sql/pgpool-regclass/pgpool-regclass.sql.in +4 -0
- data/pgpool2/sql/pgpool-regclass/pgpool_regclass--1.0.sql +7 -0
- data/pgpool2/sql/pgpool-regclass/pgpool_regclass.control +5 -0
- data/pgpool2/sql/pgpool-regclass/uninstall_pgpool-regclass.sql +1 -0
- data/pgpool2/sql/system_db.sql +38 -0
- data/pgpool2/strlcpy.c +85 -0
- data/pgpool2/test/C/test_extended.c +98 -0
- data/pgpool2/test/jdbc/.cvsignore +2 -0
- data/pgpool2/test/jdbc/AutoCommitTest.java +45 -0
- data/pgpool2/test/jdbc/BatchTest.java +55 -0
- data/pgpool2/test/jdbc/ColumnTest.java +60 -0
- data/pgpool2/test/jdbc/CreateTempTableTest.java +48 -0
- data/pgpool2/test/jdbc/InsertTest.java +34 -0
- data/pgpool2/test/jdbc/LockTest.java +36 -0
- data/pgpool2/test/jdbc/PgpoolTest.java +75 -0
- data/pgpool2/test/jdbc/README.euc_jp +73 -0
- data/pgpool2/test/jdbc/RunTest.java +83 -0
- data/pgpool2/test/jdbc/SelectTest.java +37 -0
- data/pgpool2/test/jdbc/UpdateTest.java +32 -0
- data/pgpool2/test/jdbc/expected/CreateTempTable +1 -0
- data/pgpool2/test/jdbc/expected/autocommit +10 -0
- data/pgpool2/test/jdbc/expected/batch +1 -0
- data/pgpool2/test/jdbc/expected/column +100 -0
- data/pgpool2/test/jdbc/expected/insert +1 -0
- data/pgpool2/test/jdbc/expected/lock +100 -0
- data/pgpool2/test/jdbc/expected/select +2 -0
- data/pgpool2/test/jdbc/expected/update +1 -0
- data/pgpool2/test/jdbc/pgpool.properties +7 -0
- data/pgpool2/test/jdbc/prepare.sql +54 -0
- data/pgpool2/test/jdbc/run.sh +6 -0
- data/pgpool2/test/parser/.cvsignore +6 -0
- data/pgpool2/test/parser/README +32 -0
- data/pgpool2/test/parser/expected/copy.out +17 -0
- data/pgpool2/test/parser/expected/create.out +64 -0
- data/pgpool2/test/parser/expected/cursor.out +37 -0
- data/pgpool2/test/parser/expected/delete.out +10 -0
- data/pgpool2/test/parser/expected/drop.out +12 -0
- data/pgpool2/test/parser/expected/insert.out +13 -0
- data/pgpool2/test/parser/expected/misc.out +28 -0
- data/pgpool2/test/parser/expected/prepare.out +4 -0
- data/pgpool2/test/parser/expected/privileges.out +31 -0
- data/pgpool2/test/parser/expected/scanner.out +30 -0
- data/pgpool2/test/parser/expected/select.out +89 -0
- data/pgpool2/test/parser/expected/transaction.out +38 -0
- data/pgpool2/test/parser/expected/update.out +11 -0
- data/pgpool2/test/parser/expected/v84.out +37 -0
- data/pgpool2/test/parser/expected/v90.out +25 -0
- data/pgpool2/test/parser/expected/var.out +22 -0
- data/pgpool2/test/parser/input/alter.sql +2 -0
- data/pgpool2/test/parser/input/copy.sql +17 -0
- data/pgpool2/test/parser/input/create.sql +64 -0
- data/pgpool2/test/parser/input/cursor.sql +37 -0
- data/pgpool2/test/parser/input/delete.sql +10 -0
- data/pgpool2/test/parser/input/drop.sql +12 -0
- data/pgpool2/test/parser/input/insert.sql +13 -0
- data/pgpool2/test/parser/input/misc.sql +28 -0
- data/pgpool2/test/parser/input/prepare.sql +4 -0
- data/pgpool2/test/parser/input/privileges.sql +31 -0
- data/pgpool2/test/parser/input/scanner.sql +34 -0
- data/pgpool2/test/parser/input/select.sql +89 -0
- data/pgpool2/test/parser/input/transaction.sql +38 -0
- data/pgpool2/test/parser/input/update.sql +11 -0
- data/pgpool2/test/parser/input/v84.sql +37 -0
- data/pgpool2/test/parser/input/v90.sql +38 -0
- data/pgpool2/test/parser/input/var.sql +22 -0
- data/pgpool2/test/parser/main.c +96 -0
- data/pgpool2/test/parser/parse_schedule +16 -0
- data/pgpool2/test/parser/pool.h +13 -0
- data/pgpool2/test/parser/run-test +62 -0
- data/pgpool2/test/pdo-test/README.euc_jp +58 -0
- data/pgpool2/test/pdo-test/SQLlist/test1.sql +3 -0
- data/pgpool2/test/pdo-test/SQLlist/test2.sql +3 -0
- data/pgpool2/test/pdo-test/collections.inc +11 -0
- data/pgpool2/test/pdo-test/def.inc +7 -0
- data/pgpool2/test/pdo-test/log.txt +0 -0
- data/pgpool2/test/pdo-test/mod/database.inc +36 -0
- data/pgpool2/test/pdo-test/mod/def.inc +0 -0
- data/pgpool2/test/pdo-test/mod/errorhandler.inc +27 -0
- data/pgpool2/test/pdo-test/pdotest.php +11 -0
- data/pgpool2/test/pdo-test/regsql.inc +56 -0
- data/pgpool2/test/pgpool_setup +898 -0
- data/pgpool2/test/regression/README +39 -0
- data/pgpool2/test/regression/clean.sh +21 -0
- data/pgpool2/test/regression/libs.sh +16 -0
- data/pgpool2/test/regression/regress.sh +166 -0
- data/pgpool2/test/regression/tests/001.load_balance/test.sh +128 -0
- data/pgpool2/test/regression/tests/002.native_replication/PgTester.java +47 -0
- data/pgpool2/test/regression/tests/002.native_replication/create.sql +6 -0
- data/pgpool2/test/regression/tests/002.native_replication/test.sh +71 -0
- data/pgpool2/test/regression/tests/003.failover/expected.r +6 -0
- data/pgpool2/test/regression/tests/003.failover/expected.s +6 -0
- data/pgpool2/test/regression/tests/003.failover/test.sh +45 -0
- data/pgpool2/test/regression/tests/004.watchdog/master.conf +12 -0
- data/pgpool2/test/regression/tests/004.watchdog/standby.conf +19 -0
- data/pgpool2/test/regression/tests/004.watchdog/test.sh +52 -0
- data/pgpool2/test/regression/tests/050.bug58/test.sh +50 -0
- data/pgpool2/test/regression/tests/051.bug60/bug.sql +12 -0
- data/pgpool2/test/regression/tests/051.bug60/database-clean.sql +6 -0
- data/pgpool2/test/regression/tests/051.bug60/database-setup.sql +28 -0
- data/pgpool2/test/regression/tests/051.bug60/test.sh +79 -0
- data/pgpool2/test/regression/tests/052.do_query/test.sh +44 -0
- data/pgpool2/test/regression/tests/053.insert_lock_hangs/test.sh +81 -0
- data/pgpool2/test/regression/tests/054.postgres_fdw/test.sh +67 -0
- data/pgpool2/test/regression/tests/055.backend_all_down/test.sh +52 -0
- data/pgpool2/test/regression/tests/056.bug63/jdbctest2.java +66 -0
- data/pgpool2/test/regression/tests/056.bug63/test.sh +47 -0
- data/pgpool2/test/regression/tests/057.bug61/test.sh +40 -0
- data/pgpool2/test/regression/tests/058.bug68/jdbctest3.java +45 -0
- data/pgpool2/test/regression/tests/058.bug68/test.sh +47 -0
- data/pgpool2/test/timestamp/expected/insert.out +16 -0
- data/pgpool2/test/timestamp/expected/misc.out +3 -0
- data/pgpool2/test/timestamp/expected/update.out +6 -0
- data/pgpool2/test/timestamp/input/insert.sql +16 -0
- data/pgpool2/test/timestamp/input/misc.sql +3 -0
- data/pgpool2/test/timestamp/input/update.sql +6 -0
- data/pgpool2/test/timestamp/main.c +129 -0
- data/pgpool2/test/timestamp/parse_schedule +3 -0
- data/pgpool2/test/timestamp/run-test +69 -0
- data/pgpool2/version.h +1 -0
- data/pgpool2/watchdog/Makefile.am +17 -0
- data/pgpool2/watchdog/Makefile.in +505 -0
- data/pgpool2/watchdog/test/stab.c +266 -0
- data/pgpool2/watchdog/test/test.c +85 -0
- data/pgpool2/watchdog/test/wd_child_t.c +87 -0
- data/pgpool2/watchdog/test/wd_lifecheck_t.c +87 -0
- data/pgpool2/watchdog/test/wd_packet_t.c +87 -0
- data/pgpool2/watchdog/test/wd_ping_t.c +20 -0
- data/pgpool2/watchdog/watchdog.c +408 -0
- data/pgpool2/watchdog/watchdog.h +209 -0
- data/pgpool2/watchdog/wd_child.c +444 -0
- data/pgpool2/watchdog/wd_ext.h +123 -0
- data/pgpool2/watchdog/wd_heartbeat.c +577 -0
- data/pgpool2/watchdog/wd_if.c +216 -0
- data/pgpool2/watchdog/wd_init.c +126 -0
- data/pgpool2/watchdog/wd_interlock.c +347 -0
- data/pgpool2/watchdog/wd_lifecheck.c +512 -0
- data/pgpool2/watchdog/wd_list.c +429 -0
- data/pgpool2/watchdog/wd_packet.c +1159 -0
- data/pgpool2/watchdog/wd_ping.c +330 -0
- data/pgpool2/ylwrap +223 -0
- data/pgsql/presto_client.py +346 -0
- data/pgsql/prestogres.py +156 -0
- data/pgsql/setup_functions.sql +21 -0
- data/pgsql/setup_language.sql +3 -0
- data/prestogres.gemspec +23 -0
- metadata +496 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
# pgpool Client Authentication Configuration File
|
2
|
+
# ===============================================
|
3
|
+
#
|
4
|
+
# The format rule in this file follows the rules in the PostgreSQL
|
5
|
+
# Administrator's Guide. Refer to chapter "Client Authentication" for a
|
6
|
+
# complete description. A short synopsis follows.
|
7
|
+
#
|
8
|
+
# This file controls: which hosts are allowed to connect, how clients
|
9
|
+
# are authenticated, which user names they can use, which databases they
|
10
|
+
# can access. Records take one of these forms:
|
11
|
+
#
|
12
|
+
# local DATABASE USER METHOD [OPTION]
|
13
|
+
# host DATABASE USER CIDR-ADDRESS METHOD [OPTION]
|
14
|
+
#
|
15
|
+
# (The uppercase items must be replaced by actual values.)
|
16
|
+
#
|
17
|
+
# The first field is the connection type: "local" is a Unix-domain
|
18
|
+
# socket, "host" is either a plain or SSL-encrypted TCP/IP socket.
|
19
|
+
#
|
20
|
+
# DATABASE can be "all", "sameuser", a database name, or a comma-separated
|
21
|
+
# list thereof. Note that "samegroup" like in PostgreSQL's pg_hba.conf
|
22
|
+
# file is not supported, since pgpool does not know which group a user
|
23
|
+
# belongs to. Also note that the database specified here may not exist in
|
24
|
+
# the backend PostgreSQL. pgpool will authenticate based on the database's
|
25
|
+
# name, not based on whether it exists or not.
|
26
|
+
#
|
27
|
+
# USER can be "all", a user name, or a comma-separated list thereof. In
|
28
|
+
# both the DATABASE and USER fields you can also write a file name prefixed
|
29
|
+
# with "@" to include names from a separate file. Note that a group name
|
30
|
+
# prefixed with "+" like in PostgreSQL's pg_hba.conf file is not supported
|
31
|
+
# because of the same reason as "samegroup" token. Also note that a user
|
32
|
+
# name specified here may not exist in the backend PostgreSQL. pgpool will
|
33
|
+
# authenticate based on the user's name, not based on whether he/she exists.
|
34
|
+
#
|
35
|
+
# CIDR-ADDRESS specifies the set of hosts the record matches.
|
36
|
+
# It is made up of an IP address and a CIDR mask that is an integer
|
37
|
+
# (between 0 and 32 (IPv4) that specifies the number of significant bits in
|
38
|
+
# the mask. Alternatively, you can write an IP address and netmask in
|
39
|
+
# separate columns to specify the set of hosts.
|
40
|
+
#
|
41
|
+
# METHOD can be "trust", "reject", "md5" or "pam". Note that "pam" sends passwords
|
42
|
+
# in clear text.
|
43
|
+
#
|
44
|
+
# OPTION is the name of the PAM service. Default service name is "pgpool"
|
45
|
+
#
|
46
|
+
# Database and user names containing spaces, commas, quotes and other special
|
47
|
+
# characters must be quoted. Quoting one of the keywords "all" or "sameuser"
|
48
|
+
# makes the name lose its special character, and just match a database or
|
49
|
+
# username with that name.
|
50
|
+
#
|
51
|
+
# This file is read on pgpool startup. If you edit the file on a running
|
52
|
+
# system, you have to restart the pgpool for the changes to take effect.
|
53
|
+
|
54
|
+
# Put your actual configuration here
|
55
|
+
# ----------------------------------
|
56
|
+
#
|
57
|
+
# If you want to allow non-local connections, you need to add more
|
58
|
+
# "host" records. In that case you will also need to make pgpool listen
|
59
|
+
# on a non-local interface via the listen_addresses configuration parameter.
|
60
|
+
#
|
61
|
+
|
62
|
+
# TYPE DATABASE USER CIDR-ADDRESS METHOD
|
63
|
+
|
64
|
+
# "local" is for Unix domain socket connections only
|
65
|
+
local all all trust
|
66
|
+
# IPv4 local connections:
|
67
|
+
host all all 127.0.0.1/32 trust
|
data/pgpool2/pool_ip.c
ADDED
@@ -0,0 +1,567 @@
|
|
1
|
+
/* -*-pgsql-c-*- */
|
2
|
+
/*
|
3
|
+
*
|
4
|
+
* $Header$
|
5
|
+
*
|
6
|
+
* This file was imported from PostgreSQL 8.0.8 source code.
|
7
|
+
* See below for the copyright and description.
|
8
|
+
*
|
9
|
+
* pgpool: a language independent connection pool server for PostgreSQL
|
10
|
+
* written by Tatsuo Ishii
|
11
|
+
*
|
12
|
+
* Portions Copyright (c) 2003-2010 PgPool Global Development Group
|
13
|
+
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
14
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
15
|
+
*
|
16
|
+
* Permission to use, copy, modify, and distribute this software and
|
17
|
+
* its documentation for any purpose and without fee is hereby
|
18
|
+
* granted, provided that the above copyright notice appear in all
|
19
|
+
* copies and that both that copyright notice and this permission
|
20
|
+
* notice appear in supporting documentation, and that the name of the
|
21
|
+
* author not be used in advertising or publicity pertaining to
|
22
|
+
* distribution of the software without specific, written prior
|
23
|
+
* permission. The author makes no representations about the
|
24
|
+
* suitability of this software for any purpose. It is provided "as
|
25
|
+
* is" without express or implied warranty.
|
26
|
+
*
|
27
|
+
* ------------------------------
|
28
|
+
*
|
29
|
+
*
|
30
|
+
* This file and the IPV6 implementation were initially provided by
|
31
|
+
* Nigel Kukard <nkukard@lbsd.net>, Linux Based Systems Design
|
32
|
+
* http://www.lbsd.net.
|
33
|
+
*
|
34
|
+
* pool_ip.c.: IPv6-aware network access.
|
35
|
+
*
|
36
|
+
*/
|
37
|
+
|
38
|
+
#include <errno.h>
|
39
|
+
#include <unistd.h>
|
40
|
+
#include <sys/types.h>
|
41
|
+
#include <sys/socket.h>
|
42
|
+
#include <netdb.h>
|
43
|
+
#include <netinet/in.h>
|
44
|
+
#include <netinet/tcp.h>
|
45
|
+
|
46
|
+
#include <stdio.h>
|
47
|
+
#include <stdlib.h>
|
48
|
+
#include <string.h>
|
49
|
+
#include <sys/un.h>
|
50
|
+
|
51
|
+
#include "pool.h"
|
52
|
+
#include "pool_ip.h"
|
53
|
+
#include "pool_config.h"
|
54
|
+
|
55
|
+
static int rangeSockAddrAF_INET(const struct sockaddr_in * addr,
|
56
|
+
const struct sockaddr_in * netaddr,
|
57
|
+
const struct sockaddr_in * netmask);
|
58
|
+
|
59
|
+
#ifdef HAVE_IPV6
|
60
|
+
static int rangeSockAddrAF_INET6(const struct sockaddr_in6 * addr,
|
61
|
+
const struct sockaddr_in6 * netaddr,
|
62
|
+
const struct sockaddr_in6 * netmask);
|
63
|
+
#endif
|
64
|
+
|
65
|
+
static int getaddrinfo_unix(const char *path,
|
66
|
+
const struct addrinfo * hintsp,
|
67
|
+
struct addrinfo ** result);
|
68
|
+
|
69
|
+
static int getnameinfo_unix(const struct sockaddr_un * sa, int salen,
|
70
|
+
char *node, int nodelen,
|
71
|
+
char *service, int servicelen,
|
72
|
+
int flags);
|
73
|
+
|
74
|
+
/*
|
75
|
+
* pool_getnameinfo_all - get name info for Unix, IPv4 and IPv6 sockets
|
76
|
+
* caller MUST allocate NI_MAXHOST, NI_MAXSERV bytes for remote_host and remote_port
|
77
|
+
*/
|
78
|
+
void pool_getnameinfo_all(SockAddr *saddr, char *remote_host, char *remote_port)
|
79
|
+
{
|
80
|
+
remote_host[0] = '\0';
|
81
|
+
remote_port[0] = '\0';
|
82
|
+
|
83
|
+
if (getnameinfo_all(&saddr->addr, saddr->salen,
|
84
|
+
remote_host, NI_MAXHOST,
|
85
|
+
remote_port, NI_MAXSERV,
|
86
|
+
(pool_config->log_hostname ? 0 : NI_NUMERICHOST) | NI_NUMERICSERV))
|
87
|
+
{
|
88
|
+
int ret = getnameinfo_all(&saddr->addr, saddr->salen,
|
89
|
+
remote_host, NI_MAXHOST,
|
90
|
+
remote_port, NI_MAXSERV,
|
91
|
+
NI_NUMERICHOST | NI_NUMERICSERV);
|
92
|
+
if (ret)
|
93
|
+
pool_error("getnameinfo_all() failed: %s", gai_strerror(ret));
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
/*
|
98
|
+
* getaddrinfo_all - get address info for Unix, IPv4 and IPv6 sockets
|
99
|
+
*/
|
100
|
+
int
|
101
|
+
getaddrinfo_all(const char *hostname, const char *servname,
|
102
|
+
const struct addrinfo * hintp, struct addrinfo ** result)
|
103
|
+
{
|
104
|
+
/* not all versions of getaddrinfo() zero *result on failure */
|
105
|
+
*result = NULL;
|
106
|
+
|
107
|
+
if (hintp->ai_family == AF_UNIX)
|
108
|
+
return getaddrinfo_unix(servname, hintp, result);
|
109
|
+
|
110
|
+
/* NULL has special meaning to getaddrinfo(). */
|
111
|
+
return getaddrinfo((!hostname || hostname[0] == '\0') ? NULL : hostname,
|
112
|
+
servname, hintp, result);
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
/*
|
117
|
+
* freeaddrinfo_all - free addrinfo structures for IPv4, IPv6, or Unix
|
118
|
+
*
|
119
|
+
* Note: the ai_family field of the original hint structure must be passed
|
120
|
+
* so that we can tell whether the addrinfo struct was built by the system's
|
121
|
+
* getaddrinfo() routine or our own getaddrinfo_unix() routine. Some versions
|
122
|
+
* of getaddrinfo() might be willing to return AF_UNIX addresses, so it's
|
123
|
+
* not safe to look at ai_family in the addrinfo itself.
|
124
|
+
*/
|
125
|
+
void
|
126
|
+
freeaddrinfo_all(int hint_ai_family, struct addrinfo * ai)
|
127
|
+
{
|
128
|
+
if (hint_ai_family == AF_UNIX)
|
129
|
+
{
|
130
|
+
/* struct was built by getaddrinfo_unix (see getaddrinfo_all) */
|
131
|
+
while (ai != NULL)
|
132
|
+
{
|
133
|
+
struct addrinfo *p = ai;
|
134
|
+
|
135
|
+
ai = ai->ai_next;
|
136
|
+
free(p->ai_addr);
|
137
|
+
free(p);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
else
|
141
|
+
{
|
142
|
+
/* struct was built by getaddrinfo() */
|
143
|
+
if (ai != NULL)
|
144
|
+
freeaddrinfo(ai);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
|
149
|
+
/*
|
150
|
+
* getnameinfo_all - get name info for Unix, IPv4 and IPv6 sockets
|
151
|
+
*
|
152
|
+
* The API of this routine differs from the standard getnameinfo() definition
|
153
|
+
* in two ways: first, the addr parameter is declared as sockaddr_storage
|
154
|
+
* rather than struct sockaddr, and second, the node and service fields are
|
155
|
+
* guaranteed to be filled with something even on failure return.
|
156
|
+
*/
|
157
|
+
int
|
158
|
+
getnameinfo_all(const struct sockaddr_storage * addr, int salen,
|
159
|
+
char *node, int nodelen,
|
160
|
+
char *service, int servicelen,
|
161
|
+
int flags)
|
162
|
+
{
|
163
|
+
int rc;
|
164
|
+
|
165
|
+
if (addr && addr->ss_family == AF_UNIX)
|
166
|
+
rc = getnameinfo_unix((const struct sockaddr_un *) addr, salen,
|
167
|
+
node, nodelen,
|
168
|
+
service, servicelen,
|
169
|
+
flags);
|
170
|
+
else
|
171
|
+
rc = getnameinfo((const struct sockaddr *) addr, salen,
|
172
|
+
node, nodelen,
|
173
|
+
service, servicelen,
|
174
|
+
flags);
|
175
|
+
|
176
|
+
if (rc != 0)
|
177
|
+
{
|
178
|
+
if (node)
|
179
|
+
strncpy(node, "???", nodelen);
|
180
|
+
if (service)
|
181
|
+
strncpy(service, "???", servicelen);
|
182
|
+
}
|
183
|
+
|
184
|
+
return rc;
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
#ifndef HAVE_GAI_STRERROR
|
189
|
+
const char *
|
190
|
+
gai_strerror(int errcode)
|
191
|
+
{
|
192
|
+
#ifdef HAVE_HSTRERROR
|
193
|
+
int hcode;
|
194
|
+
|
195
|
+
switch (errcode)
|
196
|
+
{
|
197
|
+
case EAI_NONAME:
|
198
|
+
hcode = HOST_NOT_FOUND;
|
199
|
+
break;
|
200
|
+
case EAI_AGAIN:
|
201
|
+
hcode = TRY_AGAIN;
|
202
|
+
break;
|
203
|
+
case EAI_FAIL:
|
204
|
+
default:
|
205
|
+
hcode = NO_RECOVERY;
|
206
|
+
break;
|
207
|
+
}
|
208
|
+
|
209
|
+
return hstrerror(hcode);
|
210
|
+
#else /* !HAVE_HSTRERROR */
|
211
|
+
|
212
|
+
switch (errcode)
|
213
|
+
{
|
214
|
+
case EAI_NONAME:
|
215
|
+
return "Unknown host";
|
216
|
+
case EAI_AGAIN:
|
217
|
+
return "Host name lookup failure";
|
218
|
+
/* Errors below are probably WIN32 only */
|
219
|
+
#ifdef EAI_BADFLAGS
|
220
|
+
case EAI_BADFLAGS:
|
221
|
+
return "Invalid argument";
|
222
|
+
#endif
|
223
|
+
#ifdef EAI_FAMILY
|
224
|
+
case EAI_FAMILY:
|
225
|
+
return "Address family not supported";
|
226
|
+
#endif
|
227
|
+
#ifdef EAI_MEMORY
|
228
|
+
case EAI_MEMORY:
|
229
|
+
return "Not enough memory";
|
230
|
+
#endif
|
231
|
+
#ifdef EAI_NODATA
|
232
|
+
#ifndef WIN32_ONLY_COMPILER /* MSVC complains because another case has the
|
233
|
+
* same value */
|
234
|
+
case EAI_NODATA:
|
235
|
+
return "No host data of that type was found";
|
236
|
+
#endif
|
237
|
+
#endif
|
238
|
+
#ifdef EAI_SERVICE
|
239
|
+
case EAI_SERVICE:
|
240
|
+
return "Class type not found";
|
241
|
+
#endif
|
242
|
+
#ifdef EAI_SOCKTYPE
|
243
|
+
case EAI_SOCKTYPE:
|
244
|
+
return "Socket type not supported";
|
245
|
+
#endif
|
246
|
+
default:
|
247
|
+
return "Unknown server error";
|
248
|
+
}
|
249
|
+
#endif /* HAVE_HSTRERROR */
|
250
|
+
}
|
251
|
+
#endif /* HAVE_GAI_STRERROR */
|
252
|
+
|
253
|
+
|
254
|
+
/*
|
255
|
+
* getaddrinfo_unix - get unix socket info using IPv6-compatible API
|
256
|
+
*
|
257
|
+
* Bugs: only one addrinfo is set even though hintsp is NULL or
|
258
|
+
* ai_socktype is 0
|
259
|
+
* AI_CANONNAME is not supported.
|
260
|
+
*
|
261
|
+
*/
|
262
|
+
static int
|
263
|
+
getaddrinfo_unix(const char *path, const struct addrinfo * hintsp,
|
264
|
+
struct addrinfo ** result)
|
265
|
+
{
|
266
|
+
struct addrinfo hints;
|
267
|
+
struct addrinfo *aip;
|
268
|
+
struct sockaddr_un *unp;
|
269
|
+
|
270
|
+
*result = NULL;
|
271
|
+
|
272
|
+
memset(&hints, 0, sizeof(hints));
|
273
|
+
|
274
|
+
if (strlen(path) >= sizeof(unp->sun_path))
|
275
|
+
return EAI_FAIL;
|
276
|
+
|
277
|
+
if (hintsp == NULL)
|
278
|
+
{
|
279
|
+
hints.ai_family = AF_UNIX;
|
280
|
+
hints.ai_socktype = SOCK_STREAM;
|
281
|
+
}
|
282
|
+
else
|
283
|
+
memcpy(&hints, hintsp, sizeof(hints));
|
284
|
+
|
285
|
+
if (hints.ai_socktype == 0)
|
286
|
+
hints.ai_socktype = SOCK_STREAM;
|
287
|
+
|
288
|
+
if (hints.ai_family != AF_UNIX)
|
289
|
+
{
|
290
|
+
/* shouldn't have been called */
|
291
|
+
return EAI_FAIL;
|
292
|
+
}
|
293
|
+
|
294
|
+
aip = calloc(1, sizeof(struct addrinfo));
|
295
|
+
if (aip == NULL)
|
296
|
+
return EAI_MEMORY;
|
297
|
+
|
298
|
+
unp = calloc(1, sizeof(struct sockaddr_un));
|
299
|
+
if (unp == NULL)
|
300
|
+
{
|
301
|
+
free(aip);
|
302
|
+
return EAI_MEMORY;
|
303
|
+
}
|
304
|
+
|
305
|
+
aip->ai_family = AF_UNIX;
|
306
|
+
aip->ai_socktype = hints.ai_socktype;
|
307
|
+
aip->ai_protocol = hints.ai_protocol;
|
308
|
+
aip->ai_next = NULL;
|
309
|
+
aip->ai_canonname = NULL;
|
310
|
+
*result = aip;
|
311
|
+
|
312
|
+
unp->sun_family = AF_UNIX;
|
313
|
+
aip->ai_addr = (struct sockaddr *) unp;
|
314
|
+
aip->ai_addrlen = sizeof(struct sockaddr_un);
|
315
|
+
|
316
|
+
strcpy(unp->sun_path, path);
|
317
|
+
|
318
|
+
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN
|
319
|
+
unp->sun_len = sizeof(struct sockaddr_un);
|
320
|
+
#endif
|
321
|
+
|
322
|
+
return 0;
|
323
|
+
}
|
324
|
+
|
325
|
+
/*
|
326
|
+
* Convert an address to a hostname.
|
327
|
+
*/
|
328
|
+
static int
|
329
|
+
getnameinfo_unix(const struct sockaddr_un * sa, int salen,
|
330
|
+
char *node, int nodelen,
|
331
|
+
char *service, int servicelen,
|
332
|
+
int flags)
|
333
|
+
{
|
334
|
+
int ret = -1;
|
335
|
+
|
336
|
+
/* Invalid arguments. */
|
337
|
+
if (sa == NULL || sa->sun_family != AF_UNIX ||
|
338
|
+
(node == NULL && service == NULL))
|
339
|
+
return EAI_FAIL;
|
340
|
+
|
341
|
+
/* We don't support those. */
|
342
|
+
if ((node && !(flags & NI_NUMERICHOST))
|
343
|
+
|| (service && !(flags & NI_NUMERICSERV)))
|
344
|
+
return EAI_FAIL;
|
345
|
+
|
346
|
+
if (node)
|
347
|
+
{
|
348
|
+
ret = snprintf(node, nodelen, "%s", "[local]");
|
349
|
+
if (ret == -1 || ret > nodelen)
|
350
|
+
return EAI_MEMORY;
|
351
|
+
}
|
352
|
+
|
353
|
+
if (service)
|
354
|
+
{
|
355
|
+
ret = snprintf(service, servicelen, "%s", sa->sun_path);
|
356
|
+
if (ret == -1 || ret > servicelen)
|
357
|
+
return EAI_MEMORY;
|
358
|
+
}
|
359
|
+
|
360
|
+
return 0;
|
361
|
+
}
|
362
|
+
|
363
|
+
|
364
|
+
/*
|
365
|
+
* rangeSockAddr - is addr within the subnet specified by netaddr/netmask ?
|
366
|
+
*
|
367
|
+
* Note: caller must already have verified that all three addresses are
|
368
|
+
* in the same address family; and AF_UNIX addresses are not supported.
|
369
|
+
*/
|
370
|
+
int
|
371
|
+
rangeSockAddr(const struct sockaddr_storage * addr,
|
372
|
+
const struct sockaddr_storage * netaddr,
|
373
|
+
const struct sockaddr_storage * netmask)
|
374
|
+
{
|
375
|
+
if (addr->ss_family == AF_INET)
|
376
|
+
return rangeSockAddrAF_INET((struct sockaddr_in *) addr,
|
377
|
+
(struct sockaddr_in *) netaddr,
|
378
|
+
(struct sockaddr_in *) netmask);
|
379
|
+
#ifdef HAVE_IPV6
|
380
|
+
else if (addr->ss_family == AF_INET6)
|
381
|
+
return rangeSockAddrAF_INET6((struct sockaddr_in6 *) addr,
|
382
|
+
(struct sockaddr_in6 *) netaddr,
|
383
|
+
(struct sockaddr_in6 *) netmask);
|
384
|
+
#endif
|
385
|
+
else
|
386
|
+
return 0;
|
387
|
+
}
|
388
|
+
|
389
|
+
static int
|
390
|
+
rangeSockAddrAF_INET(const struct sockaddr_in * addr,
|
391
|
+
const struct sockaddr_in * netaddr,
|
392
|
+
const struct sockaddr_in * netmask)
|
393
|
+
{
|
394
|
+
if (((addr->sin_addr.s_addr ^ netaddr->sin_addr.s_addr) &
|
395
|
+
netmask->sin_addr.s_addr) == 0)
|
396
|
+
return 1;
|
397
|
+
else
|
398
|
+
return 0;
|
399
|
+
}
|
400
|
+
|
401
|
+
|
402
|
+
#ifdef HAVE_IPV6
|
403
|
+
static int
|
404
|
+
rangeSockAddrAF_INET6(const struct sockaddr_in6 * addr,
|
405
|
+
const struct sockaddr_in6 * netaddr,
|
406
|
+
const struct sockaddr_in6 * netmask)
|
407
|
+
{
|
408
|
+
int i;
|
409
|
+
|
410
|
+
for (i = 0; i < 16; i++)
|
411
|
+
{
|
412
|
+
if (((addr->sin6_addr.s6_addr[i] ^ netaddr->sin6_addr.s6_addr[i]) &
|
413
|
+
netmask->sin6_addr.s6_addr[i]) != 0)
|
414
|
+
return 0;
|
415
|
+
}
|
416
|
+
|
417
|
+
return 1;
|
418
|
+
}
|
419
|
+
#endif
|
420
|
+
|
421
|
+
/*
|
422
|
+
* SockAddr_cidr_mask - make a network mask of the appropriate family
|
423
|
+
* and required number of significant bits
|
424
|
+
*
|
425
|
+
* The resulting mask is placed in *mask, which had better be big enough.
|
426
|
+
*
|
427
|
+
* Return value is 0 if okay, -1 if not.
|
428
|
+
*/
|
429
|
+
int
|
430
|
+
SockAddr_cidr_mask(struct sockaddr_storage * mask, char *numbits, int family)
|
431
|
+
{
|
432
|
+
long bits;
|
433
|
+
char *endptr;
|
434
|
+
|
435
|
+
bits = strtol(numbits, &endptr, 10);
|
436
|
+
|
437
|
+
if (*numbits == '\0' || *endptr != '\0')
|
438
|
+
return -1;
|
439
|
+
|
440
|
+
switch (family)
|
441
|
+
{
|
442
|
+
case AF_INET:
|
443
|
+
{
|
444
|
+
struct sockaddr_in mask4;
|
445
|
+
long maskl;
|
446
|
+
|
447
|
+
if (bits < 0 || bits > 32)
|
448
|
+
return -1;
|
449
|
+
/* avoid "x << 32", which is not portable */
|
450
|
+
if (bits > 0)
|
451
|
+
maskl = (0xffffffffUL << (32 - (int) bits))
|
452
|
+
& 0xffffffffUL;
|
453
|
+
else
|
454
|
+
maskl = 0;
|
455
|
+
memset(&mask4, 0, sizeof(mask4));
|
456
|
+
mask4.sin_addr.s_addr = htonl(maskl);
|
457
|
+
memcpy(mask, &mask4, sizeof(mask4));
|
458
|
+
break;
|
459
|
+
}
|
460
|
+
|
461
|
+
#ifdef HAVE_IPV6
|
462
|
+
case AF_INET6:
|
463
|
+
{
|
464
|
+
struct sockaddr_in6 mask6;
|
465
|
+
int i;
|
466
|
+
|
467
|
+
if (bits < 0 || bits > 128)
|
468
|
+
return -1;
|
469
|
+
for (i = 0; i < 16; i++)
|
470
|
+
{
|
471
|
+
if (bits <= 0)
|
472
|
+
mask6.sin6_addr.s6_addr[i] = 0;
|
473
|
+
else if (bits >= 8)
|
474
|
+
mask6.sin6_addr.s6_addr[i] = 0xff;
|
475
|
+
else
|
476
|
+
{
|
477
|
+
mask6.sin6_addr.s6_addr[i] =
|
478
|
+
(0xff << (8 - (int) bits)) & 0xff;
|
479
|
+
}
|
480
|
+
bits -= 8;
|
481
|
+
}
|
482
|
+
memcpy(mask, &mask6, sizeof(mask6));
|
483
|
+
break;
|
484
|
+
}
|
485
|
+
#endif
|
486
|
+
default:
|
487
|
+
return -1;
|
488
|
+
}
|
489
|
+
|
490
|
+
mask->ss_family = family;
|
491
|
+
return 0;
|
492
|
+
}
|
493
|
+
|
494
|
+
|
495
|
+
#ifdef HAVE_IPV6
|
496
|
+
|
497
|
+
/*
|
498
|
+
* promote_v4_to_v6_addr --- convert an AF_INET addr to AF_INET6, using
|
499
|
+
* the standard convention for IPv4 addresses mapped into IPv6 world
|
500
|
+
*
|
501
|
+
* The passed addr is modified in place; be sure it is large enough to
|
502
|
+
* hold the result! Note that we only worry about setting the fields
|
503
|
+
* that rangeSockAddr will look at.
|
504
|
+
*/
|
505
|
+
static void
|
506
|
+
promote_v4_to_v6_addr(struct sockaddr_storage * addr)
|
507
|
+
{
|
508
|
+
struct sockaddr_in addr4;
|
509
|
+
struct sockaddr_in6 addr6;
|
510
|
+
uint32 ip4addr;
|
511
|
+
|
512
|
+
memcpy(&addr4, addr, sizeof(addr4));
|
513
|
+
ip4addr = ntohl(addr4.sin_addr.s_addr);
|
514
|
+
|
515
|
+
memset(&addr6, 0, sizeof(addr6));
|
516
|
+
|
517
|
+
addr6.sin6_family = AF_INET6;
|
518
|
+
|
519
|
+
addr6.sin6_addr.s6_addr[10] = 0xff;
|
520
|
+
addr6.sin6_addr.s6_addr[11] = 0xff;
|
521
|
+
addr6.sin6_addr.s6_addr[12] = (ip4addr >> 24) & 0xFF;
|
522
|
+
addr6.sin6_addr.s6_addr[13] = (ip4addr >> 16) & 0xFF;
|
523
|
+
addr6.sin6_addr.s6_addr[14] = (ip4addr >> 8) & 0xFF;
|
524
|
+
addr6.sin6_addr.s6_addr[15] = (ip4addr) & 0xFF;
|
525
|
+
|
526
|
+
memcpy(addr, &addr6, sizeof(addr6));
|
527
|
+
}
|
528
|
+
|
529
|
+
/*
|
530
|
+
* promote_v4_to_v6_mask --- convert an AF_INET netmask to AF_INET6, using
|
531
|
+
* the standard convention for IPv4 addresses mapped into IPv6 world
|
532
|
+
*
|
533
|
+
* This must be different from promote_v4_to_v6_addr because we want to
|
534
|
+
* set the high-order bits to 1's not 0's.
|
535
|
+
*
|
536
|
+
* The passed addr is modified in place; be sure it is large enough to
|
537
|
+
* hold the result! Note that we only worry about setting the fields
|
538
|
+
* that rangeSockAddr will look at.
|
539
|
+
*/
|
540
|
+
static void
|
541
|
+
promote_v4_to_v6_mask(struct sockaddr_storage * addr)
|
542
|
+
{
|
543
|
+
struct sockaddr_in addr4;
|
544
|
+
struct sockaddr_in6 addr6;
|
545
|
+
uint32 ip4addr;
|
546
|
+
int i;
|
547
|
+
|
548
|
+
memcpy(&addr4, addr, sizeof(addr4));
|
549
|
+
ip4addr = ntohl(addr4.sin_addr.s_addr);
|
550
|
+
|
551
|
+
memset(&addr6, 0, sizeof(addr6));
|
552
|
+
|
553
|
+
addr6.sin6_family = AF_INET6;
|
554
|
+
|
555
|
+
for (i = 0; i < 12; i++)
|
556
|
+
addr6.sin6_addr.s6_addr[i] = 0xff;
|
557
|
+
|
558
|
+
addr6.sin6_addr.s6_addr[12] = (ip4addr >> 24) & 0xFF;
|
559
|
+
addr6.sin6_addr.s6_addr[13] = (ip4addr >> 16) & 0xFF;
|
560
|
+
addr6.sin6_addr.s6_addr[14] = (ip4addr >> 8) & 0xFF;
|
561
|
+
addr6.sin6_addr.s6_addr[15] = (ip4addr) & 0xFF;
|
562
|
+
|
563
|
+
memcpy(addr, &addr6, sizeof(addr6));
|
564
|
+
}
|
565
|
+
|
566
|
+
#endif /* HAVE_IPV6 */
|
567
|
+
|