ICMPv6TypePacket.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 
14 #include "ICMPv6TypePacket.hh"
15 
16 // Custom includes
17 
18 #define prefix_
19 //-/////////////////////////////////////////////////////////////////////////////////////////////////
20 
34 
48 
49 
51 {
52  ICMPv6Packet icmpv6 (Packet().rfind<ICMPv6Packet>(senf::nothrow));
53  icmpv6->code() = code;
54 }
55 
57 {
58  ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
59  icmpv6->code() = code;
60 }
61 
63 {
64  ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
65  icmpv6->code() = code;
66 }
67 
69 {
70  os << "ICMPv6 Echo Request:\n"
71  << senf::fieldName("Identifier") << p->identifier() << "\n"
72  << senf::fieldName("SequenceNumber") << p->seqNr() << "\n";
73 }
74 
76 {
77  os << "ICMPv6 Echo Reply:\n"
78  << senf::fieldName("Identifier") << p->identifier() << "\n"
79  << senf::fieldName("SequenceNumber") << p->seqNr() << "\n";
80 }
81 
83 {
84  os << "ICMPv6 Error Destination Unreachable (no further fields available here)\n";
85 }
86 
88 {
89  os << "ICMPv6 Error Packet Too Big:\n"
90  << senf::fieldName("MTU") << p->mtu() << "\n";
91 }
92 
94 {
95  os << "ICMPv6 Error Time Exceeded:\n"
96  << senf::fieldName("Unused(32Bit)") << p->unused() << "\n";
97 }
98 
100 {
101  os << "ICMPv6 Error Parameter Problem:\n"
102  << senf::fieldName("Pointer") << p->pointer() << "\n";
103 }
104 
106 {
107  os << "ICMPv6 Multicast Listener Query:\n"
108  << senf::fieldName("Max. ResponseCode") << p->maxResponseCode() << "\n"
109  << senf::fieldName("Reserved(16Bit)") << p->reserved() << "\n"
110  << senf::fieldName("Multicast Address") << p->mcAddress() << "\n"
111  << senf::fieldName("Reserver(4Bit)") << p->resv() << "\n"
112  << senf::fieldName("Suppress Router-Side Processing") << p->sFlag() << "\n"
113  << senf::fieldName("Querier's Robustness Variable") << p->qrv() << "\n"
114  << senf::fieldName("Querier's Query Interval Code") << p->qqic() << "\n"
115  << " Source Addresses:\n";
116  parser::srcAddresses_t::container_type c (p->srcAddresses());
118  for (unsigned int nr =1; i != c.end(); ++i, ++nr)
119  os << " " << nr << ".) " << *i << "\n";
120  os << "\n";
121 }
122 
124 {
125  os << "ICMPv6 Multicast Listener Report Message:\n"
126  << senf::fieldName("Reserved") << p->reserved()
127  <<"\n Multicast Address Records:\n";
128 
129  MLDv2ListenerReport::Parser::mcastAddrRecords_t::container_type cAddrR (p->mcastAddrRecords() );
131  for (; iAddrR != cAddrR.end(); ++iAddrR) {
132  os << senf::fieldName(" Record Type") << unsigned(iAddrR->recordType()) << "\n"
133  << senf::fieldName(" Multicast Address") << iAddrR->mcAddress() << "\n"
134  << " Source Addresses\n:";
135  MLDv2AddressRecordParser::srcAddresses_t::container_type cSrcAddr (iAddrR->srcAddresses());
137  for (;iSrcAddr != cSrcAddr.end();++iSrcAddr)
138  os << " " << *iSrcAddr << "\n";
139  os << " Auxiliary Data:\n";
140  MLDv2AddressRecordParser::auxData_t::container_type cAuxD ( iAddrR->auxData() );
142  for (;iAuxD != cAuxD.end(); ++iAuxD)
143  os << " " << *iAuxD << "\n";
144  }
145 }
146 
148 {
149  os << "ICMPv6 Neighbor Discovery Router Solicitation Message:\n"
150  << senf::fieldName("Reserved(32Bit)") << unsigned(p->reserved()) << "\n";
151  parser::options_t::container_type optC (p->options());
153  for (; listIter != optC.end(); ++listIter) {
154  listIter->dump(os);
155  }
156 }
157 
159 {
160  os << "ICMPv6 Neighbor Discovery Router Advertisement Message:\n"
161  << senf::fieldName("Current Hop Limit") << unsigned(p->curHopLimit()) << "\n"
162  << senf::fieldName("Managed Address Configuration") << unsigned(p->m()) << "\n"
163  << senf::fieldName("Other Configuration") << unsigned(p->o()) << "\n"
164  << senf::fieldName("Reserved(6Bit)") << unsigned(p->reserved()) << "\n"
165  << senf::fieldName("Router Lifetime") << unsigned(p->routerLifetime()) << "\n"
166  << senf::fieldName("Reachable Time") << unsigned(p->reachableTime()) << "\n"
167  << senf::fieldName("Retrans Timer") << unsigned(p->retransTimer()) << "\n";
168  parser::options_t::container_type optC (p->options());
170  for (; listIter != optC.end(); ++listIter) {
171  listIter->dump(os);
172  }
173 }
174 
176 {
177  os << "ICMPv6 Neighbor Discovery Neighbor Solicitation Message:\n"
178  << senf::fieldName("Reserved(32Bit)") << unsigned(p->reserved()) << "\n"
179  << senf::fieldName("Target Address") << p->target() << "\n";
180  parser::options_t::container_type optC (p->options());
182  for (; listIter != optC.end(); ++listIter) {
183  listIter->dump(os);
184  }
185 }
186 
188 {
189  os << "ICMPv6 Neighbor Discovery Neighbor Advertisement Message:\n"
190  << senf::fieldName("Router Flag") << unsigned(p->r()) << "\n"
191  << senf::fieldName("Solicited Flag") << unsigned(p->s()) << "\n"
192  << senf::fieldName("Override Flag") << unsigned(p->o()) << "\n"
193  << senf::fieldName("Reserved(29Bit)") << unsigned(p->reserved()) << "\n"
194  << senf::fieldName("Target Address") << p->target() << "\n";
195  parser::options_t::container_type optC(p->options() );
197  for (; listIter != optC.end(); ++listIter) {
198  listIter->dump(os);
199  }
200 }
201 
203 {
204  os << "ICMPv6 Neighbor Discovery Redirect Message:\n"
205  << senf::fieldName("Reserved(32Bit)") << unsigned(p->reserved()) << "\n"
206  << senf::fieldName("Target Address") << p->target() << "\n"
207  << senf::fieldName("Destination Address") << p->destination() << "\n";
208  parser::options_t::container_type optC(p->options() );
210  for (; listIter != optC.end(); ++listIter) {
211  listIter->dump(os);
212  }
213 }
214 //-/////////////////////////////////////////////////////////////////////////////////////////////////
215 #undef prefix_
static void dump(packet p, std::ostream &os)
static void dump(packet p, std::ostream &os)
Packet packet() const
Get packet this parser is parsing from.
static void dump(packet p, std::ostream &os)
static void dump(packet p, std::ostream &os)
std::string fieldName(std::string const &s)
Definition: DumpFormat.cc:28
static void dump(packet p, std::ostream &os)
raw_container::const_iterator const_iterator
Definition: PacketTypes.hh:70
static void dump(packet p, std::ostream &os)
Main Packet class.
Definition: Packet.hh:131
Protocol specific packet handle.
Definition: Packet.hh:87
static void dump(packet p, std::ostream &os)
data_iterator i() const
Return beginning of data to parse.
raw_container::iterator iterator
Definition: PacketTypes.hh:69
static void dump(packet p, std::ostream &os)
static void dump(packet p, std::ostream &os)
static void dump(packet p, std::ostream &os)
SENF_PACKET_REGISTRY_REGISTER(senf::ICMPTypes, 1, senf::ICMPv6ErrDestUnreachable)
nothrow
static void dump(packet p, std::ostream &os)
static void dump(packet p, std::ostream &os)
SENF_PACKET_INSTANTIATE_TEMPLATE(senf::ICMPv6ErrDestUnreachable)
VectorParser container wrapper.
Definition: VectorParser.hh:31
#define prefix_
static void dump(packet p, std::ostream &os)