added TCPPacket implemented by Dennis.
[senf.git] / Packets / DefaultBundle / IPv6Packet.cc
index 18ca266..4599276 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
 // Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,6 @@
 #include <iomanip>
 #include <boost/io/ios_state.hpp>
 #include "EthernetPacket.hh"
-#include "../../Socket/Protocols/INet/INetAddressing.hh"
 
 //#include "IPv6Packet.mpp"
 #define prefix_
@@ -42,31 +41,33 @@ namespace {
 
     senf::PacketRegistry<senf::IpTypes>::RegistrationProxy<senf::IPv6Packet>
         registerIPv6Packet2 (41); // IP6-in-IP(6) encapsulation
-
-    senf::PacketRegistry<senf::IpTypes>::RegistrationProxy<senf::DataPacket>
-        registerNoNextHeader (59);
 }
 
 prefix_ void senf::IPv6PacketType::dump(packet p, std::ostream & os)
 {
     boost::io::ios_all_saver ias(os);
-    os << "Internet protocol Version 6:\n"
-       << "  version        : " << unsigned(p->version()) << "\n"
-       << "  traffic class  : 0x" 
+    os <<     "Internet protocol Version 6:\n"
+       <<     "  version                 : " << unsigned(p->version()) << "\n"
+       <<     "  traffic class           : 0x" 
          << std::hex << std::setw(2) << std::setfill('0') << unsigned(p->trafficClass()) << "\n"
-       << "  flow label     : 0x" 
+       <<     "  flow label              : 0x" 
          << std::hex << std::setw(5) << std::setfill('0') << unsigned(p->flowLabel()) << "\n"
-       << "  payload length : " << std::dec << unsigned(p->length()) << "\n"
-       << "  next header    : " << unsigned(p->nextHeader()) << "\n"
-       << "  hop limit      : " << unsigned(p->hopLimit()) << "\n"
-       << "  source         : " << p->source() << "\n"
-       << "  destination    : " << p->destination() << "\n";
+       <<     "  payload length          : " << std::dec << unsigned(p->length()) << "\n"
+       <<     "  next header             : " << unsigned(p->nextHeader()) << "\n"
+       <<     "  hop limit               : " << unsigned(p->hopLimit()) << "\n"
+       <<     "  source                  : " << p->source() << "\n"
+       <<     "  destination             : " << p->destination() << "\n";
 }
 
 prefix_ void senf::IPv6PacketType::finalize(packet p)
 {
     p->length() << (p.size() - IPv6PacketParser::fixed_bytes);
-    p->nextHeader() << key(p.next());
+    try {
+        p->nextHeader() << key(p.next());
+    }
+    catch (InvalidPacketChainException & ex) {
+        p->nextHeader() << 59; // No next header
+    }
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////