00001 // $Id: IPv6Packet.cc 1792 2011-06-09 15:49:59Z 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 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the 00020 // Free Software Foundation, Inc., 00021 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00026 #include "IPv6Packet.hh" 00027 //#include "IPv6Packet.ih" 00028 00029 // Custom includes 00030 #include <iomanip> 00031 #include <boost/io/ios_state.hpp> 00032 #include "EthernetPacket.hh" 00033 00034 //#include "IPv6Packet.mpp" 00035 #define prefix_ 00036 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00037 00038 namespace { 00039 SENF_PACKET_REGISTRY_REGISTER( senf::EtherTypes, 0x86dd, senf::IPv6Packet); 00040 SENF_PACKET_REGISTRY_REGISTER( senf::IpTypes, 41, senf::IPv6Packet); // IP6-in-IP(6) encapsulation 00041 } 00042 00043 prefix_ void senf::IPv6PacketType::dump(packet p, std::ostream & os) 00044 { 00045 boost::io::ios_all_saver ias(os); 00046 os << "Internet protocol Version 6:\n" 00047 << senf::fieldName("version") << unsigned(p->version()) << "\n" 00048 << senf::fieldName("traffic class") 00049 << "0x" << std::hex << std::setw(2) << std::setfill('0') << std::right << unsigned(p->trafficClass()) << "\n" 00050 << senf::fieldName("flow label") 00051 << "0x" << std::hex << std::setw(5) << std::setfill('0') << std::right << unsigned(p->flowLabel()) << "\n" 00052 << senf::fieldName("payload length") << std::dec << unsigned(p->length()) << "\n" 00053 << senf::fieldName("next header") << unsigned(p->nextHeader()) << "\n" 00054 << senf::fieldName("hop limit") << unsigned(p->hopLimit()) << "\n" 00055 << senf::fieldName("source") << p->source() << "\n" 00056 << senf::fieldName("destination") << p->destination() << "\n"; 00057 } 00058 00059 prefix_ void senf::IPv6PacketType::finalize(packet p) 00060 { 00061 p->length() << (p.size() - IPv6PacketParser::fixed_bytes); 00062 try { 00063 p->nextHeader() << key(p.next()); 00064 } 00065 catch (InvalidPacketChainException & ex) { 00066 p->nextHeader() << 59; // No next header 00067 } 00068 } 00069 00070 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00071 #undef prefix_ 00072 //#include "IPv6Packet.mpp" 00073 00074 00075 // Local Variables: 00076 // mode: c++ 00077 // fill-column: 100 00078 // c-file-style: "senf" 00079 // indent-tabs-mode: nil 00080 // ispell-local-dictionary: "american" 00081 // compile-command: "scons -u test" 00082 // comment-column: 40 00083 // End: