Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

MPEGDVBBundle/MPESection.hh

Go to the documentation of this file.
00001 // $Id:MPESection.hh 560 2007-12-13 14:39:37Z tho $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Thorsten Horstmann <tho@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_Packets_MPEGDVBBundle_MPESection_
00027 #define HH_SENF_Packets_MPEGDVBBundle_MPESection_ 1
00028 
00029 // Custom includes
00030 #include <boost/crc.hpp>
00031 #include <senf/Packets/Packets.hh>
00032 
00033 //#include "MPESection.mpp"
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 
00036 namespace senf {
00037 
00038     struct MPERealTimeParametersParser : public PacketParserBase
00039     {
00040 #       include SENF_FIXED_PARSER()
00041 
00042         SENF_PARSER_BITFIELD ( delta_t,                  12, unsigned );
00043         SENF_PARSER_BITFIELD ( table_boundary,           1,  bool     );
00044         SENF_PARSER_BITFIELD ( frame_boundary,           1,  bool     );
00045         SENF_PARSER_BITFIELD ( address,                  18, unsigned );
00046 
00047         SENF_PARSER_FINALIZE( MPERealTimeParametersParser );
00048     };
00049 
00050 
00057     class MPESectionParser : public PacketParserBase
00058     {
00059     public:
00060 #       include SENF_FIXED_PARSER()
00061 
00062         SENF_PARSER_FIELD( table_id, UInt8Parser );
00063 
00064         SENF_PARSER_BITFIELD        ( section_syntax_indicator, 1,  bool     );
00065         SENF_PARSER_BITFIELD        ( private_indicator,        1,  bool     );
00066         SENF_PARSER_PRIVATE_BITFIELD( reserved_1,               2,  unsigned );
00067         SENF_PARSER_BITFIELD        ( section_length,           12, unsigned );
00068 
00069         SENF_PARSER_FIELD( mac_addr_6, UInt8Parser );
00070         SENF_PARSER_FIELD( mac_addr_5, UInt8Parser );
00071 
00072         SENF_PARSER_PRIVATE_BITFIELD( reserved_2,          2, unsigned );
00073         SENF_PARSER_BITFIELD        ( payload_scrmbl_ctrl, 2, unsigned );
00074         SENF_PARSER_BITFIELD        ( addr_scrmbl_ctrl,    2, unsigned );
00075         SENF_PARSER_BITFIELD        ( llc_snap_flag,       1, bool     );
00076         SENF_PARSER_BITFIELD        ( curr_next_indicator, 1, bool     );
00077 
00078         SENF_PARSER_FIELD( section_num,      UInt8Parser );
00079         SENF_PARSER_FIELD( last_section_num, UInt8Parser );
00080 
00081         SENF_PARSER_FIELD( real_time_parameters, MPERealTimeParametersParser );
00082 
00083         SENF_PARSER_FINALIZE( MPESectionParser );
00084 
00085         SENF_PARSER_PRIVATE_BITFIELD( ip_datagram_version, 4, unsigned );
00086 
00087         SENF_PARSER_INIT() {
00088             table_id() = 0x3e;
00089             section_syntax_indicator() = 1;
00090             private_indicator() = 0;
00091             reserved_1() = 3;
00092             reserved_2() = 3;
00093             payload_scrmbl_ctrl() = 0;
00094             addr_scrmbl_ctrl() = 0;
00095             curr_next_indicator() = 1;
00096         }
00097 
00098         UInt32Parser crc() const { return parse<UInt32Parser>( data().size()-4 ); }
00099         boost::uint32_t calcCrc() const;
00100 
00101         friend class MPESectionType;
00102 
00103     private:
00104         typedef boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0, false, false> crc32_t;
00105     };
00106 
00107 
00119     struct MPESectionType
00120         : public PacketTypeBase,
00121           public PacketTypeMixin<MPESectionType>
00122     {
00123 #ifndef DOXYGEN
00124         typedef PacketTypeMixin<MPESectionType> mixin;
00125 #endif
00126         typedef ConcretePacket<MPESectionType> packet; 
00127         typedef MPESectionParser parser;               
00128 
00129         using mixin::nextPacketRange;
00130         using mixin::init;
00131 
00133         static void dump(packet p, std::ostream & os);
00134 
00135         static void finalize(packet p);
00136 
00137         static factory_t nextPacketType(packet p);
00138 
00139         static PacketParserBase::size_type initSize();
00140         static PacketParserBase::size_type initHeadSize();
00141     };
00142 
00146     typedef ConcretePacket<MPESectionType> MPESection;
00147 }
00148 
00149 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00150 //#include "MPESection.cci"
00151 //#include "MPESection.ct"
00152 //#include "MPESection.cti"
00153 #endif
00154 
00155 
00156 // Local Variables:
00157 // mode: c++
00158 // fill-column: 100
00159 // c-file-style: "senf"
00160 // indent-tabs-mode: nil
00161 // ispell-local-dictionary: "american"
00162 // compile-command: "scons -u test"
00163 // comment-column: 40
00164 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research