Apply senf::fieldName() to all packet dump methods
[senf.git] / senf / Packets / DefaultBundle / ICMPv6TypePacket.cc
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Philipp Batroff <pug@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 // Custom includes
26 #include <senf/Packets/Packets.hh>
27 #include "ICMPv6Packet.hh"
28 #include "ICMPv6TypePacket.hh"
29
30 #define prefix_
31 namespace {
32 //Implementing the ICMPv6 Type registry
33     senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6ErrDestUnreachable>
34         registerICMPv6ErrDestUnreachable (1);
35     senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6ErrTooBig>
36         registerICMPv6ErrTooBig (2);
37     senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6ErrTimeExceeded>
38         registerICMPv6ErrTimeExceeded (3);
39     senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6ErrParamProblem>
40         registerICMPv6ErrParamProblem (4);
41     senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6EchoRequest>
42         registerICMPv6EchoRequest (128);
43     senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6EchoReply>
44         registerICMPv6EchoReply (129);
45     senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::MLDv2ListenerQuery>
46         registerMLDv2ListenerQuery (130);
47     senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::MLDv2ListenerReport>
48         registerMLDv2ListenerReport (143);
49 }
50
51 prefix_ void senf::ICMPv6EchoRequestType::dump(packet p, std::ostream & os)
52 {
53     os << "ICMPv6 Echo Request:\n"
54        << senf::fieldName("Identifier")                << unsigned(p->identifier()) << "\n"
55        << senf::fieldName("SequenceNumber")            << unsigned(p->seqNr() ) << "\n";
56 }
57
58 prefix_ void senf::ICMPv6EchoReplyType::dump(packet p, std::ostream & os)
59 {
60     os << "ICMPv6 Echo Reply:\n"
61        << senf::fieldName("Identifier")                << unsigned(p->identifier()) << "\n"
62        << senf::fieldName("SequenceNumber")            << unsigned(p->seqNr()) << "\n";
63 }
64
65 prefix_ void senf::ICMPv6ErrDestUnreachableType::dump(packet p, std::ostream & os)
66 {
67     os << "ICMPv6 Error Destination Unreachable (no further fields available here)\n";    
68 }
69
70 prefix_ void senf::ICMPv6ErrTooBigType::dump(packet p, std::ostream & os)
71 {
72     os << "ICMPv6 Error Packet Too Big:\n"
73        << senf::fieldName("MTU")                       << unsigned(p->mtu() ) << "\n";    
74 }
75
76 prefix_ void senf::ICMPv6ErrTimeExceededType::dump(packet p, std::ostream & os)
77 {
78     os << "ICMPv6 Error Time Exceeded:\n"
79        << senf::fieldName("Unused(32Bit)")             << unsigned(p->unused() ) << "\n";    
80 }
81
82 prefix_ void senf::ICMPv6ErrParamProblemType::dump(packet p, std::ostream & os)
83 {
84     os << "ICMPv6 Error Parameter Problem:\n"
85        << senf::fieldName("Pointer")                   << unsigned(p->pointer() ) << "\n";    
86 }
87
88 prefix_ void senf::MLDv2ListenerQueryType::dump(packet p, std::ostream & os)
89 {
90     os << "ICMPv6 Multicast Listener Query:\n"
91        << senf::fieldName("Max. ResponseCode")         << unsigned(p->maxResponseCode()) << "\n"
92        << senf::fieldName("Reserved(16Bit)")           << unsigned(p->reserved()) << "\n"
93        << senf::fieldName("Multicast Address")         << p->mcAddress() << "\n"
94        << senf::fieldName("Reserver(4Bit)")            << unsigned(p->resv()) << "\n"
95        << senf::fieldName("Suppress Router-Side Processing") << unsigned(p->sFlag()) << "\n"
96        << senf::fieldName("Querier's Robustness Variable") << unsigned(p->qrv()) << "\n"
97        << senf::fieldName("Querier's Query Interval Code") << unsigned(p->qqic()) << "\n"
98        << "  Source Addresses:\n";
99     senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container c (p->srcAddresses());
100     senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container::iterator i (c.begin());
101     for (unsigned int nr =1; i != c.end(); ++i, ++nr)
102         os << "    " << nr << ".) " << *i << "\n";    
103     os << "\n";    
104 }
105
106 prefix_ void senf::MLDv2ListenerReportType::dump(packet p, std::ostream & os)
107 {
108     os << "ICMPv6 Multicast Listener Report Message:\n"
109        << senf::fieldName("Reserved")                  << unsigned(p->reserved() ) 
110        <<"\n  Multicast Address Records:\n";
111     
112     senf::MLDv2ListenerReport::Parser::mcastAddrRecords_t::container cAddrR (p->mcastAddrRecords() );
113     senf::MLDv2ListenerReport::Parser::mcastAddrRecords_t::container::iterator iAddrR (cAddrR.begin() );
114     for (; iAddrR != cAddrR.end(); ++iAddrR) {
115         os << senf::fieldName("  Record Type")         << unsigned(iAddrR->recordType()) << "\n"
116            << senf::fieldName("  Multicast Address")   << iAddrR->mcAddress() << "\n"
117            << "    Source Addresses\n:";
118         senf::MLDv2AddressRecordParser::srcAddresses_t::container cSrcAddr (iAddrR->srcAddresses());
119         senf::MLDv2AddressRecordParser::srcAddresses_t::container::iterator iSrcAddr (cSrcAddr.begin());
120         for (;iSrcAddr != cSrcAddr.end();++iSrcAddr)
121             os << "      " << *iSrcAddr << "\n";
122         os << "    Auxiliary Data:\n";
123         senf::MLDv2AddressRecordParser::auxData_t::container cAuxD ( iAddrR->auxData() );
124         senf::MLDv2AddressRecordParser::auxData_t::container::iterator iAuxD (cAuxD.begin() );
125         for (;iAuxD != cAuxD.end(); ++iAuxD)
126             os << "      " << *iAuxD << "\n";
127     }
128 }
129
130 #undef prefix_