NDPOptions.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 #ifndef HH_SENF_Packets_DefaultBundle_NDPOptions_
15 #define HH_SENF_Packets_DefaultBundle_NDPOptions_ 1
16 
17 // Custom includes
18 #include <senf/Packets/Packets.hh>
21 
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 namespace senf {
24 
25  //#############################################################
26  //ICMPv6 Neighbor Discovery (RFC 4861) Options
27  //#############################################################
29  {
30  public:
31 # include SENF_PARSER()
35 
37  };
38 
39  struct NDPGenericOptionParser : public GenericTLVParserBase<NDPOptionParser>
40  {
43 
45  {
46  return length()*8;
47  }
48  };
49 
51  {
52 # include SENF_PARSER()
56 
58  defaultInit();
59  type() = typeId;
60  length() = 1;
61  }
62  static const type_t::value_type typeId = 0x01;
63  void dump(std::ostream & os) const;
64  };
65 
67  {
68 # include SENF_PARSER()
72 
74  defaultInit();
75  type() = typeId;
76  length() = 1;
77  }
78 
80  return length()*8;
81  }
82  static const type_t::value_type typeId = 0x02;
83  void dump(std::ostream & os) const;
84  };
85 
87  {
88 # include SENF_PARSER()
90 
91  SENF_PARSER_FIELD( prefixLength, UInt8Parser );
92 
93  SENF_PARSER_BITFIELD ( l, 1, bool );
94  SENF_PARSER_BITFIELD ( a, 1, bool );
95  SENF_PARSER_PRIVATE_BITFIELD( reserved1, 6, unsigned );
96 
97  SENF_PARSER_FIELD( validLifetime, UInt32Parser );
98  SENF_PARSER_FIELD( preferredLifetime, UInt32Parser );
99 
102 
104 
106  defaultInit();
107  type() = typeId;
108  length() = 4;
109  reserved1() = 0;
110  reserved2() = 0;
111  }
113  return length()*8;
114  }
115  static const UInt8Parser::value_type typeId = 0x03;
116  void dump(std::ostream & os) const;
117  };
118 
120  {
121 # include SENF_PARSER()
123 
126 
128 
130  defaultInit();
131  type() = typeId;
132  length() = 1;
133  reserved() = 0;
134  }
135  static const UInt8Parser::value_type typeId = 0x05;
136  void dump(std::ostream & os) const;
137  };
138 }
139 
140 //-/////////////////////////////////////////////////////////////////////////////////////////////////
141 //#include "NDPOptions.cci"
142 //#include "NDPOptions.ct"
143 //#include "NDPOptions.cti"
144 #endif
145 
146 
147 // Local Variables:
148 // mode: c++
149 // fill-column: 100
150 // c-file-style: "senf"
151 // indent-tabs-mode: nil
152 // ispell-local-dictionary: "american"
153 // compile-command: "scons -u test"
154 // comment-column: 40
155 // End:
156 
#define SENF_PARSER_INHERIT(base)
Define parser inheritance.
senf::PacketParserBase::size_type bytes(NDPPrefixInformationTLVParser p)
Definition: NDPOptions.hh:112
IPv6Packet public header.
EthernetPacket public header.
#define SENF_PARSER_BITFIELD(name, bits, type)
Define bit-field.
Parse 8bit unsigned byte aligned integer.
Definition: IntParser.hh:91
TLV parser registration facility.
Definition: GenericTLV.hh:227
Packets public header.
Base class for generic TLV parsers.
Definition: GenericTLV.hh:124
#define SENF_PARSER_FIELD(name, type)
Define normal parser field.
#define SENF_PARSER_PRIVATE_FIELD(name, type)
Define parser field (private)
Parse an Ethernet MAC address.
senf::PacketParserBase::size_type bytes(NDPTargetLLAddressTLVParser p)
Definition: NDPOptions.hh:79
#define SENF_PARSER_FINALIZE(name)
Generate parser control members.
GenericTLVParserBase< NDPOptionParser > base
Definition: NDPOptions.hh:41
void dump(std::ostream &os, DirectoryNode &dir=root())
void defaultInit() const
Default implementation.
Packet data STL-sequence view.
Definition: PacketData.hh:61
#define SENF_PARSER_INIT()
Define parser initialization routine.
boost::uint8_t value_type
Definition: IntParser.hh:99
data_iterator i() const
Return beginning of data to parse.
UInt8Parser type() const
__u8 reserved[3]
detail::packet::size_type size_type
Unsigned integral type.
UInt8Parser length() const
NDPGenericOptionParser(data_iterator i, state_type s)
Definition: NDPOptions.hh:42
Parser Base class.
Parse 32bit unsigned byte aligned integer.
Definition: IntParser.hh:310
Parse an IPv6 address.
Definition: IPv6Packet.hh:33
#define SENF_PARSER_PRIVATE_BITFIELD(name, bits, type)
Define bit-field (private)
Parse 16bit unsigned byte aligned integer.
Definition: IntParser.hh:174
GenericTLVParserRegistry< NDPOptionParser > Registry
Definition: NDPOptions.hh:33
senf::PacketParserBase::size_type bytes() const
Definition: NDPOptions.hh:44
detail::packet::iterator data_iterator
Raw data iterator type.