Fixed whitespace in all files (no tabs)
[senf.git] / Packets / IpV6Extensions.hh
1 // Copyright (C) 2007
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 //     Stefan Bund <g0dil@berlios.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
21 /** \file
22     \brief IpV6Extensions public header */
23
24 #ifndef HH_IpV6Extensions_
25 #define HH_IpV6Extensions_ 1
26
27 // Custom includes
28 #include "IpV6Packet.hh"
29
30 //#include "IpV6Extensions.mpp"
31 ///////////////////////////////hh.p////////////////////////////////////////
32
33 namespace senf {
34
35     // See RFC2460
36     template <class Iterator=nil, class IPacket=nil>
37     struct Parse_IpV6Extension_Fragment
38         : public ParserBase<Iterator,IPacket>
39     {
40         template <class I, class P=nil>
41         struct rebind { typedef Parse_IpV6Extension_Fragment<I,P> parser; };
42         typedef Iterator byte_iterator;
43
44         Parse_IpV6Extension_Fragment() {}
45         Parse_IpV6Extension_Fragment(Iterator const & i) : ParserBase<Iterator,IPacket>(i) {}
46
47         static unsigned bytes() { return 8; }
48
49         ///////////////////////////////////////////////////////////////////////////
50
51         typedef Parse_UInt8     <         Iterator > Parse_8bit;
52         typedef Parse_UIntField <  0, 13, Iterator > Parse_Offset;
53         typedef Parse_UIntField < 13, 15, Iterator > Parse_Reserved;
54         typedef Parse_Flag      < 15,     Iterator > Parse_More;
55         typedef Parse_UInt32    <         Iterator > Parse_32bit;
56
57         Parse_8bit      nextHeader()      const { return Parse_8bit      (this->i()      ); }
58         Parse_8bit      reserved1()       const { return Parse_8bit      (this->i() +  1 ); }
59         Parse_Offset    fragmentOffset()  const { return Parse_Offset    (this->i() +  2 ); }
60         Parse_Reserved  reserved2()       const { return Parse_Reserved  (this->i() +  2 ); }
61         Parse_More      moreFragments()   const { return Parse_More      (this->i() +  2 ); }
62         Parse_32bit     id()              const { return Parse_32bit     (this->i() +  4 ); }
63     };
64
65     class IpV6Extension_Fragment
66         : public Packet,
67           public Parse_IpV6Extension_Fragment<Packet::iterator, IpV6Extension_Fragment>,
68           public PacketRegistryMixin<IpTypes, IpV6Extension_Fragment>
69     {
70         using PacketRegistryMixin<IpTypes,IpV6Extension_Fragment>::registerInterpreter;
71     public:
72         ///////////////////////////////////////////////////////////////////////////
73         // Types
74
75         typedef ptr_t<IpV6Extension_Fragment>::ptr ptr;
76
77         ///////////////////////////////////////////////////////////////////////////
78
79     private:
80         template <class Arg>
81         IpV6Extension_Fragment(Arg const & arg);
82
83         virtual void v_nextInterpreter() const;
84         virtual void v_finalize();
85         virtual void v_dump(std::ostream & os) const;
86
87         friend class Packet;
88     };
89 }
90
91 ///////////////////////////////hh.e////////////////////////////////////////
92 //#include "IpV6Extensions.cci"
93 #include "IpV6Extensions.ct"
94 //#include "IpV6Extensions.cti"
95 #endif
96
97 \f
98 // Local Variables:
99 // mode: c++
100 // fill-column: 100
101 // c-file-style: "senf"
102 // indent-tabs-mode: nil
103 // ispell-local-dictionary: "american"
104 // End: