prefix_ void senf::MPLSPacketType::finalize(packet p)
{
+ if (p.prev(senf::nothrow).is<MPLSPacket>()) //not the last label on the MPLS stack
+ p->s_() << false;
+ else
+ p->s_() << true;
}
///////////////////////////////cc.e////////////////////////////////////////
SENF_PARSER_BITFIELD( label, 20, unsigned);
SENF_PARSER_BITFIELD( tc, 3, unsigned);
- SENF_PARSER_BITFIELD( s, 1, bool);
+ SENF_PARSER_BITFIELD_RO( s, 1, bool);
SENF_PARSER_FIELD( ttl, UInt8Parser);
SENF_PARSER_FINALIZE(MPLSPacketParser);
+
+ friend class MPLSPacketType;
};
/** \brief MPLS packet
\par Fields:
\ref MPLSPacketParser
-
+
\ingroup protocolbundle_default
*/
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 dump(packet p, std::ostream & os);
static void finalize(packet p);
};
//#include "MPLSPacket.cti"
#endif
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
// Custom includes
#include "MPLSPacket.hh"
+#include "EthernetPacket.hh"
#include "../../Utils/auto_unit_test.hh"
BOOST_AUTO_UNIT_TEST(mplsPacket_create)
{
- senf::MPLSPacket p (senf::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->s()=true;
p->tc()=0x0u;
- SENF_CHECK_NO_THROW(p.finalizeThis());
+ 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<senf::MPLSPacket>() );
+ BOOST_REQUIRE( p.next().is<senf::MPLSPacket>() );
+ BOOST_CHECK( p->s());
+ BOOST_CHECK( !p2->s());
}