From a27375762602ee41a01282b59aae617c0764b38b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Sat, 15 Oct 2005 11:02:08 +0000 Subject: [PATCH] Implemented FilterLog filter --- src/Makefile.am | 8 +++++--- src/ex_filter_frontend_net.cpp | 9 +++++++-- src/filter_log.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ src/filter_log.hpp | 25 +++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 src/filter_log.cpp create mode 100644 src/filter_log.hpp diff --git a/src/Makefile.am b/src/Makefile.am index cf719f3..0e13dd7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.18 2005-10-14 11:18:59 adam Exp $ +## $Id: Makefile.am,v 1.19 2005-10-15 11:02:08 adam Exp $ MAINTAINERCLEANFILES = Makefile.in config.in config.hpp @@ -9,9 +9,11 @@ AM_CXXFLAGS = $(YAZPPINC) $(XSLT_CFLAGS) lib_LTLIBRARIES = libyp2.la libyp2_la_LDFLAGS = -version-info 0:0:0 -libyp2_la_SOURCES = filter_frontend_net.cpp filter_frontend_net.hpp \ +libyp2_la_SOURCES = \ session.cpp session.hpp package.hpp filter.hpp router.hpp \ - thread_pool_observer.cpp thread_pool_observer.hpp + thread_pool_observer.cpp thread_pool_observer.hpp \ + filter_frontend_net.cpp filter_frontend_net.hpp \ + filter_log.cpp filter_log.hpp # Rules for programs.. diff --git a/src/ex_filter_frontend_net.cpp b/src/ex_filter_frontend_net.cpp index 23c5aa1..41813af 100644 --- a/src/ex_filter_frontend_net.cpp +++ b/src/ex_filter_frontend_net.cpp @@ -9,6 +9,7 @@ namespace po = boost::program_options; #include "config.hpp" #include "filter_frontend_net.hpp" +#include "filter_log.hpp" #include "router.hpp" #include "session.hpp" @@ -94,7 +95,7 @@ int main(int argc, char **argv) yp2::RouterChain router; - // put in frontend first + // put frontend filter in router yp2::FilterFrontendNet filter_front; filter_front.ports() = ports; @@ -104,7 +105,11 @@ int main(int argc, char **argv) } router.rule(filter_front); - // put in a backend + // put log filter in router + yp2::FilterLog filter_log; + router.rule(filter_log); + + // put backend init filter in router FilterInit filter_init; router.rule(filter_init); diff --git a/src/filter_log.cpp b/src/filter_log.cpp new file mode 100644 index 0000000..333658b --- /dev/null +++ b/src/filter_log.cpp @@ -0,0 +1,40 @@ + + +#include "config.hpp" + +#include "filter.hpp" +#include "router.hpp" +#include "package.hpp" + +#include "filter_log.hpp" + +#include +#include + +#include + +yp2::FilterLog::FilterLog() {} + +void yp2::FilterLog::process(Package &package) const { + + Z_GDU *gdu; + + gdu = package.request().get(); + if (gdu) + { + ODR odr = odr_createmem(ODR_PRINT); + z_GDU(odr, &gdu, 0, 0); + odr_destroy(odr); + } + package.move(); + + gdu = package.response().get(); + if (gdu) + { + ODR odr = odr_createmem(ODR_PRINT); + z_GDU(odr, &gdu, 0, 0); + odr_destroy(odr); + } +} + + diff --git a/src/filter_log.hpp b/src/filter_log.hpp new file mode 100644 index 0000000..84d1491 --- /dev/null +++ b/src/filter_log.hpp @@ -0,0 +1,25 @@ + +#ifndef FILTER_LOG_HPP +#define FILTER_LOG_HPP + +#include +#include + +#include "filter.hpp" + +namespace yp2 { + class FilterLog : public yp2::Filter { + public: + FilterLog::FilterLog(); + void process(yp2::Package & package) const; + }; +} + +#endif +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ -- 1.7.10.4