IPv6Extensions.cc
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 
17 #include "IPv6Extensions.hh"
18 
19 // Custom includes
20 
21 #define prefix_
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
28 
33 
34 //-/////////////////////////////////////////////////////////////////////////////////////////////////
35 // senf::IPv6FragmentPacketType
36 
38 {
39  os << "Internet protocol Version 6 fragment extension:\n"
40  << senf::fieldName("next header") << unsigned(p->nextHeader()) << "\n"
41  << senf::fieldName("fragment offset")
42  << "0x" << std::hex << unsigned(p->fragmentOffset()) << "\n"
43  << senf::fieldName("more fragments") << (p->moreFragments()?"yes":"no") << "\n"
44  << senf::fieldName("id")
45  << "0x" << std::hex << unsigned(p->id()) << "\n";
46 }
47 
49 {
50  try {
51  p->nextHeader() << key(p.next());
52  }
53  catch (InvalidPacketChainException & ex) {
54  p->nextHeader() << 59; // No next header
55  }
56 }
57 
58 //-/////////////////////////////////////////////////////////////////////////////////////////////////
59 // senf::IPv6RoutingPacketType
60 
62 {
63  os << "Internet protocol Version 6 routing extension:\n"
64  << senf::fieldName("next header") << unsigned(p->nextHeader()) << "\n"
65  << senf::fieldName("header length") << unsigned(p->headerLength()) << "\n"
66  << senf::fieldName("routing type") << unsigned(p->routingType()) << "\n"
67  << senf::fieldName("segments left") << unsigned(p->segmentsLeft()) << "\n"
68  << " further Hop Addresses:\n";
69  typedef IPv6RoutingPacket::Parser::hopAddresses_t::container_type addrContainer_t;
70  addrContainer_t hopAddresses (p->hopAddresses());
71  if ( p->segmentsLeft() != 0 )
72  for (addrContainer_t::iterator i (hopAddresses.begin()); i != hopAddresses.end(); ++i)
73  os << " " << *i << "\n";
74 }
75 
77 {
78  try {
79  p->nextHeader() << key(p.next());
80  }
81  catch (InvalidPacketChainException & ex) {
82  p->nextHeader() << 59; // No next header
83  }
84 }
85 
86 //-/////////////////////////////////////////////////////////////////////////////////////////////////
87 // senf::IPv6HopByHopOptionsPacketType
88 
90 {
91  os << "Internet protocol Version 6 Hop-By-Hop extension:\n"
92  << senf::fieldName("next header") << unsigned(p->nextHeader()) << "\n"
93  << senf::fieldName("header length") << unsigned(p->headerLength()) <<" ("<< unsigned((1+p->headerLength())*8)<< ")\n";
94  os << " OptionTypes:\n";
95  typedef IPv6HopByHopOptionsPacket::Parser::options_t::container_type optContainer_t;
96  optContainer_t options (p->options());
97  for (optContainer_t::const_iterator i = options.begin(); i != options.end(); ++i)
98  i->dump( os);
99 }
100 
102 {
103  try {
104  p->nextHeader() << key(p.next());
105  }
106  catch (InvalidPacketChainException & ex) {
107  p->nextHeader() << 59; // No next header
108  }
109 }
110 
111 //-/////////////////////////////////////////////////////////////////////////////////////////////////
112 // senf::EthernetPacketType
113 
115 {
116  os << "Internet protocol Version 6 Destination Options extension:\n"
117  << senf::fieldName("next header") << unsigned (p->nextHeader()) << "\n"
118  << senf::fieldName("header length") << unsigned (p->headerLength()) << "\n";
119  os << " OptionTypes:\n";
120  typedef IPv6DestinationOptionsPacket::Parser::options_t::container_type optContainer_t;
121  optContainer_t options (p->options());
122  for (optContainer_t::const_iterator i = options.begin(); i != options.end(); ++i)
123  i->dump( os);
124 }
125 
127 {
128  try {
129  p->nextHeader() << key(p.next());
130  }
131  catch (InvalidPacketChainException & ex) {
132  p->nextHeader() << 59; // No next header
133  }
134 }
135 
136 //-/////////////////////////////////////////////////////////////////////////////////////////////////
137 #undef prefix_
138 
139 
140 // Local Variables:
141 // mode: c++
142 // fill-column: 100
143 // c-file-style: "senf"
144 // indent-tabs-mode: nil
145 // ispell-local-dictionary: "american"
146 // compile-command: "scons -u test"
147 // comment-column: 40
148 // End:
static optional_key_t key(Packet const &p)
Find key of packet from registry.
static void dump(packet p, std::ostream &os)
Dump given IPv6FragmentPacket in readable form to given output stream.
std::string fieldName(std::string const &s)
Definition: DumpFormat.cc:28
static void finalize(packet p)
SENF_PACKET_INSTANTIATE_TEMPLATE(senf::IPv6FragmentPacket)
raw_container::const_iterator const_iterator
Definition: PacketTypes.hh:70
Protocol specific packet handle.
Definition: Packet.hh:87
Invalid packet chain operation.
Packet next() const
Get next packet in chain.
raw_container::iterator iterator
Definition: PacketTypes.hh:69
static void dump(packet p, std::ostream &os)
Dump given IPv6RoutingPacket in readable form to given output stream.
static const IPTypes::key_t ipType
static void finalize(packet p)
static const IPTypes::key_t ipType
SENF_PACKET_REGISTRY_REGISTER(senf::IPTypes, senf::IPv6FragmentPacketType::ipType, senf::IPv6FragmentPacket)
static void dump(packet p, std::ostream &os)
Dump given IPv6DestinationOptionsPacket in readable form to given output stream.
static const IPTypes::key_t ipType
static void dump(packet p, std::ostream &os)
Dump given IPv6HopByHopOptionsPacket in readable form to given output stream.
IPv6Extensions public header.
static const IPTypes::key_t ipType
IP protocol number registry.
Definition: Registries.hh:60
#define prefix_