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

Go to the documentation of this file.
00001 // $Id: IPv6Extensions.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 //     Philipp Batroff <philipp.batroff@fit.fraunhofer.de>
00008 //
00009 // This program is free software; you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation; either version 2 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with this program; if not, write to the
00021 // Free Software Foundation, Inc.,
00022 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 
00027 #ifndef HH_SENF_Packets_DefaultBundle_IPv6Extensions_
00028 #define HH_SENF_Packets_DefaultBundle_IPv6Extensions_ 1
00029 
00030 // Custom includes
00031 #include "IPv6ExtOptions.hh"
00032 #include "ListOptionTypeParser.hh"
00033 #include "IPv6Packet.hh"
00034 
00035 //#include "IPv6Extensions.mpp"
00036 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00037 
00038 namespace senf {
00039 
00048     struct IPv6FragmentPacketParser : public PacketParserBase
00049     {
00050 #       include SENF_FIXED_PARSER()
00051 
00052         SENF_PARSER_FIELD            ( nextHeader     , UInt8Parser  );
00053         SENF_PARSER_PRIVATE_FIELD    ( reserved1      , UInt8Parser  );
00054         SENF_PARSER_BITFIELD         ( fragmentOffset , 13, unsigned );
00055         SENF_PARSER_PRIVATE_BITFIELD ( reserved2      ,  2, unsigned );
00056         SENF_PARSER_BITFIELD         ( moreFragments  ,  1, bool     );
00057         SENF_PARSER_FIELD            ( id             , UInt32Parser );
00058 
00059         SENF_PARSER_FINALIZE(IPv6FragmentPacketParser);
00060     };
00061 
00078     struct IPv6FragmentPacketType
00079         : public PacketTypeBase,
00080           public PacketTypeMixin<IPv6FragmentPacketType, IpTypes>
00081     {
00082 #ifndef DOXYGEN
00083         typedef PacketTypeMixin<IPv6FragmentPacketType, IpTypes> mixin;
00084 #endif
00085 
00086         typedef ConcretePacket<IPv6FragmentPacketType> packet;
00088         typedef IPv6FragmentPacketParser parser;
00089 
00090         using mixin::nextPacketRange;
00091         using mixin::nextPacketType;
00092         using mixin::initSize;
00093         using mixin::init;
00094 
00095         static key_t nextPacketKey(packet p)
00096             { return p->nextHeader(); }
00097 
00099         static void dump(packet p, std::ostream & os);
00100 
00101         static void finalize(packet p);
00102     };
00103 
00107     typedef ConcretePacket<IPv6FragmentPacketType> IPv6FragmentPacket;
00108 
00109 // =====================================================================================================
00110 
00120     struct IPv6RoutingPacketParser : public PacketParserBase
00121     {
00122         /*
00123         The Type 0 Routing header has the following format: (RFC 2460)
00124 
00125         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00126         |  Next Header  |  Hdr Ext Len  | Routing Type=0| Segments Left |
00127         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00128         |                            Reserved                           |
00129         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00130         |                                                               |
00131         +
00132         |                                                               |
00133         +                           Address[1]
00134         |                                                               |
00135         +
00136         |                                                               |
00137         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00138         .                               .                               .
00139         .                               .                               .
00140         .                               .                               .
00141         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00142         |                                                               |
00143         +
00144         |                                                               |
00145         +                           Address[n]
00146         |                                                               |
00147         +
00148         |                                                               |
00149         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00150         */
00151 #       include SENF_PARSER()
00152 
00153         SENF_PARSER_FIELD ( nextHeader, UInt8Parser      );
00154         SENF_PARSER_FIELD ( headerLength, UInt8Parser    );
00155         SENF_PARSER_FIELD ( routingType, UInt8Parser     ); //set to Zero for minimal implementation
00156         SENF_PARSER_FIELD_RO ( segmentsLeft, UInt8Parser );
00157         SENF_PARSER_FIELD ( reserved, UInt32Parser       ); //set to zero by RFC
00158         SENF_PARSER_VECTOR ( hopAddresses, segmentsLeft, INet6AddressParser );
00159 
00160         SENF_PARSER_FINALIZE ( IPv6RoutingPacketParser );
00161 
00162         //provisionary, since only type 0 is implemented
00163         SENF_PARSER_INIT() {
00164             routingType() = 0u;
00165             reserved() = 0u;
00166         }
00167     };
00168 
00185     struct IPv6RoutingPacketType
00186     :   public PacketTypeBase,
00187         public PacketTypeMixin<IPv6RoutingPacketType, IpTypes>
00188     {
00189 #ifndef DOXYGEN
00190         typedef PacketTypeMixin<IPv6RoutingPacketType, IpTypes> mixin;
00191 #endif
00192 
00193         typedef ConcretePacket<IPv6RoutingPacketType> packet;
00195         typedef IPv6RoutingPacketParser parser;
00196 
00197         using mixin::nextPacketRange;
00198         using mixin::nextPacketType;
00199         using mixin::init;
00200         using mixin::initSize;
00201 
00202         static key_t nextPacketKey(packet p)
00203             { return p->nextHeader(); }
00204 
00206         static void dump(packet p, std::ostream & os);
00207 
00208         static void finalize(packet p);
00209     };
00210 
00214     typedef ConcretePacket<IPv6RoutingPacketType> IPv6RoutingPacket;
00215 
00216 
00217 // =====================================================================================================
00218 
00227     struct IPv6HopByHopOptionsPacketParser : public PacketParserBase
00228     {
00229 #       include SENF_PARSER()
00230 
00231         SENF_PARSER_FIELD    ( nextHeader, UInt8Parser   );
00232         SENF_PARSER_FIELD_RO ( headerLength, UInt8Parser );
00233 
00234         typedef detail::FixedAuxParserPolicy<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
00235         typedef detail::ListOptionTypeParser_Policy<
00236             IPv6GenericOptionParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
00237         typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
00238 
00239         SENF_PARSER_FIELD  ( options, ListOptionTypeParser);
00240 
00241         SENF_PARSER_FINALIZE ( IPv6HopByHopOptionsPacketParser );
00242     };
00243 
00260     struct IPv6HopByHopOptionsPacketType
00261     :   public PacketTypeBase,
00262         public PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes>
00263     {
00264 #ifndef DOXYGEN
00265         typedef PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes> mixin;
00266 #endif
00267 
00268         typedef ConcretePacket<IPv6HopByHopOptionsPacketType> packet;
00270         typedef IPv6HopByHopOptionsPacketParser parser;
00271 
00272         using mixin::nextPacketRange;
00273         using mixin::nextPacketType;
00274         using mixin::init;
00275         using mixin::initSize;
00276 
00277         static key_t nextPacketKey(packet p) {
00278             return p->nextHeader(); }
00279 
00281         static void dump(packet p, std::ostream & os);
00282 
00283         static void finalize(packet p);
00284     };
00285 
00289     typedef ConcretePacket<IPv6HopByHopOptionsPacketType> IPv6HopByHopOptionsPacket;
00290 
00291 // =====================================================================================================
00292 
00302     struct IPv6DestinationOptionsPacketParser : public PacketParserBase
00303     {
00304 #       include SENF_PARSER()
00305         SENF_PARSER_FIELD ( nextHeader, UInt8Parser   );
00306         SENF_PARSER_FIELD_RO ( headerLength, UInt8Parser );
00307         typedef detail::FixedAuxParserPolicy<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
00308         typedef detail::ListOptionTypeParser_Policy<
00309             IPv6GenericOptionParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
00310         typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
00311 
00312         SENF_PARSER_FIELD  ( options, ListOptionTypeParser);
00313 
00314         SENF_PARSER_FINALIZE ( IPv6DestinationOptionsPacketParser );
00315     };
00316 
00333     struct IPv6DestinationOptionsPacketType
00334     :   public PacketTypeBase,
00335         public PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes>
00336     {
00337 #ifndef DOXYGEN
00338         typedef PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes> mixin;
00339 #endif
00340 
00341         typedef ConcretePacket<IPv6DestinationOptionsPacketType> packet;
00343         typedef IPv6DestinationOptionsPacketParser parser;
00344 
00345         using mixin::nextPacketRange;
00346         using mixin::nextPacketType;
00347         using mixin::init;
00348         using mixin::initSize;
00349 
00350         static key_t nextPacketKey(packet p)
00351         { return p->nextHeader(); }
00353         static void dump(packet p, std::ostream & os);
00354 
00355         static void finalize(packet p);
00356     };
00357 
00361     typedef ConcretePacket<IPv6DestinationOptionsPacketType> IPv6DestinationOptionsPacket;
00362 
00363 }
00364 
00365 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00366 //#include "IPv6Extensions.cci"
00367 //#include "IPv6Extensions.ct"
00368 //#include "IPv6Extensions.cti"
00369 #endif
00370 
00371 
00372 // Local Variables:
00373 // mode: c++
00374 // fill-column: 100
00375 // c-file-style: "senf"
00376 // indent-tabs-mode: nil
00377 // ispell-local-dictionary: "american"
00378 // compile-command: "scons -u test"
00379 // comment-column: 40
00380 // End:

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