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

Go to the documentation of this file.
00001 // $Id: NDPOptions.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2010
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Sauer <ssauer@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 
00023 // Definition of non-inline non-template functions
00024 
00025 #ifndef HH_SENF_Packets_DefaultBundle_NDPOptions_
00026 #define HH_SENF_Packets_DefaultBundle_NDPOptions_ 1
00027 
00028 // Custom includes
00029 #include <senf/Packets/Packets.hh>
00030 #include <senf/Packets/DefaultBundle/EthernetPacket.hh>
00031 #include <senf/Packets/DefaultBundle/IPv6Packet.hh>
00032 
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 namespace senf {
00035 
00036     //#############################################################
00037     //ICMPv6 Neighbor Discovery (RFC 4861) Options
00038     //#############################################################
00039     struct NDPOptionParser : public PacketParserBase
00040     {
00041     public:
00042 #       include SENF_PARSER()
00043         SENF_PARSER_FIELD    ( type, UInt8Parser );
00044         SENF_PARSER_FIELD    ( length, UInt8Parser );
00045         SENF_PARSER_FINALIZE ( NDPOptionParser );
00046 
00047         typedef GenericTLVParserRegistry<NDPOptionParser> Registry;
00048     };
00049 
00050     struct NDPGenericOptionParser : public GenericTLVParserBase<NDPOptionParser>
00051     {
00052         typedef GenericTLVParserBase<NDPOptionParser> base;
00053         NDPGenericOptionParser(data_iterator i, state_type s) : base(i,s) {}
00054 
00055         senf::PacketParserBase::size_type bytes() const
00056         {
00057             return length()*8;
00058         }
00059     };
00060 
00061     struct NDPSourceLLAddressTLVParser : public NDPOptionParser
00062     {
00063 #       include SENF_PARSER()
00064         SENF_PARSER_INHERIT  ( NDPOptionParser );
00065         SENF_PARSER_FIELD    ( source, MACAddressParser);
00066         SENF_PARSER_FINALIZE ( NDPSourceLLAddressTLVParser);
00067 
00068         SENF_PARSER_INIT() {
00069             defaultInit();
00070             type() = typeId;
00071             length() = 1;
00072         }
00073         static const type_t::value_type typeId = 0x01;
00074         void dump(std::ostream & os) const;
00075     };
00076 
00077     struct NDPTargetLLAddressTLVParser : public NDPOptionParser
00078     {
00079 #       include SENF_PARSER()
00080         SENF_PARSER_INHERIT  ( NDPOptionParser );
00081         SENF_PARSER_FIELD    ( target, MACAddressParser );
00082         SENF_PARSER_FINALIZE ( NDPTargetLLAddressTLVParser );
00083 
00084         SENF_PARSER_INIT() {
00085             defaultInit();
00086             type() = typeId;
00087             length() = 1;
00088         }
00089 
00090         senf::PacketParserBase::size_type bytes(NDPTargetLLAddressTLVParser p) {
00091                     return length()*8;
00092         }
00093         static const type_t::value_type typeId = 0x02;
00094         void dump(std::ostream & os) const;
00095     };
00096 
00097     struct NDPPrefixInformationTLVParser : public NDPOptionParser
00098     {
00099 #       include SENF_PARSER()
00100         SENF_PARSER_INHERIT          ( NDPOptionParser );
00101         SENF_PARSER_FIELD            ( prefixLength, UInt8Parser );
00102         SENF_PARSER_BITFIELD         ( l, 1, bool );
00103         SENF_PARSER_BITFIELD         ( a, 1, bool );
00104         SENF_PARSER_PRIVATE_BITFIELD ( reserved1, 6, unsigned );
00105         SENF_PARSER_FIELD            ( validLifetime, UInt32Parser );
00106         SENF_PARSER_FIELD            ( preferredLifetime, UInt32Parser );
00107         SENF_PARSER_PRIVATE_BITFIELD ( reserved2, 32, unsigned );
00108         SENF_PARSER_FIELD            ( prefix, INet6AddressParser );
00109         SENF_PARSER_FINALIZE         ( NDPPrefixInformationTLVParser );
00110 
00111         SENF_PARSER_INIT() {
00112             defaultInit();
00113             type() = typeId;
00114             length() = 4;
00115             reserved1() = 0;
00116             reserved2() = 0;
00117         }
00118         senf::PacketParserBase::size_type bytes(NDPPrefixInformationTLVParser p) {
00119             return length()*8;
00120         }
00121         static const UInt8Parser::value_type typeId = 0x03;
00122         void dump(std::ostream & os) const;
00123     };
00124 
00125     struct NDPMTUTLVParser : public NDPOptionParser
00126     {
00127 #       include SENF_PARSER()
00128         SENF_PARSER_INHERIT          ( NDPOptionParser );
00129         SENF_PARSER_PRIVATE_BITFIELD ( reserved, 16, unsigned );
00130         SENF_PARSER_FIELD            ( mtu, UInt32Parser );
00131         SENF_PARSER_FINALIZE         ( NDPMTUTLVParser );
00132 
00133         SENF_PARSER_INIT() {
00134             defaultInit();
00135             type() = typeId;
00136             length() = 1;
00137             reserved() = 0;
00138         }
00139         static const UInt8Parser::value_type typeId = 0x05;
00140         void dump(std::ostream & os) const;
00141     };
00142 }
00143 
00144 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00145 //#include "NDPOptions.cci"
00146 //#include "NDPOptions.ct"
00147 //#include "NDPOptions.cti"
00148 #endif
00149 
00150 
00151 // Local Variables:
00152 // mode: c++
00153 // fill-column: 100
00154 // c-file-style: "senf"
00155 // indent-tabs-mode: nil
00156 // ispell-local-dictionary: "american"
00157 // compile-command: "scons -u test"
00158 // comment-column: 40
00159 // End:
00160 

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