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

DefaultBundle/IPv6Packet.hh

Go to the documentation of this file.
00001 // $Id: IPv6Packet.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@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_DefaultBundle_IPv6Packet_
00027 #define HH_SENF_Packets_DefaultBundle_IPv6Packet_ 1
00028 
00029 // Custom includes
00030 #include <senf/Socket/Protocols/INet/INet6Address.hh>
00031 #include <senf/Packets/Packets.hh>
00032 #include "IPv4Packet.hh"
00033 
00034 //#include "IPv6Packet.mpp"
00035 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00036 
00037 namespace senf {
00038 
00043     struct INet6AddressParser
00044         : public ValueParserBase<INet6AddressParser, INet6Address, 16u>
00045     {
00046         INet6AddressParser(data_iterator i, state_type s) : Base(i,s) {}
00047 
00048         value_type value() const { return value_type::from_data(i()); }
00049         void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); }
00050 
00051         using Base::operator=;
00052     };
00053 
00060     struct IPv6PacketParser : public PacketParserBase
00061     {
00062 #       include SENF_FIXED_PARSER()
00063 
00064         SENF_PARSER_BITFIELD( version,       4, unsigned );
00065         SENF_PARSER_BITFIELD( trafficClass,  8, unsigned );
00066         SENF_PARSER_BITFIELD( flowLabel,    20, unsigned );
00067 
00068         SENF_PARSER_FIELD( length,       UInt16Parser       );
00069         SENF_PARSER_FIELD( nextHeader,   UInt8Parser        );
00070         SENF_PARSER_FIELD( hopLimit,     UInt8Parser        );
00071         SENF_PARSER_FIELD( source,       INet6AddressParser );
00072         SENF_PARSER_FIELD( destination,  INet6AddressParser );
00073 
00074         SENF_PARSER_INIT() {
00075             version() = 6;
00076         }
00077 
00078         SENF_PARSER_FINALIZE(IPv6PacketParser);
00079     };
00080 
00120     struct IPv6PacketType
00121         : public PacketTypeBase,
00122           public PacketTypeMixin<IPv6PacketType, IpTypes>
00123     {
00124 #ifndef DOXYGEN
00125         typedef PacketTypeMixin<IPv6PacketType, IpTypes> mixin;
00126 #endif
00127         typedef ConcretePacket<IPv6PacketType> packet; 
00128         typedef IPv6PacketParser parser;               
00129 
00130         using mixin::nextPacketRange;
00131         using mixin::nextPacketType;
00132         using mixin::initSize;
00133         using mixin::init;
00134 
00135         static key_t nextPacketKey(packet p)
00136             { return p->nextHeader(); }
00137 
00139         static void dump(packet p, std::ostream & os);
00140 
00141         static void finalize(packet p); 
00142 
00147     };
00148 
00152     typedef ConcretePacket<IPv6PacketType> IPv6Packet;
00153 }
00154 
00155 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00156 //#include "IPv6Packet.cci"
00157 //#include "IPv6Packet.ct"
00158 //#include "IPv6Packet.cti"
00159 #endif
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