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

Go to the documentation of this file.
00001 // $Id: DTCPPacket.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 //     David Wagner <dw6@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_DTCPPacket_
00027 #define HH_SENF_Packets_MPEGDVBBundle_DTCPPacket_ 1
00028 
00029 // Custom includes
00030 #include <senf/Packets/DefaultBundle/IPv6Packet.hh>
00031 
00032 //#include "DTCPPacket.mpp"
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 
00035 namespace senf {
00036 
00037 #   define DTCP_V4_MCADDRESS "224.0.0.36"
00038 #   define DTCP_V6_MCADDRESS "FF02:0:0:0:0:0:1:4"
00039 #   define DTCP_UDP_PORT 652
00040 
00041     struct DTCPIPv4AddressListParser : public PacketParserBase
00042     {
00043 #       include SENF_PARSER()
00044 
00045         SENF_PARSER_PRIVATE_FIELD( fbipCount_, UInt8Parser ); //<pkgdraw: hide
00046         SENF_PARSER_PRIVATE_FIELD( reserved_, UInt8Parser ); //<pkgdraw: hide
00047 
00048         SENF_PARSER_VECTOR( fbips, fbipCount_, INet4AddressParser );
00049 
00050         // Needed since we do NOT want to init fbipCount_ or reseverd_. And since
00051         // INet4AddressParser::init() is a no-op, we can just as well disable init completely
00052         SENF_PARSER_INIT() {}
00053 
00054         SENF_PARSER_FINALIZE(DTCPIPv4AddressListParser);
00055     };
00056 
00057     struct DTCPIPv6AddressListParser : public PacketParserBase
00058     {
00059 #       include SENF_PARSER()
00060 
00061         SENF_PARSER_PRIVATE_FIELD( fbipCount_, UInt8Parser ); //<pkgdraw: hide
00062         SENF_PARSER_PRIVATE_FIELD( reserved_, UInt8Parser ); //<pkgdraw: hide
00063 
00064         SENF_PARSER_VECTOR( fbips, fbipCount_, INet6AddressParser );
00065 
00066         // Needed since we do NOT want to init fbipCount_ or reseverd_. And since
00067         // INet4AddressParser::init() is a no-op, we can just as well disable init completely
00068         SENF_PARSER_INIT() {}
00069 
00070         SENF_PARSER_FINALIZE(DTCPIPv6AddressListParser);
00071     };
00072 
00079     struct DTCPHelloPacketParser : public PacketParserBase
00080     {
00081 #       include SENF_PARSER()
00082 
00083         //>pkgdraw: name=vers
00084         SENF_PARSER_BITFIELD         ( versionNumber,        4, unsigned );  // must be 1
00085         SENF_PARSER_BITFIELD         ( command,              4, unsigned );  //<pkgdraw: name=cmd
00086 
00087         enum Command { JOIN=1, LEAVE=2 };
00088 
00089         SENF_PARSER_FIELD            ( interval,             UInt8Parser );  // should be 5
00090         SENF_PARSER_FIELD            ( sequenceNumber,       UInt16Parser );
00091 
00092         SENF_PARSER_PRIVATE_BITFIELD ( reserved0_,           3, unsigned );  //<pkgdraw: name=
00093         SENF_PARSER_BITFIELD         ( receiveCapableFeed,   1, bool );
00094         SENF_PARSER_BITFIELD_RO      ( ipVersion,            4, unsigned );  // 4=IPv4, 6=IPv6
00095 
00096         SENF_PARSER_FIELD            ( tunnelProtocol,       UInt8Parser );
00097         SENF_PARSER_FIELD_RO         ( fbipCount,            UInt8Parser );
00098         //>pkgdraw: name=
00099         SENF_PARSER_PRIVATE_FIELD    ( reserved1_,           UInt8Parser );  // must be zero
00100 
00101         // Go back to fbipCount so the variant has access to that field
00102         SENF_PARSER_GOTO( fbipCount );
00103 
00104         SENF_PARSER_VARIANT          ( fbipList_,            ipVersion,
00105                            ( ids(na, has_v4fbipList, init_v4fbipList,
00106                                  key(4, DTCPIPv4AddressListParser)) )
00107                            ( ids(na, has_v6fbipList, init_v6fbipList,
00108                                  key(6, DTCPIPv6AddressListParser)) ) );
00109 
00110         // We define the two variant accessors ourselves so we can directly return the vector and
00111         // not the collection parser which contains the vector ...
00112 
00113         typedef DTCPIPv4AddressListParser::fbips_t v4fbipList_t;
00114         v4fbipList_t v4fbipList() { return fbipList_().get<0>().fbips(); }
00115 
00116         typedef DTCPIPv6AddressListParser::fbips_t v6fbipList_t;
00117         v6fbipList_t v6fbipList() { return fbipList_().get<1>().fbips(); }
00118 
00119         SENF_PARSER_FINALIZE(DTCPHelloPacketParser);
00120     };
00121 
00134     struct DTCPHelloPacketType
00135         : public PacketTypeBase,
00136           public PacketTypeMixin<DTCPHelloPacketType>
00137     {
00138         typedef PacketTypeMixin<DTCPHelloPacketType> mixin;
00139         typedef ConcretePacket<DTCPHelloPacketType> packet;
00140         typedef DTCPHelloPacketParser parser;
00141 
00142         using mixin::nextPacketRange;
00143         using mixin::init;
00144         using mixin::initSize;
00145 
00146         static void dump(packet p, std::ostream & os);
00147     };
00148 
00150     typedef DTCPHelloPacketType::packet DTCPHelloPacket;
00151 }
00152 
00153 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00154 //#include "DTCPPacket.cci"
00155 //#include "DTCPPacket.ct"
00156 //#include "DTCPPacket.cti"
00157 #endif
00158 
00159 
00160 // Local Variables:
00161 // mode: c++
00162 // fill-column: 100
00163 // comment-column: 40
00164 // c-file-style: "senf"
00165 // indent-tabs-mode: nil
00166 // ispell-local-dictionary: "american"
00167 // compile-command: "scons -u test"
00168 // End:

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