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/GREPacket.hh

Go to the documentation of this file.
00001 // $Id: GREPacket.hh 1754 2010-12-09 15:45:42Z tho $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Joachim Kaeber <jkaeber@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_GREPacket_
00027 #define HH_SENF_Packets_MPEGDVBBundle_GREPacket_ 1
00028 
00029 // Custom includes
00030 #include <senf/Packets/DefaultBundle/EthernetPacket.hh>
00031 
00032 //#include "GREPacket.mpp"
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 
00035 namespace senf {
00036 
00043     struct GREChecksumParser : public PacketParserBase {
00044 #       include SENF_PARSER()
00045         SENF_PARSER_FIELD ( checksum1_, UInt16Parser );
00046         SENF_PARSER_PRIVATE_FIELD ( reserved1_, UInt16Parser );
00047         SENF_PARSER_FINALIZE(GREChecksumParser);
00048     };
00049 
00050     struct GREPacketParser : public PacketParserBase
00051     {
00052 #       include SENF_PARSER()
00053 
00054         SENF_PARSER_BITFIELD         ( checksum_present,  1, bool );
00055         SENF_PARSER_PRIVATE_BITFIELD ( reserved0_,       12, unsigned ); // TODO: SKIP !!
00056         SENF_PARSER_BITFIELD         ( version_number,    3, unsigned ); // TODO: Always Zero !!
00057         SENF_PARSER_FIELD            ( protocol_type,    UInt16Parser );
00058         SENF_PARSER_PRIVATE_VARIANT  ( checksum_,  checksum_present,
00059                                                    (VoidPacketParser) (GREChecksumParser) );
00060 
00061         SENF_PARSER_FINALIZE( GREPacketParser );
00062 
00063       private:
00064         UInt16Parser checksum() const 
00065              { return checksum_().get<1>().checksum1_(); }
00066     };
00067 
00079     struct GREPacketType
00080         : public PacketTypeBase,
00081           public PacketTypeMixin<GREPacketType, EtherTypes>
00082     {
00083         typedef PacketTypeMixin<GREPacketType, EtherTypes> mixin;
00084         typedef ConcretePacket<GREPacketType> packet;
00085         typedef GREPacketParser parser;
00086 
00087         using mixin::nextPacketRange;
00088         using mixin::nextPacketType;
00089         using mixin::init;
00090         using mixin::initSize;
00091 
00092         static void dump(packet p, std::ostream & os);
00093         static EtherTypes::key_t nextPacketKey(packet p) {
00094           return p->protocol_type();
00095         }
00096         static void finalize(packet p) {
00097           p->protocol_type() << key(p.next(nothrow));
00098           p->version_number() = 0; // as per RFC2784, 2.3.1
00099 
00100           if (p->checksum_present()) {
00101             // compute checksum
00102           } else {
00103             // ???
00104           }
00105         }
00106     };
00107 
00109     typedef GREPacketType::packet GREPacket;
00110 
00111 
00112 }
00113 
00114 
00115 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00116 //#include "TransportPacket.cci"
00117 //#include "TransportPacket.ct"
00118 //#include "TransportPacket.cti"
00119 #endif
00120 
00121 
00122 // Local Variables:
00123 // mode: c++
00124 // fill-column: 100
00125 // c-file-style: "senf"
00126 // indent-tabs-mode: nil
00127 // ispell-local-dictionary: "american"
00128 // compile-command: "scons -u test"
00129 // comment-column: 40
00130 // End:

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