From: cni Date: Thu, 9 Jul 2009 12:02:04 +0000 (+0000) Subject: Packets/DefaultBundle: moved MPLSPacket to NetEmu/Carmen project X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=6c81150d4758ca9b843923245e7586bcb9e4b9d5;p=senf.git Packets/DefaultBundle: moved MPLSPacket to NetEmu/Carmen project git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1263 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Packets/DefaultBundle/MPLSPacket.cc b/Packets/DefaultBundle/MPLSPacket.cc deleted file mode 100644 index 543d709..0000000 --- a/Packets/DefaultBundle/MPLSPacket.cc +++ /dev/null @@ -1,84 +0,0 @@ -// $Id$ -// -// Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY -// Christian Niephaus -// -// 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 -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -/** \file - \brief MPLSPacket non-inline non-template implementation */ - -#include "MPLSPacket.hh" -//#include "MPLSPacket.ih" - -// Custom includes -#include -#include - -#include "EthernetPacket.hh" - -#define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// - -namespace { - senf::PacketRegistry::RegistrationProxy - registerMPLSPacket (0x8848); -} - - -// senf::MPLSPacketType - -prefix_ void senf::MPLSPacketType::dump(packet p, std::ostream & os) -{ - boost::io::ios_all_saver ias(os); - os << "MPLS Header: \n" - << " label : " << p->label() << "\n" - << " traffic class : " << p->tc() << "\n" - << " bottom of stack : " << p->s() << "\n" - << " Time-to-live : " << p->ttl() << "\n"; -} - -prefix_ senf::PacketInterpreterBase::factory_t senf::MPLSPacketType::nextPacketType(packet p) -{ - if (p->s()) //last MPLS header - return no_factory(); - else - return MPLSPacket::factory(); -} - -prefix_ void senf::MPLSPacketType::finalize(packet p) -{ - if (p.prev(senf::nothrow).is()) //not the last label on the MPLS stack - p->s_() << false; - else - p->s_() << true; -} - -///////////////////////////////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: diff --git a/Packets/DefaultBundle/MPLSPacket.hh b/Packets/DefaultBundle/MPLSPacket.hh deleted file mode 100644 index 9b1d2ab..0000000 --- a/Packets/DefaultBundle/MPLSPacket.hh +++ /dev/null @@ -1,114 +0,0 @@ -// $Id$ -// -// Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY -// Christian Niephaus -// -// 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 -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -/** \file - \brief MPLSPacket public header */ - -#ifndef HH_SENF_Packets_DefaultBundle_MPLSPacket_ -#define HH_SENF_Packets_DefaultBundle_MPLSPacket_ 1 - -// Custom includes - -#include "../../Packets/Packets.hh" - -//#include "MPLSPacket.mpp" -///////////////////////////////hh.p//////////////////////////////////////// - -namespace senf { - - /** \brief Parse an MPLS packet - - Parser implementing an MPLS header. - - \image html MPLSPacket.png - - \see MPLSPacketType - */ - struct MPLSPacketParser : public PacketParserBase - { -# include SENF_FIXED_PARSER() - - SENF_PARSER_BITFIELD( label, 20, unsigned); - SENF_PARSER_BITFIELD( tc, 3, unsigned); - SENF_PARSER_BITFIELD_RO( s, 1, bool); - SENF_PARSER_FIELD( ttl, UInt8Parser); - - SENF_PARSER_FINALIZE(MPLSPacketParser); - - friend class MPLSPacketType; - }; - - /** \brief MPLS packet - - \par Packet type (typedef): - \ref MPLSPacket - - \par Fields: - \ref MPLSPacketParser - - - \ingroup protocolbundle_default - */ - struct MPLSPacketType - : public PacketTypeBase, - public PacketTypeMixin - { -#ifndef DOXYGEN - typedef PacketTypeMixin mixin; -#endif - typedef ConcretePacket packet; - typedef MPLSPacketParser parser; - - using mixin::nextPacketRange; - using mixin::initSize; - using mixin::init; - - static factory_t nextPacketType(packet p); - /// Dump given MPLSPacket in readable form to given output stream - static void dump(packet p, std::ostream & os); - static void finalize(packet p); - }; - - /** \brief MPLS packet typedef */ - typedef ConcretePacket MPLSPacket; - - -} - -///////////////////////////////hh.e//////////////////////////////////////// -#endif -#ifndef SENF_PACKETS_DECL_ONLY -//#include "MPLSPacket.cci" -//#include "MPLSPacket.ct" -//#include "MPLSPacket.cti" -#endif - - -// 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: diff --git a/Packets/DefaultBundle/MPLSPacket.test.cc b/Packets/DefaultBundle/MPLSPacket.test.cc deleted file mode 100644 index a81d35f..0000000 --- a/Packets/DefaultBundle/MPLSPacket.test.cc +++ /dev/null @@ -1,112 +0,0 @@ -// $Id$ -// -// Copyright (C) 2006 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY -// Christian Niephaus -// -// 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 -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -/** \file - \brief MPLSPacket unit tests */ - -//#include "MPLSPacket.test.hh" -//#include "MPLSPacket.test.ih" - -// Custom includes -#include "MPLSPacket.hh" -#include "EthernetPacket.hh" - - -#include "../../Utils/auto_unit_test.hh" -#include - -#define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// - -BOOST_AUTO_UNIT_TEST(mplsPacket_parse) -{ - senf::PacketData::byte data[] = { - 0x00, 0x3e, 0x90, 0x80, //1st mpls header - 0x00, 0x3e, 0xb1, 0x80, // last mpls header - 0x00 //data - }; - senf::MPLSPacket p (senf::MPLSPacket::create(data)); - - BOOST_CHECK_EQUAL( p->label(), 1001u); - BOOST_CHECK_EQUAL( p->tc(), 0u ); - BOOST_CHECK( !p->s()); - BOOST_CHECK_EQUAL( p->ttl(), 128u ); - - std::ostringstream oss (std::ostringstream::out); - SENF_CHECK_NO_THROW( p.dump( oss)); -} - -BOOST_AUTO_UNIT_TEST(mplsPacket_parse_chain) -{ - senf::PacketData::byte data[] = { - 0x00, 0x3e, 0x90, 0x80, //1st mpls header - 0x00, 0x3e, 0xb1, 0x80, // last mpls header - 0x00 //data - }; - - senf::MPLSPacket p (senf::MPLSPacket::create(data)); - - BOOST_REQUIRE( p.next().is() ); - senf::MPLSPacket p2 (p.next().as()); - BOOST_CHECK( p2->s()); - BOOST_REQUIRE( p2.next().is() ); -} - -BOOST_AUTO_UNIT_TEST(mplsPacket_create) -{ - senf::EthernetPacket eth (senf::EthernetPacket::create()); - eth->source() = senf::MACAddress::from_string("01:02:03:04:05:06"); - eth->destination() = senf::MACAddress::from_string("07:08:09:0a:0b:0c"); - - senf::MPLSPacket p (senf::MPLSPacket::createAfter(eth)); - p->label()=4444u; - p->ttl()=10u; - p->tc()=0x0u; - - senf::MPLSPacket p2 (senf::MPLSPacket::createAfter(p)); - p->label()=5555u; - p->ttl()=10u; - p->tc()=0x0u; - - SENF_CHECK_NO_THROW(eth.finalizeAll()); - - BOOST_REQUIRE( eth.next().is() ); - BOOST_REQUIRE( p.next().is() ); - BOOST_CHECK( p->s()); - BOOST_CHECK( !p2->s()); - -} - - -///////////////////////////////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: