Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

DefaultBundle/IPv6Extensions.cc

Go to the documentation of this file.
00001 // $Id: IPv6Extensions.cc 1754 2010-12-09 15:45:42Z tho $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //     Philipp Batroff <philipp.batroff@fit.fraunhofer.de>
00008 //
00009 // This program is free software; you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation; either version 2 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with this program; if not, write to the
00021 // Free Software Foundation, Inc.,
00022 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 
00027 #include "IPv6Extensions.hh"
00028 //#include "IPv6Extensions.ih"
00029 
00030 // Custom includes
00031 
00032 //#include "IPv6Extensions.mpp"
00033 #define prefix_
00034 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00035 
00036 namespace {
00037     SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 44,  senf::IPv6FragmentPacket           );
00038     SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 43,  senf::IPv6RoutingPacket            );
00039     SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 0u,  senf::IPv6HopByHopOptionsPacket    );
00040     SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 60u, senf::IPv6DestinationOptionsPacket );
00041 }
00042 
00043 prefix_ void senf::IPv6FragmentPacketType::dump(packet p, std::ostream & os)
00044 {
00045     os << "Internet protocol Version 6 fragment extension:\n"
00046        << senf::fieldName("next header")               << unsigned(p->nextHeader()) << "\n"
00047        << senf::fieldName("fragment offset")
00048        << "0x" << std::hex << unsigned(p->fragmentOffset()) << "\n"
00049        << senf::fieldName("more fragments")            << (p->moreFragments()?"yes":"no") << "\n"
00050        << senf::fieldName("id")
00051        << "0x" << std::hex << unsigned(p->id()) << "\n";
00052 }
00053 
00054 prefix_ void senf::IPv6FragmentPacketType::finalize(packet p)
00055 {
00056     try {
00057         p->nextHeader() << key(p.next());
00058     }
00059     catch (InvalidPacketChainException & ex) {
00060         p->nextHeader() << 59; // No next header
00061     }
00062 }
00063 
00064 prefix_ void senf::IPv6RoutingPacketType::dump(packet p, std::ostream & os)
00065 {
00066     os << "Internet protocol Version 6 routing extension:\n"
00067        << senf::fieldName("next header")               << unsigned(p->nextHeader()) << "\n"
00068        << senf::fieldName("header length")             << unsigned(p->headerLength()) << "\n"
00069        << senf::fieldName("routing type")              << unsigned(p->routingType()) << "\n"
00070        << senf::fieldName("segments left")             << unsigned(p->segmentsLeft()) << "\n"
00071        << "  further Hop Addresses:\n";
00072     typedef IPv6RoutingPacket::Parser::hopAddresses_t::container addrContainer_t;
00073     addrContainer_t hopAddresses (p->hopAddresses());
00074     if ( p->segmentsLeft() != 0 )
00075         for (addrContainer_t::iterator i (hopAddresses.begin()); i != hopAddresses.end(); ++i)
00076             os << "    " << *i << "\n";
00077 }
00078 
00079 prefix_ void senf::IPv6RoutingPacketType::finalize(packet p)
00080 {
00081     try {
00082         p->nextHeader() << key(p.next());
00083     }
00084     catch (InvalidPacketChainException & ex) {
00085         p->nextHeader() << 59; // No next header
00086     }
00087 }
00088 
00089 prefix_ void senf::IPv6HopByHopOptionsPacketType::dump(packet p, std::ostream & os)
00090 {
00091     os << "Internet protocol Version 6 Hop-By-Hop extension:\n"
00092        << senf::fieldName("next header")               << unsigned(p->nextHeader()) << "\n"
00093        << senf::fieldName("header length")             << unsigned(p->headerLength()) <<" ("<< unsigned((1+p->headerLength())*8)<< ")\n";
00094     os << "  OptionTypes:\n";
00095     typedef IPv6HopByHopOptionsPacket::Parser::options_t::container optContainer_t;
00096     optContainer_t options (p->options());
00097     for (optContainer_t::const_iterator i = options.begin(); i != options.end(); ++i)
00098         i->dump( os);
00099 }
00100 
00101 prefix_ void senf::IPv6HopByHopOptionsPacketType::finalize(packet p)
00102 {
00103     try {
00104         p->nextHeader() << key(p.next());
00105     }
00106     catch (InvalidPacketChainException & ex) {
00107         p->nextHeader() << 59; // No next header
00108     }
00109 }
00110 
00111 prefix_ void senf::IPv6DestinationOptionsPacketType::dump(packet p, std::ostream & os)
00112 {
00113     os << "Internet protocol Version 6 Destination Options extension:\n"
00114        << senf::fieldName("next header")               << unsigned (p->nextHeader()) << "\n"
00115        << senf::fieldName("header length")             << unsigned (p->headerLength()) << "\n";
00116     os << "  OptionTypes:\n";
00117     typedef IPv6DestinationOptionsPacket::Parser::options_t::container optContainer_t;
00118     optContainer_t options (p->options());
00119     for (optContainer_t::const_iterator i = options.begin(); i != options.end(); ++i)
00120         i->dump( os);
00121 }
00122 
00123 prefix_ void senf::IPv6DestinationOptionsPacketType::finalize(packet p)
00124 {
00125     try {
00126         p->nextHeader() << key(p.next());
00127     }
00128     catch (InvalidPacketChainException & ex) {
00129         p->nextHeader() << 59; // No next header
00130     }
00131 }
00132 
00133 
00134 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00135 #undef prefix_
00136 //#include "IPv6Extensions.mpp"
00137 
00138 
00139 // Local Variables:
00140 // mode: c++
00141 // fill-column: 100
00142 // c-file-style: "senf"
00143 // indent-tabs-mode: nil
00144 // ispell-local-dictionary: "american"
00145 // compile-command: "scons -u test"
00146 // comment-column: 40
00147 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research