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

80221Bundle/MIHPacket.hh

Go to the documentation of this file.
00001 // $Id: MIHPacket.hh 1787 2011-05-12 11:02:50Z tho $
00002 //
00003 // Copyright (C) 2009
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_80221Bundle_MIHPacket_
00027 #define HH_SENF_Packets_80221Bundle_MIHPacket_ 1
00028 
00029 // Custom includes
00030 #include <senf/Packets/Packets.hh>
00031 #include "TLVParser.hh"
00032 #include "MIHMessageRegistry.hh"
00033 
00034 //#include "MIHPacket.mpp"
00035 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00036 
00037 namespace senf {
00038 
00046     struct MIHPacketParser : public PacketParserBase
00047     {
00048     #   include SENF_PARSER()
00049 
00050         SENF_PARSER_BITFIELD_RO ( version,       4,  unsigned );
00051         SENF_PARSER_BITFIELD    ( ackRequest,    1,  bool     );
00052         SENF_PARSER_BITFIELD    ( ackResponse,   1,  bool     );
00053         SENF_PARSER_BITFIELD    ( uir,           1,  bool     );
00054         SENF_PARSER_BITFIELD    ( moreFragment,  1,  bool     );
00055         SENF_PARSER_BITFIELD    ( fragmentNr,    7,  unsigned );
00056         SENF_PARSER_SKIP_BITS   ( 1                           );
00057 
00058         // MIH message ID (MID)
00059         SENF_PARSER_FIELD    ( messageId, UInt16Parser ); //<pkgdraw:hide
00060         SENF_PARSER_GOTO     ( messageId               );
00061         SENF_PARSER_BITFIELD ( sid,     4,  unsigned   );
00062         SENF_PARSER_BITFIELD ( opcode,  2,  unsigned   );
00063         SENF_PARSER_BITFIELD ( aid,    10,  unsigned   );
00064 
00065         SENF_PARSER_SKIP_BITS ( 4                           );
00066         SENF_PARSER_BITFIELD  ( transactionId, 12, unsigned );
00067         SENF_PARSER_FIELD_RO  ( payloadLength, UInt16Parser );
00068 
00069         SENF_PARSER_GOTO_OFFSET( 8, 8); // just to limit the offset calculation
00070 
00071         // Source MIHF Id
00072         SENF_PARSER_FIELD ( src_mihfId, MIHFSrcIdTLVParser );
00073         // Destination MIHF Id
00074         SENF_PARSER_FIELD ( dst_mihfId, MIHFDstIdTLVParser );
00075 
00076         SENF_PARSER_FINALIZE ( MIHPacketParser );
00077 
00078         SENF_PARSER_INIT() {
00079             defaultInit();
00080             version_() = 1;
00081         }
00082 
00083         friend class MIHPacketType;
00084     };
00085 
00096     struct MIHPacketType
00097         : public PacketTypeBase,
00098           public PacketTypeMixin<MIHPacketType, MIHMessageRegistry>
00099     {
00100         typedef PacketTypeMixin<MIHPacketType, MIHMessageRegistry> mixin;
00101         typedef ConcretePacket<MIHPacketType> packet; 
00102         typedef MIHPacketParser parser;               
00103 
00104         using mixin::nextPacketRange;
00105         using mixin::init;
00106         using mixin::initSize;
00107 
00109         static void dump(packet p, std::ostream & os);
00110         static void finalize(packet p);
00111         static factory_t nextPacketType(packet p);
00112         static void validate(packet p);
00113 
00114         static const boost::uint16_t etherType = 0x8917;
00115     };
00116 
00120     typedef ConcretePacket<MIHPacketType> MIHPacket;
00121 
00122 
00123     struct MIHGenericPayloadPacketParser : public PacketParserBase
00124     {
00125     #   include SENF_PARSER()
00126         SENF_PARSER_LIST ( tlvList, packetSize(), MIHGenericTLVParser );
00127         SENF_PARSER_FINALIZE ( MIHGenericPayloadPacketParser );
00128     };
00129 
00130     struct MIHGenericPayloadPacketType
00131         : public PacketTypeBase,
00132           public PacketTypeMixin<MIHGenericPayloadPacketType>
00133     {
00134         typedef PacketTypeMixin<MIHGenericPayloadPacketType> mixin;
00135         typedef ConcretePacket<MIHGenericPayloadPacketType> packet; 
00136         typedef MIHGenericPayloadPacketParser parser; 
00137 
00138         using mixin::nextPacketRange;
00139         using mixin::init;
00140         using mixin::initSize;
00141 
00143         static void dump(packet p, std::ostream & os);
00144         static void finalize(packet p);
00145     };
00146 
00150     typedef ConcretePacket<MIHGenericPayloadPacketType> MIHGenericPayloadPacket;
00151 }
00152 
00153 
00154 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00155 //#include "MIHPacket.cci"
00156 //#include "MIHPacket.ct"
00157 //#include "MIHPacket.cti"
00158 #endif
00159 
00160 
00161 
00162 // Local Variables:
00163 // mode: c++
00164 // fill-column: 100
00165 // c-file-style: "senf"
00166 // indent-tabs-mode: nil
00167 // ispell-local-dictionary: "american"
00168 // compile-command: "scons -u test"
00169 // comment-column: 40
00170 // End:

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