[svn] commit: r1616 - in /branches/likun-xfrout: ./ src/bin/ src/bin/auth/ src/bin/bind10/ src/bin/xfrout/ src/lib/ src/lib/config/ src/lib/dns/ src/lib/python/isc/auth/ src/lib/xfr/ src/lib/xfr/tests/
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Mar 20 11:33:56 UTC 2010
Author: zhanglikun
Date: Sat Mar 20 11:33:56 2010
New Revision: 1616
Log:
The code for xfrout has almostly been finished, more unittests need to be added.(This branch will be merged to trunk in a few days.)
Added:
branches/likun-xfrout/src/bin/xfrout/
branches/likun-xfrout/src/bin/xfrout/Makefile.am
branches/likun-xfrout/src/bin/xfrout/run_b10-xfrout.sh.in
branches/likun-xfrout/src/bin/xfrout/xfrout.py.in
branches/likun-xfrout/src/bin/xfrout/xfrout.spec
branches/likun-xfrout/src/lib/xfr/
branches/likun-xfrout/src/lib/xfr/Makefile.am
branches/likun-xfrout/src/lib/xfr/Makefile.dat
branches/likun-xfrout/src/lib/xfr/fd_share.cc
branches/likun-xfrout/src/lib/xfr/fd_share.h
branches/likun-xfrout/src/lib/xfr/tests/
branches/likun-xfrout/src/lib/xfr/tests/client_main.cpp
branches/likun-xfrout/src/lib/xfr/tests/xfrout_server.py
branches/likun-xfrout/src/lib/xfr/xfr_python.cc
branches/likun-xfrout/src/lib/xfr/xfrout_client.cc
branches/likun-xfrout/src/lib/xfr/xfrout_client.h
Modified:
branches/likun-xfrout/configure.ac
branches/likun-xfrout/src/bin/Makefile.am
branches/likun-xfrout/src/bin/auth/Makefile.am
branches/likun-xfrout/src/bin/auth/main.cc
branches/likun-xfrout/src/bin/bind10/bind10.py.in
branches/likun-xfrout/src/lib/Makefile.am
branches/likun-xfrout/src/lib/config/ccsession.cc
branches/likun-xfrout/src/lib/dns/base64.cc
branches/likun-xfrout/src/lib/dns/buffer.h
branches/likun-xfrout/src/lib/python/isc/auth/sqlite3_ds.py
Modified: branches/likun-xfrout/configure.ac
==============================================================================
--- branches/likun-xfrout/configure.ac (original)
+++ branches/likun-xfrout/configure.ac Sat Mar 20 11:33:56 2010
@@ -275,6 +275,7 @@
src/bin/auth/Makefile
src/bin/auth/tests/Makefile
src/bin/xfrin/Makefile
+ src/bin/xfrout/Makefile
src/bin/usermgr/Makefile
src/lib/Makefile
src/lib/cc/Makefile
@@ -290,6 +291,7 @@
src/lib/exceptions/Makefile
src/lib/auth/Makefile
src/lib/auth/tests/Makefile
+ src/lib/xfr/Makefile
])
AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
src/bin/cmdctl/cmdctl.py
@@ -299,6 +301,8 @@
src/bin/xfrin/xfrin.py
src/bin/xfrin/xfrin.pre
src/bin/xfrin/run_b10-xfrin.sh
+ src/bin/xfrout/xfrout.py
+ src/bin/xfrout/run_b10-xfrout.sh
src/bin/bind10/bind10.py
src/bin/bind10/tests/bind10_test
src/bin/bind10/run_bind10.sh
@@ -322,6 +326,7 @@
], [
chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
chmod +x src/bin/xfrin/run_b10-xfrin.sh
+ chmod +x src/bin/xfrout/run_b10-xfrout.sh
chmod +x src/bin/bind10/run_bind10.sh
chmod +x src/bin/cmdctl/unittest/cmdctl_test
chmod +x src/bin/xfrin/unittest/xfrin_test
Modified: branches/likun-xfrout/src/bin/Makefile.am
==============================================================================
--- branches/likun-xfrout/src/bin/Makefile.am (original)
+++ branches/likun-xfrout/src/bin/Makefile.am Sat Mar 20 11:33:56 2010
@@ -1,1 +1,1 @@
-SUBDIRS = bind10 bindctl cfgmgr loadzone msgq host cmdctl auth xfrin usermgr
+SUBDIRS = bind10 bindctl cfgmgr loadzone msgq host cmdctl auth xfrin xfrout usermgr
Modified: branches/likun-xfrout/src/bin/auth/Makefile.am
==============================================================================
--- branches/likun-xfrout/src/bin/auth/Makefile.am (original)
+++ branches/likun-xfrout/src/bin/auth/Makefile.am Sat Mar 20 11:33:56 2010
@@ -34,6 +34,7 @@
b10_auth_LDADD += $(top_builddir)/src/lib/cc/libcc.a
b10_auth_LDADD += $(top_builddir)/src/lib/exceptions/.libs/libexceptions.a
b10_auth_LDADD += $(SQLITE_LIBS)
+b10_auth_LDADD += $(top_builddir)/src/lib/xfr/.libs/libxfr.a
if HAVE_BOOSTLIB
b10_auth_LDFLAGS = $(AM_LDFLAGS) $(BOOST_LDFLAGS)
b10_auth_LDADD += $(BOOST_SYSTEM_LIB)
Modified: branches/likun-xfrout/src/bin/auth/main.cc
==============================================================================
--- branches/likun-xfrout/src/bin/auth/main.cc (original)
+++ branches/likun-xfrout/src/bin/auth/main.cc Sat Mar 20 11:33:56 2010
@@ -42,12 +42,15 @@
#include <cc/session.h>
#include <cc/data.h>
#include <config/ccsession.h>
+#include <xfr/xfrout_client.h>
#include "spec_config.h"
#include "common.h"
#include "auth_srv.h"
using namespace std;
+using namespace isc::xfr;
+
#ifdef HAVE_BOOSTLIB
using namespace boost::asio;
@@ -101,6 +104,20 @@
}
return answer;
+}
+
+// The sample way for checking axfr query.
+static bool
+check_axfr_query(char *msg_data, uint16_t msg_len)
+{
+ if (msg_len < 15)
+ return false;
+
+ uint16_t query_type = *(uint16_t *)(msg_data + (msg_len - 4));
+ if ( query_type == 0xFC00)
+ return true;
+
+ return false;
}
#ifdef HAVE_BOOSTLIB
@@ -148,17 +165,31 @@
{
if (!error) {
InputBuffer dnsbuffer(data_, bytes_transferred);
- if (auth_server->processMessage(dnsbuffer, dns_message_,
- response_renderer_, false)) {
- responselen_buffer_.writeUint16(response_buffer_.getLength());
- async_write(socket_,
- boost::asio::buffer(
- responselen_buffer_.getData(),
- responselen_buffer_.getLength()),
- boost::bind(&TCPClient::responseWrite, this,
- placeholders::error));
- } else {
- delete this;
+ if (check_axfr_query(data_, bytes_transferred)) {
+ printf("===========================");
+ std::string path = "/tmp/auth_xfrout_conn";
+ XfroutClient xfr_client(path);
+ xfr_client.connect();
+ xfr_client.sendXfroutRequestInfo(socket_.native(), (uint8_t *)data_, bytes_transferred);
+ xfr_client.disconnect();
+ printf("===========================");
+
+ // start to get new query ?
+ start();
+ }
+ else {
+ if (auth_server->processMessage(dnsbuffer, dns_message_,
+ response_renderer_, false)) {
+ responselen_buffer_.writeUint16(response_buffer_.getLength());
+ async_write(socket_,
+ boost::asio::buffer(
+ responselen_buffer_.getData(),
+ responselen_buffer_.getLength()),
+ boost::bind(&TCPClient::responseWrite, this,
+ placeholders::error));
+ } else {
+ delete this;
+ }
}
} else {
delete this;
@@ -537,25 +568,37 @@
cc += cc0;
}
- InputBuffer buffer(&message_buffer[0], size);
- dns_message.clear(Message::PARSE);
- response_renderer.clear();
- if (auth_server->processMessage(buffer, dns_message, response_renderer,
- false)) {
- size = response_renderer.getLength();
- size_n = htons(size);
- if (send(ts, &size_n, 2, 0) == 2) {
- cc = send(ts, response_renderer.getData(),
- response_renderer.getLength(), 0);
- if (cc == -1) {
- if (verbose_mode) {
- cerr << "[AuthSrv] error in sending TCP response message" <<
- endl;
- }
- } else {
- if (verbose_mode) {
- cerr << "[XX] sent TCP response: " << cc << " bytes"
- << endl;
+ printf("begin to check---------------------\n");
+ if (check_axfr_query(message_buffer, size)) {
+ printf("===========================");
+ std::string path = "/tmp/auth_xfrout_conn";
+ XfroutClient xfr_client(path);
+ xfr_client.connect();
+ xfr_client.sendXfroutRequestInfo(ts, message_buffer, size);
+ xfr_client.disconnect();
+ printf("===========================");
+ }
+ else {
+ InputBuffer buffer(&message_buffer[0], size);
+ dns_message.clear(Message::PARSE);
+ response_renderer.clear();
+ if (auth_server->processMessage(buffer, dns_message, response_renderer,
+ false)) {
+ size = response_renderer.getLength();
+ size_n = htons(size);
+ if (send(ts, &size_n, 2, 0) == 2) {
+ cc = send(ts, response_renderer.getData(),
+ response_renderer.getLength(), 0);
+ if (cc == -1) {
+ if (verbose_mode) {
+ cerr << "[AuthSrv] error in sending TCP response message" <<
+ endl;
+ }
+ } else {
+ if (verbose_mode) {
+ cerr << "[XX] sent TCP response: " << cc << " bytes"
+ << endl;
+ }
}
}
} else {
@@ -563,10 +606,11 @@
cerr << "TCP send error" << endl;
}
}
- }
-
- // TODO: we don't check for more queries on the stream atm
- close(ts);
+
+ // TODO: we don't check for more queries on the stream atm
+ close(ts);
+ }
+
}
void
@@ -651,7 +695,7 @@
main(int argc, char* argv[]) {
int ch;
const char* port = DNSPORT;
- bool use_ipv4 = true, use_ipv6 = true;
+ bool use_ipv4 = true, use_ipv6 = false;
while ((ch = getopt(argc, argv, "46p:v")) != -1) {
switch (ch) {
Modified: branches/likun-xfrout/src/bin/bind10/bind10.py.in
==============================================================================
--- branches/likun-xfrout/src/bin/bind10/bind10.py.in (original)
+++ branches/likun-xfrout/src/bin/bind10/bind10.py.in Sat Mar 20 11:33:56 2010
@@ -265,6 +265,21 @@
if self.verbose:
print("[XX] ccsession started")
+ # start the xfrout before auth-server, to make sure every xfr-query can be
+ # processed properly.
+ if self.verbose:
+ sys.stdout.write("Starting b10-xfrout\n")
+ try:
+ xfrout = ProcessInfo("b10-xfrout", ["b10-xfrout"],
+ { 'ISC_MSGQ_PORT': str(self.c_channel_port)})
+ except Exception as e:
+ c_channel.process.kill()
+ bind_cfgd.process.kill()
+ return "Unable to start b10-xfrout; " + str(e)
+ self.processes[xfrout.pid] = xfrout
+ if self.verbose:
+ sys.stdout.write("Started b10-xfrout (PID %d)\n" % xfrout.pid)
+
# start b10-auth
# XXX: this must be read from the configuration manager in the future
authargs = ['b10-auth', '-p', str(self.auth_port)]
@@ -278,6 +293,7 @@
except Exception as e:
c_channel.process.kill()
bind_cfgd.process.kill()
+ xfrout.process.kill()
return "Unable to start b10-auth; " + str(e)
self.processes[auth.pid] = auth
if self.verbose:
@@ -292,6 +308,7 @@
except Exception as e:
c_channel.process.kill()
bind_cfgd.process.kill()
+ xfrout.process.kill()
auth.process.kill()
return "Unable to start b10-xfrin; " + str(e)
self.processes[xfrind.pid] = xfrind
@@ -308,6 +325,7 @@
except Exception as e:
c_channel.process.kill()
bind_cfgd.process.kill()
+ xfrout.process.kill()
auth.process.kill()
xfrind.process.kill()
return "Unable to start b10-cmdctl; " + str(e)
Modified: branches/likun-xfrout/src/lib/Makefile.am
==============================================================================
--- branches/likun-xfrout/src/lib/Makefile.am (original)
+++ branches/likun-xfrout/src/lib/Makefile.am Sat Mar 20 11:33:56 2010
@@ -1,1 +1,1 @@
-SUBDIRS = exceptions dns cc config auth python
+SUBDIRS = exceptions dns cc config auth xfr python
Modified: branches/likun-xfrout/src/lib/config/ccsession.cc
==============================================================================
--- branches/likun-xfrout/src/lib/config/ccsession.cc (original)
+++ branches/likun-xfrout/src/lib/config/ccsession.cc Sat Mar 20 11:33:56 2010
@@ -209,7 +209,6 @@
session_(io_service)
{
init(spec_file_name, config_handler, command_handler);
-
// register callback for asynchronous read
session_.startRead(boost::bind(&ModuleCCSession::startCheck, this));
}
Modified: branches/likun-xfrout/src/lib/dns/base64.cc
==============================================================================
--- branches/likun-xfrout/src/lib/dns/base64.cc (original)
+++ branches/likun-xfrout/src/lib/dns/base64.cc Sat Mar 20 11:33:56 2010
@@ -14,7 +14,6 @@
// $Id$
-#include "config.h"
#include <stdint.h>
#include <cassert>
Modified: branches/likun-xfrout/src/lib/dns/buffer.h
==============================================================================
--- branches/likun-xfrout/src/lib/dns/buffer.h (original)
+++ branches/likun-xfrout/src/lib/dns/buffer.h Sat Mar 20 11:33:56 2010
@@ -205,7 +205,7 @@
}
//@}
-private:
+public:
size_t position_;
const uint8_t* data_;
size_t len_;
Modified: branches/likun-xfrout/src/lib/python/isc/auth/sqlite3_ds.py
==============================================================================
--- branches/likun-xfrout/src/lib/python/isc/auth/sqlite3_ds.py (original)
+++ branches/likun-xfrout/src/lib/python/isc/auth/sqlite3_ds.py Sat Mar 20 11:33:56 2010
@@ -84,6 +84,43 @@
return conn, cur
+
+#########################################################################
+# find_zone_datas
+# returns all the records for one zone with the given zone id.
+#########################################################################
+def find_zone_datas(zone_id, cur):
+ cur.execute("SELECT * FROM records WHERE zone_id = ?", [zone_id])
+ datas = cur.fetchall()
+ return datas
+
+#########################################################################
+# get_zone_datas
+# returns all the records for one zone with the given zone name.
+#########################################################################
+def get_zone_datas(zonename, dbfile ='/usr/local/var/bind10-devel/zone.sqlite3'):
+ conn, cur = open(dbfile)
+ zone_id = get_zoneid(zonename, cur)
+ datas = find_zone_datas(zone_id, cur)
+ cur.close()
+ conn.close()
+ return datas
+
+#########################################################################
+# get_zone_soa
+# returns the soa record of the zone with the given zone name.
+# If the zone doesn't exist, return None.
+#########################################################################
+def get_zone_soa(zonename, dbfile = '/usr/local/var/bind10-devel/zone.sqlite3'):
+ conn, cur = open(dbfile)
+ id = get_zoneid(zonename, cur)
+ cur.execute("SELECT * FROM records WHERE zone_id = ? and rdtype = ?", [id, 'SOA'])
+ datas = cur.fetchone()
+ cur.close()
+ conn.close()
+
+ return datas
+
#########################################################################
# get_zoneid:
# returns the zone_id for a given zone name, or an empty
More information about the bind10-changes
mailing list