# -*- python -*-
-import sys
-sys.path.extend(['senf/site_scons', '../../site_scons'])
+import sys, os, os.path
+sys.path.append(((_ for _ in (os.path.join(os.path.sep.join(('..' for _ in range(_))),d,'site_scons') for d in ('','senf','Senf') for _ in range(len(os.getcwd().split('/')))) if os.path.exists(_))).next())
import senfutil
env = Environment()
# -*- python -*-
-import sys
-sys.path.extend(['senf/site_scons', '../../site_scons'])
+import sys, os, os.path
+sys.path.append(((_ for _ in (os.path.join(os.path.sep.join(('..' for _ in range(_))),d,'site_scons') for d in ('','senf','Senf') for _ in range(len(os.getcwd().split('/')))) if os.path.exists(_))).next())
import senfutil
env = Environment()
# -*- python -*-
-import sys
-sys.path.extend(['senf/site_scons', '../../site_scons'])
+import sys, os, os.path
+sys.path.append(((_ for _ in (os.path.join(os.path.sep.join(('..' for _ in range(_))),d,'site_scons') for d in ('','senf','Senf') for _ in range(len(os.getcwd().split('/')))) if os.path.exists(_))).next())
import senfutil
env = Environment()
# -*- python -*-
-import sys
-sys.path.extend(['senf/site_scons', '../../site_scons'])
+import sys, os, os.path
+sys.path.append(((_ for _ in (os.path.join(os.path.sep.join(('..' for _ in range(_))),d,'site_scons') for d in ('','senf','Senf') for _ in range(len(os.getcwd().split('/')))) if os.path.exists(_))).next())
import senfutil
env = Environment()
# -*- python -*-
-import sys
-sys.path.extend(['senf/site_scons', '../../site_scons'])
+import sys, os, os.path
+sys.path.append(((_ for _ in (os.path.join(os.path.sep.join(('..' for _ in range(_))),d,'site_scons') for d in ('','senf','Senf') for _ in range(len(os.getcwd().split('/')))) if os.path.exists(_))).next())
import senfutil
env = Environment()
# -*- python -*-
-import sys
-sys.path.extend(['senf/site_scons', '../../site_scons'])
+import sys, os, os.path
+sys.path.append(((_ for _ in (os.path.join(os.path.sep.join(('..' for _ in range(_))),d,'site_scons') for d in ('','senf','Senf') for _ in range(len(os.getcwd().split('/')))) if os.path.exists(_))).next())
import senfutil
env = Environment()
+# -*- python -*-
+
Import('env')
-env['ALLOBJECTS'] = []
+env.Replace( ALLOBJECTS = [], PACKET_BUNDLES = [] )
+env.SetDefault( ALLBUNDLES = '$LOCALLIBDIR/AllBundles${OBJADDSUFFIX}${OBJSUFFIX}' )
SConscript('senf/SConscript')
env.Default(conf)
env.Install('$CONFINSTALLDIR', conf)
-# AllBundles:
+### AllBundles:
cobject = env.CombinedObject('${LOCALLIBDIR}/${NAME}${OBJADDSUFFIX}', env['PACKET_BUNDLES'],
NAME="AllBundles")
env.Default(cobject)
env.Install('${OBJINSTALLDIR}', cobject)
-
\ No newline at end of file
+
--- /dev/null
+/bundledump
struct ICMPTypes {
// ICMP type registry
- typedef boost::uint16_t key_t;
+ typedef boost::uint8_t key_t;
};
/** \brief ICMP Packet for IPv6
PacketRegistry
*/
struct IpTypes {
- typedef boost::uint16_t key_t;
+ typedef boost::uint8_t key_t;
};
/** \brief IPv4 packet
RegistryMap::const_iterator i (registries().begin());
RegistryMap::const_iterator const i_end (registries().end());
for (; i!=i_end; ++i) {
- os << i->first << ":\n";
- i->second->v_dump(os);
- os << "\n";
+ if (! i->second->v_empty()) {
+ os << i->first << ":\n";
+ i->second->v_dump(os);
+ os << "\n";
+ }
}
}
+prefix_ void senf::detail::PacketRegistryImplBase::clear()
+{
+ RegistryMap::const_iterator i (registries().begin());
+ RegistryMap::const_iterator const i_end (registries().end());
+ for (; i!=i_end; ++i)
+ i->second->v_clear();
+}
+
prefix_ senf::detail::PacketRegistryImplBase::RegistryMap &
senf::detail::PacketRegistryImplBase::registries()
{
// Custom includes
#include <senf/Utils/senfassert.hh>
#include <iostream>
+#include <iomanip>
+#include <cmath>
#include <senf/Utils/TypeInfo.hh>
#define prefix_
}
template <class KeyType>
+prefix_ bool senf::detail::PacketRegistryImpl<KeyType>::v_empty()
+ const
+{
+ return registry_.empty();
+}
+
+template <class KeyType>
prefix_ void senf::detail::PacketRegistryImpl<KeyType>::v_dump(std::ostream & os)
+ const
{
typename PacketMap::const_iterator i (registry_.begin());
typename PacketMap::const_iterator const i_end (registry_.end());
- for (; i != i_end; ++i)
- os << i->first << " " << i->second->name() << "\n";
+ for (; i != i_end; ++i) {
+ std::string n (i->second->name());
+ senf::detail::DumpKey<KeyType>::dump(i->first, os);
+ os << ' ' << n.substr(21,n.size()-22) << "\n";
+ }
+}
+
+template <class KeyType>
+prefix_ void senf::detail::PacketRegistryImpl<KeyType>::v_clear()
+{
+ registry_.clear();
+ reverseRegistry_.clear();
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::detail::DumpKey<KeyType,is_integral>
+
+template <class KeyType, bool is_integral>
+prefix_ void senf::detail::DumpKey<KeyType,is_integral>::dump(KeyType const & v,
+ std::ostream & os)
+{
+ os << " " << std::setw(16) << std::left << v << std::setw(0) << std::right;
+}
+
+// senf::detail::DumpKey<KeyType, true>
+
+template <class KeyType>
+prefix_ void senf::detail::DumpKey<KeyType, true>::dump(KeyType const & v, std::ostream & os)
+{
+ int bytes ((std::numeric_limits<KeyType>::digits+7)/8);
+ int digs (int(2.4*bytes)+1);
+
+ os << " 0x" << std::setw(2*bytes) << std::setfill('0') << std::hex
+ << typename senf::detail::CharToInt<KeyType>::type (v)
+ << " (" << std::setw(digs) << std::setfill(' ') << std::dec
+ << typename senf::detail::CharToInt<KeyType>::type (v)
+ << ") (";
+ for (int i (bytes-1); i>=0; --i) {
+ char c ((v>>(8*i))&0xff);
+ os << ((c>=32 && c<=127) ? c : '.');
+ }
+ os << ')';
}
///////////////////////////////ct.e////////////////////////////////////////
// Custom includes
#include <ext/functional>
+#include <limits>
#include <boost/intrusive_ptr.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <senf/Utils/TypeIdValue.hh>
virtual ~PacketRegistryImplBase();
static void dump(std::ostream & os);
+ static void clear();
protected:
typedef std::map<std::string, PacketRegistryImplBase*> RegistryMap;
static RegistryMap & registries();
private:
- virtual void v_dump(std::ostream & os) = 0;
+ virtual bool v_empty() const = 0;
+ virtual void v_dump(std::ostream & os) const = 0;
+ virtual void v_clear() = 0;
};
/** \brief Internal: Singleton class implementing the packet registry.
protected:
private:
- virtual void v_dump(std::ostream & os);
+ virtual bool v_empty() const;
+ virtual void v_dump(std::ostream & os) const;
+ virtual void v_clear();
PacketMap registry_;
ReversePacketMap reverseRegistry_;
};
+ template <class KeyType, bool is_integral=std::numeric_limits<KeyType>::is_integer>
+ struct DumpKey
+ {
+ static void dump(KeyType const & v, std::ostream & os);
+ };
+
+ template <class KeyType>
+ struct DumpKey<KeyType, true>
+ {
+ static void dump(KeyType const & v, std::ostream & os);
+ };
+
+ template <class Type> struct CharToInt { typedef Type type; };
+ template <> struct CharToInt<char> { typedef int type; };
+ template <> struct CharToInt<signed char> { typedef int type; };
+ template <> struct CharToInt<unsigned char> { typedef unsigned type; };
+
}}
///////////////////////////////ih.e////////////////////////////////////////
senf::dumpPacketRegistries(s);
BOOST_CHECK_EQUAL( s.str(),
"(anonymous namespace)::BaseTag:\n"
- "1 senf::ConcretePacket<(anonymous namespace)::FooPacketType>\n"
- "2 senf::ConcretePacket<(anonymous namespace)::BarPacketType>\n"
+ " 0x00000001 ( 1) (....) (anonymous namespace)::FooPacketType\n"
+ " 0x00000002 ( 2) (....) (anonymous namespace)::BarPacketType\n"
"\n"
"(anonymous namespace)::RegTag:\n"
- "1 senf::ConcretePacket<(anonymous namespace)::FooPacketType>\n"
- "2 senf::ConcretePacket<(anonymous namespace)::BarPacketType>\n"
+ " 0x00000001 ( 1) (....) (anonymous namespace)::FooPacketType\n"
+ " 0x00000002 ( 2) (....) (anonymous namespace)::BarPacketType\n"
"\n"
"(anonymous namespace)::StringTag:\n"
- "bar senf::ConcretePacket<(anonymous namespace)::BarPacketType>\n"
- "foo senf::ConcretePacket<(anonymous namespace)::FooPacketType>\n"
+ " bar (anonymous namespace)::BarPacketType\n"
+ " foo (anonymous namespace)::FooPacketType\n"
"\n" );
-
}
///////////////////////////////cc.e////////////////////////////////////////
###########################################################################
-env['PACKET_BUNDLES'] = []
-
-SENFSCons.AutoRules(env, doc_extra_sources = [
+SENFSCons.AutoRules(env, exclude = [ 'bundledump.cc' ], doc_extra_sources = [
env.Dia2Png("structure.dia"),
env.Dia2Png("80221Bundle/TLV.dia"),
env.PkgDraw("MPEGDVBBundle/DTCPPacket.hh"),
env.PkgDraw("MPEGDVBBundle/TransportPacket.hh"),
])
+env.Default(env.Program('bundledump', [ 'bundledump.cc', '$LOCALLIBDIR/DefaultBundle.o' ],
+ LIBS = [ '$LIBS', 'dl' ]))
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2009
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.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 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief bundledump non-inline non-template implementation */
+
+// Custom includes
+#include <dlfcn.h>
+#include <iostream>
+#include "Packets.hh"
+#include <senf/Utils/Logger/Logger.hh>
+
+//#include "bundledump.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+int main(int argc, char const ** argv)
+{
+ // Link in logger library ...
+ (void) senf::log::StreamRegistry::instance();
+ for (unsigned i (1); i<argc; ++i) {
+ senf::detail::PacketRegistryImplBase::clear();
+ void *handle = dlopen(argv[i], RTLD_NOW | RTLD_GLOBAL);
+ if (handle == NULL) {
+ std::cerr << "could not load packet bundle " << argv[i] << ": "
+ << dlerror() << std::endl;
+ return 1;
+ }
+ }
+ senf::dumpPacketRegistries(std::cout);
+ return 0;
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+//#include "bundledump.mpp"
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
sources, tests, includes = SENFSCons.Glob(env)
-env.BoostUnitTest('test', tests + ['${LOCALLIBDIR}/AllBundles${OBJADDSUFFIX}${OBJSUFFIX}'])
+env.BoostUnitTest('test', tests + ['${ALLBUNDLES}'])
objects = env.Object(sources)
cobject = env.CombinedObject('${LOCALLIBDIR}/${NAME}${OBJADDSUFFIX}', objects, NAME=((name)))
+ sobundle = env.SharedLibrary('${LOCALLIBDIR}/${NAME}${OBJADDSUFFIX}', sources, NAME=((name)),
+ LIBS=[], SHLIBPREFIX='')
env.Default(cobject)
+ env.Default(sobundle)
env.Append(ALLOBJECTS = objects, PACKET_BUNDLES = cobject)
env.Install('$OBJINSTALLDIR', cobject)
+ env.Install('$OBJINSTALLDIR', sobundle)
if tests : env.BoostUnitTest('test', tests + cobject)
if includes : env.InstallSubdir('$INCLUDEINSTALLDIR', includes)
#!/bin/sh -e
-if [ -z "$1" ]; then
- echo "Usage:"
- echo " $0 [-c] <commands>"
- echo
- echo "-c Only list C/C++ source files"
- echo
- echo "<commands> are any find commands (which should contain a -print somewhere)"
- echo "which are matched for any file fond"
- exit 1
-fi
-
cond=""
if [ "$1" = "-c" ]; then
shift
-name ".sconsign*" -o \
-name "semantic.cache" -o \
-name "all_includes.hh" -o \
- -type f $cond \( "$@" \)
+ -type f $cond \( "$@" -print \)