X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FICMPv6Packet.cc;h=9d5d104b51770342bdfd7f215401c43d662d7bbe;hb=a1fdb7bb122f0b05be809a922d4b7ef5e125fa67;hp=719b8d9cd4bbc2d91355c3a9b44572400f26575f;hpb=ccc827edda90ace7d2f8564660ee26b09a5a23b5;p=senf.git diff --git a/Packets/DefaultBundle/ICMPv6Packet.cc b/Packets/DefaultBundle/ICMPv6Packet.cc index 719b8d9..9d5d104 100644 --- a/Packets/DefaultBundle/ICMPv6Packet.cc +++ b/Packets/DefaultBundle/ICMPv6Packet.cc @@ -1,7 +1,9 @@ +// $Id$ +// // Copyright (C) 2008 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY -// Philipp Batroff +// Philipp Batroff // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -18,24 +20,34 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Custom includes -#include "../../Packets/Packets.hh" +/** \file + \brief ICMPv6Packet non-inline non-template implementation */ + #include "ICMPv6Packet.hh" +//#include "ICMPv6Packet.ih" + +// Custom includes #include #include "../../Packets/DefaultBundle/IPv6Packet.hh" #include "../../Utils/IpChecksum.hh" #define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// namespace { senf::PacketRegistry::RegistrationProxy registerICMPv6Packet (58); } -prefix_ void senf::ICMPV6PacketParser::calcChecksum() const { +prefix_ boost::uint16_t senf::ICMPv6PacketParser::calcChecksum() + const +{ senf::IpChecksum summer; senf::IPv6Packet ipv6 (packet().rfind(senf::nothrow)); + + if (! ipv6) + return 0u; summer.feed( ipv6->source().i(), ipv6->source().i() + senf::IPv6Packet::Parser::source_t::fixed_bytes ); @@ -55,16 +67,28 @@ prefix_ void senf::ICMPV6PacketParser::calcChecksum() const { summer.feed( i()+checksum_offset+2, data().end() ); boost::uint16_t rv (summer.sum()); - this->checksum() << (rv ? rv : 0xffffu); + return rv ? rv : 0xffffu; } -prefix_ void senf::ICMPV6PacketType::dump(packet p, std::ostream &os) +prefix_ void senf::ICMPv6PacketType::dump(packet p, std::ostream &os) { boost::io::ios_all_saver ias(os); os << "ICMPv6 protocol:\n" - << "Type : " << p->type() <<"\n" - << "Code : " << p->code() <<"\n" - << "Checksum : " << p->checksumOutput() << "\n"; + << "Type : " << p->type() <<"\n" + << "Code : " << p->code() <<"\n" + << "Checksum : " << p->checksum() << "\n"; } +///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 +// End: