summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aclocal.m42
-rwxr-xr-xconfigure3
-rw-r--r--configure.ac1
-rw-r--r--src/Common/Makefile.am5
-rw-r--r--src/Common/Makefile.in442
-rw-r--r--src/Common/Request.h46
-rw-r--r--src/Common/RequestManager.cpp111
-rw-r--r--src/Common/RequestManager.h64
-rw-r--r--src/Core/ConnectionManager.cpp63
-rw-r--r--src/Core/ConnectionManager.h19
-rw-r--r--src/Makefile.am8
-rw-r--r--src/Makefile.in15
-rw-r--r--src/Net/Packet.h36
-rw-r--r--src/mad-core.cpp20
-rw-r--r--src/madc.cpp33
15 files changed, 757 insertions, 111 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index cc442ca..b1826ac 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -21,7 +21,7 @@ To do so, use the procedure documented by the package, typically `autoreconf'.])
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-# serial 52 Debian 1.5.26-4 AC_PROG_LIBTOOL
+# serial 52 Debian 1.5.26-1ubuntu1 AC_PROG_LIBTOOL
# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
diff --git a/configure b/configure
index 912fc30..0cc46eb 100755
--- a/configure
+++ b/configure
@@ -20647,7 +20647,7 @@ fi
# Checks for library functions.
-ac_config_files="$ac_config_files Makefile src/Makefile src/Core/Makefile src/Net/Makefile"
+ac_config_files="$ac_config_files Makefile src/Makefile src/Common/Makefile src/Core/Makefile src/Net/Makefile"
cat >confcache <<\_ACEOF
@@ -21245,6 +21245,7 @@ do
"depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
+ "src/Common/Makefile") CONFIG_FILES="$CONFIG_FILES src/Common/Makefile" ;;
"src/Core/Makefile") CONFIG_FILES="$CONFIG_FILES src/Core/Makefile" ;;
"src/Net/Makefile") CONFIG_FILES="$CONFIG_FILES src/Net/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index f859434..7afc8ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,7 @@ AC_C_CONST
AC_CONFIG_FILES([
Makefile
src/Makefile
+ src/Common/Makefile
src/Core/Makefile
src/Net/Makefile
])
diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am
new file mode 100644
index 0000000..aa2e45f
--- /dev/null
+++ b/src/Common/Makefile.am
@@ -0,0 +1,5 @@
+noinst_LTLIBRARIES = libcommon.la
+
+libcommon_la_SOURCES = RequestManager.cpp
+
+noinst_HEADERS = Request.h RequestManager.h
diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in
new file mode 100644
index 0000000..55e52ce
--- /dev/null
+++ b/src/Common/Makefile.in
@@ -0,0 +1,442 @@
+# 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
+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 =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libcommon_la_LIBADD =
+am_libcommon_la_OBJECTS = RequestManager.lo
+libcommon_la_OBJECTS = $(am_libcommon_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 = $(libcommon_la_SOURCES)
+DIST_SOURCES = $(libcommon_la_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@
+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_LTLIBRARIES = libcommon.la
+libcommon_la_SOURCES = RequestManager.cpp
+noinst_HEADERS = Request.h RequestManager.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 \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Common/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Common/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
+
+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
+libcommon.la: $(libcommon_la_OBJECTS) $(libcommon_la_DEPENDENCIES)
+ $(CXXLINK) $(libcommon_la_OBJECTS) $(libcommon_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestManager.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
+
+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 $(LTLIBRARIES) $(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 clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile 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 -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile 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 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.
+.NOEXPORT:
diff --git a/src/Common/Request.h b/src/Common/Request.h
new file mode 100644
index 0000000..b537b66
--- /dev/null
+++ b/src/Common/Request.h
@@ -0,0 +1,46 @@
+/*
+ * Request.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_REQUEST_H_
+#define MAD_COMMON_REQUEST_H_
+
+namespace Mad {
+
+namespace Common {
+
+class Request {
+ public:
+ enum Type {
+ TYPE_PING, TYPE_DISCONNECT
+ };
+
+ private:
+ Type type;
+
+ public:
+ Request(Type type0) : type(type0) {}
+
+ Type getType() const {return type;}
+};
+
+}
+
+}
+
+#endif /* MAD_COMMON_REQUEST_H_ */
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
new file mode 100644
index 0000000..9cc4c71
--- /dev/null
+++ b/src/Common/RequestManager.cpp
@@ -0,0 +1,111 @@
+/*
+ * RequestManager.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 "RequestManager.h"
+
+#include <iostream>
+
+namespace Mad {
+namespace Common {
+
+void RequestManager::receiveHandler(Net::Connection *connection, const Net::Packet &packet) {
+ std::map<Net::Connection*,RequestInfo>::iterator it = requestMap.find(connection);
+
+ if(it == requestMap.end()) {
+ // TODO: Error
+ std::cerr << "Received a packet from a unregistered connection." << std::endl;
+
+ return;
+ }
+
+ RequestInfo &requestInfo = it->second;
+ RequestInfo::iterator it2;
+
+ switch(packet.getType()) {
+ case Net::Packet::TYPE_PING:
+ std::cout << "Received ping request." << std::endl;
+ std::cout << " Request ID: " << packet.getRequestId() << std::endl;
+
+ connection->send(Net::Packet(Net::Packet::TYPE_PONG, packet.getRequestId(), packet.getData(), packet.getLength()));
+ break;
+ case Net::Packet::TYPE_PONG:
+ it2 = requestInfo.find(packet.getRequestId());
+ if(it2 == requestInfo.end() || it2->second.getType() != Request::TYPE_PING) {
+ // TODO: Error
+ std::cerr << "Received an unexpected ping reply." << std::endl;
+
+ return;
+ }
+
+ requestInfo.erase(it2);
+
+ std::cout << "Received ping reply." << std::endl;
+ std::cout << " Request ID: " << packet.getRequestId() << std::endl;
+ break;
+ case Net::Packet::TYPE_DISCONNECT_REQ:
+ connection->send(Net::Packet(Net::Packet::TYPE_DISCONNECT_REP, packet.getRequestId()));
+ connection->disconnect();
+ break;
+ case Net::Packet::TYPE_DISCONNECT_REP:
+ it2 = requestInfo.find(packet.getRequestId());
+ if(it2 == requestInfo.end() || it2->second.getType() != Request::TYPE_DISCONNECT) {
+ // TODO: Error
+ std::cerr << "Received an unexpected disconnect reply." << std::endl;
+
+ return;
+ }
+
+ requestInfo.erase(it2);
+
+ connection->disconnect();
+ }
+}
+
+bool RequestManager::sendRequest(Net::Connection *connection, Request::Type type) {
+ std::map<Net::Connection*,RequestInfo>::iterator it = requestMap.find(connection);
+
+ if(it == requestMap.end())
+ return false;
+
+ RequestInfo &requestInfo = it->second;
+
+ unsigned short request;
+ do {
+ request = getRequestId();
+ } while(requestInfo.find(request) != requestInfo.end());
+
+ switch(type) {
+ case Request::TYPE_PING:
+ if(!connection->send(Net::Packet(Net::Packet::TYPE_PING, request)))
+ return false;
+
+ requestInfo.insert(std::make_pair(request, Request(type)));
+ break;
+ case Request::TYPE_DISCONNECT:
+ if(!connection->send(Net::Packet(Net::Packet::TYPE_DISCONNECT_REQ, request)))
+ return false;
+
+ requestInfo.insert(std::make_pair(request, Request(type)));
+ }
+
+ return true;
+}
+
+}
+}
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
new file mode 100644
index 0000000..f84cf23
--- /dev/null
+++ b/src/Common/RequestManager.h
@@ -0,0 +1,64 @@
+/*
+ * RequestManager.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_REQUESTMANAGER_H_
+#define MAD_COMMON_REQUESTMANAGER_H_
+
+#include "Request.h"
+#include <Net/Connection.h>
+#include <map>
+
+namespace Mad {
+namespace Common {
+
+class RequestManager {
+ private:
+ typedef std::map<unsigned short,Request> RequestInfo;
+
+ std::map<Net::Connection*,RequestInfo> requestMap;
+ unsigned short requestId;
+
+ unsigned short getRequestId() {
+ return requestId++;
+ }
+
+ void receiveHandler(Net::Connection *connection, const Net::Packet &packet);
+
+ public:
+ void registerConnection(Net::Connection *connection) {
+ requestMap.insert(std::make_pair(connection, RequestInfo()));
+
+ connection->signalReceive().connect(sigc::mem_fun(this, &RequestManager::receiveHandler));
+ }
+
+ void unregisterConnection(Net::Connection *connection) {
+ requestMap.erase(connection);
+ }
+
+ bool sendRequest(Net::Connection *connection, Request::Type type);
+
+ RequestManager() : requestId(0) {}
+
+ virtual ~RequestManager() {}
+};
+
+}
+}
+
+#endif /* MAD_COMMON_REQUESTMANAGER_H_ */
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index 5ff5e29..020c8a7 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -23,58 +23,33 @@
#include <Net/Listener.h>
#include <unistd.h>
-#include <iostream>
-
namespace Mad {
namespace Core {
void ConnectionManager::refreshPollfds() {
pollfds.clear();
pollfdMap.clear();
-
+
for(std::list<Net::Listener*>::iterator listener = listeners.begin(); listener != listeners.end(); ++listener) {
std::vector<struct pollfd> fds = (*listener)->getPollfds();
-
+
for(std::vector<struct pollfd>::iterator fd = fds.begin(); fd != fds.end(); ++fd) {
pollfds.push_back(*fd);
pollfdMap.insert(std::make_pair(fd->fd, &pollfds.back().revents));
}
}
-
+
for(std::list<Net::ServerConnection*>::iterator con = daemonConnections.begin(); con != daemonConnections.end(); ++con) {
pollfds.push_back((*con)->getPollfd());
pollfdMap.insert(std::make_pair(pollfds.back().fd, &pollfds.back().revents));
}
-
+
for(std::list<Net::ServerConnection*>::iterator con = clientConnections.begin(); con != clientConnections.end(); ++con) {
pollfds.push_back((*con)->getPollfd());
pollfdMap.insert(std::make_pair(pollfds.back().fd, &pollfds.back().revents));
}
}
-void ConnectionManager::receiveHandler(Net::Connection *connection, const Net::Packet &packet) {
- switch(packet.getType()) {
- case Net::Packet::TYPE_UNKNOWN:
- break;
- case Net::Packet::TYPE_DEBUG:
- std::cout << "Received debug packet." << std::endl;
- std::cout << " Request ID: 0x" << std::hex << std::uppercase << packet.getRequestId() << std::dec << std::endl;
- break;
- case Net::Packet::TYPE_PING:
- connection->send(Net::Packet(Net::Packet::TYPE_PONG, packet.getRequestId(), packet.getData(), packet.getLength()));
- break;
- case Net::Packet::TYPE_PONG:
- // TODO: Pong!
- break;
- case Net::Packet::TYPE_DISCONNECT_REQ:
- connection->send(Net::Packet(Net::Packet::TYPE_DISCONNECT_REP, packet.getRequestId()));
- connection->disconnect();
- break;
- case Net::Packet::TYPE_DISCONNECT_REP:
- connection->disconnect();
- }
-}
-
ConnectionManager::ConnectionManager() {
try {
// TODO: Get listener addresses from config
@@ -83,72 +58,72 @@ ConnectionManager::ConnectionManager() {
catch(Net::Exception &e) {
// TODO: Log error
}
-
+
refreshPollfds();
}
ConnectionManager::~ConnectionManager() {
for(std::list<Net::ServerConnection*>::iterator con = daemonConnections.begin(); con != daemonConnections.end(); ++con)
delete *con;
-
+
for(std::list<Net::ServerConnection*>::iterator con = clientConnections.begin(); con != clientConnections.end(); ++con)
delete *con;
}
void ConnectionManager::run() {
// TODO: Logging
-
+
for(std::list<Net::ServerConnection*>::iterator con = daemonConnections.begin(); con != daemonConnections.end();) {
if((*con)->isConnected()) {
std::map<int,const short*>::iterator events = pollfdMap.find((*con)->getSocket());
-
+
if(events != pollfdMap.end())
(*con)->sendReceive(*events->second);
else
(*con)->sendReceive();
-
+
++con;
}
else {
- std::cout << "A daemon connection was dropped." << std::endl;
+ requestManager.unregisterConnection(*con);
delete *con;
daemonConnections.erase(con++);
}
}
-
+
for(std::list<Net::ServerConnection*>::iterator con = clientConnections.begin(); con != clientConnections.end();) {
if((*con)->isConnected()) {
std::map<int,const short*>::iterator events = pollfdMap.find((*con)->getSocket());
-
+
if(events != pollfdMap.end())
(*con)->sendReceive(*events->second);
else
(*con)->sendReceive();
-
+
++con;
}
else {
- std::cout << "A client connection was dropped." << std::endl;
+ requestManager.unregisterConnection(*con);
delete *con;
clientConnections.erase(con++);
}
}
-
+
for(std::list<Net::Listener*>::iterator listener = listeners.begin(); listener != listeners.end(); ++listener) {
Net::ServerConnection *con;
-
+
while((con = (*listener)->getConnection(pollfdMap)) != 0) {
if(con->isDaemonConnection()) {
daemonConnections.push_back(con);
- con->signalReceive().connect(sigc::mem_fun(this, &ConnectionManager::receiveHandler));
+ requestManager.registerConnection(con);
}
else {
clientConnections.push_back(con);
- con->signalReceive().connect(sigc::mem_fun(this, &ConnectionManager::receiveHandler));
+ requestManager.registerConnection(con);
}
}
}
-
+
refreshPollfds();
}
diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h
index 608ec27..c7fe669 100644
--- a/src/Core/ConnectionManager.h
+++ b/src/Core/ConnectionManager.h
@@ -24,6 +24,7 @@
#include <vector>
#include <map>
#include <poll.h>
+#include <Common/RequestManager.h>
namespace Mad {
@@ -41,27 +42,27 @@ class ConnectionManager {
// Prevent shallow copy
ConnectionManager(const ConnectionManager &o);
ConnectionManager& operator=(const ConnectionManager &o);
-
+
+ Common::RequestManager requestManager;
+
std::list<Net::Listener*> listeners;
-
+
std::list<Net::ServerConnection*> daemonConnections;
std::list<Net::ServerConnection*> clientConnections;
-
+
std::vector<struct pollfd> pollfds;
std::map<int,const short*> pollfdMap;
-
+
void refreshPollfds();
-
- void receiveHandler(Net::Connection *connection, const Net::Packet &packet);
-
+
public:
ConnectionManager();
virtual ~ConnectionManager();
-
+
bool wait(int timeout) {
return (poll(pollfds.data(), pollfds.size(), timeout) > 0);
}
-
+
void run();
};
diff --git a/src/Makefile.am b/src/Makefile.am
index a62aeb9..8b06a70 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,12 +1,12 @@
-SUBDIRS = Core Net
+SUBDIRS = Common Core Net
bin_PROGRAMS = mad madc mad-core
mad_SOURCES = mad.cpp
-mad_LDADD = Net/libnet.la
+mad_LDADD = Net/libnet.la Common/libcommon.la
madc_SOURCES = madc.cpp
-madc_LDADD = Net/libnet.la
+madc_LDADD = Net/libnet.la Common/libcommon.la
mad_core_SOURCES = mad-core.cpp
-mad_core_LDADD = Core/libcore.la Net/libnet.la
+mad_core_LDADD = Core/libcore.la Net/libnet.la Common/libcommon.la
diff --git a/src/Makefile.in b/src/Makefile.in
index 0e5f05b..0c56569 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -48,13 +48,14 @@ binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_mad_OBJECTS = mad.$(OBJEXT)
mad_OBJECTS = $(am_mad_OBJECTS)
-mad_DEPENDENCIES = Net/libnet.la
+mad_DEPENDENCIES = 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
+mad_core_DEPENDENCIES = Core/libcore.la Net/libnet.la \
+ Common/libcommon.la
am_madc_OBJECTS = madc.$(OBJEXT)
madc_OBJECTS = $(am_madc_OBJECTS)
-madc_DEPENDENCIES = Net/libnet.la
+madc_DEPENDENCIES = Net/libnet.la Common/libcommon.la
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -196,13 +197,13 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = Core Net
+SUBDIRS = Common Core Net
mad_SOURCES = mad.cpp
-mad_LDADD = Net/libnet.la
+mad_LDADD = Net/libnet.la Common/libcommon.la
madc_SOURCES = madc.cpp
-madc_LDADD = Net/libnet.la
+madc_LDADD = Net/libnet.la Common/libcommon.la
mad_core_SOURCES = mad-core.cpp
-mad_core_LDADD = Core/libcore.la Net/libnet.la
+mad_core_LDADD = Core/libcore.la Net/libnet.la Common/libcommon.la
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
diff --git a/src/Net/Packet.h b/src/Net/Packet.h
index c2bd4d1..7ef5cb0 100644
--- a/src/Net/Packet.h
+++ b/src/Net/Packet.h
@@ -29,73 +29,73 @@ namespace Net {
class Packet {
public:
enum Type {
- TYPE_UNKNOWN = 0x0000, TYPE_DEBUG = 0x0001, TYPE_PING = 0x0002, TYPE_PONG = 0x0003,
+ TYPE_PING = 0x0000, TYPE_PONG = 0x0001,
TYPE_DISCONNECT_REQ = 0x0010, TYPE_DISCONNECT_REP = 0x0011
};
-
+
struct Data {
unsigned short type;
unsigned short requestId;
unsigned long length;
unsigned char data[0];
};
-
+
protected:
Data *rawData;
-
+
public:
Packet(Type type, unsigned short requestId, const void *data = NULL, unsigned long length = 0) {
rawData = (Data*)std::malloc(sizeof(Data)+length);
-
+
rawData->type = type;
rawData->requestId = requestId;
rawData->length = length;
-
+
if(length)
std::memcpy(rawData->data, data, length);
}
-
+
Packet(const Packet &p) {
rawData = (Data*)std::malloc(p.getRawDataLength());
std::memcpy(rawData, p.rawData, p.getRawDataLength());
}
-
+
Packet& operator=(Packet &p) {
if(&p == this)
return *this;
-
+
std::free(rawData);
-
+
rawData = (Data*)std::malloc(p.getRawDataLength());
std::memcpy(rawData, p.rawData, p.getRawDataLength());
-
+
return *this;
}
-
+
virtual ~Packet() {
std::free(rawData);
}
-
+
Type getType() const {
return (Type)rawData->type;
}
-
+
unsigned short getRequestId() const {
return rawData->requestId;
}
-
+
unsigned long getLength() const {
return rawData->length;
}
-
+
const unsigned char* getData() const {
return rawData->data;
}
-
+
const Data* getRawData() const {
return rawData;
}
-
+
unsigned long getRawDataLength() const {
return sizeof(Data) + rawData->length;
}
diff --git a/src/mad-core.cpp b/src/mad-core.cpp
index 36e889b..525eb88 100644
--- a/src/mad-core.cpp
+++ b/src/mad-core.cpp
@@ -23,21 +23,23 @@
int main() {
sigset_t signals;
-
+
sigemptyset(&signals);
sigaddset(&signals, SIGPIPE);
sigprocmask(SIG_BLOCK, &signals, 0);
-
+
Mad::Net::Connection::init();
-
- Mad::Core::ConnectionManager connectionManager;
-
+
+ Mad::Core::ConnectionManager *connectionManager = new Mad::Core::ConnectionManager;
+
while(true) {
- if(connectionManager.wait(10000))
- connectionManager.run();
+ if(connectionManager->wait(10000))
+ connectionManager->run();
}
-
+
+ delete connectionManager;
+
Mad::Net::Connection::deinit();
-
+
return 0;
}
diff --git a/src/madc.cpp b/src/madc.cpp
index 790baf5..17f6953 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -20,46 +20,43 @@
#include "Net/ClientConnection.h"
#include "Net/IPAddress.h"
#include "Net/Packet.h"
+#include "Common/RequestManager.h"
#include <iostream>
int main() {
Mad::Net::Connection::init();
- Mad::Net::ClientConnection connection;
+ Mad::Common::RequestManager requestManager;
+ Mad::Net::ClientConnection *connection = new Mad::Net::ClientConnection;
try {
- connection.connect(Mad::Net::IPAddress("127.0.0.1", 6666));
+ connection->connect(Mad::Net::IPAddress("127.0.0.1", 6666));
- while(connection.isConnecting()) {
- struct pollfd fd = connection.getPollfd();
+ while(connection->isConnecting()) {
+ struct pollfd fd = connection->getPollfd();
if(poll(&fd, 1, 10000) > 0)
- connection.sendReceive(fd.revents);
+ connection->sendReceive(fd.revents);
}
- connection.send(Mad::Net::Packet(Mad::Net::Packet::TYPE_DEBUG, 0x1234));
- connection.send(Mad::Net::Packet(Mad::Net::Packet::TYPE_DISCONNECT_REQ, 0xABCD));
+ requestManager.registerConnection(connection);
- while(!connection.sendQueueEmpty()) {
- struct pollfd fd = connection.getPollfd();
+ requestManager.sendRequest(connection, Mad::Common::Request::TYPE_PING);
+ requestManager.sendRequest(connection, Mad::Common::Request::TYPE_DISCONNECT);
- if(poll(&fd, 1, 10000) > 0)
- connection.sendReceive(fd.revents);
- }
-
- connection.disconnect();
-
- while(connection.isConnected()) {
- struct pollfd fd = connection.getPollfd();
+ while(connection->isConnected()) {
+ struct pollfd fd = connection->getPollfd();
if(poll(&fd, 1, 10000) > 0)
- connection.sendReceive(fd.revents);
+ connection->sendReceive(fd.revents);
}
}
catch(Mad::Net::Exception &e) {
std::cerr << "Connection error: " << e.what() << std::endl;
}
+ delete connection;
+
Mad::Net::Connection::deinit();
return 0;