Utils: fixed typo on TypeIdValue
[senf.git] / senf / Packets / DefaultBundle / NDPOptions.hh
1 // $Id$
2 //
3 // Copyright (C) 2010
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Sauer <ssauer@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 // Definition of non-inline non-template functions
24
25 #ifndef HH_SENF_Packets_DefaultBundle_NDPOptions_
26 #define HH_SENF_Packets_DefaultBundle_NDPOptions_ 1
27
28 // Custom includes
29 #include <senf/Packets/Packets.hh>
30 #include <senf/Packets/DefaultBundle/EthernetPacket.hh>
31 #include <senf/Packets/DefaultBundle/IPv6Packet.hh>
32
33 ///////////////////////////////hh.p////////////////////////////////////////
34 namespace senf {
35
36     //#############################################################
37     //ICMPv6 Neighbor Discovery (RFC 4861) Options
38     //#############################################################
39     struct NDPOptionParser : public PacketParserBase
40     {
41     public:
42 #       include SENF_PARSER()
43         SENF_PARSER_FIELD    ( type, UInt8Parser );
44         SENF_PARSER_FIELD    ( length, UInt8Parser );
45         SENF_PARSER_FINALIZE ( NDPOptionParser );
46
47         typedef GenericTLVParserRegistry<NDPOptionParser> Registry;
48     };
49     typedef GenericTLVParserBase<NDPOptionParser> NDPGenericOptionParser;
50
51     struct NDPSourceLLAddressTLVParser : public NDPOptionParser
52     {
53 #       include SENF_PARSER()
54         SENF_PARSER_INHERIT  ( NDPOptionParser );
55         SENF_PARSER_FIELD    ( source, MACAddressParser);
56         SENF_PARSER_FINALIZE ( NDPSourceLLAddressTLVParser);
57
58         SENF_PARSER_INIT() {
59             defaultInit();
60             type() = typeId;
61             length() = 1;
62         }
63         static const type_t::value_type typeId = 0x01;
64         void dump(std::ostream & os) const;
65     };
66
67     struct NDPTargetLLAddressTLVParser : public NDPOptionParser
68     {
69 #       include SENF_PARSER()
70         SENF_PARSER_INHERIT  ( NDPOptionParser );
71         SENF_PARSER_FIELD    ( target, MACAddressParser );
72         SENF_PARSER_FINALIZE ( NDPTargetLLAddressTLVParser );
73
74         SENF_PARSER_INIT() {
75             defaultInit();
76             type() = typeId;
77             length() = 1;
78         }
79         static const UInt8Parser::value_type typeId = 0x02;
80         void dump(std::ostream & os) const;
81     };
82
83     struct NDPPrefixInformationTLVParser : public NDPOptionParser
84     {
85 #       include SENF_PARSER()
86         SENF_PARSER_INHERIT          ( NDPOptionParser );
87         SENF_PARSER_FIELD            ( prefixLength, UInt8Parser );
88         SENF_PARSER_BITFIELD         ( l, 1, bool );
89         SENF_PARSER_BITFIELD         ( a, 1, bool );
90         SENF_PARSER_PRIVATE_BITFIELD ( reserved1, 6, unsigned );
91         SENF_PARSER_FIELD            ( validLifetime, UInt32Parser );
92         SENF_PARSER_FIELD            ( preferredLifetime, UInt32Parser );
93         SENF_PARSER_PRIVATE_BITFIELD ( reserved2, 32, unsigned );
94         SENF_PARSER_FIELD            ( prefix, INet6AddressParser );
95         SENF_PARSER_FINALIZE         ( NDPPrefixInformationTLVParser );
96
97         SENF_PARSER_INIT() {
98             defaultInit();
99             type() = typeId;
100             length() = 4;
101             reserved1() = 0;
102             reserved2() = 0;
103         }
104         static const UInt8Parser::value_type typeId = 0x03;
105         void dump(std::ostream & os) const;
106     };
107
108     struct NDPMTUTLVParser : public NDPOptionParser
109     {
110 #       include SENF_PARSER()
111         SENF_PARSER_INHERIT          ( NDPOptionParser );
112         SENF_PARSER_PRIVATE_BITFIELD ( reserved, 16, unsigned );
113         SENF_PARSER_FIELD            ( mtu, UInt32Parser );
114         SENF_PARSER_FINALIZE         ( NDPMTUTLVParser );
115
116         SENF_PARSER_INIT() {
117             defaultInit();
118             type() = typeId;
119             length() = 1;
120             reserved() = 0;
121         }
122         static const UInt8Parser::value_type typeId = 0x05;
123         void dump(std::ostream & os) const;
124     };
125 }
126
127 ///////////////////////////////hh.e////////////////////////////////////////
128 //#include "NDPOptions.cci"
129 //#include "NDPOptions.ct"
130 //#include "NDPOptions.cti"
131 #endif
132
133 \f
134 // Local Variables:
135 // mode: c++
136 // fill-column: 100
137 // c-file-style: "senf"
138 // indent-tabs-mode: nil
139 // ispell-local-dictionary: "american"
140 // compile-command: "scons -u test"
141 // comment-column: 40
142 // End:
143