From: tho Date: Wed, 4 Feb 2009 13:30:23 +0000 (+0000) Subject: Packets documentation updates X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=f7dcc6267c7637efaba2ebe5a20df5f849a68d39 Packets documentation updates git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1098 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Makefile b/Makefile index 250155c..b09752e 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,9 @@ all_docs all_tests all: %/test %/doc: $(SCONS) $@ +%/build: + $(SCONS) $* + #---------------------------------------------------------------------- # Subversion stuff #---------------------------------------------------------------------- diff --git a/Packets/80221Bundle/MIHPacket.hh b/Packets/80221Bundle/MIHPacket.hh index 9c7f103..ede5f41 100644 --- a/Packets/80221Bundle/MIHPacket.hh +++ b/Packets/80221Bundle/MIHPacket.hh @@ -44,7 +44,7 @@ namespace senf { // the maximum length of a MIHF_ID is 253 octets (see F.3.11 in 802.21) // we could set maxLengthValue in INIT, but for the most MIHF_IDs the default // maximum length of 127 should be enough. - // The user must call mihPacket->src_mihfId().maxLengthValue( 127) before + // The user must call mihPacket->src_mihfId().maxLengthValue( 253) before // setting longer MIHF_IDs class MIHFId_TLVParser : public BaseTLVPacketParser { @@ -94,6 +94,13 @@ namespace senf { } }; + /** \brief Parse a MIH packet + + Parser implementing the MIH header. The fields implemented are: + \image html MIHPacket.png + + \see MIHPacketType + */ struct MIHPacketParser : public PacketParserBase { # include SENF_PARSER() @@ -138,7 +145,6 @@ namespace senf { \par Fields: \ref MIHPacketParser - \image html MIHPacket.png \ingroup protocolbundle_80221 */ @@ -146,19 +152,23 @@ namespace senf { : public PacketTypeBase, public PacketTypeMixin { +#ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef MIHPacketParser parser; +#endif + typedef ConcretePacket packet; ///< MIH packet typedef + typedef MIHPacketParser parser; ///< typedef to the parser of MIH packet using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + /** \brief Dump given MIH packet in readable form to given output stream */ static void dump(packet p, std::ostream &os); static void finalize(packet p); static factory_t nextPacketType(packet p); }; + /** \brief MIH packet typedef */ typedef ConcretePacket MIHPacket; @@ -174,20 +184,22 @@ namespace senf { : public PacketTypeBase, public PacketTypeMixin { +#ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef MIHPayloadPacketParser parser; +#endif + typedef ConcretePacket packet; ///< MIH Payload packet typedef + typedef MIHPayloadPacketParser parser; ///< typedef to the parser of MIH Payload packet using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + /** \brief Dump given MIHPayload in readable form to given output stream */ static void dump(packet p, std::ostream &os); }; + /** \brief MIH Payload packet typedef */ typedef ConcretePacket MIHPayloadPacket; - - } diff --git a/Packets/80221Bundle/TLV.dia b/Packets/80221Bundle/TLV.dia new file mode 100644 index 0000000..d3f9ab5 Binary files /dev/null and b/Packets/80221Bundle/TLV.dia differ diff --git a/Packets/80221Bundle/TLVPacket.hh b/Packets/80221Bundle/TLVPacket.hh index c337aec..bf0ce2e 100644 --- a/Packets/80221Bundle/TLVPacket.hh +++ b/Packets/80221Bundle/TLVPacket.hh @@ -71,27 +71,80 @@ namespace senf { }; + /** \brief Base class for TLV-Packet-Parsers + + BaseTLVPacketParser is the abstract base class for TLV-Packet-Parsers. It defines the + \ref type() field as an \ref senf::UInt8Parser and the \ref length() field as a + DynamicTLVLengthParser. The length field is read-only. + + To create your own \c TLVParser you have to inherit from BaseTLVPacketParser (don't + forget \ref SENF_PARSER_INHERIT) and define the \c value field. In the following example + the value is a vector of MacAddresses: + \code + struct MacAddressesTLVParser : public BaseTLVPacketParser { + # include SENF_PARSER() + SENF_PARSER_INHERIT ( BaseTLVPacketParser ); + SENF_PARSER_VECTOR ( value, bytes(length), senf::MACAddressParser ); + SENF_PARSER_FINALIZE( MacAddressesTLVParser ); + }; + + struct MacAddressesTLVPacketType : public PacketTypeBase { + typedef MacAddressesTLVParser parser; + ... + static void finalize(ConcretePacket p) { + p->shrinkLength(); + } + }; + \endcode + + You have to adjust the maximum length value with the \ref maxLengthValue function + before the length value is set. The default maximum value is 127. So, in the above + example adding more than 21 MACAddresses to the vector will throw a TLVLengthException + if you don't call \c macAddressesTLVPacket->maxLengthValue( \e some_value) before. + + \see DynamicTLVLengthParser \n + GenericTLVPacketParser \n + */ class BaseTLVPacketParser : public PacketParserBase { + public: # include SENF_PARSER() SENF_PARSER_FIELD ( type, UInt8Parser ); SENF_PARSER_FIELD_RO ( length, DynamicTLVLengthParser ); SENF_PARSER_FINALIZE ( BaseTLVPacketParser ); + /** \brief set maximum value of length field + + The size of the length field will be increased if necessary. + \param v maximum value of length field + */ void maxLengthValue(DynamicTLVLengthParser::value_type v) const { length_().maxValue(v); } + + /** \brief shrink size of length field to minimum + + The size of the length field will be decreased to minimum necessary to hold + the current length value. + */ void shrinkLength() { length_().shrink(); }; protected: + /// return size of length field size_type length_bytes() const { return length_().bytes(); }; + /// set length field to given value void length(DynamicTLVLengthParser::value_type &v) { length_() = v; }; + /// resize the Packet after the length field to given size senf::safe_data_iterator resizeValue(DynamicTLVLengthParser::value_type size); }; + /** \brief Parser for a generic TLV packet + + \see GenericTLVPacketType + */ struct GenericTLVPacketParser : public BaseTLVPacketParser { # include SENF_PARSER() @@ -109,22 +162,38 @@ namespace senf { void value(ForwardReadableRange const &range); }; + /** \brief Generic TLV packet + + \par Packet type (typedef): + \ref GenericTLVPacket + + \image html TLV.png + + \ingroup protocolbundle_80221 + */ struct GenericTLVPacketType : public PacketTypeBase, public PacketTypeMixin { +#ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef GenericTLVPacketParser parser; +#endif + typedef ConcretePacket packet; ///< GenericTLV packet typedef + typedef GenericTLVPacketParser parser; ///< typedef to the parser of GenericTLV packet using mixin::nextPacketRange; using mixin::init; using mixin::initSize; - static void finalize(packet p); - static void dump(packet p, std::ostream & os); + /** \brief Dump given GenericTLVPacket in readable form to given output stream */ + static void dump(packet p, std::ostream & os); + static void finalize(packet p); ///< Finalize packet. + /**< shrink size of length field to minimum + \see BaseTLVPacketParser::shrinkLength() */ + }; + /** \brief GenericTLV packet typedef */ typedef ConcretePacket GenericTLVPacket; } diff --git a/Packets/DefaultBundle/EthernetPacket.hh b/Packets/DefaultBundle/EthernetPacket.hh index 8286e88..4332391 100644 --- a/Packets/DefaultBundle/EthernetPacket.hh +++ b/Packets/DefaultBundle/EthernetPacket.hh @@ -85,7 +85,6 @@ namespace senf { \ref PacketRegistry */ struct EtherTypes { - // See typedef boost::uint16_t key_t; }; @@ -110,7 +109,9 @@ namespace senf { : public PacketTypeBase, public PacketTypeMixin { +#ifndef DOXYGEN typedef PacketTypeMixin mixin; +#endif typedef ConcretePacket packet; typedef EthernetPacketParser parser; @@ -119,7 +120,8 @@ namespace senf { using mixin::init; static factory_t nextPacketType(packet p); - static void dump(packet p, std::ostream & os); + /// Dump given EthernetPacket in readable form to given output stream + static void dump(packet p, std::ostream & os); static void finalize(packet p); }; @@ -166,7 +168,9 @@ namespace senf { : public PacketTypeBase, public PacketTypeMixin { +#ifndef DOXYGEN typedef PacketTypeMixin mixin; +#endif typedef ConcretePacket packet; typedef EthVLanPacketParser parser; @@ -180,6 +184,7 @@ namespace senf { static key_t nextPacketKey(packet p) { return p->type(); } + /// Dump given EthVLanPacket in readable form to given output stream static void dump(packet p, std::ostream & os); static void finalize(packet p); }; diff --git a/Packets/DefaultBundle/IPv4Packet.hh b/Packets/DefaultBundle/IPv4Packet.hh index 0dc7917..e124ee4 100644 --- a/Packets/DefaultBundle/IPv4Packet.hh +++ b/Packets/DefaultBundle/IPv4Packet.hh @@ -60,6 +60,8 @@ namespace senf { Parser implementing the IPv4 header. + \image html IPv4Packet.png + \see IPv4PacketType \n RFC 791 @@ -76,10 +78,10 @@ namespace senf { SENF_PARSER_FIELD( length, UInt16Parser ); SENF_PARSER_FIELD( identifier, UInt16Parser ); - SENF_PARSER_BITFIELD( reserved, 1, bool ); - SENF_PARSER_BITFIELD( df, 1, bool ); - SENF_PARSER_BITFIELD( mf, 1, bool ); - SENF_PARSER_BITFIELD( frag, 13, unsigned ); + SENF_PARSER_PRIVATE_BITFIELD( reserved, 1, bool ); + SENF_PARSER_BITFIELD ( df, 1, bool ); + SENF_PARSER_BITFIELD ( mf, 1, bool ); + SENF_PARSER_BITFIELD ( frag, 13, unsigned ); SENF_PARSER_FIELD( ttl, UInt8Parser ); SENF_PARSER_FIELD( protocol, UInt8Parser ); @@ -95,11 +97,16 @@ namespace senf { SENF_PARSER_FINALIZE(IPv4PacketParser); - boost::uint16_t calcChecksum() const; + boost::uint16_t calcChecksum() const; ///< calculate header checksum + /**< calculate and return the checksum of the header + \see \ref senf::IpChecksum */ bool validateChecksum() const { return checksum() == calcChecksum(); - } + } ///< validate header checksum + /**< return \c true if the \ref checksum() "checksum" + field is equal to the \ref calcChecksum() + "calculated checksum" */ }; /** \brief IP protocol number registry @@ -114,6 +121,12 @@ namespace senf { }; /** \brief IPv4 packet + + \par Packet type (typedef): + \ref IPv4Packet + + \par Fields: + see \ref IPv4PacketParser @@ -129,7 +142,7 @@ namespace senf { - + @@ -143,23 +156,13 @@ namespace senf {
\ref IPv4PacketParser::length() "Length"
\ref IPv4PacketParser::identifier() "Identifier"\ref IPv4PacketParser::reserved() "R"R \ref IPv4PacketParser::df() "DF" \ref IPv4PacketParser::mf() "MF" \ref IPv4PacketParser::frag() "Fragment Offset"\ref IPv4PacketParser::destination() "Destination Address"
- - \par Packet type (typedef): - \ref IPv4Packet - - \par Fields: - \ref IPv4PacketParser \par Associated registries: \ref IpTypes \par Finalize action: - Set \a length from payload size\n - Set \a protocol from type of next packet if found in \ref IpTypes\n - Calculate \a checksum - - \image html IPv4Packet.png - + \copydetails finalize() + \ingroup protocolbundle_default */ struct IPv4PacketType @@ -168,9 +171,10 @@ namespace senf { { #ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef IPv4PacketParser parser; #endif + typedef ConcretePacket packet; ///< IPv4 packet typedef + typedef IPv4PacketParser parser; ///< typedef to the parser of IPv4 packet + using mixin::nextPacketRange; using mixin::nextPacketType; using mixin::initSize; @@ -178,11 +182,19 @@ namespace senf { static key_t nextPacketKey(packet p) { return p->protocol(); } - - static void dump(packet p, std::ostream & os); - static void finalize(packet p); - }; + /** \brief Dump given IPv4Packet in readable form to given output stream */ + static void dump(packet p, std::ostream & os); + + static void finalize(packet p); ///< Finalize packet. + /**< \li set \ref IPv4PacketParser::length() "length" + from payload size + \li set \ref IPv4PacketParser::protocol() "protocol" + from type of next packet if found in \ref IpTypes + \li calculate and set + \ref IPv4PacketParser::checksum() "checksum" */ + }; + /** \brief IPv4 packet typedef */ typedef ConcretePacket IPv4Packet; } @@ -191,7 +203,7 @@ namespace senf { ///////////////////////////////hh.e//////////////////////////////////////// #endif #ifndef SENF_PACKETS_DECL_ONLY -//#include IPv4Packet.cci" +//#include "IPv4Packet.cci" //#include "IPv4Packet.ct" //#include "IPv4Packet.cti" #endif diff --git a/Packets/DefaultBundle/IPv4Packet.test.cc b/Packets/DefaultBundle/IPv4Packet.test.cc index 423e19f..9f1eb94 100644 --- a/Packets/DefaultBundle/IPv4Packet.test.cc +++ b/Packets/DefaultBundle/IPv4Packet.test.cc @@ -54,7 +54,6 @@ BOOST_AUTO_UNIT_TEST(ipV4Packet_packet) BOOST_CHECK_EQUAL( p->tos(), 0x02u ); BOOST_CHECK_EQUAL( p->length(), 0x0304u ); BOOST_CHECK_EQUAL( p->identifier(), 0x0506u ); - BOOST_CHECK_EQUAL( p->reserved(), 0 ); BOOST_CHECK_EQUAL( p->df(), 0 ); BOOST_CHECK_EQUAL( p->mf(), 0 ); BOOST_CHECK_EQUAL( p->frag(), 0x0708u ); diff --git a/Packets/DefaultBundle/IPv6Extensions.hh b/Packets/DefaultBundle/IPv6Extensions.hh index d2e9de0..4a88310 100644 --- a/Packets/DefaultBundle/IPv6Extensions.hh +++ b/Packets/DefaultBundle/IPv6Extensions.hh @@ -37,6 +37,7 @@ namespace senf { /** \brief Parse in IPv6 fragment extension header Parser implementing the IPv6 fragment extension. The fields implemented are: + \image html IPv6Extensions_Fragment.png \see IPv6ExtensionType_Fragment \n RFC 2460 @@ -66,13 +67,11 @@ namespace senf { \ref IPv6PacketParserExtension_Fragment \par Associated registries: - \par IpTypes + \ref IpTypes \par Finalize action: Set \a nextHeader from type of next packet if found in \ref IpTypes - \image html IPv6Extensions_Fragment.png - \ingroup protocolbundle_default */ struct IPv6ExtensionType_Fragment @@ -81,9 +80,12 @@ namespace senf { { #ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef IPv6PacketParserExtension_Fragment parser; #endif + /** \brief IPv6 fragment extension packet typedef */ + typedef ConcretePacket packet; + /** \brief typedef to the parser of IPv6 fragment extension packet */ + typedef IPv6PacketParserExtension_Fragment parser; + using mixin::nextPacketRange; using mixin::nextPacketType; using mixin::initSize; @@ -92,10 +94,11 @@ namespace senf { static key_t nextPacketKey(packet p) { return p->nextHeader(); } - static void dump(packet p, std::ostream & os); + /** \brief Dump given IPv6Extension_Fragment in readable form to given output stream */ + static void dump(packet p, std::ostream & os); - static void finalize(packet p) - { p->nextHeader() << key(p.next(nothrow)); } + static void finalize(packet p) { + p->nextHeader() << key(p.next(nothrow)); } }; /** \brief IPv6 fragment extension packet typedef */ diff --git a/Packets/DefaultBundle/IPv6Packet.hh b/Packets/DefaultBundle/IPv6Packet.hh index 97f79ab..2ce41a6 100644 --- a/Packets/DefaultBundle/IPv6Packet.hh +++ b/Packets/DefaultBundle/IPv6Packet.hh @@ -59,6 +59,7 @@ namespace senf { /** \brief Parse an IPv6 packet + \image html IPv6Packet.png \see IPv6PacketType \n RFC 2460 */ @@ -91,14 +92,34 @@ namespace senf { \par Fields: \ref IPv6PacketParser + + + + + + + + + + + + + + + + + + + +
0 4 812 16 2024 2831
\ref IPv6PacketParser::version() "Version"\ref IPv6PacketParser::trafficClass() "Traffic Class"\ref IPv6PacketParser::flowLabel() "Flow Label"
\ref IPv6PacketParser::length() "Payload Length"\ref IPv6PacketParser::nextHeader() "Next Header"\ref IPv6PacketParser::hopLimit() "Hop Limit"
+ \ref IPv6PacketParser::source() "Source Address"
+ \ref IPv6PacketParser::destination() "Destination Address"
+ \par Associated registries: \ref IpTypes \par Finalize action: - Set \a length from payload size\n - Set \a nextHeader from type of next packet if found in \ref IpTypes - - \image html IPv6Packet.png + \copydetails finalize() \ingroup protocolbundle_default */ @@ -108,9 +129,10 @@ namespace senf { { #ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef IPv6PacketParser parser; #endif + typedef ConcretePacket packet; ///< IPv6 packet typedef + typedef IPv6PacketParser parser; ///< typedef to the parser of IPv6 packet + using mixin::nextPacketRange; using mixin::nextPacketType; using mixin::initSize; @@ -119,9 +141,15 @@ namespace senf { static key_t nextPacketKey(packet p) { return p->nextHeader(); } - static void dump(packet p, std::ostream & os); - - static void finalize(packet p); + /** \brief Dump given IPv6Packet in readable form to given output stream */ + static void dump(packet p, std::ostream & os); + + static void finalize(packet p); ///< Finalize packet. + /**< \li set \ref IPv6PacketParser::length() "length" + from payload size + \li set \ref IPv6PacketParser::nextHeader() + "nextHeader" from type of next packet if found + in \ref IpTypes */ }; /** \brief IPv6 packet typedef */ diff --git a/Packets/DefaultBundle/LlcSnapPacket.hh b/Packets/DefaultBundle/LlcSnapPacket.hh index df1d155..5d0f7e9 100644 --- a/Packets/DefaultBundle/LlcSnapPacket.hh +++ b/Packets/DefaultBundle/LlcSnapPacket.hh @@ -38,6 +38,7 @@ namespace senf { /** \brief Parse a LLC/SNAP header + \image html LlcSnapPacket.png \todo document me */ struct LlcSnapPacketParser : public PacketParserBase @@ -77,8 +78,6 @@ namespace senf { \par Finalize action: XXXX - \image html LlcSnapPacket.png - \ingroup protocolbundle_default */ struct LlcSnapPacketType @@ -87,18 +86,21 @@ namespace senf { { #ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef LlcSnapPacketParser parser; #endif + typedef ConcretePacket packet; ///< LLC/SNAP packet typedef + typedef LlcSnapPacketParser parser; ///< typedef to the parser of LLC/SNAP packet + using mixin::nextPacketRange; using mixin::initSize; using mixin::init; static factory_t nextPacketType(packet p); - static void dump(packet p, std::ostream & os); + /** \brief Dump given LlcSnapPacket in readable form to given output stream */ + static void dump(packet p, std::ostream & os); static void finalize(packet p); }; + /** \brief LLC/SNAP packet typedef */ typedef ConcretePacket LlcSnapPacket; } diff --git a/Packets/DefaultBundle/Mldv2Packet.test.cc b/Packets/DefaultBundle/Mldv2Packet.test.cc index 1aeb6a5..b26eabe 100644 --- a/Packets/DefaultBundle/Mldv2Packet.test.cc +++ b/Packets/DefaultBundle/Mldv2Packet.test.cc @@ -1,4 +1,4 @@ -// $Id: main.test.cc 206 2008-06-08 14:20:52Z pug $ +// $Id$ // // Copyright (C) 2006 // Fraunhofer Institute for Open Communication Systems (FOKUS) diff --git a/Packets/DefaultBundle/RTPPacket.cc b/Packets/DefaultBundle/RTPPacket.cc index a09a89f..4e512ab 100644 --- a/Packets/DefaultBundle/RTPPacket.cc +++ b/Packets/DefaultBundle/RTPPacket.cc @@ -1,9 +1,9 @@ -// $Id: main.test.cc 206 2008-08-06 14:20:52Z pug $ +// $Id$ // -// Copyright (C) 2006 +// Copyright (C) 2008 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY -// Stefan Bund +// Philipp Batroff // // 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 @@ -20,14 +20,14 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline non-template functions +/** \file + \brief RTPPacket non-inline non-template implementation */ -// Custom includes #include "RTPPacket.hh" -#include "../../Packets/Packets.hh" -#include "../../Scheduler/ClockService.hh" -#include +//#include "UDPPacket.ih" +// Custom includes +#include #define prefix_ diff --git a/Packets/DefaultBundle/RTPPacket.hh b/Packets/DefaultBundle/RTPPacket.hh index c65360e..403d994 100644 --- a/Packets/DefaultBundle/RTPPacket.hh +++ b/Packets/DefaultBundle/RTPPacket.hh @@ -1,9 +1,9 @@ -// $Id: main.test.cc 206 2008-08-06 14:20:52Z pug $ +// $Id$ // // Copyright (C) 2006 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY -// Stefan Bund +// Philipp Batroff // // 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 @@ -20,7 +20,8 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline non-template functions +/** \file + \brief RTPPacket public header */ // Custom includes #ifndef HH_SENF_Packets_DefaultBundle_RTPPacket_ @@ -28,14 +29,12 @@ #include "../../Packets/Packets.hh" #include "../../Socket/Protocols/INet/INet6Address.hh" -#include "../../Socket/Protocols/INet.hh" -#include "../../Utils/Logger/SenfLog.hh" + namespace senf { - struct RTPPacketParser : public senf::PacketParserBase + struct RTPPacketParser : public PacketParserBase { - SENF_LOG_CLASS_AREA(); # include SENF_PARSER() SENF_PARSER_BITFIELD ( version, 2, unsigned ); //Version (RFC 3550) SENF_PARSER_BITFIELD ( padding, 1, bool ); //1 if padding behind payload @@ -43,22 +42,21 @@ namespace senf { SENF_PARSER_BITFIELD_RO ( csrcCount, 4, unsigned ); //0-15,define the number of contributing sources SENF_PARSER_BITFIELD ( marker, 1, bool ); //Marker M=1, used to signal speech silent compression; further use in combination with PT to be defined SENF_PARSER_BITFIELD ( payloadType, 7, unsigned ); //Payload Type; e.g. PCM=8 (RFC 3550) - SENF_PARSER_FIELD ( seqNumber, senf::UInt16Parser ); //random number to identify initial segment of a stream, increment by 1 used to resequence segments at receiver - SENF_PARSER_FIELD ( timeStamp, senf::UInt32Parser ); //signals sampling time of 1st byte of payload; initialised; used to calculate Jitter between segments - SENF_PARSER_FIELD ( synSourceId, senf::UInt32Parser ); //Synchronisation source identifier; identifier of RFTP stream source (random number) in case of conferencing identifier of mixer - SENF_PARSER_VECTOR (csrcOpt, csrcCount, senf::UInt32Parser ); + SENF_PARSER_FIELD ( seqNumber, UInt16Parser ); //random number to identify initial segment of a stream, increment by 1 used to resequence segments at receiver + SENF_PARSER_FIELD ( timeStamp, UInt32Parser ); //signals sampling time of 1st byte of payload; initialised; used to calculate Jitter between segments + SENF_PARSER_FIELD ( synSourceId, UInt32Parser ); //Synchronisation source identifier; identifier of RFTP stream source (random number) in case of conferencing identifier of mixer + SENF_PARSER_VECTOR (csrcOpt, csrcCount, UInt32Parser ); bool valid() const {return version() == 2;} SENF_PARSER_FINALIZE(RTPPacketParser); }; struct RTPPacketType - : public senf::PacketTypeBase, - public senf::PacketTypeMixin + : public PacketTypeBase, + public PacketTypeMixin { - SENF_LOG_CLASS_AREA(); - typedef senf::PacketTypeMixin mixin; - typedef senf::ConcretePacket packet; + typedef PacketTypeMixin mixin; + typedef ConcretePacket packet; typedef RTPPacketParser parser; using mixin::nextPacketRange; diff --git a/Packets/DefaultBundle/RTPPacket.test.cc b/Packets/DefaultBundle/RTPPacket.test.cc index 8a8446f..9cff4af 100644 --- a/Packets/DefaultBundle/RTPPacket.test.cc +++ b/Packets/DefaultBundle/RTPPacket.test.cc @@ -1,9 +1,9 @@ -// $Id: main.test.cc 206 2008-08-06 14:20:52Z pug $ +// $Id$ // -// Copyright (C) 2006 +// Copyright (C) 2008 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY -// Stefan Bund +// Philipp Batroff // // 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 @@ -20,14 +20,15 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Definition of non-inline non-template functions +// Unit tests // Custom includes +#include "RTPPacket.hh" -#include "../../Packets/Packets.hh" #include "../../Utils/auto_unit_test.hh" #include -#include "RTPPacket.hh" + + BOOST_AUTO_UNIT_TEST(RTPPacket_packet) { unsigned char data[] = {0x80 , 0x08 , 0x1b , 0xbb , 0x02 , 0xcb , 0xad , 0x80 , 0x50 , 0x48 , 0xa7, 0x8c }; diff --git a/Packets/DefaultBundle/UDPPacket.hh b/Packets/DefaultBundle/UDPPacket.hh index fb71f44..e85c182 100644 --- a/Packets/DefaultBundle/UDPPacket.hh +++ b/Packets/DefaultBundle/UDPPacket.hh @@ -37,7 +37,8 @@ namespace senf { /** \brief Parse a UDP packet Parser implementing the UDP header. The fields implemented are: - + \image html UDPPacket.png + \see UDPPacketType \n RFC 768 */ @@ -52,11 +53,14 @@ namespace senf { SENF_PARSER_FINALIZE(UDPPacketParser); - boost::uint16_t calcChecksum() const; - + boost::uint16_t calcChecksum() const; ///< calculate (pseudo-)header checksum + /**< calculate and return the checksum of the + (pseudo-)header \see \ref senf::IpChecksum */ bool validateChecksum() const { return checksum() == 0u || checksum() == calcChecksum(); - } + } ///< validate header checksum + /**< return \c true if the \ref checksum() "checksum" + field is equal to the \ref calcChecksum() "calculated checksum" */ }; /** \brief UDP packet @@ -67,11 +71,21 @@ namespace senf { \par Fields: \ref UDPPacketParser + + + + + + + + + + + +
0 8 1624 31
\ref UDPPacketParser::source() "Source Port"\ref UDPPacketParser::destination() "Destination Port"
\ref UDPPacketParser::length() "Length"\ref UDPPacketParser::checksum() "Checksum"
+ \par Finalize action: - Set \a length from payload size\n - Calculate \a checksum - - \image html UDPPacket.png + \copydetails finalize() \ingroup protocolbundle_default */ @@ -81,16 +95,22 @@ namespace senf { { #ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef UDPPacketParser parser; #endif + typedef ConcretePacket packet; ///< UDP packet typedef + typedef UDPPacketParser parser; ///< typedef to the parser of UDP packet + using mixin::nextPacketRange; using mixin::initSize; using mixin::init; + /** \brief Dump given UDPPacket in readable form to given output stream */ static void dump(packet p, std::ostream & os); - - static void finalize(packet p); + + static void finalize(packet p); ///< Finalize packet. + /**< \li set \ref UDPPacketParser::length() "length" from + payload size + \li calculate and set \ref UDPPacketParser::checksum() + "checksum" */ }; /** \brief UDP packet typedef */ @@ -101,7 +121,7 @@ namespace senf { ///////////////////////////////hh.e//////////////////////////////////////// #endif #ifndef SENF_PACKETS_DECL_ONLY -//#include UDPPacket.cci" +//#include "UDPPacket.cci" //#include "UDPPacket.ct" //#include "UDPPacket.cti" #endif diff --git a/Packets/MPEGDVBBundle/MPESection.hh b/Packets/MPEGDVBBundle/MPESection.hh index e617691..5b80e05 100644 --- a/Packets/MPEGDVBBundle/MPESection.hh +++ b/Packets/MPEGDVBBundle/MPESection.hh @@ -121,20 +121,27 @@ namespace senf { : public PacketTypeBase, public PacketTypeMixin { +#ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef MPESectionParser parser; +#endif + typedef ConcretePacket packet; ///< MPESection packet typedef + typedef MPESectionParser parser; ///< typedef to the parser of MPESection using mixin::nextPacketRange; using mixin::init; + /** \brief Dump given MPESection in readable form to given output stream */ static void dump(packet p, std::ostream & os); + static void finalize(packet p); + static factory_t nextPacketType(packet p); + static PacketParserBase::size_type initSize(); static PacketParserBase::size_type initHeadSize(); }; + /** \brief MPESection packet typedef */ typedef ConcretePacket MPESection; } diff --git a/Packets/MPEGDVBBundle/TLV.dia b/Packets/MPEGDVBBundle/TLV.dia deleted file mode 100644 index 77dc6eb..0000000 Binary files a/Packets/MPEGDVBBundle/TLV.dia and /dev/null differ diff --git a/Packets/MPEGDVBBundle/TransportPacket.hh b/Packets/MPEGDVBBundle/TransportPacket.hh index 13eff46..38200d5 100644 --- a/Packets/MPEGDVBBundle/TransportPacket.hh +++ b/Packets/MPEGDVBBundle/TransportPacket.hh @@ -34,16 +34,10 @@ namespace senf { -// struct PSIPayloadPacketParser : public PacketParserBase -// { -// static const size_type fixed_bytes = 184; -// -// }; - - /** \brief Parse a Transport Stream packet Parser implementing the header of a MPEG Transport Stream packet. + \image html TransportPacket.png \see TransportPacketType */ @@ -117,7 +111,6 @@ namespace senf { \par Fields: \ref TransportPacketParser - \image html TransportPacket.png \ingroup protocolbundle_mpegdvb */ @@ -125,14 +118,17 @@ namespace senf { : public PacketTypeBase, public PacketTypeMixin { +#ifndef DOXYGEN typedef PacketTypeMixin mixin; - typedef ConcretePacket packet; - typedef TransportPacketParser parser; +#endif + typedef ConcretePacket packet; ///< Transport packet typedef + typedef TransportPacketParser parser; ///< typedef to the parser of Transport packet using mixin::nextPacketRange; using mixin::init; using mixin::initSize; + /** \brief Dump given Transport packet in readable form to given output stream */ static void dump(packet p, std::ostream & os); static const byte SYNC_BYTE = 0x47; }; diff --git a/Packets/SConscript b/Packets/SConscript index 21b1900..640269c 100644 --- a/Packets/SConscript +++ b/Packets/SConscript @@ -11,7 +11,7 @@ SENFSCons.StandardTargets(env) SENFSCons.Lib(env, sources) SENFSCons.Doxygen(env, extra_sources = [ env.Dia2Png("structure.dia"), - env.Dia2Png("MPEGDVBBundle/TLV.dia"), + env.Dia2Png("80221Bundle/TLV.dia"), env.PkgDraw("MPEGDVBBundle/DTCPPacket.hh"), env.PkgDraw("DefaultBundle/EthernetPacket.hh", PKGDRAWPACKETS = "EthernetPacketParser"), diff --git a/Socket/Protocols/DatagramSocketProtocol.hh b/Socket/Protocols/DatagramSocketProtocol.hh index dcf5af8..73df063 100644 --- a/Socket/Protocols/DatagramSocketProtocol.hh +++ b/Socket/Protocols/DatagramSocketProtocol.hh @@ -51,10 +51,6 @@ namespace senf { received from the network. This allows precise network timing. - The returned value can be converted to the - senf::ClockService::clock_type representation using - semf::ClockService::from_timeval(). - \pre The \c SO_TIMESTAMP socket option must not be set on the socket. \returns timestamp when last packet was received */