From 1258abe0da526fdf80299372aed8b78fd6b88ab0 Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Mon, 9 Dec 2002 16:24:17 +0000 Subject: [PATCH] heap of solaris work git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@61 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- acconfig.h | 3 - configure.in | 32 +- modules/gmysqlbackend/Makefile.in | 6 +- modules/mysqlbackend/Makefile.am | 2 +- modules/pdnsbackend/Makefile.am | 1 + modules/pdnsbackend/pdnsbackend.cc | 8 +- modules/pdnsbackend/pdnsbackend.hh | 4 +- modules/pipebackend/Makefile.am | 1 + modules/pipebackend/coprocess.hh | 1 + modules/pipebackend/pipebackend.cc | 8 +- pdns/Makefile.am | 8 +- pdns/backends/bind/Makefile.am | 2 +- pdns/backends/bind/bindbackend.cc | 10 +- pdns/communicator.hh | 28 +- pdns/distributor.hh | 42 +-- pdns/dnspacket.cc | 7 +- pdns/dnspacket.hh | 31 +- pdns/dnsproxy.hh | 16 +- pdns/docs/pdns.sgml | 498 ++++++++++++++++++++++++++++- pdns/extra/Makefile | 12 - pdns/extra/null.c | 0 pdns/misc.cc | 57 ++-- pdns/nameserver.cc | 23 +- pdns/pdns.in | 3 +- pdns/tcpreceiver.cc | 6 +- pdns/unix_utility.cc | 11 +- pdns/utility.hh | 7 + pdns/ws.cc | 19 +- 28 files changed, 645 insertions(+), 201 deletions(-) delete mode 100644 acconfig.h delete mode 100644 pdns/extra/Makefile delete mode 100644 pdns/extra/null.c diff --git a/acconfig.h b/acconfig.h deleted file mode 100644 index 512236579..000000000 --- a/acconfig.h +++ /dev/null @@ -1,3 +0,0 @@ -/* Define when extra posix typedefs are needed (solaris2.6) */ -#undef NEED_POSIX_TYPEDEF -#undef VERBOSELOG diff --git a/configure.in b/configure.in index 9be7eaabe..34cb77c49 100644 --- a/configure.in +++ b/configure.in @@ -3,7 +3,9 @@ AC_INIT(pdns/receiver.cc) AM_INIT_AUTOMAKE(pdns, 2.9.1) AC_CANONICAL_HOST AM_CONFIG_HEADER(config.h) -CXXFLAGS="-Wall -pthread -O2" +AC_C_BIGENDIAN +AC_PREREQ(2.52) +CXXFLAGS="$CXXFLAGS -Wall" AC_PREFIX_DEFAULT(/usr/local) AC_PROG_CC @@ -25,11 +27,16 @@ AC_HEADER_TIME AC_STRUCT_TM dnl Checks for library functions. -AC_FUNC_SETVBUF_REVERSED AC_TYPE_SIGNAL -AC_FUNC_STRFTIME AC_CHECK_FUNCS(gethostname gettimeofday mkdir mktime select socket strerror) +AC_CHECK_LIB(resolv, inet_ntop) + +dnl AC_MSG_NOTICE([Looking in libraries: $LIBS]) + +AC_CHECK_FUNCS(inet_ntop, , AC_LIBOBJ(lib/inet_ntop)) +AC_CHECK_FUNCS(inet_pton, , AC_LIBOBJ(lib/inet_pton)) + # # Check for libdl @@ -89,9 +96,20 @@ fi case "$host_os" in solaris2*) - AC_DEFINE(NEED_POSIX_TYPEDEF) + AC_DEFINE(NEED_POSIX_TYPEDEF,,[If POSIX typedefs need to be defined]) + AC_DEFINE(NEED_INET_NTOP_PROTO,,[If your OS is so broken that it needs an additional prototype]) + LIBS="-lposix4 -lnsl -lsocket -lpthread $LIBS" + CXXFLAGS="-D_REENTRANT $CXXFLAGS" + ;; +linux*) + AC_DEFINE(HAVE_IPV6,1,[If the host operating system understands IPv6]) + LDFLAGS="-pthread $LDFLAGS" + CXXFLAGS="-pthread -D_GNU_SOURCE $CXXFLAGS" ;; *) + AC_DEFINE(HAVE_IPV6,1,[If the host operating system understands IPv6]) + LDFLAGS="-pthread $LDFLAGS" + CXXFLAGS="-pthread $CXXFLAGS" ;; esac @@ -99,7 +117,7 @@ AC_MSG_CHECKING(whether we will be doing verbose logging) AC_ARG_ENABLE(verbose-logging, [ --enable-verbose-logging Do verbose logging],enable_verbose_logging=yes ,enable_verbose_logging=no) -if test $enable_verbose_logging = yes; then AC_DEFINE(VERBOSELOG, 1) +if test $enable_verbose_logging = yes; then AC_DEFINE(VERBOSELOG, 1, [If verbose logging should be enabled]) fi AC_MSG_RESULT($enable_verbose_logging) @@ -245,7 +263,7 @@ then [PGSQL_lib_check="$withval/lib/pgsql $with_pgsql/lib" PGSQL_inc_check="$withval/include/pgsql"], [PGSQL_lib_check="/usr/local/pgsql/lib/pgsql /usr/local/lib/pgsql /opt/pgsql/lib/pgsql /usr/lib/pgsql /usr/local/pgsql/lib /usr/local/lib /opt/pgsql/lib /usr/lib" - PGSQL_inc_check="/usr/local/pgsql/include/pgsql /usr/local/include/pgsql /opt/pgsql/include/pgsql /opt/pgsql/include /usr/include/postgresql"]) + PGSQL_inc_check="/usr/local/pgsql/include/pgsql /usr/local/include/postgresql/ /usr/local/include /opt/pgsql/include/pgsql /opt/pgsql/include /usr/include/postgresql"]) AC_ARG_WITH(pgsql-lib, [ --with-pgsql-lib= directory path of PgSQL library installation], [PGSQL_lib_check="$withval/lib/pgsql $withval/pgsql $withval"]) @@ -283,7 +301,7 @@ then fi done if test -z "$PGSQL_incdir"; then - AC_MSG_ERROR([Didn't find the mysql include dir in '$PGSQL_inc_check']) + AC_MSG_ERROR([Didn't find the PgSQL include dir in '$PGSQL_inc_check']) fi case "$PGSQL_incdir" in /* ) ;; diff --git a/modules/gmysqlbackend/Makefile.in b/modules/gmysqlbackend/Makefile.in index 9fac8e919..8298ec631 100644 --- a/modules/gmysqlbackend/Makefile.in +++ b/modules/gmysqlbackend/Makefile.in @@ -15,7 +15,7 @@ PGSQL_INCLUDES = @PGSQL_incdir@ PGSQL_LIB = @PGSQL_lib@ PGSQL_LIBS = -Wl,-Bstatic -lpq++ -lpq -Wl,-Bdynamic -lssl -lcrypt -lcrypto -CXXFLAGS:=-I$(PDNS_HOME) $(CXXFLAGS) +INCLUDES=-I$(PDNS_HOME) -I../.. dopgsql=@dopgsql@ domysql=@domysql@ @@ -70,12 +70,12 @@ distdir: $(DISTFILES) deps: - -g++ -MM -g -c $(CXXFLAGS) $(CPPFLAGS) gmysqlbackend.cc smysql.cc > deps + -g++ -MM -g -c $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) gmysqlbackend.cc smysql.cc > deps -include deps .cc.o: - g++ -MD -g -c $(CXXFLAGS) $(CPPFLAGS) $< + g++ -MD -g -c $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) $< install: diff --git a/modules/mysqlbackend/Makefile.am b/modules/mysqlbackend/Makefile.am index 4ebb5188b..2378103e1 100644 --- a/modules/mysqlbackend/Makefile.am +++ b/modules/mysqlbackend/Makefile.am @@ -1,4 +1,4 @@ -CXXFLAGS:=-I@MYSQL_incdir@ $(CXXFLAGS) +INCLUDES=-I@MYSQL_incdir@ lib_LTLIBRARIES = libmysqlbackend.la EXTRA_DIST=OBJECTFILES OBJECTLIBS libmysqlbackend_la_SOURCES=mysqlcbackend.cc mysqlcbackend.hh diff --git a/modules/pdnsbackend/Makefile.am b/modules/pdnsbackend/Makefile.am index ca3e8a225..1d33b85d6 100644 --- a/modules/pdnsbackend/Makefile.am +++ b/modules/pdnsbackend/Makefile.am @@ -1,3 +1,4 @@ +INCLUDES=-I@MYSQL_incdir@ lib_LTLIBRARIES = libpdnsbackend.la EXTRA_DIST=OBJECTFILES OBJECTLIBS diff --git a/modules/pdnsbackend/pdnsbackend.cc b/modules/pdnsbackend/pdnsbackend.cc index a78504bfc..349b77d6f 100644 --- a/modules/pdnsbackend/pdnsbackend.cc +++ b/modules/pdnsbackend/pdnsbackend.cc @@ -1,4 +1,4 @@ -// $Id: pdnsbackend.cc,v 1.2 2002/11/28 12:30:45 ahu Exp $ +// $Id: pdnsbackend.cc,v 1.3 2002/12/09 16:24:17 ahu Exp $ #include #include @@ -248,15 +248,15 @@ class PDNSFactory : public BackendFactory //! Magic class that is activated when the dynamic library is loaded -class Loader +class PdnsBeLoader { public: - Loader() + PdnsBeLoader() { BackendMakers().report(new PDNSFactory); L< +#include class PdnsBackend : public DNSBackend { diff --git a/modules/pipebackend/Makefile.am b/modules/pipebackend/Makefile.am index 1f26fa735..3abaad45e 100644 --- a/modules/pipebackend/Makefile.am +++ b/modules/pipebackend/Makefile.am @@ -3,6 +3,7 @@ # install .lib/libpipebackend.so.0.0.0 @libdir@ #endif +EXTRA_DIST=OBJECTFILES OBJECTLIBS lib_LTLIBRARIES = libpipebackend.la diff --git a/modules/pipebackend/coprocess.hh b/modules/pipebackend/coprocess.hh index bb1dbd4a8..231865bd4 100644 --- a/modules/pipebackend/coprocess.hh +++ b/modules/pipebackend/coprocess.hh @@ -3,6 +3,7 @@ #include #include +#include using namespace std; diff --git a/modules/pipebackend/pipebackend.cc b/modules/pipebackend/pipebackend.cc index 4c6055d16..8aa5cbc6d 100644 --- a/modules/pipebackend/pipebackend.cc +++ b/modules/pipebackend/pipebackend.cc @@ -1,6 +1,6 @@ // -*- sateh-c -*- // File : pdnsbackend.cc -// Version : $Id: pipebackend.cc,v 1.2 2002/12/06 09:58:03 ahu Exp $ +// Version : $Id: pipebackend.cc,v 1.3 2002/12/09 16:24:17 ahu Exp $ // #include @@ -223,10 +223,10 @@ class PipeFactory : public BackendFactory } }; -class Loader +class PipeLoader { public: - Loader() + PipeLoader() { BackendMakers().report(new PipeFactory); @@ -234,5 +234,5 @@ class Loader } }; -static Loader loader; +static PipeLoader pipeloader; diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 1a3d1042b..2708eceed 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -1,10 +1,10 @@ -AM_CXXFLAGS=-D_GNU_SOURCE -DSYSCONFDIR=\"@sysconfdir@\" -DBINDIR=\"@bindir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind +AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DBINDIR=\"@bindir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind AM_CPPFLAGS=-Ibackends/bind EXTRA_DIST = codedocs/Makefile codedocs/doxygen.conf docs/Makefile \ docs/gslb-operations.sgml docs/powerdns-case.sgml docs/powerdns-install.sgml \ -docs/powerdns-overview.sgml docs/powerdns-technical.sgml extra/Makefile \ -extra/null.c pdns.spec release-scripts/ docs/pdns.sgml \ +docs/powerdns-overview.sgml docs/powerdns-technical.sgml \ +pdns.spec release-scripts/ docs/pdns.sgml \ choosepaths mtasker.cc noinst_SCRIPTS = pdns @@ -48,5 +48,5 @@ pdns_control_LDFLAGS= # binpatch_SOURCES=binpatch.cc -SUBDIRS= codedocs backends extra . +SUBDIRS= codedocs backends . diff --git a/pdns/backends/bind/Makefile.am b/pdns/backends/bind/Makefile.am index 11cb071d3..362f107c2 100644 --- a/pdns/backends/bind/Makefile.am +++ b/pdns/backends/bind/Makefile.am @@ -1,4 +1,4 @@ -AM_CXXFLAGS=-D_GNU_SOURCE -I../.. +INCLUDES=-I../.. lib_LTLIBRARIES = libbindbackend.la libbindbackend_la_SOURCES=bindbackend.cc bindbackend.hh bindparser.yy \ diff --git a/pdns/backends/bind/bindbackend.cc b/pdns/backends/bind/bindbackend.cc index fe0fc3be3..453d90b42 100644 --- a/pdns/backends/bind/bindbackend.cc +++ b/pdns/backends/bind/bindbackend.cc @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// $Id: bindbackend.cc,v 1.1 2002/11/27 15:18:37 ahu Exp $ +// $Id: bindbackend.cc,v 1.2 2002/12/09 16:24:17 ahu Exp $ #include #include #include @@ -540,13 +540,13 @@ class BindFactory : public BackendFactory //! Magic class that is activated when the dynamic library is loaded -class Loader +class BindLoader { public: - Loader() + BindLoader() { BackendMakers().report(new BindFactory); - theL()< #include #include - -#ifndef WIN32 -# include -# include -# include -#endif // WIN32 - + +#ifndef WIN32 +# include +# include +# include +#endif // WIN32 + #include "lock.hh" #include "packethandler.hh" @@ -47,12 +47,12 @@ class NotificationQueue public: void add(const string &domain, const string &ip) { - NotificationRequest nr; - nr.domain = domain; - nr.ip = ip; - nr.attempts = 0; - nr.id = Utility::random()%0xffff; - nr.next = time(0); + NotificationRequest nr; + nr.domain = domain; + nr.ip = ip; + nr.attempts = 0; + nr.id = Utility::random()%0xffff; + nr.next = time(0); d_nqueue.push_back(nr); } @@ -157,7 +157,7 @@ private: void slaveRefresh(PacketHandler *P); void masterUpdateCheck(PacketHandler *P); pthread_mutex_t d_lock; - queue d_suckdomains; + std::queue d_suckdomains; Semaphore d_suck_sem; Semaphore d_any_sem; int d_tickinterval; diff --git a/pdns/distributor.hh b/pdns/distributor.hh index 5b6802043..03cad418a 100644 --- a/pdns/distributor.hh +++ b/pdns/distributor.hh @@ -16,21 +16,21 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef DISTRIBUTOR_HH -#define DISTRIBUTOR_HH - - + +#ifndef DISTRIBUTOR_HH +#define DISTRIBUTOR_HH + + #include #include #include #include #include -#include - +#include + #ifndef WIN32 -# include -#endif // WIN32 +# include +#endif // WIN32 #include "logger.hh" #include "dns.hh" @@ -72,8 +72,8 @@ public: sleep(1); int qcount, acount; - us->numquestions.getvalue( &qcount ); - us->numanswers.getvalue( &acount ); + us->numquestions.getvalue( &qcount ); + us->numanswers.getvalue( &acount ); L <<"queued questions: "< tuple_t; private: - queue questions; + std::queue questions; pthread_mutex_t q_lock; @@ -166,10 +166,10 @@ templatevoid *Distributord_idle_threads++; - + us->numquestions.getValue( &qcount ); - us->numquestions.wait(); + us->numquestions.wait(); us->d_idle_threads--; pthread_mutex_lock(&us->q_lock); @@ -278,9 +278,9 @@ templateint Distributorint DistributorAnswer* Distributorvoid Distributor::getQueueSizes(int &questions, int &answers) -{ - numquestions.getValue( &questions ); +{ + numquestions.getValue( &questions ); numanswers.getValue( &answers ); } @@ -441,6 +441,6 @@ templateint Distributor @@ -273,9 +273,11 @@ void DNSPacket::addAAAARecord(const DNSResourceRecord &rr) DLOG(L<<"Adding an AAAA record to the packet!"<( addr ))) addAAAARecord(rr.qname, addr, rr.ttl); else +#endif L< DNSPacket::getAnswers() if(length!=16) throw AhuException("Wrong length AAAA record returned from remote"); char tmp[128]; - +#ifdef AF_INET6 if(!Utility::inet_ntop(AF_INET6, datapos, tmp, sizeof(tmp)-1)) +#endif throw AhuException("Unable to translate record of type AAAA in resolver"); rr.content=tmp; diff --git a/pdns/dnspacket.hh b/pdns/dnspacket.hh index 6bb5f98a8..ae83dc614 100644 --- a/pdns/dnspacket.hh +++ b/pdns/dnspacket.hh @@ -16,22 +16,22 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// $Id: dnspacket.hh,v 1.3 2002/12/06 09:58:03 ahu Exp $ +// $Id: dnspacket.hh,v 1.4 2002/12/09 16:24:17 ahu Exp $ #ifndef DNSPACKET_HH #define DNSPACKET_HH #include #include #include -#include - +#include + #ifndef WIN32 #include #include #include -#include -#include - +#include +#include + #endif // WIN32 #include @@ -47,14 +47,8 @@ #ifdef HAVE_CONFIG_H #include "config.h" -#endif // HAVE_CONFIG_H - - + #endif // HAVE_CONFIG_H -#ifdef NEED_POSIX_TYPEDEF -typedef unsigned short int u_int16_t; -typedef unsigned int u_int32_t; -#endif #ifdef WIN32 # ifdef BYTE_ORDER @@ -80,7 +74,7 @@ public: struct dnsheader { unsigned int id:16; //!< id of this query/response -#if BYTE_ORDER == BIG_ENDIAN +#ifdef WORDS_BIGENDIAN // ultrasparc unsigned int qr:1; //!< 1 if this is a query, 0 if response unsigned int opcode:4; //!< the opcode unsigned int aa:1; //!< packet contains authoritative data @@ -301,13 +295,8 @@ int DNSPacket::parse(const char *mesg, int length) d_qlen=offset+4; // this points to the start of any answers } - - const char *p=(stringbuffer.c_str()+12+offset); - const unsigned short int *i=(const unsigned short int *)p; - qtype=ntohs(*i++); - qclass=ntohs(*i); - - + qtype=stringbuffer[12+offset]*256+stringbuffer[13+offset]; + qclass=stringbuffer[14+offset]*256+stringbuffer[15+offset]; return 0; } diff --git a/pdns/dnsproxy.hh b/pdns/dnsproxy.hh index 6ec260551..60c15766c 100644 --- a/pdns/dnsproxy.hh +++ b/pdns/dnsproxy.hh @@ -20,13 +20,13 @@ #define PDNS_DNSPROXY #include #include - -#ifndef WIN32 -# include -# include -# include -#endif // WIN32 - + +#ifndef WIN32 +# include +# include +# include +#endif // WIN32 + #include "dnspacket.hh" #include "lock.hh" #include "iputils.hh" @@ -76,7 +76,7 @@ private: struct ConntrackEntry { u_int16_t id; - struct sockaddr_in6 remote; + char remote[28]; Utility::socklen_t addrlen; int outsock; time_t created; diff --git a/pdns/docs/pdns.sgml b/pdns/docs/pdns.sgml index 278ce5e5a..4784e5b83 100644 --- a/pdns/docs/pdns.sgml +++ b/pdns/docs/pdns.sgml @@ -15,7 +15,7 @@ - v2.1 $Date: 2002/11/28 14:38:00 $ + v2.1 $Date: 2002/12/09 16:24:17 $ @@ -6543,23 +6543,489 @@ static RandomLoader randomloader; Compiling PowerDNS - The PowerDNS source is separated from many of its modules. The main PowerDNS source tree however is able - to pull in certain files for creating packaged releases. + For now, see the Open Source PowerDNS site. + ./configure --enable-mysql ; make ; make install will do The Right Thing for most people. - - First download the source or retrieve from anoncvs.powerdns.com (module 'powerdns'). If from cvs, you need to execute - ./bootstrap to have the GNU autotools build the configure script and the Makefiles. - - - The run ./configure, followed by 'make'. PowerDNS prefers being compiled with GCC 3.2 but 2.95.4 and 3.0.4 will also work on most systems. - It will not compile on Debian Potato because that lacks the sstream include file. - - - After compiling, the ./installer script can be used to install. - - Configuring external modules with PowerDNS + Compiling PowerDNS on Windows + + By Michael Stol (michael@physos.info). + Assumptions + + I will assume these things from you: + + + + + You have the PowerDNS sources. + + + + There's not much to compile without the source files, eh? :) + + + + + + + You are using Microsoft Visual C++. If you get it to compile using a free compiler, please let us know! + + + + From the day that we began porting the UNIX PowerDNS sources to Microsoft Windows + we used Microsoft Visual C++ as our development environment of choice. + + + + We used Visual C++ 6.0 to compile all sources (both standard version and SP5). Other versions + (including Visual C++ .NET) are untested. + + + + + + + You are using Microsoft Windows NT, 2000 or XP + + + + I will assume that the system where you want to compile the sources on is running + Microsoft Windows NT, 2000 or XP. These are the operating systems that where found + running PowerDNS for Windows. + + + + + + You probably can compile the sources on other Windows versions too, but that is currently untested. + + + + + + + + You are using an English Windows version. + + + + Troughout this document I will use the English names for menu items, names etc., so if you are + running a non-English Windows or MSVC version you have to translate those things yourself. But + I don't think that would be a big problem. + + + + + + + + + + Prequisites + + + Although we tried to keep PowerDNS for Windows' dependencies down to a minimum, you will still need some + programs and libraries to be able to compile the sources. + + + + pthreads for Windows + + + The pthreads for Windows library is a Windows implementation of the POSIX threads + specification, which is used a lot in UNIX programs. + + + + PowerDNS uses pthreads too, and to ease the porting process we decided not to reinvent the wheel, + but to use pthreads for Windows instead. + + + + Getting pthreads for Windows + + + Pthreads for Windows is available from anonymous ftp at ftp://sources.redhat.com/pub/pthreads-win32/. + You should download the latest pthreads-YYYY-MM-DD.exe file. + + + + + PowerDNS for Windows was tested with the snapshot of 2002-03-02 of the library. + + + + + For more information you can visit the pthreads for Windows homepage at http://sources.redhat.com/pthreads-win32/ + + + + + Installing pthreads for Windows + + + To install the pthreads for Windows library you have to locate your pthreads-YYYY-MM-DD.exe + file and start it. + + + + After starting the executable a self-extractor dialog will show up where you can specify where to extract + the contents of the file. When you selected a location you can press the Extract button + to extract all content to the target directory. + + + + The library is now installed, we still have to tell Visual C++ where it's located though, more + on that later. + + + + + + + Nullsoft Installer + + + For our installation program we used Nullsoft's Installer System (NSIS). We used + NSIS because it's easy to use, versatile and free (and it uses SuperPiMP technology, but + they refuse to tell us what it is ;)). If the name Nullsoft rings a bell, it's because they're the guys who made + winamp. + + + + Getting the Nullsoft Installer + + + The Nullsoft Installer can be downloaded at their website, which is + located at http://www.nullsoft.com/free/nsis/. + The file that you should download is called nsisXXX.exe (where XXX is the latest version). + + + + + You can find the NSIS documentation at that website too. + + + + + + Installing the Nullsoft Installer + + + Installing NSIS is easy. All there is to it is locating the installer and execute it. + Then just follow the installation steps. + + + + + + + Setting up the build-environment + + + Before starting Microsoft Visual C++ and compile PowerDNS for Windows, you first + have to set up your build environment. + + + + Make Microsoft Visual C++ recognize <filename>*.cc</filename> and <filename>*.hh</filename> (optional) + + + All PowerDNS source files are in the form name.cc, and all header files in the form + name.hh. These extensions aren't recognized by MSVC by default, so + you might want to change that first. + + + + + Only perform this step if you want to be able to edit the *.cc + and *.hh files in MSVC. + + + + + + If you decide to perform this step, remember that it requires modification of the Windows registry, + always make a backup before modifying! + + + + + Ok, after that word of caution we can now proceed. You have to follow these steps: + + + + + + + Start the registry editor by entering regedit.exe in the run prompt + (Start->Run...). + + + + + + Right click on HKEY_CLASSES_ROOT and select New->Key. + A new key will appear, change that key to .cc, then change the default + value to cppfile + + + + Then perform the same step for .hh (use hfile instead of cppfile). + + + + + + Go to HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Build System\Components\Platforms\Win32 (x86)\Tools\32-bit C/C++ Compiler for 80x86. And + add ;*.cc to the Input_Spec value (so that it becomes *.c;*.cpp;*.cxx;*.cc). + + + + + If you happen to use another platform (like alpha) to compile the sources, you have to do the step above for that platform. + + + + + + + Go to HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Search. And + add ;*.cc;*.hh to the FIF_Filter value (so that it becomes *.c;*.cpp;*.cxx;*.tli;*.h;*.tlh;*.inl;*.rc;*.cc;*.hh). + + + + + + Finally change HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\C/C++. And + add ;cc;hh to the FileExtensions value (so that it becomes cpp;cxx;c;h;hxx;hpp;inl;tlh;tli;rc;rc2;hh;cc). + + + + + + Close the registry editor. + + + + + + + Now should MSVC properly recognize the files as being C++. + + + + + + Setting Microsoft Visual C++'s directories + + + MSVC needs to locate some include files, libraries and executables + when it has to build PowerDNS for Windows. We are now going to tell MSVC where + to find those. + + + + To enter the directory dialog you have to go to Tools->Options...->Directories. + + + + Setting the pthreads directories + + + When you are in the directory dialog you can add the pthreads for Windows directory. + + + + First add the include directory, to do this you have to select Include files + from the Show directories for: combobox. Then press the New + button and browse to the include directory of pthreads (ie. C:\pthreads\include). + + + + Then switch to Library files and add the library directory + (ie. C:\pthreads\lib) using the same method as above. + + + + + Setting the Nullsoft Installer directory + + + While still being in the directory dialog, switch to Executable files + and add the Nullsoft Installer directory (ie. C:\Program Files\NSIS) to the list. + + + + + + + + + Compilation + + + Finally, after all the reading, installing and configuring we are ready to start compiling + PowerDNS for Windows. + + + + Starting the compilation + + + To start the compilation you first have to open the PowerDNS workspace (powerdns.dsw) using explorer or + from the File->Open Workspace... menu in MSVC. + + + + After you opened the workspace you can start compiling. Check all the checkboxes in the + Build->Batch Build... menu and press the Build button. + + + + Now cross your fingers and go make some coffee or tea while compiling PowerDNS for Windows. :) + + + + + + Yay! It compiled + + + Congratulations, you have now compiled PowerDNS for Windows! + + - A module needs to see the PowerDNS sources. See the INSTALL file of a module on how to configure this. + All the release builds of the binaries are in the Release directory (including the + generated installer). The debug builds are in the, guess what, Debug directory. + + + Now you can start installing PowerDNS, but that's beyond the scope of this document. See + the online documentation for + more information about that. + + + + + What if it went wrong? + + + If the compilation fails, then try reading this article again, and again to see if you did something wrong. + + + + If you are pretty sure that it's a bug, either in the PowerDNS sources, the build + system or in this article, then please send an e-mail to powerdns-dev@mailman.powerdns.com describing your + problem. We will then try to fix it. + + + + + + + + Miscellaneous + + + Some miscellaneous information. + + + + Credits + + + Michel Stol would like to thank these people: + + + + Bert Hubert + + + + For writing the wonderfull PowerDNS software and learning me stuff + that I'd otherwise never had learned. + + + + + + + PowerDNS B.V. + + + + For being great colleagues. + + + + + + + The pthreads-win32 crew (see the pthreads-win32 CONTRIBUTORS file). + + + + For easing our porting process by writing a great Windows implementation of pthreads. + + + + + + + The guys over at Nullsoft. + + + + For creating the Nullsoft Installer System (NSIS), and Winamp, the program we use every + day to make a lot of noise in the office. + + + + + + + + + + Contact information + + + If you have a comment, or a bug report concerning either this document or the PowerDNS sources + you can contact powerdns-dev@mailman.powerdns.com + + + + For general information about PowerDNS, the pdns server, express, documentation etc. I advice you to visit + http://www.powerdns.com/ + + + + If you are interested in buying PowerDNS you can send a mail to sales@powerdns.com + or you can visit the PowerDNS website at http://www.powerdns.com/pdns/ + + + + If you want to praise my work, ask me to marry you, deposit $1.000.000 on my bank account or flame me to death, then + you can mail me at michel@physos.info :) + + + + + + Legal information + + + Microsoft, Visual C++, Windows, Windows NT, Windows 2000, Windows XP and Win32 are + either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries. + + + + Other product and company names mentioned herein may be the trademarks of their respective owners. + + + + + + diff --git a/pdns/extra/Makefile b/pdns/extra/Makefile deleted file mode 100644 index 5c2f69904..000000000 --- a/pdns/extra/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# $Id: Makefile,v 1.1 2002/11/27 15:18:37 ahu Exp $ - -all: null.o - -install: - -distdir: - -distclean: clean - -clean: - rm -f null.o *.o *.so diff --git a/pdns/extra/null.c b/pdns/extra/null.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/pdns/misc.cc b/pdns/misc.cc index 34604ad94..6c43b81cd 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -21,20 +21,21 @@ #include #include #include -#include - +#include + #include #include #include #include #include - -#ifndef WIN32 -# include -# include +#include + +#ifndef WIN32 +# include +# include # include # include -#endif // WIN32 +#endif // WIN32 #include "utility.hh" @@ -83,8 +84,8 @@ int matchNetmask(const char *address, const char *omask) *sep=0; } - if(!Utility::inet_aton(address, &a) || !Utility::inet_aton(mask, &m)) - { + if(!Utility::inet_aton(address, &a) || !Utility::inet_aton(mask, &m)) + { free(mask); return -1; } @@ -107,23 +108,23 @@ int matchNetmask(const char *address, const char *omask) int waitForData(int fd, int seconds) { - struct timeval tv; - int ret; - - tv.tv_sec = seconds; - tv.tv_usec = 0; - - fd_set readfds; - FD_ZERO( &readfds ); - FD_SET( fd, &readfds ); - - ret = select( fd + 1, &readfds, NULL, NULL, &tv ); - if ( ret == -1 ) - { - ret = -1; - errno = ETIMEDOUT; - } - + struct timeval tv; + int ret; + + tv.tv_sec = seconds; + tv.tv_usec = 0; + + fd_set readfds; + FD_ZERO( &readfds ); + FD_SET( fd, &readfds ); + + ret = select( fd + 1, &readfds, NULL, NULL, &tv ); + if ( ret == -1 ) + { + ret = -1; + errno = ETIMEDOUT; + } + return ret; } @@ -238,8 +239,7 @@ const string sockAddrToString(struct sockaddr_in *remote, Utility::socklen_t soc { if(socklen==sizeof(struct sockaddr_in)) return inet_ntoa(((struct sockaddr_in *)remote)->sin_addr); - - // TODO: Add ipv6 support here. +#ifdef HAVE_IPV6 else { char tmp[128]; @@ -248,6 +248,7 @@ const string sockAddrToString(struct sockaddr_in *remote, Utility::socklen_t soc return tmp; } +#endif return "untranslateable"; } diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index dc215d590..f8d1e2fe7 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -1,5 +1,4 @@ /* - PowerDNS Versatile Database Driven Nameserver Copyright (C) 2002 PowerDNS.COM BV This program is free software; you can redistribute it and/or modify @@ -16,24 +15,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* - Copyright (C) 2002 PowerDNS.COM BV - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -// $Id: nameserver.cc,v 1.1 2002/11/27 15:18:31 ahu Exp $ +// $Id: nameserver.cc,v 1.2 2002/12/09 16:24:17 ahu Exp $ #include "utility.hh" #include #include @@ -155,8 +137,7 @@ void UDPNameserver::bindIPv4() void UDPNameserver::bindIPv6() { - // TODO: Add Windows ipv6 support. -#ifndef WIN32 +#if !WIN32 && HAVE_IPV6 vectorlocals; stringtok(locals,arg()["local-ipv6"]," ,"); diff --git a/pdns/pdns.in b/pdns/pdns.in index fc223c291..b80c5d07c 100755 --- a/pdns/pdns.in +++ b/pdns/pdns.in @@ -5,6 +5,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ BINARYPATH=@bindir@ +SBINARYPATH=@sbindir@ SOCKETPATH=@socketdir@ cd $SOCKETPATH @@ -17,7 +18,7 @@ else PROGNAME=pdns fi -pdns_server="$BINARYPATH/pdns_server $EXTRAOPTS" +pdns_server="$SBINARYPATH/pdns_server $EXTRAOPTS" doPC() { diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 0d5bd21fb..0909308be 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "utility.hh" +#include "utility.hh" #include #include #include @@ -24,7 +24,7 @@ #include #include #include "tcpreceiver.hh" - + #include #include @@ -436,7 +436,7 @@ TCPNameserver::TCPNameserver() } // TODO: Implement ipv6 -#ifndef WIN32 +#if !WIN32 && HAVE_IPV6 for(vector::const_iterator laddr=locals6.begin();laddr!=locals6.end();++laddr) { struct sockaddr_in6 local; int s=socket(AF_INET6,SOCK_STREAM,0); diff --git a/pdns/unix_utility.cc b/pdns/unix_utility.cc index 7f2ccaef8..dba1caedf 100644 --- a/pdns/unix_utility.cc +++ b/pdns/unix_utility.cc @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// Utility class win32 implementation. + #include "utility.hh" #include @@ -30,6 +30,13 @@ #include #include +#ifdef NEED_INET_NTOP_PROTO +extern "C" { +const char *inet_ntop(int af, const void *src, char *dst, size_t cnt); +} +#endif + + using namespace std; // Closes a socket. @@ -56,7 +63,7 @@ bool Utility::setBlocking(sock_t sock) const char *Utility::inet_ntop(int af, const char *src, char *dst, size_t size) { - return const_cast(::inet_ntop(af,src,dst,size)); + return ::inet_ntop(af,src,dst,size); } unsigned int Utility::sleep(unsigned int sec) diff --git a/pdns/utility.hh b/pdns/utility.hh index b2285003c..18cedf7c8 100644 --- a/pdns/utility.hh +++ b/pdns/utility.hh @@ -21,6 +21,13 @@ #ifndef UTILITY_HH #define UTILITY_HH +#include "config.h" +#ifdef NEED_POSIX_TYPEDEF +typedef unsigned short int u_int16_t; +typedef unsigned int u_int32_t; +#endif + + #ifndef WIN32 # include # include diff --git a/pdns/ws.cc b/pdns/ws.cc index 8696cfe01..bd1d72b6d 100644 --- a/pdns/ws.cc +++ b/pdns/ws.cc @@ -1,21 +1,4 @@ -/* - PowerDNS Versatile Database Driven Nameserver - Copyright (C) 2002 PowerDNS.COM BV - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ /* Copyright (C) 2002 PowerDNS.COM BV @@ -32,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/#include "utility.hh" +*/#include "utility.hh" #include "ws.hh" #include "webserver.hh" #include "logger.hh" -- 2.40.0