summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure3
-rw-r--r--configure.ac1
-rw-r--r--src/Common/Makefile.am4
-rw-r--r--src/Common/Makefile.in4
-rw-r--r--src/Common/Request/IdentifyRequest.h4
-rw-r--r--src/Common/Request/Request.h4
-rw-r--r--src/Common/RequestHandler/DisconnectRequestHandler.h55
-rw-r--r--src/Common/RequestHandler/IdentifyRequestHandler.h56
-rw-r--r--src/Common/RequestHandler/Makefile.am2
-rw-r--r--src/Common/RequestHandler/Makefile.in379
-rw-r--r--src/Common/RequestHandler/RequestHandler.h (renamed from src/Common/RequestHandler.h)8
-rw-r--r--src/Common/RequestManager.cpp23
-rw-r--r--src/Common/RequestManager.h14
-rw-r--r--src/Core/RequestHandler/CoreStatusRequestHandler.h9
-rw-r--r--src/Core/RequestHandler/GSSAPIAuthRequestHandler.h4
-rw-r--r--src/mad.cpp6
16 files changed, 533 insertions, 43 deletions
diff --git a/configure b/configure
index 3f70db6..b239d50 100755
--- a/configure
+++ b/configure
@@ -22089,7 +22089,7 @@ done
-ac_config_files="$ac_config_files Makefile src/Makefile src/Client/Makefile src/Client/Request/Makefile src/Common/Makefile src/Common/Backends/Makefile src/Common/Request/Makefile src/Core/Makefile src/Core/RequestHandler/Makefile src/Daemon/Makefile src/Daemon/RequestHandler/Makefile src/Net/Makefile src/Net/Packets/Makefile"
+ac_config_files="$ac_config_files Makefile src/Makefile src/Client/Makefile src/Client/Request/Makefile src/Common/Makefile src/Common/Backends/Makefile src/Common/Request/Makefile src/Common/RequestHandler/Makefile src/Core/Makefile src/Core/RequestHandler/Makefile src/Daemon/Makefile src/Daemon/RequestHandler/Makefile src/Net/Makefile src/Net/Packets/Makefile"
cat >confcache <<\_ACEOF
@@ -22692,6 +22692,7 @@ do
"src/Common/Makefile") CONFIG_FILES="$CONFIG_FILES src/Common/Makefile" ;;
"src/Common/Backends/Makefile") CONFIG_FILES="$CONFIG_FILES src/Common/Backends/Makefile" ;;
"src/Common/Request/Makefile") CONFIG_FILES="$CONFIG_FILES src/Common/Request/Makefile" ;;
+ "src/Common/RequestHandler/Makefile") CONFIG_FILES="$CONFIG_FILES src/Common/RequestHandler/Makefile" ;;
"src/Core/Makefile") CONFIG_FILES="$CONFIG_FILES src/Core/Makefile" ;;
"src/Core/RequestHandler/Makefile") CONFIG_FILES="$CONFIG_FILES src/Core/RequestHandler/Makefile" ;;
"src/Daemon/Makefile") CONFIG_FILES="$CONFIG_FILES src/Daemon/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 1827a70..5771ed9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,7 @@ AC_CONFIG_FILES([
src/Common/Makefile
src/Common/Backends/Makefile
src/Common/Request/Makefile
+ src/Common/RequestHandler/Makefile
src/Core/Makefile
src/Core/RequestHandler/Makefile
src/Daemon/Makefile
diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am
index cd1b8c0..6df8a62 100644
--- a/src/Common/Makefile.am
+++ b/src/Common/Makefile.am
@@ -1,7 +1,7 @@
-SUBDIRS = Backends Request
+SUBDIRS = Backends Request RequestHandler
noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = ConfigManager.cpp RequestManager.cpp SystemBackend.cpp
libcommon_la_LIBADD = Backends/libbackends.la
-noinst_HEADERS = ConfigManager.h RequestHandler.h RequestManager.h SystemBackend.h Util.h
+noinst_HEADERS = ConfigManager.h RequestManager.h SystemBackend.h Util.h
diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in
index 95a5c35..d2e1f59 100644
--- a/src/Common/Makefile.in
+++ b/src/Common/Makefile.in
@@ -192,11 +192,11 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = Backends Request
+SUBDIRS = Backends Request RequestHandler
noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = ConfigManager.cpp RequestManager.cpp SystemBackend.cpp
libcommon_la_LIBADD = Backends/libbackends.la
-noinst_HEADERS = ConfigManager.h RequestHandler.h RequestManager.h SystemBackend.h Util.h
+noinst_HEADERS = ConfigManager.h RequestManager.h SystemBackend.h Util.h
all: all-recursive
.SUFFIXES:
diff --git a/src/Common/Request/IdentifyRequest.h b/src/Common/Request/IdentifyRequest.h
index e7b9d21..2637e47 100644
--- a/src/Common/Request/IdentifyRequest.h
+++ b/src/Common/Request/IdentifyRequest.h
@@ -64,11 +64,9 @@ class IdentifyRequest: public Request {
if(isFinished())
return false;
- if(packet.getType() != Net::Packet::IDENTIFY)
+ if(packet.getType() != Net::Packet::OK)
return false; // TODO Logging
- std::cout << "Identified as '" << hostname << "'." << std::endl;
-
setFinished();
return true;
}
diff --git a/src/Common/Request/Request.h b/src/Common/Request/Request.h
index 657a0a7..5087992 100644
--- a/src/Common/Request/Request.h
+++ b/src/Common/Request/Request.h
@@ -20,13 +20,13 @@
#ifndef MAD_COMMON_REQUEST_REQUEST_H_
#define MAD_COMMON_REQUEST_REQUEST_H_
-#include "../RequestHandler.h"
+#include "../RequestHandler/RequestHandler.h"
namespace Mad {
namespace Common {
namespace Request {
-class Request : public RequestHandler {
+class Request : public RequestHandler::RequestHandler {
private:
bool sent;
diff --git a/src/Common/RequestHandler/DisconnectRequestHandler.h b/src/Common/RequestHandler/DisconnectRequestHandler.h
new file mode 100644
index 0000000..9da825a
--- /dev/null
+++ b/src/Common/RequestHandler/DisconnectRequestHandler.h
@@ -0,0 +1,55 @@
+/*
+ * DisconnectRequestHandler.h
+ *
+ * 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/>.
+ */
+
+#ifndef MAD_COMMON_REQUESTHANDLER_DISCONNECTREQUESTHANDLER_H_
+#define MAD_COMMON_REQUESTHANDLER_DISCONNECTREQUESTHANDLER_H_
+
+#include "RequestHandler.h"
+
+namespace Mad {
+namespace Common {
+namespace RequestHandler {
+
+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;
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_COMMON_REQUESTHANDLER_DISCONNECTREQUESTHANDLER_H_ */
diff --git a/src/Common/RequestHandler/IdentifyRequestHandler.h b/src/Common/RequestHandler/IdentifyRequestHandler.h
new file mode 100644
index 0000000..a8082c6
--- /dev/null
+++ b/src/Common/RequestHandler/IdentifyRequestHandler.h
@@ -0,0 +1,56 @@
+/*
+ * IdentifyRequestHandler.h
+ *
+ * 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/>.
+ */
+
+#ifndef MAD_COMMON_REQUESTHANDLER_IDENTIFYREQUESTHANDLER_H_
+#define MAD_COMMON_REQUESTHANDLER_IDENTIFYREQUESTHANDLER_H_
+
+#include "RequestHandler.h"
+
+namespace Mad {
+namespace Common {
+namespace RequestHandler {
+
+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;
+ }
+};
+
+}
+}
+}
+
+#endif /* MAD_COMMON_REQUESTHANDLER_IDENTIFYREQUESTHANDLER_H_ */
diff --git a/src/Common/RequestHandler/Makefile.am b/src/Common/RequestHandler/Makefile.am
new file mode 100644
index 0000000..146c4cd
--- /dev/null
+++ b/src/Common/RequestHandler/Makefile.am
@@ -0,0 +1,2 @@
+noinst_HEADERS = DisconnectRequestHandler.h IdentifyRequestHandler.h RequestHandler.h
+
diff --git a/src/Common/RequestHandler/Makefile.in b/src/Common/RequestHandler/Makefile.in
new file mode 100644
index 0000000..066da38
--- /dev/null
+++ b/src/Common/RequestHandler/Makefile.in
@@ -0,0 +1,379 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/Common/RequestHandler
+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) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+GnuTLS_CFLAGS = @GnuTLS_CFLAGS@
+GnuTLS_LIBS = @GnuTLS_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCRECPP_CFLAGS = @PCRECPP_CFLAGS@
+PCRECPP_LIBS = @PCRECPP_LIBS@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sigc_CFLAGS = @sigc_CFLAGS@
+sigc_LIBS = @sigc_LIBS@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+noinst_HEADERS = DisconnectRequestHandler.h IdentifyRequestHandler.h RequestHandler.h
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Common/RequestHandler/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Common/RequestHandler/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+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
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+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
+
+# 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.
+.NOEXPORT:
diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler/RequestHandler.h
index a6995ec..8f50d55 100644
--- a/src/Common/RequestHandler.h
+++ b/src/Common/RequestHandler/RequestHandler.h
@@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_REQUESTHANDLER_H_
-#define MAD_COMMON_REQUESTHANDLER_H_
+#ifndef MAD_COMMON_REQUESTHANDLER_REQUESTHANDLER_H_
+#define MAD_COMMON_REQUESTHANDLER_REQUESTHANDLER_H_
namespace Mad {
@@ -28,6 +28,7 @@ class Packet;
}
namespace Common {
+namespace RequestHandler {
class RequestHandler {
private:
@@ -48,5 +49,6 @@ class RequestHandler {
}
}
+}
-#endif /* MAD_COMMON_REQUESTHANDLER_H_ */
+#endif /* MAD_COMMON_REQUESTHANDLER_REQUESTHANDLER_H_ */
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index f8d5450..e71fd07 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -19,12 +19,19 @@
#include "RequestManager.h"
#include "Request/Request.h"
+#include "RequestHandler/DisconnectRequestHandler.h"
+#include "RequestHandler/IdentifyRequestHandler.h"
#include <iostream>
namespace Mad {
namespace Common {
+RequestManager::RequestManager(bool core) : requestId(core ? -2 : -1) {
+ registerPacketType<RequestHandler::DisconnectRequestHandler>(Net::Packet::DISCONNECT);
+ registerPacketType<RequestHandler::IdentifyRequestHandler>(Net::Packet::IDENTIFY);
+}
+
void RequestManager::receiveHandler(Net::Connection *connection, const Net::Packet &packet) {
std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
@@ -36,7 +43,7 @@ void RequestManager::receiveHandler(Net::Connection *connection, const Net::Pack
}
RequestMap *requestMap = it->second;
- RequestHandler *request = requestMap->findRequest(packet.getRequestId());
+ RequestHandler::RequestHandler *request = requestMap->findRequest(packet.getRequestId());
if(request) {
request->handlePacket(connection, packet);
@@ -61,19 +68,7 @@ void RequestManager::receiveHandler(Net::Connection *connection, const Net::Pack
}
- switch(packet.getType()) {
- case Net::Packet::DISCONNECT:
- connection->send(Net::Packet(Net::Packet::OK, packet.getRequestId()));
- connection->disconnect();
- break;
- case Net::Packet::IDENTIFY:
- std::cout << "Received identify request from '" << std::string((char*)packet.getData(), packet.getLength()) << "'." << std::endl;
-
- connection->send(Net::Packet(Net::Packet::IDENTIFY, packet.getRequestId(), packet.getData(), packet.getLength()));
- break;
- default:
- std::cerr << "Received an unexpected packet." << std::endl;
- }
+ std::cerr << "Received an unexpected packet." << std::endl;
}
bool RequestManager::sendRequest(Net::Connection *connection, Request::Request *request) {
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index a783fe2..68510f9 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -20,7 +20,7 @@
#ifndef MAD_COMMON_REQUESTMANAGER_H_
#define MAD_COMMON_REQUESTMANAGER_H_
-#include "RequestHandler.h"
+#include "RequestHandler/RequestHandler.h"
#include <Net/Connection.h>
#include <map>
@@ -33,7 +33,7 @@ class Request;
class RequestManager {
private:
- class RequestMap : private std::map<uint16_t,RequestHandler*> {
+ class RequestMap : private std::map<uint16_t,RequestHandler::RequestHandler*> {
private:
// Prevent shallow copy
RequestMap(const RequestMap &o);
@@ -47,11 +47,11 @@ class RequestManager {
delete it->second;
}
- bool addRequest(uint16_t id, RequestHandler *info) {
+ bool addRequest(uint16_t id, RequestHandler::RequestHandler *info) {
return insert(std::make_pair(id, info)).second;
}
- RequestHandler* findRequest(uint16_t id) {
+ RequestHandler::RequestHandler* findRequest(uint16_t id) {
iterator it = find(id);
if(it == end())
return 0;
@@ -76,13 +76,13 @@ class RequestManager {
RequestHandlerFactory() {}
public:
- virtual RequestHandler* createRequestHandler() = 0;
+ virtual RequestHandler::RequestHandler* createRequestHandler() = 0;
virtual ~RequestHandlerFactory() {}
};
template<class T> class SpecificRequestHandlerFactory : public RequestHandlerFactory {
public:
- virtual RequestHandler* createRequestHandler() {
+ virtual RequestHandler::RequestHandler* createRequestHandler() {
return new T();
}
};
@@ -137,7 +137,7 @@ class RequestManager {
bool sendRequest(Net::Connection *connection, Request::Request *request);
- RequestManager(bool core) : requestId(core ? -2 : -1) {}
+ RequestManager(bool core);
virtual ~RequestManager() {
for(std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it)
diff --git a/src/Core/RequestHandler/CoreStatusRequestHandler.h b/src/Core/RequestHandler/CoreStatusRequestHandler.h
index c895dd5..acf941e 100644
--- a/src/Core/RequestHandler/CoreStatusRequestHandler.h
+++ b/src/Core/RequestHandler/CoreStatusRequestHandler.h
@@ -20,20 +20,15 @@
#ifndef MAD_CORE_REQUESTHANDLER_CORESTATUSREQUESTHANDLER_H_
#define MAD_CORE_REQUESTHANDLER_CORESTATUSREQUESTHANDLER_H_
-#include <Common/RequestHandler.h>
+#include <Common/RequestHandler/RequestHandler.h>
#include <Common/SystemBackend.h>
#include <Net/Packets/HostStatusPacket.h>
-#include <cstring>
-#include <gssapi/gssapi.h>
-
-#include <iostream>
-
namespace Mad {
namespace Core {
namespace RequestHandler {
-class CoreStatusRequestHandler : public Common::RequestHandler {
+class CoreStatusRequestHandler : public Common::RequestHandler::RequestHandler {
public:
CoreStatusRequestHandler() {}
diff --git a/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h
index 8713db7..c04857b 100644
--- a/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h
+++ b/src/Core/RequestHandler/GSSAPIAuthRequestHandler.h
@@ -20,7 +20,7 @@
#ifndef MAD_CORE_REQUESTHANDLER_GSSAPIAUTHREQUESTHANDLER_H_
#define MAD_CORE_REQUESTHANDLER_GSSAPIAUTHREQUESTHANDLER_H_
-#include <Common/RequestHandler.h>
+#include <Common/RequestHandler/RequestHandler.h>
#include <Net/Packet.h>
#include <cstring>
#include <gssapi/gssapi.h>
@@ -33,7 +33,7 @@ namespace RequestHandler {
// TODO Error handling
-class GSSAPIAuthRequestHandler : public Common::RequestHandler {
+class GSSAPIAuthRequestHandler : public Common::RequestHandler::RequestHandler {
private:
gss_ctx_id_t gssContext;
diff --git a/src/mad.cpp b/src/mad.cpp
index dc3241e..177b88a 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -20,8 +20,10 @@
#include "Net/ClientConnection.h"
#include "Net/IPAddress.h"
#include "Common/RequestManager.h"
+#include "Common/Request/IdentifyRequest.h"
#include <iostream>
+#include <unistd.h>
int main() {
@@ -42,6 +44,10 @@ int main() {
requestManager.registerConnection(connection);
+ char hostname[256];
+ gethostname(hostname, sizeof(hostname));
+ Mad::Common::Request::IdentifyRequest::send(connection, requestManager, hostname);
+
while(connection->isConnected()) {
struct pollfd fd = connection->getPollfd();