From: tho Date: Mon, 13 Sep 2010 07:42:14 +0000 (+0000) Subject: Packet: added Packet::reparse() and ::clearAnnotations() member X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=a518319a80169b48c8dccfeb82ed2834d3eebd75;p=senf.git Packet: added Packet::reparse() and ::clearAnnotations() member Scheduler: fixed slight compiler warning on final build SConstruct: increased g++ inline-unit-growth git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1713 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/SConstruct b/SConstruct index 8b5429c..ee0c64e 100644 --- a/SConstruct +++ b/SConstruct @@ -101,7 +101,7 @@ env.Append( '--param','large-function-growth=10000', '--param', 'large-function-insns=10000', '--param','inline-unit-growth=10000' ], - INLINE_OPTS_NORMAL = [ '-finline-limit=5000' ], + INLINE_OPTS_NORMAL = [ '-finline-limit=5000', '--param', 'inline-unit-growth=60' ], INLINE_OPTS = [ '$INLINE_OPTS_NORMAL' ], CXXFLAGS = [ '-Wall', '-Woverloaded-virtual', '-Wno-long-long', '$INLINE_OPTS', '-pipe', '$CXXFLAGS_', '-fno-strict-aliasing' ], diff --git a/senf/Packets/Packet.cci b/senf/Packets/Packet.cci index cb9e4de..ef46112 100644 --- a/senf/Packets/Packet.cci +++ b/senf/Packets/Packet.cci @@ -130,7 +130,6 @@ prefix_ senf::Packet::size_type senf::Packet::size() return data().size(); } - // Other methods prefix_ bool senf::Packet::operator==(Packet const & other) @@ -197,6 +196,17 @@ prefix_ bool senf::Packet::is_shared() return ptr()->is_shared() || (ptr()->impl().refcount() > 1); } +prefix_ void senf::Packet::reparse() + const +{ + return ptr()->reparse(); +} + +prefix_ void senf::Packet::clearAnnotations() +{ + return ptr()->clearAnnotations(); +} + template prefix_ Parser senf::operator<<(Parser target, ConcretePacket const & packet) { diff --git a/senf/Packets/Packet.hh b/senf/Packets/Packet.hh index 6693d0d..cc9c9f2 100644 --- a/senf/Packets/Packet.hh +++ b/senf/Packets/Packet.hh @@ -309,6 +309,10 @@ namespace senf { after \c this in the packet/header/interpreter chain. */ + void reparse() const; ///< Reparse the payload the packet + /**< This member will throw away the packet chain after the + current packet. The payload will be reparsed + automatically when calling next() */ ///@} ///\name Data access @@ -319,7 +323,6 @@ namespace senf { /**< This size does \e not include the size of any preceding headers/packets/interpreters. It does however include \c this packets payload. */ - ///@} ///\name Annotations @@ -382,12 +385,17 @@ namespace senf { considering that the packetimpl itself uses a pool. */ - ///@} - template Annotation const & annotation() const; ///< Get packet annotation /**< \see annotation() */ + void clearAnnotations(); ///< Clear all packet annotations + /**< All packet annotations will be cleared. Afterwards + the annotations equates to a new created %packet. + \warning all references to existing complex + annotations become invalid. */ + ///@} + ///\name Other methods ///@{ @@ -750,14 +758,14 @@ namespace senf { access. The parser class may have any member which is needed for full packet access (e.g. checksum validation / recreation ...) - \see \ref packetparser for the parser interface. */ + \see \ref packetparser for the %parser interface. */ Parser parser() const; ///< Access packet field parser directly /**< Access the parser of the packet. This is the same object returned by the operator->() operator. The operator however does not allow to access this object itself, only it's members. - \see \ref packetparser for the parser interface */ + \see \ref packetparser for the %parser interface */ protected: diff --git a/senf/Packets/Packet.test.cc b/senf/Packets/Packet.test.cc index 557e7f8..1684a88 100644 --- a/senf/Packets/Packet.test.cc +++ b/senf/Packets/Packet.test.cc @@ -349,6 +349,11 @@ SENF_AUTO_UNIT_TEST(packetAnnotation) BOOST_CHECK_EQUAL( p2.annotation().s, "dead beef" ); BOOST_CHECK_EQUAL( p2.annotation().i, 0x12345678 ); + p2.clearAnnotations(); + BOOST_CHECK_EQUAL( p2.annotation().s, "empty" ); + BOOST_CHECK_EQUAL( p2.annotation().i, -1 ); + BOOST_CHECK_EQUAL( p2.annotation().value, 0 ); + BOOST_CHECK( Reg::lookup() >= 0 ); BOOST_CHECK( Reg::lookup() < 0 ); BOOST_CHECK( Reg::lookup() < 0 ); diff --git a/senf/Packets/PacketImpl.cc b/senf/Packets/PacketImpl.cc index 0c38d46..c374e6d 100644 --- a/senf/Packets/PacketImpl.cc +++ b/senf/Packets/PacketImpl.cc @@ -156,6 +156,12 @@ prefix_ void senf::detail::PacketImpl::dumpAnnotations(std::ostream & os) } } +prefix_ void senf::detail::PacketImpl::clearAnnotations() +{ + ::memset(simpleAnnotations_, 0, sizeof(simpleAnnotations_)); + complexAnnotations_.clear(); +} + prefix_ void * senf::detail::PacketImpl::complexAnnotation(AnnotationRegistry::key_type key) { SENF_ASSERT( key < 0, "complexAnnotation called with invalid key"); diff --git a/senf/Packets/PacketImpl.hh b/senf/Packets/PacketImpl.hh index 2900044..32b2acf 100644 --- a/senf/Packets/PacketImpl.hh +++ b/senf/Packets/PacketImpl.hh @@ -171,6 +171,7 @@ namespace detail { template Annotation & annotation(); + void clearAnnotations(); void dumpAnnotations(std::ostream & os); /** \brief Internal: Keep PacketImpl instance alive diff --git a/senf/Packets/PacketInterpreter.cc b/senf/Packets/PacketInterpreter.cc index cb94b8d..3b03742 100644 --- a/senf/Packets/PacketInterpreter.cc +++ b/senf/Packets/PacketInterpreter.cc @@ -70,6 +70,12 @@ prefix_ senf::PacketInterpreterBase::ptr senf::PacketInterpreterBase::append(ptr return rv; } +prefix_ void senf::PacketInterpreterBase::reparse() +{ + if (next()) + impl().truncateInterpreters(next().get()); +} + // Access to the abstract interface prefix_ void senf::PacketInterpreterBase::dump(std::ostream & os) diff --git a/senf/Packets/PacketInterpreter.cci b/senf/Packets/PacketInterpreter.cci index 40d2531..470ed65 100644 --- a/senf/Packets/PacketInterpreter.cci +++ b/senf/Packets/PacketInterpreter.cci @@ -98,6 +98,11 @@ prefix_ senf::PacketInterpreterBase::factory_t senf::PacketInterpreterBase::next return v_nextPacketType(); } +prefix_ void senf::PacketInterpreterBase::clearAnnotations() +{ + return impl().clearAnnotations(); +} + //////////////////////////////////////// // protected members diff --git a/senf/Packets/PacketInterpreter.hh b/senf/Packets/PacketInterpreter.hh index fa9ed46..4f9ae70 100644 --- a/senf/Packets/PacketInterpreter.hh +++ b/senf/Packets/PacketInterpreter.hh @@ -153,6 +153,8 @@ namespace senf { ptr append(ptr packet); + void reparse(); + ///@} ///\name Data access @@ -169,6 +171,8 @@ namespace senf { template Annotation & annotation(); + void clearAnnotations(); + ///@} ///\name Access to the abstract interface diff --git a/senf/Packets/VectorParser.hh b/senf/Packets/VectorParser.hh index c3fabc6..d914a5f 100644 --- a/senf/Packets/VectorParser.hh +++ b/senf/Packets/VectorParser.hh @@ -27,9 +27,6 @@ #define HH_SENF_Packets_VectorParser_ 1 // Custom includes -#include -#include -#include #include #include "PacketParser.hh" #include "ArrayParser.hh" // for ArrayParser_iterator diff --git a/senf/Scheduler/FIFORunner.cc b/senf/Scheduler/FIFORunner.cc index 94009c3..af748e6 100644 --- a/senf/Scheduler/FIFORunner.cc +++ b/senf/Scheduler/FIFORunner.cc @@ -253,10 +253,6 @@ prefix_ void senf::scheduler::detail::FIFORunner::watchdog(int, siginfo_t * si, prefix_ void senf::scheduler::detail::FIFORunner::watchdogError() { - static char const hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'a', 'b', 'c', 'd', 'e', 'f' }; - static void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS]; - // We don't care if the write commands below fail, we just give our best to inform the user senf::IGNORE( write(1, "\n\n*** Scheduler task hanging (pid ",34) ); static char pid[7]; @@ -267,6 +263,9 @@ prefix_ void senf::scheduler::detail::FIFORunner::watchdogError() senf::IGNORE( write(1, runningName_.c_str(), runningName_.size()) ); senf::IGNORE( write(1, " at\n ", 3) ); #ifdef SENF_DEBUG + static char const hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f' }; + static void * entries[SENF_DEBUG_BACKTRACE_NUMCALLERS]; unsigned nEntries( ::backtrace(entries, SENF_DEBUG_BACKTRACE_NUMCALLERS) ); for (unsigned i (0); i < nEntries; ++i) { senf::IGNORE( write(1, " 0x", 3) ); diff --git a/senf/Scheduler/ReadHelper.hh b/senf/Scheduler/ReadHelper.hh index ee91997..1748791 100644 --- a/senf/Scheduler/ReadHelper.hh +++ b/senf/Scheduler/ReadHelper.hh @@ -39,7 +39,7 @@ namespace senf { - /** \brief Asyncronous reading helper + /** \brief Asynchronous reading helper This class provides a simple asynchronous reading facility. This helper will register with the Scheduler and read incoming data. It will collect the data until a specific number of diff --git a/senf/Scheduler/Scheduler.hh b/senf/Scheduler/Scheduler.hh index 6ecef0d..385e477 100644 --- a/senf/Scheduler/Scheduler.hh +++ b/senf/Scheduler/Scheduler.hh @@ -60,7 +60,7 @@ namespace senf { The Scheduler is based on the RAII principle: Every event is represented by a class instance. The event is registered in the constructor and removed by the destructor of that instance. This implementation automatically links the lifetime of an event with the lifetime of - the object resposible for it's creation. + the object responsible for it's creation. Every event registration is represented by an instance of an event specific class: diff --git a/senf/Scheduler/WriteHelper.hh b/senf/Scheduler/WriteHelper.hh index 2a19577..0d92962 100644 --- a/senf/Scheduler/WriteHelper.hh +++ b/senf/Scheduler/WriteHelper.hh @@ -36,7 +36,7 @@ namespace senf { - /** \brief Asyncronous writing helper + /** \brief Asynchronous writing helper This class provides a simple asynchronous writing facility. This helper will register with the Scheduler to write the requested data. It will stay registered until the data has been diff --git a/tools/senf.dict b/tools/senf.dict index dfac3bf..7b07341 100644 --- a/tools/senf.dict +++ b/tools/senf.dict @@ -103,6 +103,7 @@ ct cti CXXFLAGS daemonization +datagram DatagramSection DataPacket datarate @@ -111,12 +112,14 @@ de DEBUGINFO DebugModules decapsulated +decorator DefaultArea DefaultBundle defaultInit defgroup deinitEmulationInterface deque +destructor dia dil dir @@ -329,6 +332,7 @@ mac MACAddress MACAddressParser mainpage +malformed manualparse maxTxPowerIndex Mbit @@ -338,6 +342,7 @@ mcDropMembership mcLoop mem memberfn +membind Mhz min mixin @@ -376,6 +381,8 @@ namespace nbar nc nChannels +neighbour +neighbours netcat NetEmu NETwork @@ -471,6 +478,7 @@ PassiveQueue PassiveSink PassiveSocketWriter PassiveSource +payload pencolor png POPD @@ -503,6 +511,7 @@ ReadInfo receiveModule ReceiverDecorator receiverJack +ref refcount regex registerEvent @@ -510,6 +519,7 @@ registerPacket registerPacketType registerSomePacket RegistrationProxy +registry ReportPacket repos rerference @@ -683,6 +693,7 @@ Ver vlanId VLanId VoidPacketParser +watchdog WiredInterface WiredReceiver WiredTransmitter