Implement libPacket protocol bundles
g0dil [Tue, 22 May 2007 10:57:23 +0000 (10:57 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@246 270642c3-0616-0410-b53a-bc976706d245

43 files changed:
Examples/MCSniffer/MCSniffer.cc
Examples/MCSniffer/SConscript
Examples/Sniffer/SConscript
Examples/Sniffer/Sniffer.cc
Examples/TCPClientServer/client.cc
Examples/TCPClientServer/server.cc
Packets/DefaultBundle/EthernetPacket.cc [moved from Packets/EthernetPacket.cc with 100% similarity]
Packets/DefaultBundle/EthernetPacket.cti [moved from Packets/EthernetPacket.cti with 100% similarity]
Packets/DefaultBundle/EthernetPacket.hh [moved from Packets/EthernetPacket.hh with 97% similarity]
Packets/DefaultBundle/EthernetPacket.test.cc [moved from Packets/EthernetPacket.test.cc with 100% similarity]
Packets/DefaultBundle/IpV4Packet.cc [moved from Packets/IpV4Packet.cc with 100% similarity]
Packets/DefaultBundle/IpV4Packet.cti [moved from Packets/IpV4Packet.cti with 100% similarity]
Packets/DefaultBundle/IpV4Packet.hh [moved from Packets/IpV4Packet.hh with 97% similarity]
Packets/DefaultBundle/IpV4Packet.test.cc [moved from Packets/IpV4Packet.test.cc with 100% similarity]
Packets/DefaultBundle/IpV6Extensions.cc [moved from Packets/IpV6Extensions.cc with 100% similarity]
Packets/DefaultBundle/IpV6Extensions.ct [moved from Packets/IpV6Extensions.ct with 100% similarity]
Packets/DefaultBundle/IpV6Extensions.hh [moved from Packets/IpV6Extensions.hh with 100% similarity]
Packets/DefaultBundle/IpV6Extensions.test.cc [moved from Packets/IpV6Extensions.test.cc with 99% similarity]
Packets/DefaultBundle/IpV6Packet.cc [moved from Packets/IpV6Packet.cc with 100% similarity]
Packets/DefaultBundle/IpV6Packet.cti [moved from Packets/IpV6Packet.cti with 100% similarity]
Packets/DefaultBundle/IpV6Packet.hh [moved from Packets/IpV6Packet.hh with 96% similarity]
Packets/DefaultBundle/IpV6Packet.test.cc [moved from Packets/IpV6Packet.test.cc with 100% similarity]
Packets/DefaultBundle/SConscript [new file with mode: 0644]
Packets/DefaultBundle/UDPPacket.cc [moved from Packets/UDPPacket.cc with 98% similarity]
Packets/DefaultBundle/UDPPacket.cti [moved from Packets/UDPPacket.cti with 100% similarity]
Packets/DefaultBundle/UDPPacket.hh [moved from Packets/UDPPacket.hh with 95% similarity]
Packets/DefaultBundle/UDPPacket.test.cc [moved from Packets/UDPPacket.test.cc with 100% similarity]
Packets/DefaultBundle/main.test.cc [copied from Packets/RTCPPacket.cc with 85% similarity]
Packets/Doxyfile
Packets/PacketRegistry.hh
Packets/RTPBundle/RTCPPacket.cc [copied from Packets/RTCPPacket.cc with 100% similarity]
Packets/RTPBundle/RTCPPacket.cti [moved from Packets/RTCPPacket.cti with 100% similarity]
Packets/RTPBundle/RTCPPacket.hh [moved from Packets/RTCPPacket.hh with 98% similarity]
Packets/RTPBundle/RTCPPacket.test.cc [moved from Packets/RTCPPacket.test.cc with 100% similarity]
Packets/RTPBundle/RTPPacket.cc [moved from Packets/RTPPacket.cc with 100% similarity]
Packets/RTPBundle/RTPPacket.cti [moved from Packets/RTPPacket.cti with 100% similarity]
Packets/RTPBundle/RTPPacket.hh [moved from Packets/RTPPacket.hh with 98% similarity]
Packets/RTPBundle/RTPPacket.test.cc [moved from Packets/RTPPacket.test.cc with 98% similarity]
Packets/RTPBundle/SConscript [new file with mode: 0644]
Packets/RTPBundle/main.test.cc [moved from Packets/RTCPPacket.cc with 85% similarity]
Packets/SConscript
senfscons/BoostUnitTests.py
senfscons/SENFSCons.py

index f353b2c..1da14b6 100644 (file)
@@ -30,7 +30,7 @@
 #include <iomanip>
 #include "Socket/UDPSocketHandle.hh"
 #include "Scheduler/Scheduler.hh"
-#include "Packets/EthernetPacket.hh"
+#include "Packets/DefaultBundle/EthernetPacket.hh"
 #include "Utils/membind.hh"
 
 
index c7cab09..8d4e3b7 100644 (file)
@@ -4,4 +4,5 @@ import SENFSCons
 ###########################################################################
 
 SENFSCons.Binary(env, 'mcsniffer', SENFSCons.GlobSources(),
-                LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ]);
+                 LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ],
+                 OBJECTS = [ '#/Packets/DefaultBundle/DefaultBundle.o' ]);
index 8d68b85..6c1c57a 100644 (file)
@@ -4,4 +4,5 @@ import SENFSCons
 ###########################################################################
 
 SENFSCons.Binary(env, 'sniffer', SENFSCons.GlobSources(),
-                LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ]);
+                 LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ],
+                 OBJECTS = [ '#/Packets/DefaultBundle/DefaultBundle.o' ]);
index 9cf1883..2c43eb6 100644 (file)
 #include "Socket/PacketSocketHandle.hh"
 #include "Scheduler/Scheduler.hh"
 #include "Utils/membind.hh"
-
-#include "Packets/EthernetPacket.hh"
-#include "Packets/IpV4Packet.hh"
-#include "Packets/UDPPacket.hh"
+#include "Packets/DefaultBundle/EthernetPacket.hh"
 
 //#include "Sniffer.mpp"
 #define prefix_
@@ -81,12 +78,6 @@ namespace {
         std::cout << std::dec;
     }
 
-    void use_em()
-    {
-        // Pull in symbols from the wanted packets ...
-        senf::Packet::create<senf::IpV4Packet>(0,0);
-        senf::Packet::create<senf::UDPPacket>(0,0);
-    }
 }
 
 int loop_main (int argc, char const * argv[])
index 0297c41..e30c96e 100644 (file)
@@ -25,7 +25,6 @@
 #include <sstream>
 #include "Socket/TCPSocketHandle.hh"
 #include "Socket/INetAddressing.hh"
-#include "Packets/EthernetPacket.hh"
 
 
 int main(int argc, char const * argv[])
index 99991f7..a3b0374 100644 (file)
 
 // Custom includes
 #include <string>
+#include <iostream>
 #include "Scheduler/Scheduler.hh"
 #include "Utils/membind.hh"
 #include "Socket/TCPSocketHandle.hh"
 #include "Socket/INetAddressing.hh"
-#include "Packets/EthernetPacket.hh"
 
 
 class Server
similarity index 97%
rename from Packets/EthernetPacket.hh
rename to Packets/DefaultBundle/EthernetPacket.hh
index 8603c85..5dbec31 100644 (file)
 #define HH_EthernetPacket_ 1
 
 // Custom includes
-#include "Packet.hh"
-#include "ParseInt.hh"
-#include "ParseArray.hh"
-#include "PacketRegistry.hh"
+#include "Packets/Packet.hh"
+#include "Packets/ParseInt.hh"
+#include "Packets/ParseArray.hh"
+#include "Packets/PacketRegistry.hh"
 
 //#include "EthernetPacket.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
similarity index 97%
rename from Packets/IpV4Packet.hh
rename to Packets/DefaultBundle/IpV4Packet.hh
index c848d3a..94a3a91 100644 (file)
 #define HH_IpV4Packet_ 1
 
 // Custom includes
-#include "Packet.hh"
-#include "ParseInt.hh"
-#include "ParseArray.hh"
-#include "PacketRegistry.hh"
+#include "Packets/Packet.hh"
+#include "Packets/ParseInt.hh"
+#include "Packets/ParseArray.hh"
+#include "Packets/PacketRegistry.hh"
 
 //#include "IpV4Packet.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
similarity index 99%
rename from Packets/IpV6Extensions.test.cc
rename to Packets/DefaultBundle/IpV6Extensions.test.cc
index f0fed39..35c33f0 100644 (file)
@@ -28,7 +28,7 @@
 #include "IpV6Extensions.hh"
 #include "IpV6Packet.hh"
 #include "UDPPacket.hh"
-#include "DataPacket.hh"
+#include "Packets/DataPacket.hh"
 #include "Socket/INetAddressing.hh"
 
 #include <boost/test/auto_unit_test.hpp>
similarity index 96%
rename from Packets/IpV6Packet.hh
rename to Packets/DefaultBundle/IpV6Packet.hh
index fa8fdb1..32fd807 100644 (file)
 #define HH_IpV6Packet_ 1
 
 // Custom includes
-#include "Packet.hh"
-#include "ParseInt.hh"
-#include "ParseArray.hh"
-#include "PacketRegistry.hh"
+#include "Packets/Packet.hh"
+#include "Packets/ParseInt.hh"
+#include "Packets/ParseArray.hh"
+#include "Packets/PacketRegistry.hh"
 #include "IpV4Packet.hh"
 
 //#include "IpV6Packet.mpp"
diff --git a/Packets/DefaultBundle/SConscript b/Packets/DefaultBundle/SConscript
new file mode 100644 (file)
index 0000000..f096a68
--- /dev/null
@@ -0,0 +1,14 @@
+# -*- python -*-
+
+Import('env')
+import SENFSCons, glob
+
+###########################################################################
+
+sources = SENFSCons.GlobSources()
+
+SENFSCons.StandardTargets(env)
+
+SENFSCons.Object(env, target = 'DefaultBundle', sources=sources,
+                 LIBS = ['Packets', 'Socket', 'Utils'])
+                 
similarity index 98%
rename from Packets/UDPPacket.cc
rename to Packets/DefaultBundle/UDPPacket.cc
index a93f80f..d74e080 100644 (file)
@@ -27,7 +27,7 @@
 #include "IpV4Packet.hh"
 
 // Custom includes
-#include "DataPacket.hh"
+#include "Packets/DataPacket.hh"
 
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
similarity index 95%
rename from Packets/UDPPacket.hh
rename to Packets/DefaultBundle/UDPPacket.hh
index 2f54e93..bd0fc57 100644 (file)
 #define HH_UDPPacket_ 1
 
 // Custom includes
-#include "Packet.hh"
-#include "ParseInt.hh"
-#include "ParseArray.hh"
-#include "PacketRegistry.hh"
+#include "Packets/Packet.hh"
+#include "Packets/ParseInt.hh"
+#include "Packets/ParseArray.hh"
+#include "Packets/PacketRegistry.hh"
 
 //#include "UDPPacket.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
similarity index 85%
copy from Packets/RTCPPacket.cc
copy to Packets/DefaultBundle/main.test.cc
index 440532f..fd5cfe1 100644 (file)
@@ -1,4 +1,4 @@
-// $Id$
+// $Id: main.test.cc 206 2007-02-20 14:20:52Z g0dil $
 //
 // Copyright (C) 2006
 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
 
 // Definition of non-inline non-template functions
 
-#include "RTCPPacket.hh"
-//#include "RTCPPacket.ih"
+//#include "test.hh"
+//#include "test.ih"
 
 // Custom includes
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
 
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
 
-prefix_ void senf::RTCPPacket::v_nextInterpreter()
-    const
-{
-    registerInterpreter<DataPacket>(begin()+bytes(),end());
-}
-
-prefix_ void senf::RTCPPacket::v_finalize()
-{}
-
-
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 
index 2e7c41a..a7fcd33 100644 (file)
@@ -2,4 +2,5 @@
 
 PROJECT_NAME = libPackets
 TAGFILES = "$(TOPDIR)/Utils/doc/Utils.tag"
-GENERATE_TAGFILE = doc/Packets.tag
\ No newline at end of file
+GENERATE_TAGFILE = doc/Packets.tag
+INPUT = . DefaultBundle RTPBundle
\ No newline at end of file
index 93f951a..da9964a 100644 (file)
@@ -89,9 +89,6 @@ namespace senf {
     {
     public:
         /** \brief Statically register a packet type in a PacketRegistry
-
-            \fixme This fails to work within a library since the linker will
-            remove all unused object files ...
          */
         template <class OtherPacket>
         struct RegistrationProxy
similarity index 98%
rename from Packets/RTCPPacket.hh
rename to Packets/RTPBundle/RTCPPacket.hh
index 1d566cb..da4d25a 100644 (file)
 #define HH_RTCPPacket_ 1
 
 // Custom includes
-#include "Packet.hh"
-#include "ParseInt.hh"
-#include "ParseArray.hh"
-#include "ParseListS.hh"
-#include "ParseVec.hh"
-#include "PacketRegistry.hh"
+#include "Packets/Packet.hh"
+#include "Packets/ParseInt.hh"
+#include "Packets/ParseArray.hh"
+#include "Packets/ParseListS.hh"
+#include "Packets/ParseVec.hh"
+#include "Packets/PacketRegistry.hh"
 
 //#include "RTCPPacket.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
similarity index 98%
rename from Packets/RTPPacket.hh
rename to Packets/RTPBundle/RTPPacket.hh
index 823487a..1f281f5 100644 (file)
 #define HH_RTPPacket_ 1
 
 // Custom includes
-#include "Packet.hh"
-#include "ParseInt.hh"
-#include "ParseArray.hh"
-#include "ParseVec.hh"
-#include "PacketRegistry.hh"
+#include "Packets/Packet.hh"
+#include "Packets/ParseInt.hh"
+#include "Packets/ParseArray.hh"
+#include "Packets/ParseVec.hh"
+#include "Packets/PacketRegistry.hh"
 
 //#include "RTPPacket.mpp"
 ///////////////////////////////hh.p////////////////////////////////////////
similarity index 98%
rename from Packets/RTPPacket.test.cc
rename to Packets/RTPBundle/RTPPacket.test.cc
index 9711b18..1f0da11 100644 (file)
@@ -28,9 +28,9 @@
 // Custom includes
 #include "RTPPacket.hh"
 
-#include "EthernetPacket.hh"
-#include "IpV4Packet.hh"
-#include "UDPPacket.hh"
+#include "Packets/DefaultBundle/EthernetPacket.hh"
+#include "Packets/DefaultBundle/IpV4Packet.hh"
+#include "Packets/DefaultBundle/UDPPacket.hh"
 
 #include <boost/test/auto_unit_test.hpp>
 #include <boost/test/test_tools.hpp>
diff --git a/Packets/RTPBundle/SConscript b/Packets/RTPBundle/SConscript
new file mode 100644 (file)
index 0000000..fe9bc76
--- /dev/null
@@ -0,0 +1,15 @@
+# -*- python -*-
+
+Import('env')
+import SENFSCons, glob
+
+###########################################################################
+
+sources = SENFSCons.GlobSources()
+
+SENFSCons.StandardTargets(env)
+
+SENFSCons.Object(env, target = 'RTPBundle', sources=sources,
+                 LIBS = ['Packets', 'Socket', 'Utils'],
+                 OBJECTS = ['#/Packets/DefaultBundle/DefaultBundle.o'])
+                 
similarity index 85%
rename from Packets/RTCPPacket.cc
rename to Packets/RTPBundle/main.test.cc
index 440532f..fd5cfe1 100644 (file)
@@ -1,4 +1,4 @@
-// $Id$
+// $Id: main.test.cc 206 2007-02-20 14:20:52Z g0dil $
 //
 // Copyright (C) 2006
 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
 
 // Definition of non-inline non-template functions
 
-#include "RTCPPacket.hh"
-//#include "RTCPPacket.ih"
+//#include "test.hh"
+//#include "test.ih"
 
 // Custom includes
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/test/test_tools.hpp>
 
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
 
-prefix_ void senf::RTCPPacket::v_nextInterpreter()
-    const
-{
-    registerInterpreter<DataPacket>(begin()+bytes(),end());
-}
-
-prefix_ void senf::RTCPPacket::v_finalize()
-{}
-
-
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 
index b39aa65..27f0650 100644 (file)
@@ -1,7 +1,7 @@
 # -*- python -*-
 
 Import('env')
-import SENFSCons
+import SENFSCons, glob
 
 ###########################################################################
 
@@ -17,3 +17,5 @@ SENFSCons.Lib(env,
 SENFSCons.Doxygen(env, extra_sources = [
     env.Dia2Png("structure.dia")
 ])
+
+SConscript(glob.glob("*/SConscript"))
index e6aed7a..2dce3ba 100644 (file)
@@ -26,7 +26,7 @@ import SCons.Defaults
 import os.path
 import os
 
-def BoostUnitTests(env, target, source, test_source=None, LIBS = [], DEPENDS = [], **kw):
+def BoostUnitTests(env, target, source, test_source=None, LIBS = [], OBJECTS = [], DEPENDS = [], **kw):
     path, name = os.path.split(target)
     if test_source:
         if type(test_source) is not type([]):
@@ -38,7 +38,7 @@ def BoostUnitTests(env, target, source, test_source=None, LIBS = [], DEPENDS = [
     testEnv.Prepend(LIBS = LIBS)
     sources = []
     if source:
-        sources = sources + env.Object(source)
+        sources = sources + env.Object(source) + OBJECTS
     sources = sources + test_source
     binName = os.path.join(path,'.' + name +'.bin')
     testRunner = testEnv.Program(binName, sources)
index d87f229..c676f34 100644 (file)
@@ -292,7 +292,7 @@ def LibPath(lib): return '$LOCALLIBDIR/lib%s.a' % lib
 # provide both \a sources and \a testSources.
 #
 # \ingroup target
-def Objects(env, sources, testSources = None, LIBS = []):
+def Objects(env, sources, testSources = None, LIBS = [], OBJECTS = []):
     if type(sources) == type(()):
         testSources = sources[1]
         sources = sources[0]
@@ -307,6 +307,7 @@ def Objects(env, sources, testSources = None, LIBS = []):
             source = sources,
             test_source = testSources,
             LIBS = LIBS,
+            OBJECTS = OBJECTS,
             DEPENDS = [ env.File(LibPath(x)) for x in LIBS ])
         env.Alias('all_tests', test)
         # Hmm ... here I'd like to use an Alias instead of a file
@@ -493,8 +494,8 @@ def DoxyXRef(env, docs=None,
 # The library is added to the list of default targets.
 #
 #\ingroup target
-def Lib(env, library, sources, testSources = None, LIBS = []):
-    objects = Objects(env,sources,testSources,LIBS=LIBS)
+def Lib(env, library, sources, testSources = None, LIBS = [], OBJECTS = []):
+    objects = Objects(env,sources,testSources,LIBS=LIBS,OBJECTS=OBJECTS)
     lib = None
     if objects:
         lib = env.Library(env.File(LibPath(library)),objects)
@@ -502,6 +503,15 @@ def Lib(env, library, sources, testSources = None, LIBS = []):
         env.Append(ALLLIBS = library)
     return lib
 
+## \brief Build Object from multiple sources
+def Object(env, target, sources, testSources = None, LIBS = [], OBJECTS = []):
+    objects = Objects(env,sources,testSources,LIBS=LIBS,OBJECTS=OBJECTS)
+    ob = None
+    if objects:
+        ob = env.Command(target+".o", objects, "ld -r -o $TARGET $SOURCES")
+        env.Default(ob)
+    return ob
+
 ## \brief Build executable
 #
 # This target helper will build the given binary.  The \a sources, \a
@@ -512,13 +522,13 @@ def Lib(env, library, sources, testSources = None, LIBS = []):
 # construction environment parameters or the framework helpers.
 #
 # \ingroup target
-def Binary(env, binary, sources, testSources = None, LIBS = []):
-    objects = Objects(env,sources,testSources,LIBS=LIBS)
+def Binary(env, binary, sources, testSources = None, LIBS = [], OBJECTS = []):
+    objects = Objects(env,sources,testSources,LIBS=LIBS,OBJECTS=OBJECTS)
     program = None
     if objects:
         progEnv = env.Copy()
         progEnv.Prepend(LIBS = LIBS)
-        program = progEnv.Program(target=binary,source=objects)
+        program = progEnv.Program(target=binary,source=objects+OBJECTS)
         env.Default(program)
         env.Depends(program, [ env.File(LibPath(x)) for x in LIBS ])
     return program