Packets: use SENF_PACKET_REGISTRY_REGISTER macro for packet registration
[senf.git] / senf / Packets / DefaultBundle / IPv6Extensions.cc
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //     Philipp Batroff <philipp.batroff@fokus.fraunhofer.de>
8 //
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the
21 // Free Software Foundation, Inc.,
22 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23
24 /** \file
25     \brief IPv6Extensions non-inline non-template implementation */
26
27 #include "IPv6Extensions.hh"
28 //#include "IPv6Extensions.ih"
29 #include <senf/Utils/hexdump.hh>
30 // Custom includes
31
32 //#include "IPv6Extensions.mpp"
33 #define prefix_
34 ///////////////////////////////cc.p////////////////////////////////////////
35
36 namespace {
37     SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 44,  senf::IPv6FragmentPacket           );
38     SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 43,  senf::IPv6RoutingPacket            );
39     SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 0u,  senf::IPv6HopByHopOptionsPacket    );
40     SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 60u, senf::IPv6DestinationOptionsPacket );
41 }
42
43 prefix_ void senf::IPv6FragmentPacketType::dump(packet p, std::ostream & os)
44 {
45     os << "Internet protocol Version 6 fragment extension:\n"
46        <<     "  next header             : " << unsigned(p->nextHeader()) << "\n"
47        <<     "  fragment offset         : " << std::hex << unsigned(p->fragmentOffset()) << "\n"
48        <<     "  more fragments          : " << (p->moreFragments()?"yes":"no") << "\n"
49        <<     "  id                      : " << std::hex << unsigned(p->id()) << "\n";
50 }
51
52 prefix_ void senf::IPv6RoutingPacketType::dump(packet p, std::ostream & os)
53 {
54     os << "Internet protocol Version 6 routing extension:\n"
55        <<     "  next header             : " << unsigned (p->nextHeader()) << "\n"
56        <<     "  header length           : " << unsigned (p->headerLength()) << "\n"
57        <<     "  routing type            : " << unsigned (p->routingType()) << "\n"
58        <<     "  segments left           : " << unsigned (p->segmentsLeft()) << "\n"
59        <<     "  further Hop Addresses   : \n";
60     typedef IPv6RoutingPacket::Parser::hopAddresses_t::container addrContainer_t;
61     addrContainer_t hopAddresses (p->hopAddresses());
62     if ( p->segmentsLeft() != 0 )
63         for (addrContainer_t::iterator i (hopAddresses.begin()); i != hopAddresses.end(); ++i)
64             os << *i << "\n";
65 }
66
67 prefix_ void senf::IPv6HopByHopOptionsPacketType::dump(packet p, std::ostream & os)
68 {
69     os << "Internet protocol Version 6 Hop-By-Hop extension:\n"
70        <<     "  next header             : " << unsigned (p->nextHeader()) << "\n"
71        <<     "  header length           : " << unsigned (p->headerLength()) << "\n";
72     os <<     "  OptionTypes:\n";
73     typedef IPv6HopByHopOptionsPacket::Parser::options_t::container optContainer_t;
74     optContainer_t options (p->options());
75     optContainer_t::iterator optIter(options.begin());
76     for(; optIter != options.end(); ++optIter) {
77         os << "    AltAction             : " << (unsigned) optIter->altAction()
78            << "\n    ChangeFlag            : " << (unsigned) optIter->changeFlag()
79            << "\n    Option Type           : " << (unsigned) optIter->optionType()
80            << "\n    OptionLength          : " << (unsigned)  optIter->optionLength() <<"\n";
81         senf::hexdump(boost::begin(optIter->value()) , boost::end(optIter->value()), os );
82     }
83 }
84
85 prefix_ void senf::IPv6DestinationOptionsPacketType::dump(packet p, std::ostream & os)
86 {
87     os << "Internet protocol Version 6 Destination Options extension:\n"
88        <<     "  next header             : " << unsigned (p->nextHeader()) << "\n"
89        <<     "  header length           : " << unsigned (p->headerLength()) << "\n";
90 }
91
92 ///////////////////////////////cc.e////////////////////////////////////////
93 #undef prefix_
94 //#include "IPv6Extensions.mpp"
95
96 \f
97 // Local Variables:
98 // mode: c++
99 // fill-column: 100
100 // c-file-style: "senf"
101 // indent-tabs-mode: nil
102 // ispell-local-dictionary: "american"
103 // compile-command: "scons -u test"
104 // comment-column: 40
105 // End: