summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Client/CommandParser.cpp1
-rw-r--r--src/Client/Makefile.am1
-rw-r--r--src/Client/Makefile.in3
-rw-r--r--src/Client/Request/CoreStatusRequest.cpp69
-rw-r--r--src/Client/Request/CoreStatusRequest.h51
-rw-r--r--src/Client/Request/Makefile.am5
-rw-r--r--src/Client/Request/Makefile.in99
-rw-r--r--src/Common/Makefile.am4
-rw-r--r--src/Common/Makefile.in10
-rw-r--r--src/Common/Request/DisconnectRequest.cpp67
-rw-r--r--src/Common/Request/DisconnectRequest.h47
-rw-r--r--src/Common/Request/GSSAPIAuthRequest.cpp171
-rw-r--r--src/Common/Request/GSSAPIAuthRequest.h149
-rw-r--r--src/Common/Request/IdentifyRequest.cpp62
-rw-r--r--src/Common/Request/IdentifyRequest.h43
-rw-r--r--src/Common/Request/Makefile.am5
-rw-r--r--src/Common/Request/Makefile.in102
-rw-r--r--src/Common/Request/Request.h1
-rw-r--r--src/Common/RequestHandler/DisconnectRequestHandler.cpp46
-rw-r--r--src/Common/RequestHandler/DisconnectRequestHandler.h17
-rw-r--r--src/Common/RequestHandler/IdentifyRequestHandler.cpp47
-rw-r--r--src/Common/RequestHandler/IdentifyRequestHandler.h18
-rw-r--r--src/Common/RequestHandler/Makefile.am5
-rw-r--r--src/Common/RequestHandler/Makefile.in101
-rw-r--r--src/Common/RequestManager.cpp62
-rw-r--r--src/Common/RequestManager.h59
-rw-r--r--src/Common/Util.cpp50
-rw-r--r--src/Common/Util.h27
-rw-r--r--src/Core/Makefile.am1
-rw-r--r--src/Core/Makefile.in3
-rw-r--r--src/Core/RequestHandler/CoreStatusRequestHandler.cpp52
-rw-r--r--src/Core/RequestHandler/CoreStatusRequestHandler.h23
-rw-r--r--src/Core/RequestHandler/GSSAPIAuthRequestHandler.cpp113
-rw-r--r--src/Core/RequestHandler/GSSAPIAuthRequestHandler.h84
-rw-r--r--src/Core/RequestHandler/Makefile.am5
-rw-r--r--src/Core/RequestHandler/Makefile.in101
-rw-r--r--src/Daemon/Makefile.am7
-rw-r--r--src/Daemon/Makefile.in75
-rw-r--r--src/Daemon/RequestHandler/Makefile.am5
-rw-r--r--src/Daemon/RequestHandler/Makefile.in68
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Makefile.in7
-rw-r--r--src/Net/Connection.cpp62
-rw-r--r--src/Net/Connection.h58
-rw-r--r--src/Net/IPAddress.cpp92
-rw-r--r--src/Net/IPAddress.h73
-rw-r--r--src/Net/Makefile.am2
-rw-r--r--src/Net/Makefile.in5
48 files changed, 1448 insertions, 714 deletions
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp
index 3100466..ed15b7b 100644
--- a/src/Client/CommandParser.cpp
+++ b/src/Client/CommandParser.cpp
@@ -20,6 +20,7 @@
#include "CommandParser.h"
#include "Request/CoreStatusRequest.h"
#include <Common/Request/DisconnectRequest.h>
+#include <Net/Packets/HostStatusPacket.h>
#include <iostream>
#include <cstdio>
diff --git a/src/Client/Makefile.am b/src/Client/Makefile.am
index 0a1d8e3..65407f3 100644
--- a/src/Client/Makefile.am
+++ b/src/Client/Makefile.am
@@ -2,5 +2,6 @@ SUBDIRS = Request
noinst_LTLIBRARIES = libclient.la
libclient_la_SOURCES = CommandParser.cpp
+libclient_la_LIBADD = Request/librequest.la
noinst_HEADERS = CommandParser.h
diff --git a/src/Client/Makefile.in b/src/Client/Makefile.in
index 423e2f3..a1a049e 100644
--- a/src/Client/Makefile.in
+++ b/src/Client/Makefile.in
@@ -44,7 +44,7 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
-libclient_la_LIBADD =
+libclient_la_DEPENDENCIES = Request/librequest.la
am_libclient_la_OBJECTS = CommandParser.lo
libclient_la_OBJECTS = $(am_libclient_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
@@ -194,6 +194,7 @@ top_srcdir = @top_srcdir@
SUBDIRS = Request
noinst_LTLIBRARIES = libclient.la
libclient_la_SOURCES = CommandParser.cpp
+libclient_la_LIBADD = Request/librequest.la
noinst_HEADERS = CommandParser.h
all: all-recursive
diff --git a/src/Client/Request/CoreStatusRequest.cpp b/src/Client/Request/CoreStatusRequest.cpp
new file mode 100644
index 0000000..f5fe043
--- /dev/null
+++ b/src/Client/Request/CoreStatusRequest.cpp
@@ -0,0 +1,69 @@
+/*
+ * CoreStatusRequest.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "CoreStatusRequest.h"
+
+#include <Common/RequestManager.h>
+#include <Net/Packets/HostStatusPacket.h>
+
+#include <sigc++/signal.h>
+
+namespace Mad {
+namespace Client {
+namespace Request {
+
+bool CoreStatusRequest::send(Net::Connection *connection, Common::RequestManager &requestManager, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback) {
+ CoreStatusRequest *request = new CoreStatusRequest();
+
+ request->finished.connect(callback);
+
+ if(requestManager.sendRequest(connection, request))
+ return true;
+
+ delete request;
+ return false;
+}
+
+bool CoreStatusRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ if(isSent())
+ return false;
+
+ if(!connection->send(Net::Packet(Net::Packet::CORE_STATUS, requestId)))
+ return false;
+
+ setSent();
+ return true;
+}
+
+bool CoreStatusRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::OK)
+ return false; // TODO Logging
+
+ finished(Net::Packets::HostStatusPacket(packet));
+
+ setFinished();
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Client/Request/CoreStatusRequest.h b/src/Client/Request/CoreStatusRequest.h
index 328c4ff..1a6a01e 100644
--- a/src/Client/Request/CoreStatusRequest.h
+++ b/src/Client/Request/CoreStatusRequest.h
@@ -20,14 +20,22 @@
#ifndef MAD_CLIENT_REQUEST_CORESTATUSREQUEST_H_
#define MAD_CLIENT_REQUEST_CORESTATUSREQUEST_H_
-#include <Common/RequestManager.h>
#include <Common/Request/Request.h>
-#include <Net/Connection.h>
-#include <Net/Packets/HostStatusPacket.h>
#include <sigc++/signal.h>
namespace Mad {
+
+namespace Common {
+class RequestManager;
+}
+
+namespace Net {
+namespace Packets {
+class HostStatusPacket;
+}
+}
+
namespace Client {
namespace Request {
@@ -38,41 +46,10 @@ class CoreStatusRequest: public Common::Request::Request {
CoreStatusRequest() {}
public:
- static bool send(Net::Connection *connection, Common::RequestManager &requestManager, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback) {
- CoreStatusRequest *request = new CoreStatusRequest();
-
- request->finished.connect(callback);
-
- if(requestManager.sendRequest(connection, request))
- return true;
-
- delete request;
- return false;
- }
-
- virtual bool sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(isSent())
- return false;
-
- if(!connection->send(Net::Packet(Net::Packet::CORE_STATUS, requestId)))
- return false;
-
- setSent();
- return true;
- }
-
- virtual bool handlePacket(Net::Connection*, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::OK)
- return false; // TODO Logging
-
- finished(Net::Packets::HostStatusPacket(packet));
+ static bool send(Net::Connection *connection, Common::RequestManager &requestManager, const sigc::slot<void,const Net::Packets::HostStatusPacket&> &callback);
- setFinished();
- return true;
- }
+ virtual bool sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual bool handlePacket(Net::Connection*, const Net::Packet &packet);
};
}
diff --git a/src/Client/Request/Makefile.am b/src/Client/Request/Makefile.am
index 58db76c..64b5a33 100644
--- a/src/Client/Request/Makefile.am
+++ b/src/Client/Request/Makefile.am
@@ -1 +1,4 @@
-noinst_HEADERS = CoreStatusRequest.h
+noinst_LTLIBRARIES = librequest.la
+librequest_la_SOURCES = CoreStatusRequest.cpp
+
+noinst_HEADERS = CoreStatusRequest.h
diff --git a/src/Client/Request/Makefile.in b/src/Client/Request/Makefile.in
index d81a597..fde067d 100644
--- a/src/Client/Request/Makefile.in
+++ b/src/Client/Request/Makefile.in
@@ -14,6 +14,7 @@
@SET_MAKE@
+
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -42,8 +43,24 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
-SOURCES =
-DIST_SOURCES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+librequest_la_LIBADD =
+am_librequest_la_OBJECTS = CoreStatusRequest.lo
+librequest_la_OBJECTS = $(am_librequest_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(librequest_la_SOURCES)
+DIST_SOURCES = $(librequest_la_SOURCES)
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
@@ -164,10 +181,13 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = librequest.la
+librequest_la_SOURCES = CoreStatusRequest.cpp
noinst_HEADERS = CoreStatusRequest.h
all: all-am
.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -198,6 +218,46 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+librequest.la: $(librequest_la_OBJECTS) $(librequest_la_DEPENDENCIES)
+ $(CXXLINK) $(librequest_la_OBJECTS) $(librequest_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoreStatusRequest.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
mostlyclean-libtool:
-rm -f *.lo
@@ -279,7 +339,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(HEADERS)
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
install: install-am
install-exec: install-exec-am
@@ -307,11 +367,14 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libtool mostlyclean-am
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-tags
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
dvi: dvi-am
@@ -342,12 +405,14 @@ install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
-mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
pdf: pdf-am
@@ -362,17 +427,17 @@ uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool ctags distclean distclean-generic \
- distclean-libtool distclean-tags distdir dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-generic \
- mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
- uninstall-am
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am
index 6df8a62..c282538 100644
--- a/src/Common/Makefile.am
+++ b/src/Common/Makefile.am
@@ -1,7 +1,7 @@
SUBDIRS = Backends Request RequestHandler
noinst_LTLIBRARIES = libcommon.la
-libcommon_la_SOURCES = ConfigManager.cpp RequestManager.cpp SystemBackend.cpp
-libcommon_la_LIBADD = Backends/libbackends.la
+libcommon_la_SOURCES = ConfigManager.cpp RequestManager.cpp SystemBackend.cpp Util.cpp
+libcommon_la_LIBADD = Backends/libbackends.la Request/librequest.la RequestHandler/librequesthandler.la
noinst_HEADERS = ConfigManager.h RequestManager.h SystemBackend.h Util.h
diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in
index d2e1f59..39ba3b6 100644
--- a/src/Common/Makefile.in
+++ b/src/Common/Makefile.in
@@ -44,9 +44,10 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
-libcommon_la_DEPENDENCIES = Backends/libbackends.la
+libcommon_la_DEPENDENCIES = Backends/libbackends.la \
+ Request/librequest.la RequestHandler/librequesthandler.la
am_libcommon_la_OBJECTS = ConfigManager.lo RequestManager.lo \
- SystemBackend.lo
+ SystemBackend.lo Util.lo
libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -194,8 +195,8 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = Backends Request RequestHandler
noinst_LTLIBRARIES = libcommon.la
-libcommon_la_SOURCES = ConfigManager.cpp RequestManager.cpp SystemBackend.cpp
-libcommon_la_LIBADD = Backends/libbackends.la
+libcommon_la_SOURCES = ConfigManager.cpp RequestManager.cpp SystemBackend.cpp Util.cpp
+libcommon_la_LIBADD = Backends/libbackends.la Request/librequest.la RequestHandler/librequesthandler.la
noinst_HEADERS = ConfigManager.h RequestManager.h SystemBackend.h Util.h
all: all-recursive
@@ -251,6 +252,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfigManager.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestManager.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemBackend.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Plo@am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/Common/Request/DisconnectRequest.cpp b/src/Common/Request/DisconnectRequest.cpp
new file mode 100644
index 0000000..0f8a3c0
--- /dev/null
+++ b/src/Common/Request/DisconnectRequest.cpp
@@ -0,0 +1,67 @@
+/*
+ * DisconnectRequest.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "DisconnectRequest.h"
+#include "../RequestManager.h"
+
+namespace Mad {
+namespace Common {
+namespace Request {
+
+bool DisconnectRequest::send(Net::Connection *connection, RequestManager &requestManager, const sigc::slot<void> &callback) {
+ DisconnectRequest *request = new DisconnectRequest();
+
+ request->finished.connect(callback);
+
+ if(requestManager.sendRequest(connection, request))
+ return true;
+
+ delete request;
+ return false;
+}
+
+bool DisconnectRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ if(isSent())
+ return false;
+
+ if(!connection->send(Net::Packet(Net::Packet::DISCONNECT, requestId)))
+ return false;
+
+ setSent();
+ return true;
+}
+
+bool DisconnectRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::OK)
+ return false; // TODO Logging
+
+ connection->disconnect();
+
+ finished();
+
+ setFinished();
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Common/Request/DisconnectRequest.h b/src/Common/Request/DisconnectRequest.h
index 1b2d467..136ef73 100644
--- a/src/Common/Request/DisconnectRequest.h
+++ b/src/Common/Request/DisconnectRequest.h
@@ -21,60 +21,27 @@
#define MAD_COMMON_REQUEST_DISCONNECTREQUEST_H_
#include "Request.h"
-#include "../RequestManager.h"
-#include <Net/Connection.h>
-#include <Net/Packet.h>
#include <sigc++/signal.h>
namespace Mad {
namespace Common {
+
+class RequestManager;
+
namespace Request {
-class DisconnectRequest: public Request {
+class DisconnectRequest : public Request {
private:
sigc::signal<void> finished;
DisconnectRequest() {}
public:
- static bool send(Net::Connection *connection, RequestManager &requestManager, const sigc::slot<void> &callback) {
- DisconnectRequest *request = new DisconnectRequest();
-
- request->finished.connect(callback);
-
- if(requestManager.sendRequest(connection, request))
- return true;
-
- delete request;
- return false;
- }
-
- virtual bool sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(isSent())
- return false;
-
- if(!connection->send(Net::Packet(Net::Packet::DISCONNECT, requestId)))
- return false;
-
- setSent();
- return true;
- }
-
- virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::OK)
- return false; // TODO Logging
-
- connection->disconnect();
-
- finished();
+ static bool send(Net::Connection *connection, RequestManager &requestManager, const sigc::slot<void> &callback);
- setFinished();
- return true;
- }
+ virtual bool sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
}
diff --git a/src/Common/Request/GSSAPIAuthRequest.cpp b/src/Common/Request/GSSAPIAuthRequest.cpp
new file mode 100644
index 0000000..4387f97
--- /dev/null
+++ b/src/Common/Request/GSSAPIAuthRequest.cpp
@@ -0,0 +1,171 @@
+/*
+ * GSSAPIAuthRequest.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "GSSAPIAuthRequest.h"
+#include "../RequestManager.h"
+
+#include <cstring>
+
+#include <iostream>
+
+namespace Mad {
+namespace Common {
+namespace Request {
+
+// TODO Logging & error handling!
+
+GSSAPIAuthRequest::~GSSAPIAuthRequest() {
+ OM_uint32 minStat;
+
+ if(gssServiceName != GSS_C_NO_NAME)
+ gss_release_name(&minStat, &gssServiceName);
+}
+
+bool GSSAPIAuthRequest::send(Net::Connection *connection, RequestManager &requestManager, const std::string &serviceName0) {
+ GSSAPIAuthRequest *request = new GSSAPIAuthRequest(serviceName0);
+
+ if(requestManager.sendRequest(connection, request))
+ return true;
+
+ delete request;
+ return false;
+}
+
+bool GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ if(isSent())
+ return false;
+
+ OM_uint32 majStat, minStat;
+ gss_buffer_desc buffer;
+
+ buffer.length = serviceName.length();
+ buffer.value = std::malloc(buffer.length);
+ std::memcpy(buffer.value, serviceName.c_str(), buffer.length);
+
+ majStat = gss_import_name(&minStat, &buffer, GSS_C_NT_HOSTBASED_SERVICE, &gssServiceName);
+
+ std::free(buffer.value);
+
+ if(majStat != GSS_S_COMPLETE) {
+ gssServiceName = GSS_C_NO_NAME;
+ return false;
+ }
+
+ majStat = gss_init_sec_context(&minStat, GSS_C_NO_CREDENTIAL, &gssContext, gssServiceName, GSS_C_NO_OID, GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG,
+ 0, GSS_C_NO_CHANNEL_BINDINGS, GSS_C_NO_BUFFER, 0, &buffer, 0, 0);
+
+ if(majStat == GSS_S_COMPLETE) {
+ std::cout << "GSS context established." << std::endl;
+ gssContinue = false;
+ }
+ else if(majStat != GSS_S_CONTINUE_NEEDED) {
+ gss_release_buffer(&minStat, &buffer);
+ return false;
+ }
+
+ if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, requestId, buffer.value, buffer.length))) {
+ gss_release_buffer(&minStat, &buffer);
+ return false;
+ }
+
+ gss_release_buffer(&minStat, &buffer);
+
+ setSent();
+ return true;
+}
+
+bool GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::GSSAPI_AUTH)
+ return false; // TODO Logging
+
+ OM_uint32 majStat, minStat;
+ gss_buffer_desc recvBuffer, sendBuffer;
+
+ if(gssContinue) {
+ recvBuffer.length = packet.getLength();
+ recvBuffer.value = std::malloc(recvBuffer.length);
+ std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
+
+ majStat = gss_init_sec_context(&minStat, GSS_C_NO_CREDENTIAL, &gssContext, gssServiceName, GSS_C_NO_OID, GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | GSS_C_INTEG_FLAG,
+ 0, GSS_C_NO_CHANNEL_BINDINGS, &recvBuffer, 0, &sendBuffer, 0, 0);
+
+ std::free(recvBuffer.value);
+
+ if(majStat == GSS_S_COMPLETE) {
+ std::cout << "GSS context established." << std::endl;
+ gssContinue = false;
+ }
+ else if(majStat != GSS_S_CONTINUE_NEEDED) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ gss_release_buffer(&minStat, &sendBuffer);
+ }
+ else {
+ recvBuffer.length = packet.getLength();
+ recvBuffer.value = std::malloc(recvBuffer.length);
+ std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
+
+ const gnutls_datum_t *cert = connection->getPeerCertificate();
+
+ sendBuffer.length = cert->size;
+ sendBuffer.value = cert->data;
+
+ majStat = gss_verify_mic(&minStat, gssContext, &sendBuffer, &recvBuffer, 0);
+
+ std::free(recvBuffer.value);
+
+ if(majStat != GSS_S_COMPLETE)
+ return false;
+
+ connection->setAuthenticated();
+ std::cout << "Authentication complete." << std::endl;
+
+ majStat = gss_delete_sec_context(&minStat, &gssContext, &sendBuffer);
+
+ if(majStat != GSS_S_COMPLETE) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ gss_release_buffer(&minStat, &sendBuffer);
+
+ setFinished();
+ }
+
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Common/Request/GSSAPIAuthRequest.h b/src/Common/Request/GSSAPIAuthRequest.h
index 6882f36..dd2afbb 100644
--- a/src/Common/Request/GSSAPIAuthRequest.h
+++ b/src/Common/Request/GSSAPIAuthRequest.h
@@ -21,19 +21,15 @@
#define MAD_COMMON_REQUEST_GSSAPIAUTHREQUEST_H_
#include "Request.h"
-#include "../RequestManager.h"
-#include <Net/Connection.h>
-#include <Net/Packet.h>
#include <string>
-#include <cstring>
#include <gssapi/gssapi.h>
-#include <iostream>
-
namespace Mad {
namespace Common {
-namespace Request {
+class RequestManager;
+
+namespace Request {
// TODO Logging & error handling!
@@ -48,147 +44,16 @@ class GSSAPIAuthRequest : public Request {
GSSAPIAuthRequest(const std::string &serviceName0) : serviceName(serviceName0), gssServiceName(GSS_C_NO_NAME), gssContext(GSS_C_NO_CONTEXT), gssContinue(true) {}
public:
- virtual ~GSSAPIAuthRequest() {
- OM_uint32 minStat;
-
- if(gssServiceName != GSS_C_NO_NAME)
- gss_release_name(&minStat, &gssServiceName);
- }
-
- static bool send(Net::Connection *connection, RequestManager &requestManager, const std::string &serviceName0) {
- GSSAPIAuthRequest *request = new GSSAPIAuthRequest(serviceName0);
-
- if(requestManager.sendRequest(connection, request))
- return true;
-
- delete request;
- return false;
- }
-
- virtual bool sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(isSent())
- return false;
-
- OM_uint32 majStat, minStat;
- gss_buffer_desc buffer;
-
- buffer.length = serviceName.length();
- buffer.value = std::malloc(buffer.length);
- std::memcpy(buffer.value, serviceName.c_str(), buffer.length);
-
- majStat = gss_import_name(&minStat, &buffer, GSS_C_NT_HOSTBASED_SERVICE, &gssServiceName);
-
- std::free(buffer.value);
-
- if(majStat != GSS_S_COMPLETE) {
- gssServiceName = GSS_C_NO_NAME;
- return false;
- }
-
- majStat = gss_init_sec_context(&minStat, GSS_C_NO_CREDENTIAL, &gssContext, gssServiceName, GSS_C_NO_OID, GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG,
- 0, GSS_C_NO_CHANNEL_BINDINGS, GSS_C_NO_BUFFER, 0, &buffer, 0, 0);
-
- if(majStat == GSS_S_COMPLETE) {
- std::cout << "GSS context established." << std::endl;
- gssContinue = false;
- }
- else if(majStat != GSS_S_CONTINUE_NEEDED) {
- gss_release_buffer(&minStat, &buffer);
- return false;
- }
-
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, requestId, buffer.value, buffer.length))) {
- gss_release_buffer(&minStat, &buffer);
- return false;
- }
-
- gss_release_buffer(&minStat, &buffer);
-
- setSent();
- return true;
- }
-
- virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
+ virtual ~GSSAPIAuthRequest();
- if(packet.getType() != Net::Packet::GSSAPI_AUTH)
- return false; // TODO Logging
+ static bool send(Net::Connection *connection, RequestManager &requestManager, const std::string &serviceName0);
- OM_uint32 majStat, minStat;
- gss_buffer_desc recvBuffer, sendBuffer;
-
- if(gssContinue) {
- recvBuffer.length = packet.getLength();
- recvBuffer.value = std::malloc(recvBuffer.length);
- std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
-
- majStat = gss_init_sec_context(&minStat, GSS_C_NO_CREDENTIAL, &gssContext, gssServiceName, GSS_C_NO_OID, GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | GSS_C_INTEG_FLAG,
- 0, GSS_C_NO_CHANNEL_BINDINGS, &recvBuffer, 0, &sendBuffer, 0, 0);
-
- std::free(recvBuffer.value);
-
- if(majStat == GSS_S_COMPLETE) {
- std::cout << "GSS context established." << std::endl;
- gssContinue = false;
- }
- else if(majStat != GSS_S_CONTINUE_NEEDED) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- gss_release_buffer(&minStat, &sendBuffer);
- }
- else {
- recvBuffer.length = packet.getLength();
- recvBuffer.value = std::malloc(recvBuffer.length);
- std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
-
- const gnutls_datum_t *cert = connection->getPeerCertificate();
-
- sendBuffer.length = cert->size;
- sendBuffer.value = cert->data;
-
- majStat = gss_verify_mic(&minStat, gssContext, &sendBuffer, &recvBuffer, 0);
-
- std::free(recvBuffer.value);
-
- if(majStat != GSS_S_COMPLETE)
- return false;
-
- connection->setAuthenticated();
- std::cout << "Authentication complete." << std::endl;
-
- majStat = gss_delete_sec_context(&minStat, &gssContext, &sendBuffer);
-
- if(majStat != GSS_S_COMPLETE) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- gss_release_buffer(&minStat, &sendBuffer);
-
- setFinished();
- }
-
- return true;
- }
+ virtual bool sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
}
-
}
-
}
#endif /* MAD_COMMON_REQUEST_GSSAPIAUTHREQUEST_H_ */
diff --git a/src/Common/Request/IdentifyRequest.cpp b/src/Common/Request/IdentifyRequest.cpp
new file mode 100644
index 0000000..5fe4227
--- /dev/null
+++ b/src/Common/Request/IdentifyRequest.cpp
@@ -0,0 +1,62 @@
+/*
+ * IdentifyRequest.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "IdentifyRequest.h"
+#include "../RequestManager.h"
+#include <Net/Packet.h>
+
+namespace Mad {
+namespace Common {
+namespace Request {
+
+bool IdentifyRequest::send(Net::Connection *connection, RequestManager &requestManager, const std::string &hostname0) {
+ IdentifyRequest *request = new IdentifyRequest(hostname0);
+
+ if(requestManager.sendRequest(connection, request))
+ return true;
+
+ delete request;
+ return false;
+}
+
+bool IdentifyRequest::sendRequest(Net::Connection *connection, uint16_t requestId) {
+ if(isSent())
+ return false;
+
+ if(!connection->send(Net::Packet(Net::Packet::IDENTIFY, requestId, hostname.c_str(), hostname.length())))
+ return false;
+
+ setSent();
+ return true;
+}
+
+bool IdentifyRequest::handlePacket(Net::Connection*, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::OK)
+ return false; // TODO Logging
+
+ setFinished();
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Common/Request/IdentifyRequest.h b/src/Common/Request/IdentifyRequest.h
index 2637e47..276da23 100644
--- a/src/Common/Request/IdentifyRequest.h
+++ b/src/Common/Request/IdentifyRequest.h
@@ -21,55 +21,26 @@
#define MAD_COMMON_REQUEST_IDENTIFYREQUEST_H_
#include "Request.h"
-#include "../RequestManager.h"
-#include <Net/Connection.h>
-#include <Net/Packet.h>
#include <string>
-#include <iostream>
-
namespace Mad {
namespace Common {
+
+class RequestManager;
+
namespace Request {
-class IdentifyRequest: public Request {
+class IdentifyRequest : public Request {
private:
IdentifyRequest(const std::string &hostname0) : hostname(hostname0) {}
std::string hostname;
public:
- static bool send(Net::Connection *connection, RequestManager &requestManager, const std::string &hostname0) {
- IdentifyRequest *request = new IdentifyRequest(hostname0);
-
- if(requestManager.sendRequest(connection, request))
- return true;
-
- delete request;
- return false;
- }
-
- virtual bool sendRequest(Net::Connection *connection, uint16_t requestId) {
- if(isSent())
- return false;
-
- if(!connection->send(Net::Packet(Net::Packet::IDENTIFY, requestId, hostname.c_str(), hostname.length())))
- return false;
-
- setSent();
- return true;
- }
-
- virtual bool handlePacket(Net::Connection*, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::OK)
- return false; // TODO Logging
+ static bool send(Net::Connection *connection, RequestManager &requestManager, const std::string &hostname0);
- setFinished();
- return true;
- }
+ virtual bool sendRequest(Net::Connection *connection, uint16_t requestId);
+ virtual bool handlePacket(Net::Connection*, const Net::Packet &packet);
};
}
diff --git a/src/Common/Request/Makefile.am b/src/Common/Request/Makefile.am
index 64c5078..ef75dfe 100644
--- a/src/Common/Request/Makefile.am
+++ b/src/Common/Request/Makefile.am
@@ -1 +1,4 @@
-noinst_HEADERS = DisconnectRequest.h GSSAPIAuthRequest.h IdentifyRequest.h Request.h
+noinst_LTLIBRARIES = librequest.la
+librequest_la_SOURCES = DisconnectRequest.cpp GSSAPIAuthRequest.cpp IdentifyRequest.cpp
+
+noinst_HEADERS = DisconnectRequest.h GSSAPIAuthRequest.h IdentifyRequest.h Request.h
diff --git a/src/Common/Request/Makefile.in b/src/Common/Request/Makefile.in
index 4aa720d..f44ec75 100644
--- a/src/Common/Request/Makefile.in
+++ b/src/Common/Request/Makefile.in
@@ -14,6 +14,7 @@
@SET_MAKE@
+
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -42,8 +43,25 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
-SOURCES =
-DIST_SOURCES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+librequest_la_LIBADD =
+am_librequest_la_OBJECTS = DisconnectRequest.lo GSSAPIAuthRequest.lo \
+ IdentifyRequest.lo
+librequest_la_OBJECTS = $(am_librequest_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(librequest_la_SOURCES)
+DIST_SOURCES = $(librequest_la_SOURCES)
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
@@ -164,10 +182,13 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = librequest.la
+librequest_la_SOURCES = DisconnectRequest.cpp GSSAPIAuthRequest.cpp IdentifyRequest.cpp
noinst_HEADERS = DisconnectRequest.h GSSAPIAuthRequest.h IdentifyRequest.h Request.h
all: all-am
.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -198,6 +219,48 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+librequest.la: $(librequest_la_OBJECTS) $(librequest_la_DEPENDENCIES)
+ $(CXXLINK) $(librequest_la_OBJECTS) $(librequest_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DisconnectRequest.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequest.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IdentifyRequest.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
mostlyclean-libtool:
-rm -f *.lo
@@ -279,7 +342,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(HEADERS)
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
install: install-am
install-exec: install-exec-am
@@ -307,11 +370,14 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libtool mostlyclean-am
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-tags
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
dvi: dvi-am
@@ -342,12 +408,14 @@ install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
-mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
pdf: pdf-am
@@ -362,17 +430,17 @@ uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool ctags distclean distclean-generic \
- distclean-libtool distclean-tags distdir dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-generic \
- mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
- uninstall-am
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/Common/Request/Request.h b/src/Common/Request/Request.h
index 5087992..c87d87d 100644
--- a/src/Common/Request/Request.h
+++ b/src/Common/Request/Request.h
@@ -21,6 +21,7 @@
#define MAD_COMMON_REQUEST_REQUEST_H_
#include "../RequestHandler/RequestHandler.h"
+#include <stdint.h>
namespace Mad {
namespace Common {
diff --git a/src/Common/RequestHandler/DisconnectRequestHandler.cpp b/src/Common/RequestHandler/DisconnectRequestHandler.cpp
new file mode 100644
index 0000000..af05457
--- /dev/null
+++ b/src/Common/RequestHandler/DisconnectRequestHandler.cpp
@@ -0,0 +1,46 @@
+/*
+ * DisconnectRequestHandler.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "DisconnectRequestHandler.h"
+#include <Net/Connection.h>
+
+namespace Mad {
+namespace Common {
+namespace RequestHandler {
+
+bool DisconnectRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::DISCONNECT)
+ return false; // TODO Logging
+
+ if(!connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId())))
+ return false;
+
+ connection->disconnect();
+
+ setFinished();
+
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Common/RequestHandler/DisconnectRequestHandler.h b/src/Common/RequestHandler/DisconnectRequestHandler.h
index 9da825a..90429c4 100644
--- a/src/Common/RequestHandler/DisconnectRequestHandler.h
+++ b/src/Common/RequestHandler/DisconnectRequestHandler.h
@@ -30,22 +30,7 @@ class DisconnectRequestHandler : public RequestHandler {
public:
DisconnectRequestHandler() {}
- virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::DISCONNECT)
- return false; // TODO Logging
-
- if(!connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId())))
- return false;
-
- connection->disconnect();
-
- setFinished();
-
- return true;
- }
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
}
diff --git a/src/Common/RequestHandler/IdentifyRequestHandler.cpp b/src/Common/RequestHandler/IdentifyRequestHandler.cpp
new file mode 100644
index 0000000..8a6ea40
--- /dev/null
+++ b/src/Common/RequestHandler/IdentifyRequestHandler.cpp
@@ -0,0 +1,47 @@
+/*
+ * IdentifyRequestHandler.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "IdentifyRequestHandler.h"
+#include <Net/Connection.h>
+
+namespace Mad {
+namespace Common {
+namespace RequestHandler {
+
+bool IdentifyRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::IDENTIFY)
+ return false; // TODO Logging
+
+ // TODO Require authentication
+ // TODO Save identity information
+
+ if(!connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId())))
+ return false;
+
+ setFinished();
+
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Common/RequestHandler/IdentifyRequestHandler.h b/src/Common/RequestHandler/IdentifyRequestHandler.h
index a8082c6..7ac2e3e 100644
--- a/src/Common/RequestHandler/IdentifyRequestHandler.h
+++ b/src/Common/RequestHandler/IdentifyRequestHandler.h
@@ -30,23 +30,7 @@ class IdentifyRequestHandler : public RequestHandler {
public:
IdentifyRequestHandler() {}
- virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::IDENTIFY)
- return false; // TODO Logging
-
- // TODO Require authentication
- // TODO Save identity information
-
- if(!connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId())))
- return false;
-
- setFinished();
-
- return true;
- }
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
}
diff --git a/src/Common/RequestHandler/Makefile.am b/src/Common/RequestHandler/Makefile.am
index 146c4cd..69e6c77 100644
--- a/src/Common/RequestHandler/Makefile.am
+++ b/src/Common/RequestHandler/Makefile.am
@@ -1,2 +1,5 @@
-noinst_HEADERS = DisconnectRequestHandler.h IdentifyRequestHandler.h RequestHandler.h
+noinst_LTLIBRARIES = librequesthandler.la
+librequesthandler_la_SOURCES = DisconnectRequestHandler.cpp IdentifyRequestHandler.cpp
+
+noinst_HEADERS = DisconnectRequestHandler.h IdentifyRequestHandler.h RequestHandler.h
diff --git a/src/Common/RequestHandler/Makefile.in b/src/Common/RequestHandler/Makefile.in
index 066da38..0140d46 100644
--- a/src/Common/RequestHandler/Makefile.in
+++ b/src/Common/RequestHandler/Makefile.in
@@ -14,6 +14,7 @@
@SET_MAKE@
+
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -42,8 +43,25 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
-SOURCES =
-DIST_SOURCES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+librequesthandler_la_LIBADD =
+am_librequesthandler_la_OBJECTS = DisconnectRequestHandler.lo \
+ IdentifyRequestHandler.lo
+librequesthandler_la_OBJECTS = $(am_librequesthandler_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(librequesthandler_la_SOURCES)
+DIST_SOURCES = $(librequesthandler_la_SOURCES)
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
@@ -164,10 +182,13 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = librequesthandler.la
+librequesthandler_la_SOURCES = DisconnectRequestHandler.cpp IdentifyRequestHandler.cpp
noinst_HEADERS = DisconnectRequestHandler.h IdentifyRequestHandler.h RequestHandler.h
all: all-am
.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -198,6 +219,47 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+librequesthandler.la: $(librequesthandler_la_OBJECTS) $(librequesthandler_la_DEPENDENCIES)
+ $(CXXLINK) $(librequesthandler_la_OBJECTS) $(librequesthandler_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DisconnectRequestHandler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IdentifyRequestHandler.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
mostlyclean-libtool:
-rm -f *.lo
@@ -279,7 +341,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(HEADERS)
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
install: install-am
install-exec: install-exec-am
@@ -307,11 +369,14 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libtool mostlyclean-am
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-tags
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
dvi: dvi-am
@@ -342,12 +407,14 @@ install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
-mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
pdf: pdf-am
@@ -362,17 +429,17 @@ uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool ctags distclean distclean-generic \
- distclean-libtool distclean-tags distdir dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-generic \
- mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
- uninstall-am
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index e71fd07..0dc7a48 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -27,11 +27,26 @@
namespace Mad {
namespace Common {
-RequestManager::RequestManager(bool core) : requestId(core ? -2 : -1) {
- registerPacketType<RequestHandler::DisconnectRequestHandler>(Net::Packet::DISCONNECT);
- registerPacketType<RequestHandler::IdentifyRequestHandler>(Net::Packet::IDENTIFY);
+RequestHandler::RequestHandler* RequestManager::RequestMap::findRequest(uint16_t id) {
+ iterator it = find(id);
+ if(it == end())
+ return 0;
+
+ return it->second;
+}
+
+bool RequestManager::RequestMap::deleteRequest(uint16_t id) {
+ iterator it = find(id);
+ if(it == end())
+ return false;
+
+ delete it->second;
+
+ erase(it);
+ return true;
}
+
void RequestManager::receiveHandler(Net::Connection *connection, const Net::Packet &packet) {
std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
@@ -92,5 +107,46 @@ bool RequestManager::sendRequest(Net::Connection *connection, Request::Request *
return true;
}
+void RequestManager::registerConnection(Net::Connection *connection) {
+ requestMaps.insert(std::make_pair(connection, new RequestMap()));
+
+ connection->signalReceive().connect(sigc::mem_fun(this, &RequestManager::receiveHandler));
+}
+
+void RequestManager::unregisterConnection(Net::Connection *connection) {
+ std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
+
+ if(it == requestMaps.end())
+ return;
+
+ delete it->second;
+
+ requestMaps.erase(it);
+}
+
+void RequestManager::unregisterPacketType(Net::Packet::Type type) {
+ std::map<Net::Packet::Type,RequestHandlerFactory*>::iterator it = requestHandlerFactories.find(type);
+
+ if(it == requestHandlerFactories.end())
+ return;
+
+ delete it->second;
+
+ requestHandlerFactories.erase(it);
+}
+
+RequestManager::RequestManager(bool core) : requestId(core ? -2 : -1) {
+ registerPacketType<RequestHandler::DisconnectRequestHandler>(Net::Packet::DISCONNECT);
+ registerPacketType<RequestHandler::IdentifyRequestHandler>(Net::Packet::IDENTIFY);
+}
+
+RequestManager::~RequestManager() {
+ for(std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it)
+ delete it->second;
+
+ for(std::map<Net::Packet::Type,RequestHandlerFactory*>::iterator it = requestHandlerFactories.begin(); it != requestHandlerFactories.end(); ++it)
+ delete it->second;
+}
+
}
}
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index 68510f9..e7a8e7b 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -41,7 +41,6 @@ class RequestManager {
public:
RequestMap() {}
-
~RequestMap() {
for(iterator it = begin(); it != end(); ++it)
delete it->second;
@@ -51,24 +50,8 @@ class RequestManager {
return insert(std::make_pair(id, info)).second;
}
- RequestHandler::RequestHandler* findRequest(uint16_t id) {
- iterator it = find(id);
- if(it == end())
- return 0;
-
- return it->second;
- }
-
- bool deleteRequest(uint16_t id) {
- iterator it = find(id);
- if(it == end())
- return false;
-
- delete it->second;
-
- erase(it);
- return true;
- }
+ RequestHandler::RequestHandler* findRequest(uint16_t id);
+ bool deleteRequest(uint16_t id);
};
class RequestHandlerFactory {
@@ -103,49 +86,19 @@ class RequestManager {
void receiveHandler(Net::Connection *connection, const Net::Packet &packet);
public:
- void registerConnection(Net::Connection *connection) {
- requestMaps.insert(std::make_pair(connection, new RequestMap()));
-
- connection->signalReceive().connect(sigc::mem_fun(this, &RequestManager::receiveHandler));
- }
-
- void unregisterConnection(Net::Connection *connection) {
- std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
-
- if(it == requestMaps.end())
- return;
-
- delete it->second;
-
- requestMaps.erase(it);
- }
+ void registerConnection(Net::Connection *connection);
+ void unregisterConnection(Net::Connection *connection);
template <class T> void registerPacketType(Net::Packet::Type type) {
requestHandlerFactories.insert(std::make_pair(type, new SpecificRequestHandlerFactory<T>()));
}
- void unregisterPacketType(Net::Packet::Type type) {
- std::map<Net::Packet::Type,RequestHandlerFactory*>::iterator it = requestHandlerFactories.find(type);
-
- if(it == requestHandlerFactories.end())
- return;
-
- delete it->second;
-
- requestHandlerFactories.erase(it);
- }
+ void unregisterPacketType(Net::Packet::Type type);
bool sendRequest(Net::Connection *connection, Request::Request *request);
RequestManager(bool core);
-
- virtual ~RequestManager() {
- for(std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it)
- delete it->second;
-
- for(std::map<Net::Packet::Type,RequestHandlerFactory*>::iterator it = requestHandlerFactories.begin(); it != requestHandlerFactories.end(); ++it)
- delete it->second;
- }
+ virtual ~RequestManager();
};
}
diff --git a/src/Common/Util.cpp b/src/Common/Util.cpp
new file mode 100644
index 0000000..2bf4d50
--- /dev/null
+++ b/src/Common/Util.cpp
@@ -0,0 +1,50 @@
+/*
+ * Util.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "Util.h"
+
+namespace Mad {
+namespace Common {
+
+std::string Util::tolower(const std::string &str) {
+ std::string ret;
+
+ for(std::string::const_iterator c = str.begin(); c != str.end(); ++c)
+ ret += std::tolower(*c);
+
+ return ret;
+}
+
+std::string Util::trim(const std::string &str) {
+ size_t beg, end;
+
+ beg = str.find_first_not_of(" \t");
+ end = str.find_last_not_of(" \t");
+
+ if(beg == std::string::npos)
+ beg = 0;
+
+ if(end != std::string::npos)
+ end = end-beg+1;
+
+ return str.substr(beg, end);
+}
+
+}
+}
diff --git a/src/Common/Util.h b/src/Common/Util.h
index 19f87b9..8df5cac 100644
--- a/src/Common/Util.h
+++ b/src/Common/Util.h
@@ -21,8 +21,6 @@
#define MAD_COMMON_UTIL_H_
#include <string>
-#include <locale>
-#include <vector>
namespace Mad {
namespace Common {
@@ -32,29 +30,8 @@ class Util {
Util();
public:
- static std::string tolower(const std::string &str) {
- std::string ret;
-
- for(std::string::const_iterator c = str.begin(); c != str.end(); ++c)
- ret += std::tolower(*c);
-
- return ret;
- }
-
- static std::string trim(const std::string &str) {
- size_t beg, end;
-
- beg = str.find_first_not_of(" \t");
- end = str.find_last_not_of(" \t");
-
- if(beg == std::string::npos)
- beg = 0;
-
- if(end != std::string::npos)
- end = end-beg+1;
-
- return str.substr(beg, end);
- }
+ static std::string tolower(const std::string &str);
+ static std::string trim(const std::string &str);
};
}
diff --git a/src/Core/Makefile.am b/src/Core/Makefile.am
index 929003a..3051814 100644
--- a/src/Core/Makefile.am
+++ b/src/Core/Makefile.am
@@ -3,5 +3,6 @@ SUBDIRS = RequestHandler
noinst_LTLIBRARIES = libcore.la
libcore_la_SOURCES = ConfigManager.cpp ConnectionManager.cpp
+libcore_la_LIBADD = RequestHandler/librequesthandler.la
noinst_HEADERS = ConfigManager.h ConnectionManager.h
diff --git a/src/Core/Makefile.in b/src/Core/Makefile.in
index 98a97e0..e274531 100644
--- a/src/Core/Makefile.in
+++ b/src/Core/Makefile.in
@@ -44,7 +44,7 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
-libcore_la_LIBADD =
+libcore_la_DEPENDENCIES = RequestHandler/librequesthandler.la
am_libcore_la_OBJECTS = ConfigManager.lo ConnectionManager.lo
libcore_la_OBJECTS = $(am_libcore_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
@@ -194,6 +194,7 @@ top_srcdir = @top_srcdir@
SUBDIRS = RequestHandler
noinst_LTLIBRARIES = libcore.la
libcore_la_SOURCES = ConfigManager.cpp ConnectionManager.cpp
+libcore_la_LIBADD = RequestHandler/librequesthandler.la
noinst_HEADERS = ConfigManager.h ConnectionManager.h
all: all-recursive
diff --git a/src/Core/RequestHandler/CoreStatusRequestHandler.cpp b/src/Core/RequestHandler/CoreStatusRequestHandler.cpp
new file mode 100644
index 0000000..9d923f5
--- /dev/null
+++ b/src/Core/RequestHandler/CoreStatusRequestHandler.cpp
@@ -0,0 +1,52 @@
+/*
+ * CoreStatusRequestHandler.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "CoreStatusRequestHandler.h"
+#include <Common/SystemBackend.h>
+#include <Net/Connection.h>
+#include <Net/Packets/HostStatusPacket.h>
+
+namespace Mad {
+namespace Core {
+namespace RequestHandler {
+
+bool CoreStatusRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::CORE_STATUS)
+ return false; // TODO Logging
+
+ // TODO Require authentication
+
+ Common::SystemBackend::UptimeInfo uptimeInfo = Common::SystemBackend::getBackend()->getUptimeInfo();
+ Common::SystemBackend::MemoryInfo memInfo = Common::SystemBackend::getBackend()->getMemoryInfo();
+
+ if(!connection->send(Net::Packets::HostStatusPacket(Net::Packet::OK, packet.getRequestId(), uptimeInfo.uptime, uptimeInfo.idleTime,
+ memInfo.totalMem, memInfo.freeMem, memInfo.totalSwap, memInfo.freeSwap)))
+ return false;
+
+ setFinished();
+
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Core/RequestHandler/CoreStatusRequestHandler.h b/src/Core/RequestHandler/CoreStatusRequestHandler.h
index acf941e..dc822cb 100644
--- a/src/Core/RequestHandler/CoreStatusRequestHandler.h
+++ b/src/Core/RequestHandler/CoreStatusRequestHandler.h
@@ -21,8 +21,6 @@
#define MAD_CORE_REQUESTHANDLER_CORESTATUSREQUESTHANDLER_H_
#include <Common/RequestHandler/RequestHandler.h>
-#include <Common/SystemBackend.h>
-#include <Net/Packets/HostStatusPacket.h>
namespace Mad {
namespace Core {
@@ -32,26 +30,7 @@ class CoreStatusRequestHandler : public Common::RequestHandler::RequestHandler {
public:
CoreStatusRequestHandler() {}
- virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::CORE_STATUS)
- return false; // TODO Logging
-
- // TODO Require authentication
-
- Common::SystemBackend::UptimeInfo uptimeInfo = Common::SystemBackend::getBackend()->getUptimeInfo();
- Common::SystemBackend::MemoryInfo memInfo = Common::SystemBackend::getBackend()->getMemoryInfo();
-
- if(!connection->send(Net::Packets::HostStatusPacket(Net::Packet::OK, packet.getRequestId(), uptimeInfo.uptime, uptimeInfo.idleTime,
- memInfo.totalMem, memInfo.freeMem, memInfo.totalSwap, memInfo.freeSwap)))
- return false;
-
- setFinished();
-
- return true;
- }
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
}
diff --git a/src/Core/RequestHandler/GSSAPIAuthRequestHandler.cpp b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.cpp
new file mode 100644
index 0000000..08c4751
--- /dev/null
+++ b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.cpp
@@ -0,0 +1,113 @@
+/*
+ * GSSAPIAuthRequestHandler.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "GSSAPIAuthRequestHandler.h"
+#include <Net/Connection.h>
+
+#include <cstring>
+
+#include <iostream>
+
+namespace Mad {
+namespace Core {
+namespace RequestHandler {
+
+// TODO Error handling
+
+bool GSSAPIAuthRequestHandler::handlePacket(Net::Connection *connection, const Net::Packet &packet) {
+ if(isFinished())
+ return false;
+
+ if(packet.getType() != Net::Packet::GSSAPI_AUTH)
+ return false; // TODO Logging
+
+ OM_uint32 majStat, minStat;
+ gss_buffer_desc recvBuffer, sendBuffer;
+
+ if(gssContinue) {
+ recvBuffer.length = packet.getLength();
+ recvBuffer.value = std::malloc(recvBuffer.length);
+ std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
+
+ majStat = gss_accept_sec_context(&minStat, &gssContext, GSS_C_NO_CREDENTIAL, &recvBuffer, GSS_C_NO_CHANNEL_BINDINGS, 0, 0, &sendBuffer, 0, 0, 0);
+
+ std::free(recvBuffer.value);
+
+ if(majStat == GSS_S_COMPLETE) {
+ std::cout << "GSS context established." << std::endl;
+ gssContinue = false;
+ }
+ else if(majStat != GSS_S_CONTINUE_NEEDED) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ gss_release_buffer(&minStat, &sendBuffer);
+ }
+ else if(!sentSignature) {
+ if(packet.getLength() != 0)
+ return false;
+
+ const gnutls_datum_t *cert = connection->getCertificate();
+
+ recvBuffer.length = cert->size;
+ recvBuffer.value = cert->data;
+
+ majStat = gss_get_mic(&minStat, gssContext, GSS_C_QOP_DEFAULT, &recvBuffer, &sendBuffer);
+
+ if(majStat != GSS_S_COMPLETE) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
+ gss_release_buffer(&minStat, &sendBuffer);
+ return false;
+ }
+
+ gss_release_buffer(&minStat, &sendBuffer);
+
+ sentSignature = true;
+ }
+ else {
+ recvBuffer.length = packet.getLength();
+ recvBuffer.value = std::malloc(recvBuffer.length);
+ std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
+
+ majStat = gss_process_context_token(&minStat, gssContext, &recvBuffer);
+
+ std::free(recvBuffer.value);
+
+ if(majStat != GSS_S_COMPLETE)
+ return false;
+
+ setFinished();
+ }
+
+ return true;
+}
+
+}
+}
+}
diff --git a/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h
index c04857b..590919f 100644
--- a/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h
+++ b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h
@@ -21,18 +21,12 @@
#define MAD_CORE_REQUESTHANDLER_GSSAPIAUTHREQUESTHANDLER_H_
#include <Common/RequestHandler/RequestHandler.h>
-#include <Net/Packet.h>
-#include <cstring>
#include <gssapi/gssapi.h>
-#include <iostream>
-
namespace Mad {
namespace Core {
namespace RequestHandler {
-// TODO Error handling
-
class GSSAPIAuthRequestHandler : public Common::RequestHandler::RequestHandler {
private:
gss_ctx_id_t gssContext;
@@ -42,83 +36,7 @@ class GSSAPIAuthRequestHandler : public Common::RequestHandler::RequestHandler {
public:
GSSAPIAuthRequestHandler() : gssContext(GSS_C_NO_CONTEXT), gssContinue(true), sentSignature(false) {}
- virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet) {
- if(isFinished())
- return false;
-
- if(packet.getType() != Net::Packet::GSSAPI_AUTH)
- return false; // TODO Logging
-
- OM_uint32 majStat, minStat;
- gss_buffer_desc recvBuffer, sendBuffer;
-
- if(gssContinue) {
- recvBuffer.length = packet.getLength();
- recvBuffer.value = std::malloc(recvBuffer.length);
- std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
-
- majStat = gss_accept_sec_context(&minStat, &gssContext, GSS_C_NO_CREDENTIAL, &recvBuffer, GSS_C_NO_CHANNEL_BINDINGS, 0, 0, &sendBuffer, 0, 0, 0);
-
- std::free(recvBuffer.value);
-
- if(majStat == GSS_S_COMPLETE) {
- std::cout << "GSS context established." << std::endl;
- gssContinue = false;
- }
- else if(majStat != GSS_S_CONTINUE_NEEDED) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- gss_release_buffer(&minStat, &sendBuffer);
- }
- else if(!sentSignature) {
- if(packet.getLength() != 0)
- return false;
-
- const gnutls_datum_t *cert = connection->getCertificate();
-
- recvBuffer.length = cert->size;
- recvBuffer.value = cert->data;
-
- majStat = gss_get_mic(&minStat, gssContext, GSS_C_QOP_DEFAULT, &recvBuffer, &sendBuffer);
-
- if(majStat != GSS_S_COMPLETE) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, packet.getRequestId(), sendBuffer.value, sendBuffer.length))) {
- gss_release_buffer(&minStat, &sendBuffer);
- return false;
- }
-
- gss_release_buffer(&minStat, &sendBuffer);
-
- sentSignature = true;
- }
- else {
- recvBuffer.length = packet.getLength();
- recvBuffer.value = std::malloc(recvBuffer.length);
- std::memcpy(recvBuffer.value, packet.getData(), recvBuffer.length);
-
- majStat = gss_process_context_token(&minStat, gssContext, &recvBuffer);
-
- std::free(recvBuffer.value);
-
- if(majStat != GSS_S_COMPLETE)
- return false;
-
- setFinished();
- }
-
- return true;
- }
+ virtual bool handlePacket(Net::Connection *connection, const Net::Packet &packet);
};
}
diff --git a/src/Core/RequestHandler/Makefile.am b/src/Core/RequestHandler/Makefile.am
index c0abc5c..3754a22 100644
--- a/src/Core/RequestHandler/Makefile.am
+++ b/src/Core/RequestHandler/Makefile.am
@@ -1 +1,4 @@
-noinst_HEADERS = CoreStatusRequestHandler.h GSSAPIAuthRequestHandler.h
+noinst_LTLIBRARIES = librequesthandler.la
+librequesthandler_la_SOURCES = CoreStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp
+
+noinst_HEADERS = CoreStatusRequestHandler.h GSSAPIAuthRequestHandler.h
diff --git a/src/Core/RequestHandler/Makefile.in b/src/Core/RequestHandler/Makefile.in
index 2d1cbee..8b20b23 100644
--- a/src/Core/RequestHandler/Makefile.in
+++ b/src/Core/RequestHandler/Makefile.in
@@ -14,6 +14,7 @@
@SET_MAKE@
+
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -42,8 +43,25 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
-SOURCES =
-DIST_SOURCES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+librequesthandler_la_LIBADD =
+am_librequesthandler_la_OBJECTS = CoreStatusRequestHandler.lo \
+ GSSAPIAuthRequestHandler.lo
+librequesthandler_la_OBJECTS = $(am_librequesthandler_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(librequesthandler_la_SOURCES)
+DIST_SOURCES = $(librequesthandler_la_SOURCES)
HEADERS = $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
@@ -164,10 +182,13 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = librequesthandler.la
+librequesthandler_la_SOURCES = CoreStatusRequestHandler.cpp GSSAPIAuthRequestHandler.cpp
noinst_HEADERS = CoreStatusRequestHandler.h GSSAPIAuthRequestHandler.h
all: all-am
.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@@ -198,6 +219,47 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+librequesthandler.la: $(librequesthandler_la_OBJECTS) $(librequesthandler_la_DEPENDENCIES)
+ $(CXXLINK) $(librequesthandler_la_OBJECTS) $(librequesthandler_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoreStatusRequestHandler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSSAPIAuthRequestHandler.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
mostlyclean-libtool:
-rm -f *.lo
@@ -279,7 +341,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(HEADERS)
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
install: install-am
install-exec: install-exec-am
@@ -307,11 +369,14 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libtool mostlyclean-am
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-tags
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
dvi: dvi-am
@@ -342,12 +407,14 @@ install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
-mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
pdf: pdf-am
@@ -362,17 +429,17 @@ uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool ctags distclean distclean-generic \
- distclean-libtool distclean-tags distdir dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-generic \
- mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
- uninstall-am
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am
index c178507..355fa65 100644
--- a/src/Daemon/Makefile.am
+++ b/src/Daemon/Makefile.am
@@ -1 +1,8 @@
SUBDIRS = RequestHandler
+
+noinst_LTLIBRARIES = libdaemon.la
+
+libdaemon_la_SOURCES =
+libdaemon_la_LIBADD = RequestHandler/librequesthandler.la
+
+noinst_HEADERS =
diff --git a/src/Daemon/Makefile.in b/src/Daemon/Makefile.in
index 2252496..6f7efcf 100644
--- a/src/Daemon/Makefile.in
+++ b/src/Daemon/Makefile.in
@@ -13,6 +13,8 @@
# PARTICULAR PURPOSE.
@SET_MAKE@
+
+
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -32,7 +34,8 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = src/Daemon
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -40,8 +43,22 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
-SOURCES =
-DIST_SOURCES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libdaemon_la_DEPENDENCIES = RequestHandler/librequesthandler.la
+am_libdaemon_la_OBJECTS =
+libdaemon_la_OBJECTS = $(am_libdaemon_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libdaemon_la_SOURCES)
+DIST_SOURCES = $(libdaemon_la_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
@@ -49,6 +66,7 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
+HEADERS = $(noinst_HEADERS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
ETAGS = etags
@@ -172,6 +190,10 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = RequestHandler
+noinst_LTLIBRARIES = libdaemon.la
+libdaemon_la_SOURCES =
+libdaemon_la_LIBADD = RequestHandler/librequesthandler.la
+noinst_HEADERS =
all: all-recursive
.SUFFIXES:
@@ -205,6 +227,23 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libdaemon.la: $(libdaemon_la_OBJECTS) $(libdaemon_la_DEPENDENCIES)
+ $(LINK) $(libdaemon_la_OBJECTS) $(libdaemon_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
mostlyclean-libtool:
-rm -f *.lo
@@ -386,7 +425,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-recursive
-all-am: Makefile
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
@@ -415,11 +454,13 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
-clean-am: clean-generic clean-libtool mostlyclean-am
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-tags
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
dvi: dvi-recursive
@@ -455,7 +496,8 @@ maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
-mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
pdf: pdf-recursive
@@ -472,15 +514,16 @@ uninstall-am:
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am check check-am clean clean-generic clean-libtool \
- ctags ctags-recursive distclean distclean-generic \
- distclean-libtool distclean-tags distdir dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs installdirs-am maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-generic \
+ clean-noinstLTLIBRARIES ctags ctags-recursive distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ installdirs-am maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am
diff --git a/src/Daemon/RequestHandler/Makefile.am b/src/Daemon/RequestHandler/Makefile.am
index 33bc72a..7e1c298 100644
--- a/src/Daemon/RequestHandler/Makefile.am
+++ b/src/Daemon/RequestHandler/Makefile.am
@@ -1 +1,4 @@
-noinst_HEADERS =
+noinst_LTLIBRARIES = librequesthandler.la
+librequesthandler_la_SOURCES =
+
+noinst_HEADERS =
diff --git a/src/Daemon/RequestHandler/Makefile.in b/src/Daemon/RequestHandler/Makefile.in
index 0028faf..814f907 100644
--- a/src/Daemon/RequestHandler/Makefile.in
+++ b/src/Daemon/RequestHandler/Makefile.in
@@ -14,6 +14,7 @@
@SET_MAKE@
+
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -42,8 +43,22 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
-SOURCES =
-DIST_SOURCES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+librequesthandler_la_LIBADD =
+am_librequesthandler_la_OBJECTS =
+librequesthandler_la_OBJECTS = $(am_librequesthandler_la_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(librequesthandler_la_SOURCES)
+DIST_SOURCES = $(librequesthandler_la_SOURCES)
HEADERS = $(noinst_HEADERS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@@ -162,6 +177,8 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+noinst_LTLIBRARIES = librequesthandler.la
+librequesthandler_la_SOURCES =
noinst_HEADERS =
all: all-am
@@ -196,6 +213,23 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+librequesthandler.la: $(librequesthandler_la_OBJECTS) $(librequesthandler_la_DEPENDENCIES)
+ $(LINK) $(librequesthandler_la_OBJECTS) $(librequesthandler_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
mostlyclean-libtool:
-rm -f *.lo
@@ -236,7 +270,7 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(HEADERS)
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
installdirs:
install: install-am
install-exec: install-exec-am
@@ -264,11 +298,12 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libtool mostlyclean-am
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
distclean: distclean-am
-rm -f Makefile
-distclean-am: clean-am distclean-generic
+distclean-am: clean-am distclean-compile distclean-generic
dvi: dvi-am
@@ -304,7 +339,8 @@ maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
-mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
pdf: pdf-am
@@ -319,15 +355,17 @@ uninstall-am:
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
- distclean distclean-generic distclean-libtool distdir dvi \
- dvi-am html html-am info info-am install install-am \
- install-data install-data-am install-dvi install-dvi-am \
- install-exec install-exec-am install-html install-html-am \
- install-info install-info-am install-man install-pdf \
- install-pdf-am install-ps install-ps-am install-strip \
- installcheck installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-generic \
- mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
+ clean-noinstLTLIBRARIES distclean distclean-compile \
+ distclean-generic distclean-libtool distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/Makefile.am b/src/Makefile.am
index 7d44176..95e8d37 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,9 @@
-SUBDIRS = Common Client Core Net
+SUBDIRS = Common Client Core Daemon Net
bin_PROGRAMS = mad madc mad-core
mad_SOURCES = mad.cpp
-mad_LDADD = Net/libnet.la Common/libcommon.la
+mad_LDADD = Daemon/libdaemon.la Net/libnet.la Common/libcommon.la
madc_SOURCES = madc.cpp
madc_LDADD = Client/libclient.la Net/libnet.la Common/libcommon.la
diff --git a/src/Makefile.in b/src/Makefile.in
index f5314e5..80eb776 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -48,7 +48,8 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_mad_OBJECTS = mad.$(OBJEXT)
mad_OBJECTS = $(am_mad_OBJECTS)
-mad_DEPENDENCIES = Net/libnet.la Common/libcommon.la
+mad_DEPENDENCIES = Daemon/libdaemon.la Net/libnet.la \
+ Common/libcommon.la
am_mad_core_OBJECTS = mad-core.$(OBJEXT)
mad_core_OBJECTS = $(am_mad_core_OBJECTS)
mad_core_DEPENDENCIES = Core/libcore.la Net/libnet.la \
@@ -200,9 +201,9 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = Common Client Core Net
+SUBDIRS = Common Client Core Daemon Net
mad_SOURCES = mad.cpp
-mad_LDADD = Net/libnet.la Common/libcommon.la
+mad_LDADD = Daemon/libdaemon.la Net/libnet.la Common/libcommon.la
madc_SOURCES = madc.cpp
madc_LDADD = Client/libclient.la Net/libnet.la Common/libcommon.la
mad_core_SOURCES = mad-core.cpp
diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp
index 22adeaf..da1ff3f 100644
--- a/src/Net/Connection.cpp
+++ b/src/Net/Connection.cpp
@@ -22,11 +22,42 @@
#include <cstring>
#include <sys/socket.h>
-#include <iostream>
-
namespace Mad {
namespace Net {
+Connection::~Connection() {
+ if(isConnected())
+ doDisconnect();
+
+ if(transR.data)
+ delete [] transR.data;
+
+ while(!sendQueueEmpty()) {
+ delete [] transS.front().data;
+ transS.pop();
+ }
+
+ gnutls_certificate_free_credentials(x509_cred);
+}
+
+void Connection::handshake() {
+ if(isConnected())
+ return;
+
+ state = HANDSHAKE;
+
+ doHandshake();
+}
+
+void Connection::bye() {
+ if(state != DISCONNECT)
+ return;
+
+ state = BYE;
+
+ doBye();
+}
+
void Connection::doHandshake() {
if(state != HANDSHAKE)
return;
@@ -36,8 +67,6 @@ void Connection::doHandshake() {
if(ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN)
return;
- std::cerr << "Handshake error: " << gnutls_strerror(ret) << std::endl;
-
// TODO: Error
doDisconnect();
return;
@@ -64,6 +93,15 @@ void Connection::doBye() {
doDisconnect();
}
+bool Connection::enterReceiveLoop() {
+ if(!isConnected() || isDisconnecting())
+ return false;
+
+ state = PACKET_HEADER;
+
+ return rawReceive(sizeof(Packet::Data), sigc::mem_fun(this, &Connection::packetHeaderReceiveHandler));
+}
+
void Connection::packetHeaderReceiveHandler(const void *data, unsigned long length) {
if(state != PACKET_HEADER)
return;
@@ -213,6 +251,22 @@ void Connection::sendReceive(short events) {
bye();
}
+bool Connection::send(const Packet &packet) {
+ if(!isConnected() || isConnecting() || isDisconnecting())
+ return false;
+
+ return rawSend((const uint8_t*)packet.getRawData(), packet.getRawDataLength());
+}
+
+void Connection::disconnect() {
+ if(isConnected() && !isDisconnecting()) {
+ state = DISCONNECT;
+
+ if(sendQueueEmpty())
+ bye();
+ }
+}
+
void Connection::doDisconnect() {
if(!isConnected())
return;
diff --git a/src/Net/Connection.h b/src/Net/Connection.h
index 0f012f1..58e7291 100644
--- a/src/Net/Connection.h
+++ b/src/Net/Connection.h
@@ -72,14 +72,7 @@ class Connection {
return (transR.length == transR.transmitted);
}
- void bye() {
- if(state != DISCONNECT)
- return;
-
- state = BYE;
-
- doBye();
- }
+ void bye();
// Prevent shallow copy
Connection(const Connection &o);
@@ -104,28 +97,14 @@ class Connection {
IPAddress *peer;
- void handshake() {
- if(isConnected())
- return;
-
- state = HANDSHAKE;
-
- doHandshake();
- }
+ void handshake();
virtual void connectionHeader() = 0;
bool rawReceive(unsigned long length, const sigc::slot<void,const void*,unsigned long> &notify);
bool rawSend(const uint8_t *data, unsigned long length);
- bool enterReceiveLoop() {
- if(!isConnected() || isDisconnecting())
- return false;
-
- state = PACKET_HEADER;
-
- return rawReceive(sizeof(Packet::Data), sigc::mem_fun(this, &Connection::packetHeaderReceiveHandler));
- }
+ bool enterReceiveLoop();
public:
Connection() : state(DISCONNECTED), authenticated(false), peer(0) {
@@ -135,20 +114,7 @@ class Connection {
gnutls_certificate_allocate_credentials(&x509_cred);
}
- virtual ~Connection() {
- if(isConnected())
- doDisconnect();
-
- if(transR.data)
- delete [] transR.data;
-
- while(!sendQueueEmpty()) {
- delete [] transS.front().data;
- transS.pop();
- }
-
- gnutls_certificate_free_credentials(x509_cred);
- }
+ virtual ~Connection();
bool isConnected() const {return (state != DISCONNECTED);}
bool isConnecting() const {
@@ -174,23 +140,11 @@ class Connection {
const IPAddress* getPeer() {return peer;}
int getSocket() const {return sock;}
- void disconnect() {
- if(isConnected() && !isDisconnecting()) {
- state = DISCONNECT;
-
- if(sendQueueEmpty())
- bye();
- }
- }
+ void disconnect();
struct pollfd getPollfd() const;
- bool send(const Packet &packet) {
- if(!isConnected() || isConnecting() || isDisconnecting())
- return false;
-
- return rawSend((const uint8_t*)packet.getRawData(), packet.getRawDataLength());
- }
+ bool send(const Packet &packet);
void sendReceive(short events = POLLIN|POLLOUT);
diff --git a/src/Net/IPAddress.cpp b/src/Net/IPAddress.cpp
new file mode 100644
index 0000000..9c9793e
--- /dev/null
+++ b/src/Net/IPAddress.cpp
@@ -0,0 +1,92 @@
+/*
+ * IPAddress.cpp
+ *
+ * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "IPAddress.h"
+
+#include <cstdlib>
+
+namespace Mad {
+namespace Net {
+
+IPAddress::IPAddress(uint16_t port0) : addr(INADDR_ANY), port(port0) {
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(port);
+ sa.sin_addr.s_addr = INADDR_ANY;
+}
+
+IPAddress::IPAddress(uint32_t address, uint16_t port0) : addr(address), port(port0) {
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(port);
+ sa.sin_addr.s_addr = htonl(addr);
+}
+
+IPAddress::IPAddress(const std::string &address) throw(InvalidAddressException) {
+ std::string ip;
+ size_t pos = address.find_first_of(':');
+
+ if(pos == std::string::npos) {
+ ip = address;
+ // TODO Default port
+ port = 6666;
+ }
+ else {
+ ip = address.substr(0, pos);
+
+ char *endptr;
+ port = std::strtol(address.substr(pos+1).c_str(), &endptr, 10);
+ if(*endptr != 0 || port == 0)
+ throw InvalidAddressException(address);
+ }
+
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(port);
+
+ if(ip == "*")
+ sa.sin_addr.s_addr = INADDR_ANY;
+ else if(!inet_pton(AF_INET, ip.c_str(), &sa.sin_addr))
+ throw InvalidAddressException(address);
+
+ addr = ntohl(sa.sin_addr.s_addr);
+}
+
+IPAddress::IPAddress(const std::string &address, uint16_t port0) throw(InvalidAddressException) : port(port0) {
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(port);
+
+ if(!inet_pton(AF_INET, address.c_str(), &sa.sin_addr))
+ throw InvalidAddressException(address);
+
+ addr = ntohl(sa.sin_addr.s_addr);
+}
+
+IPAddress::IPAddress(const struct sockaddr_in &address) : sa(address) {
+ port = ntohs(sa.sin_port);
+ addr = ntohl(sa.sin_addr.s_addr);
+}
+
+std::string IPAddress::getAddressString() const {
+ char buf[INET_ADDRSTRLEN];
+ uint32_t address = htonl(addr);
+
+ inet_ntop(AF_INET, &address, buf, sizeof(buf));
+ return std::string(buf);
+}
+
+}
+}
diff --git a/src/Net/IPAddress.h b/src/Net/IPAddress.h
index 78b41dd..1d6140f 100644
--- a/src/Net/IPAddress.h
+++ b/src/Net/IPAddress.h
@@ -20,10 +20,11 @@
#ifndef MAD_NET_IPADDRESS_H_
#define MAD_NET_IPADDRESS_H_
+#include "InvalidAddressException.h"
+
#include <string>
-#include <cstdlib>
#include <arpa/inet.h>
-#include "InvalidAddressException.h"
+#include <stdint.h>
namespace Mad {
namespace Net {
@@ -36,72 +37,16 @@ class IPAddress {
public:
// TODO Default port
- IPAddress(uint16_t port0 = 6666) : addr(INADDR_ANY), port(port0) {
- sa.sin_family = AF_INET;
- sa.sin_port = htons(port);
- sa.sin_addr.s_addr = INADDR_ANY;
- }
-
- IPAddress(uint32_t address, uint16_t port0) : addr(address), port(port0) {
- sa.sin_family = AF_INET;
- sa.sin_port = htons(port);
- sa.sin_addr.s_addr = htonl(addr);
- }
-
- IPAddress(const std::string &address) throw(InvalidAddressException) {
- std::string ip;
- size_t pos = address.find_first_of(':');
-
- if(pos == std::string::npos) {
- ip = address;
- // TODO Default port
- port = 6666;
- }
- else {
- ip = address.substr(0, pos);
-
- char *endptr;
- port = std::strtol(address.substr(pos+1).c_str(), &endptr, 10);
- if(*endptr != 0 || port == 0)
- throw InvalidAddressException(address);
- }
-
- sa.sin_family = AF_INET;
- sa.sin_port = htons(port);
-
- if(ip == "*")
- sa.sin_addr.s_addr = INADDR_ANY;
- else if(!inet_pton(AF_INET, ip.c_str(), &sa.sin_addr))
- throw InvalidAddressException(address);
-
- addr = ntohl(sa.sin_addr.s_addr);
- }
-
- IPAddress(const std::string &address, uint16_t port0) throw(InvalidAddressException) : port(port0) {
- sa.sin_family = AF_INET;
- sa.sin_port = htons(port);
-
- if(!inet_pton(AF_INET, address.c_str(), &sa.sin_addr))
- throw InvalidAddressException(address);
-
- addr = ntohl(sa.sin_addr.s_addr);
- }
-
- IPAddress(const struct sockaddr_in &address) : sa(address) {
- port = ntohs(sa.sin_port);
- addr = ntohl(sa.sin_addr.s_addr);
- }
+ IPAddress(uint16_t port0 = 6666);
+ IPAddress(uint32_t address, uint16_t port0);
+ IPAddress(const std::string &address) throw(InvalidAddressException);
+ IPAddress(const std::string &address, uint16_t port0) throw(InvalidAddressException);
+ IPAddress(const struct sockaddr_in &address);
uint32_t getAddress() const {return addr;}
uint16_t getPort() const {return port;}
- std::string getAddressString() const {
- char buf[INET_ADDRSTRLEN];
- uint32_t address = htonl(addr);
-
- inet_ntop(AF_INET, &address, buf, sizeof(buf));
- return std::string(buf);
- }
+ std::string getAddressString() const;
struct sockaddr* getSockAddr() {return (struct sockaddr*)&sa;}
socklen_t getSockAddrLength() const {return sizeof(sa);}
diff --git a/src/Net/Makefile.am b/src/Net/Makefile.am
index 2fd4f12..967e989 100644
--- a/src/Net/Makefile.am
+++ b/src/Net/Makefile.am
@@ -1,7 +1,7 @@
SUBDIRS = Packets
noinst_LTLIBRARIES = libnet.la
-libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp Packet.cpp
+libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp IPAddress.cpp Listener.cpp Packet.cpp
libnet_la_LIBADD = Packets/libpackets.la
noinst_HEADERS = ClientConnection.h ServerConnection.h Connection.h Exception.h ConnectionException.h \
diff --git a/src/Net/Makefile.in b/src/Net/Makefile.in
index 3d9f7bf..163ca89 100644
--- a/src/Net/Makefile.in
+++ b/src/Net/Makefile.in
@@ -46,7 +46,7 @@ CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libnet_la_DEPENDENCIES = Packets/libpackets.la
am_libnet_la_OBJECTS = ClientConnection.lo ServerConnection.lo \
- Connection.lo Listener.lo Packet.lo
+ Connection.lo IPAddress.lo Listener.lo Packet.lo
libnet_la_OBJECTS = $(am_libnet_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -194,7 +194,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = Packets
noinst_LTLIBRARIES = libnet.la
-libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp Listener.cpp Packet.cpp
+libnet_la_SOURCES = ClientConnection.cpp ServerConnection.cpp Connection.cpp IPAddress.cpp Listener.cpp Packet.cpp
libnet_la_LIBADD = Packets/libpackets.la
noinst_HEADERS = ClientConnection.h ServerConnection.h Connection.h Exception.h ConnectionException.h \
InvalidAddressException.h IPAddress.h Listener.h Packet.h
@@ -252,6 +252,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClientConnection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Connection.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IPAddress.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Listener.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Packet.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ServerConnection.Plo@am__quote@