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/SNDUPacket.cc

Go to the documentation of this file.
00001 // $Id: SNDUPacket.cc 1772 2011-03-10 12:45:21Z 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 #include "SNDUPacket.hh"
00027 //#include "SNDUPacket.ih"
00028 
00029 // Custom includes
00030 #include <iomanip>
00031 
00032 #define prefix_
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 
00035 prefix_ boost::uint32_t senf::SNDUPacketParser::calcCrc()
00036     const
00037 {
00038     return std::for_each(
00039             data().begin(),
00040             boost::prior(data().end(), 4),
00041             ule_crc32() ).checksum();
00042 }
00043 
00044 //prefix_ senf::SNDUPacketType::key_t senf::SNDUPacketType::nextPacketKey(packet p)
00045 //{
00046 //    return p->type();
00047 //}
00048 
00049 prefix_ void senf::SNDUPacketType::init(packet p)
00050 {
00051     p->init();
00052 }
00053 
00054 prefix_ senf::PacketInterpreterBase::factory_t senf::SNDUPacketType::nextPacketType(packet p)
00055 {
00056     if (p.data().size() < 8)
00057         return no_factory();
00058     PacketInterpreterBase::factory_t f (no_factory());
00059     if (p->type() < 1536) {
00060         PacketRegistry<senf::ULEExtHeaderTypes>::Entry const * e (
00061             PacketRegistry<senf::ULEExtHeaderTypes>::lookup( p->type(), nothrow ));
00062         if (e) f = e->factory();
00063     }
00064     else {
00065         PacketRegistry<senf::EtherTypes>::Entry const * e (
00066             PacketRegistry<senf::ULEExtHeaderTypes>::lookup( p->type(), nothrow ));
00067         if (e) f = e->factory();
00068     }
00069     return f;
00070 }
00071 
00072 prefix_ senf::PacketInterpreterBase::optional_range
00073 senf::SNDUPacketType::nextPacketRange(packet p)
00074 {
00075     if (p.data().size() < 8)
00076         return no_range();
00077 
00078     size_type sz = 2 + 2;  // D-Bit + 15 bits length + 16 bits type field
00079     if (! p->d_bit() )
00080         sz += 6;  // + 6 Byte NPA destination address
00081     return range(
00082             boost::next(p.data().begin(), sz),
00083             boost::prior(p.data().end(), 4));  // - 32 bits crc
00084 }
00085 
00086 prefix_ void senf::SNDUPacketType::dump(packet p, std::ostream & os)
00087 {
00088     os << "SNDUPacket:\n"
00089        << std::dec
00090        << senf::fieldName("d_bit")  << p->d_bit() << "\n"
00091        << senf::fieldName("length") << unsigned(p->length()) << "\n"
00092        << std::hex
00093        << senf::fieldName("type")   << "0x" << unsigned(p->type()) << "\n"
00094        << std::dec
00095        << senf::fieldName("crc")    << unsigned(p->crc()) << "\n";
00096 }
00097 
00098 prefix_ senf::PacketParserBase::size_type senf::SNDUPacketType::initSize()
00099 {
00100     return 2 + 2 + 4;  // D-Bit + 15 bits length + 16 bits type field + 32 bits crc
00101 }
00102 
00103 prefix_ senf::PacketParserBase::size_type senf::SNDUPacketType::initHeadSize()
00104 {
00105     return 2 + 2;  // D-Bit + 15 bits length + 16 bits type field
00106 }
00107 
00108 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00109 #undef prefix_
00110 
00111 
00112 // Local Variables:
00113 // mode: c++
00114 // fill-column: 100
00115 // c-file-style: "senf"
00116 // indent-tabs-mode: nil
00117 // ispell-local-dictionary: "american"
00118 // compile-command: "scons -u test"
00119 // comment-column: 40
00120 // End:

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